@uipath/common 1.199.0-preview.99 → 1.200.0-preview.109

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.
@@ -164,6 +164,25 @@ export declare class FilterEvaluationError extends Error {
164
164
  readonly result: FailureResultType;
165
165
  constructor(filter: string, cause: unknown);
166
166
  }
167
+ /**
168
+ * Thrown by `trackedAction` when `--output-filter` is combined with a command
169
+ * whose `--limit` resolved from its declared default instead of the command
170
+ * line. The filter runs client-side over only the records the command fetched,
171
+ * so an implicit limit would silently cap the data being filtered — the caller
172
+ * must state how much data the filter applies to.
173
+ *
174
+ * Uses a duck-type `__brand` rather than relying on `instanceof`, because each
175
+ * tool bundles its own copy of `@uipath/common` and class identity differs
176
+ * across bundle boundaries.
177
+ */
178
+ export declare class FilterImplicitLimitError extends Error {
179
+ readonly __brand: "FilterImplicitLimitError";
180
+ readonly errorCode: CliErrorCode;
181
+ readonly instructions: string;
182
+ readonly retry: RetryHint;
183
+ readonly result: FailureResultType;
184
+ constructor(defaultLimit: string);
185
+ }
167
186
  /**
168
187
  * OutputFormatter namespace for formatting and displaying output.
169
188
  */
package/dist/guid.js ADDED
@@ -0,0 +1,10 @@
1
+ // src/guid.ts
2
+ var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3
+ function isGuid(value) {
4
+ return GUID_REGEX.test(value);
5
+ }
6
+ export {
7
+ isGuid
8
+ };
9
+
10
+ //# debugId=F25023E1915C1B3664756E2164756E21
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Global options the CLI host owns. It parses them out of argv before
3
+ * Commander runs (`stripGlobalOptions` in `packages/cli/src/utils/globalOptions.ts`)
4
+ * so tools never have to define them.
5
+ *
6
+ * The host cleans `context.args` only — `process.argv` keeps the raw tokens. A
7
+ * tool that re-reads `process.argv` therefore still sees these, and must strip
8
+ * them itself before forwarding. `function-tool`'s passthrough does exactly
9
+ * that: it reads raw argv on purpose, so unknown flags reach the downstream
10
+ * CLI verbatim, which means the host's own options would reach it too and be
11
+ * rejected as unknown options.
12
+ *
13
+ * Adding a global option to the host means adding it here as well;
14
+ * `globalOptions.spec.ts` fails if the two drift apart.
15
+ */
16
+ /** Host options that consume a following value (`--flag v` / `--flag=v`). */
17
+ export declare const HOST_GLOBAL_OPTIONS_WITH_VALUE: readonly ["--output", "--output-filter", "--log-level", "--log-file", "--profile"];
18
+ /** Host options that take no value. */
19
+ export declare const HOST_GLOBAL_FLAGS: readonly ["--json", "--interactive", "--no-interactive"];
20
+ /**
21
+ * Drop every host-owned global option from `args`, returning the rest
22
+ * untouched. Handles both `--flag value` and `--flag=value`; unrelated flags
23
+ * are always preserved, since a passthrough tool must forward what it does not
24
+ * own.
25
+ */
26
+ export declare function stripHostGlobalOptions(args: string[]): string[];
@@ -26,7 +26,7 @@ export * from "./telemetry/command-attribution.js";
26
26
  export * from "./telemetry/command-terminal.js";
27
27
  export { ConsoleTelemetryProvider } from "./telemetry/console-telemetry-provider.js";
28
28
  export type { IContextStorage } from "./telemetry/context-storage.js";
29
- export { getConfiguredTelemetrySessionId, getTelemetrySessionId, resolveTelemetrySessionId, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_ID_PROPERTY, } from "./telemetry/session-id.js";
29
+ export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./telemetry/session-id.js";
30
30
  export * from "./telemetry/telemetry-events.js";
31
31
  export type { ITelemetryProvider } from "./telemetry/telemetry-provider.js";
32
32
  export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry/telemetry-service.js";
@@ -21223,6 +21223,9 @@ async function extractErrorDetails(error, options) {
21223
21223
  if (!extractedMessage) {
21224
21224
  extractedMessage = body;
21225
21225
  }
21226
+ if (extractedMessage && typeof parsedBody.detail === "string" && parsedBody.detail.length > 0 && !extractedMessage.includes(parsedBody.detail)) {
21227
+ extractedMessage = `${extractedMessage}: ${parsedBody.detail}`;
21228
+ }
21226
21229
  } else {
21227
21230
  extractedMessage = isHtmlDocument(body) ? HTML_RESPONSE_MESSAGE : body;
21228
21231
  }
@@ -21277,6 +21280,8 @@ async function extractErrorDetails(error, options) {
21277
21280
  const extra = {};
21278
21281
  if (parsedBody.errorCode)
21279
21282
  extra.errorCode = parsedBody.errorCode;
21283
+ if (parsedBody.detail)
21284
+ extra.detail = parsedBody.detail;
21280
21285
  if (parsedBody.details)
21281
21286
  extra.details = parsedBody.details;
21282
21287
  if (parsedBody.errors != null)
@@ -22254,9 +22259,15 @@ var FAILURE_STATUSES = new Set([
22254
22259
  "stopped"
22255
22260
  ]);
22256
22261
  function isTerminalStatus(status) {
22262
+ if (typeof status !== "string") {
22263
+ return false;
22264
+ }
22257
22265
  return TERMINAL_STATUSES.has(status.toLowerCase());
22258
22266
  }
22259
22267
  function isFailureStatus(status) {
22268
+ if (typeof status !== "string") {
22269
+ return false;
22270
+ }
22260
22271
  return FAILURE_STATUSES.has(status.toLowerCase());
22261
22272
  }
22262
22273
  function isSuccessStatus(status) {
@@ -22479,7 +22490,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
22479
22490
  ["agents", "build", ["uip.codedagent", "uip.agent"]],
22480
22491
  ["agenthub", "build", ["uip.agenthub"]],
22481
22492
  ["coded-apps", "build", ["uip.codedapp"]],
22482
- ["functions", "build", ["uip.functions"]],
22493
+ ["functions", "build", ["uip.function", "uip.functions"]],
22483
22494
  ["solution", "build", ["uip.solution"]],
22484
22495
  ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
22485
22496
  ["llm-observability", "troubleshoot", ["uip.traces"]],
@@ -22842,8 +22853,18 @@ function getInboundTraceContext() {
22842
22853
 
22843
22854
  // src/telemetry/session-id.ts
22844
22855
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
22845
- var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
22846
- var telemetrySessionIdSlot = singleton("TelemetrySessionId");
22856
+ var SESSION_ID_MAX_LENGTH = 64;
22857
+ var RANDOM_SESSION_ID_LENGTH = 32;
22858
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
22859
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
22860
+ var INHERITED_SESSION_SOURCES = [
22861
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
22862
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
22863
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
22864
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
22865
+ { envVar: "WT_SESSION", source: "terminal" }
22866
+ ];
22867
+ var telemetrySessionSlot = singleton("TelemetrySession");
22847
22868
  var telemetryOperationIdSlot = singleton("TelemetryOperationId");
22848
22869
  function getProcessEnv2() {
22849
22870
  return globalThis.process?.env;
@@ -22852,27 +22873,45 @@ function normalizeSessionId(value) {
22852
22873
  if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
22853
22874
  return;
22854
22875
  }
22855
- const trimmed = String(value).trim();
22856
- return trimmed || undefined;
22876
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
22877
+ return cleaned || undefined;
22857
22878
  }
22858
22879
  function getConfiguredTelemetrySessionId() {
22859
22880
  return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
22860
22881
  }
22861
- function getTelemetrySessionId() {
22862
- const envSessionId = getConfiguredTelemetrySessionId();
22863
- if (envSessionId) {
22864
- return envSessionId;
22882
+ function getInheritedSession(env2) {
22883
+ for (const candidate of INHERITED_SESSION_SOURCES) {
22884
+ const handle = normalizeSessionId(env2[candidate.envVar]);
22885
+ if (handle) {
22886
+ return { id: handle, source: candidate.source };
22887
+ }
22888
+ }
22889
+ return;
22890
+ }
22891
+ function generateRandomSession() {
22892
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
22893
+ crypto.getRandomValues(bytes);
22894
+ let hex = "";
22895
+ for (const byte of bytes) {
22896
+ hex += byte.toString(16).padStart(2, "0");
22865
22897
  }
22866
- const existing = telemetrySessionIdSlot.get();
22898
+ return { id: hex, source: "random" };
22899
+ }
22900
+ function resolveTelemetrySession() {
22901
+ const existing = telemetrySessionSlot.get();
22867
22902
  if (existing) {
22868
22903
  return existing;
22869
22904
  }
22870
- const generated = crypto.randomUUID();
22871
- telemetrySessionIdSlot.set(generated);
22872
- return generated;
22905
+ const declaredHandle = getConfiguredTelemetrySessionId();
22906
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
22907
+ telemetrySessionSlot.set(resolved);
22908
+ return resolved;
22909
+ }
22910
+ function getTelemetrySessionId() {
22911
+ return resolveTelemetrySession().id;
22873
22912
  }
22874
- function resolveTelemetrySessionId(existingSessionId) {
22875
- return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
22913
+ function getTelemetrySessionSource() {
22914
+ return resolveTelemetrySession().source;
22876
22915
  }
22877
22916
  function getTelemetryOperationId() {
22878
22917
  const existing = telemetryOperationIdSlot.get();
@@ -22887,7 +22926,7 @@ function getTelemetryOperationId() {
22887
22926
  // src/telemetry/telemetry-events.ts
22888
22927
  var CommonTelemetryEvents = {
22889
22928
  Error: "uip.error",
22890
- ShipSucceeded: "ship_succeeded"
22929
+ ShipSucceeded: "uip.ship.succeeded"
22891
22930
  };
22892
22931
  // src/telemetry/detect-agent.ts
22893
22932
  var KNOWN_AGENTS = [
@@ -23250,14 +23289,11 @@ class TelemetryService {
23250
23289
  }
23251
23290
  async trackDependencyOperation(name, type, fn, properties) {
23252
23291
  const parentContext = this.getCurrentContext();
23253
- if (!parentContext) {
23254
- throw new Error("trackDependencyOperation must be called within a trackRequest block.");
23255
- }
23256
- const childContext = {
23292
+ const childContext = parentContext !== undefined ? {
23257
23293
  operationId: parentContext.operationId,
23258
23294
  parentId: parentContext.id,
23259
23295
  id: this.generateId()
23260
- };
23296
+ } : this.createRequestContext();
23261
23297
  const startTime = performance.now();
23262
23298
  try {
23263
23299
  const result = await this.contextStorage.run(childContext, fn);
@@ -23278,24 +23314,18 @@ class TelemetryService {
23278
23314
  }
23279
23315
  enrichPropertiesWithContext(properties, context) {
23280
23316
  const globalProperties = getGlobalTelemetryProperties();
23281
- const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
23282
- const sessionId = resolveTelemetrySessionId(existingSessionId);
23283
23317
  const enriched = {
23284
23318
  ...getExecutionContextTelemetryProperties(),
23285
23319
  ...globalProperties,
23286
23320
  ...this.defaultProperties,
23287
23321
  ...redactProperties(properties ?? {}),
23322
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
23288
23323
  ...context ? {
23289
23324
  [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
23290
23325
  ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
23291
23326
  [TELEMETRY_SPAN_ID_PROPERTY]: context.id
23292
23327
  } : {}
23293
23328
  };
23294
- if (sessionId === undefined) {
23295
- delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
23296
- } else {
23297
- enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
23298
- }
23299
23329
  return enriched;
23300
23330
  }
23301
23331
  generateId() {
@@ -23311,22 +23341,80 @@ class TelemetryService {
23311
23341
  return hex;
23312
23342
  }
23313
23343
  }
23344
+ // src/packager-tool-import.ts
23345
+ var REGISTER_EXPORT = "registerPackagerFactories";
23346
+ async function importPackagerTool(specifier) {
23347
+ const [importError, mod] = await catchError(import(specifier));
23348
+ if (importError)
23349
+ return importError;
23350
+ const register = mod?.[REGISTER_EXPORT];
23351
+ if (typeof register !== "function") {
23352
+ logger.debug(`'${specifier}' has no '${REGISTER_EXPORT}' export — treating it as a ` + "legacy entry point that registered its factories at import.");
23353
+ return;
23354
+ }
23355
+ const [registerError] = catchError(() => {
23356
+ register();
23357
+ });
23358
+ return registerError;
23359
+ }
23360
+
23361
+ // src/tool-module-import.ts
23362
+ async function importToolModule(specifier) {
23363
+ return await import(specifier);
23364
+ }
23365
+
23314
23366
  // src/tool-provider.ts
23315
23367
  var factorySlot = singleton("PackagerFactoryProvider");
23316
23368
  function setPackagerFactoryProvider(provider) {
23317
23369
  factorySlot.set(provider);
23318
23370
  }
23319
- async function ensurePackagerFactory(verb) {
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
+ async function ensurePackagerFactory(verb, packageName) {
23320
23394
  const provider = factorySlot.get();
23321
- if (!provider) {
23322
- throw new Error(`Packager factory for '${verb}' is required but no factory provider is registered. ` + `Run 'uip tools install ${verb}' manually.`);
23395
+ if (provider) {
23396
+ await provider(verb);
23397
+ return;
23323
23398
  }
23324
- await provider(verb);
23399
+ const importError = packageName ? await loadPackagerTool(`${packageName}/packager-tool`) : undefined;
23400
+ if (packageName && !importError)
23401
+ return;
23402
+ 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 });
23403
+ }
23404
+ async function loadPackagerTool(specifier) {
23405
+ const error = await importPackagerTool(specifier);
23406
+ if (error) {
23407
+ logger.debug(`No packager factory provider registered; import of '${specifier}' failed: ${error.message}`);
23408
+ return error;
23409
+ }
23410
+ logger.debug(`No packager factory provider registered; loaded '${specifier}' directly.`);
23411
+ return;
23325
23412
  }
23326
23413
  export {
23327
23414
  withCompleter,
23328
23415
  takeRecordedCommandFailureTelemetry,
23329
23416
  singleton,
23417
+ setToolModuleProvider,
23330
23418
  setSdkUserAgentHostToken,
23331
23419
  setPackagerFactoryProvider,
23332
23420
  setOutputFormatExplicit,
@@ -23337,7 +23425,6 @@ export {
23337
23425
  setGlobalLogFilePath,
23338
23426
  runWithSink,
23339
23427
  restoreConsole,
23340
- resolveTelemetrySessionId,
23341
23428
  resolveEnvReference,
23342
23429
  resetLoggerInstance,
23343
23430
  registerPackageMetadataOptions,
@@ -23363,6 +23450,7 @@ export {
23363
23450
  installSdkCodingAgentHeader,
23364
23451
  installConsoleGuard,
23365
23452
  hashContent,
23453
+ getTelemetrySessionSource,
23366
23454
  getTelemetrySessionId,
23367
23455
  getSdkUserAgentToken,
23368
23456
  getRecordedCommandFailureTelemetry,
@@ -23382,6 +23470,7 @@ export {
23382
23470
  extractErrorMessage,
23383
23471
  extractErrorDetails,
23384
23472
  extractCommandHelp,
23473
+ ensureToolModule,
23385
23474
  ensurePackagerFactory,
23386
23475
  describeConnectivityError,
23387
23476
  createPollAbortController,
@@ -23399,7 +23488,7 @@ export {
23399
23488
  addSdkCodingAgentHeader,
23400
23489
  UIPATH_HOME_DIR,
23401
23490
  TelemetryService,
23402
- TELEMETRY_SESSION_ID_PROPERTY,
23491
+ TELEMETRY_SESSION_SOURCE_PROPERTY,
23403
23492
  TELEMETRY_SESSION_ID_ENV,
23404
23493
  ScreenLogger,
23405
23494
  PollOutcome,
@@ -23421,4 +23510,4 @@ export {
23421
23510
  AUTH_FILENAME
23422
23511
  };
23423
23512
 
23424
- //# debugId=5714488353CEE82464756E2164756E21
23513
+ //# debugId=C2BB3B73AD55AF7D64756E2164756E21
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from "./error-handler";
14
14
  export * from "./error-instructions";
15
15
  export * from "./formatter";
16
16
  export * from "./guid";
17
+ export * from "./host-global-options";
17
18
  export * from "./interactivity-context";
18
19
  export * from "./logger";
19
20
  export * from "./option-aliases";
@@ -23,12 +24,14 @@ export * from "./output-context";
23
24
  export * from "./output-format-context";
24
25
  export * from "./output-sink";
25
26
  export * from "./package-metadata-options";
27
+ export { type PackagerToolModule, REGISTER_EXPORT, } from "./packager-tool-import";
26
28
  export * from "./polling";
27
29
  export * from "./preview";
28
30
  export * from "./registry";
29
31
  export * from "./screen-logger";
30
32
  export * from "./sdk-user-agent";
31
33
  export * from "./singleton";
34
+ export * from "./solution-project-artifacts";
32
35
  export * from "./stdin";
33
36
  export { BrowserContextStorage } from "./telemetry/browser-context-storage.js";
34
37
  export * from "./telemetry/command-attribution.js";
@@ -40,5 +43,6 @@ export { redactError, redactProperties, redactProperty, redactValue, } from "./t
40
43
  export { type ShipSucceededTelemetryPayload, trackShipSucceeded, } from "./telemetry/ship-succeeded.js";
41
44
  export * from "./telemetry/telemetry-events.js";
42
45
  export * from "./telemetry/telemetry-init.js";
46
+ export * from "./telemetry/telemetry-spool.js";
43
47
  export * from "./tool-provider";
44
48
  export * from "./trackedAction.js";