@uipath/common 1.206.0-preview.303 → 1.207.0-preview.305

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.
@@ -33,6 +33,15 @@ export declare function getProjectTelemetryResolver(command: Command): ProjectTe
33
33
  export declare function getProjectTelemetryCapture(command: Command | undefined): ProjectTelemetryCapture | undefined;
34
34
  /** Host only: expose a session to its handler for the duration of the action. */
35
35
  export declare function attachProjectTelemetryCapture(command: Command, capture: ProjectTelemetryCapture | undefined): void;
36
+ /**
37
+ * Name the folder a handler created or resolved, so the request row carries
38
+ * the identity of what the command actually used: the capture the host
39
+ * attached to `command` reads its target again. No capture (project telemetry
40
+ * off, no resolver on the tree, an older host) is a no-op. Fail-soft like the
41
+ * resolver: the capture may come from another copy of common on an older
42
+ * host, and telemetry must never fail a command that succeeded.
43
+ */
44
+ export declare function setProjectTelemetryTarget(command: Command | undefined, target: string): Promise<void>;
36
45
  export interface ProjectTargetRule {
37
46
  arguments?: readonly string[];
38
47
  options?: readonly string[];
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Marks a command whose output the CLI host does not shape.
3
+ *
4
+ * Some tool commands relay another program's stdout unchanged — rpa-tool's
5
+ * pass-through to an external CLI such as UI Automation is the case in point.
6
+ * The host's `--output` and `--output-filter` act on the response envelope, and
7
+ * such a command never builds one, so offering them in its help advertises
8
+ * options it cannot honour. The help formatter reads this marker to leave them
9
+ * out. The tool stays responsible for refusing them if they are passed anyway.
10
+ *
11
+ * Cross-bundle detail: each tool bundles its own copy of commander and of
12
+ * `@uipath/common`, so the tool that marks a command and the host that renders
13
+ * its help are different module instances. The marker is stored on the command
14
+ * under a `Symbol.for()` key, which is shared process-wide.
15
+ */
16
+ /** Mark `cmd` as relaying its output unchanged, and return it. */
17
+ export declare function markOutputRelayed<T extends object>(cmd: T): T;
18
+ /** Whether `cmd` was marked with {@link markOutputRelayed}. */
19
+ export declare function isOutputRelayed(cmd: object): boolean;
@@ -82,13 +82,15 @@ var ProjectDimensions = {
82
82
  SolutionKey: "SolutionKey",
83
83
  SolutionProjectKey: "SolutionProjectKey",
84
84
  SolutionIdentityStatus: "SolutionIdentityStatus",
85
- PreviousSolutionKey: "PreviousSolutionKey"
85
+ PreviousSolutionKey: "PreviousSolutionKey",
86
+ PreviousProjectKey: "PreviousProjectKey"
86
87
  };
87
88
  var GUID_KEY_DIMENSIONS = new Set([
88
89
  ProjectDimensions.ProjectKey,
89
90
  ProjectDimensions.SolutionKey,
90
91
  ProjectDimensions.SolutionProjectKey,
91
- ProjectDimensions.PreviousSolutionKey
92
+ ProjectDimensions.PreviousSolutionKey,
93
+ ProjectDimensions.PreviousProjectKey
92
94
  ]);
93
95
  var ShipDimensions = {
94
96
  ShipKind: "ShipKind",
@@ -304,4 +306,4 @@ export {
304
306
  setSdkUserAgentHostToken
305
307
  };
306
308
 
307
- //# debugId=E1368F19FF99619464756E2164756E21
309
+ //# debugId=62411CD7B5C4810464756E2164756E21
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A synchronous SHA-256 that runs in Node and in the browser bundle, where
3
+ * `node:crypto`'s `createHash` throws and `crypto.subtle.digest` is async.
4
+ *
5
+ * Callers persist what it returns: telemetry pseudonyms (`telemetry/pseudonymize.ts`)
6
+ * and the V2 BPMN connector binding ids written into `.bpmn` files
7
+ * (`@uipath/maestro-sdk`'s `connector-spec/bpmn-element.ts`). Its output must
8
+ * stay a plain SHA-256, byte for byte, or both stop matching what they wrote
9
+ * before.
10
+ */
11
+ /**
12
+ * SHA-256 of the UTF-8 bytes of `input`, as 64 lowercase hex: what
13
+ * `createHash("sha256").update(input).digest("hex")` gives.
14
+ *
15
+ * The portable reference implementation: telemetry's browser fallback, and the
16
+ * value `resolveSha256Hex` in `telemetry/pseudonymize.ts` checks `node:crypto`
17
+ * against before adopting it.
18
+ */
19
+ export declare function sha256Hex(input: string): string;
20
+ /**
21
+ * SHA-256 of the UTF-8 bytes of `input`, as unpadded base64url: what
22
+ * `createHash("sha256").update(input).digest("base64url")` gives.
23
+ */
24
+ export declare function sha256Base64Url(input: string): string;
package/dist/stdin.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  export declare function readStdin(): Promise<string | null>;
2
2
  /**
3
- * `readStdin()` with a deadline. A non-TTY pipe that stays open but never sends
4
- * data (or EOF) would otherwise block forever; on expiry this unrefs stdin so
5
- * it can't keep the process alive and resolves `null`. Returns `null` on
6
- * timeout, TTY, or empty input.
3
+ * `readStdin()` with an idle deadline. A non-TTY pipe that stays open but never
4
+ * sends a byte would otherwise block forever; on expiry this resolves `null`.
5
+ * The deadline resets on every chunk, so a slow but steady producer is never cut
6
+ * off. A pipe that goes idle after sending some data rejects with a timeout
7
+ * error rather than returning a truncated body. Once the deadline fires, every
8
+ * listener is detached and stdin is paused and unref'd, so late input can't
9
+ * re-arm it or keep the process alive. Returns `null` on silence, TTY, or empty
10
+ * input.
7
11
  */
8
12
  export declare function readStdinWithTimeout(timeoutMs: number): Promise<string | null>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Span fields both App Insights providers (Node SDK and browser) fill the
3
+ * same way. Browser-safe: no Node-only imports.
4
+ */
5
+ /**
6
+ * AppInsights' trackRequest validates `url` as an absolute URL. The CLI passes
7
+ * operation identifiers like 'ProjectPackager.Tool.Pack' (not http URLs) which
8
+ * causes a TypeError to be thrown to stderr. Wrap in a `urn:` scheme so URL
9
+ * parsing succeeds without changing the displayed name.
10
+ */
11
+ export declare function toOperationUrn(name: string): string;
12
+ /**
13
+ * Fallback span start, for a caller that recorded no real one.
14
+ *
15
+ * App Insights treats a request's/dependency's timestamp as the span START and
16
+ * draws the bar forward by `duration`, but `track()` stamps the envelope at the
17
+ * moment it is called — and a span is only ever tracked once its work has
18
+ * finished. Left alone, every bar lands one whole duration late: a 3.8s command
19
+ * renders entirely *after* the HTTP calls nested inside it.
20
+ *
21
+ * The SDK's own instrumentation stamps the start it captured
22
+ * (`AutoCollection/HttpRequestParser`: `telemetry.time = new Date(startTime)`);
23
+ * the manual `trackRequest`/`trackDependency` API has no start to work from, so
24
+ * it defaults to now.
25
+ *
26
+ * Deriving `now - duration` is only right when the emit lands on the instant
27
+ * the clock stopped. It never quite does, and the error is charged to the front
28
+ * of the bar: `trackedAction` stops its timer, then extracts command params and
29
+ * runs the redaction detectors over every one of them before it emits, so the
30
+ * command's bar started after any dependency that ran early in the command —
31
+ * the auth token call, every time. Callers therefore record their real start on
32
+ * the span context (`TelemetryContext.startedAt`) and it arrives here as
33
+ * `startTime`. This remains for contexts assembled by hand, where a derived
34
+ * start still beats the emit time.
35
+ */
36
+ export declare function spanStart(duration: number): Date;
@@ -0,0 +1,37 @@
1
+ import type { ITelemetryProvider, TrackedDependencySpan, TrackedEvent, TrackedException, TrackedSpan } from "./telemetry-provider.js";
2
+ /** Where a {@link BrowserAppInsightsTelemetryProvider} sends. */
3
+ export interface BrowserAppInsightsTarget {
4
+ instrumentationKey: string;
5
+ /** e.g. `https://westeurope-5.in.applicationinsights.azure.com`. */
6
+ ingestionOrigin: string;
7
+ }
8
+ /**
9
+ * Sends telemetry to Application Insights from a browser, over plain `fetch`.
10
+ *
11
+ * The Node SDK cannot load in a browser. The web SDK can, but it files
12
+ * requests as page views and sets `ai_user`/`ai_session` cookies on the page
13
+ * that hosts the bundle. This writes the same envelopes the Node provider
14
+ * sends, so a browser command lands in `requests` next to the Node ones.
15
+ *
16
+ * Items are buffered and sent on {@link flush}, which the CLI calls at the end
17
+ * of each run. {@link shutdown} only flushes: one page runs many commands, and
18
+ * the provider has to keep working for the next one.
19
+ */
20
+ export declare class BrowserAppInsightsTelemetryProvider implements ITelemetryProvider {
21
+ private readonly target;
22
+ private pending;
23
+ private applicationVersion;
24
+ constructor(target: BrowserAppInsightsTarget);
25
+ /** Sets the `ai.application.ver` tag on every later item. */
26
+ setApplicationVersion(version: string): void;
27
+ getSessionId(): string;
28
+ trackEvent(event: TrackedEvent): Promise<void>;
29
+ trackException(exception: TrackedException): Promise<void>;
30
+ trackRequest(span: TrackedSpan): Promise<void>;
31
+ trackDependency(span: TrackedDependencySpan): Promise<void>;
32
+ /** Send everything buffered. A failed send is dropped, never thrown. */
33
+ flush(): Promise<void>;
34
+ shutdown(): Promise<void>;
35
+ private enqueue;
36
+ private tags;
37
+ }
@@ -63,7 +63,7 @@ __export(exports_buffer, {
63
63
  File: () => File,
64
64
  INSPECT_MAX_BYTES: () => INSPECT_MAX_BYTES,
65
65
  atob: () => atob,
66
- btoa: () => btoa,
66
+ btoa: () => btoa2,
67
67
  constants: () => constants,
68
68
  default: () => buffer_default,
69
69
  isAscii: () => isAscii,
@@ -740,7 +740,7 @@ function notimpl(name) {
740
740
  throw Error(name + " is not implemented for node:buffer browser polyfill");
741
741
  };
742
742
  }
743
- var lookup, revLookup, code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i, len, customInspectSymbol, INSPECT_MAX_BYTES = 50, kMaxLength = 2147483647, kStringMaxLength = 536870888, btoa, atob, File, Blob, constants, ERR_BUFFER_OUT_OF_BOUNDS, ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE, MAX_ARGUMENTS_LENGTH = 4096, INVALID_BASE64_RE, hexSliceLookupTable, resolveObjectURL, isUtf8, isAscii = (str) => {
743
+ var lookup, revLookup, code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i, len, customInspectSymbol, INSPECT_MAX_BYTES = 50, kMaxLength = 2147483647, kStringMaxLength = 536870888, btoa2, atob, File, Blob, constants, ERR_BUFFER_OUT_OF_BOUNDS, ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE, MAX_ARGUMENTS_LENGTH = 4096, INVALID_BASE64_RE, hexSliceLookupTable, resolveObjectURL, isUtf8, isAscii = (str) => {
744
744
  for (let char of str)
745
745
  if (char.charCodeAt(0) > 127)
746
746
  return false;
@@ -754,7 +754,7 @@ var init_buffer = __esm(() => {
754
754
  revLookup[45] = 62;
755
755
  revLookup[95] = 63;
756
756
  customInspectSymbol = typeof Symbol === "function" && typeof Symbol.for === "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
757
- btoa = globalThis.btoa;
757
+ btoa2 = globalThis.btoa;
758
758
  atob = globalThis.atob;
759
759
  File = globalThis.File;
760
760
  Blob = globalThis.Blob;
@@ -18209,13 +18209,15 @@ var ProjectDimensions = {
18209
18209
  SolutionKey: "SolutionKey",
18210
18210
  SolutionProjectKey: "SolutionProjectKey",
18211
18211
  SolutionIdentityStatus: "SolutionIdentityStatus",
18212
- PreviousSolutionKey: "PreviousSolutionKey"
18212
+ PreviousSolutionKey: "PreviousSolutionKey",
18213
+ PreviousProjectKey: "PreviousProjectKey"
18213
18214
  };
18214
18215
  var GUID_KEY_DIMENSIONS = new Set([
18215
18216
  ProjectDimensions.ProjectKey,
18216
18217
  ProjectDimensions.SolutionKey,
18217
18218
  ProjectDimensions.SolutionProjectKey,
18218
- ProjectDimensions.PreviousSolutionKey
18219
+ ProjectDimensions.PreviousSolutionKey,
18220
+ ProjectDimensions.PreviousProjectKey
18219
18221
  ]);
18220
18222
  var ShipDimensions = {
18221
18223
  ShipKind: "ShipKind",
@@ -18836,9 +18838,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
18836
18838
  }
18837
18839
  }
18838
18840
 
18839
- // src/telemetry/pseudonymize.ts
18840
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
18841
- var PSEUDONYM_HEX_LENGTH = 32;
18841
+ // src/sha256.ts
18842
18842
  var SHA256_K = new Uint32Array([
18843
18843
  1116352408,
18844
18844
  1899447441,
@@ -18918,7 +18918,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
18918
18918
  function rotr(value, bits) {
18919
18919
  return (value >>> bits | value << 32 - bits) >>> 0;
18920
18920
  }
18921
- function sha256Hex(input) {
18921
+ function sha256Words(input) {
18922
18922
  const bytes = new TextEncoder().encode(input);
18923
18923
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
18924
18924
  const buffer = new Uint8Array(paddedLength);
@@ -18974,12 +18974,19 @@ function sha256Hex(input) {
18974
18974
  state[6] = state[6] + g >>> 0;
18975
18975
  state[7] = state[7] + h >>> 0;
18976
18976
  }
18977
+ return state;
18978
+ }
18979
+ function sha256Hex(input) {
18977
18980
  let hex = "";
18978
- for (const word of state) {
18981
+ for (const word of sha256Words(input)) {
18979
18982
  hex += word.toString(16).padStart(8, "0");
18980
18983
  }
18981
18984
  return hex;
18982
18985
  }
18986
+
18987
+ // src/telemetry/pseudonymize.ts
18988
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
18989
+ var PSEUDONYM_HEX_LENGTH = 32;
18983
18990
  function resolveSha256Hex() {
18984
18991
  try {
18985
18992
  const nodeCrypto = (init_crypto(), __toCommonJS(exports_crypto));
@@ -19620,4 +19627,4 @@ export {
19620
19627
  withinProjectIdentityBudget
19621
19628
  };
19622
19629
 
19623
- //# debugId=5D027FA9452A90EE64756E2164756E21
19630
+ //# debugId=88ABE03833098D5A64756E2164756E21
@@ -4,7 +4,7 @@ export { detectAgent, detectAgentVersion } from "./detect-agent.js";
4
4
  export { buildEnvironmentProperties, type NormalizedEnvironment, normalizeBaseUrl, normalizeEnvironment, } from "./environment-info.js";
5
5
  export { type CiProvider, detectExecutionContext, EXECUTION_CONTEXT_VALUES, type ExecutionContext, type ExecutionContextDetection, type ExecutionContextDetectionOptions, getExecutionContextTelemetryProperties, setExecutionContextAuthSignal, } from "./execution-context.js";
6
6
  export { NodeContextStorage } from "./node-context-storage.js";
7
- export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./session-id.js";
7
+ export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, resetTelemetryInvocationIds, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./session-id.js";
8
8
  export type { ITelemetryProvider, TelemetryCorrelation, TrackedDependencySpan, TrackedEvent, TrackedException, TrackedSpan, } from "./telemetry-provider.js";
9
9
  export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry-service.js";
10
10
  export { TelemetryService } from "./telemetry-service.js";
@@ -33,7 +33,7 @@
33
33
  * The redactor runs inside `String.prototype.replace` callbacks, so the digest
34
34
  * has to be synchronous — which rules out `crypto.subtle.digest`, the async
35
35
  * one. It does NOT rule out `node:crypto`: `createHash().digest()` is fully
36
- * synchronous, and about 36x faster than the pure implementation below (0.28us
36
+ * synchronous, and about 36x faster than the pure one in `../sha256.ts` (0.28us
37
37
  * against 10.2us on a short string). So Node takes `node:crypto` and the pure
38
38
  * version is the browser fallback, where `node:crypto` does not resolve. Both
39
39
  * produce the same bytes, so a pseudonym computed on either path joins with the
@@ -42,13 +42,6 @@
42
42
  * @see hashContent in `../content-hash.ts` for the async SHA-256 used for
43
43
  * content addressing — a different job with no sync constraint.
44
44
  */
45
- /**
46
- * FIPS 180-4 SHA-256 over the UTF-8 bytes of `input`, as 64 lowercase hex.
47
- *
48
- * The portable reference implementation: the browser fallback, and the value
49
- * `resolveSha256Hex` checks `node:crypto` against before adopting it.
50
- */
51
- export declare function sha256Hex(input: string): string;
52
45
  /**
53
46
  * The stable pseudonym for an identifying value: 32 lowercase hex characters.
54
47
  *
@@ -74,3 +74,13 @@ export declare function getTelemetrySessionSource(): TelemetrySessionSource;
74
74
  * redactor, so the emitted value matches raw on every path.
75
75
  */
76
76
  export declare function getTelemetryOperationId(): string;
77
+ /**
78
+ * Forget this process's session and operation ids, so the next item resolves
79
+ * them again from `UIPATH_SESSION_ID` / `TRACEPARENT`.
80
+ *
81
+ * For a host that runs many commands in one process — the browser bundle,
82
+ * where one page is one process. Without it, every command the page runs
83
+ * shares the first command's session and trace, and a host that sets
84
+ * `UIPATH_SESSION_ID` per command (one chat per session) cannot be honoured.
85
+ */
86
+ export declare function resetTelemetryInvocationIds(): void;
@@ -5,3 +5,8 @@
5
5
  export declare function isTelemetryDisabled(): boolean;
6
6
  /** Independent opt-out for optional project and solution identity discovery. */
7
7
  export declare function isProjectTelemetryDisabled(): boolean;
8
+ /**
9
+ * One `Key=value` part of an Application Insights connection string, matched
10
+ * case-insensitively and trimmed, or undefined when absent.
11
+ */
12
+ export declare function connectionStringValue(connectionString: string, key: string): string | undefined;
@@ -97,6 +97,12 @@ export declare const ProjectDimensions: {
97
97
  readonly SolutionProjectKey: "SolutionProjectKey";
98
98
  readonly SolutionIdentityStatus: "SolutionIdentityStatus";
99
99
  readonly PreviousSolutionKey: "PreviousSolutionKey";
100
+ /**
101
+ * The id a project had before Studio Web assigned it a new one. Set on the
102
+ * `Cli.ProjectActivity` row of `solution upload` for a member whose local
103
+ * manifest id was read, next to the assigned id under `ProjectKey`.
104
+ */
105
+ readonly PreviousProjectKey: "PreviousProjectKey";
100
106
  };
101
107
  /** Full native GUIDs, normalized to lowercase compact form before delivery. */
102
108
  export declare const GUID_KEY_DIMENSIONS: ReadonlySet<string>;
@@ -40,15 +40,16 @@ interface TelemetryProviderResult {
40
40
  }
41
41
  /**
42
42
  * Create the default telemetry provider (async).
43
- * Uses Application Insights (Node SDK) by default, falls back to
44
- * LoggerTelemetryProvider if telemetry is disabled, the host has no
45
- * Application Insights (`appInsights: false`), initialization fails, or
46
- * the applicationinsights package is not installed.
43
+ * Uses Application Insights (Node SDK) by default, or the browser sender when
44
+ * the browser bundle's host asks for it (`browserAppInsights`), and falls back
45
+ * to LoggerTelemetryProvider if telemetry is disabled, the host has no
46
+ * Application Insights (`appInsights: false`), initialization fails, or the
47
+ * applicationinsights package is not installed.
47
48
  *
48
49
  * Returns both the provider and its name so callers can log which
49
50
  * provider was selected without relying on module-level mutable state.
50
51
  */
51
- export declare function createTelemetryProvider(options?: Pick<TelemetryInitOptions, "appInsights">): Promise<TelemetryProviderResult>;
52
+ export declare function createTelemetryProvider(options?: Pick<TelemetryInitOptions, "appInsights" | "browserAppInsights">): Promise<TelemetryProviderResult>;
52
53
  export declare const telemetry: ITelemetryService;
53
54
  export interface TelemetryInitOptions {
54
55
  /** Application version — sets the standard `ai.application.ver` context tag. */
@@ -60,6 +61,11 @@ export interface TelemetryInitOptions {
60
61
  * bundle externalizes it): use the logger provider without trying it.
61
62
  */
62
63
  appInsights?: boolean;
64
+ /**
65
+ * Send to the CLI's Application Insights from a browser (the browser
66
+ * bundle, when its host turns telemetry on for the run).
67
+ */
68
+ browserAppInsights?: boolean;
63
69
  }
64
70
  /**
65
71
  * Initialize telemetry with default properties.