@uipath/codedagent-tool 1.204.0 → 1.205.0-preview.258

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
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  metadata,
4
4
  registerCommands
5
- } from "./tool-2a8j0aej.js";
5
+ } from "./tool-c3rrmpjx.js";
6
6
  import {
7
7
  Command
8
- } from "./tool-dyn9hret.js";
8
+ } from "./tool-kh9ddkna.js";
9
9
  import"./tool-1de529jm.js";
10
10
 
11
11
  // src/index.ts
package/dist/init.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  COMMAND_RULES,
3
3
  codedAgentCommandPreflight,
4
4
  runUipathPythonCommand
5
- } from "./tool-dyn9hret.js";
5
+ } from "./tool-kh9ddkna.js";
6
6
  import"./tool-1de529jm.js";
7
7
 
8
8
  // src/services/codedagent-init-service.ts
@@ -15,13 +15,13 @@ import {
15
15
  parseJWT,
16
16
  processContext,
17
17
  trackShipSucceeded
18
- } from "./tool-dyn9hret.js";
18
+ } from "./tool-kh9ddkna.js";
19
19
  // package.json
20
20
  var package_default = {
21
21
  name: "@uipath/codedagent-tool",
22
22
  author: "UiPath",
23
23
  license: "SEE LICENSE IN LICENSE.txt",
24
- version: "1.204.0",
24
+ version: "1.205.0-preview.258",
25
25
  description: "Build, run, deploy, and manage AI Agents.",
26
26
  keywords: [
27
27
  "cli-tool",
@@ -1027,4 +1027,4 @@ var registerCommands = async (program) => {
1027
1027
 
1028
1028
  export { metadata, registerCommands };
1029
1029
 
1030
- //# debugId=E89208B3B8FE8D0864756E2164756E21
1030
+ //# debugId=CCBA5272770CF4B764756E2164756E21
@@ -2150,7 +2150,9 @@ var ErrorDimensions = {
2150
2150
  Result: "Result",
2151
2151
  ErrorCode: "ErrorCode",
2152
2152
  Retry: "Retry",
2153
- ErrorMessage: "ErrorMessage"
2153
+ ErrorMessage: "ErrorMessage",
2154
+ HttpStatus: "HttpStatus",
2155
+ UpstreamErrorCode: "UpstreamErrorCode"
2154
2156
  };
2155
2157
  var AuthDimensions = {
2156
2158
  AuthenticationMethod: "AuthenticationMethod",
@@ -2989,6 +2991,16 @@ class NodeFileSystem {
2989
2991
  async rename(oldPath, newPath) {
2990
2992
  await fs.rename(oldPath, newPath);
2991
2993
  }
2994
+ async isSymbolicLink(filePath) {
2995
+ try {
2996
+ return (await fs.lstat(filePath)).isSymbolicLink();
2997
+ } catch (error) {
2998
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
2999
+ return false;
3000
+ }
3001
+ throw error;
3002
+ }
3003
+ }
2992
3004
  async realpath(filePath) {
2993
3005
  try {
2994
3006
  return await fs.realpath(filePath);
@@ -3078,7 +3090,7 @@ function setGlobalLogFilePath(path2) {
3078
3090
  function getGlobalLogFilePath() {
3079
3091
  return logFilePathSlot.get("");
3080
3092
  }
3081
- var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
3093
+ var DEFAULT_LOG_LEVEL = 2 /* WARN */;
3082
3094
 
3083
3095
  class SimpleLogger {
3084
3096
  __brand = "SimpleLogger";
@@ -4233,7 +4245,9 @@ var CLI_ERROR_CODES = [
4233
4245
  "timeout",
4234
4246
  "server_error",
4235
4247
  "method_not_allowed",
4248
+ "not_supported",
4236
4249
  "configuration_error",
4250
+ "execution_failed",
4237
4251
  "unknown_error"
4238
4252
  ];
4239
4253
  var RETRY_HINTS = [
@@ -5190,7 +5204,9 @@ var OutputFormatter;
5190
5204
  [ErrorDimensions.Result]: data.Result,
5191
5205
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
5192
5206
  [ErrorDimensions.Retry]: data.Retry,
5193
- [ErrorDimensions.ErrorMessage]: data.Message
5207
+ [ErrorDimensions.ErrorMessage]: data.Message,
5208
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
5209
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
5194
5210
  });
5195
5211
  }
5196
5212
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -6212,22 +6228,12 @@ var resolveConfigAsync = async ({
6212
6228
  baseUrl = DEFAULT_BASE_URL;
6213
6229
  }
6214
6230
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
6215
- let clientId = customClientId;
6216
- if (!clientId && fileAuth.clientId) {
6217
- clientId = fileAuth.clientId;
6218
- }
6219
- if (!clientId) {
6220
- clientId = DEFAULT_CLIENT_ID;
6221
- }
6222
- let clientSecret = customClientSecret;
6223
- if (!clientSecret && fileAuth.clientSecret) {
6224
- clientSecret = fileAuth.clientSecret;
6225
- }
6226
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
6231
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
6232
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
6227
6233
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
6228
6234
  return {
6229
6235
  clientId,
6230
- clientSecret,
6236
+ clientSecret: customClientSecret,
6231
6237
  scopes,
6232
6238
  baseUrl,
6233
6239
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -6401,6 +6407,16 @@ var resolveIdentityType = (claims, authFlow, email) => {
6401
6407
  }
6402
6408
  return;
6403
6409
  };
6410
+ var resolveApplicationSubtype = (claims, authFlow) => {
6411
+ switch (asString(claims?.sub_type)) {
6412
+ case "service.external":
6413
+ return "External";
6414
+ case "service.internal":
6415
+ return "Internal";
6416
+ default:
6417
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
6418
+ }
6419
+ };
6404
6420
  var looksLikeEmail = (value) => value?.includes("@") ?? false;
6405
6421
  var pickEmail = (claims) => {
6406
6422
  for (const candidate of [claims?.email, claims?.preferred_username]) {
@@ -6442,6 +6458,12 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
6442
6458
  const clientId = asString(claims?.client_id);
6443
6459
  if (clientId)
6444
6460
  identity.clientId = clientId;
6461
+ const subType = asString(claims?.sub_type);
6462
+ if (subType)
6463
+ identity.subType = subType;
6464
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
6465
+ if (applicationSubtype)
6466
+ identity.applicationSubtype = applicationSubtype;
6445
6467
  return identity;
6446
6468
  };
6447
6469
  var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
@@ -6734,6 +6756,40 @@ var tryRobotClientFallback = async (options = {}) => {
6734
6756
  }
6735
6757
  };
6736
6758
 
6759
+ // ../auth/src/tenantSelection.ts
6760
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
6761
+ var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
6762
+ var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
6763
+ var describeNonJsonResponse = (organizationId, response, parseError) => {
6764
+ if (response.redirected) {
6765
+ return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
6766
+ }
6767
+ const contentType = response.headers.get("content-type") ?? "unknown";
6768
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
6769
+ };
6770
+ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
6771
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
6772
+ const response = await fetch(url, {
6773
+ headers: {
6774
+ Authorization: `Bearer ${accessToken}`
6775
+ },
6776
+ ...signal ? { signal } : {}
6777
+ });
6778
+ if (!response.ok) {
6779
+ if (response.status === 401) {
6780
+ throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
6781
+ }
6782
+ const errorText = await response.text();
6783
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
6784
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
6785
+ }
6786
+ const [parseError, data] = await catchError2(response.json());
6787
+ if (parseError) {
6788
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
6789
+ }
6790
+ return data;
6791
+ };
6792
+
6737
6793
  // ../auth/src/tokenRefresh.ts
6738
6794
  var TOKEN_REFRESH_REAUTHENTICATE_MESSAGE = "Token refresh failed. Run 'uip login' to re-authenticate.";
6739
6795
 
@@ -6946,6 +7002,8 @@ var saveEnvFileAsync = async ({
6946
7002
  };
6947
7003
 
6948
7004
  // ../auth/src/loginStatus.ts
7005
+ var defaultRobotTenantIdCache = new Map;
7006
+ var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
6949
7007
  var getLoginStatusAsync = async (options = {}) => {
6950
7008
  return getLoginStatusWithDeps(options);
6951
7009
  };
@@ -6958,12 +7016,20 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
6958
7016
  refreshToken: refreshTokenFn = refreshAccessToken,
6959
7017
  resolveConfig = resolveConfigAsync,
6960
7018
  robotFallback = tryRobotClientFallback,
7019
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
7020
+ robotTenantIdCache = defaultRobotTenantIdCache,
7021
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
6961
7022
  loadBreaker = loadRefreshBreaker,
6962
7023
  saveBreaker = saveRefreshBreaker,
6963
7024
  clearBreaker = clearRefreshBreaker
6964
7025
  } = deps;
7026
+ const robotDeps = {
7027
+ fetchTenantsAndOrgs,
7028
+ cache: robotTenantIdCache,
7029
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
7030
+ };
6965
7031
  if (isRobotAuthEnforced()) {
6966
- return resolveRobotEnforcedStatus(robotFallback);
7032
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
6967
7033
  }
6968
7034
  if (isEnvAuthEnabled()) {
6969
7035
  return readAuthFromEnv();
@@ -6981,7 +7047,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
6981
7047
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
6982
7048
  };
6983
7049
  }
6984
- return resolveBorrowedRobotStatus(robotFallback);
7050
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
6985
7051
  }
6986
7052
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
6987
7053
  if ("status" in loaded) {
@@ -7023,7 +7089,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
7023
7089
  }
7024
7090
  return buildFileStatus(tokens, credentials, globalHint);
7025
7091
  };
7026
- async function resolveRobotEnforcedStatus(robotFallback) {
7092
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
7027
7093
  if (isEnvAuthEnabled()) {
7028
7094
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
7029
7095
  }
@@ -7034,11 +7100,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
7034
7100
  hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
7035
7101
  };
7036
7102
  }
7037
- return buildRobotStatus(robotCreds);
7103
+ return buildRobotStatus(robotCreds, deps);
7038
7104
  }
7039
- async function resolveBorrowedRobotStatus(robotFallback) {
7105
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
7040
7106
  const robotCreds = await robotFallback();
7041
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
7107
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
7042
7108
  }
7043
7109
  async function loadFileCredentials(loadEnvFile, absolutePath) {
7044
7110
  let credentials;
@@ -7173,9 +7239,10 @@ function identityFields(accessToken, credentials) {
7173
7239
  ...scopes ? { scopes } : {}
7174
7240
  };
7175
7241
  }
7176
- function buildRobotStatus(robotCreds) {
7242
+ async function buildRobotStatus(robotCreds, deps) {
7177
7243
  const identity = resolveSessionIdentity(robotCreds.accessToken);
7178
7244
  const scopes = readTokenScopes(robotCreds.accessToken);
7245
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
7179
7246
  return {
7180
7247
  loginStatus: "Logged in",
7181
7248
  accessToken: robotCreds.accessToken,
@@ -7183,14 +7250,62 @@ function buildRobotStatus(robotCreds) {
7183
7250
  organizationName: robotCreds.organizationName,
7184
7251
  organizationId: robotCreds.organizationId,
7185
7252
  tenantName: robotCreds.tenantName,
7186
- tenantId: robotCreds.tenantId,
7253
+ tenantId: tenant.tenantId,
7187
7254
  issuer: robotCreds.issuer,
7188
7255
  expiration: getTokenExpiration(robotCreds.accessToken),
7189
7256
  source: "robot" /* Robot */,
7257
+ ...tenant.hint ? { hint: tenant.hint } : {},
7190
7258
  ...identity ? { identity } : {},
7191
7259
  ...scopes ? { scopes } : {}
7192
7260
  };
7193
7261
  }
7262
+ async function resolveRobotTenantId(robotCreds, deps) {
7263
+ const { baseUrl, accessToken, tenantName } = robotCreds;
7264
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
7265
+ if (!tenantName || !organization) {
7266
+ return {};
7267
+ }
7268
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
7269
+ let pending = deps.cache.get(key);
7270
+ if (!pending) {
7271
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
7272
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
7273
+ if (!settled.tenantId) {
7274
+ deps.cache.delete(key);
7275
+ }
7276
+ return settled;
7277
+ });
7278
+ deps.cache.set(key, pending);
7279
+ }
7280
+ return pending;
7281
+ }
7282
+ async function lookupRobotTenantId(target, deps) {
7283
+ const { baseUrl, accessToken, organization, tenantName } = target;
7284
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
7285
+ if (error) {
7286
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
7287
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
7288
+ }
7289
+ const rows = data?.tenants;
7290
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
7291
+ const wantedName = decodePathSegment(tenantName);
7292
+ const wanted = wantedName.toLowerCase();
7293
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
7294
+ if (!match) {
7295
+ const names = tenants.map((tenant) => tenant.name).join(", ");
7296
+ return {
7297
+ hint: `The Robot session targets tenant '${tenantName}', but ` + `organization '${organization}' lists no tenant of that name` + `${names ? ` (available: ${names})` : ""}. Commands that need ` + `the tenant id will fail until it can be resolved.`
7298
+ };
7299
+ }
7300
+ return { tenantId: match.id };
7301
+ }
7302
+ function tenantLookupFailureHint(tenantName, reason) {
7303
+ return `Could not resolve the id of tenant '${tenantName}' from the ` + `Robot session: ${reason} Commands that need the tenant id will ` + `fail until it can be resolved.`;
7304
+ }
7305
+ function decodePathSegment(segment) {
7306
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
7307
+ return error ? segment : decoded;
7308
+ }
7194
7309
  var isFileNotFoundError = (error) => {
7195
7310
  if (!(error instanceof Object))
7196
7311
  return false;
@@ -7456,9 +7571,6 @@ var getAuthEnv = async (options = {}) => {
7456
7571
  }
7457
7572
  return { authEnv, loginStatus: status };
7458
7573
  };
7459
- // ../auth/src/tenantSelection.ts
7460
- var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
7461
-
7462
7574
  // ../auth/src/selectTenant.ts
7463
7575
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
7464
7576
  var INVALID_TENANT_CODE = "INVALID_TENANT";
@@ -8436,4 +8548,4 @@ var codedAgentCommandPreflight = ({
8436
8548
 
8437
8549
  export { getFileSystem, catchError, extractErrorMessageSync, CommandDimensions, ShipDimensions, RESULTS, OutputFormatter, Command, processContext, trackShipSucceeded, parseJWT, getLoginStatusAsync, runUipathPythonCommand, createExecuteCommand, createSetupCommand, WHITELISTED_COMMANDS, COMMAND_RULES, codedAgentCommandPreflight };
8438
8550
 
8439
- //# debugId=4184EF0A2E09B9C464756E2164756E21
8551
+ //# debugId=1E5B8C31A730D68164756E2164756E21
package/dist/tool.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-2a8j0aej.js";
5
- import"./tool-dyn9hret.js";
4
+ } from "./tool-c3rrmpjx.js";
5
+ import"./tool-kh9ddkna.js";
6
6
  import"./tool-1de529jm.js";
7
7
  export {
8
8
  metadata,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/codedagent-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.204.0",
5
+ "version": "1.205.0-preview.258",
6
6
  "description": "Build, run, deploy, and manage AI Agents.",
7
7
  "keywords": [
8
8
  "cli-tool",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "registry": "https://registry.npmjs.org/"
35
35
  },
36
- "gitHead": "699c58dabb59414557755a8933bcbe40aa420df3"
36
+ "gitHead": "8f629ee9fa89abf94f197436a60cb3b9620f8b27"
37
37
  }