@uipath/common 1.196.0 → 1.197.0-preview.59

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.
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * Process-wide interactivity mode.
3
3
  *
4
- * The CLI is non-interactive by default: an automation agent or CI runner can
5
- * never answer a `y/N` prompt, so a hidden prompt hangs the caller forever.
4
+ * The CLI prompts by default only when both stdout and stdin are attached to an
5
+ * interactive terminal. An automation agent or CI runner can never answer a
6
+ * `y/N` prompt, so piped input or redirected output stays non-interactive.
6
7
  * Commands consult {@link canPrompt} before showing any optional/selection
7
8
  * prompt; when it returns `false` they must fall back to a flag-driven path or
8
9
  * fail fast with a structured error naming the flag to pass.
9
10
  *
10
11
  * Modes:
11
- * - "never" — never prompt (the default; the safe machine-first contract).
12
- * - "auto" — prompt only when stdout is a TTY (opt-in via config for humans).
12
+ * - "never" — never prompt.
13
+ * - "auto" — prompt only when stdout and stdin are TTYs (the default).
13
14
  * - "always" — always prompt (assume a prompt-capable terminal).
14
15
  *
15
16
  * Stored via {@link singleton} so the value set once by the CLI host is visible
@@ -21,13 +22,12 @@
21
22
  export type InteractivityMode = "never" | "auto" | "always";
22
23
  /** Set the process-wide interactivity mode. Called once at CLI startup. */
23
24
  export declare function setInteractivityMode(mode: InteractivityMode): void;
24
- /** Get the current interactivity mode, defaulting to "never". */
25
+ /** Get the current interactivity mode, defaulting to "auto". */
25
26
  export declare function getInteractivityMode(): InteractivityMode;
26
27
  /**
27
28
  * True when the CLI may show an interactive prompt right now.
28
29
  *
29
30
  * "always" always prompts; "never" never does; "auto" prompts only when the
30
- * output sink reports an interactive (TTY) terminal the canonical signal also
31
- * used by `login` and `completion`.
31
+ * output sink reports an interactive (TTY) terminal and prompt-readable stdin.
32
32
  */
33
33
  export declare function canPrompt(): boolean;
@@ -14,8 +14,10 @@ export interface OutputSink {
14
14
  readonly capabilities: SinkCapabilities;
15
15
  }
16
16
  export interface SinkCapabilities {
17
- /** True when a human is reading (TTY). False for piped, MCP, browser. */
17
+ /** True when stdout is a TTY. False for piped output, MCP, browser. */
18
18
  isInteractive: boolean;
19
+ /** True when stdin can be read interactively (TTY). False for piped input. */
20
+ canReadInput: boolean;
19
21
  /** True when ANSI escape codes are supported. */
20
22
  supportsColor: boolean;
21
23
  /** Terminal width, or a sensible default (80/120). */
@@ -8,6 +8,8 @@ import type { Command } from "commander";
8
8
  * Commands extend their own option interface with this.
9
9
  */
10
10
  export interface PackageMetadataCliOptions {
11
+ author?: string;
12
+ description?: string;
11
13
  repositoryUrl?: string;
12
14
  repositoryCommit?: string;
13
15
  repositoryBranch?: string;
@@ -1,9 +1,13 @@
1
1
  // src/package-metadata-options.ts
2
2
  function registerPackageMetadataOptions(command) {
3
- return command.option("--repository-url <url>", "Source repository URL (recorded in the package for traceability)").option("--repository-commit <sha>", "Source repository commit hash (recorded in the package for traceability)").option("--repository-branch <branch>", "Source repository branch").option("--repository-type <type>", "Source repository type (defaults to 'git' when --repository-url is set)").option("--release-notes <text>", "Release notes for the package").option("--project-url <url>", "Automation Hub idea URL");
3
+ return command.option("--author <author>", "Package author").option("--description <text>", "Package description").option("--repository-url <url>", "Source repository URL (recorded in the package for traceability)").option("--repository-commit <sha>", "Source repository commit hash (recorded in the package for traceability)").option("--repository-branch <branch>", "Source repository branch").option("--repository-type <type>", "Source repository type (defaults to 'git' when --repository-url is set)").option("--release-notes <text>", "Release notes for the package").option("--project-url <url>", "Automation Hub idea URL");
4
4
  }
5
5
  function mapPackageMetadataOptions(opts) {
6
6
  const fields = {};
7
+ if (opts.author !== undefined)
8
+ fields.author = opts.author;
9
+ if (opts.description !== undefined)
10
+ fields.description = opts.description;
7
11
  if (opts.releaseNotes !== undefined)
8
12
  fields.releaseNotes = opts.releaseNotes;
9
13
  if (opts.projectUrl !== undefined)
@@ -25,3 +29,5 @@ export {
25
29
  registerPackageMetadataOptions,
26
30
  mapPackageMetadataOptions
27
31
  };
32
+
33
+ //# debugId=D76F2616EBFEF0E864756E2164756E21
@@ -0,0 +1,53 @@
1
+ import { type CommandOptions } from "commander";
2
+ /**
3
+ * Publish whether the running CLI is a preview build. Called once by the CLI
4
+ * host during startup, before any command (root or tool) is registered.
5
+ *
6
+ * "Preview" means the CLI binary's own version (`pkg.version`) carries any
7
+ * prerelease tag — `alpha`, `beta`, or `preview`. The host computes that from
8
+ * its version alone; this module stays free of any version-parsing logic so
9
+ * it can ship in every tool bundle.
10
+ */
11
+ export declare function setPreviewBuild(isPreview: boolean): void;
12
+ /**
13
+ * True when the running CLI is a preview (prerelease) build.
14
+ *
15
+ * Defaults to `false` when the host never called {@link setPreviewBuild} —
16
+ * e.g. a tool's unit tests that don't boot the CLI host — so preview-only
17
+ * commands stay unregistered unless a preview build explicitly opted in.
18
+ */
19
+ export declare function isPreviewBuild(): boolean;
20
+ /**
21
+ * Register a command (or run any setup) only on preview builds.
22
+ *
23
+ * Ergonomic guard for `registerCommands`: on a stable build `register` is
24
+ * never called, so the command is not added to Commander at all — invoking it
25
+ * yields the standard "unknown command" error. On a preview build it
26
+ * registers normally.
27
+ *
28
+ * export const registerCommands = async (program: Command) => {
29
+ * registerStableCommand(program);
30
+ * previewOnly(() => registerExperimentalCommand(program));
31
+ * };
32
+ */
33
+ export declare function previewOnly(register: () => void): void;
34
+ declare module "commander" {
35
+ interface Command {
36
+ /**
37
+ * Drop-in for `.command(nameAndArgs, opts)` that attaches the
38
+ * subcommand only on preview (prerelease) builds.
39
+ *
40
+ * On a preview build it behaves exactly like `.command(...)`. On a
41
+ * stable build it returns a *detached* Command: the chained
42
+ * `.description()` / `.option()` / `.trackedAction()` calls still
43
+ * type-check and run, but the command is never added to this program,
44
+ * so invoking it yields the standard "unknown command" error.
45
+ *
46
+ * entities
47
+ * .previewCommand("bulk-import <file>")
48
+ * .description("experimental bulk import")
49
+ * .trackedAction(processContext, async () => { ... });
50
+ */
51
+ previewCommand(nameAndArgs: string, opts?: CommandOptions): Command;
52
+ }
53
+ }
@@ -5,8 +5,21 @@ export interface SdkUserAgentPackageInfo {
5
5
  export type SdkHttpHeaders = Record<string, string>;
6
6
  export declare function getSdkUserAgentToken(pkg: SdkUserAgentPackageInfo): string;
7
7
  export declare function setSdkUserAgentHostToken(token: string | undefined): void;
8
+ /**
9
+ * Forwards the SDK `User-Agent` token, prefixed with the host token (e.g.
10
+ * `uip/1.1.0`) when one is configured. Appends to any existing value without
11
+ * duplicating tokens and preserves the caller's header casing.
12
+ */
8
13
  export declare function addSdkUserAgentHeader(headers: SdkHttpHeaders | undefined, userAgent: string): SdkHttpHeaders;
9
- export declare function withSdkUserAgentHeader(headers: unknown, userAgent: string): unknown;
14
+ /**
15
+ * Forwards the telemetry `agent` via `x-coding-agent-info` as a JSON envelope —
16
+ * `{"CodingAgent":"<agent>"}`; preserves the caller's header casing.
17
+ * Leaves the header absent when no agent is available.
18
+ */
19
+ export declare function addSdkCodingAgentHeader(headers: SdkHttpHeaders | undefined, agent?: string | undefined): SdkHttpHeaders;
10
20
  export declare function installSdkUserAgentHeader(BaseApiClass: {
11
21
  prototype: unknown;
12
22
  }, userAgent: string): void;
23
+ export declare function installSdkCodingAgentHeader(BaseApiClass: {
24
+ prototype: unknown;
25
+ }): void;
@@ -28,12 +28,30 @@ function singleton(ctorOrName) {
28
28
  };
29
29
  }
30
30
 
31
+ // src/telemetry/global-telemetry-properties.ts
32
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
33
+ function getGlobalTelemetryProperties() {
34
+ return telemetryPropsSlot.get();
35
+ }
36
+
37
+ // src/telemetry/telemetry-config.ts
38
+ function isTelemetryDisabled() {
39
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
40
+ return value === "1" || value === "true";
41
+ }
42
+
31
43
  // src/sdk-user-agent.ts
32
44
  var USER_AGENT_HEADER = "User-Agent";
45
+ var CODING_AGENT_HEADER = "x-coding-agent-info";
46
+ var AGENT_PROPERTY = "agent";
47
+ var CODING_AGENT_PROPERTY = "CodingAgent";
33
48
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
34
49
  function userAgentPatchKey(userAgent) {
35
50
  return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
36
51
  }
52
+ function codingAgentPatchKey() {
53
+ return Symbol.for("@uipath/common/sdk-coding-agent");
54
+ }
37
55
  function splitUserAgentTokens(value) {
38
56
  return value?.trim().split(/\s+/).filter(Boolean) ?? [];
39
57
  }
@@ -51,8 +69,15 @@ function appendUserAgentToken(value, userAgent) {
51
69
  function getEffectiveUserAgent(userAgent) {
52
70
  return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
53
71
  }
54
- function isHeadersLike(headers) {
55
- return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
72
+ function getHeaderName(headers, headerName) {
73
+ return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
74
+ }
75
+ function getSdkAgentInfo() {
76
+ if (isTelemetryDisabled()) {
77
+ return;
78
+ }
79
+ const agent = getGlobalTelemetryProperties()?.[AGENT_PROPERTY];
80
+ return agent === undefined ? undefined : String(agent);
56
81
  }
57
82
  function getSdkUserAgentToken(pkg) {
58
83
  const packageName = pkg.name.replace(/^@uipath\//, "");
@@ -67,59 +92,42 @@ function setSdkUserAgentHostToken(token) {
67
92
  }
68
93
  function addSdkUserAgentHeader(headers, userAgent) {
69
94
  const result = { ...headers ?? {} };
70
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
71
- const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
72
- if (headerName) {
73
- result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
74
- } else {
75
- result[USER_AGENT_HEADER] = effectiveUserAgent;
76
- }
95
+ const headerName = getHeaderName(result, USER_AGENT_HEADER);
96
+ result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
77
97
  return result;
78
98
  }
79
- function withSdkUserAgentHeader(headers, userAgent) {
80
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
81
- if (isHeadersLike(headers)) {
82
- headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
83
- return headers;
84
- }
85
- if (Array.isArray(headers)) {
86
- const result = headers.map((entry) => {
87
- const [key, value] = entry;
88
- return [key, value];
89
- });
90
- const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
91
- if (headerIndex >= 0) {
92
- const [key, value] = result[headerIndex];
93
- result[headerIndex] = [
94
- key,
95
- appendUserAgentToken(value, effectiveUserAgent)
96
- ];
97
- } else {
98
- result.push([USER_AGENT_HEADER, effectiveUserAgent]);
99
- }
99
+ function addSdkCodingAgentHeader(headers, agent = getSdkAgentInfo()) {
100
+ const result = { ...headers ?? {} };
101
+ if (agent === undefined) {
100
102
  return result;
101
103
  }
102
- return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
104
+ const headerName = getHeaderName(result, CODING_AGENT_HEADER);
105
+ result[headerName ?? CODING_AGENT_HEADER] = JSON.stringify({
106
+ [CODING_AGENT_PROPERTY]: agent
107
+ });
108
+ return result;
109
+ }
110
+ function asHeaderRecord(headers) {
111
+ return typeof headers === "object" && headers !== null ? { ...headers } : {};
103
112
  }
104
- function withUserAgentInitOverride(initOverrides, userAgent) {
113
+ function withForwardedHeadersInitOverride(initOverrides, forward) {
105
114
  return async (requestContext) => {
106
- const initWithUserAgent = {
115
+ const initWithHeaders = {
107
116
  ...requestContext.init,
108
- headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
117
+ headers: forward(asHeaderRecord(requestContext.init.headers))
109
118
  };
110
119
  const override = typeof initOverrides === "function" ? await initOverrides({
111
120
  ...requestContext,
112
- init: initWithUserAgent
121
+ init: initWithHeaders
113
122
  }) : initOverrides;
114
123
  return {
115
124
  ...override ?? {},
116
- headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
125
+ headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
117
126
  };
118
127
  };
119
128
  }
120
- function installSdkUserAgentHeader(BaseApiClass, userAgent) {
129
+ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
121
130
  const prototype = BaseApiClass.prototype;
122
- const patchKey = userAgentPatchKey(userAgent);
123
131
  if (prototype[patchKey]) {
124
132
  return;
125
133
  }
@@ -127,17 +135,26 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
127
135
  throw new Error("Generated BaseAPI request function not found.");
128
136
  }
129
137
  const originalRequest = prototype.request;
130
- prototype.request = function requestWithUserAgent(context, initOverrides) {
131
- return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
138
+ prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
139
+ return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
132
140
  };
133
141
  Object.defineProperty(prototype, patchKey, {
134
142
  value: true
135
143
  });
136
144
  }
145
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
146
+ installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
147
+ }
148
+ function installSdkCodingAgentHeader(BaseApiClass) {
149
+ installRequestHeaderForwarding(BaseApiClass, codingAgentPatchKey(), (headers) => addSdkCodingAgentHeader(headers));
150
+ }
137
151
  export {
138
- withSdkUserAgentHeader,
139
152
  setSdkUserAgentHostToken,
140
153
  installSdkUserAgentHeader,
154
+ installSdkCodingAgentHeader,
141
155
  getSdkUserAgentToken,
142
- addSdkUserAgentHeader
156
+ addSdkUserAgentHeader,
157
+ addSdkCodingAgentHeader
143
158
  };
159
+
160
+ //# debugId=9DC7523199926B8364756E2164756E21
@@ -291,3 +291,5 @@ export {
291
291
  ConsoleTelemetryProvider,
292
292
  BrowserContextStorage
293
293
  };
294
+
295
+ //# debugId=71EE5BABB86B607F64756E2164756E21
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Check whether telemetry is disabled via environment variable.
3
+ * Set UIPATH_TELEMETRY_DISABLED=1 or UIPATH_TELEMETRY_DISABLED=true to opt out.
4
+ */
5
+ export declare function isTelemetryDisabled(): boolean;
@@ -6,11 +6,7 @@ import { type NodeAppInsightsTelemetryProvider } from "./node-appinsights-teleme
6
6
  * Returns undefined if the applicationinsights package is not installed.
7
7
  */
8
8
  export declare function createAppInsightsProvider(): Promise<NodeAppInsightsTelemetryProvider | undefined>;
9
- /**
10
- * Check whether telemetry is disabled via environment variable.
11
- * Set UIPATH_TELEMETRY_DISABLED=1 or UIPATH_TELEMETRY_DISABLED=true to opt out.
12
- */
13
- export declare function isTelemetryDisabled(): boolean;
9
+ export { isTelemetryDisabled } from "./telemetry-config.js";
14
10
  interface TelemetryProviderResult {
15
11
  provider: ITelemetryProvider;
16
12
  name: string;
@@ -50,4 +46,3 @@ export declare function telemetryInit(options?: TelemetryInitOptions): Promise<v
50
46
  * Capped at FLUSH_SHUTDOWN_TIMEOUT_MS to avoid hanging on slow/unreachable endpoints.
51
47
  */
52
48
  export declare function telemetryFlushAndShutdown(): Promise<void>;
53
- export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/common",
3
3
  "license": "MIT",
4
- "version": "1.196.0",
4
+ "version": "1.197.0-preview.59",
5
5
  "description": "Common infrastructure needed by uip tools.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,17 +24,39 @@
24
24
  "default": "./dist/index.js"
25
25
  }
26
26
  },
27
+ "./catch-error": {
28
+ "types": "./dist/catch-error.d.ts",
29
+ "default": "./dist/catch-error.js"
30
+ },
27
31
  "./sdk-user-agent": {
28
- "types": "./dist/sdk-user-agent.d.ts",
29
- "default": "./dist/sdk-user-agent.js"
32
+ "browser": {
33
+ "types": "./dist/sdk-user-agent.d.ts",
34
+ "default": "./dist/sdk-user-agent.js"
35
+ },
36
+ "default": {
37
+ "types": "./dist/sdk-user-agent.d.ts",
38
+ "default": "./dist/sdk-user-agent.js"
39
+ }
30
40
  },
31
41
  "./package-metadata-options": {
32
- "types": "./dist/package-metadata-options.d.ts",
33
- "default": "./dist/package-metadata-options.js"
42
+ "browser": {
43
+ "types": "./dist/package-metadata-options.d.ts",
44
+ "default": "./dist/package-metadata-options.js"
45
+ },
46
+ "default": {
47
+ "types": "./dist/package-metadata-options.d.ts",
48
+ "default": "./dist/package-metadata-options.js"
49
+ }
34
50
  },
35
51
  "./telemetry": {
36
- "types": "./dist/telemetry/index.d.ts",
37
- "default": "./dist/telemetry/index.js"
52
+ "browser": {
53
+ "types": "./dist/telemetry/index.d.ts",
54
+ "default": "./dist/telemetry/index.js"
55
+ },
56
+ "default": {
57
+ "types": "./dist/telemetry/index.d.ts",
58
+ "default": "./dist/telemetry/index.js"
59
+ }
38
60
  }
39
61
  },
40
62
  "files": [
@@ -45,5 +67,5 @@
45
67
  "mihaigirleanu",
46
68
  "vlad-uipath"
47
69
  ],
48
- "gitHead": "94d71f9c52214980a1f0ae62b3f5372095788553"
70
+ "gitHead": "df0e2b8140cced13f463b487214927c82bc0f85b"
49
71
  }
@@ -1,11 +0,0 @@
1
- /**
2
- * Evaluate a JSONPath expression against arbitrary data.
3
- *
4
- * Returns a newline-separated string of matched values.
5
- * Objects/arrays are serialized to compact JSON.
6
- * Returns an empty string when nothing matches or the expression is unrecognised.
7
- */
8
- export declare function evaluateJsonPath(data: unknown, expression: string): string;
9
- export declare class JsonPathError extends Error {
10
- constructor(message: string);
11
- }