@uipath/maestro-sdk 1.204.0 → 1.205.0-preview.258

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.
@@ -876,6 +876,16 @@ class NodeFileSystem {
876
876
  async rename(oldPath, newPath) {
877
877
  await fs6.rename(oldPath, newPath);
878
878
  }
879
+ async isSymbolicLink(filePath) {
880
+ try {
881
+ return (await fs6.lstat(filePath)).isSymbolicLink();
882
+ } catch (error) {
883
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
884
+ return false;
885
+ }
886
+ throw error;
887
+ }
888
+ }
879
889
  async realpath(filePath) {
880
890
  try {
881
891
  return await fs6.realpath(filePath);
@@ -1935,7 +1945,7 @@ function getGlobalLogFilePath() {
1935
1945
  function getLogFilePath() {
1936
1946
  return logger.getLogFilePath();
1937
1947
  }
1938
- var logFilePathSlot, DEFAULT_LOG_LEVEL = 3 /* ERROR */, SimpleLogger, loggerSingleton, logger;
1948
+ var logFilePathSlot, DEFAULT_LOG_LEVEL = 2 /* WARN */, SimpleLogger, loggerSingleton, logger;
1939
1949
  var init_logger = __esm(() => {
1940
1950
  init_src();
1941
1951
  init_catch_error();
@@ -6823,7 +6833,9 @@ var init_telemetry_dimensions = __esm(() => {
6823
6833
  Result: "Result",
6824
6834
  ErrorCode: "ErrorCode",
6825
6835
  Retry: "Retry",
6826
- ErrorMessage: "ErrorMessage"
6836
+ ErrorMessage: "ErrorMessage",
6837
+ HttpStatus: "HttpStatus",
6838
+ UpstreamErrorCode: "UpstreamErrorCode"
6827
6839
  };
6828
6840
  AuthDimensions = {
6829
6841
  AuthenticationMethod: "AuthenticationMethod",
@@ -8788,7 +8800,9 @@ var init_formatter = __esm(() => {
8788
8800
  "timeout",
8789
8801
  "server_error",
8790
8802
  "method_not_allowed",
8803
+ "not_supported",
8791
8804
  "configuration_error",
8805
+ "execution_failed",
8792
8806
  "unknown_error"
8793
8807
  ];
8794
8808
  RETRY_HINTS = [
@@ -8902,7 +8916,9 @@ var init_formatter = __esm(() => {
8902
8916
  [ErrorDimensions.Result]: data.Result,
8903
8917
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
8904
8918
  [ErrorDimensions.Retry]: data.Retry,
8905
- [ErrorDimensions.ErrorMessage]: data.Message
8919
+ [ErrorDimensions.ErrorMessage]: data.Message,
8920
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
8921
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
8906
8922
  });
8907
8923
  }
8908
8924
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -11635,6 +11651,9 @@ async function hashContent(content) {
11635
11651
  throw new Error("Unable to compute SHA-256 hash in this environment.");
11636
11652
  }
11637
11653
 
11654
+ // ../common/src/entity-field-rules.ts
11655
+ var init_entity_field_rules = () => {};
11656
+
11638
11657
  // ../common/src/entity-name-rules.ts
11639
11658
  var RESERVED_SQL_KEYWORDS_LOWER, RESERVED_FIELD_NAMES_LOWER, RESERVED_KEYWORDS_LOWER;
11640
11659
  var init_entity_name_rules = __esm(() => {
@@ -11869,6 +11888,17 @@ var init_host_global_options = __esm(() => {
11869
11888
  BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
11870
11889
  });
11871
11890
 
11891
+ // ../common/src/http-status.ts
11892
+ function httpStatusOf(error) {
11893
+ if (!error || typeof error !== "object") {
11894
+ return;
11895
+ }
11896
+ if ("response" in error && error.response && typeof error.response === "object" && "status" in error.response && typeof error.response.status === "number") {
11897
+ return error.response.status;
11898
+ }
11899
+ return "status" in error && typeof error.status === "number" ? error.status : undefined;
11900
+ }
11901
+
11872
11902
  // ../common/src/interactivity-context.ts
11873
11903
  var modeSlot, interactiveFlagSlot;
11874
11904
  var init_interactivity_context = __esm(() => {
@@ -11878,6 +11908,11 @@ var init_interactivity_context = __esm(() => {
11878
11908
  interactiveFlagSlot = singleton("InteractiveFlag");
11879
11909
  });
11880
11910
 
11911
+ // ../common/src/json-option.ts
11912
+ var init_json_option = __esm(() => {
11913
+ init_src();
11914
+ });
11915
+
11881
11916
  // ../common/src/mime-types.ts
11882
11917
  var MIME_TYPES_BY_EXTENSION;
11883
11918
  var init_mime_types = __esm(() => {
@@ -11919,9 +11954,15 @@ var init_mime_types = __esm(() => {
11919
11954
  // ../common/src/option-aliases.ts
11920
11955
  var init_option_aliases = __esm(() => {
11921
11956
  init_esm();
11957
+ init_formatter();
11922
11958
  init_output_context();
11923
11959
  });
11924
11960
 
11961
+ // ../common/src/option-groups.ts
11962
+ var init_option_groups = __esm(() => {
11963
+ init_formatter();
11964
+ });
11965
+
11925
11966
  // ../common/src/option-validators.ts
11926
11967
  function parseLimit(raw, _previous) {
11927
11968
  return parseBoundedInt(raw, "--limit", { min: 1, max: 1e4 });
@@ -12111,6 +12152,11 @@ var init_sdk_user_agent = __esm(() => {
12111
12152
  AGENT_PROPERTY = BaseDimensions.Agent;
12112
12153
  sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
12113
12154
  });
12155
+
12156
+ // ../common/src/shell-quote.ts
12157
+ function quoteForShell(value) {
12158
+ return `'${value.replace(/'/g, "'\\''")}'`;
12159
+ }
12114
12160
  // ../common/src/stdin.ts
12115
12161
  async function readStdin() {
12116
12162
  if (process.stdin.isTTY) {
@@ -12167,6 +12213,7 @@ var init_src2 = __esm(() => {
12167
12213
  init_completer();
12168
12214
  init_confirmation();
12169
12215
  init_constants();
12216
+ init_entity_field_rules();
12170
12217
  init_entity_name_rules();
12171
12218
  init_error_handler();
12172
12219
  init_error_instructions();
@@ -12174,9 +12221,11 @@ var init_src2 = __esm(() => {
12174
12221
  init_guid();
12175
12222
  init_host_global_options();
12176
12223
  init_interactivity_context();
12224
+ init_json_option();
12177
12225
  init_logger();
12178
12226
  init_mime_types();
12179
12227
  init_option_aliases();
12228
+ init_option_groups();
12180
12229
  init_option_validators();
12181
12230
  init_output_codecs();
12182
12231
  init_output_context();
@@ -12283,22 +12332,12 @@ var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00", AUTH_FILE_CONFIG
12283
12332
  baseUrl = DEFAULT_BASE_URL;
12284
12333
  }
12285
12334
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
12286
- let clientId = customClientId;
12287
- if (!clientId && fileAuth.clientId) {
12288
- clientId = fileAuth.clientId;
12289
- }
12290
- if (!clientId) {
12291
- clientId = DEFAULT_CLIENT_ID;
12292
- }
12293
- let clientSecret = customClientSecret;
12294
- if (!clientSecret && fileAuth.clientSecret) {
12295
- clientSecret = fileAuth.clientSecret;
12296
- }
12297
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
12335
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
12336
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
12298
12337
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
12299
12338
  return {
12300
12339
  clientId,
12301
- clientSecret,
12340
+ clientSecret: customClientSecret,
12302
12341
  scopes,
12303
12342
  baseUrl,
12304
12343
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -12495,6 +12534,15 @@ var parseAuthFlow = (value) => value === "authorization_code" || value === "clie
12495
12534
  return "Application";
12496
12535
  }
12497
12536
  return;
12537
+ }, resolveApplicationSubtype = (claims, authFlow) => {
12538
+ switch (asString(claims?.sub_type)) {
12539
+ case "service.external":
12540
+ return "External";
12541
+ case "service.internal":
12542
+ return "Internal";
12543
+ default:
12544
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
12545
+ }
12498
12546
  }, looksLikeEmail = (value) => value?.includes("@") ?? false, pickEmail = (claims) => {
12499
12547
  for (const candidate of [claims?.email, claims?.preferred_username]) {
12500
12548
  const value = asString(candidate);
@@ -12532,6 +12580,12 @@ var parseAuthFlow = (value) => value === "authorization_code" || value === "clie
12532
12580
  const clientId = asString(claims?.client_id);
12533
12581
  if (clientId)
12534
12582
  identity.clientId = clientId;
12583
+ const subType = asString(claims?.sub_type);
12584
+ if (subType)
12585
+ identity.subType = subType;
12586
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
12587
+ if (applicationSubtype)
12588
+ identity.applicationSubtype = applicationSubtype;
12535
12589
  return identity;
12536
12590
  }, readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
12537
12591
  var init_sessionIdentity = __esm(() => {
@@ -12820,6 +12874,39 @@ var init_robotClientFallback = __esm(() => {
12820
12874
  ROBOT_CLIENT_LOADER_KEY = Symbol.for("@uipath/auth/RobotClientLoader");
12821
12875
  });
12822
12876
 
12877
+ // ../auth/src/tenantSelection.ts
12878
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.", organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`, IDENTIFIER_STATUSES, describeNonJsonResponse = (organizationId, response, parseError) => {
12879
+ if (response.redirected) {
12880
+ return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
12881
+ }
12882
+ const contentType = response.headers.get("content-type") ?? "unknown";
12883
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
12884
+ }, fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
12885
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
12886
+ const response = await fetch(url, {
12887
+ headers: {
12888
+ Authorization: `Bearer ${accessToken}`
12889
+ },
12890
+ ...signal ? { signal } : {}
12891
+ });
12892
+ if (!response.ok) {
12893
+ if (response.status === 401) {
12894
+ throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
12895
+ }
12896
+ const errorText = await response.text();
12897
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
12898
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
12899
+ }
12900
+ const [parseError, data] = await catchError2(response.json());
12901
+ if (parseError) {
12902
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
12903
+ }
12904
+ return data;
12905
+ };
12906
+ var init_tenantSelection = __esm(() => {
12907
+ IDENTIFIER_STATUSES = new Set([400, 403, 404]);
12908
+ });
12909
+
12823
12910
  // ../auth/src/tokenRefresh.ts
12824
12911
  function isTokenRefreshOAuthFailure(error) {
12825
12912
  return error instanceof TokenRefreshOAuthError;
@@ -13031,7 +13118,7 @@ var init_envFile = __esm(() => {
13031
13118
  });
13032
13119
 
13033
13120
  // ../auth/src/loginStatus.ts
13034
- async function resolveRobotEnforcedStatus(robotFallback) {
13121
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
13035
13122
  if (isEnvAuthEnabled()) {
13036
13123
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
13037
13124
  }
@@ -13042,11 +13129,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
13042
13129
  hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
13043
13130
  };
13044
13131
  }
13045
- return buildRobotStatus(robotCreds);
13132
+ return buildRobotStatus(robotCreds, deps);
13046
13133
  }
13047
- async function resolveBorrowedRobotStatus(robotFallback) {
13134
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
13048
13135
  const robotCreds = await robotFallback();
13049
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
13136
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
13050
13137
  }
13051
13138
  async function loadFileCredentials(loadEnvFile, absolutePath) {
13052
13139
  let credentials;
@@ -13181,9 +13268,10 @@ function identityFields(accessToken, credentials) {
13181
13268
  ...scopes ? { scopes } : {}
13182
13269
  };
13183
13270
  }
13184
- function buildRobotStatus(robotCreds) {
13271
+ async function buildRobotStatus(robotCreds, deps) {
13185
13272
  const identity = resolveSessionIdentity(robotCreds.accessToken);
13186
13273
  const scopes = readTokenScopes(robotCreds.accessToken);
13274
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
13187
13275
  return {
13188
13276
  loginStatus: "Logged in",
13189
13277
  accessToken: robotCreds.accessToken,
@@ -13191,14 +13279,62 @@ function buildRobotStatus(robotCreds) {
13191
13279
  organizationName: robotCreds.organizationName,
13192
13280
  organizationId: robotCreds.organizationId,
13193
13281
  tenantName: robotCreds.tenantName,
13194
- tenantId: robotCreds.tenantId,
13282
+ tenantId: tenant.tenantId,
13195
13283
  issuer: robotCreds.issuer,
13196
13284
  expiration: getTokenExpiration(robotCreds.accessToken),
13197
13285
  source: "robot" /* Robot */,
13286
+ ...tenant.hint ? { hint: tenant.hint } : {},
13198
13287
  ...identity ? { identity } : {},
13199
13288
  ...scopes ? { scopes } : {}
13200
13289
  };
13201
13290
  }
13291
+ async function resolveRobotTenantId(robotCreds, deps) {
13292
+ const { baseUrl, accessToken, tenantName } = robotCreds;
13293
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
13294
+ if (!tenantName || !organization) {
13295
+ return {};
13296
+ }
13297
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
13298
+ let pending = deps.cache.get(key);
13299
+ if (!pending) {
13300
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
13301
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
13302
+ if (!settled.tenantId) {
13303
+ deps.cache.delete(key);
13304
+ }
13305
+ return settled;
13306
+ });
13307
+ deps.cache.set(key, pending);
13308
+ }
13309
+ return pending;
13310
+ }
13311
+ async function lookupRobotTenantId(target, deps) {
13312
+ const { baseUrl, accessToken, organization, tenantName } = target;
13313
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
13314
+ if (error) {
13315
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
13316
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
13317
+ }
13318
+ const rows = data?.tenants;
13319
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
13320
+ const wantedName = decodePathSegment(tenantName);
13321
+ const wanted = wantedName.toLowerCase();
13322
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
13323
+ if (!match) {
13324
+ const names = tenants.map((tenant) => tenant.name).join(", ");
13325
+ return {
13326
+ hint: `The Robot session targets tenant '${tenantName}', but ` + `organization '${organization}' lists no tenant of that name` + `${names ? ` (available: ${names})` : ""}. Commands that need ` + `the tenant id will fail until it can be resolved.`
13327
+ };
13328
+ }
13329
+ return { tenantId: match.id };
13330
+ }
13331
+ function tenantLookupFailureHint(tenantName, reason) {
13332
+ return `Could not resolve the id of tenant '${tenantName}' from the ` + `Robot session: ${reason} Commands that need the tenant id will ` + `fail until it can be resolved.`;
13333
+ }
13334
+ function decodePathSegment(segment) {
13335
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
13336
+ return error ? segment : decoded;
13337
+ }
13202
13338
  async function circuitBreakerShortCircuit(ctx) {
13203
13339
  const {
13204
13340
  absolutePath,
@@ -13429,7 +13565,7 @@ function normalizeTokenRefreshUnavailableFailure() {
13429
13565
  function errorMessage(error) {
13430
13566
  return error instanceof Error ? error.message : String(error);
13431
13567
  }
13432
- var getLoginStatusAsync = async (options = {}) => {
13568
+ var defaultRobotTenantIdCache, ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000, getLoginStatusAsync = async (options = {}) => {
13433
13569
  return getLoginStatusWithDeps(options);
13434
13570
  }, getLoginStatusWithDeps = async (options = {}, deps = {}) => {
13435
13571
  const {
@@ -13440,12 +13576,20 @@ var getLoginStatusAsync = async (options = {}) => {
13440
13576
  refreshToken: refreshTokenFn = refreshAccessToken,
13441
13577
  resolveConfig = resolveConfigAsync,
13442
13578
  robotFallback = tryRobotClientFallback,
13579
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
13580
+ robotTenantIdCache = defaultRobotTenantIdCache,
13581
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
13443
13582
  loadBreaker = loadRefreshBreaker,
13444
13583
  saveBreaker = saveRefreshBreaker,
13445
13584
  clearBreaker = clearRefreshBreaker
13446
13585
  } = deps;
13586
+ const robotDeps = {
13587
+ fetchTenantsAndOrgs,
13588
+ cache: robotTenantIdCache,
13589
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
13590
+ };
13447
13591
  if (isRobotAuthEnforced()) {
13448
- return resolveRobotEnforcedStatus(robotFallback);
13592
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
13449
13593
  }
13450
13594
  if (isEnvAuthEnabled()) {
13451
13595
  return readAuthFromEnv();
@@ -13463,7 +13607,7 @@ var getLoginStatusAsync = async (options = {}) => {
13463
13607
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
13464
13608
  };
13465
13609
  }
13466
- return resolveBorrowedRobotStatus(robotFallback);
13610
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
13467
13611
  }
13468
13612
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
13469
13613
  if ("status" in loaded) {
@@ -13517,9 +13661,11 @@ var init_loginStatus = __esm(() => {
13517
13661
  init_refreshCircuitBreaker();
13518
13662
  init_robotClientFallback();
13519
13663
  init_sessionIdentity();
13664
+ init_tenantSelection();
13520
13665
  init_tokenRefresh();
13521
13666
  init_envFile();
13522
13667
  init_jwt();
13668
+ defaultRobotTenantIdCache = new Map;
13523
13669
  });
13524
13670
 
13525
13671
  // ../auth/src/authContext.ts
@@ -13581,12 +13727,6 @@ var init_federatedCredentials = __esm(() => {
13581
13727
  init_tokenGrant();
13582
13728
  });
13583
13729
 
13584
- // ../auth/src/tenantSelection.ts
13585
- var IDENTIFIER_STATUSES;
13586
- var init_tenantSelection = __esm(() => {
13587
- IDENTIFIER_STATUSES = new Set([400, 403, 404]);
13588
- });
13589
-
13590
13730
  // ../auth/src/selectTenant.ts
13591
13731
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED", INVALID_TENANT_CODE = "INVALID_TENANT", TENANT_SELECTION_CODES;
13592
13732
  var init_selectTenant = __esm(() => {
@@ -13971,7 +14111,10 @@ function injectSolutionProjectProcessEntries(fpsProperties, solutionProjects) {
13971
14111
  const entries = solutionProjects.map((project) => ({
13972
14112
  name: project.name,
13973
14113
  projectType: project.projectType,
13974
- executorInfo: JSON.stringify(project.projectType === "Function" ? {
14114
+ executorInfo: JSON.stringify(project.projectType === "BusinessRules" ? {
14115
+ projectId: project.projectId,
14116
+ solutionId: project.solutionId
14117
+ } : project.projectType === "Function" ? {
13975
14118
  projectId: project.projectId,
13976
14119
  command: "debug",
13977
14120
  args: ["--attach=none"],
@@ -14313,32 +14456,64 @@ class DebugVariablesFetchFailedError extends Error {
14313
14456
  this.name = "DebugVariablesFetchFailedError";
14314
14457
  }
14315
14458
  }
14459
+ function undefinedGlobals(response, expected) {
14460
+ const defined = response?.globalDefinitions;
14461
+ if (defined === undefined || defined === null) {
14462
+ return [];
14463
+ }
14464
+ return expected.filter((id) => !Object.hasOwn(defined, id));
14465
+ }
14316
14466
  async function fetchDebugInstanceVariables(config, instanceId, options) {
14317
14467
  const endpoint = `/api/v1/debug-instances/${encodeURIComponent(instanceId)}/variables`;
14318
14468
  const delays = options?.delays ?? FETCH_VARIABLES_RETRY_DELAYS_MS;
14319
14469
  const attemptTimeoutMs = options?.attemptTimeoutMs ?? FETCH_VARIABLES_ATTEMPT_TIMEOUT_MS;
14320
14470
  const totalAttempts = delays.length + 1;
14321
14471
  const traceIds = [];
14472
+ const startedAt = Date.now();
14473
+ const terminalStatusAt = options?.terminalStatusAt;
14474
+ const timing = () => {
14475
+ const now = Date.now();
14476
+ return {
14477
+ elapsedMs: now - startedAt,
14478
+ ...terminalStatusAt === undefined ? {} : { sinceTerminalMs: now - terminalStatusAt }
14479
+ };
14480
+ };
14481
+ const failures = [];
14322
14482
  let lastMessage = "";
14323
14483
  let lastStatus;
14484
+ let lastMissing = [];
14324
14485
  for (let attempt = 1;attempt <= totalAttempts; attempt++) {
14325
14486
  const controller = new AbortController;
14326
14487
  const timer = setTimeout(() => controller.abort(), attemptTimeoutMs);
14327
14488
  const [error, result] = await catchError(debugPimsGet(config, endpoint, "fetch-output-variables", { signal: controller.signal }));
14328
14489
  clearTimeout(timer);
14329
- if (!error) {
14490
+ const missing = error ? [] : undefinedGlobals(result, options?.expectGlobals ?? []);
14491
+ if (!error && missing.length === 0) {
14492
+ options?.onFetched?.({
14493
+ attempts: attempt,
14494
+ failures: [...failures],
14495
+ ...timing()
14496
+ });
14330
14497
  return result;
14331
14498
  }
14332
- if (controller.signal.aborted) {
14499
+ if (!error) {
14500
+ lastMissing = missing;
14501
+ failures.push("unmaterialized");
14502
+ lastMessage = `the response does not define the declared output variable(s) ${missing.join(", ")} yet (record not materialized)`;
14503
+ lastStatus = undefined;
14504
+ } else if (controller.signal.aborted) {
14505
+ failures.push("timeout");
14333
14506
  lastMessage = `timed out after ${attemptTimeoutMs / 1000}s`;
14334
14507
  lastStatus = undefined;
14335
14508
  } else if (error instanceof MaestroHttpError) {
14509
+ failures.push("http");
14336
14510
  lastMessage = error.message;
14337
14511
  lastStatus = error.httpStatus;
14338
14512
  if (error.parsedTraceId) {
14339
14513
  traceIds.push(error.parsedTraceId);
14340
14514
  }
14341
14515
  } else {
14516
+ failures.push("network");
14342
14517
  lastMessage = error.message;
14343
14518
  lastStatus = undefined;
14344
14519
  }
@@ -14354,7 +14529,13 @@ async function fetchDebugInstanceVariables(config, instanceId, options) {
14354
14529
  ...lastStatus === undefined ? {} : { httpStatus: lastStatus },
14355
14530
  attempts: totalAttempts,
14356
14531
  traceIds,
14357
- endpoint
14532
+ endpoint,
14533
+ ...lastMissing.length === 0 ? {} : {
14534
+ missingGlobals: lastMissing,
14535
+ expectedGlobals: [...options?.expectGlobals ?? []]
14536
+ },
14537
+ failures,
14538
+ ...timing()
14358
14539
  });
14359
14540
  }
14360
14541
  function isFaultedDebugStatus(status) {
@@ -14464,12 +14645,14 @@ async function uploadAndDebugSolution(params) {
14464
14645
  logger.info(`Debug instance created — instanceId: ${debugInstance.instanceId}`);
14465
14646
  logger.info("Polling for completion...");
14466
14647
  const finalResponse = await pollDebugInstanceStatus(apiConfig, debugInstance.instanceId, params.callbacks, params.pollInterval, params.maxPolls, session.jobKey);
14648
+ const terminalStatusAt = Date.now();
14467
14649
  const incidents = await resolveFaultIncidents(apiConfig, debugInstance.instanceId, finalResponse.status);
14468
14650
  return {
14469
14651
  jobKey: session.jobKey,
14470
14652
  instanceId: debugInstance.instanceId,
14471
14653
  runId: debugInstance.runId,
14472
14654
  finalStatus: finalResponse.status,
14655
+ terminalStatusAt,
14473
14656
  elementExecutions: finalResponse.elementExecutions.map((e) => ({
14474
14657
  elementId: e.elementId,
14475
14658
  elementType: e.elementType,
@@ -14997,6 +15180,505 @@ async function withDebugPimsCall(fn, errorMessage2) {
14997
15180
  return result;
14998
15181
  }
14999
15182
 
15183
+ // src/shared-commands/examples.ts
15184
+ var INSTANCE = "f4a1c2b3-0000-4000-8000-000000000001";
15185
+ var FOLDER = "b2c3d4e5-0000-4000-8000-000000000002";
15186
+ var PROCESS = "c3d4e5f6-0000-4000-8000-000000000003";
15187
+ var INCIDENT = "d4e5f6a7-0000-4000-8000-000000000004";
15188
+ var ELEMENT = "Task_Review";
15189
+ var SOLUTION = "e5f6a7b8-0000-4000-8000-000000000009";
15190
+ var PROJECT = "f6a7b8c9-0000-4000-8000-00000000000a";
15191
+ var operation = (verb, code, description, status) => (prefix) => ({
15192
+ Description: description,
15193
+ Command: `${prefix} instance ${verb} ${INSTANCE} --folder-key ${FOLDER}`,
15194
+ Output: { Code: code, Data: { InstanceId: INSTANCE, Status: status } }
15195
+ });
15196
+ var EXAMPLES = {
15197
+ "instance list": (prefix) => ({
15198
+ Description: "List the faulted instances in a folder",
15199
+ Command: `${prefix} instance list --folder-key ${FOLDER} --status Faulted --limit 2`,
15200
+ Output: {
15201
+ Code: "InstanceList",
15202
+ Data: [
15203
+ {
15204
+ InstanceId: INSTANCE,
15205
+ InstanceDisplayName: "Claim 1042",
15206
+ ProcessKey: PROCESS,
15207
+ PackageVersion: "1.0.3",
15208
+ LatestRunStatus: "Faulted",
15209
+ StartedTime: "2026-10-13T09:12:00Z"
15210
+ }
15211
+ ]
15212
+ }
15213
+ }),
15214
+ "instance get": (prefix) => ({
15215
+ Description: "Get one instance and its latest run",
15216
+ Command: `${prefix} instance get ${INSTANCE} --folder-key ${FOLDER}`,
15217
+ Output: {
15218
+ Code: "InstanceGet",
15219
+ Data: {
15220
+ InstanceId: INSTANCE,
15221
+ InstanceDisplayName: "Claim 1042",
15222
+ ProcessKey: PROCESS,
15223
+ PackageVersion: "1.0.3",
15224
+ LatestRunStatus: "Running",
15225
+ StartedTime: "2026-10-13T09:12:00Z",
15226
+ CompletedTime: null
15227
+ }
15228
+ }
15229
+ }),
15230
+ "instance pause": operation("pause", "InstancePaused", "Pause a running instance", "Paused"),
15231
+ "instance resume": operation("resume", "InstanceResumed", "Resume a paused instance", "Running"),
15232
+ "instance cancel": operation("cancel", "InstanceCanceled", "Cancel an instance", "Canceling"),
15233
+ "instance retry": operation("retry", "InstanceRetried", "Retry a faulted instance from where it failed", "Running"),
15234
+ "instance variables": (prefix) => ({
15235
+ Description: "Read an instance's variables",
15236
+ Command: `${prefix} instance variables ${INSTANCE} --folder-key ${FOLDER}`,
15237
+ Output: {
15238
+ Code: "InstanceVariables",
15239
+ Data: {
15240
+ InstanceId: INSTANCE,
15241
+ ParentElementId: null,
15242
+ GlobalVariables: [
15243
+ {
15244
+ Id: "claimAmount",
15245
+ Name: "claimAmount",
15246
+ Type: "number",
15247
+ Value: 1200,
15248
+ ElementId: "root",
15249
+ Source: "=vars.claimAmount"
15250
+ }
15251
+ ],
15252
+ Elements: []
15253
+ }
15254
+ }
15255
+ }),
15256
+ "instance variables-all": (prefix) => ({
15257
+ Description: "Read the variables of every scope in an instance",
15258
+ Command: `${prefix} instance variables-all ${INSTANCE} --folder-key ${FOLDER}`,
15259
+ Output: {
15260
+ Code: "InstanceVariablesAll",
15261
+ Data: {
15262
+ Variables: [
15263
+ {
15264
+ InstanceId: INSTANCE,
15265
+ ParentElementId: null,
15266
+ GlobalVariables: [],
15267
+ Elements: []
15268
+ }
15269
+ ]
15270
+ }
15271
+ }
15272
+ }),
15273
+ "instance global-variables": (prefix) => ({
15274
+ Description: "Read an instance's global variables",
15275
+ Command: `${prefix} instance global-variables ${INSTANCE} --folder-key ${FOLDER}`,
15276
+ Output: {
15277
+ Code: "InstanceGlobalVariables",
15278
+ Data: {
15279
+ InstanceId: INSTANCE,
15280
+ Globals: { claimAmount: 1200 },
15281
+ Count: 1,
15282
+ RetrievedAt: "2026-10-13T09:20:00Z"
15283
+ }
15284
+ }
15285
+ }),
15286
+ "instance variables-set": (prefix) => ({
15287
+ Description: "Patch variables on a running instance from a file",
15288
+ Command: `${prefix} instance variables-set ${INSTANCE} --folder-key ${FOLDER} --inputs @patch.json`,
15289
+ Output: {
15290
+ Code: "InstanceVariablesSet",
15291
+ Data: {}
15292
+ }
15293
+ }),
15294
+ "instance incidents": (prefix) => ({
15295
+ Description: "List the incidents an instance raised",
15296
+ Command: `${prefix} instance incidents ${INSTANCE} --folder-key ${FOLDER}`,
15297
+ Output: {
15298
+ Code: "InstanceIncidents",
15299
+ Data: [
15300
+ {
15301
+ IncidentId: INCIDENT,
15302
+ InstanceId: INSTANCE,
15303
+ ElementId: ELEMENT,
15304
+ IncidentStatus: "Open",
15305
+ ErrorCode: "TaskFailed",
15306
+ ErrorMessage: "The action app returned an error"
15307
+ }
15308
+ ]
15309
+ }
15310
+ }),
15311
+ "instance asset": (prefix) => ({
15312
+ Description: "Get the asset an instance runs",
15313
+ Command: `${prefix} instance asset ${INSTANCE} --folder-key ${FOLDER}`,
15314
+ Output: { Code: "InstanceAsset", Data: {} }
15315
+ }),
15316
+ "instance migrate": (prefix) => ({
15317
+ Description: "Move an instance to a newer package version",
15318
+ Command: `${prefix} instance migrate ${INSTANCE} 1.0.4 --folder-key ${FOLDER} --comment "Fix review step"`,
15319
+ Output: {
15320
+ Code: "InstanceMigrated",
15321
+ Data: { InstanceId: INSTANCE, Status: "Running" }
15322
+ }
15323
+ }),
15324
+ "instance goto": (prefix) => ({
15325
+ Description: "Move an instance's cursor from one element to another",
15326
+ Command: `${prefix} instance goto ${INSTANCE} '[{"sourceElementId":"${ELEMENT}","targetElementId":"Task_Approve"}]' --folder-key ${FOLDER}`,
15327
+ Output: {
15328
+ Code: "InstanceGoto",
15329
+ Data: { InstanceId: INSTANCE, Status: "Running" }
15330
+ }
15331
+ }),
15332
+ "instance cursors": (prefix) => ({
15333
+ Description: "List the elements an instance is currently at",
15334
+ Command: `${prefix} instance cursors ${INSTANCE} --folder-key ${FOLDER}`,
15335
+ Output: {
15336
+ Code: "InstanceCursors",
15337
+ Data: { ElementIds: [ELEMENT] }
15338
+ }
15339
+ }),
15340
+ "instance message send": (prefix) => ({
15341
+ Description: "Send a message to the instances waiting for it",
15342
+ Command: `${prefix} instance message send --folder-key ${FOLDER} --inputs @message.json`,
15343
+ Output: {
15344
+ Code: "MessageSent",
15345
+ Data: {
15346
+ Id: "e5f6a7b8-0000-4000-8000-000000000005",
15347
+ JobId: "f6a7b8c9-0000-4000-8000-000000000006"
15348
+ }
15349
+ }
15350
+ }),
15351
+ "instance element-executions": (prefix) => ({
15352
+ Description: "List how each element of an instance ran",
15353
+ Command: `${prefix} instance element-executions ${INSTANCE} --folder-key ${FOLDER}`,
15354
+ Output: {
15355
+ Code: "InstanceElementExecutions",
15356
+ Data: {
15357
+ InstanceId: INSTANCE,
15358
+ ProcessKey: PROCESS,
15359
+ Status: "Running",
15360
+ ElementExecutions: [
15361
+ {
15362
+ ElementId: ELEMENT,
15363
+ ElementType: "UserTask",
15364
+ Status: "Completed",
15365
+ StartedTimeUtc: "2026-10-13T09:12:05Z"
15366
+ }
15367
+ ]
15368
+ }
15369
+ }
15370
+ }),
15371
+ "instance element cancel": (prefix) => ({
15372
+ Description: "Cancel one running element of an instance",
15373
+ Command: `${prefix} instance element cancel ${INSTANCE} ${ELEMENT} --folder-key ${FOLDER}`,
15374
+ Output: {
15375
+ Code: "ElementCanceled",
15376
+ Data: { InstanceId: INSTANCE, Status: "Running" }
15377
+ }
15378
+ }),
15379
+ "instance element retry": (prefix) => ({
15380
+ Description: "Retry one faulted element of an instance",
15381
+ Command: `${prefix} instance element retry ${INSTANCE} ${ELEMENT} --folder-key ${FOLDER}`,
15382
+ Output: {
15383
+ Code: "ElementRetried",
15384
+ Data: { InstanceId: INSTANCE, Status: "Running" }
15385
+ }
15386
+ }),
15387
+ "incident summary": (prefix) => ({
15388
+ Description: "Summarize the open incidents in a folder by error",
15389
+ Command: `${prefix} incident summary --folder-key ${FOLDER} --limit 2`,
15390
+ Output: {
15391
+ Code: "IncidentSummary",
15392
+ Data: [
15393
+ {
15394
+ ProcessKey: PROCESS,
15395
+ ErrorCode: "TaskFailed",
15396
+ ErrorMessage: "The action app returned an error",
15397
+ Count: 3,
15398
+ FirstTimeUtc: "2026-10-12T15:02:00Z"
15399
+ }
15400
+ ]
15401
+ }
15402
+ }),
15403
+ "incident get": (prefix) => ({
15404
+ Description: "Get one incident with its error details",
15405
+ Command: `${prefix} incident get ${INCIDENT} --folder-key ${FOLDER}`,
15406
+ Output: {
15407
+ Code: "IncidentGet",
15408
+ Data: {
15409
+ IncidentId: INCIDENT,
15410
+ InstanceId: INSTANCE,
15411
+ ProcessKey: PROCESS,
15412
+ IncidentStatus: "Open",
15413
+ ElementId: ELEMENT,
15414
+ ErrorCode: "TaskFailed",
15415
+ ErrorMessage: "The action app returned an error",
15416
+ ErrorTime: "2026-10-12T15:02:00Z"
15417
+ }
15418
+ }
15419
+ }),
15420
+ "process settings get": (prefix) => ({
15421
+ Description: "Read a process's settings",
15422
+ Command: `${prefix} process settings get ${PROCESS} --folder-key ${FOLDER}`,
15423
+ Output: {
15424
+ Code: "ProcessSettingsGet",
15425
+ Data: {
15426
+ VariableTags: {
15427
+ Elements: {},
15428
+ SourcePackageVersion: "1.0.3",
15429
+ LastUpdateTimeUtc: "2026-10-12T15:00:00Z"
15430
+ }
15431
+ }
15432
+ }
15433
+ }),
15434
+ "process settings set": (prefix) => ({
15435
+ Description: "Replace a process's settings from a file",
15436
+ Command: `${prefix} process settings set ${PROCESS} --folder-key ${FOLDER} --inputs @settings.json`,
15437
+ Output: {
15438
+ Code: "ProcessSettingsSet",
15439
+ Data: {}
15440
+ }
15441
+ }),
15442
+ "process variable-tags get": (prefix) => ({
15443
+ Description: "Read which variables are tagged for instance search",
15444
+ Command: `${prefix} process variable-tags get ${PROCESS} --folder-key ${FOLDER}`,
15445
+ Output: {
15446
+ Code: "ProcessVariableTagsGet",
15447
+ Data: {
15448
+ Elements: {},
15449
+ SourcePackageVersion: "1.0.3",
15450
+ LastUpdateTimeUtc: "2026-10-12T15:00:00Z"
15451
+ }
15452
+ }
15453
+ }),
15454
+ "process variable-tags set": (prefix) => ({
15455
+ Description: "Make a variable searchable when filtering instances",
15456
+ Command: `${prefix} process variable-tags set ${PROCESS} --folder-key ${FOLDER} --variable claimAmount --searchable true`,
15457
+ Output: {
15458
+ Code: "ProcessVariableTagsSet",
15459
+ Data: {
15460
+ Updated: [
15461
+ {
15462
+ ElementId: ELEMENT,
15463
+ Name: "claimAmount",
15464
+ Tags: ["Searchable"]
15465
+ }
15466
+ ],
15467
+ VariableTags: {
15468
+ Elements: {
15469
+ [ELEMENT]: {
15470
+ Outputs: [
15471
+ {
15472
+ Name: "claimAmount",
15473
+ Tags: ["Searchable"],
15474
+ ExtractPath: "claimAmount",
15475
+ Label: "Claim amount",
15476
+ ExtractedValueType: "number"
15477
+ }
15478
+ ]
15479
+ }
15480
+ },
15481
+ SourcePackageVersion: "1.0.3",
15482
+ LastUpdateTimeUtc: "2026-10-12T15:00:00Z"
15483
+ }
15484
+ }
15485
+ }
15486
+ }),
15487
+ "processes list": (prefix) => ({
15488
+ Description: "List processes with their running and faulted counts",
15489
+ Command: `${prefix} processes list --folder-key ${FOLDER} --limit 2`,
15490
+ Output: {
15491
+ Code: "ProcessList",
15492
+ Data: {
15493
+ Processes: [
15494
+ { ProcessKey: PROCESS, RunningCount: 4, FaultedCount: 1 }
15495
+ ]
15496
+ }
15497
+ }
15498
+ }),
15499
+ "processes incidents": (prefix) => ({
15500
+ Description: "List a process's incidents",
15501
+ Command: `${prefix} processes incidents ${PROCESS} --folder-key ${FOLDER}`,
15502
+ Output: {
15503
+ Code: "ProcessIncidents",
15504
+ Data: [
15505
+ {
15506
+ IncidentId: INCIDENT,
15507
+ InstanceId: INSTANCE,
15508
+ ProcessKey: PROCESS,
15509
+ ElementId: ELEMENT,
15510
+ IncidentStatus: "Open",
15511
+ ErrorCode: "TaskFailed",
15512
+ ErrorMessage: "The action app returned an error"
15513
+ }
15514
+ ]
15515
+ }
15516
+ }),
15517
+ "processes diagnose": (prefix) => ({
15518
+ Description: "Diagnose why a process's instances fault",
15519
+ Command: `${prefix} processes diagnose ${PROCESS} --folder-key ${FOLDER}`,
15520
+ Output: {
15521
+ Code: "ProcessDiagnostics",
15522
+ Data: {
15523
+ ProcessKey: PROCESS,
15524
+ FolderKey: FOLDER,
15525
+ Summary: {
15526
+ ProcessKey: PROCESS,
15527
+ RunningCount: 4,
15528
+ FaultedCount: 1
15529
+ },
15530
+ FaultedCount: 1,
15531
+ RunningCount: 4,
15532
+ Incidents: [
15533
+ {
15534
+ IncidentId: INCIDENT,
15535
+ InstanceId: INSTANCE,
15536
+ ElementId: ELEMENT,
15537
+ ErrorCode: "TaskFailed"
15538
+ }
15539
+ ],
15540
+ IncidentCount: 1,
15541
+ ErrorCodes: [
15542
+ {
15543
+ ErrorCode: "TaskFailed",
15544
+ ErrorMessage: "The action app returned an error"
15545
+ }
15546
+ ],
15547
+ ErrorCodeCount: 1
15548
+ }
15549
+ }
15550
+ }),
15551
+ "processes error-codes": (prefix) => ({
15552
+ Description: "List the error codes a process's incidents carry",
15553
+ Command: `${prefix} processes error-codes ${PROCESS} --folder-key ${FOLDER}`,
15554
+ Output: {
15555
+ Code: "ProcessIncidentErrorCodes",
15556
+ Data: [
15557
+ {
15558
+ ErrorCode: "TaskFailed",
15559
+ ErrorMessage: "The action app returned an error"
15560
+ }
15561
+ ]
15562
+ }
15563
+ }),
15564
+ "debug-instance create": (prefix) => ({
15565
+ Description: "Start a debug run of an uploaded solution's entry point",
15566
+ Command: `${prefix} debug-instance create --solution-id ${SOLUTION} --project-id ${PROJECT} --entry-point "/Main.bpmn#start" --debug-mode StepByStep`,
15567
+ Output: {
15568
+ Code: "DebugInstanceCreated",
15569
+ Data: {
15570
+ InstanceId: INSTANCE,
15571
+ RunId: "a7b8c9d0-0000-4000-8000-000000000007",
15572
+ JobKey: "b8c9d0e1-0000-4000-8000-000000000008"
15573
+ }
15574
+ }
15575
+ }),
15576
+ "debug-instance status": (prefix) => ({
15577
+ Description: "Check where a debug run is",
15578
+ Command: `${prefix} debug-instance status ${INSTANCE}`,
15579
+ Output: {
15580
+ Code: "DebugInstanceStatus",
15581
+ Data: {
15582
+ InstanceId: INSTANCE,
15583
+ Status: "Paused",
15584
+ StartedTimeUtc: "2026-10-13T09:12:00Z",
15585
+ CompletedTimeUtc: null
15586
+ }
15587
+ }
15588
+ }),
15589
+ "debug-instance breakpoints": (prefix) => ({
15590
+ Description: "Replace a debug run's breakpoints from a file",
15591
+ Command: `${prefix} debug-instance breakpoints ${INSTANCE} --inputs @breakpoints.json`,
15592
+ Output: {
15593
+ Code: "DebugInstanceBreakpointsUpdated",
15594
+ Data: {}
15595
+ }
15596
+ }),
15597
+ "debug-instance cancel": (prefix) => ({
15598
+ Description: "Stop a debug run",
15599
+ Command: `${prefix} debug-instance cancel ${INSTANCE}`,
15600
+ Output: {
15601
+ Code: "DebugInstanceCanceled",
15602
+ Data: {}
15603
+ }
15604
+ }),
15605
+ "debug-instance continue": (prefix) => ({
15606
+ Description: "Continue a paused debug run",
15607
+ Command: `${prefix} debug-instance continue ${INSTANCE}`,
15608
+ Output: {
15609
+ Code: "DebugInstanceContinued",
15610
+ Data: {}
15611
+ }
15612
+ }),
15613
+ "debug-instance incidents": (prefix) => ({
15614
+ Description: "List the incidents a debug run raised",
15615
+ Command: `${prefix} debug-instance incidents ${INSTANCE}`,
15616
+ Output: {
15617
+ Code: "DebugInstanceIncidents",
15618
+ Data: [
15619
+ {
15620
+ IncidentId: INCIDENT,
15621
+ ElementId: ELEMENT,
15622
+ ErrorCode: "TaskFailed"
15623
+ }
15624
+ ]
15625
+ }
15626
+ }),
15627
+ "debug-instance variables": (prefix) => ({
15628
+ Description: "Read a paused debug run's variables",
15629
+ Command: `${prefix} debug-instance variables ${INSTANCE}`,
15630
+ Output: {
15631
+ Code: "DebugInstanceVariables",
15632
+ Data: { InstanceId: INSTANCE, Globals: {}, Elements: [] }
15633
+ }
15634
+ }),
15635
+ "debug-instance variables-set": (prefix) => ({
15636
+ Description: "Patch a paused debug run's variables from a file",
15637
+ Command: `${prefix} debug-instance variables-set ${INSTANCE} --inputs @patch.json`,
15638
+ Output: {
15639
+ Code: "DebugInstanceVariablesSet",
15640
+ Data: {}
15641
+ }
15642
+ }),
15643
+ "debug-instance variables-all": (prefix) => ({
15644
+ Description: "Read the variables of every scope in a debug run",
15645
+ Command: `${prefix} debug-instance variables-all ${INSTANCE}`,
15646
+ Output: {
15647
+ Code: "DebugInstanceVariablesAll",
15648
+ Data: { Variables: [] }
15649
+ }
15650
+ })
15651
+ };
15652
+ var pathOf = (command) => {
15653
+ const names = [];
15654
+ for (let at = command;at !== null; at = at.parent) {
15655
+ if (at.parent === null)
15656
+ break;
15657
+ names.unshift(at.name());
15658
+ }
15659
+ return ["uip", ...names];
15660
+ };
15661
+ var attachSharedExamples = (group) => {
15662
+ const visit = (command) => {
15663
+ if (command.commands.length > 0) {
15664
+ for (const child of command.commands)
15665
+ visit(child);
15666
+ return;
15667
+ }
15668
+ const path3 = pathOf(command);
15669
+ for (let words = 3;words >= 2; words -= 1) {
15670
+ const key = path3.slice(-words).join(" ");
15671
+ const example = EXAMPLES[key];
15672
+ if (example === undefined)
15673
+ continue;
15674
+ const prefix = path3.slice(0, path3.length - words).join(" ");
15675
+ command.examples([example(prefix)]);
15676
+ return;
15677
+ }
15678
+ };
15679
+ visit(group);
15680
+ };
15681
+
15000
15682
  // src/shared-commands/debug-instances.ts
15001
15683
  var DEBUG_API_PREFIX = "/api/v1/debug-instances";
15002
15684
  var VALID_DEBUG_MODES = Object.keys(DEBUG_MODE_MAP);
@@ -15158,11 +15840,23 @@ var registerSharedDebugInstanceCommands = (program2, config) => {
15158
15840
  Data: result ?? []
15159
15841
  });
15160
15842
  });
15161
- debugInstance.command("variables").description(`Get variables for a ${toolLabel} debug instance`).argument("<instance-id>", "Debug instance ID").option("--parent-element-id <id>", "Filter variables by parent element ID").trackedAction(processContext, async (instanceId, options) => {
15843
+ debugInstance.command("variables").description(`Get variables for a ${toolLabel} debug instance`).argument("<instance-id>", "Debug instance ID").option("--parent-element-id <id>", "Filter variables by parent element ID").option("--expected-outputs <ids...>", "Output variable ids the record must define; retried until it does, failed if it never does").trackedAction(processContext, async (instanceId, options) => {
15844
+ const expectGlobals = options.expectedOutputs ?? [];
15845
+ if (expectGlobals.length > 0 && options.parentElementId !== undefined) {
15846
+ OutputFormatter.error({
15847
+ Result: RESULTS.Failure,
15848
+ Message: "--expected-outputs cannot be combined with --parent-element-id",
15849
+ Instructions: "Drop --parent-element-id: --expected-outputs checks the instance's root variables record."
15850
+ });
15851
+ processContext.exit(1);
15852
+ return;
15853
+ }
15162
15854
  const query = buildQueryString({
15163
15855
  parentElementId: options.parentElementId
15164
15856
  });
15165
- const result = await withDebugPimsCall((cfg) => debugPimsGet(cfg, `${DEBUG_API_PREFIX}/${instanceId}/variables${query}`), "Error getting debug instance variables");
15857
+ const result = await withDebugPimsCall((cfg) => expectGlobals.length > 0 ? fetchDebugInstanceVariables(cfg, instanceId, {
15858
+ expectGlobals
15859
+ }) : debugPimsGet(cfg, `${DEBUG_API_PREFIX}/${instanceId}/variables${query}`), "Error getting debug instance variables");
15166
15860
  if (!result)
15167
15861
  return;
15168
15862
  OutputFormatter.success({
@@ -15217,6 +15911,7 @@ var registerSharedDebugInstanceCommands = (program2, config) => {
15217
15911
  Data: result
15218
15912
  });
15219
15913
  });
15914
+ attachSharedExamples(debugInstance);
15220
15915
  };
15221
15916
  // src/shared-commands/incidents.ts
15222
15917
  init_src2();
@@ -15252,6 +15947,7 @@ var registerSharedIncidentCommands = (program2, config) => {
15252
15947
  Data: result
15253
15948
  });
15254
15949
  });
15950
+ attachSharedExamples(incident);
15255
15951
  };
15256
15952
  // src/shared-commands/instances.ts
15257
15953
  init_src2();
@@ -15666,6 +16362,7 @@ var registerSharedInstanceCommands = (program2, config) => {
15666
16362
  Data: result
15667
16363
  });
15668
16364
  });
16365
+ attachSharedExamples(instances);
15669
16366
  };
15670
16367
  // src/shared-commands/process.ts
15671
16368
  init_src2();
@@ -15909,14 +16606,19 @@ var registerSharedProcessCommands = (processCmd, config) => {
15909
16606
  }
15910
16607
  await setVariableTagsFromPayload(processKey, options);
15911
16608
  });
16609
+ attachSharedExamples(settingsCmd);
16610
+ attachSharedExamples(variableTagsCmd);
15912
16611
  };
15913
16612
  // src/shared-commands/processes.ts
15914
16613
  init_src2();
15915
- function findProcessSummary(summaries, processKey) {
16614
+ async function findProcessSummary(config, processKey, folderKey, processType) {
16615
+ const page = await pimsGet(config, `/processes/summary${buildQueryString({ processType, processKey })}`, { folderKey });
16616
+ const summaries = Array.isArray(page?.processes) ? page.processes : [];
15916
16617
  return summaries.find((summary) => summary.processKey === processKey) ?? null;
15917
16618
  }
15918
16619
  var registerSharedProcessesCommands = (program2, config) => {
15919
16620
  const { toolLabel, processType } = config;
16621
+ const incidentsQuery = buildQueryString({ processType });
15920
16622
  const processes = program2.command("processes").description(`Manage ${toolLabel} process summaries`);
15921
16623
  processes.command("list").description(`List all ${toolLabel} process summaries`).option("--folder-key <key>", "Folder key").option("-l, --limit <number>", "Number of items to return (1-10000)", parseLimit).option("--offset <number>", "Number of items to skip (0-1000000)", parseOffset, 0).option("--status <status>", "Filter by process status").trackedAction(processContext, async (options) => {
15922
16624
  const query = buildQueryString({
@@ -15937,7 +16639,7 @@ var registerSharedProcessesCommands = (program2, config) => {
15937
16639
  });
15938
16640
  processes.command("incidents").description(`Get incidents for a specific ${toolLabel} process`).argument("<process-key>", "Process definition key").requiredOption("--folder-key <key>", "Folder key").trackedAction(processContext, async (processKey, options) => {
15939
16641
  const reqOptions = { folderKey: options.folderKey };
15940
- const result = await withPimsCall((config2) => pimsGet(config2, `/incidents/process/${encodeURIComponent(processKey)}`, reqOptions), "Error getting process incidents", { resource: "process", id: processKey });
16642
+ const result = await withPimsCall((config2) => pimsGet(config2, `/incidents/process/${encodeURIComponent(processKey)}${incidentsQuery}`, reqOptions), "Error getting process incidents", { resource: "process", id: processKey });
15941
16643
  if (!result)
15942
16644
  return;
15943
16645
  OutputFormatter.success({
@@ -15948,12 +16650,11 @@ var registerSharedProcessesCommands = (program2, config) => {
15948
16650
  });
15949
16651
  processes.command("diagnose").description(`Correlate ${toolLabel} process summary, incidents, and error codes`).argument("<process-key>", "Process definition key").requiredOption("--folder-key <key>", "Folder key").trackedAction(processContext, async (processKey, options) => {
15950
16652
  const result = await withPimsCall(async (config2) => {
15951
- const query = processType ? buildQueryString({ processType }) : "";
15952
- const summaries = await pimsGet(config2, `/processes/summary${query}`);
15953
- const incidents = await pimsGet(config2, `/incidents/process/${encodeURIComponent(processKey)}`, { folderKey: options.folderKey });
16653
+ const summary = await findProcessSummary(config2, processKey, options.folderKey, processType);
16654
+ const incidents = await pimsGet(config2, `/incidents/process/${encodeURIComponent(processKey)}${incidentsQuery}`, { folderKey: options.folderKey });
15954
16655
  const errorCodes = await pimsGet(config2, `/incidents/process/${encodeURIComponent(processKey)}/error-codes`, { folderKey: options.folderKey });
15955
16656
  return {
15956
- summary: findProcessSummary(summaries, processKey),
16657
+ summary,
15957
16658
  incidents,
15958
16659
  errorCodes: errorCodes.errorCodes || []
15959
16660
  };
@@ -15987,6 +16688,7 @@ var registerSharedProcessesCommands = (program2, config) => {
15987
16688
  Data: result.errorCodes || []
15988
16689
  });
15989
16690
  });
16691
+ attachSharedExamples(processes);
15990
16692
  };
15991
16693
  export {
15992
16694
  registerSharedDebugInstanceCommands,
@@ -15996,4 +16698,4 @@ export {
15996
16698
  registerSharedProcessesCommands
15997
16699
  };
15998
16700
 
15999
- //# debugId=11D8829B1410D86164756E2164756E21
16701
+ //# debugId=FB56BC5ED202DB9964756E2164756E21