@uipath/conversational-tool 1.199.0-preview.106 → 1.199.0-preview.108

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.
Files changed (2) hide show
  1. package/dist/tool.js +47 -15
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -38458,7 +38458,7 @@ var init_conversational_agent = __esm(() => {
38458
38458
  var package_default = {
38459
38459
  name: "@uipath/conversational-tool",
38460
38460
  license: "MIT",
38461
- version: "1.199.0-preview.106",
38461
+ version: "1.199.0-preview.108",
38462
38462
  description: "Handle conversations with deployed UiPath conversational processes.",
38463
38463
  type: "module",
38464
38464
  main: "./dist/tool.js",
@@ -44390,8 +44390,18 @@ function getInboundTraceContext() {
44390
44390
 
44391
44391
  // ../common/src/telemetry/session-id.ts
44392
44392
  var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
44393
- var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
44394
- var telemetrySessionIdSlot = singleton("TelemetrySessionId");
44393
+ var SESSION_ID_MAX_LENGTH = 64;
44394
+ var RANDOM_SESSION_ID_LENGTH = 32;
44395
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
44396
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
44397
+ var INHERITED_SESSION_SOURCES = [
44398
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
44399
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
44400
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
44401
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
44402
+ { envVar: "WT_SESSION", source: "terminal" }
44403
+ ];
44404
+ var telemetrySessionSlot = singleton("TelemetrySession");
44395
44405
  var telemetryOperationIdSlot = singleton("TelemetryOperationId");
44396
44406
  function getProcessEnv2() {
44397
44407
  return globalThis.process?.env;
@@ -44400,14 +44410,42 @@ function normalizeSessionId(value) {
44400
44410
  if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
44401
44411
  return;
44402
44412
  }
44403
- const trimmed = String(value).trim();
44404
- return trimmed || undefined;
44413
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
44414
+ return cleaned || undefined;
44405
44415
  }
44406
44416
  function getConfiguredTelemetrySessionId() {
44407
44417
  return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
44408
44418
  }
44409
- function resolveTelemetrySessionId(existingSessionId) {
44410
- return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
44419
+ function getInheritedSession(env) {
44420
+ for (const candidate of INHERITED_SESSION_SOURCES) {
44421
+ const handle = normalizeSessionId(env[candidate.envVar]);
44422
+ if (handle) {
44423
+ return { id: handle, source: candidate.source };
44424
+ }
44425
+ }
44426
+ return;
44427
+ }
44428
+ function generateRandomSession() {
44429
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
44430
+ crypto.getRandomValues(bytes);
44431
+ let hex = "";
44432
+ for (const byte of bytes) {
44433
+ hex += byte.toString(16).padStart(2, "0");
44434
+ }
44435
+ return { id: hex, source: "random" };
44436
+ }
44437
+ function resolveTelemetrySession() {
44438
+ const existing = telemetrySessionSlot.get();
44439
+ if (existing) {
44440
+ return existing;
44441
+ }
44442
+ const declaredHandle = getConfiguredTelemetrySessionId();
44443
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
44444
+ telemetrySessionSlot.set(resolved);
44445
+ return resolved;
44446
+ }
44447
+ function getTelemetrySessionSource() {
44448
+ return resolveTelemetrySession().source;
44411
44449
  }
44412
44450
  function getTelemetryOperationId() {
44413
44451
  const existing = telemetryOperationIdSlot.get();
@@ -44684,24 +44722,18 @@ class TelemetryService {
44684
44722
  }
44685
44723
  enrichPropertiesWithContext(properties, context) {
44686
44724
  const globalProperties = getGlobalTelemetryProperties();
44687
- const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
44688
- const sessionId = resolveTelemetrySessionId(existingSessionId);
44689
44725
  const enriched = {
44690
44726
  ...getExecutionContextTelemetryProperties(),
44691
44727
  ...globalProperties,
44692
44728
  ...this.defaultProperties,
44693
44729
  ...redactProperties(properties ?? {}),
44730
+ [TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
44694
44731
  ...context ? {
44695
44732
  [TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
44696
44733
  ...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
44697
44734
  [TELEMETRY_SPAN_ID_PROPERTY]: context.id
44698
44735
  } : {}
44699
44736
  };
44700
- if (sessionId === undefined) {
44701
- delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
44702
- } else {
44703
- enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
44704
- }
44705
44737
  return enriched;
44706
44738
  }
44707
44739
  generateId() {
@@ -57949,4 +57981,4 @@ export {
57949
57981
  metadata
57950
57982
  };
57951
57983
 
57952
- //# debugId=22546A80021C6BDD64756E2164756E21
57984
+ //# debugId=B0FB18221FD2F09E64756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/conversational-tool",
3
3
  "license": "MIT",
4
- "version": "1.199.0-preview.106",
4
+ "version": "1.199.0-preview.108",
5
5
  "description": "Handle conversations with deployed UiPath conversational processes.",
6
6
  "type": "module",
7
7
  "main": "./dist/tool.js",
@@ -17,5 +17,5 @@
17
17
  "publishConfig": {
18
18
  "registry": "https://registry.npmjs.org/"
19
19
  },
20
- "gitHead": "cb01f256c2c4f1a1a5d014ffb97e506bac709e45"
20
+ "gitHead": "171f68daab68809916e8df10ea198c259f688ede"
21
21
  }