@uipath/common 1.201.0-preview.115 → 1.201.0-preview.122

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.
@@ -45,6 +45,23 @@ export interface ConnectivityError {
45
45
  /** Actionable, user-facing remediation steps. */
46
46
  instructions: string;
47
47
  }
48
+ /**
49
+ * A local OS/sandbox permission failure (EACCES, EPERM, EROFS), already
50
+ * classified with actionable guidance. Returned by
51
+ * {@link describePermissionError}. Deliberately distinct from an HTTP 403:
52
+ * this failure means the local OS refused a syscall, so the fix is a local
53
+ * permission grant or elevation, never a credential or role change.
54
+ */
55
+ export interface LocalPermissionError {
56
+ /** The OS error code, e.g. `EACCES`. */
57
+ code: string;
58
+ /** The most specific message found while walking the cause chain. */
59
+ message: string;
60
+ /** The file or directory the OS refused access to, when known. */
61
+ path?: string;
62
+ /** Actionable, user-facing remediation steps. */
63
+ instructions: string;
64
+ }
48
65
  export declare function formatErrorChain(error: unknown): string;
49
66
  /**
50
67
  * Classify an outbound connectivity failure by walking the error graph.
@@ -60,6 +77,25 @@ export declare function formatErrorChain(error: unknown): string;
60
77
  * failure so callers can fall back to their normal handling.
61
78
  */
62
79
  export declare function describeConnectivityError(error: unknown): ConnectivityError | undefined;
80
+ /**
81
+ * Classify a local OS/sandbox permission failure by walking the error graph.
82
+ *
83
+ * Recognises `EACCES`/`EPERM`/`EROFS` on the `code` property of any node in
84
+ * the `.cause` / `AggregateError.errors` graph, and falls back to the errno
85
+ * token inside the message for errors that were re-wrapped and lost their
86
+ * `code` (e.g. `catchError`'s `new Error(String(err))`). Returns `undefined`
87
+ * for anything else — including HTTP-shaped errors, which are the service's
88
+ * failures, not the local OS's.
89
+ */
90
+ export declare function describePermissionError(error: unknown): LocalPermissionError | undefined;
91
+ /**
92
+ * Parse an `HTTP <status>` prefix out of an error message. SDK wrappers often
93
+ * throw plain `Error`s shaped `HTTP 403: <body>` with no structured status
94
+ * field; every classifier that treats "has a status" as "the service
95
+ * answered" must see these too, or the local-vs-service split drifts between
96
+ * layers. Shared by {@link extractErrorDetails} and `instructionsFor`.
97
+ */
98
+ export declare function parseHttpStatusFromMessage(message: string): number | undefined;
63
99
  export declare function isHtmlDocument(body: string): boolean;
64
100
  /**
65
101
  * Extract a structured error message and details from an unknown thrown value.
@@ -2,7 +2,7 @@ import { type CommandErrorClass, type TerminalOutcome } from "./telemetry/comman
2
2
  export type OutputFormat = "table" | "json" | "yaml" | "plain";
3
3
  export type ResultType = "Success" | "Failure" | "ConfigError" | "AuthenticationError" | "ValidationError" | "TimeoutError";
4
4
  export type FailureResultType = Exclude<ResultType, "Success">;
5
- export declare const CLI_ERROR_CODES: readonly ["invalid_argument", "authentication_required", "permission_denied", "not_found", "rate_limited", "network_error", "timeout", "server_error", "method_not_allowed", "configuration_error", "unknown_error"];
5
+ export declare const CLI_ERROR_CODES: readonly ["invalid_argument", "authentication_required", "permission_denied", "local_permission_denied", "not_found", "rate_limited", "network_error", "timeout", "server_error", "method_not_allowed", "configuration_error", "unknown_error"];
6
6
  export type CliErrorCode = (typeof CLI_ERROR_CODES)[number];
7
7
  export declare const RETRY_HINTS: readonly ["RetryWillNotFix", "RetryLater", "RetryAfter1Second", "RetryAfter10Seconds", "RetryAfter30Seconds", "RetryAfter60Seconds"];
8
8
  export type RetryHint = (typeof RETRY_HINTS)[number];
@@ -41,14 +41,24 @@ export type DataRecord = Record<string, unknown> | (object & Record<never, never
41
41
  export declare class Pagination {
42
42
  Returned: number;
43
43
  Limit: number;
44
- Offset: number;
44
+ /** Absent for APIs that page by cursor instead of by offset. */
45
+ Offset?: number;
45
46
  Total?: number;
46
47
  HasMore: boolean;
47
- constructor({ returned, limit, offset, total, }: {
48
+ /**
49
+ * Opaque cursor the caller passes back to fetch the next page. Only set by
50
+ * APIs that page by cursor (e.g. PIMS instance listing); absent on the last
51
+ * page and on offset-paged commands.
52
+ */
53
+ NextPage?: string;
54
+ constructor({ returned, limit, offset, total, hasMore, nextPage, }: {
48
55
  returned: number;
49
56
  limit: number;
50
- offset: number;
57
+ offset?: number;
51
58
  total?: number;
59
+ /** Server-reported "more pages exist"; overrides the derived guess. */
60
+ hasMore?: boolean;
61
+ nextPage?: string;
52
62
  });
53
63
  }
54
64
  export declare class SuccessOutput {
@@ -77,6 +87,10 @@ export interface ErrorContext {
77
87
  method?: string;
78
88
  /** Distributed-tracing id parsed from the backend error body when present. */
79
89
  traceId?: string;
90
+ /** Local filesystem path the OS refused access to. Set only for
91
+ * `local_permission_denied` failures — it is the one datum a caller
92
+ * needs to decide which permission to grant. */
93
+ path?: string;
80
94
  }
81
95
  export declare class FailureOutput {
82
96
  Result: FailureResultType;
@@ -21052,6 +21052,16 @@ var TLS_ERROR_CODES = new Set([
21052
21052
  ]);
21053
21053
  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.";
21054
21054
  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.";
21055
+ var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
21056
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
21057
+ function localPermissionInstructions(code2, path) {
21058
+ const target = path !== undefined ? `'${path}'` : "a local file or resource";
21059
+ if (code2 === "EROFS") {
21060
+ return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
21061
+ }
21062
+ const remedy = process.platform === "win32" ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
21063
+ return `The operating system denied access to ${target} (${code2}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
21064
+ }
21055
21065
  function formatErrorChain(error) {
21056
21066
  const lines = [];
21057
21067
  const seen = new Set;
@@ -21084,16 +21094,7 @@ function formatErrorChain(error) {
21084
21094
  `);
21085
21095
  }
21086
21096
  function describeConnectivityError(error) {
21087
- const queue2 = [error];
21088
- const seen = new Set;
21089
- for (let steps = 0;queue2.length > 0 && steps < 32; steps++) {
21090
- const current = queue2.shift();
21091
- if (current === null || typeof current !== "object")
21092
- continue;
21093
- if (seen.has(current))
21094
- continue;
21095
- seen.add(current);
21096
- const cur = current;
21097
+ for (const cur of walkErrorGraph(error)) {
21097
21098
  const code2 = typeof cur.code === "string" ? cur.code : undefined;
21098
21099
  const message = typeof cur.message === "string" ? cur.message : undefined;
21099
21100
  if (code2 && TLS_ERROR_CODES.has(code2)) {
@@ -21112,6 +21113,49 @@ function describeConnectivityError(error) {
21112
21113
  instructions: NETWORK_INSTRUCTIONS
21113
21114
  };
21114
21115
  }
21116
+ }
21117
+ return;
21118
+ }
21119
+ function describePermissionError(error) {
21120
+ for (const cur of walkErrorGraph(error)) {
21121
+ const message = typeof cur.message === "string" ? cur.message : undefined;
21122
+ const code2 = matchLocalPermissionCode(cur.code, message);
21123
+ if (!code2)
21124
+ continue;
21125
+ const path = localPermissionPath(cur.path, message);
21126
+ return {
21127
+ code: code2,
21128
+ message: message ?? code2,
21129
+ ...path !== undefined ? { path } : {},
21130
+ instructions: localPermissionInstructions(code2, path)
21131
+ };
21132
+ }
21133
+ return;
21134
+ }
21135
+ function matchLocalPermissionCode(code2, message) {
21136
+ if (typeof code2 === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code2)) {
21137
+ return code2;
21138
+ }
21139
+ const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
21140
+ return match ? match[1] : undefined;
21141
+ }
21142
+ function localPermissionPath(path, message) {
21143
+ if (typeof path === "string")
21144
+ return path;
21145
+ return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
21146
+ }
21147
+ function* walkErrorGraph(error) {
21148
+ const queue2 = [error];
21149
+ const seen = new Set;
21150
+ for (let steps = 0;queue2.length > 0 && steps < 32; steps++) {
21151
+ const current = queue2.shift();
21152
+ if (current === null || typeof current !== "object")
21153
+ continue;
21154
+ if (seen.has(current))
21155
+ continue;
21156
+ seen.add(current);
21157
+ const cur = current;
21158
+ yield cur;
21115
21159
  if (cur.cause !== undefined)
21116
21160
  queue2.push(cur.cause);
21117
21161
  if (Array.isArray(cur.errors))
@@ -21172,6 +21216,12 @@ function classifyError(status, error) {
21172
21216
  if (status !== undefined && status >= 500 && status < 600) {
21173
21217
  return { errorCode: "server_error", retry: "RetryLater" };
21174
21218
  }
21219
+ if (status === undefined && describePermissionError(error)) {
21220
+ return {
21221
+ errorCode: "local_permission_denied",
21222
+ retry: "RetryWillNotFix"
21223
+ };
21224
+ }
21175
21225
  const connectivity = describeConnectivityError(error);
21176
21226
  if (connectivity) {
21177
21227
  return {
@@ -21274,6 +21324,16 @@ async function extractErrorDetails(error, options) {
21274
21324
  message = `${message}: ${connectivity.message}`;
21275
21325
  }
21276
21326
  }
21327
+ const permission = status === undefined ? describePermissionError(error) : undefined;
21328
+ if (permission) {
21329
+ if (permission.message !== message && !message.includes(permission.message)) {
21330
+ message = `${message}: ${permission.message}`;
21331
+ }
21332
+ if (!message.includes(permission.instructions)) {
21333
+ const punctuated = message.endsWith(".") ? message : `${message}.`;
21334
+ message = `${punctuated} ${permission.instructions}`;
21335
+ }
21336
+ }
21277
21337
  let details = rawMessage;
21278
21338
  if (rawBody) {
21279
21339
  if (parsedBody) {
@@ -21313,6 +21373,9 @@ async function extractErrorDetails(error, options) {
21313
21373
  if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
21314
21374
  context.traceId = parsedBody.traceId;
21315
21375
  }
21376
+ if (permission?.path !== undefined) {
21377
+ context.path = permission.path;
21378
+ }
21316
21379
  if (status === 429) {
21317
21380
  const resp = response;
21318
21381
  const headersObj = resp?.headers;
@@ -21388,7 +21451,10 @@ function extractHttpStatus(err) {
21388
21451
  if (!err || typeof err !== "object")
21389
21452
  return;
21390
21453
  const e = err;
21391
- return e.response?.status ?? e.status ?? e.statusCode;
21454
+ const structured = e.response?.status ?? e.status ?? e.statusCode;
21455
+ if (structured !== undefined)
21456
+ return structured;
21457
+ return typeof e.message === "string" ? parseHttpStatusFromMessage(e.message) : undefined;
21392
21458
  }
21393
21459
  var GENERIC = "Check authentication and parameters";
21394
21460
  function instructionsFor(ctx, err) {
@@ -21422,6 +21488,10 @@ function instructionsFor(ctx, err) {
21422
21488
  if (status !== undefined && status >= 500 && status < 600) {
21423
21489
  return "Orchestrator returned a server error — retry; if it persists, check service status";
21424
21490
  }
21491
+ const permission = describePermissionError(err);
21492
+ if (permission) {
21493
+ return permission.instructions;
21494
+ }
21425
21495
  const connectivity = describeConnectivityError(err);
21426
21496
  if (connectivity) {
21427
21497
  return connectivity.instructions;
@@ -21688,6 +21758,11 @@ function parseSafeInteger(raw, min) {
21688
21758
  }
21689
21759
  return parsed;
21690
21760
  }
21761
+ function splitScopeList(raw) {
21762
+ if (!raw)
21763
+ return [];
21764
+ return raw.split(/[\s,]+/).filter((scope) => scope.length > 0);
21765
+ }
21691
21766
  // src/orchestrator-urls.ts
21692
21767
  function requireNonEmpty(label, value) {
21693
21768
  if (typeof value !== "string" || value.trim().length === 0) {
@@ -23358,38 +23433,11 @@ async function importPackagerTool(specifier) {
23358
23433
  return registerError;
23359
23434
  }
23360
23435
 
23361
- // src/tool-module-import.ts
23362
- async function importToolModule(specifier) {
23363
- return await import(specifier);
23364
- }
23365
-
23366
23436
  // src/tool-provider.ts
23367
23437
  var factorySlot = singleton("PackagerFactoryProvider");
23368
23438
  function setPackagerFactoryProvider(provider) {
23369
23439
  factorySlot.set(provider);
23370
23440
  }
23371
- var moduleSlot = singleton("ToolModuleProvider");
23372
- function setToolModuleProvider(provider) {
23373
- moduleSlot.set(provider);
23374
- }
23375
- async function ensureToolModule(verb, packageName, moduleName) {
23376
- if (!/^[a-z0-9-]+$/.test(moduleName)) {
23377
- throw new Error(`Invalid tool module name '${moduleName}'.`);
23378
- }
23379
- const provider = moduleSlot.get();
23380
- if (provider) {
23381
- return provider(verb, moduleName);
23382
- }
23383
- const specifier = `${packageName}/${moduleName}`;
23384
- const [importError, mod] = await catchError(importToolModule(specifier));
23385
- if (importError) {
23386
- logger.debug(`No tool-module provider registered; import of '${specifier}' failed: ${importError.message}`);
23387
- throw new Error(`This command needs '${packageName}'. Install it.`, {
23388
- cause: importError
23389
- });
23390
- }
23391
- return mod;
23392
- }
23393
23441
  async function ensurePackagerFactory(verb, packageName) {
23394
23442
  const provider = factorySlot.get();
23395
23443
  if (provider) {
@@ -23413,8 +23461,8 @@ async function loadPackagerTool(specifier) {
23413
23461
  export {
23414
23462
  withCompleter,
23415
23463
  takeRecordedCommandFailureTelemetry,
23464
+ splitScopeList,
23416
23465
  singleton,
23417
- setToolModuleProvider,
23418
23466
  setSdkUserAgentHostToken,
23419
23467
  setPackagerFactoryProvider,
23420
23468
  setOutputFormatExplicit,
@@ -23434,6 +23482,7 @@ export {
23434
23482
  parseOffset,
23435
23483
  parseNonNegativeInteger,
23436
23484
  parseLimit,
23485
+ parseHttpStatusFromMessage,
23437
23486
  parseBoundedInt,
23438
23487
  normalizeSkillName,
23439
23488
  msToDuration,
@@ -23470,8 +23519,8 @@ export {
23470
23519
  extractErrorMessage,
23471
23520
  extractErrorDetails,
23472
23521
  extractCommandHelp,
23473
- ensureToolModule,
23474
23522
  ensurePackagerFactory,
23523
+ describePermissionError,
23475
23524
  describeConnectivityError,
23476
23525
  createPollAbortController,
23477
23526
  configureLogger,
@@ -23510,4 +23559,4 @@ export {
23510
23559
  AUTH_FILENAME
23511
23560
  };
23512
23561
 
23513
- //# debugId=C2BB3B73AD55AF7D64756E2164756E21
23562
+ //# debugId=8E9A65CE1EE8015D64756E2164756E21
package/dist/index.d.ts CHANGED
@@ -33,7 +33,6 @@ export * from "./registry";
33
33
  export * from "./screen-logger";
34
34
  export * from "./sdk-user-agent";
35
35
  export * from "./singleton";
36
- export * from "./solution-project-artifacts";
37
36
  export * from "./solution-project-types";
38
37
  export * from "./stdin";
39
38
  export { BrowserContextStorage } from "./telemetry/browser-context-storage.js";
package/dist/index.js CHANGED
@@ -8182,6 +8182,16 @@ var TLS_ERROR_CODES = new Set([
8182
8182
  ]);
8183
8183
  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.";
8184
8184
  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.";
8185
+ var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
8186
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
8187
+ function localPermissionInstructions(code, path3) {
8188
+ const target = path3 !== undefined ? `'${path3}'` : "a local file or resource";
8189
+ if (code === "EROFS") {
8190
+ return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
8191
+ }
8192
+ const remedy = process.platform === "win32" ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
8193
+ return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
8194
+ }
8185
8195
  function formatErrorChain(error) {
8186
8196
  const lines = [];
8187
8197
  const seen = new Set;
@@ -8214,16 +8224,7 @@ function formatErrorChain(error) {
8214
8224
  `);
8215
8225
  }
8216
8226
  function describeConnectivityError(error) {
8217
- const queue = [error];
8218
- const seen = new Set;
8219
- for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
8220
- const current = queue.shift();
8221
- if (current === null || typeof current !== "object")
8222
- continue;
8223
- if (seen.has(current))
8224
- continue;
8225
- seen.add(current);
8226
- const cur = current;
8227
+ for (const cur of walkErrorGraph(error)) {
8227
8228
  const code = typeof cur.code === "string" ? cur.code : undefined;
8228
8229
  const message = typeof cur.message === "string" ? cur.message : undefined;
8229
8230
  if (code && TLS_ERROR_CODES.has(code)) {
@@ -8242,6 +8243,49 @@ function describeConnectivityError(error) {
8242
8243
  instructions: NETWORK_INSTRUCTIONS
8243
8244
  };
8244
8245
  }
8246
+ }
8247
+ return;
8248
+ }
8249
+ function describePermissionError(error) {
8250
+ for (const cur of walkErrorGraph(error)) {
8251
+ const message = typeof cur.message === "string" ? cur.message : undefined;
8252
+ const code = matchLocalPermissionCode(cur.code, message);
8253
+ if (!code)
8254
+ continue;
8255
+ const path3 = localPermissionPath(cur.path, message);
8256
+ return {
8257
+ code,
8258
+ message: message ?? code,
8259
+ ...path3 !== undefined ? { path: path3 } : {},
8260
+ instructions: localPermissionInstructions(code, path3)
8261
+ };
8262
+ }
8263
+ return;
8264
+ }
8265
+ function matchLocalPermissionCode(code, message) {
8266
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
8267
+ return code;
8268
+ }
8269
+ const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
8270
+ return match ? match[1] : undefined;
8271
+ }
8272
+ function localPermissionPath(path3, message) {
8273
+ if (typeof path3 === "string")
8274
+ return path3;
8275
+ return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
8276
+ }
8277
+ function* walkErrorGraph(error) {
8278
+ const queue = [error];
8279
+ const seen = new Set;
8280
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
8281
+ const current = queue.shift();
8282
+ if (current === null || typeof current !== "object")
8283
+ continue;
8284
+ if (seen.has(current))
8285
+ continue;
8286
+ seen.add(current);
8287
+ const cur = current;
8288
+ yield cur;
8245
8289
  if (cur.cause !== undefined)
8246
8290
  queue.push(cur.cause);
8247
8291
  if (Array.isArray(cur.errors))
@@ -8302,6 +8346,12 @@ function classifyError(status, error) {
8302
8346
  if (status !== undefined && status >= 500 && status < 600) {
8303
8347
  return { errorCode: "server_error", retry: "RetryLater" };
8304
8348
  }
8349
+ if (status === undefined && describePermissionError(error)) {
8350
+ return {
8351
+ errorCode: "local_permission_denied",
8352
+ retry: "RetryWillNotFix"
8353
+ };
8354
+ }
8305
8355
  const connectivity = describeConnectivityError(error);
8306
8356
  if (connectivity) {
8307
8357
  return {
@@ -8404,6 +8454,16 @@ async function extractErrorDetails(error, options) {
8404
8454
  message = `${message}: ${connectivity.message}`;
8405
8455
  }
8406
8456
  }
8457
+ const permission = status === undefined ? describePermissionError(error) : undefined;
8458
+ if (permission) {
8459
+ if (permission.message !== message && !message.includes(permission.message)) {
8460
+ message = `${message}: ${permission.message}`;
8461
+ }
8462
+ if (!message.includes(permission.instructions)) {
8463
+ const punctuated = message.endsWith(".") ? message : `${message}.`;
8464
+ message = `${punctuated} ${permission.instructions}`;
8465
+ }
8466
+ }
8407
8467
  let details = rawMessage;
8408
8468
  if (rawBody) {
8409
8469
  if (parsedBody) {
@@ -8443,6 +8503,9 @@ async function extractErrorDetails(error, options) {
8443
8503
  if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
8444
8504
  context.traceId = parsedBody.traceId;
8445
8505
  }
8506
+ if (permission?.path !== undefined) {
8507
+ context.path = permission.path;
8508
+ }
8446
8509
  if (status === 429) {
8447
8510
  const resp = response;
8448
8511
  const headersObj = resp?.headers;
@@ -10612,6 +10675,7 @@ var CLI_ERROR_CODES = [
10612
10675
  "invalid_argument",
10613
10676
  "authentication_required",
10614
10677
  "permission_denied",
10678
+ "local_permission_denied",
10615
10679
  "not_found",
10616
10680
  "rate_limited",
10617
10681
  "network_error",
@@ -10652,19 +10716,32 @@ class Pagination {
10652
10716
  Offset;
10653
10717
  Total;
10654
10718
  HasMore;
10719
+ NextPage;
10655
10720
  constructor({
10656
10721
  returned,
10657
10722
  limit,
10658
10723
  offset,
10659
- total
10724
+ total,
10725
+ hasMore,
10726
+ nextPage
10660
10727
  }) {
10661
10728
  this.Returned = returned;
10662
10729
  this.Limit = limit;
10663
10730
  this.Offset = offset;
10664
10731
  this.Total = total;
10665
- this.HasMore = total === undefined ? returned === limit : offset + returned < total;
10732
+ this.HasMore = hasMore ?? derivePaginationHasMore(returned, limit, offset, total, nextPage);
10733
+ this.NextPage = nextPage;
10666
10734
  }
10667
10735
  }
10736
+ function derivePaginationHasMore(returned, limit, offset, total, nextPage) {
10737
+ if (nextPage) {
10738
+ return true;
10739
+ }
10740
+ if (total === undefined) {
10741
+ return returned >= limit;
10742
+ }
10743
+ return (offset ?? 0) + returned < total;
10744
+ }
10668
10745
 
10669
10746
  class SuccessOutput {
10670
10747
  Result = RESULTS.Success;
@@ -11111,12 +11188,16 @@ function defaultErrorCodeForHttpStatus(status) {
11111
11188
  return "server_error";
11112
11189
  return;
11113
11190
  }
11191
+ var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
11114
11192
  function defaultErrorCodeForFailure(data) {
11115
11193
  if (data.Result === RESULTS.Failure) {
11116
11194
  const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
11117
11195
  const errorCode = defaultErrorCodeForHttpStatus(status);
11118
11196
  if (errorCode)
11119
11197
  return errorCode;
11198
+ if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
11199
+ return "local_permission_denied";
11200
+ }
11120
11201
  }
11121
11202
  return defaultErrorCodeForResult(data.Result);
11122
11203
  }
@@ -11796,7 +11877,10 @@ function extractHttpStatus(err) {
11796
11877
  if (!err || typeof err !== "object")
11797
11878
  return;
11798
11879
  const e = err;
11799
- return e.response?.status ?? e.status ?? e.statusCode;
11880
+ const structured = e.response?.status ?? e.status ?? e.statusCode;
11881
+ if (structured !== undefined)
11882
+ return structured;
11883
+ return typeof e.message === "string" ? parseHttpStatusFromMessage(e.message) : undefined;
11800
11884
  }
11801
11885
  var GENERIC = "Check authentication and parameters";
11802
11886
  function instructionsFor(ctx, err) {
@@ -11830,6 +11914,10 @@ function instructionsFor(ctx, err) {
11830
11914
  if (status !== undefined && status >= 500 && status < 600) {
11831
11915
  return "Orchestrator returned a server error — retry; if it persists, check service status";
11832
11916
  }
11917
+ const permission = describePermissionError(err);
11918
+ if (permission) {
11919
+ return permission.instructions;
11920
+ }
11833
11921
  const connectivity = describeConnectivityError(err);
11834
11922
  if (connectivity) {
11835
11923
  return connectivity.instructions;
@@ -11984,6 +12072,11 @@ function parseSafeInteger(raw, min) {
11984
12072
  }
11985
12073
  return parsed;
11986
12074
  }
12075
+ function splitScopeList(raw) {
12076
+ if (!raw)
12077
+ return [];
12078
+ return raw.split(/[\s,]+/).filter((scope) => scope.length > 0);
12079
+ }
11987
12080
  // src/orchestrator-urls.ts
11988
12081
  function requireNonEmpty(label, value) {
11989
12082
  if (typeof value !== "string" || value.trim().length === 0) {
@@ -12673,68 +12766,6 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
12673
12766
  function installSdkCodingAgentHeader(BaseApiClass) {
12674
12767
  installRequestHeaderForwarding(BaseApiClass, codingAgentPatchKey(), (headers) => addSdkCodingAgentHeader(headers));
12675
12768
  }
12676
- // src/tool-module-import.ts
12677
- async function importToolModule(specifier) {
12678
- return await import(specifier);
12679
- }
12680
-
12681
- // src/tool-provider.ts
12682
- var factorySlot = singleton("PackagerFactoryProvider");
12683
- function setPackagerFactoryProvider(provider) {
12684
- factorySlot.set(provider);
12685
- }
12686
- var moduleSlot = singleton("ToolModuleProvider");
12687
- function setToolModuleProvider(provider) {
12688
- moduleSlot.set(provider);
12689
- }
12690
- async function ensureToolModule(verb, packageName, moduleName) {
12691
- if (!/^[a-z0-9-]+$/.test(moduleName)) {
12692
- throw new Error(`Invalid tool module name '${moduleName}'.`);
12693
- }
12694
- const provider = moduleSlot.get();
12695
- if (provider) {
12696
- return provider(verb, moduleName);
12697
- }
12698
- const specifier = `${packageName}/${moduleName}`;
12699
- const [importError, mod2] = await catchError(importToolModule(specifier));
12700
- if (importError) {
12701
- logger.debug(`No tool-module provider registered; import of '${specifier}' failed: ${importError.message}`);
12702
- throw new Error(`This command needs '${packageName}'. Install it.`, {
12703
- cause: importError
12704
- });
12705
- }
12706
- return mod2;
12707
- }
12708
- async function ensurePackagerFactory(verb, packageName) {
12709
- const provider = factorySlot.get();
12710
- if (provider) {
12711
- await provider(verb);
12712
- return;
12713
- }
12714
- const importError = packageName ? await loadPackagerTool(`${packageName}/packager-tool`) : undefined;
12715
- if (packageName && !importError)
12716
- return;
12717
- throw new Error(packageName ? `Packing this project type needs '${packageName}'. Install it.` : `Packing this project type needs the packager factory for '${verb}', and no package provides it.`, { cause: importError });
12718
- }
12719
- async function loadPackagerTool(specifier) {
12720
- const error = await importPackagerTool(specifier);
12721
- if (error) {
12722
- logger.debug(`No packager factory provider registered; import of '${specifier}' failed: ${error.message}`);
12723
- return error;
12724
- }
12725
- logger.debug(`No packager factory provider registered; loaded '${specifier}' directly.`);
12726
- return;
12727
- }
12728
-
12729
- // src/solution-project-artifacts.ts
12730
- async function ensureProjectArtifacts(args) {
12731
- const [error, mod2] = await catchError(ensureToolModule("solution", "@uipath/solution-tool", "init"));
12732
- if (error) {
12733
- logger.warn(`Solution artifact-resource generation skipped for project "${args.projectName}": ${error.message}. ` + "Run 'uip solution projects add' to finish setup.");
12734
- return { Created: false, Error: error.message };
12735
- }
12736
- return mod2.addProjectArtifactsToSolutionAsync(args);
12737
- }
12738
12769
  // src/solution-project-types.ts
12739
12770
  var LIBRARY_NOT_A_PROJECT = "A library cannot be a project inside a solution — it is a reusable .nupkg that other projects consume as a NuGet dependency, not a deployable unit. Build and publish it on its own ('uip rpa pack <project-dir> <output-path>', then 'uip or libraries upload --file <nupkg-path>'), and reference it from a project's dependencies. To make the published library part of this solution, add it as a resource instead: 'uip solution resources add --source remote --kind Library --name <library-name>'.";
12740
12771
  function unsupportedSolutionProjectType(projectType) {
@@ -12842,6 +12873,31 @@ function trackShipSucceeded(payload) {
12842
12873
  telemetry.trackEvent(CommonTelemetryEvents.ShipSucceeded, redactProperties({ ...payload }));
12843
12874
  return true;
12844
12875
  }
12876
+ // src/tool-provider.ts
12877
+ var factorySlot = singleton("PackagerFactoryProvider");
12878
+ function setPackagerFactoryProvider(provider) {
12879
+ factorySlot.set(provider);
12880
+ }
12881
+ async function ensurePackagerFactory(verb, packageName) {
12882
+ const provider = factorySlot.get();
12883
+ if (provider) {
12884
+ await provider(verb);
12885
+ return;
12886
+ }
12887
+ const importError = packageName ? await loadPackagerTool(`${packageName}/packager-tool`) : undefined;
12888
+ if (packageName && !importError)
12889
+ return;
12890
+ throw new Error(packageName ? `Packing this project type needs '${packageName}'. Install it.` : `Packing this project type needs the packager factory for '${verb}', and no package provides it.`, { cause: importError });
12891
+ }
12892
+ async function loadPackagerTool(specifier) {
12893
+ const error = await importPackagerTool(specifier);
12894
+ if (error) {
12895
+ logger.debug(`No packager factory provider registered; import of '${specifier}' failed: ${error.message}`);
12896
+ return error;
12897
+ }
12898
+ logger.debug(`No packager factory provider registered; loaded '${specifier}' directly.`);
12899
+ return;
12900
+ }
12845
12901
  export {
12846
12902
  writeTelemetrySpoolFile,
12847
12903
  withCompleter,
@@ -12858,8 +12914,8 @@ export {
12858
12914
  takeRecordedCommandFailureTelemetry,
12859
12915
  sweepTelemetrySpool,
12860
12916
  stripHostGlobalOptions,
12917
+ splitScopeList,
12861
12918
  singleton,
12862
- setToolModuleProvider,
12863
12919
  setTelemetrySidecarEntry,
12864
12920
  setSdkUserAgentHostToken,
12865
12921
  setProxyAuthHttpsAgent,
@@ -12904,6 +12960,7 @@ export {
12904
12960
  parseNonNegativeInteger,
12905
12961
  parseLimit,
12906
12962
  parseInboundTraceparent,
12963
+ parseHttpStatusFromMessage,
12907
12964
  parseBoundedInt,
12908
12965
  parseAttachmentSpec,
12909
12966
  normalizeSkillName,
@@ -12957,13 +13014,12 @@ export {
12957
13014
  extractErrorDetails,
12958
13015
  extractCommandHelp,
12959
13016
  escapeNonAscii,
12960
- ensureToolModule,
12961
- ensureProjectArtifacts,
12962
13017
  ensurePackagerFactory,
12963
13018
  discardClaimedSpoolFile,
12964
13019
  detectExecutionContext,
12965
13020
  detectAgentVersion,
12966
13021
  detectAgent,
13022
+ describePermissionError,
12967
13023
  describeConnectivityError,
12968
13024
  deriveCommandPath,
12969
13025
  createTelemetryProvider,
@@ -13037,4 +13093,4 @@ export {
13037
13093
  ATTACHMENT_INSTRUCTIONS
13038
13094
  };
13039
13095
 
13040
- //# debugId=A4E6BBF59E547A0B64756E2164756E21
13096
+ //# debugId=8077A5752FBAFF2864756E2164756E21
@@ -33,3 +33,17 @@ export declare function parseBoundedInt(raw: string, optionName: string, bounds:
33
33
  }): number;
34
34
  export declare function parsePositiveInteger(raw: string): number | undefined;
35
35
  export declare function parseNonNegativeInteger(raw: string): number | undefined;
36
+ /**
37
+ * Split an OAuth scope list into individual scope names.
38
+ *
39
+ * Accepts both separators the CLI has historically used: the OAuth2
40
+ * space-separated form (`uip login --scope`) and the comma-separated form
41
+ * (`uip admin external-apps --user-scope`). Space is safe to split on
42
+ * because RFC 6749 uses it as the scope delimiter. Comma is not reserved by
43
+ * the RFC — a `scope-token` may legally contain one — but no UiPath scope
44
+ * name does, and the server validates every name it is sent, so a
45
+ * wrongly-split name fails as unknown rather than granting anything extra.
46
+ *
47
+ * Returns an empty array for undefined, empty, or separator-only input.
48
+ */
49
+ export declare function splitScopeList(raw: string | undefined): string[];
@@ -1,28 +1,8 @@
1
1
  /**
2
- * Cross-module bridge for packager factory and tool-module resolution.
2
+ * Cross-module bridge for packager factory resolution.
3
3
  */
4
4
  export type PackagerFactoryProvider = (verb: string) => Promise<void>;
5
5
  export declare function setPackagerFactoryProvider(provider: PackagerFactoryProvider): void;
6
- export type ToolModuleProvider = (verb: string, moduleName: string) => Promise<unknown>;
7
- export declare function setToolModuleProvider(provider: ToolModuleProvider): void;
8
- /**
9
- * Resolve another tool's library entry point (its `dist/<module>.js` subpath
10
- * export) at runtime and return the module namespace.
11
- *
12
- * Prefers the registered provider (installed by the CLI — it can install the
13
- * tool on demand and imports the entry by absolute path). With no provider —
14
- * a library caller — falls back to importing `<packageName>/<moduleName>`,
15
- * which resolves when the tool package is installed next to the caller.
16
- *
17
- * This is how one tool uses another tool's code without bundling it: the
18
- * multi-megabyte implementation ships once, in the tool that owns it.
19
- *
20
- * @param verb - CLI tool verb that owns the module (e.g. `"solution"`).
21
- * @param packageName - npm package behind that verb, used for the fallback
22
- * import (e.g. `"@uipath/solution-tool"`).
23
- * @param moduleName - subpath entry to load (e.g. `"init"`, `"resource"`).
24
- */
25
- export declare function ensureToolModule(verb: string, packageName: string, moduleName: string): Promise<unknown>;
26
6
  /**
27
7
  * Resolve the packager factory for a tool verb.
28
8
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/common",
3
3
  "license": "MIT",
4
- "version": "1.201.0-preview.115",
4
+ "version": "1.201.0-preview.122",
5
5
  "description": "Common infrastructure needed by uip tools.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -71,5 +71,5 @@
71
71
  "mihaigirleanu",
72
72
  "vlad-uipath"
73
73
  ],
74
- "gitHead": "f1086b73654d7728cb71f280588b3e0c77d535fc"
74
+ "gitHead": "6c56f56100be96231fccbaa59e99d64d94808d58"
75
75
  }
@@ -1,43 +0,0 @@
1
- /**
2
- * Shared `ensureProjectArtifacts` used by every `*-tool init` path (agent,
3
- * case, codedapp, flow, maestro). Lives here so the five tools don't each
4
- * carry a copy; each tool re-exports it from its own
5
- * `src/services/project-artifacts.ts` shim (the browser-build
6
- * `excludedImports` stub mechanism resolves only relative paths under each
7
- * tool's own src tree).
8
- */
9
- /** Options forwarded to solution-tool's `addProjectArtifactsToSolutionAsync`. */
10
- export interface EnsureProjectArtifactsArgs {
11
- /** Absolute path to the solution directory (containing the `.uipx`). */
12
- solutionDir: string;
13
- /** Stable project key — must match the `Id` in `.uipx` `Projects[]`. */
14
- projectId: string;
15
- /** Display name for the project; typically the project folder name. */
16
- projectName: string;
17
- /** Project type as written to `project.uiproj` (e.g. `Flow`, `Agent`). */
18
- projectType: string;
19
- /** Optional SDK subType (AppV2: `"Coded"` / `"CodedAction"`). */
20
- projectSubType?: string;
21
- }
22
- /**
23
- * Result envelope. Structurally identical to `ProjectArtifactsResult` in
24
- * `@uipath/solution-sdk/resources` — declared here too because this
25
- * package sits below `solution-sdk` in the dependency graph and cannot import
26
- * from it.
27
- */
28
- export interface ProjectArtifactsResult {
29
- /** True when artifact resources were generated. */
30
- Created: boolean;
31
- /** Error message when `Created` is `false`. */
32
- Error?: string;
33
- }
34
- /**
35
- * Generate the `resources/solution_folder/...` artifact-resource entries for
36
- * a project that has just been registered in its parent solution's `.uipx`.
37
- *
38
- * The implementation is resolved at runtime from the installed
39
- * `@uipath/solution-tool` (through the CLI host's tool-module provider, which
40
- * installs it on demand), so the multi-megabyte resource-builder chain is
41
- * never bundled into the calling tool.
42
- */
43
- export declare function ensureProjectArtifacts(args: EnsureProjectArtifactsArgs): Promise<ProjectArtifactsResult>;
@@ -1,9 +0,0 @@
1
- /**
2
- * Dynamic import of another tool's library entry point (e.g.
3
- * `@uipath/solution-tool/init`).
4
- *
5
- * Its own module so tests can stand in for it, and so the specifier stays a
6
- * plain variable — bundlers then leave the `import()` to run at runtime
7
- * instead of inlining the multi-megabyte target bundle into the caller.
8
- */
9
- export declare function importToolModule(specifier: string): Promise<unknown>;