@uipath/context-grounding-tool 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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata,
5
5
  registerCommands
6
- } from "./tool-rfxscr39.js";
6
+ } from "./tool-ab2qbker.js";
7
7
  import"./tool-1de529jm.js";
8
8
 
9
9
  // src/index.ts
@@ -2864,6 +2864,57 @@ function settlePromiseLike(thenable) {
2864
2864
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
2865
2865
  }
2866
2866
 
2867
+ // ../common/src/error-graph.ts
2868
+ function* walkErrorGraph(error) {
2869
+ const queue = [error];
2870
+ const seen = new Set;
2871
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
2872
+ const current = queue.shift();
2873
+ if (current === null || typeof current !== "object")
2874
+ continue;
2875
+ if (seen.has(current))
2876
+ continue;
2877
+ seen.add(current);
2878
+ const cur = current;
2879
+ yield cur;
2880
+ if (cur.cause !== undefined)
2881
+ queue.push(cur.cause);
2882
+ if (Array.isArray(cur.errors))
2883
+ queue.push(...cur.errors);
2884
+ }
2885
+ return;
2886
+ }
2887
+ function parseHttpStatusFromMessage(message) {
2888
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
2889
+ if (!match)
2890
+ return;
2891
+ const status = Number(match[1]);
2892
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
2893
+ }
2894
+ function findHttpStatusInGraph(error) {
2895
+ for (const node of walkErrorGraph(error)) {
2896
+ const response = node.response;
2897
+ const explicit = typeof node.status === "number" ? node.status : response?.status;
2898
+ if (typeof explicit === "number" && explicit >= 400 && explicit <= 599) {
2899
+ return explicit;
2900
+ }
2901
+ if (typeof node.message === "string") {
2902
+ const parsed = parseHttpStatusFromMessage(node.message);
2903
+ if (parsed !== undefined && parsed >= 400) {
2904
+ return parsed;
2905
+ }
2906
+ }
2907
+ }
2908
+ return;
2909
+ }
2910
+
2911
+ // ../common/src/local-permission-codes.ts
2912
+ var LOCAL_PERMISSION_ERROR_CODES = new Set([
2913
+ "EACCES",
2914
+ "EPERM",
2915
+ "EROFS"
2916
+ ]);
2917
+
2867
2918
  // ../common/src/error-handler.ts
2868
2919
  var NETWORK_ERROR_CODES = new Set([
2869
2920
  "ECONNREFUSED",
@@ -2888,7 +2939,7 @@ var TLS_ERROR_CODES = new Set([
2888
2939
  ]);
2889
2940
  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.";
2890
2941
  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.";
2891
- var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
2942
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = new RegExp(`\\b(${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})\\b`);
2892
2943
  // ../common/src/exit-code.ts
2893
2944
  function setExitCode(code) {
2894
2945
  process.exitCode = code;
@@ -3150,12 +3201,162 @@ function getOutputFilter() {
3150
3201
  return filterSlot.get();
3151
3202
  }
3152
3203
 
3204
+ // ../common/src/telemetry/telemetry-dimensions.ts
3205
+ var BaseDimensions = {
3206
+ ApplicationName: "ApplicationName",
3207
+ ProductVersion: "ProductVersion",
3208
+ InstallationId: "InstallationId",
3209
+ CloudUserId: "CloudUserId",
3210
+ CloudTenantId: "CloudTenantId",
3211
+ CloudOrganizationId: "CloudOrganizationId",
3212
+ IsInternalUser: "IsInternalUser",
3213
+ Environment: "Environment",
3214
+ BaseUrl: "BaseUrl",
3215
+ Region: "Region",
3216
+ Agent: "Agent",
3217
+ AgentVersion: "AgentVersion",
3218
+ AgentModel: "AgentModel",
3219
+ ToolName: "ToolName",
3220
+ ToolVersion: "ToolVersion",
3221
+ ExecutionContext: "ExecutionContext",
3222
+ CiProvider: "CiProvider",
3223
+ SessionIdSource: "SessionIdSource",
3224
+ SessionId: "SessionId"
3225
+ };
3226
+ var CommandDimensions = {
3227
+ IsCommand: "IsCommand",
3228
+ IsReexec: "IsReexec",
3229
+ CommandName: "CommandName",
3230
+ ExitCode: "ExitCode",
3231
+ TerminalOutcome: "TerminalOutcome",
3232
+ ErrorClass: "ErrorClass",
3233
+ TerminalSignal: "TerminalSignal",
3234
+ ErrorMessage: "ErrorMessage",
3235
+ SkillName: "SkillName",
3236
+ ProductArea: "ProductArea",
3237
+ Mode: "Mode"
3238
+ };
3239
+ var ShipDimensions = {
3240
+ ShipKind: "ShipKind",
3241
+ Target: "Target",
3242
+ ProjectType: "ProjectType",
3243
+ ProjectTypes: "ProjectTypes",
3244
+ ArtifactCorrelationKey: "ArtifactCorrelationKey",
3245
+ PackageName: "PackageName",
3246
+ PackageVersion: "PackageVersion",
3247
+ PackageVersionKey: "PackageVersionKey",
3248
+ DeploymentKey: "DeploymentKey",
3249
+ SolutionId: "SolutionId",
3250
+ FolderKey: "FolderKey",
3251
+ FeedId: "FeedId"
3252
+ };
3253
+ var ErrorDimensions = {
3254
+ Result: "Result",
3255
+ ErrorCode: "ErrorCode",
3256
+ Retry: "Retry",
3257
+ ErrorMessage: "ErrorMessage"
3258
+ };
3259
+ var AuthDimensions = {
3260
+ AuthenticationMethod: "AuthenticationMethod",
3261
+ Success: "Success",
3262
+ Reason: "Reason"
3263
+ };
3264
+ var SkillsDimensions = {
3265
+ SchemaVersion: "SchemaVersion",
3266
+ AgentType: "AgentType",
3267
+ SkillsVersion: "SkillsVersion",
3268
+ UipSubcommand: "UipSubcommand",
3269
+ FileExtension: "FileExtension",
3270
+ SubagentModel: "SubagentModel",
3271
+ SubagentType: "SubagentType",
3272
+ PermissionMode: "PermissionMode",
3273
+ EffortLevel: "EffortLevel",
3274
+ SessionSource: "SessionSource",
3275
+ Outcome: "Outcome",
3276
+ DurationMs: "DurationMs",
3277
+ Source: "Source"
3278
+ };
3279
+ var PackagerDimensions = {
3280
+ ProjectId: "ProjectId",
3281
+ ProjectType: "ProjectType",
3282
+ SolutionId: "SolutionId"
3283
+ };
3284
+ var ScopeDimensions = {
3285
+ FolderId: "FolderId"
3286
+ };
3287
+ var ID_DIMENSIONS = new Set([
3288
+ BaseDimensions.CloudUserId,
3289
+ BaseDimensions.CloudTenantId,
3290
+ BaseDimensions.CloudOrganizationId,
3291
+ BaseDimensions.InstallationId,
3292
+ ShipDimensions.ArtifactCorrelationKey,
3293
+ ShipDimensions.PackageVersionKey,
3294
+ ShipDimensions.DeploymentKey,
3295
+ ShipDimensions.SolutionId,
3296
+ ShipDimensions.FolderKey,
3297
+ ShipDimensions.FeedId,
3298
+ PackagerDimensions.ProjectId
3299
+ ]);
3300
+ var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
3301
+ var RESERVED_DIMENSION_NAMES = new Set([
3302
+ ...Object.values(BaseDimensions),
3303
+ ...Object.values(CommandDimensions),
3304
+ ...Object.values(ShipDimensions),
3305
+ ...Object.values(ErrorDimensions),
3306
+ ...Object.values(AuthDimensions),
3307
+ ...Object.values(SkillsDimensions),
3308
+ ...Object.values(PackagerDimensions),
3309
+ ...Object.values(ScopeDimensions)
3310
+ ]);
3311
+ var CURATED_DIMENSIONS = new Set([
3312
+ BaseDimensions.ApplicationName,
3313
+ BaseDimensions.ProductVersion,
3314
+ BaseDimensions.InstallationId,
3315
+ BaseDimensions.CloudUserId,
3316
+ BaseDimensions.CloudTenantId,
3317
+ BaseDimensions.CloudOrganizationId,
3318
+ BaseDimensions.IsInternalUser,
3319
+ BaseDimensions.Environment,
3320
+ BaseDimensions.BaseUrl,
3321
+ BaseDimensions.Region,
3322
+ BaseDimensions.Agent,
3323
+ BaseDimensions.AgentVersion,
3324
+ BaseDimensions.ToolVersion,
3325
+ BaseDimensions.ExecutionContext,
3326
+ BaseDimensions.CiProvider,
3327
+ BaseDimensions.SessionIdSource,
3328
+ BaseDimensions.SessionId,
3329
+ ...Object.values(CommandDimensions),
3330
+ ...Object.values(ShipDimensions)
3331
+ ]);
3332
+ function lowercaseIdDimensionValues(properties) {
3333
+ let changed = false;
3334
+ const result = {
3335
+ ...properties
3336
+ };
3337
+ for (const key of Object.keys(result)) {
3338
+ const value = result[key];
3339
+ if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
3340
+ continue;
3341
+ }
3342
+ const lowered = value.toLowerCase();
3343
+ if (lowered !== value) {
3344
+ result[key] = lowered;
3345
+ changed = true;
3346
+ }
3347
+ }
3348
+ return changed ? result : properties;
3349
+ }
3350
+
3153
3351
  // ../common/src/telemetry/command-terminal.ts
3154
3352
  var recordedFailureSlot = singleton("CommandTelemetryFailure");
3155
3353
  var AUTH_ERROR_CODES = new Set([
3156
3354
  "authentication_required",
3157
3355
  "permission_denied"
3158
3356
  ]);
3357
+ var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
3358
+ "local_permission_denied"
3359
+ ]);
3159
3360
  var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
3160
3361
  var NETWORK_HTTP_ERROR_CODES = new Set([
3161
3362
  "network_error",
@@ -3296,6 +3497,9 @@ function classifyFromErrorCode(errorCode) {
3296
3497
  if (AUTH_ERROR_CODES.has(errorCode)) {
3297
3498
  return "auth";
3298
3499
  }
3500
+ if (LOCAL_PERMISSION_CLI_ERROR_CODES.has(errorCode)) {
3501
+ return "local_permission";
3502
+ }
3299
3503
  if (VALIDATION_ERROR_CODES.has(errorCode)) {
3300
3504
  return "validation";
3301
3505
  }
@@ -3307,6 +3511,15 @@ function classifyFromErrorCode(errorCode) {
3307
3511
  }
3308
3512
  return;
3309
3513
  }
3514
+ function hasLocalPermissionCode(error) {
3515
+ for (const node of walkErrorGraph(error)) {
3516
+ const code = node.code;
3517
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
3518
+ return true;
3519
+ }
3520
+ }
3521
+ return false;
3522
+ }
3310
3523
  function classifyFromError(error) {
3311
3524
  const code = findCodeInCauseChain(error);
3312
3525
  if (code) {
@@ -3323,6 +3536,9 @@ function classifyFromError(error) {
3323
3536
  return "missing_dependency";
3324
3537
  }
3325
3538
  }
3539
+ if (hasLocalPermissionCode(error)) {
3540
+ return "local_permission";
3541
+ }
3326
3542
  const message = stringField(error, "message");
3327
3543
  if (message?.includes("fetch failed") === true) {
3328
3544
  return "network_http";
@@ -3338,7 +3554,7 @@ function classifyError(input) {
3338
3554
  if (recorded?.errorClass) {
3339
3555
  return recorded.errorClass;
3340
3556
  }
3341
- const status = recorded?.context?.httpStatus;
3557
+ const status = recorded?.context?.httpStatus ?? findHttpStatusInGraph(input.error);
3342
3558
  if (status !== undefined) {
3343
3559
  return classifyHttpStatus(status);
3344
3560
  }
@@ -3361,17 +3577,18 @@ function buildCommandTerminalTelemetryProperties(input) {
3361
3577
  const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError(input);
3362
3578
  const terminalSignal = terminalSignalFor(input, outcome);
3363
3579
  return {
3364
- exit_code: input.exitCode,
3365
- terminal_outcome: outcome,
3366
- ...errorClass ? { error_class: errorClass } : {},
3367
- ...terminalSignal ? { terminal_signal: terminalSignal } : {}
3580
+ [CommandDimensions.ExitCode]: input.exitCode,
3581
+ [CommandDimensions.TerminalOutcome]: outcome,
3582
+ ...errorClass ? { [CommandDimensions.ErrorClass]: errorClass } : {},
3583
+ ...terminalSignal ? { [CommandDimensions.TerminalSignal]: terminalSignal } : {}
3368
3584
  };
3369
3585
  }
3370
3586
 
3371
3587
  // ../common/src/telemetry/telemetry-events.ts
3372
3588
  var CommonTelemetryEvents = {
3373
- Error: "uip.error",
3374
- ShipSucceeded: "uip.ship.succeeded"
3589
+ Start: "Application.Start",
3590
+ Error: "Application.Error",
3591
+ ShipSucceeded: "Cli.ShipSucceeded"
3375
3592
  };
3376
3593
 
3377
3594
  // ../common/src/registry.ts
@@ -3579,8 +3796,8 @@ function detectExecutionContext(options = {}) {
3579
3796
  function getExecutionContextTelemetryProperties() {
3580
3797
  const detected = detectExecutionContext();
3581
3798
  return {
3582
- execution_context: detected.executionContext,
3583
- ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
3799
+ [BaseDimensions.ExecutionContext]: detected.executionContext,
3800
+ ...detected.ciProvider ? { [BaseDimensions.CiProvider]: detected.ciProvider } : {}
3584
3801
  };
3585
3802
  }
3586
3803
  // ../common/src/telemetry/node-context-storage.ts
@@ -3623,7 +3840,7 @@ function getInboundTraceContext() {
3623
3840
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
3624
3841
  var SESSION_ID_MAX_LENGTH = 64;
3625
3842
  var RANDOM_SESSION_ID_LENGTH = 32;
3626
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
3843
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
3627
3844
  var CONTROL_CHARACTERS = /\p{Cc}/gu;
3628
3845
  var INHERITED_SESSION_SOURCES = [
3629
3846
  { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
@@ -3675,6 +3892,9 @@ function resolveTelemetrySession() {
3675
3892
  telemetrySessionSlot.set(resolved);
3676
3893
  return resolved;
3677
3894
  }
3895
+ function getTelemetrySessionId() {
3896
+ return resolveTelemetrySession().id;
3897
+ }
3678
3898
  function getTelemetrySessionSource() {
3679
3899
  return resolveTelemetrySession().source;
3680
3900
  }
@@ -3755,7 +3975,10 @@ class TelemetryService {
3755
3975
  } catch (error) {
3756
3976
  const durationMs = clock.elapsedMs();
3757
3977
  const err = error instanceof Error ? error : new Error(String(error));
3758
- await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, context));
3978
+ await this.telemetryProvider.trackRequest(this.spanFor(name, durationMs, false, {
3979
+ ...properties,
3980
+ [CommandDimensions.ErrorMessage]: err.message
3981
+ }, context));
3759
3982
  throw error;
3760
3983
  }
3761
3984
  }
@@ -3826,7 +4049,10 @@ class TelemetryService {
3826
4049
  const durationMs = clock.elapsedMs();
3827
4050
  const err = error instanceof Error ? error : new Error(String(error));
3828
4051
  await this.telemetryProvider.trackDependency({
3829
- ...this.spanFor(name, durationMs, false, { ...properties, errorMessage: err.message }, childContext),
4052
+ ...this.spanFor(name, durationMs, false, {
4053
+ ...properties,
4054
+ [CommandDimensions.ErrorMessage]: err.message
4055
+ }, childContext),
3830
4056
  type
3831
4057
  });
3832
4058
  throw error;
@@ -3861,9 +4087,10 @@ class TelemetryService {
3861
4087
  ...globalProperties,
3862
4088
  ...this.defaultProperties,
3863
4089
  ...redactProperties(properties ?? {}),
3864
- [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource()
4090
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
4091
+ [BaseDimensions.SessionId]: this.telemetryProvider.getSessionId?.() ?? getTelemetrySessionId()
3865
4092
  };
3866
- return enriched;
4093
+ return lowercaseIdDimensionValues(enriched);
3867
4094
  }
3868
4095
  generateId() {
3869
4096
  const bytes = new Uint8Array(8);
@@ -4624,7 +4851,165 @@ class FilterImplicitLimitError extends Error {
4624
4851
  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).";
4625
4852
  }
4626
4853
  }
4627
- function applyFilter(data, filter) {
4854
+ function countRecords(data) {
4855
+ if (Array.isArray(data))
4856
+ return data.length;
4857
+ return data == null ? 0 : 1;
4858
+ }
4859
+ function availableFields(data) {
4860
+ const records = Array.isArray(data) ? data : [data];
4861
+ const keys = new Set;
4862
+ for (const record of records) {
4863
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4864
+ for (const key of Object.keys(record))
4865
+ keys.add(key);
4866
+ }
4867
+ }
4868
+ return [...keys];
4869
+ }
4870
+ function decodeQuotedIdentifier(whole, inner) {
4871
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4872
+ if (!error && typeof decoded === "string")
4873
+ return decoded;
4874
+ return inner.replace(/\\(.)/g, "$1");
4875
+ }
4876
+ function referencedFields(filter) {
4877
+ const top = new Set;
4878
+ const nested = new Set;
4879
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4880
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4881
+ const quoted = [];
4882
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4883
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4884
+ if (!isAlias) {
4885
+ quoted.push({
4886
+ name: decodeQuotedIdentifier(whole, name),
4887
+ index,
4888
+ tail: isPathTail(withoutValueLiterals, index)
4889
+ });
4890
+ }
4891
+ return `"${" ".repeat(whole.length - 2)}"`;
4892
+ });
4893
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4894
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4895
+ const place = (name, index, tail) => {
4896
+ if (tail || index >= rootEnd)
4897
+ nested.add(name);
4898
+ else
4899
+ top.add(name);
4900
+ };
4901
+ for (const entry of quoted)
4902
+ place(entry.name, entry.index, entry.tail);
4903
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4904
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4905
+ for (const match of identifiers) {
4906
+ const [, name, trailing] = match;
4907
+ if (trailing || reserved.has(name))
4908
+ continue;
4909
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4910
+ }
4911
+ return {
4912
+ top: [...top],
4913
+ nested: [...nested].filter((name) => !top.has(name)),
4914
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4915
+ };
4916
+ }
4917
+ function appearsBelowTopLevel(data, name) {
4918
+ let budget = 2000;
4919
+ const visit = (value, depth) => {
4920
+ if (budget-- <= 0 || depth > 4)
4921
+ return false;
4922
+ if (value === null || typeof value !== "object")
4923
+ return false;
4924
+ if (Array.isArray(value))
4925
+ return value.some((entry) => visit(entry, depth));
4926
+ const record = value;
4927
+ if (depth > 0 && Object.hasOwn(record, name))
4928
+ return true;
4929
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4930
+ };
4931
+ return visit(data, 0);
4932
+ }
4933
+ function alwaysNullKeys(records) {
4934
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4935
+ if (objects.length === 0 || objects.length !== records.length)
4936
+ return [];
4937
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4938
+ if (keys.length === 0)
4939
+ return [];
4940
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4941
+ return nullKeys.length === keys.length ? nullKeys : [];
4942
+ }
4943
+ function carriesOnlyNulls(value) {
4944
+ if (value === null)
4945
+ return true;
4946
+ if (Array.isArray(value)) {
4947
+ return value.length > 0 && value.every(carriesOnlyNulls);
4948
+ }
4949
+ if (typeof value === "object" && value !== undefined) {
4950
+ const values = Object.values(value);
4951
+ return values.length > 0 && values.every(carriesOnlyNulls);
4952
+ }
4953
+ return false;
4954
+ }
4955
+ function nameList(names, cap2 = 12) {
4956
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4957
+ const rest = names.length - shown.length;
4958
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4959
+ }
4960
+ function buildFilterWarning(filter, data, outcome) {
4961
+ const present = availableFields(data);
4962
+ const refs = referencedFields(filter);
4963
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4964
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4965
+ const count = countRecords(data);
4966
+ const scope = `${count} record(s)`;
4967
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4968
+ 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" : "";
4969
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4970
+ let detail;
4971
+ let lede;
4972
+ if (outcome.kind === "null-elements") {
4973
+ lede = "returned only null values";
4974
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4975
+ if (unknown.length > 0) {
4976
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4977
+ } else if (unchecked.length > 0) {
4978
+ detail = withSoundness(projected);
4979
+ } else {
4980
+ 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`;
4981
+ }
4982
+ } else if (outcome.kind === "null-rows") {
4983
+ lede = "returned only null values";
4984
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4985
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4986
+ } else if (outcome.kind === "null-values") {
4987
+ lede = "returned only null values";
4988
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4989
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4990
+ if (sameSet) {
4991
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4992
+ } else if (unknown.length > 0) {
4993
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4994
+ } else {
4995
+ detail = withSoundness(`${projected} on all ${scope}`);
4996
+ }
4997
+ } else {
4998
+ lede = "returned nothing";
4999
+ if (unknown.length > 0) {
5000
+ detail = isNotAField(unknown);
5001
+ } else {
5002
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
5003
+ detail = withSoundness(`${selection} — it read ${scope}`);
5004
+ }
5005
+ }
5006
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
5007
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
5008
+ }
5009
+ function appendWarning(existing, note) {
5010
+ return existing ? `${existing} ${note}` : note;
5011
+ }
5012
+ function applyFilter(data, filter, onWarning) {
4628
5013
  const codec = requireJmespath();
4629
5014
  let result;
4630
5015
  try {
@@ -4632,9 +5017,34 @@ function applyFilter(data, filter) {
4632
5017
  } catch (err) {
4633
5018
  throw new FilterEvaluationError(filter, err);
4634
5019
  }
4635
- if (result == null)
5020
+ const inputCount = countRecords(data);
5021
+ const warn = (outcome) => {
5022
+ if (inputCount === 0)
5023
+ return;
5024
+ const note = buildFilterWarning(filter, data, outcome);
5025
+ getOutputSink().writeErr(`[WARN] ${note}
5026
+ `);
5027
+ onWarning?.(note);
5028
+ };
5029
+ const warnIfAllNull = (records) => {
5030
+ const keys = alwaysNullKeys(records);
5031
+ if (keys.length > 0)
5032
+ warn({ kind: "null-values", keys });
5033
+ };
5034
+ if (result == null) {
5035
+ warn({ kind: "empty" });
4636
5036
  return [];
5037
+ }
4637
5038
  if (Array.isArray(result)) {
5039
+ if (result.length === 0) {
5040
+ warn({ kind: "empty" });
5041
+ } else if (result.every((entry) => entry === null)) {
5042
+ warn({ kind: "null-elements", count: result.length });
5043
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
5044
+ warn({ kind: "null-rows", count: result.length });
5045
+ } else {
5046
+ warnIfAllNull(result);
5047
+ }
4638
5048
  if (result.length > 0 && typeof result[0] !== "object") {
4639
5049
  const fieldMatch = filter.match(/\.(\w+)$/);
4640
5050
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4642,10 +5052,30 @@ function applyFilter(data, filter) {
4642
5052
  }
4643
5053
  return result;
4644
5054
  }
4645
- if (typeof result === "object")
5055
+ if (typeof result === "object") {
5056
+ warnIfAllNull([result]);
4646
5057
  return result;
5058
+ }
4647
5059
  return { Value: result };
4648
5060
  }
5061
+ function filterFailureData(envelope) {
5062
+ const filter = getOutputFilter();
5063
+ const data = envelope.Data;
5064
+ if (!filter || data == null)
5065
+ return;
5066
+ let note;
5067
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
5068
+ note = n;
5069
+ }));
5070
+ if (filterError) {
5071
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
5072
+ return;
5073
+ }
5074
+ envelope.Data = filtered;
5075
+ if (note) {
5076
+ envelope.Warning = appendWarning(envelope.Warning, note);
5077
+ }
5078
+ }
4649
5079
  function defaultErrorCodeForResult(result) {
4650
5080
  switch (result) {
4651
5081
  case RESULTS.AuthenticationError:
@@ -4660,7 +5090,7 @@ function defaultErrorCodeForResult(result) {
4660
5090
  return "unknown_error";
4661
5091
  }
4662
5092
  }
4663
- function parseHttpStatusFromMessage(message) {
5093
+ function parseHttpStatusFromMessage2(message) {
4664
5094
  const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
4665
5095
  if (!match)
4666
5096
  return;
@@ -4689,10 +5119,10 @@ function defaultErrorCodeForHttpStatus(status) {
4689
5119
  return "server_error";
4690
5120
  return;
4691
5121
  }
4692
- var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
5122
+ var LOCAL_PERMISSION_TEXT_PATTERN = new RegExp(`(?:\\b|\\()(?:${[...LOCAL_PERMISSION_ERROR_CODES].join("|")})(?::\\s|\\))`);
4693
5123
  function defaultErrorCodeForFailure(data) {
4694
5124
  if (data.Result === RESULTS.Failure) {
4695
- const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
5125
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
4696
5126
  const errorCode = defaultErrorCodeForHttpStatus(status);
4697
5127
  if (errorCode)
4698
5128
  return errorCode;
@@ -4728,8 +5158,14 @@ var OutputFormatter;
4728
5158
  }
4729
5159
  const filter = getOutputFilter();
4730
5160
  if (filter) {
4731
- const filtered = applyFilter(data.Data, filter);
5161
+ let note;
5162
+ const filtered = applyFilter(data.Data, filter, (n) => {
5163
+ note = n;
5164
+ });
4732
5165
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
5166
+ if (note) {
5167
+ data.Warning = appendWarning(data.Warning, note);
5168
+ }
4733
5169
  }
4734
5170
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4735
5171
  }
@@ -4757,12 +5193,13 @@ var OutputFormatter;
4757
5193
  delete envelope.TelemetryErrorClass;
4758
5194
  delete envelope.TelemetryTerminalOutcome;
4759
5195
  delete envelope.TelemetryTerminalSignal;
5196
+ filterFailureData(envelope);
4760
5197
  if (!suppressTelemetry) {
4761
5198
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4762
- result: data.Result,
4763
- errorCode: data.ErrorCode,
4764
- retry: data.Retry,
4765
- message: data.Message
5199
+ [ErrorDimensions.Result]: data.Result,
5200
+ [ErrorDimensions.ErrorCode]: data.ErrorCode,
5201
+ [ErrorDimensions.Retry]: data.Retry,
5202
+ [ErrorDimensions.ErrorMessage]: data.Message
4766
5203
  });
4767
5204
  }
4768
5205
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -4805,13 +5242,20 @@ var OutputFormatter;
4805
5242
  OutputFormatter.log = log;
4806
5243
  function formatToString(data) {
4807
5244
  const filter = getOutputFilter();
5245
+ const envelope = data;
4808
5246
  if ("Data" in data && data.Data != null) {
4809
5247
  data.Data = normalizeDataKeys(data.Data);
4810
5248
  if (filter) {
4811
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
5249
+ let note;
5250
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
5251
+ note = n;
5252
+ }));
5253
+ if (note) {
5254
+ envelope.Warning = appendWarning(envelope.Warning, note);
5255
+ }
4812
5256
  }
4813
5257
  }
4814
- const output = normalizeOutputKeys(data);
5258
+ const output = normalizeOutputKeys(envelope);
4815
5259
  const lines = [];
4816
5260
  const sink = getOutputSink();
4817
5261
  printOutput(output, getOutputFormat(), (msg) => {
@@ -4861,7 +5305,7 @@ var LEGACY_SKILL_NAMESPACE = "uipath:";
4861
5305
  var MAX_SKILL_NAME_LENGTH = 80;
4862
5306
  var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
4863
5307
  function productMode(productArea, mode) {
4864
- return { product_area: productArea, mode };
5308
+ return { ProductArea: productArea, Mode: mode };
4865
5309
  }
4866
5310
  function attributionRecord(groups) {
4867
5311
  const record = {};
@@ -4919,6 +5363,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
4919
5363
  ["rpa", "build", ["uip.rpa-legacy"]],
4920
5364
  ["conversational", "operate", ["uip.conversational"]],
4921
5365
  ["agents", "build", ["uip.codedagent", "uip.agent"]],
5366
+ ["coding-agents", "build", ["uip.coder"]],
4922
5367
  ["agenthub", "build", ["uip.agenthub"]],
4923
5368
  ["coded-apps", "build", ["uip.codedapp"]],
4924
5369
  ["functions", "build", ["uip.function", "uip.functions"]],
@@ -5004,32 +5449,64 @@ function normalizeSkillName(value) {
5004
5449
  function buildCommandTelemetryAttribution(commandPath, skillSource) {
5005
5450
  const skillName = normalizeSkillName(skillSource);
5006
5451
  return {
5007
- ...skillName ? { skill_name: skillName } : {},
5452
+ ...skillName ? { SkillName: skillName } : {},
5008
5453
  ...getCommandProductModeAttribution(commandPath)
5009
5454
  };
5010
5455
  }
5456
+ var AGENT_SESSION_ENV = {
5457
+ [BaseDimensions.AgentModel]: "UIPATH_AGENT_MODEL",
5458
+ [SkillsDimensions.PermissionMode]: "UIPATH_PERMISSION_MODE",
5459
+ [SkillsDimensions.EffortLevel]: "UIPATH_EFFORT_LEVEL",
5460
+ [SkillsDimensions.SkillsVersion]: "UIPATH_SKILLS_VERSION"
5461
+ };
5462
+ var MAX_TELEMETRY_TOKEN_LENGTH = 120;
5463
+ function sanitizeTelemetryToken(value) {
5464
+ return value.replace(/[^A-Za-z0-9:._/ -]/g, "_").slice(0, MAX_TELEMETRY_TOKEN_LENGTH);
5465
+ }
5466
+ function buildAgentSessionTelemetry(env) {
5467
+ const dimensions = {};
5468
+ for (const [key, variable] of Object.entries(AGENT_SESSION_ENV)) {
5469
+ const value = env[variable]?.trim();
5470
+ if (value) {
5471
+ dimensions[key] = sanitizeTelemetryToken(value);
5472
+ }
5473
+ }
5474
+ return dimensions;
5475
+ }
5011
5476
 
5012
5477
  // ../common/src/telemetry/command-name.ts
5013
- var TELEMETRY_COMMAND_ROOT = "uip";
5478
+ var TELEMETRY_NAME_ROOT = "Cli";
5479
+ var CLI_COMMAND_ROOT = "uip";
5480
+ var TELEMETRY_NAME_BARE_ACTION = "Invoke";
5014
5481
  function commandTelemetryName(parts) {
5482
+ const action = vetCommandTokens(parts).map(pascalizeToken).join("");
5483
+ return `${TELEMETRY_NAME_ROOT}.${action || TELEMETRY_NAME_BARE_ACTION}`;
5484
+ }
5485
+ function commandInvocationPath(parts) {
5486
+ return [CLI_COMMAND_ROOT, ...vetCommandTokens(parts)].join(" ");
5487
+ }
5488
+ function vetCommandTokens(parts) {
5015
5489
  const tokens = [];
5016
5490
  for (const part of parts) {
5017
- const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== TELEMETRY_COMMAND_ROOT);
5491
+ const pieces = String(part ?? "").split(/\s+/).filter((token) => token && !token.startsWith("-") && token !== CLI_COMMAND_ROOT);
5018
5492
  if (pieces.every(isCommandToken)) {
5019
5493
  tokens.push(...pieces);
5020
5494
  continue;
5021
5495
  }
5022
5496
  tokens.push(UNKNOWN_TOKEN);
5023
5497
  }
5024
- return [TELEMETRY_COMMAND_ROOT, ...tokens].join(".");
5498
+ return tokens;
5025
5499
  }
5026
- var COMMAND_TOKEN_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
5500
+ function pascalizeToken(token) {
5501
+ return token.split("-").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
5502
+ }
5503
+ var COMMAND_TOKEN_PATTERN = /^[a-z][a-z0-9-]*$/;
5027
5504
  var MAX_COMMAND_TOKEN_LENGTH = 32;
5028
5505
  var GUID_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
5029
5506
  function isCommandToken(token) {
5030
- return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token) && !/^\d+$/.test(token);
5507
+ return token.length <= MAX_COMMAND_TOKEN_LENGTH && COMMAND_TOKEN_PATTERN.test(token) && !GUID_TOKEN.test(token);
5031
5508
  }
5032
- var UNKNOWN_TOKEN = "<unknown>";
5509
+ var UNKNOWN_TOKEN = "unknown";
5033
5510
 
5034
5511
  // ../common/src/telemetry/invocation-request.ts
5035
5512
  var requestContextSlot = singleton("TelemetryInvocationRequestContext");
@@ -5134,7 +5611,7 @@ function withheldArgumentValues(cmd) {
5134
5611
  });
5135
5612
  return values;
5136
5613
  }
5137
- function deriveCommandPath(cmd) {
5614
+ function deriveCommandParts(cmd) {
5138
5615
  const parts = [];
5139
5616
  let current = cmd;
5140
5617
  while (current) {
@@ -5147,14 +5624,13 @@ function deriveCommandPath(cmd) {
5147
5624
  if (parts.length > 1) {
5148
5625
  parts.shift();
5149
5626
  }
5150
- return commandTelemetryName(parts);
5627
+ return parts;
5151
5628
  }
5152
5629
  function isErrorContext(value) {
5153
5630
  return value !== null && typeof value === "object";
5154
5631
  }
5155
5632
  function commandHelpHint(commandPath) {
5156
- const command = commandPath.replace(/\./g, " ");
5157
- return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
5633
+ return `An unexpected error occurred. Run '${commandPath} --help' to verify command syntax, or run with --log-level debug for details.`;
5158
5634
  }
5159
5635
  function isPromptCancellation(error) {
5160
5636
  return error instanceof Error && error.name === "ExitPromptError";
@@ -5179,7 +5655,9 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5179
5655
  yaml: getOutputFormat() === "yaml",
5180
5656
  filter: getOutputFilter() !== undefined
5181
5657
  });
5182
- const telemetryName = deriveCommandPath(command);
5658
+ const commandParts = deriveCommandParts(command);
5659
+ const telemetryName = commandTelemetryName(commandParts);
5660
+ const commandPath = commandInvocationPath(commandParts);
5183
5661
  const props = typeof properties === "function" ? properties(...args) : properties;
5184
5662
  markCommandStart();
5185
5663
  const supplied = recordSuppliedArgumentValues(withheldArgumentValues(command));
@@ -5214,7 +5692,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5214
5692
  Result: finalResult,
5215
5693
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
5216
5694
  Message: errorMessage,
5217
- Instructions: customInstructions ?? commandHelpHint(telemetryName),
5695
+ Instructions: customInstructions ?? commandHelpHint(commandPath),
5218
5696
  ...customRetry ? { Retry: customRetry } : {},
5219
5697
  ...customContext ? { Context: customContext } : {}
5220
5698
  });
@@ -5231,8 +5709,8 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5231
5709
  recordedFailure,
5232
5710
  pollSignal: context.pollSignal
5233
5711
  });
5234
- if (terminalTelemetry.error_class === "internal" && error) {
5235
- telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { command_name: telemetryName }, getInvocationRequestContext());
5712
+ if (terminalTelemetry[CommandDimensions.ErrorClass] === "internal" && error) {
5713
+ telemetry.trackException(error instanceof Error ? error : new Error(String(error)), { [CommandDimensions.CommandName]: commandPath }, getInvocationRequestContext());
5236
5714
  }
5237
5715
  const commandParams = extractCommandParams(command);
5238
5716
  if (props) {
@@ -5243,10 +5721,12 @@ Command.prototype.trackedAction = function(context, fn, properties) {
5243
5721
  const baseProperties = redactProperties({
5244
5722
  ...commandParams,
5245
5723
  ...props,
5246
- ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
5247
- command: "true",
5724
+ ...buildCommandTelemetryAttribution(commandPath, process.env.UIPATH_SKILL),
5725
+ ...buildAgentSessionTelemetry(process.env),
5726
+ [CommandDimensions.CommandName]: commandPath,
5727
+ [CommandDimensions.IsCommand]: "true",
5248
5728
  ...terminalTelemetry,
5249
- ...errorMessage ? { errorMessage } : {}
5729
+ ...errorMessage ? { [CommandDimensions.ErrorMessage]: errorMessage } : {}
5250
5730
  });
5251
5731
  emitInvocationRequest(telemetryName, success, baseProperties);
5252
5732
  } finally {
@@ -5478,6 +5958,40 @@ var BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
5478
5958
  // ../common/src/interactivity-context.ts
5479
5959
  var modeSlot = singleton("InteractivityMode");
5480
5960
  var interactiveFlagSlot = singleton("InteractiveFlag");
5961
+ // ../common/src/mime-types.ts
5962
+ var MIME_TYPES_BY_EXTENSION = Object.freeze({
5963
+ pdf: "application/pdf",
5964
+ png: "image/png",
5965
+ jpg: "image/jpeg",
5966
+ jpeg: "image/jpeg",
5967
+ gif: "image/gif",
5968
+ webp: "image/webp",
5969
+ bmp: "image/bmp",
5970
+ tif: "image/tiff",
5971
+ tiff: "image/tiff",
5972
+ svg: "image/svg+xml",
5973
+ txt: "text/plain",
5974
+ log: "text/plain",
5975
+ md: "text/markdown",
5976
+ csv: "text/csv",
5977
+ tsv: "text/tab-separated-values",
5978
+ json: "application/json",
5979
+ xml: "application/xml",
5980
+ html: "text/html",
5981
+ htm: "text/html",
5982
+ yaml: "application/yaml",
5983
+ yml: "application/yaml",
5984
+ doc: "application/msword",
5985
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
5986
+ xls: "application/vnd.ms-excel",
5987
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
5988
+ ppt: "application/vnd.ms-powerpoint",
5989
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
5990
+ zip: "application/zip",
5991
+ mp3: "audio/mpeg",
5992
+ wav: "audio/wav",
5993
+ mp4: "video/mp4"
5994
+ });
5481
5995
  // ../common/src/polling/types.ts
5482
5996
  var PollOutcome = {
5483
5997
  Completed: "completed",
@@ -5522,6 +6036,7 @@ var ScreenLogger;
5522
6036
  ScreenLogger.progress = progress;
5523
6037
  })(ScreenLogger ||= {});
5524
6038
  // ../common/src/sdk-user-agent.ts
6039
+ var AGENT_PROPERTY = BaseDimensions.Agent;
5525
6040
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
5526
6041
  // ../common/src/telemetry/ship-succeeded.ts
5527
6042
  var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
@@ -5932,6 +6447,11 @@ var pickName = (claims) => {
5932
6447
  const username = asString(claims?.preferred_username);
5933
6448
  return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
5934
6449
  };
6450
+ var pickScopes = (claims) => {
6451
+ const raw = claims?.scope;
6452
+ const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
6453
+ return scopes.length > 0 ? scopes : undefined;
6454
+ };
5935
6455
  var resolveSessionIdentity = (accessToken, authFlow) => {
5936
6456
  const claims = accessToken ? decodeClaims(accessToken) : undefined;
5937
6457
  const email = pickEmail(claims);
@@ -5957,6 +6477,7 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
5957
6477
  identity.clientId = clientId;
5958
6478
  return identity;
5959
6479
  };
6480
+ var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
5960
6481
 
5961
6482
  // ../auth/src/envAuth.ts
5962
6483
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
@@ -6029,6 +6550,7 @@ var readAuthFromEnv = () => {
6029
6550
  const expiration = getTokenExpiration(accessToken);
6030
6551
  const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
6031
6552
  const identity = resolveSessionIdentity(accessToken);
6553
+ const scopes = readTokenScopes(accessToken);
6032
6554
  return {
6033
6555
  loginStatus,
6034
6556
  accessToken,
@@ -6039,7 +6561,8 @@ var readAuthFromEnv = () => {
6039
6561
  tenantId,
6040
6562
  expiration,
6041
6563
  source: "env-vars" /* EnvironmentVariables */,
6042
- ...identity ? { identity } : {}
6564
+ ...identity ? { identity } : {},
6565
+ ...scopes ? { scopes } : {}
6043
6566
  };
6044
6567
  };
6045
6568
 
@@ -6677,10 +7200,15 @@ async function buildFileStatus(tokens, credentials, globalHint) {
6677
7200
  }
6678
7201
  function identityFields(accessToken, credentials) {
6679
7202
  const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
6680
- return identity ? { identity } : {};
7203
+ const scopes = readTokenScopes(accessToken);
7204
+ return {
7205
+ ...identity ? { identity } : {},
7206
+ ...scopes ? { scopes } : {}
7207
+ };
6681
7208
  }
6682
7209
  function buildRobotStatus(robotCreds) {
6683
7210
  const identity = resolveSessionIdentity(robotCreds.accessToken);
7211
+ const scopes = readTokenScopes(robotCreds.accessToken);
6684
7212
  return {
6685
7213
  loginStatus: "Logged in",
6686
7214
  accessToken: robotCreds.accessToken,
@@ -6692,7 +7220,8 @@ function buildRobotStatus(robotCreds) {
6692
7220
  issuer: robotCreds.issuer,
6693
7221
  expiration: getTokenExpiration(robotCreds.accessToken),
6694
7222
  source: "robot" /* Robot */,
6695
- ...identity ? { identity } : {}
7223
+ ...identity ? { identity } : {},
7224
+ ...scopes ? { scopes } : {}
6696
7225
  };
6697
7226
  }
6698
7227
  var isFileNotFoundError = (error) => {
@@ -6970,6 +7499,28 @@ var TENANT_SELECTION_CODES = new Set([
6970
7499
  TENANT_SELECTION_REQUIRED_CODE,
6971
7500
  INVALID_TENANT_CODE
6972
7501
  ]);
7502
+ // ../uipath-python-bridge/src/scaffold-type.ts
7503
+ import { execFile } from "node:child_process";
7504
+ var PROBE_TIMEOUT_MS = 15000;
7505
+ var TYPE_OPTION = /^--type(=|$)/;
7506
+ var TYPE_LISTED = /^[ \t]*--type(?![\w-])/m;
7507
+ function hasTypeOption(args) {
7508
+ return args.some((arg) => TYPE_OPTION.test(arg));
7509
+ }
7510
+ async function supportsNewTypeOption(exePath, cwd, env = {}, signal) {
7511
+ return new Promise((resolve2) => {
7512
+ execFile(exePath, ["new", "--help"], {
7513
+ cwd,
7514
+ env: { ...process.env, ...env },
7515
+ timeout: PROBE_TIMEOUT_MS,
7516
+ windowsHide: true,
7517
+ signal
7518
+ }, (error, stdout) => {
7519
+ resolve2(!error && TYPE_LISTED.test(typeof stdout === "string" ? stdout : ""));
7520
+ });
7521
+ });
7522
+ }
7523
+
6973
7524
  // ../uipath-python-bridge/src/execute.ts
6974
7525
  var ENV_FILE_NAME = ".env";
6975
7526
  function isHelpCommand(args) {
@@ -7025,10 +7576,21 @@ var fail = (reason, message, instructions, extras = {}) => ({
7025
7576
  exitCode: extras.exitCode ?? 1,
7026
7577
  stderr: extras.stderr
7027
7578
  });
7579
+ function childStdio(stdio) {
7580
+ switch (stdio) {
7581
+ case "pipe":
7582
+ return ["ignore", "pipe", "pipe"];
7583
+ case "stdout-to-stderr":
7584
+ return ["inherit", "pipe", "inherit"];
7585
+ default:
7586
+ return "inherit";
7587
+ }
7588
+ }
7028
7589
  async function runUipathPythonCommand(args, options = {}) {
7029
7590
  const fs2 = getFileSystem();
7030
7591
  const cacheFile = fs2.path.join(fs2.env.homedir(), UIPATH_HOME_DIR, getCacheFileName());
7031
- const setupCommand = `uip ${options.commandPrefix ?? "codedagent"} setup`;
7592
+ const toolLabel = options.toolName ?? options.commandPrefix ?? "codedagent";
7593
+ const setupCommand = `uip ${toolLabel} setup`;
7032
7594
  const setupHint = `Run '${setupCommand}' first to configure the environment. ` + `Activate the project's virtual environment and run ${setupCommand} --force.`;
7033
7595
  const cache = await readCache(cacheFile);
7034
7596
  if (!cache?.uipathExePath) {
@@ -7041,6 +7603,9 @@ async function runUipathPythonCommand(args, options = {}) {
7041
7603
  if (!processed.allowed) {
7042
7604
  return fail("command_disabled", processed.errorMessage || "Command disabled.", "Use of --force flag is not recommended. Favor alternate command.", { exitCode: 3 });
7043
7605
  }
7606
+ if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && hasTypeOption(processed.args)) {
7607
+ return fail("new_type_not_allowed", "--type is not a valid option.", "Remove --type and re-run.");
7608
+ }
7044
7609
  const processedArgs = applyOutputFormatOption(processed.args, options.outputFormatOption, options.outputFormats);
7045
7610
  const commandArgs = options.commandPrefix ? [options.commandPrefix, ...processedArgs] : [...processedArgs];
7046
7611
  const requiredEnv = {};
@@ -7075,6 +7640,9 @@ async function runUipathPythonCommand(args, options = {}) {
7075
7640
  }
7076
7641
  const stdio = options.stdio ?? "inherit";
7077
7642
  const cwd = options.cwd ?? fs2.env.cwd();
7643
+ if (options.pinNewType && processed.args[0] === "new" && !isHelpCommand(processed.args) && await supportsNewTypeOption(cache.uipathExePath, cwd, { ...authEnv, ...requiredEnv }, options.signal)) {
7644
+ commandArgs.push("--type", options.pinNewType);
7645
+ }
7078
7646
  const proc = spawn(cache.uipathExePath, commandArgs, {
7079
7647
  cwd,
7080
7648
  env: {
@@ -7082,17 +7650,24 @@ async function runUipathPythonCommand(args, options = {}) {
7082
7650
  ...authEnv,
7083
7651
  ...requiredEnv
7084
7652
  },
7085
- stdio: stdio === "pipe" ? ["ignore", "pipe", "pipe"] : "inherit",
7653
+ stdio: childStdio(stdio),
7086
7654
  signal: options.signal
7087
7655
  });
7088
7656
  let stdout = "";
7089
7657
  let stderr = "";
7090
7658
  if (stdio === "pipe") {
7659
+ proc.stdout?.setEncoding("utf8");
7660
+ proc.stderr?.setEncoding("utf8");
7091
7661
  proc.stdout?.on("data", (chunk) => {
7092
- stdout += chunk.toString("utf8");
7662
+ stdout += chunk;
7093
7663
  });
7094
7664
  proc.stderr?.on("data", (chunk) => {
7095
- stderr += chunk.toString("utf8");
7665
+ stderr += chunk;
7666
+ });
7667
+ } else if (stdio === "stdout-to-stderr") {
7668
+ proc.stdout?.setEncoding("utf8");
7669
+ proc.stdout?.on("data", (chunk) => {
7670
+ getOutputSink().writeErr(chunk);
7096
7671
  });
7097
7672
  }
7098
7673
  const [spawnError, exitCode] = await catchError(new Promise((resolve2, reject) => {
@@ -7122,17 +7697,30 @@ var CLI_RESULT_BY_REASON = {
7122
7697
  python_not_configured: RESULTS.ConfigError,
7123
7698
  uipath_exe_missing: RESULTS.ConfigError,
7124
7699
  command_disabled: RESULTS.ValidationError,
7700
+ new_type_not_allowed: RESULTS.ValidationError,
7125
7701
  required_env_missing: RESULTS.ConfigError,
7126
7702
  preflight_error: RESULTS.Failure,
7127
7703
  preflight_rejected: RESULTS.ConfigError,
7128
7704
  spawn_failed: RESULTS.Failure
7129
7705
  };
7706
+ function reportUipathPythonFailure(result) {
7707
+ if (!result.ok && result.reason !== "command_failed") {
7708
+ OutputFormatter.error({
7709
+ Result: CLI_RESULT_BY_REASON[result.reason],
7710
+ Message: result.message,
7711
+ Instructions: result.instructions
7712
+ });
7713
+ }
7714
+ return result.exitCode;
7715
+ }
7130
7716
  function createExecuteCommand(config) {
7131
7717
  const executeCommand = async (rawArgs, _options) => {
7132
7718
  const runIndex = rawArgs.indexOf("exec");
7133
7719
  const actualArgs = runIndex >= 0 ? rawArgs.slice(runIndex + 1) : [];
7134
7720
  const result = await runUipathPythonCommand(actualArgs, {
7135
7721
  commandPrefix: config.commandPrefix,
7722
+ toolName: config.toolName,
7723
+ pinNewType: config.pinNewType,
7136
7724
  commandRules: config.commandRules,
7137
7725
  commandPreflight: config.commandPreflight,
7138
7726
  requiredEnvironmentVariables: config.requiredEnvironmentVariables,
@@ -7140,18 +7728,11 @@ function createExecuteCommand(config) {
7140
7728
  outputFormats: config.outputFormats,
7141
7729
  stdio: "inherit"
7142
7730
  });
7143
- if (!result.ok && result.reason !== "command_failed") {
7144
- OutputFormatter.error({
7145
- Result: CLI_RESULT_BY_REASON[result.reason],
7146
- Message: result.message,
7147
- Instructions: result.instructions
7148
- });
7149
- }
7150
- processContext.exit(result.exitCode);
7731
+ processContext.exit(reportUipathPythonFailure(result));
7151
7732
  return result;
7152
7733
  };
7153
7734
  const registerExecCommand = (program2) => {
7154
- program2.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, config.telemetryEvent, async (_options, cmd) => {
7735
+ program2.command("exec", { hidden: true }).description("Execute the uipath package with provided arguments").allowUnknownOption(true).allowExcessArguments(true).trackedAction(processContext, async (_options, cmd) => {
7155
7736
  await executeCommand(["_", "_", "exec", ...cmd.args], {});
7156
7737
  });
7157
7738
  };
@@ -7179,6 +7760,10 @@ class PythonService {
7179
7760
  }
7180
7761
  async _setupInternal(packageName, force) {
7181
7762
  const virtualEnv = process.env.VIRTUAL_ENV || undefined;
7763
+ const dormantVenv = await this.checkDormantVenv();
7764
+ if (dormantVenv) {
7765
+ return dormantVenv;
7766
+ }
7182
7767
  if (!force) {
7183
7768
  const reused = await this.reuseCache(packageName, virtualEnv);
7184
7769
  if (reused)
@@ -7205,7 +7790,7 @@ class PythonService {
7205
7790
  packageInstalled: false,
7206
7791
  source,
7207
7792
  error: `Package '${packageName}' is not installed in the active virtual environment: ${virtualEnv}`,
7208
- instructions: `Install it inside the active virtual environment (uv pip install ${packageName} or the framework package), then re-run uip codedagent setup --force.`
7793
+ 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.`
7209
7794
  };
7210
7795
  }
7211
7796
  return {
@@ -7339,6 +7924,20 @@ To install the package, run:
7339
7924
  source: "venv"
7340
7925
  };
7341
7926
  }
7927
+ async checkDormantVenv() {
7928
+ if (process.env.VIRTUAL_ENV) {
7929
+ return null;
7930
+ }
7931
+ const fs2 = getFileSystem();
7932
+ if (!await fs2.exists(fs2.path.join(fs2.env.cwd(), ".venv"))) {
7933
+ return null;
7934
+ }
7935
+ return {
7936
+ success: false,
7937
+ error: "Found .venv in current directory but no virtual environment is activated.",
7938
+ instructions: process.platform === "win32" ? "Run '.venv\\Scripts\\activate' first, then re-run setup." : "Run 'source .venv/bin/activate' first, then re-run setup."
7939
+ };
7940
+ }
7342
7941
  async detectPython() {
7343
7942
  const pythonCommands = this.getDefaultPythonPaths();
7344
7943
  const checkedVersions = [];
@@ -7663,22 +8262,12 @@ function createSetupCommand(config) {
7663
8262
  processContext.exit(1);
7664
8263
  return;
7665
8264
  }
7666
- const fs2 = getFileSystem();
7667
- const venvPath = fs2.path.join(fs2.env.cwd(), ".venv");
7668
- if (await fs2.exists(venvPath) && !process.env.VIRTUAL_ENV) {
7669
- OutputFormatter.error({
7670
- Result: RESULTS.Failure,
7671
- Message: "Found .venv in current directory but no virtual environment is activated.",
7672
- Instructions: process.platform === "win32" ? "Run '.venv\\Scripts\\activate' first, then re-run setup." : "Run 'source .venv/bin/activate' first, then re-run setup."
7673
- });
7674
- processContext.exit(1);
7675
- return;
7676
- }
7677
8265
  logger.info(`
7678
8266
  Searching for Python installations: ${allowedVersions}`);
7679
8267
  const service = new PythonService({
7680
8268
  allowedVersions,
7681
- packageName
8269
+ packageName,
8270
+ toolName: config.toolName
7682
8271
  });
7683
8272
  const result = await service.setup(packageName, options.force);
7684
8273
  if (!result.success) {
@@ -7706,7 +8295,7 @@ Searching for Python installations: ${allowedVersions}`);
7706
8295
  });
7707
8296
  };
7708
8297
  }
7709
- function createDefaultAction(_config, executeCommand) {
8298
+ function createDefaultAction(executeCommand) {
7710
8299
  return (program2) => {
7711
8300
  program2.trackedAction(processContext, async () => {
7712
8301
  const userArgs = program2.args.length > 0 ? normalizeDefaultActionArgs(program2.args) : [];
@@ -7718,7 +8307,7 @@ function createDefaultAction(_config, executeCommand) {
7718
8307
  function normalizeDefaultActionArgs(args) {
7719
8308
  return args.length === 1 && args[0] === "-h" ? ["--help"] : args;
7720
8309
  }
7721
- function createHelpCommand(_config, executeCommand) {
8310
+ function createHelpCommand(executeCommand) {
7722
8311
  return (program2) => {
7723
8312
  program2.command("help").description("Display help for the python tool").trackedAction(processContext, async () => {
7724
8313
  await executeCommand(["_", "_", "exec", "--help"], {});
@@ -7740,7 +8329,7 @@ var package_default = {
7740
8329
  name: "@uipath/context-grounding-tool",
7741
8330
  author: "UiPath",
7742
8331
  license: "SEE LICENSE IN LICENSE.txt",
7743
- version: "1.203.0-preview.203",
8332
+ version: "1.204.0-preview.206",
7744
8333
  description: "Tool for context grounding operations via the UiPath Python SDK",
7745
8334
  keywords: [
7746
8335
  "uipcli-tool",
@@ -7792,14 +8381,6 @@ var COMMAND_RULES = [
7792
8381
  }
7793
8382
  ];
7794
8383
 
7795
- // src/telemetry-events.ts
7796
- var ContextGroundingTelemetryEvents = {
7797
- DefaultAction: "ContextGrounding.DefaultAction",
7798
- Setup: "ContextGrounding.Setup",
7799
- Exec: "ContextGrounding.Exec",
7800
- Help: "ContextGrounding.Help"
7801
- };
7802
-
7803
8384
  // src/tool.ts
7804
8385
  var COMMAND_PREFIX = "context-grounding";
7805
8386
  var metadata = {
@@ -7810,23 +8391,16 @@ var metadata = {
7810
8391
  };
7811
8392
  var { executeCommand, registerExecCommand } = createExecuteCommand({
7812
8393
  commandPrefix: COMMAND_PREFIX,
7813
- telemetryEvent: ContextGroundingTelemetryEvents.Exec,
7814
8394
  commandRules: COMMAND_RULES,
7815
8395
  outputFormatOption: "--format",
7816
8396
  outputFormats: ["json"]
7817
8397
  });
7818
8398
  var registerSetupCommand = createSetupCommand({
7819
- telemetryEvent: ContextGroundingTelemetryEvents.Setup,
7820
- successCode: "ContextGroundingSetup"
8399
+ successCode: "ContextGroundingSetup",
8400
+ toolName: COMMAND_PREFIX
7821
8401
  });
7822
- var registerDefaultAction = createDefaultAction({
7823
- defaultTelemetryEvent: ContextGroundingTelemetryEvents.DefaultAction,
7824
- helpTelemetryEvent: ContextGroundingTelemetryEvents.Help
7825
- }, executeCommand);
7826
- var registerHelpCommand = createHelpCommand({
7827
- defaultTelemetryEvent: ContextGroundingTelemetryEvents.DefaultAction,
7828
- helpTelemetryEvent: ContextGroundingTelemetryEvents.Help
7829
- }, executeCommand);
8402
+ var registerDefaultAction = createDefaultAction(executeCommand);
8403
+ var registerHelpCommand = createHelpCommand(executeCommand);
7830
8404
  var registerCommands = async (program2) => {
7831
8405
  program2.allowUnknownOption(true);
7832
8406
  program2.allowExcessArguments(true);
@@ -7841,4 +8415,4 @@ var registerCommands = async (program2) => {
7841
8415
 
7842
8416
  export { Command, metadata, registerCommands };
7843
8417
 
7844
- //# debugId=6C910398764C77C064756E2164756E21
8418
+ //# debugId=029D7B3C0BCCA01064756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-rfxscr39.js";
4
+ } from "./tool-ab2qbker.js";
5
5
  import"./tool-1de529jm.js";
6
6
  export {
7
7
  metadata,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/context-grounding-tool",
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": "Tool for context grounding operations via the UiPath Python SDK",
7
7
  "keywords": [
8
8
  "uipcli-tool",
@@ -29,5 +29,5 @@
29
29
  "publishConfig": {
30
30
  "registry": "https://registry.npmjs.org/"
31
31
  },
32
- "gitHead": "a10661bf5ec19ddd6c628ed7bb1db55f721a6027"
32
+ "gitHead": "ea7fd32a02acccf14e8e83522e69101430627b83"
33
33
  }