@uipath/common 1.201.0-preview.132 → 1.202.0-preview.134

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 (37) hide show
  1. package/dist/catch-error.d.ts +14 -0
  2. package/dist/catch-error.js +259 -10
  3. package/dist/classified-failure.d.ts +28 -0
  4. package/dist/entity-name-rules.d.ts +18 -0
  5. package/dist/entity-name-rules.js +241 -0
  6. package/dist/error-handler.d.ts +13 -0
  7. package/dist/exit-code.d.ts +42 -0
  8. package/dist/formatter.d.ts +34 -5
  9. package/dist/index.browser.d.ts +3 -0
  10. package/dist/index.browser.js +11328 -10486
  11. package/dist/index.d.ts +10 -1
  12. package/dist/index.js +9299 -8195
  13. package/dist/logger.d.ts +15 -0
  14. package/dist/package-metadata-options.js +3 -3
  15. package/dist/polling/poll-failure-mapping.d.ts +15 -1
  16. package/dist/sdk-user-agent.js +6 -6
  17. package/dist/telemetry/command-name.d.ts +60 -0
  18. package/dist/telemetry/console-telemetry-provider.d.ts +5 -6
  19. package/dist/telemetry/debug-telemetry-provider.d.ts +5 -6
  20. package/dist/telemetry/index.d.ts +3 -3
  21. package/dist/telemetry/index.js +18581 -105
  22. package/dist/telemetry/invocation-request.d.ts +38 -0
  23. package/dist/telemetry/logger-telemetry-provider.d.ts +5 -6
  24. package/dist/telemetry/node-appinsights-telemetry-provider.d.ts +17 -29
  25. package/dist/telemetry/node.d.ts +2 -2
  26. package/dist/telemetry/packaged-name.d.ts +22 -0
  27. package/dist/telemetry/pii-redactor.d.ts +110 -13
  28. package/dist/telemetry/pseudonymize.d.ts +57 -0
  29. package/dist/telemetry/span-clock.d.ts +27 -0
  30. package/dist/telemetry/supplied-values.d.ts +59 -0
  31. package/dist/telemetry/telemetry-init.d.ts +27 -0
  32. package/dist/telemetry/telemetry-provider.d.ts +84 -16
  33. package/dist/telemetry/telemetry-service.d.ts +71 -41
  34. package/dist/telemetry/telemetry-spool.d.ts +17 -0
  35. package/dist/timings.d.ts +99 -0
  36. package/dist/trackedAction.d.ts +25 -2
  37. package/package.json +6 -2
@@ -1,4 +1,18 @@
1
1
  type CatchErrorResult<T> = [undefined, T] | [Error, undefined];
2
+ /**
3
+ * Describe a thrown value that is not an `Error`.
4
+ *
5
+ * `String(value)` on an object yields `"[object Object]"`, which is what a
6
+ * user ends up reading when a command reports `Instructions: error.message`
7
+ * — the real content is gone. Libraries that reject with a plain object
8
+ * (some SDK clients, validation results) hit exactly that. So: use the
9
+ * value's own `message` when it has one, otherwise serialize it, and only
10
+ * fall back to `String` when neither works.
11
+ *
12
+ * Exported for the error-handler extractors, which face the same raw
13
+ * `unknown` values when a caller hands them one directly.
14
+ */
15
+ export declare function describeThrownValue(value: unknown): string;
2
16
  export declare function catchError<T>(fnOrPromise: Promise<T>): Promise<CatchErrorResult<T>>;
3
17
  export declare function catchError<T>(fnOrPromise: () => Promise<T>): Promise<CatchErrorResult<T>>;
4
18
  export declare function catchError<T>(fnOrPromise: () => T): CatchErrorResult<T>;
@@ -1,4 +1,258 @@
1
+ // src/telemetry/pseudonymize.ts
2
+ var SHA256_K = new Uint32Array([
3
+ 1116352408,
4
+ 1899447441,
5
+ 3049323471,
6
+ 3921009573,
7
+ 961987163,
8
+ 1508970993,
9
+ 2453635748,
10
+ 2870763221,
11
+ 3624381080,
12
+ 310598401,
13
+ 607225278,
14
+ 1426881987,
15
+ 1925078388,
16
+ 2162078206,
17
+ 2614888103,
18
+ 3248222580,
19
+ 3835390401,
20
+ 4022224774,
21
+ 264347078,
22
+ 604807628,
23
+ 770255983,
24
+ 1249150122,
25
+ 1555081692,
26
+ 1996064986,
27
+ 2554220882,
28
+ 2821834349,
29
+ 2952996808,
30
+ 3210313671,
31
+ 3336571891,
32
+ 3584528711,
33
+ 113926993,
34
+ 338241895,
35
+ 666307205,
36
+ 773529912,
37
+ 1294757372,
38
+ 1396182291,
39
+ 1695183700,
40
+ 1986661051,
41
+ 2177026350,
42
+ 2456956037,
43
+ 2730485921,
44
+ 2820302411,
45
+ 3259730800,
46
+ 3345764771,
47
+ 3516065817,
48
+ 3600352804,
49
+ 4094571909,
50
+ 275423344,
51
+ 430227734,
52
+ 506948616,
53
+ 659060556,
54
+ 883997877,
55
+ 958139571,
56
+ 1322822218,
57
+ 1537002063,
58
+ 1747873779,
59
+ 1955562222,
60
+ 2024104815,
61
+ 2227730452,
62
+ 2361852424,
63
+ 2428436474,
64
+ 2756734187,
65
+ 3204031479,
66
+ 3329325298
67
+ ]);
68
+ var SHA256_INITIAL_STATE = new Uint32Array([
69
+ 1779033703,
70
+ 3144134277,
71
+ 1013904242,
72
+ 2773480762,
73
+ 1359893119,
74
+ 2600822924,
75
+ 528734635,
76
+ 1541459225
77
+ ]);
78
+
79
+ // src/singleton.ts
80
+ var PREFIX = "@uipath/common/";
81
+ var _g = globalThis;
82
+ function singleton(ctorOrName) {
83
+ const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name;
84
+ const key = Symbol.for(PREFIX + name);
85
+ return {
86
+ get(fallback) {
87
+ return _g[key] ?? fallback;
88
+ },
89
+ set(value) {
90
+ _g[key] = value;
91
+ },
92
+ clear() {
93
+ delete _g[key];
94
+ },
95
+ getOrInit(factory, guard) {
96
+ const existing = _g[key];
97
+ if (existing != null && typeof existing === "object") {
98
+ if (!guard || guard(existing)) {
99
+ return existing;
100
+ }
101
+ }
102
+ const instance = factory();
103
+ _g[key] = instance;
104
+ return instance;
105
+ }
106
+ };
107
+ }
108
+
109
+ // src/telemetry/supplied-values.ts
110
+ var suppliedValuesSlot = singleton("TelemetrySuppliedArgumentValues");
111
+
112
+ // src/telemetry/pii-redactor.ts
113
+ var SENSITIVE_NAME_TOKENS = new Set([
114
+ "token",
115
+ "tokens",
116
+ "secret",
117
+ "secrets",
118
+ "password",
119
+ "passwords",
120
+ "pwd",
121
+ "credential",
122
+ "credentials",
123
+ "auth",
124
+ "authentication",
125
+ "authorization",
126
+ "authority",
127
+ "cert",
128
+ "certificate",
129
+ "certificates"
130
+ ]);
131
+ var SENSITIVE_KEY_PREFIXES = new Set([
132
+ "api",
133
+ "access",
134
+ "client",
135
+ "private",
136
+ "public",
137
+ "signing",
138
+ "encryption",
139
+ "session",
140
+ "master",
141
+ "shared",
142
+ "root",
143
+ "ssh",
144
+ "rsa",
145
+ "aes",
146
+ "hmac",
147
+ "oauth"
148
+ ]);
149
+ var SOURCE_FILE_EXTENSIONS = new Set([
150
+ "ts",
151
+ "tsx",
152
+ "js",
153
+ "jsx",
154
+ "mjs",
155
+ "cjs",
156
+ "cts",
157
+ "mts",
158
+ "py",
159
+ "cs",
160
+ "java",
161
+ "go",
162
+ "rs",
163
+ "rb",
164
+ "php",
165
+ "sh",
166
+ "ps1",
167
+ "json",
168
+ "jsonc",
169
+ "yaml",
170
+ "yml",
171
+ "xml",
172
+ "xaml",
173
+ "md",
174
+ "txt",
175
+ "log",
176
+ "css",
177
+ "html",
178
+ "htm",
179
+ "csproj",
180
+ "nuspec",
181
+ "sql"
182
+ ]);
183
+ var QUOTED_LITERAL_MAX_SPAN = 200;
184
+ var QUOTED_LITERAL_PATTERN = new RegExp([
185
+ `(?<![A-Za-z0-9])'(?:[^\\
186
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?'(?![A-Za-z0-9])`,
187
+ `(?<![A-Za-z0-9])"(?:[^\\
188
+ ]|\\.){2,${QUOTED_LITERAL_MAX_SPAN}}?"(?![A-Za-z0-9])`
189
+ ].join("|"), "g");
190
+ var MESSAGE_NAMES = new Set([
191
+ "message",
192
+ "errormessage",
193
+ "errmessage",
194
+ "error_message",
195
+ "msg",
196
+ "detail",
197
+ "details",
198
+ "reason",
199
+ "instructions",
200
+ "warning"
201
+ ]);
202
+ function nameTokens(name) {
203
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s._-]+/).map((t) => t.toLowerCase()).filter(Boolean);
204
+ }
205
+ function isSensitiveName(name) {
206
+ const tokens = nameTokens(name);
207
+ for (let i = 0;i < tokens.length; i++) {
208
+ const token = tokens[i];
209
+ if (SENSITIVE_NAME_TOKENS.has(token)) {
210
+ return true;
211
+ }
212
+ if (token === "key" || token === "keys") {
213
+ const prev = tokens[i - 1];
214
+ if (prev && SENSITIVE_KEY_PREFIXES.has(prev)) {
215
+ return true;
216
+ }
217
+ }
218
+ }
219
+ return false;
220
+ }
221
+
1
222
  // src/catch-error.ts
223
+ var MAX_SERIALIZED_LENGTH = 500;
224
+ var TRUNCATION_SUFFIX = "…(truncated)";
225
+ var REDACTED = "[REDACTED]";
226
+ function cap(text) {
227
+ return text.length > MAX_SERIALIZED_LENGTH ? `${text.slice(0, MAX_SERIALIZED_LENGTH)}${TRUNCATION_SUFFIX}` : text;
228
+ }
229
+ function omitSensitive(key, value) {
230
+ return key.length > 0 && isSensitiveName(key) ? REDACTED : value;
231
+ }
232
+ function describeThrownValue(value) {
233
+ if (typeof value !== "object" || value === null) {
234
+ return String(value);
235
+ }
236
+ let message;
237
+ try {
238
+ message = value.message;
239
+ } catch {
240
+ message = undefined;
241
+ }
242
+ if (typeof message === "string" && message.length > 0) {
243
+ return cap(message);
244
+ }
245
+ try {
246
+ const json = JSON.stringify(value, omitSensitive);
247
+ if (json !== undefined) {
248
+ return cap(json);
249
+ }
250
+ } catch {}
251
+ return String(value);
252
+ }
253
+ function toError(error) {
254
+ return error instanceof Error ? error : new Error(describeThrownValue(error), { cause: error });
255
+ }
2
256
  function isPromiseLike(value) {
3
257
  return value !== null && typeof value === "object" && typeof value.then === "function";
4
258
  }
@@ -13,20 +267,15 @@ function catchError(fnOrPromise) {
13
267
  }
14
268
  return [undefined, result];
15
269
  } catch (error) {
16
- return [
17
- error instanceof Error ? error : new Error(String(error)),
18
- undefined
19
- ];
270
+ return [toError(error), undefined];
20
271
  }
21
272
  }
22
273
  function settlePromiseLike(thenable) {
23
- return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [
24
- error instanceof Error ? error : new Error(String(error)),
25
- undefined
26
- ]);
274
+ return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
27
275
  }
28
276
  export {
29
- catchError
277
+ catchError,
278
+ describeThrownValue
30
279
  };
31
280
 
32
- //# debugId=246638ED7A60E04D64756E2164756E21
281
+ //# debugId=523FB0079E2C37BE64756E2164756E21
@@ -0,0 +1,28 @@
1
+ import { type FailureOutput } from "./formatter";
2
+ /**
3
+ * Build the standard failure envelope for `error`, classified.
4
+ *
5
+ * `Message` says what the command was doing; `Instructions` carries the detail
6
+ * from {@link extractErrorDetails}, along with the `ErrorCode`, `Retry` and
7
+ * `Context` that agents branch on. Building the envelope from
8
+ * `extractErrorMessage` instead drops those three, so a transient 5xx reports
9
+ * as `unknown_error` / `RetryWillNotFix` and callers are told never to retry.
10
+ *
11
+ * Returns the envelope rather than emitting it, so each command still passes it
12
+ * to the `OutputFormatter` it imported. That keeps `vi.mock("@uipath/common")`
13
+ * able to intercept the call — a helper here that emitted directly would close
14
+ * over the real formatter and command specs could no longer assert on it.
15
+ *
16
+ * Pair it with the caller's own exit, which stays visible at the call site:
17
+ *
18
+ * ```ts
19
+ * OutputFormatter.error(await classifiedFailure("Error listing folders", err));
20
+ * processContext.exit(1);
21
+ * ```
22
+ */
23
+ export declare function classifiedFailure(message: string, error: unknown): Promise<FailureOutput>;
24
+ /**
25
+ * Collapse whitespace and cap length so a platform's raw response body can be
26
+ * quoted inside `Instructions` without dumping an arbitrarily long payload.
27
+ */
28
+ export declare function summarizePlatformBody(body: string): string;
@@ -0,0 +1,18 @@
1
+ import type { ValidationError } from "./body-validators";
2
+ export type NameKind = "entity" | "field" | "choice set";
3
+ /**
4
+ * The reserved-name half of the rules, split out so a caller that already checks
5
+ * name FORMAT does not report the same name twice. `solution pack` does exactly
6
+ * that: the authored document has its own format pattern, but the reserved lists
7
+ * are the server's and apply to every author.
8
+ *
9
+ * Field names are only reserved for CUSTOM fields — `Id`, `CreateTime`,
10
+ * `CreatedBy`, `UpdateTime` and `UpdatedBy` are the system fields' own names, so
11
+ * callers must not run this over them.
12
+ */
13
+ export declare function findReservedNameError(name: string, kind: NameKind): ValidationError | null;
14
+ /**
15
+ * Check an entity / field / choice-set name against the server's format,
16
+ * reserved-name, and reserved-keyword rules.
17
+ */
18
+ export declare function validateName(name: string, kind: NameKind): ValidationError | null;
@@ -0,0 +1,241 @@
1
+ // src/entity-name-rules.ts
2
+ var RESERVED_SQL_KEYWORDS_LOWER = new Set(["group", "order"]);
3
+ var ENTITY_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]{2,99}$/;
4
+ var FIELD_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9]{2,99}$/;
5
+ var RESERVED_FIELD_NAMES_LOWER = new Set([
6
+ "id",
7
+ "createdby",
8
+ "createtime",
9
+ "updatedby",
10
+ "updatetime",
11
+ "recordowner",
12
+ "version"
13
+ ]);
14
+ var RESERVED_KEYWORDS_LOWER = new Set([
15
+ "abstract",
16
+ "as",
17
+ "base",
18
+ "bool",
19
+ "break",
20
+ "byte",
21
+ "case",
22
+ "catch",
23
+ "char",
24
+ "checked",
25
+ "class",
26
+ "const",
27
+ "continue",
28
+ "decimal",
29
+ "default",
30
+ "delegate",
31
+ "do",
32
+ "double",
33
+ "else",
34
+ "enum",
35
+ "event",
36
+ "explicit",
37
+ "extern",
38
+ "false",
39
+ "finally",
40
+ "fixed",
41
+ "float",
42
+ "for",
43
+ "foreach",
44
+ "goto",
45
+ "if",
46
+ "implicit",
47
+ "in",
48
+ "int",
49
+ "interface",
50
+ "internal",
51
+ "is",
52
+ "lock",
53
+ "long",
54
+ "namespace",
55
+ "new",
56
+ "null",
57
+ "object",
58
+ "operator",
59
+ "out",
60
+ "override",
61
+ "params",
62
+ "private",
63
+ "protected",
64
+ "public",
65
+ "readonly",
66
+ "ref",
67
+ "return",
68
+ "sbyte",
69
+ "sealed",
70
+ "short",
71
+ "sizeof",
72
+ "stackalloc",
73
+ "static",
74
+ "string",
75
+ "struct",
76
+ "switch",
77
+ "this",
78
+ "throw",
79
+ "true",
80
+ "try",
81
+ "typeof",
82
+ "uint",
83
+ "ulong",
84
+ "unchecked",
85
+ "unsafe",
86
+ "ushort",
87
+ "using",
88
+ "virtual",
89
+ "void",
90
+ "volatile",
91
+ "while",
92
+ "addhandler",
93
+ "addressof",
94
+ "alias",
95
+ "and",
96
+ "andalso",
97
+ "boolean",
98
+ "byref",
99
+ "byval",
100
+ "call",
101
+ "cbool",
102
+ "cbyte",
103
+ "cchar",
104
+ "cdate",
105
+ "cdbl",
106
+ "cdec",
107
+ "cint",
108
+ "clng",
109
+ "cobj",
110
+ "csbyte",
111
+ "cshort",
112
+ "csng",
113
+ "cstr",
114
+ "ctype",
115
+ "cuint",
116
+ "culng",
117
+ "cushort",
118
+ "date",
119
+ "declare",
120
+ "dim",
121
+ "directcast",
122
+ "each",
123
+ "elseif",
124
+ "end",
125
+ "endif",
126
+ "erase",
127
+ "error",
128
+ "exit",
129
+ "friend",
130
+ "function",
131
+ "get",
132
+ "gettype",
133
+ "getxmlnamespace",
134
+ "global",
135
+ "gosub",
136
+ "goto",
137
+ "handles",
138
+ "implements",
139
+ "imports",
140
+ "inherits",
141
+ "integer",
142
+ "isnot",
143
+ "let",
144
+ "lib",
145
+ "like",
146
+ "loop",
147
+ "me",
148
+ "mod",
149
+ "module",
150
+ "mustinherit",
151
+ "mustoverride",
152
+ "mybase",
153
+ "myclass",
154
+ "narrowing",
155
+ "next",
156
+ "not",
157
+ "nothing",
158
+ "notinheritable",
159
+ "notoverridable",
160
+ "of",
161
+ "on",
162
+ "option",
163
+ "optional",
164
+ "or",
165
+ "orelse",
166
+ "overloads",
167
+ "overridable",
168
+ "overrides",
169
+ "paramarray",
170
+ "partial",
171
+ "property",
172
+ "raiseevent",
173
+ "redim",
174
+ "rem",
175
+ "removehandler",
176
+ "resume",
177
+ "select",
178
+ "set",
179
+ "shadows",
180
+ "shared",
181
+ "single",
182
+ "step",
183
+ "stop",
184
+ "structure",
185
+ "sub",
186
+ "synclock",
187
+ "then",
188
+ "to",
189
+ "trycast",
190
+ "uinteger",
191
+ "ushort",
192
+ "variant",
193
+ "wend",
194
+ "when",
195
+ "widening",
196
+ "with",
197
+ "withevents",
198
+ "writeonly",
199
+ "xor"
200
+ ]);
201
+ function findReservedNameError(name, kind) {
202
+ if (kind === "field" && RESERVED_FIELD_NAMES_LOWER.has(name.toLowerCase())) {
203
+ return {
204
+ message: `Field name '${name}' is reserved`,
205
+ instructions: "The following field names are reserved by the platform (case-insensitive): Id, CreatedBy, CreateTime, UpdatedBy, UpdateTime, RecordOwner, Version. Pick a different name."
206
+ };
207
+ }
208
+ if (RESERVED_KEYWORDS_LOWER.has(name.toLowerCase())) {
209
+ return {
210
+ message: `${kind === "entity" ? "Entity" : kind === "field" ? "Field" : "Choice set"} name '${name}' is a reserved C# or VB keyword`,
211
+ instructions: "Reserved keywords are rejected with RESERVED_LANGUAGE_KEYWORDS. Pick a domain-specific rename, for example 'Case' -> 'WorkItem', 'Class' -> 'Category', 'New' -> 'IsNew'."
212
+ };
213
+ }
214
+ if (kind === "entity" && RESERVED_SQL_KEYWORDS_LOWER.has(name.toLowerCase())) {
215
+ return {
216
+ message: `Entity name '${name}' is a reserved SQL keyword`,
217
+ instructions: "The platform rejects 'Order' and 'Group' as entity names. Pick a domain-specific name such as 'PurchaseOrder' or 'TeamGroup'."
218
+ };
219
+ }
220
+ return null;
221
+ }
222
+ function validateName(name, kind) {
223
+ const reserved = findReservedNameError(name, kind);
224
+ if (reserved) {
225
+ return reserved;
226
+ }
227
+ const pattern = kind === "field" ? FIELD_NAME_PATTERN : ENTITY_NAME_PATTERN;
228
+ if (!pattern.test(name)) {
229
+ return {
230
+ message: `Invalid ${kind} name '${name}'`,
231
+ instructions: kind === "field" ? "Field names must start with a letter, contain only letters and digits (no underscores), and be 3-100 characters long." : "Names must start with a letter, contain only letters, digits, and underscores, and be 3-100 characters long."
232
+ };
233
+ }
234
+ return null;
235
+ }
236
+ export {
237
+ findReservedNameError,
238
+ validateName
239
+ };
240
+
241
+ //# debugId=DEFF72153B22EA2764756E2164756E21
@@ -62,6 +62,19 @@ export interface LocalPermissionError {
62
62
  /** Actionable, user-facing remediation steps. */
63
63
  instructions: string;
64
64
  }
65
+ /**
66
+ * Actionable instructions carried on an error object, when present. The
67
+ * repo-wide convention (`trackedAction` surfaces it the same way) is a string
68
+ * `instructions` field on the error — the CLI host's `InstallRefusedError`
69
+ * family, `FilterEvaluationError`, `LocalPermissionError`, and future shapes
70
+ * alike. Duck-typed on purpose, never `instanceof`: these errors cross bundle
71
+ * boundaries (a packager/executor pull inside `uip solution pack` / `run`
72
+ * throws from the host bundle into the tool's), where class identity does not
73
+ * survive. Lets an error funnel that only carries a message string keep the
74
+ * actionable next step (retry, the escape hatches, "remove the shadowing
75
+ * copy") attached to the failure instead of replacing it with a generic hint.
76
+ */
77
+ export declare function carriedInstructions(error: unknown): string | undefined;
65
78
  export declare function formatErrorChain(error: unknown): string;
66
79
  /**
67
80
  * Classify an outbound connectivity failure by walking the error graph.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The one place that writes `process.exitCode`.
3
+ *
4
+ * A command signals its outcome by calling `context.exit(code)`; a failure
5
+ * envelope printed through `OutputFormatter.error()` sets the non-zero default
6
+ * on its own. Both land here, so anything that has to observe the outcome —
7
+ * telemetry, the exit-code bridge in the browser host, a timing report — reads
8
+ * one value written in one place instead of racing scattered assignments.
9
+ *
10
+ * Hosts that adopt a status from outside the process (the version-sync re-exec
11
+ * takes the child's) call {@link setExitCode} directly. Everything inside a
12
+ * command handler goes through `context.exit`.
13
+ *
14
+ * `bun scripts/lint-exit-code.ts` (part of `bun run lint`) keeps this the only
15
+ * writer: an assignment to `process.exitCode` in any other package file fails.
16
+ */
17
+ /**
18
+ * Record `code` as the process exit code.
19
+ *
20
+ * Last write wins, which is what the scattered assignments did: an explicit
21
+ * `exit(code)` is the caller's final word. A caller that must not overwrite an
22
+ * earlier failure with success — the exit(0) at the end of a run — checks
23
+ * {@link getExitCode} first; the CLI host's `context.exit` does exactly that.
24
+ */
25
+ export declare function setExitCode(code: number): void;
26
+ /**
27
+ * The recorded exit code; `0` when nothing has set one.
28
+ *
29
+ * Node coerces a numeric string on assignment and rejects anything else, so a
30
+ * non-number here means unset — or a browser host writing to the `process`
31
+ * shim, which is not a code either way.
32
+ */
33
+ export declare function getExitCode(): number;
34
+ /**
35
+ * Clear the recorded exit code.
36
+ *
37
+ * For hosts that run more than one invocation in a process (the browser bundle,
38
+ * the MCP bridge): without this, a failing run's `1` leaks into the next run's
39
+ * success path. Not for command code — a command that wants to exit clean says
40
+ * so with `context.exit(0)`.
41
+ */
42
+ export declare function resetExitCode(): void;