@uipath/uipath-typescript 1.4.2 → 1.5.1

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 (52) hide show
  1. package/README.md +7 -1
  2. package/dist/agent-memory/index.d.ts +4 -1
  3. package/dist/agents/index.cjs +341 -6
  4. package/dist/agents/index.d.ts +717 -16
  5. package/dist/agents/index.mjs +342 -7
  6. package/dist/assets/index.cjs +132 -15
  7. package/dist/assets/index.d.ts +12 -1
  8. package/dist/assets/index.mjs +132 -15
  9. package/dist/attachments/index.cjs +120 -12
  10. package/dist/attachments/index.mjs +120 -12
  11. package/dist/buckets/index.cjs +136 -15
  12. package/dist/buckets/index.d.ts +12 -1
  13. package/dist/buckets/index.mjs +136 -15
  14. package/dist/cases/index.cjs +1203 -938
  15. package/dist/cases/index.d.ts +325 -45
  16. package/dist/cases/index.mjs +1203 -938
  17. package/dist/conversational-agent/index.cjs +48 -10
  18. package/dist/conversational-agent/index.d.ts +117 -6
  19. package/dist/conversational-agent/index.mjs +48 -10
  20. package/dist/core/index.cjs +1 -1
  21. package/dist/core/index.mjs +1 -1
  22. package/dist/entities/index.cjs +448 -9
  23. package/dist/entities/index.d.ts +441 -1
  24. package/dist/entities/index.mjs +447 -10
  25. package/dist/feedback/index.cjs +25 -9
  26. package/dist/feedback/index.mjs +25 -9
  27. package/dist/index.cjs +1281 -330
  28. package/dist/index.d.ts +1988 -143
  29. package/dist/index.mjs +1282 -331
  30. package/dist/index.umd.js +1230 -279
  31. package/dist/jobs/index.cjs +141 -19
  32. package/dist/jobs/index.d.ts +22 -6
  33. package/dist/jobs/index.mjs +141 -19
  34. package/dist/maestro-processes/index.cjs +553 -354
  35. package/dist/maestro-processes/index.d.ts +376 -47
  36. package/dist/maestro-processes/index.mjs +553 -354
  37. package/dist/notifications/index.cjs +2012 -0
  38. package/dist/notifications/index.d.ts +615 -0
  39. package/dist/notifications/index.mjs +2010 -0
  40. package/dist/processes/index.cjs +118 -18
  41. package/dist/processes/index.d.ts +18 -2
  42. package/dist/processes/index.mjs +118 -18
  43. package/dist/queues/index.cjs +131 -14
  44. package/dist/queues/index.d.ts +12 -1
  45. package/dist/queues/index.mjs +131 -14
  46. package/dist/tasks/index.cjs +125 -13
  47. package/dist/tasks/index.d.ts +4 -1
  48. package/dist/tasks/index.mjs +125 -13
  49. package/dist/traces/index.cjs +220 -6
  50. package/dist/traces/index.d.ts +360 -25
  51. package/dist/traces/index.mjs +221 -7
  52. package/package.json +14 -4
@@ -713,7 +713,16 @@ var PaginationType;
713
713
  * Returns the original value if parsing fails.
714
714
  */
715
715
  /**
716
- * Transforms data by mapping fields according to the provided field mapping
716
+ * Transforms data by renaming each key in `data` exactly once, using the
717
+ * mapping (`sourceField → targetField`). Keys not present in the mapping
718
+ * pass through unchanged. The original (pre-rename) key is dropped — the
719
+ * result contains only the renamed key.
720
+ *
721
+ * Each rename is independent. If the mapping happens to contain chained
722
+ * entries (`a → b` and `b → c`), they do NOT compose: a field named `a`
723
+ * in `data` becomes `b` (not `c`), because the renames are applied based
724
+ * on the original data's keys, not the running result.
725
+ *
717
726
  * @param data The source data to transform
718
727
  * @param fieldMapping Object mapping source field names to target field names
719
728
  * @returns Transformed data with mapped field names
@@ -736,21 +745,28 @@ var PaginationType;
736
745
  * // { userId: '123', name: 'john' },
737
746
  * // { userId: '456', name: 'jane' }
738
747
  * // ]
748
+ *
749
+ * // No chaining — `a → b` does not become `a → c` even if the map has `b → c`.
750
+ * transformData({ a: 1 }, { a: 'b', b: 'c' });
751
+ * // result = { b: 1 }
739
752
  * ```
740
753
  */
741
754
  function transformData(data, fieldMapping) {
755
+ // Pass null/undefined through unchanged — callers (e.g. AttachmentService.getById)
756
+ // may invoke this on optional fields that an OData `select` excluded.
757
+ if (data == null) {
758
+ return data;
759
+ }
742
760
  // Handle array of objects
743
761
  if (Array.isArray(data)) {
744
762
  return data.map(item => transformData(item, fieldMapping));
745
763
  }
746
- // Handle single object
747
- const result = { ...data };
748
- for (const [sourceField, targetField] of Object.entries(fieldMapping)) {
749
- if (sourceField in result) {
750
- const value = result[sourceField];
751
- delete result[sourceField];
752
- result[targetField] = value;
753
- }
764
+ // Walk the ORIGINAL data's keys, look up each in the mapping. One rename
765
+ // per data key — no mutation of an in-progress result, so chains can't form.
766
+ const result = {};
767
+ for (const [key, value] of Object.entries(data)) {
768
+ const renamedKey = fieldMapping[key] ?? key;
769
+ result[renamedKey] = value;
754
770
  }
755
771
  return result;
756
772
  }
@@ -965,6 +981,97 @@ function addPrefixToKeys(obj, prefix, keys) {
965
981
  }
966
982
  return result;
967
983
  }
984
+ /**
985
+ * Creates a new map with the keys and values reversed
986
+ * @param map The original map to reverse
987
+ * @returns A new map with keys and values swapped
988
+ *
989
+ * @example
990
+ * ```typescript
991
+ * const original = { key1: 'value1', key2: 'value2' };
992
+ * const reversed = reverseMap(original);
993
+ * // reversed = { value1: 'key1', value2: 'key2' }
994
+ * ```
995
+ */
996
+ function reverseMap(map) {
997
+ return Object.entries(map).reduce((acc, [key, value]) => {
998
+ acc[value] = key;
999
+ return acc;
1000
+ }, {});
1001
+ }
1002
+ /**
1003
+ * OData query-string keys whose values may contain field identifiers that
1004
+ * need rewriting from SDK names → API names.
1005
+ */
1006
+ const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
1007
+ /**
1008
+ * Matches one token at a time in an OData expression:
1009
+ * 1. A single-quoted string literal, allowing the `''` escape sequence —
1010
+ * consumed atomically so identifiers inside the literal can't match.
1011
+ * 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
1012
+ * Anything else (whitespace, operators, parens, commas) is left alone by
1013
+ * `String.prototype.replace`, which only substitutes matched substrings.
1014
+ */
1015
+ const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
1016
+ /**
1017
+ * Rewrites SDK field identifiers to API field identifiers inside an OData
1018
+ * expression string (`$filter`, `$orderby`, `$select`, `$expand`).
1019
+ *
1020
+ * Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
1021
+ * SDK consumers see the renamed names. Without this rewrite, the same name
1022
+ * in a `filter` string would be forwarded verbatim and the API (which still
1023
+ * uses the original name) would reject it.
1024
+ *
1025
+ * Quoted string literals (with the OData `''` escape) are preserved exactly:
1026
+ * the token regex consumes them whole, so identifiers inside literals never
1027
+ * match. Identifier tokens are looked up in the reversed field map.
1028
+ *
1029
+ * @example
1030
+ * ```typescript
1031
+ * const requestMap = { processName: 'releaseName' };
1032
+ * rewriteODataIdentifiers("processName eq 'processName'", requestMap);
1033
+ * // "releaseName eq 'processName'" — identifier rewritten, literal preserved
1034
+ * ```
1035
+ */
1036
+ function rewriteODataIdentifiers(expression, requestMap) {
1037
+ if (!expression)
1038
+ return expression;
1039
+ return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
1040
+ }
1041
+ /**
1042
+ * Symmetric counterpart of {@link transformRequest} for OData query options:
1043
+ * rewrites SDK field identifiers inside the recognized OData string params
1044
+ * (`filter`, `orderby`, `select`, `expand`) to their API names using the
1045
+ * reversed form of a response field map. Returns a shallow copy with the
1046
+ * relevant values rewritten; other keys pass through unchanged.
1047
+ *
1048
+ * Use at the OData edge so SDK consumers can refer to renamed fields by
1049
+ * their SDK name throughout — for reading the response and for filtering /
1050
+ * sorting / projecting / expanding.
1051
+ *
1052
+ * @param options The OData query options as authored with SDK field names
1053
+ * @param responseMap The response field map (API → SDK); reversed internally
1054
+ *
1055
+ * @example
1056
+ * ```typescript
1057
+ * // JobMap renames releaseName → processName on responses.
1058
+ * transformOptions({ filter: "processName eq 'X'" }, JobMap);
1059
+ * // { filter: "releaseName eq 'X'" }
1060
+ * ```
1061
+ */
1062
+ function transformOptions(options, responseMap) {
1063
+ const requestMap = reverseMap(responseMap);
1064
+ if (Object.keys(requestMap).length === 0)
1065
+ return options;
1066
+ const result = { ...options };
1067
+ for (const key of ODATA_FIELD_PARAM_KEYS) {
1068
+ const value = result[key];
1069
+ if (typeof value === 'string') {
1070
+ result[key] = rewriteODataIdentifiers(value, requestMap);
1071
+ }
1072
+ }
1073
+ return result;
1074
+ }
968
1075
 
969
1076
  /**
970
1077
  * Constants used throughout the pagination system
@@ -2258,6 +2365,10 @@ class TaskService extends BaseService {
2258
2365
  const transformedTask = transformData(pascalToCamelCaseKeys(task), TaskMap);
2259
2366
  return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
2260
2367
  };
2368
+ // Rewrite renamed SDK field names → API names inside OData strings
2369
+ // before delegating, mirroring the transformRequest pattern used for
2370
+ // request bodies.
2371
+ const apiOptions = options ? transformOptions(options, TaskMap) : options;
2261
2372
  return PaginationHelpers.getAll({
2262
2373
  serviceAccess: this.createPaginationServiceAccess(),
2263
2374
  getEndpoint: () => endpoint,
@@ -2274,7 +2385,7 @@ class TaskService extends BaseService {
2274
2385
  countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM // OData OFFSET parameter
2275
2386
  }
2276
2387
  }
2277
- }, options);
2388
+ }, apiOptions);
2278
2389
  }
2279
2390
  /**
2280
2391
  * Gets a task by ID
@@ -2310,9 +2421,10 @@ class TaskService extends BaseService {
2310
2421
  const headers = createHeaders({ [FOLDER_ID]: folderId });
2311
2422
  // Add default expand parameters
2312
2423
  const modifiedOptions = this.addDefaultExpand(restOptions);
2313
- // prefix all keys in options
2314
- const keysToPrefix = Object.keys(modifiedOptions);
2315
- const apiOptions = addPrefixToKeys(modifiedOptions, ODATA_PREFIX, keysToPrefix);
2424
+ // Rewrite renamed SDK field names → API names inside OData strings,
2425
+ // then prefix all keys for OData.
2426
+ const apiFieldOptions = transformOptions(modifiedOptions, TaskMap);
2427
+ const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
2316
2428
  const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
2317
2429
  params: apiOptions,
2318
2430
  headers
@@ -948,6 +948,17 @@ const TRACEVIEW_SPANS_PAGINATION = {
948
948
  /** Total count path — same envelope location as the agents list. */
949
949
  TOTAL_COUNT_FIELD: AGENTS_PAGINATION.TOTAL_COUNT_FIELD
950
950
  };
951
+ /**
952
+ * Governance decisions pagination constants — decision rows sit directly
953
+ * under `items`. This endpoint returns no total-count field, so no
954
+ * `TOTAL_COUNT_FIELD` is defined; `hasNextPage` falls back to page-fullness
955
+ * (a full page implies there may be more). Request params reuse
956
+ * {@link AGENTS_OFFSET_PARAMS} (pageSize + 0-based pageNumber).
957
+ */
958
+ const GOVERNANCE_DECISIONS_PAGINATION = {
959
+ /** Field name for the decision-rows array in the response. */
960
+ ITEMS_FIELD: 'items',
961
+ };
951
962
  /**
952
963
  * OData OFFSET pagination parameter names (ODATA-style)
953
964
  */
@@ -1839,12 +1850,16 @@ const AGENT_TRACES_ENDPOINTS = {
1839
1850
  GET_ERRORS_TIMELINE: `${INSIGHTS_RTM_BASE}/Traceview/errorsTimeline`,
1840
1851
  /** Trace-level time-series of latency (decimal seconds per series). */
1841
1852
  GET_LATENCY_TIMELINE: `${INSIGHTS_RTM_BASE}/Traceview/latencyTimeline`,
1842
- /** Trace-level per-agent AGU/PLTU consumption totals. */
1853
+ /** Trace-level per-agent Agent Units and Platform Units consumption totals. */
1843
1854
  GET_UNIT_CONSUMPTION: `${INSIGHTS_RTM_BASE}/Traceview/unitConsumption`,
1844
1855
  /** All spans for a single trace (flat array, not paginated). */
1845
1856
  GET_SPANS_BY_TRACE_ID: (traceId) => `${INSIGHTS_RTM_BASE}/Traceview/spans/${traceId}`,
1846
1857
  /** Paginated spans whose reference hierarchy contains the given reference id. */
1847
1858
  GET_SPANS_BY_REFERENCE: (referenceId) => `${INSIGHTS_RTM_BASE}/Traceview/spans/reference/${referenceId}`,
1859
+ /** Paginated raw governance decision rows. */
1860
+ GET_GOVERNANCE_DECISIONS: `${INSIGHTS_RTM_BASE}/Governance/agentic/traces`,
1861
+ /** Aggregated governance posture (totals + top-N breakdowns). */
1862
+ GET_GOVERNANCE_SUMMARY: `${INSIGHTS_RTM_BASE}/Governance/agentic/summary`,
1848
1863
  };
1849
1864
 
1850
1865
  /**
@@ -1983,6 +1998,52 @@ __decorate([
1983
1998
  track('Traces.GetSpansByIds')
1984
1999
  ], TracesService.prototype, "getSpansByIds", null);
1985
2000
 
2001
+ // ─── Governance ─────────────────────────────────────────────────────
2002
+ /**
2003
+ * Evaluation mode of a governance decision.
2004
+ */
2005
+ exports.AgentGovernanceMode = void 0;
2006
+ (function (AgentGovernanceMode) {
2007
+ /** Policy evaluated and logged, but not enforced. */
2008
+ AgentGovernanceMode["Audit"] = "AUDIT";
2009
+ /** Policy evaluated and enforced. */
2010
+ AgentGovernanceMode["Enforce"] = "ENFORCE";
2011
+ /** Unrecognized or missing mode. */
2012
+ AgentGovernanceMode["Unknown"] = "Unknown";
2013
+ })(exports.AgentGovernanceMode || (exports.AgentGovernanceMode = {}));
2014
+ /**
2015
+ * Verdict of a governance decision (`Deny` = violation).
2016
+ */
2017
+ exports.AgentGovernanceVerdict = void 0;
2018
+ (function (AgentGovernanceVerdict) {
2019
+ /** Allowed — not a violation. */
2020
+ AgentGovernanceVerdict["Allow"] = "ALLOW";
2021
+ /** Denied — counts as a violation. */
2022
+ AgentGovernanceVerdict["Deny"] = "DENY";
2023
+ /** Unrecognized or missing verdict. */
2024
+ AgentGovernanceVerdict["Unknown"] = "Unknown";
2025
+ })(exports.AgentGovernanceVerdict || (exports.AgentGovernanceVerdict = {}));
2026
+ /**
2027
+ * Sections the governance summary can compute. `action` and `mode` are opt-in.
2028
+ */
2029
+ exports.AgentGovernanceSection = void 0;
2030
+ (function (AgentGovernanceSection) {
2031
+ /** Scalar totals (`total`, `violations`). */
2032
+ AgentGovernanceSection["Totals"] = "totals";
2033
+ /** Breakdown by governance hook. */
2034
+ AgentGovernanceSection["Hook"] = "hook";
2035
+ /** Breakdown by agent. */
2036
+ AgentGovernanceSection["Agent"] = "agent";
2037
+ /** Breakdown by policy. */
2038
+ AgentGovernanceSection["Policy"] = "policy";
2039
+ /** Breakdown by governance pack. */
2040
+ AgentGovernanceSection["Pack"] = "pack";
2041
+ /** Breakdown by enforcement action (opt-in). */
2042
+ AgentGovernanceSection["Action"] = "action";
2043
+ /** Breakdown by evaluation mode (opt-in). */
2044
+ AgentGovernanceSection["Mode"] = "mode";
2045
+ })(exports.AgentGovernanceSection || (exports.AgentGovernanceSection = {}));
2046
+
1986
2047
  /**
1987
2048
  * Maps a raw span record to a {@link AgentSpanGetResponse}
1988
2049
  */
@@ -1990,6 +2051,22 @@ const transformSpan = (span) => {
1990
2051
  const { expiryTimeUtc, ...rest } = span;
1991
2052
  return { ...rest, expiredTime: expiryTimeUtc };
1992
2053
  };
2054
+ // Case-insensitive lookups from a raw API value → enum member (keys upper-cased).
2055
+ const GOVERNANCE_MODE_BY_VALUE = new Map(Object.values(exports.AgentGovernanceMode).map((mode) => [mode.toUpperCase(), mode]));
2056
+ const GOVERNANCE_VERDICT_BY_VALUE = new Map(Object.values(exports.AgentGovernanceVerdict).map((verdict) => [verdict.toUpperCase(), verdict]));
2057
+ /** Maps a raw mode string to {@link AgentGovernanceMode}, case-insensitively; missing/unrecognized → `Unknown`. */
2058
+ const toGovernanceMode = (raw) => (raw != null ? GOVERNANCE_MODE_BY_VALUE.get(raw.toUpperCase()) : undefined) ?? exports.AgentGovernanceMode.Unknown;
2059
+ /** Maps a raw verdict string to {@link AgentGovernanceVerdict}, case-insensitively; missing/unrecognized → `Unknown`. */
2060
+ const toGovernanceVerdict = (raw) => (raw != null ? GOVERNANCE_VERDICT_BY_VALUE.get(raw.toUpperCase()) : undefined) ?? exports.AgentGovernanceVerdict.Unknown;
2061
+ /**
2062
+ * Normalizes a raw governance row, mapping the mode and verdict strings to
2063
+ * their enums while leaving the other fields untouched.
2064
+ */
2065
+ const transformGovernanceDecision = (row) => ({
2066
+ ...row,
2067
+ mode: toGovernanceMode(row.mode),
2068
+ evaluatorResult: toGovernanceVerdict(row.evaluatorResult),
2069
+ });
1993
2070
  /**
1994
2071
  * Service for retrieving UiPath Agent trace metrics.
1995
2072
  */
@@ -2078,7 +2155,7 @@ class AgentTracesService extends BaseService {
2078
2155
  * // Get per-agent unit consumption
2079
2156
  * const result = await trace.getUnitConsumption();
2080
2157
  * result.forEach((row) => {
2081
- * console.log(`${row.agentId}: ${row.agentUnitsConsumed} AGU, ${row.platformUnitsConsumed} PLTU`);
2158
+ * console.log(`${row.agentId}: ${row.agentUnitsConsumed} Agent Units, ${row.platformUnitsConsumed} Platform Units`);
2082
2159
  * });
2083
2160
  * ```
2084
2161
  * @example
@@ -2125,10 +2202,6 @@ class AgentTracesService extends BaseService {
2125
2202
  /**
2126
2203
  * Retrieves spans whose reference hierarchy contains the given reference id.
2127
2204
  *
2128
- * Returns a {@link PaginatedResponse} when pagination options (`pageSize`,
2129
- * `cursor`, or `jumpToPage`) are provided, otherwise a
2130
- * {@link NonPaginatedResponse}.
2131
- *
2132
2205
  * @param referenceId - Reference id matched against each span's reference hierarchy
2133
2206
  * @param options - Optional pagination and hierarchy/time filters
2134
2207
  * @returns Promise resolving to a paginated or non-paginated list of {@link AgentSpanGetResponse}
@@ -2189,6 +2262,141 @@ class AgentTracesService extends BaseService {
2189
2262
  },
2190
2263
  }, apiOptions);
2191
2264
  }
2265
+ /**
2266
+ * Lists individual governance decisions from agent execution traces — each
2267
+ * policy check's allow/deny outcome with its agent, policy, pack, hook, and
2268
+ * mode, plus the trace it belongs to — over the requested window. Filterable
2269
+ * and paginated.
2270
+ *
2271
+ * @remarks Requires the caller to be an organization admin. Non-admin callers get a `403` and the SDK throws an {@link AuthorizationError}.
2272
+ *
2273
+ * @param startTime - Inclusive lower bound for the query window
2274
+ * @param options - Optional window end, filters, and pagination
2275
+ * @returns Promise resolving to a paginated or non-paginated list of {@link AgentGovernanceDecisionGetResponse}
2276
+ * @example
2277
+ * ```typescript
2278
+ * import { AgentTraces } from '@uipath/uipath-typescript/traces';
2279
+ *
2280
+ * const trace = new AgentTraces(sdk);
2281
+ *
2282
+ * // Decision rows since a start time
2283
+ * const result = await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z'));
2284
+ * result.items.forEach((row) => {
2285
+ * console.log(`${row.hook} ${row.policyId}: ${row.evaluatorResult}`);
2286
+ * });
2287
+ * ```
2288
+ * @example
2289
+ * ```typescript
2290
+ * // Violations only, for one agent, paginated
2291
+ * const page = await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z'), {
2292
+ * endTime: new Date('2025-06-01T00:00:00Z'),
2293
+ * violationsOnly: true,
2294
+ * agentId: '<agentProjectKey>',
2295
+ * pageSize: 25,
2296
+ * });
2297
+ * if (page.hasNextPage && page.nextCursor) {
2298
+ * const next = await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z'), { cursor: page.nextCursor });
2299
+ * }
2300
+ * ```
2301
+ * @example
2302
+ * ```typescript
2303
+ * import { isAuthorizationError } from '@uipath/uipath-typescript/core';
2304
+ *
2305
+ * // Non-admin callers get a 403
2306
+ * try {
2307
+ * await trace.getGovernanceDecisions(new Date('2025-05-01T00:00:00Z'));
2308
+ * } catch (error) {
2309
+ * if (isAuthorizationError(error)) {
2310
+ * console.error('Governance data requires an organization admin.');
2311
+ * }
2312
+ * }
2313
+ * ```
2314
+ */
2315
+ async getGovernanceDecisions(startTime, options) {
2316
+ const { endTime, ...rest } = options ?? {};
2317
+ const apiOptions = {
2318
+ ...rest,
2319
+ startTime: startTime.toISOString(),
2320
+ ...(endTime !== undefined ? { endTime: endTime.toISOString() } : {}),
2321
+ };
2322
+ return PaginationHelpers.getAll({
2323
+ serviceAccess: this.createPaginationServiceAccess(),
2324
+ getEndpoint: () => AGENT_TRACES_ENDPOINTS.GET_GOVERNANCE_DECISIONS,
2325
+ method: HTTP_METHODS.POST,
2326
+ transformFn: transformGovernanceDecision,
2327
+ excludeFromPrefix: Object.keys(apiOptions),
2328
+ pagination: {
2329
+ paginationType: PaginationType.OFFSET,
2330
+ itemsField: GOVERNANCE_DECISIONS_PAGINATION.ITEMS_FIELD,
2331
+ paginationParams: {
2332
+ pageSizeParam: AGENTS_OFFSET_PARAMS.PAGE_SIZE_PARAM,
2333
+ offsetParam: AGENTS_OFFSET_PARAMS.OFFSET_PARAM,
2334
+ countParam: AGENTS_OFFSET_PARAMS.COUNT_PARAM,
2335
+ convertToSkip: false,
2336
+ zeroBased: true,
2337
+ },
2338
+ },
2339
+ }, apiOptions);
2340
+ }
2341
+ /**
2342
+ * Summarizes governance decisions across agent execution traces — total
2343
+ * decisions and violations, plus top breakdowns by hook, agent, policy, and
2344
+ * pack — over the requested window. Filterable.
2345
+ *
2346
+ * @remarks Requires the caller to be an organization admin. Non-admin callers get a `403` and the SDK throws an {@link AuthorizationError}.
2347
+ *
2348
+ * @param startTime - Inclusive lower bound for the query window
2349
+ * @param options - Optional window end, top-N, pack scope, and sections
2350
+ * @returns Promise resolving to {@link AgentGovernanceGetSummaryResponse}
2351
+ * @example
2352
+ * ```typescript
2353
+ * import { AgentTraces } from '@uipath/uipath-typescript/traces';
2354
+ *
2355
+ * const trace = new AgentTraces(sdk);
2356
+ *
2357
+ * // Default posture since a start time
2358
+ * const summary = await trace.getGovernanceSummary(new Date('2025-05-01T00:00:00Z'));
2359
+ * console.log(`${summary.violations} / ${summary.total} violations`);
2360
+ * summary.byPolicy.forEach((p) => console.log(`${p.key}: ${p.violationCount}`));
2361
+ * ```
2362
+ * @example
2363
+ * ```typescript
2364
+ * import { AgentGovernanceSection } from '@uipath/uipath-typescript/traces';
2365
+ *
2366
+ * // Top 5 per breakdown, scoped to a pack, including the opt-in action/mode sections
2367
+ * const summary = await trace.getGovernanceSummary(new Date('2025-05-01T00:00:00Z'), {
2368
+ * topN: 5,
2369
+ * packName: 'ISO/IEC 42001:2023 Runtime',
2370
+ * sections: [AgentGovernanceSection.Action, AgentGovernanceSection.Mode],
2371
+ * });
2372
+ * ```
2373
+ * @example
2374
+ * ```typescript
2375
+ * import { isAuthorizationError } from '@uipath/uipath-typescript/core';
2376
+ *
2377
+ * // Non-admin callers get a 403
2378
+ * try {
2379
+ * await trace.getGovernanceSummary(new Date('2025-05-01T00:00:00Z'));
2380
+ * } catch (error) {
2381
+ * if (isAuthorizationError(error)) {
2382
+ * console.error('Governance data requires an organization admin.');
2383
+ * }
2384
+ * }
2385
+ * ```
2386
+ */
2387
+ async getGovernanceSummary(startTime, options) {
2388
+ const body = { startTime: startTime.toISOString() };
2389
+ if (options?.endTime !== undefined)
2390
+ body.endTime = options.endTime.toISOString();
2391
+ if (options?.topN !== undefined)
2392
+ body.topN = options.topN;
2393
+ if (options?.packName !== undefined)
2394
+ body.packName = options.packName;
2395
+ if (options?.sections !== undefined)
2396
+ body.sections = options.sections;
2397
+ const response = await this.post(AGENT_TRACES_ENDPOINTS.GET_GOVERNANCE_SUMMARY, body);
2398
+ return response.data;
2399
+ }
2192
2400
  buildTraceFilterBody(options) {
2193
2401
  const body = {};
2194
2402
  if (options?.startTime !== undefined)
@@ -2221,6 +2429,12 @@ __decorate([
2221
2429
  __decorate([
2222
2430
  track('AgentTraces.GetSpansByReference')
2223
2431
  ], AgentTracesService.prototype, "getSpansByReference", null);
2432
+ __decorate([
2433
+ track('AgentTraces.GetGovernanceDecisions')
2434
+ ], AgentTracesService.prototype, "getGovernanceDecisions", null);
2435
+ __decorate([
2436
+ track('AgentTraces.GetGovernanceSummary')
2437
+ ], AgentTracesService.prototype, "getGovernanceSummary", null);
2224
2438
 
2225
2439
  exports.AgentTraceExecutionType = exports.SpanExecutionType;
2226
2440
  exports.AgentTraces = AgentTracesService;