@uipath/common 1.200.0-preview.120 → 1.201.0-preview.121

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.
@@ -0,0 +1,6 @@
1
+ import { Command } from "commander";
2
+ import "./command-examples";
3
+ import "./preview";
4
+ import "./trackedAction.js";
5
+ /** Install Common's Commander augmentations on a caller-owned constructor. */
6
+ export declare function installCommandExtensions(commandConstructor: typeof Command): void;
@@ -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;
@@ -142,6 +156,9 @@ export declare function escapeNonAscii(jsonText: string): string;
142
156
  * successfully can still throw at evaluation time (e.g. type-coercion errors
143
157
  * when functions receive unexpected types). Callers that need a fully
144
158
  * closed-box guarantee must additionally wrap {@link applyFilter}.
159
+ *
160
+ * Requires `loadOutputCodecsAsync({ filter: true })` to have run — the CLI
161
+ * host awaits it immediately before calling this.
145
162
  */
146
163
  export declare function validateOutputFilter(filter: string): Error | null;
147
164
  /**
@@ -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
@@ -2,6 +2,7 @@ export * from "./attachment-binding";
2
2
  export * from "./body-validators";
3
3
  export * from "./catch-error";
4
4
  export * from "./command-examples";
5
+ export * from "./command-extensions";
5
6
  export * from "./command-help";
6
7
  export * from "./command-walker";
7
8
  export * from "./completer";
@@ -20,6 +21,7 @@ export * from "./logger";
20
21
  export * from "./option-aliases";
21
22
  export * from "./option-validators";
22
23
  export * from "./orchestrator-urls";
24
+ export * from "./output-codecs";
23
25
  export * from "./output-context";
24
26
  export * from "./output-format-context";
25
27
  export * from "./output-sink";
@@ -31,7 +33,7 @@ export * from "./registry";
31
33
  export * from "./screen-logger";
32
34
  export * from "./sdk-user-agent";
33
35
  export * from "./singleton";
34
- export * from "./solution-project-artifacts";
36
+ export * from "./solution-project-types";
35
37
  export * from "./stdin";
36
38
  export { BrowserContextStorage } from "./telemetry/browser-context-storage.js";
37
39
  export * from "./telemetry/command-attribution.js";
@@ -40,6 +42,7 @@ export { ConsoleTelemetryProvider } from "./telemetry/console-telemetry-provider
40
42
  export * from "./telemetry/node.js";
41
43
  export { setGlobalTelemetryProperties } from "./telemetry/node-appinsights-telemetry-provider.js";
42
44
  export { redactError, redactProperties, redactProperty, redactValue, } from "./telemetry/pii-redactor.js";
45
+ export { getProxyAuthHttpsAgent, setProxyAuthHttpsAgent, } from "./telemetry/proxy-http-agent.js";
43
46
  export { type ShipSucceededTelemetryPayload, trackShipSucceeded, } from "./telemetry/ship-succeeded.js";
44
47
  export * from "./telemetry/telemetry-events.js";
45
48
  export * from "./telemetry/telemetry-init.js";