@uipath/coder-tool 1.206.0-preview.301 → 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.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  setPreviewBuild,
5
5
  metadata2,
6
6
  registerCommands2
7
- } from "./tool-46a2sjrp.js";
7
+ } from "./tool-n7he8rbd.js";
8
8
 
9
9
  // src/index.ts
10
10
  setPreviewBuild(true);
@@ -2127,12 +2127,26 @@ class NodeFileSystem {
2127
2127
  throw error;
2128
2128
  }
2129
2129
  }
2130
- async writeFile(filePath, data) {
2130
+ async writeFile(filePath, data, options) {
2131
2131
  const dir = path.dirname(filePath);
2132
2132
  if (dir) {
2133
2133
  await fs.mkdir(dir, { recursive: true });
2134
2134
  }
2135
- await fs.writeFile(filePath, data);
2135
+ if (options?.mode === undefined || process.platform === "win32") {
2136
+ if (options?.exclusive) {
2137
+ await fs.writeFile(filePath, data, { flag: "wx" });
2138
+ } else {
2139
+ await fs.writeFile(filePath, data);
2140
+ }
2141
+ return;
2142
+ }
2143
+ const handle = await fs.open(filePath, options.exclusive ? "wx" : "w", options.mode);
2144
+ try {
2145
+ await handle.chmod(options.mode);
2146
+ await handle.writeFile(data);
2147
+ } finally {
2148
+ await handle.close();
2149
+ }
2136
2150
  }
2137
2151
  async appendFile(filePath, data) {
2138
2152
  const dir = path.dirname(filePath);
@@ -2167,7 +2181,8 @@ class NodeFileSystem {
2167
2181
  isDirectory: () => stats.isDirectory(),
2168
2182
  size: stats.size,
2169
2183
  mtimeMs: stats.mtimeMs,
2170
- ctimeMs: stats.ctimeMs
2184
+ ctimeMs: stats.ctimeMs,
2185
+ mode: stats.mode
2171
2186
  };
2172
2187
  } catch (error) {
2173
2188
  if (this.isEnoent(error))
@@ -2178,8 +2193,13 @@ class NodeFileSystem {
2178
2193
  async exists(filePath) {
2179
2194
  return existsSync(filePath);
2180
2195
  }
2181
- async mkdir(dirPath) {
2182
- await fs.mkdir(dirPath, { recursive: true });
2196
+ async mkdir(dirPath, options) {
2197
+ await fs.mkdir(dirPath, { recursive: true, mode: options?.mode });
2198
+ }
2199
+ async chmod(targetPath, mode) {
2200
+ if (process.platform === "win32")
2201
+ return;
2202
+ await fs.chmod(targetPath, mode);
2183
2203
  }
2184
2204
  async acquireLock(lockPath) {
2185
2205
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -2329,7 +2349,7 @@ class NodeFileSystem {
2329
2349
  async getTempDir() {
2330
2350
  return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
2331
2351
  }
2332
- async copyDirectory(sourcePath, destPath) {
2352
+ async copyDirectory(sourcePath, destPath, options) {
2333
2353
  const sourceStats = await this.stat(sourcePath);
2334
2354
  if (!sourceStats) {
2335
2355
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -2346,7 +2366,9 @@ class NodeFileSystem {
2346
2366
  if (!entryStats)
2347
2367
  continue;
2348
2368
  if (entryStats.isDirectory()) {
2349
- await this.copyDirectory(srcEntry, destEntry);
2369
+ if (options?.skipDirectoryNames?.includes(entry))
2370
+ continue;
2371
+ await this.copyDirectory(srcEntry, destEntry, options);
2350
2372
  } else if (entryStats.isFile()) {
2351
2373
  const content = await this.readFile(srcEntry);
2352
2374
  if (content !== null) {
@@ -2409,13 +2431,15 @@ var ProjectDimensions = {
2409
2431
  SolutionKey: "SolutionKey",
2410
2432
  SolutionProjectKey: "SolutionProjectKey",
2411
2433
  SolutionIdentityStatus: "SolutionIdentityStatus",
2412
- PreviousSolutionKey: "PreviousSolutionKey"
2434
+ PreviousSolutionKey: "PreviousSolutionKey",
2435
+ PreviousProjectKey: "PreviousProjectKey"
2413
2436
  };
2414
2437
  var GUID_KEY_DIMENSIONS = new Set([
2415
2438
  ProjectDimensions.ProjectKey,
2416
2439
  ProjectDimensions.SolutionKey,
2417
2440
  ProjectDimensions.SolutionProjectKey,
2418
- ProjectDimensions.PreviousSolutionKey
2441
+ ProjectDimensions.PreviousSolutionKey,
2442
+ ProjectDimensions.PreviousProjectKey
2419
2443
  ]);
2420
2444
  var ShipDimensions = {
2421
2445
  ShipKind: "ShipKind",
@@ -2569,9 +2593,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
2569
2593
  }
2570
2594
  }
2571
2595
 
2572
- // ../common/src/telemetry/pseudonymize.ts
2573
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2574
- var PSEUDONYM_HEX_LENGTH = 32;
2596
+ // ../common/src/sha256.ts
2575
2597
  var SHA256_K = new Uint32Array([
2576
2598
  1116352408,
2577
2599
  1899447441,
@@ -2651,7 +2673,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
2651
2673
  function rotr(value, bits) {
2652
2674
  return (value >>> bits | value << 32 - bits) >>> 0;
2653
2675
  }
2654
- function sha256Hex(input) {
2676
+ function sha256Words(input) {
2655
2677
  const bytes = new TextEncoder().encode(input);
2656
2678
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2657
2679
  const buffer = new Uint8Array(paddedLength);
@@ -2707,12 +2729,19 @@ function sha256Hex(input) {
2707
2729
  state[6] = state[6] + g >>> 0;
2708
2730
  state[7] = state[7] + h >>> 0;
2709
2731
  }
2732
+ return state;
2733
+ }
2734
+ function sha256Hex(input) {
2710
2735
  let hex = "";
2711
- for (const word of state) {
2736
+ for (const word of sha256Words(input)) {
2712
2737
  hex += word.toString(16).padStart(8, "0");
2713
2738
  }
2714
2739
  return hex;
2715
2740
  }
2741
+
2742
+ // ../common/src/telemetry/pseudonymize.ts
2743
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2744
+ var PSEUDONYM_HEX_LENGTH = 32;
2716
2745
  function resolveSha256Hex() {
2717
2746
  try {
2718
2747
  const nodeCrypto = __require("node:crypto");
@@ -3108,13 +3137,25 @@ function settlePromiseLike(thenable) {
3108
3137
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
3109
3138
  }
3110
3139
 
3140
+ // ../common/src/result-types.ts
3141
+ var RESULTS = {
3142
+ Success: "Success",
3143
+ Failure: "Failure",
3144
+ ConfigError: "ConfigError",
3145
+ AuthenticationError: "AuthenticationError",
3146
+ ValidationError: "ValidationError",
3147
+ TimeoutError: "TimeoutError"
3148
+ };
3149
+
3111
3150
  // ../common/src/error-codes.ts
3112
3151
  var CLI_ERROR_CODES = [
3113
3152
  "invalid_argument",
3153
+ "confirmation_required",
3114
3154
  "authentication_required",
3115
3155
  "permission_denied",
3116
3156
  "local_permission_denied",
3117
3157
  "not_found",
3158
+ "not_enabled",
3118
3159
  "rate_limited",
3119
3160
  "network_error",
3120
3161
  "timeout",
@@ -3153,6 +3194,12 @@ function carriedRetry(error) {
3153
3194
  const retry = error.retry;
3154
3195
  return isRetryHint(retry) ? retry : undefined;
3155
3196
  }
3197
+ function carriedResult(error) {
3198
+ if (!error || typeof error !== "object")
3199
+ return;
3200
+ const result = error.result;
3201
+ return typeof result === "string" && result !== RESULTS.Success && Object.values(RESULTS).includes(result) ? result : undefined;
3202
+ }
3156
3203
  function defaultRetryForErrorCode(errorCode) {
3157
3204
  switch (errorCode) {
3158
3205
  case "network_error":
@@ -3542,6 +3589,8 @@ async function extractErrorDetails(error, options) {
3542
3589
  }
3543
3590
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
3544
3591
  context.errorCode = parsedBody.errorCode;
3592
+ } else if (typeof parsedBody?.errorCode === "number") {
3593
+ context.errorCode = String(parsedBody.errorCode);
3545
3594
  } else if (parsedBody?.code && typeof parsedBody.code === "string") {
3546
3595
  context.errorCode = parsedBody.code;
3547
3596
  }
@@ -3598,15 +3647,6 @@ async function extractErrorDetails(error, options) {
3598
3647
  ...parsedErrors ? { parsedErrors } : {}
3599
3648
  };
3600
3649
  }
3601
- // ../common/src/result-types.ts
3602
- var RESULTS = {
3603
- Success: "Success",
3604
- Failure: "Failure",
3605
- ConfigError: "ConfigError",
3606
- AuthenticationError: "AuthenticationError",
3607
- ValidationError: "ValidationError",
3608
- TimeoutError: "TimeoutError"
3609
- };
3610
3650
  // ../../node_modules/commander/index.js
3611
3651
  var exports_commander = {};
3612
3652
  __exportCjs(exports_commander, {
@@ -4047,7 +4087,10 @@ var AUTH_ERROR_CODES = new Set([
4047
4087
  var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
4048
4088
  "local_permission_denied"
4049
4089
  ]);
4050
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
4090
+ var VALIDATION_ERROR_CODES = new Set([
4091
+ "invalid_argument",
4092
+ "confirmation_required"
4093
+ ]);
4051
4094
  var NETWORK_HTTP_ERROR_CODES = new Set([
4052
4095
  "network_error",
4053
4096
  "rate_limited",
@@ -4273,6 +4316,109 @@ var CommonTelemetryEvents = {
4273
4316
  ShipSucceeded: "Cli.ShipSucceeded"
4274
4317
  };
4275
4318
 
4319
+ // ../common/src/telemetry/global-telemetry-properties.ts
4320
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
4321
+ function getGlobalTelemetryProperties() {
4322
+ return telemetryPropsSlot.get();
4323
+ }
4324
+
4325
+ // ../common/src/telemetry/trace-context.ts
4326
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
4327
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
4328
+ function getProcessEnv() {
4329
+ return globalThis.process?.env;
4330
+ }
4331
+ function parseInboundTraceparent(value) {
4332
+ if (!value) {
4333
+ return;
4334
+ }
4335
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
4336
+ if (!match) {
4337
+ return;
4338
+ }
4339
+ const [, traceId, parentSpanId] = match;
4340
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
4341
+ return;
4342
+ }
4343
+ return { traceId, parentSpanId };
4344
+ }
4345
+ function getInboundTraceContext() {
4346
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
4347
+ }
4348
+
4349
+ // ../common/src/telemetry/session-id.ts
4350
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
4351
+ var SESSION_ID_MAX_LENGTH = 64;
4352
+ var RANDOM_SESSION_ID_LENGTH = 32;
4353
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
4354
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
4355
+ var INHERITED_SESSION_SOURCES = [
4356
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
4357
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
4358
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
4359
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
4360
+ { envVar: "WT_SESSION", source: "terminal" }
4361
+ ];
4362
+ var telemetrySessionSlot = singleton("TelemetrySession");
4363
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
4364
+ function getProcessEnv2() {
4365
+ return globalThis.process?.env;
4366
+ }
4367
+ function normalizeSessionId(value) {
4368
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
4369
+ return;
4370
+ }
4371
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
4372
+ return cleaned || undefined;
4373
+ }
4374
+ function getConfiguredTelemetrySessionId() {
4375
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
4376
+ }
4377
+ function getInheritedSession(env) {
4378
+ for (const candidate of INHERITED_SESSION_SOURCES) {
4379
+ const handle = normalizeSessionId(env[candidate.envVar]);
4380
+ if (handle) {
4381
+ return { id: handle, source: candidate.source };
4382
+ }
4383
+ }
4384
+ return;
4385
+ }
4386
+ function generateRandomSession() {
4387
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
4388
+ crypto.getRandomValues(bytes);
4389
+ let hex = "";
4390
+ for (const byte of bytes) {
4391
+ hex += byte.toString(16).padStart(2, "0");
4392
+ }
4393
+ return { id: hex, source: "random" };
4394
+ }
4395
+ function resolveTelemetrySession() {
4396
+ const existing = telemetrySessionSlot.get();
4397
+ if (existing) {
4398
+ return existing;
4399
+ }
4400
+ const declaredHandle = getConfiguredTelemetrySessionId();
4401
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
4402
+ telemetrySessionSlot.set(resolved);
4403
+ return resolved;
4404
+ }
4405
+ function getTelemetrySessionId() {
4406
+ return resolveTelemetrySession().id;
4407
+ }
4408
+ function getTelemetrySessionSource() {
4409
+ return resolveTelemetrySession().source;
4410
+ }
4411
+ function getTelemetryOperationId() {
4412
+ const existing = telemetryOperationIdSlot.get();
4413
+ if (existing) {
4414
+ return existing;
4415
+ }
4416
+ const inboundTraceId = getInboundTraceContext()?.traceId;
4417
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
4418
+ telemetryOperationIdSlot.set(generated);
4419
+ return generated;
4420
+ }
4421
+
4276
4422
  // ../common/src/registry.ts
4277
4423
  import { execFileSync } from "node:child_process";
4278
4424
  function readRegistryValue(keyPath, valueName) {
@@ -4494,108 +4640,6 @@ class NodeContextStorage {
4494
4640
  return this.storage.getStore();
4495
4641
  }
4496
4642
  }
4497
- // ../common/src/telemetry/trace-context.ts
4498
- var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
4499
- var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
4500
- function getProcessEnv() {
4501
- return globalThis.process?.env;
4502
- }
4503
- function parseInboundTraceparent(value) {
4504
- if (!value) {
4505
- return;
4506
- }
4507
- const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
4508
- if (!match) {
4509
- return;
4510
- }
4511
- const [, traceId, parentSpanId] = match;
4512
- if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
4513
- return;
4514
- }
4515
- return { traceId, parentSpanId };
4516
- }
4517
- function getInboundTraceContext() {
4518
- return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
4519
- }
4520
-
4521
- // ../common/src/telemetry/session-id.ts
4522
- var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
4523
- var SESSION_ID_MAX_LENGTH = 64;
4524
- var RANDOM_SESSION_ID_LENGTH = 32;
4525
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
4526
- var CONTROL_CHARACTERS = /\p{Cc}/gu;
4527
- var INHERITED_SESSION_SOURCES = [
4528
- { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
4529
- { envVar: "CODEX_THREAD_ID", source: "codex" },
4530
- { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
4531
- { envVar: "TERM_SESSION_ID", source: "terminal" },
4532
- { envVar: "WT_SESSION", source: "terminal" }
4533
- ];
4534
- var telemetrySessionSlot = singleton("TelemetrySession");
4535
- var telemetryOperationIdSlot = singleton("TelemetryOperationId");
4536
- function getProcessEnv2() {
4537
- return globalThis.process?.env;
4538
- }
4539
- function normalizeSessionId(value) {
4540
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
4541
- return;
4542
- }
4543
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
4544
- return cleaned || undefined;
4545
- }
4546
- function getConfiguredTelemetrySessionId() {
4547
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
4548
- }
4549
- function getInheritedSession(env) {
4550
- for (const candidate of INHERITED_SESSION_SOURCES) {
4551
- const handle = normalizeSessionId(env[candidate.envVar]);
4552
- if (handle) {
4553
- return { id: handle, source: candidate.source };
4554
- }
4555
- }
4556
- return;
4557
- }
4558
- function generateRandomSession() {
4559
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
4560
- crypto.getRandomValues(bytes);
4561
- let hex = "";
4562
- for (const byte of bytes) {
4563
- hex += byte.toString(16).padStart(2, "0");
4564
- }
4565
- return { id: hex, source: "random" };
4566
- }
4567
- function resolveTelemetrySession() {
4568
- const existing = telemetrySessionSlot.get();
4569
- if (existing) {
4570
- return existing;
4571
- }
4572
- const declaredHandle = getConfiguredTelemetrySessionId();
4573
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
4574
- telemetrySessionSlot.set(resolved);
4575
- return resolved;
4576
- }
4577
- function getTelemetrySessionId() {
4578
- return resolveTelemetrySession().id;
4579
- }
4580
- function getTelemetrySessionSource() {
4581
- return resolveTelemetrySession().source;
4582
- }
4583
- function getTelemetryOperationId() {
4584
- const existing = telemetryOperationIdSlot.get();
4585
- if (existing) {
4586
- return existing;
4587
- }
4588
- const inboundTraceId = getInboundTraceContext()?.traceId;
4589
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
4590
- telemetryOperationIdSlot.set(generated);
4591
- return generated;
4592
- }
4593
- // ../common/src/telemetry/global-telemetry-properties.ts
4594
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
4595
- function getGlobalTelemetryProperties() {
4596
- return telemetryPropsSlot.get();
4597
- }
4598
-
4599
4643
  // ../common/src/telemetry/span-clock.ts
4600
4644
  function startSpanClock() {
4601
4645
  const started = performance.now();
@@ -4809,6 +4853,7 @@ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
4809
4853
  // ../common/src/telemetry/telemetry-init.ts
4810
4854
  var telemetryInstanceSlot = singleton("TelemetryService");
4811
4855
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
4856
+ var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
4812
4857
  function getGlobalTelemetryInstance() {
4813
4858
  const existing = telemetryInstanceSlot.get();
4814
4859
  if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
@@ -4992,7 +5037,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
4992
5037
  const pagedRows = extractPagedRows(data.Data);
4993
5038
  const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
4994
5039
  items.forEach((item) => {
4995
- const values = Object.values(item).map((v) => v ?? "").join("\t");
5040
+ const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
4996
5041
  logFn(values);
4997
5042
  });
4998
5043
  } else {
@@ -5007,7 +5052,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
5007
5052
  default: {
5008
5053
  const hasData = "Data" in data && data.Data != null;
5009
5054
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
5010
- const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
5055
+ const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
5056
+ const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
5011
5057
  if (hasData && !(rows !== null && rows.length === 0)) {
5012
5058
  const logValue = data.Log;
5013
5059
  if (rows !== null) {
@@ -5064,6 +5110,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
5064
5110
  function isPlainObjectArray(value) {
5065
5111
  return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
5066
5112
  }
5113
+ function isPrimitiveArray(value) {
5114
+ return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
5115
+ }
5067
5116
  function isNonEmptyPlainObject(value) {
5068
5117
  return isPlainRecord(value) && Object.keys(value).length > 0;
5069
5118
  }
@@ -5410,12 +5459,12 @@ class FilterEvaluationError extends Error {
5410
5459
  instructions;
5411
5460
  retry = "RetryWillNotFix";
5412
5461
  result = RESULTS.ValidationError;
5413
- constructor(filter, cause) {
5462
+ constructor(filter, cause, hint) {
5414
5463
  const underlying = cause instanceof Error ? cause.message : String(cause);
5415
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
5464
+ super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
5416
5465
  this.name = "FilterEvaluationError";
5417
5466
  this.filter = filter;
5418
- this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
5467
+ this.instructions = (hint ? `${hint.instructions} ` : "") + `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
5419
5468
  }
5420
5469
  }
5421
5470
 
@@ -5537,6 +5586,93 @@ function nameList(names, cap = 12) {
5537
5586
  const rest = names.length - shown.length;
5538
5587
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
5539
5588
  }
5589
+ function notFieldsOn(names, scope) {
5590
+ return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
5591
+ }
5592
+ function failingFieldRead(ast, isList, fn, argIndex) {
5593
+ const [left, right, condition] = ast.children ?? [];
5594
+ let scopes = [];
5595
+ if (!isList) {
5596
+ scopes = [ast];
5597
+ } else if (ast.type === "FilterProjection" && left?.type === "Identity") {
5598
+ scopes = [condition, right];
5599
+ } else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
5600
+ scopes = [right];
5601
+ }
5602
+ const reads = new Set;
5603
+ let tracked = 0;
5604
+ const visit = (node) => {
5605
+ if (!node)
5606
+ return;
5607
+ switch (node.type) {
5608
+ case "Function": {
5609
+ const arg = node.children?.[argIndex - 1];
5610
+ if (node.name === fn && arg?.type === "Field" && arg.name) {
5611
+ reads.add(arg.name);
5612
+ tracked++;
5613
+ }
5614
+ node.children?.forEach(visit);
5615
+ return;
5616
+ }
5617
+ case "AndExpression":
5618
+ case "OrExpression":
5619
+ case "NotExpression":
5620
+ case "Comparator":
5621
+ case "MultiSelectList":
5622
+ case "MultiSelectHash":
5623
+ node.children?.forEach(visit);
5624
+ return;
5625
+ case "KeyValuePair":
5626
+ visit(node.value);
5627
+ return;
5628
+ }
5629
+ };
5630
+ scopes.forEach(visit);
5631
+ const calls = (node) => {
5632
+ if (node === null || typeof node !== "object")
5633
+ return 0;
5634
+ const own = node.type === "Function" && node.name === fn ? 1 : 0;
5635
+ const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
5636
+ return own + next.reduce((sum, child) => sum + calls(child), 0);
5637
+ };
5638
+ return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
5639
+ }
5640
+ function fieldExpression(name) {
5641
+ return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
5642
+ }
5643
+ function evaluationHint(codec, filter, data, cause) {
5644
+ const underlying = cause instanceof Error ? cause.message : String(cause);
5645
+ const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
5646
+ if (!failure)
5647
+ return;
5648
+ const [, fn, position, expected] = failure;
5649
+ const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
5650
+ if (name === undefined)
5651
+ return;
5652
+ const present = availableFields(data);
5653
+ if (present.length === 0)
5654
+ return;
5655
+ const scope = `${countRecords(data)} record(s)`;
5656
+ if (!present.includes(name)) {
5657
+ return {
5658
+ detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
5659
+ instructions: "Use a field the records have; names are case-sensitive."
5660
+ };
5661
+ }
5662
+ const records = Array.isArray(data) ? data : [data];
5663
+ const unset = records.filter((r) => r?.[name] == null).length;
5664
+ const field = fieldExpression(name);
5665
+ let fallback;
5666
+ if (expected.split(",").includes("string")) {
5667
+ fallback = "''";
5668
+ } else if (expected.split(",").includes("array")) {
5669
+ fallback = "`[]`";
5670
+ }
5671
+ return {
5672
+ detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
5673
+ instructions: fallback ? `Give it a default where ${fn}() reads it, e.g. \`${field} || ${fallback}\`.` : `Filter out the records where \`${name}\` is null before ${fn}() reads it.`
5674
+ };
5675
+ }
5540
5676
  function buildFilterWarning(filter, data, outcome) {
5541
5677
  const present = availableFields(data);
5542
5678
  const refs = referencedFields(filter);
@@ -5544,7 +5680,7 @@ function buildFilterWarning(filter, data, outcome) {
5544
5680
  const unchecked = refs.nested.filter((name) => !present.includes(name));
5545
5681
  const count = countRecords(data);
5546
5682
  const scope = `${count} record(s)`;
5547
- const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
5683
+ const isNotAField = (names) => notFieldsOn(names, scope);
5548
5684
  const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
5549
5685
  const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
5550
5686
  let detail;
@@ -5595,7 +5731,8 @@ function applyFilter(data, filter, onWarning) {
5595
5731
  try {
5596
5732
  result = codec.search(data, filter);
5597
5733
  } catch (err) {
5598
- throw new FilterEvaluationError(filter, err);
5734
+ const [, hint] = catchError(() => evaluationHint(codec, filter, data, err));
5735
+ throw new FilterEvaluationError(filter, err, hint);
5599
5736
  }
5600
5737
  const inputCount = countRecords(data);
5601
5738
  const warn = (outcome) => {
@@ -6486,7 +6623,7 @@ Command.prototype.trackedAction = function(context, fn, properties) {
6486
6623
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
6487
6624
  const typed = error;
6488
6625
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
6489
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
6626
+ const customResult = carriedResult(error);
6490
6627
  const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6491
6628
  const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
6492
6629
  const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
@@ -6848,6 +6985,8 @@ var FAILURE_STATUSES = new Set([
6848
6985
  "canceled",
6849
6986
  "stopped"
6850
6987
  ]);
6988
+ // ../common/src/relayed-output.ts
6989
+ var RELAYED_OUTPUT_SYMBOL = Symbol.for("@uipath/common/relayed-output");
6851
6990
  // ../common/src/screen-logger.ts
6852
6991
  var ScreenLogger;
6853
6992
  ((ScreenLogger) => {
@@ -6869,7 +7008,7 @@ var package_default = {
6869
7008
  name: "@uipath/coder-tool",
6870
7009
  author: "UiPath",
6871
7010
  license: "SEE LICENSE IN LICENSE.txt",
6872
- version: "1.206.0-preview.301",
7011
+ version: "1.207.0-preview.305",
6873
7012
  description: "Interactive coding agent (Pi) with UiPath LLM Gateway and BYO provider support.",
6874
7013
  publishConfig: {
6875
7014
  registry: "https://npm.pkg.github.com/"
@@ -6941,6 +7080,8 @@ function settlePromiseLike2(thenable) {
6941
7080
  // ../auth/src/constants.ts
6942
7081
  var UIPATH_HOME_DIR = ".uipath";
6943
7082
  var AUTH_FILENAME = ".auth";
7083
+ var AUTH_FILE_MODE = 384;
7084
+ var AUTH_DIR_MODE = 448;
6944
7085
  var DEFAULT_BASE_URL = "https://cloud.uipath.com";
6945
7086
  var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
6946
7087
 
@@ -7764,6 +7905,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
7764
7905
  }
7765
7906
  return parseEnvContent(content);
7766
7907
  };
7908
+ var findAuthHomeDir = (fs, dir) => {
7909
+ let current = dir;
7910
+ for (;; ) {
7911
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
7912
+ return current;
7913
+ const parent = fs.path.dirname(current);
7914
+ if (parent === current)
7915
+ return;
7916
+ current = parent;
7917
+ }
7918
+ };
7919
+ var TEMP_FILE_ATTEMPTS = 5;
7920
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
7921
+ var writeTempFile = async (fs, targetPath, content) => {
7922
+ for (let attempt = 1;; attempt++) {
7923
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
7924
+ try {
7925
+ await fs.writeFile(tempPath, content, {
7926
+ mode: AUTH_FILE_MODE,
7927
+ exclusive: true
7928
+ });
7929
+ return tempPath;
7930
+ } catch (error) {
7931
+ if (!isFileExists(error)) {
7932
+ await fs.rm(tempPath).catch(() => {});
7933
+ throw error;
7934
+ }
7935
+ if (attempt === TEMP_FILE_ATTEMPTS)
7936
+ throw error;
7937
+ }
7938
+ }
7939
+ };
7767
7940
  var saveEnvFileAsync = async ({
7768
7941
  envPath,
7769
7942
  data,
@@ -7791,10 +7964,18 @@ var saveEnvFileAsync = async ({
7791
7964
  `)}
7792
7965
  `;
7793
7966
  const dir = fs.path.dirname(absolutePath);
7794
- await fs.mkdir(dir);
7795
- const tempPath = `${absolutePath}.tmp`;
7796
- await fs.writeFile(tempPath, content);
7797
- await fs.rename(tempPath, absolutePath);
7967
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
7968
+ const authHomeDir = findAuthHomeDir(fs, dir);
7969
+ if (authHomeDir !== undefined) {
7970
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
7971
+ }
7972
+ const tempPath = await writeTempFile(fs, absolutePath, content);
7973
+ try {
7974
+ await fs.rename(tempPath, absolutePath);
7975
+ } catch (error) {
7976
+ await fs.rm(tempPath).catch(() => {});
7977
+ throw error;
7978
+ }
7798
7979
  };
7799
7980
 
7800
7981
  // ../auth/src/loginStatus.ts
@@ -8626,4 +8807,4 @@ var registerCommands2 = async (program) => {
8626
8807
 
8627
8808
  export { Command, setPreviewBuild, metadata2, registerCommands2 };
8628
8809
 
8629
- //# debugId=E1EE55838B4FFB1E64756E2164756E21
8810
+ //# debugId=D9BF79353DB8CF0464756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata2,
3
3
  registerCommands2
4
- } from "./tool-46a2sjrp.js";
4
+ } from "./tool-n7he8rbd.js";
5
5
  export {
6
6
  metadata2 as metadata,
7
7
  registerCommands2 as registerCommands
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/coder-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.301",
5
+ "version": "1.207.0-preview.305",
6
6
  "description": "Interactive coding agent (Pi) with UiPath LLM Gateway and BYO provider support.",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/"
@@ -21,5 +21,5 @@
21
21
  "dependencies": {
22
22
  "@earendil-works/pi-coding-agent": "^0.80.6"
23
23
  },
24
- "gitHead": "078afc3ef7ebf4c38353ee0059e321acf16a350d"
24
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
25
25
  }