@cleocode/cleo 2026.4.11 → 2026.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/add.d.ts.map +1 -1
- package/dist/cli/commands/add.js +123 -19
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/agent.d.ts.map +1 -1
- package/dist/cli/commands/agent.js +64 -20
- package/dist/cli/commands/agent.js.map +1 -1
- package/dist/cli/commands/backup.d.ts +1 -0
- package/dist/cli/commands/backup.d.ts.map +1 -1
- package/dist/cli/commands/backup.js +7 -1
- package/dist/cli/commands/backup.js.map +1 -1
- package/dist/cli/commands/complete.d.ts.map +1 -1
- package/dist/cli/commands/complete.js +55 -6
- package/dist/cli/commands/complete.js.map +1 -1
- package/dist/cli/commands/find.d.ts.map +1 -1
- package/dist/cli/commands/find.js +75 -11
- package/dist/cli/commands/find.js.map +1 -1
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +84 -12
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/observe.d.ts +3 -0
- package/dist/cli/commands/observe.d.ts.map +1 -1
- package/dist/cli/commands/observe.js +12 -9
- package/dist/cli/commands/observe.js.map +1 -1
- package/dist/cli/commands/restore.d.ts +1 -0
- package/dist/cli/commands/restore.d.ts.map +1 -1
- package/dist/cli/commands/restore.js +4 -0
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/schema.d.ts +27 -0
- package/dist/cli/commands/schema.d.ts.map +1 -0
- package/dist/cli/commands/schema.js +160 -0
- package/dist/cli/commands/schema.js.map +1 -0
- package/dist/cli/commands/show.d.ts.map +1 -1
- package/dist/cli/commands/show.js +24 -4
- package/dist/cli/commands/show.js.map +1 -1
- package/dist/cli/help-generator.d.ts +74 -0
- package/dist/cli/help-generator.d.ts.map +1 -0
- package/dist/cli/help-generator.js +229 -0
- package/dist/cli/help-generator.js.map +1 -0
- package/dist/cli/index.js +342 -107991
- package/dist/cli/index.js.map +1 -7
- package/dist/cli/renderers/index.d.ts +35 -7
- package/dist/cli/renderers/index.d.ts.map +1 -1
- package/dist/cli/renderers/index.js +64 -10
- package/dist/cli/renderers/index.js.map +1 -1
- package/dist/cli/renderers/lafs-validator.d.ts +27 -33
- package/dist/cli/renderers/lafs-validator.d.ts.map +1 -1
- package/dist/cli/renderers/lafs-validator.js +45 -98
- package/dist/cli/renderers/lafs-validator.js.map +1 -1
- package/dist/dispatch/adapters/cli.d.ts.map +1 -1
- package/dist/dispatch/adapters/cli.js +16 -2
- package/dist/dispatch/adapters/cli.js.map +1 -1
- package/dist/dispatch/dispatcher.js +7 -7
- package/dist/dispatch/dispatcher.js.map +1 -1
- package/dist/dispatch/domains/_base.js +4 -4
- package/dist/dispatch/domains/_base.js.map +1 -1
- package/dist/dispatch/domains/_meta.d.ts +3 -3
- package/dist/dispatch/domains/_meta.d.ts.map +1 -1
- package/dist/dispatch/domains/_meta.js +2 -2
- package/dist/dispatch/domains/admin.js +19 -19
- package/dist/dispatch/domains/admin.js.map +1 -1
- package/dist/dispatch/domains/check.js +3 -3
- package/dist/dispatch/domains/check.js.map +1 -1
- package/dist/dispatch/domains/nexus.js +2 -2
- package/dist/dispatch/domains/nexus.js.map +1 -1
- package/dist/dispatch/domains/orchestrate.js +3 -3
- package/dist/dispatch/domains/orchestrate.js.map +1 -1
- package/dist/dispatch/domains/pipeline.js +1 -1
- package/dist/dispatch/domains/pipeline.js.map +1 -1
- package/dist/dispatch/domains/sticky.js +1 -1
- package/dist/dispatch/domains/sticky.js.map +1 -1
- package/dist/dispatch/domains/tasks.js +1 -1
- package/dist/dispatch/domains/tasks.js.map +1 -1
- package/dist/dispatch/domains/tools.js +5 -5
- package/dist/dispatch/domains/tools.js.map +1 -1
- package/dist/dispatch/engines/_error.d.ts +34 -0
- package/dist/dispatch/engines/_error.d.ts.map +1 -1
- package/dist/dispatch/engines/_error.js +44 -0
- package/dist/dispatch/engines/_error.js.map +1 -1
- package/dist/dispatch/engines/session-engine.d.ts.map +1 -1
- package/dist/dispatch/engines/session-engine.js +18 -68
- package/dist/dispatch/engines/session-engine.js.map +1 -1
- package/dist/dispatch/engines/system-engine.d.ts.map +1 -1
- package/dist/dispatch/engines/system-engine.js +29 -37
- package/dist/dispatch/engines/system-engine.js.map +1 -1
- package/dist/dispatch/engines/task-engine.d.ts +1 -1
- package/dist/dispatch/engines/task-engine.d.ts.map +1 -1
- package/dist/dispatch/engines/task-engine.js +35 -229
- package/dist/dispatch/engines/task-engine.js.map +1 -1
- package/dist/dispatch/lib/budget.d.ts +1 -0
- package/dist/dispatch/lib/budget.d.ts.map +1 -1
- package/dist/dispatch/lib/budget.js +36 -29
- package/dist/dispatch/lib/budget.js.map +1 -1
- package/dist/dispatch/lib/config.d.ts +1 -1
- package/dist/dispatch/lib/config.d.ts.map +1 -1
- package/dist/dispatch/lib/defaults.d.ts +0 -2
- package/dist/dispatch/lib/defaults.d.ts.map +1 -1
- package/dist/dispatch/lib/defaults.js +3 -0
- package/dist/dispatch/lib/defaults.js.map +1 -1
- package/dist/dispatch/lib/exit-codes.d.ts +35 -0
- package/dist/dispatch/lib/exit-codes.d.ts.map +1 -0
- package/dist/dispatch/lib/exit-codes.js +60 -0
- package/dist/dispatch/lib/exit-codes.js.map +1 -0
- package/dist/dispatch/lib/gateway-meta.d.ts +1 -1
- package/dist/dispatch/lib/meta.d.ts +2 -2
- package/dist/dispatch/lib/meta.d.ts.map +1 -1
- package/dist/dispatch/lib/meta.js +1 -1
- package/dist/dispatch/lib/meta.js.map +1 -1
- package/dist/dispatch/lib/param-utils.d.ts +1 -1
- package/dist/dispatch/lib/param-utils.d.ts.map +1 -1
- package/dist/dispatch/lib/param-utils.js +1 -1
- package/dist/dispatch/lib/param-utils.js.map +1 -1
- package/dist/dispatch/lib/proto-envelope.d.ts +56 -0
- package/dist/dispatch/lib/proto-envelope.d.ts.map +1 -0
- package/dist/dispatch/lib/proto-envelope.js +17 -0
- package/dist/dispatch/lib/proto-envelope.js.map +1 -0
- package/dist/dispatch/middleware/field-filter.d.ts +1 -0
- package/dist/dispatch/middleware/field-filter.d.ts.map +1 -1
- package/dist/dispatch/middleware/field-filter.js +10 -5
- package/dist/dispatch/middleware/field-filter.js.map +1 -1
- package/dist/dispatch/middleware/projection.js +1 -1
- package/dist/dispatch/middleware/projection.js.map +1 -1
- package/dist/dispatch/middleware/protocol-enforcement.d.ts +6 -3
- package/dist/dispatch/middleware/protocol-enforcement.d.ts.map +1 -1
- package/dist/dispatch/middleware/protocol-enforcement.js +28 -17
- package/dist/dispatch/middleware/protocol-enforcement.js.map +1 -1
- package/dist/dispatch/middleware/rate-limiter.js +2 -2
- package/dist/dispatch/middleware/rate-limiter.js.map +1 -1
- package/dist/dispatch/middleware/sanitizer.js +1 -1
- package/dist/dispatch/middleware/sanitizer.js.map +1 -1
- package/dist/dispatch/middleware/verification-gates.js +2 -2
- package/dist/dispatch/middleware/verification-gates.js.map +1 -1
- package/dist/dispatch/types.d.ts +5 -1
- package/dist/dispatch/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/templates/cleoos-hub/pi-extensions/cleo-cant-bridge.ts +180 -0
|
@@ -14,16 +14,17 @@
|
|
|
14
14
|
* @epic T4663
|
|
15
15
|
*/
|
|
16
16
|
import { type FormatOptions } from '@cleocode/core';
|
|
17
|
+
import type { CliMeta } from '@cleocode/lafs';
|
|
17
18
|
export interface CliOutputOptions {
|
|
18
19
|
/** Command name (used to pick the correct human renderer). */
|
|
19
20
|
command: string;
|
|
20
|
-
/** Optional success message for JSON envelope. */
|
|
21
|
+
/** Optional success message for JSON envelope (attached to `meta.message`). */
|
|
21
22
|
message?: string;
|
|
22
|
-
/** Operation name for
|
|
23
|
+
/** Operation name for canonical envelope `meta.operation` (e.g. `"tasks.show"`). */
|
|
23
24
|
operation?: string;
|
|
24
|
-
/** Pagination for
|
|
25
|
+
/** Pagination metadata for canonical envelope `page` field. */
|
|
25
26
|
page?: FormatOptions['page'];
|
|
26
|
-
/** Extra
|
|
27
|
+
/** Extra metadata extensions merged into `meta`. */
|
|
27
28
|
extensions?: Record<string, unknown>;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
@@ -41,19 +42,46 @@ export interface CliOutputOptions {
|
|
|
41
42
|
export declare function cliOutput(data: unknown, opts: CliOutputOptions): void;
|
|
42
43
|
/**
|
|
43
44
|
* Error details for structured error output.
|
|
45
|
+
*
|
|
46
|
+
* Carries the full LAFS-compatible error context forwarded by the dispatch
|
|
47
|
+
* adapter from {@link DispatchError}. All fields are optional — only present
|
|
48
|
+
* fields are emitted in the output envelope.
|
|
49
|
+
*
|
|
50
|
+
* @see packages/cleo/src/dispatch/types.ts DispatchError
|
|
44
51
|
*/
|
|
45
52
|
export interface CliErrorDetails {
|
|
53
|
+
/** Machine-readable error code name (e.g. `E_NOT_FOUND`). */
|
|
46
54
|
name?: string;
|
|
55
|
+
/** Additional structured details from the error. */
|
|
47
56
|
details?: unknown;
|
|
57
|
+
/** Copy-paste fix hint for the operator or agent. */
|
|
48
58
|
fix?: unknown;
|
|
59
|
+
/** Alternative actions the caller can try. */
|
|
60
|
+
alternatives?: Array<{
|
|
61
|
+
action: string;
|
|
62
|
+
command: string;
|
|
63
|
+
}>;
|
|
49
64
|
}
|
|
50
65
|
/**
|
|
51
66
|
* Output an error in the resolved format.
|
|
52
|
-
*
|
|
53
|
-
*
|
|
67
|
+
*
|
|
68
|
+
* In JSON format (default / agent mode): emits a canonical `CliEnvelope` error
|
|
69
|
+
* envelope to stdout. The envelope always includes `meta` (ADR-039).
|
|
70
|
+
* All optional fields (`codeName`, `fix`, `alternatives`, `details`) are
|
|
71
|
+
* included only when they are actually present — no `undefined` keys are emitted.
|
|
72
|
+
*
|
|
73
|
+
* In human format: prints a plain error line to stderr and, when
|
|
74
|
+
* `details.fix` is a string, appends a `Fix: <hint>` line.
|
|
75
|
+
*
|
|
76
|
+
* @param message - Human-readable error message.
|
|
77
|
+
* @param code - Numeric exit code or string error code.
|
|
78
|
+
* @param details - Optional structured details (codeName, fix, alternatives, …).
|
|
79
|
+
* @param meta - Optional partial meta to merge into the error envelope.
|
|
54
80
|
*
|
|
55
81
|
* @task T4666
|
|
56
82
|
* @task T4813
|
|
83
|
+
* @task T336
|
|
84
|
+
* @task T338
|
|
57
85
|
*/
|
|
58
|
-
export declare function cliError(message: string, code?: number | string,
|
|
86
|
+
export declare function cliError(message: string, code?: number | string, details?: CliErrorDetails, meta?: Partial<CliMeta>): void;
|
|
59
87
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/renderers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/renderers/index.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAe,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA8E3D,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAsIrE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,8CAA8C;IAC9C,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,EACzB,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GACtB,IAAI,CA0CN"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a request UUID for error envelopes.
|
|
4
|
+
* Extracted to keep the hot path synchronous.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
function generateRequestId() {
|
|
9
|
+
return randomUUID();
|
|
10
|
+
}
|
|
1
11
|
/**
|
|
2
12
|
* Central output dispatch for V2 CLI commands.
|
|
3
13
|
*
|
|
@@ -109,6 +119,8 @@ export function cliOutput(data, opts) {
|
|
|
109
119
|
// --field: single-field plain text extraction (scripting / agent use).
|
|
110
120
|
// Centralised here so ALL commands (dispatchFromCli and dispatchRaw) honour the flag.
|
|
111
121
|
if (fieldCtx.field) {
|
|
122
|
+
// extractFieldFromResult operates on the data payload (not the envelope).
|
|
123
|
+
// Cast to the proto-envelope result type for the SDK call.
|
|
112
124
|
const value = extractFieldFromResult(data, fieldCtx.field);
|
|
113
125
|
if (value === undefined) {
|
|
114
126
|
cliError(`Field "${fieldCtx.field}" not found`, 4, { name: 'E_NOT_FOUND' });
|
|
@@ -118,13 +130,14 @@ export function cliOutput(data, opts) {
|
|
|
118
130
|
process.stdout.write(out + '\n');
|
|
119
131
|
return;
|
|
120
132
|
}
|
|
121
|
-
// JSON format (default): apply --fields filter, then emit
|
|
133
|
+
// JSON format (default): apply --fields filter, then emit canonical CLI envelope.
|
|
122
134
|
// Centralised here so ALL commands honour the flag without per-command wiring.
|
|
123
135
|
// applyFieldFilter can throw on unusual mixed-type arrays (e.g. changes: ['status']).
|
|
124
136
|
// In that case we fall back to unfiltered output rather than crashing.
|
|
125
137
|
let filteredData = data;
|
|
126
138
|
if (fieldCtx.fields?.length && data !== undefined && data !== null) {
|
|
127
139
|
try {
|
|
140
|
+
// Build a proto-envelope stub to drive the SDK field filter (ADR-039 bridge).
|
|
128
141
|
const stub = {
|
|
129
142
|
$schema: 'https://lafs.dev/schemas/v1/envelope.schema.json',
|
|
130
143
|
_meta: {
|
|
@@ -149,8 +162,7 @@ export function cliOutput(data, opts) {
|
|
|
149
162
|
// supported. Fall through to emit the full unfiltered result.
|
|
150
163
|
}
|
|
151
164
|
}
|
|
152
|
-
//
|
|
153
|
-
// --mvi minimal governs result contents only; mvi level is reflected in _meta.mvi.
|
|
165
|
+
// Build FormatOptions for formatSuccess (now emits canonical CliEnvelope shape).
|
|
154
166
|
const formatOpts = {};
|
|
155
167
|
if (opts.operation)
|
|
156
168
|
formatOpts.operation = opts.operation;
|
|
@@ -187,22 +199,64 @@ export function cliOutput(data, opts) {
|
|
|
187
199
|
}
|
|
188
200
|
/**
|
|
189
201
|
* Output an error in the resolved format.
|
|
190
|
-
*
|
|
191
|
-
*
|
|
202
|
+
*
|
|
203
|
+
* In JSON format (default / agent mode): emits a canonical `CliEnvelope` error
|
|
204
|
+
* envelope to stdout. The envelope always includes `meta` (ADR-039).
|
|
205
|
+
* All optional fields (`codeName`, `fix`, `alternatives`, `details`) are
|
|
206
|
+
* included only when they are actually present — no `undefined` keys are emitted.
|
|
207
|
+
*
|
|
208
|
+
* In human format: prints a plain error line to stderr and, when
|
|
209
|
+
* `details.fix` is a string, appends a `Fix: <hint>` line.
|
|
210
|
+
*
|
|
211
|
+
* @param message - Human-readable error message.
|
|
212
|
+
* @param code - Numeric exit code or string error code.
|
|
213
|
+
* @param details - Optional structured details (codeName, fix, alternatives, …).
|
|
214
|
+
* @param meta - Optional partial meta to merge into the error envelope.
|
|
192
215
|
*
|
|
193
216
|
* @task T4666
|
|
194
217
|
* @task T4813
|
|
218
|
+
* @task T336
|
|
219
|
+
* @task T338
|
|
195
220
|
*/
|
|
196
|
-
export function cliError(message, code,
|
|
221
|
+
export function cliError(message, code, details, meta) {
|
|
197
222
|
const ctx = getFormatContext();
|
|
198
223
|
if (ctx.format === 'human') {
|
|
199
224
|
console.error(`Error: ${message}${code ? ` (${code})` : ''}`);
|
|
225
|
+
if (typeof details?.fix === 'string') {
|
|
226
|
+
console.error(`Fix: ${details.fix}`);
|
|
227
|
+
}
|
|
200
228
|
return;
|
|
201
229
|
}
|
|
202
|
-
// JSON envelope always goes to stdout for consistent machine-readable output
|
|
203
|
-
|
|
230
|
+
// JSON envelope always goes to stdout for consistent machine-readable output.
|
|
231
|
+
// Build the error object incrementally so that absent optional fields are
|
|
232
|
+
// never serialised as `undefined` (which JSON.stringify would strip anyway,
|
|
233
|
+
// but being explicit keeps the intent clear and avoids lint warnings).
|
|
234
|
+
const errorObj = {
|
|
235
|
+
code: code ?? 1,
|
|
236
|
+
message,
|
|
237
|
+
};
|
|
238
|
+
if (details?.name !== undefined)
|
|
239
|
+
errorObj['codeName'] = details.name;
|
|
240
|
+
if (details?.fix !== undefined)
|
|
241
|
+
errorObj['fix'] = details.fix;
|
|
242
|
+
if (details?.alternatives !== undefined)
|
|
243
|
+
errorObj['alternatives'] = details.alternatives;
|
|
244
|
+
if (details?.details !== undefined)
|
|
245
|
+
errorObj['details'] = details.details;
|
|
246
|
+
// Canonical error envelope: {success, error, meta} — meta is ALWAYS present.
|
|
247
|
+
// Merge caller-supplied meta with defaults (ADR-039).
|
|
248
|
+
const errorMeta = {
|
|
249
|
+
operation: meta?.operation ?? 'cli.error',
|
|
250
|
+
requestId: meta?.requestId ?? generateRequestId(),
|
|
251
|
+
duration_ms: meta?.duration_ms ?? 0,
|
|
252
|
+
timestamp: meta?.timestamp ?? new Date().toISOString(),
|
|
253
|
+
...meta,
|
|
254
|
+
};
|
|
255
|
+
const envelope = {
|
|
204
256
|
success: false,
|
|
205
|
-
error:
|
|
206
|
-
|
|
257
|
+
error: errorObj,
|
|
258
|
+
meta: errorMeta,
|
|
259
|
+
};
|
|
260
|
+
console.log(JSON.stringify(envelope));
|
|
207
261
|
}
|
|
208
262
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/renderers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAsB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,iBAAiB;AACjB,OAAO,EACL,SAAS,EACT,aAAa,EACb,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AAQpB,MAAM,SAAS,GAAkC;IAC/C,YAAY;IACZ,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,E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
-
*
|
|
2
|
+
* CLI envelope validator middleware (Phase 6 / ADR-039 update).
|
|
3
3
|
*
|
|
4
4
|
* Every CLI envelope emitted by `cliOutput()` flows through this module
|
|
5
|
-
* before hitting stdout.
|
|
6
|
-
*
|
|
7
|
-
* optimized **minimal envelope** format that the canonical schema does
|
|
8
|
-
* not cover.
|
|
5
|
+
* before hitting stdout. Validates the **canonical CLI envelope** shape
|
|
6
|
+
* (`{success, data?, error?, meta, page?}`) as defined in ADR-039.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* schema at `packages/lafs/schemas/v1/envelope.schema.json`.
|
|
15
|
-
* - Minimal envelopes (`{ok, r, _m}`) are agent-optimized and not part
|
|
16
|
-
* of the public LAFS schema. We validate their shape locally with
|
|
17
|
-
* the lightweight invariant check below.
|
|
8
|
+
* The canonical shape replaces the three legacy shapes:
|
|
9
|
+
* - `{ok, r, _m}` (minimal MVI — removed)
|
|
10
|
+
* - `{$schema, _meta, success, result}` (full LAFS — migrated)
|
|
11
|
+
* - `{success, result}` (observe command — migrated)
|
|
18
12
|
*
|
|
19
|
-
* Validation invariants
|
|
20
|
-
* - Envelope MUST be a JSON object
|
|
21
|
-
* -
|
|
22
|
-
* -
|
|
23
|
-
* - On success, `r` / `result` MUST exist (may be null)
|
|
13
|
+
* Validation invariants:
|
|
14
|
+
* - Envelope MUST be a JSON object
|
|
15
|
+
* - `success` MUST be present and boolean
|
|
16
|
+
* - On success, `data` MUST exist (may be null)
|
|
24
17
|
* - On failure, `error` MUST exist with at least `code` and `message`
|
|
25
|
-
* - `
|
|
18
|
+
* - `meta` MUST be present (always — success and failure)
|
|
26
19
|
*
|
|
27
20
|
* When a violation is detected, the validator:
|
|
28
21
|
* 1. Wraps the malformed output in a valid error envelope
|
|
@@ -30,37 +23,38 @@
|
|
|
30
23
|
* 3. Emits the wrapped envelope to stderr for diagnostic tooling
|
|
31
24
|
*
|
|
32
25
|
* @task Phase 6 — LAFS formalization + schema consolidation
|
|
33
|
-
* @
|
|
34
|
-
* @see packages/lafs/schemas/v1/envelope.schema.json — canonical full-envelope schema
|
|
35
|
-
* @see crates/lafs-core — Rust embed of the canonical schema
|
|
26
|
+
* @task T338 — ADR-039 canonical envelope unification
|
|
36
27
|
*/
|
|
37
28
|
import { ExitCode } from '@cleocode/contracts';
|
|
38
29
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
30
|
+
* Shape violation report for a canonical CLI envelope.
|
|
31
|
+
*
|
|
32
|
+
* Carries the individual invariant results so diagnostic tooling can
|
|
33
|
+
* report exactly which invariants were violated.
|
|
41
34
|
*/
|
|
42
35
|
export interface LafsShapeViolation {
|
|
43
36
|
/** True iff the input is a well-formed JSON object. */
|
|
44
37
|
isObject: boolean;
|
|
45
|
-
/** True iff
|
|
38
|
+
/** True iff `success` is present. */
|
|
46
39
|
hasSuccessField: boolean;
|
|
47
|
-
/** True iff
|
|
40
|
+
/** True iff `success` is a boolean. */
|
|
48
41
|
successIsBoolean: boolean;
|
|
49
|
-
/** True iff
|
|
42
|
+
/** True iff `meta` is present (always required — ADR-039). */
|
|
50
43
|
hasMeta: boolean;
|
|
51
|
-
/** True iff the
|
|
44
|
+
/** True iff the data/error invariants hold for the indicated success value. */
|
|
52
45
|
resultOrErrorValid: boolean;
|
|
53
46
|
/** Human-readable reasons the envelope failed validation (empty = valid). */
|
|
54
47
|
reasons: string[];
|
|
55
48
|
}
|
|
56
49
|
/**
|
|
57
|
-
* Validate a
|
|
50
|
+
* Validate a canonical CLI envelope shape and report violations.
|
|
58
51
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
52
|
+
* Validates the unified `{success, data?, error?, meta, page?}` shape
|
|
53
|
+
* defined in ADR-039. All three legacy shapes (`{ok,r,_m}`,
|
|
54
|
+
* `{$schema,_meta,success,result}`, `{success,result}`) are now invalid
|
|
55
|
+
* and will produce violation reports.
|
|
62
56
|
*
|
|
63
|
-
* @param envelope - The candidate envelope (serialized string or object)
|
|
57
|
+
* @param envelope - The candidate envelope (serialized string or parsed object).
|
|
64
58
|
* @returns A `LafsShapeViolation` report. `.reasons.length === 0` when valid.
|
|
65
59
|
*/
|
|
66
60
|
export declare function validateLafsShape(envelope: unknown): LafsShapeViolation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lafs-validator.d.ts","sourceRoot":"","sources":["../../../src/cli/renderers/lafs-validator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lafs-validator.d.ts","sourceRoot":"","sources":["../../../src/cli/renderers/lafs-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,QAAQ,EAAE,OAAO,CAAC;IAClB,qCAAqC;IACrC,eAAe,EAAE,OAAO,CAAC;IACzB,uCAAuC;IACvC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,OAAO,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,kBAAkB,EAAE,OAAO,CAAC;IAC5B,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,CAqFvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAQvD;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,2BAA2B;IACxC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB;CAKxD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAqB/D"}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CLI envelope validator middleware (Phase 6 / ADR-039 update).
|
|
3
3
|
*
|
|
4
4
|
* Every CLI envelope emitted by `cliOutput()` flows through this module
|
|
5
|
-
* before hitting stdout.
|
|
6
|
-
*
|
|
7
|
-
* optimized **minimal envelope** format that the canonical schema does
|
|
8
|
-
* not cover.
|
|
5
|
+
* before hitting stdout. Validates the **canonical CLI envelope** shape
|
|
6
|
+
* (`{success, data?, error?, meta, page?}`) as defined in ADR-039.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* schema at `packages/lafs/schemas/v1/envelope.schema.json`.
|
|
15
|
-
* - Minimal envelopes (`{ok, r, _m}`) are agent-optimized and not part
|
|
16
|
-
* of the public LAFS schema. We validate their shape locally with
|
|
17
|
-
* the lightweight invariant check below.
|
|
8
|
+
* The canonical shape replaces the three legacy shapes:
|
|
9
|
+
* - `{ok, r, _m}` (minimal MVI — removed)
|
|
10
|
+
* - `{$schema, _meta, success, result}` (full LAFS — migrated)
|
|
11
|
+
* - `{success, result}` (observe command — migrated)
|
|
18
12
|
*
|
|
19
|
-
* Validation invariants
|
|
20
|
-
* - Envelope MUST be a JSON object
|
|
21
|
-
* -
|
|
22
|
-
* -
|
|
23
|
-
* - On success, `r` / `result` MUST exist (may be null)
|
|
13
|
+
* Validation invariants:
|
|
14
|
+
* - Envelope MUST be a JSON object
|
|
15
|
+
* - `success` MUST be present and boolean
|
|
16
|
+
* - On success, `data` MUST exist (may be null)
|
|
24
17
|
* - On failure, `error` MUST exist with at least `code` and `message`
|
|
25
|
-
* - `
|
|
18
|
+
* - `meta` MUST be present (always — success and failure)
|
|
26
19
|
*
|
|
27
20
|
* When a violation is detected, the validator:
|
|
28
21
|
* 1. Wraps the malformed output in a valid error envelope
|
|
@@ -30,37 +23,21 @@
|
|
|
30
23
|
* 3. Emits the wrapped envelope to stderr for diagnostic tooling
|
|
31
24
|
*
|
|
32
25
|
* @task Phase 6 — LAFS formalization + schema consolidation
|
|
33
|
-
* @
|
|
34
|
-
* @see packages/lafs/schemas/v1/envelope.schema.json — canonical full-envelope schema
|
|
35
|
-
* @see crates/lafs-core — Rust embed of the canonical schema
|
|
26
|
+
* @task T338 — ADR-039 canonical envelope unification
|
|
36
27
|
*/
|
|
37
28
|
import { ExitCode } from '@cleocode/contracts';
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const ENVELOPE_RESULT_KEY_FULL = 'result';
|
|
42
|
-
const ENVELOPE_META_KEYS = ['_m', '_meta'];
|
|
29
|
+
const ENVELOPE_SUCCESS_KEY = 'success';
|
|
30
|
+
const ENVELOPE_DATA_KEY = 'data';
|
|
31
|
+
const ENVELOPE_META_KEY = 'meta';
|
|
43
32
|
/**
|
|
44
|
-
*
|
|
33
|
+
* Validate a canonical CLI envelope shape and report violations.
|
|
45
34
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if ('success' in obj || '_meta' in obj || '$schema' in obj)
|
|
51
|
-
return 'full';
|
|
52
|
-
if ('ok' in obj || '_m' in obj)
|
|
53
|
-
return 'minimal';
|
|
54
|
-
return 'unknown';
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Validate a LAFS envelope shape and report violations.
|
|
35
|
+
* Validates the unified `{success, data?, error?, meta, page?}` shape
|
|
36
|
+
* defined in ADR-039. All three legacy shapes (`{ok,r,_m}`,
|
|
37
|
+
* `{$schema,_meta,success,result}`, `{success,result}`) are now invalid
|
|
38
|
+
* and will produce violation reports.
|
|
58
39
|
*
|
|
59
|
-
*
|
|
60
|
-
* uses the canonical schema via lafs-napi/AJV). Minimal envelopes are
|
|
61
|
-
* checked against the lightweight invariants in this module.
|
|
62
|
-
*
|
|
63
|
-
* @param envelope - The candidate envelope (serialized string or object)
|
|
40
|
+
* @param envelope - The candidate envelope (serialized string or parsed object).
|
|
64
41
|
* @returns A `LafsShapeViolation` report. `.reasons.length === 0` when valid.
|
|
65
42
|
*/
|
|
66
43
|
export function validateLafsShape(envelope) {
|
|
@@ -89,61 +66,29 @@ export function validateLafsShape(envelope) {
|
|
|
89
66
|
}
|
|
90
67
|
report.isObject = true;
|
|
91
68
|
const obj = parsed;
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// We only inspect minimal envelopes locally because they're an internal
|
|
96
|
-
// agent-optimized format that the canonical schema does not cover.
|
|
97
|
-
const flavor = detectEnvelopeFlavor(obj);
|
|
98
|
-
if (flavor === 'full') {
|
|
99
|
-
try {
|
|
100
|
-
// Lazy require to avoid pulling lafs into the cli bundle's hot path.
|
|
101
|
-
// The package exports validateEnvelope() at the package root.
|
|
102
|
-
// biome-ignore lint/suspicious/noExplicitAny: dynamic import shape
|
|
103
|
-
const lafs = require('@cleocode/lafs');
|
|
104
|
-
const result = lafs.validateEnvelope(obj);
|
|
105
|
-
report.hasSuccessField = true;
|
|
106
|
-
report.successIsBoolean = true;
|
|
107
|
-
report.hasMeta = true;
|
|
108
|
-
report.resultOrErrorValid = result.valid;
|
|
109
|
-
if (!result.valid) {
|
|
110
|
-
for (const err of result.errors) {
|
|
111
|
-
report.reasons.push(`canonical validator: ${err}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return report;
|
|
115
|
-
}
|
|
116
|
-
catch (loadErr) {
|
|
117
|
-
// Fall through to the local minimal-shape check if @cleocode/lafs
|
|
118
|
-
// can't be loaded for any reason — better than failing closed.
|
|
119
|
-
report.reasons.push(`Could not load canonical LAFS validator (${loadErr instanceof Error ? loadErr.message : String(loadErr)}); falling back to local shape check`);
|
|
120
|
-
// continue to the minimal-shape path below
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// Success-indicator field presence
|
|
124
|
-
const hasMinimal = ENVELOPE_OK_KEY_MINIMAL in obj;
|
|
125
|
-
const hasFull = ENVELOPE_OK_KEY_FULL in obj;
|
|
126
|
-
if (!hasMinimal && !hasFull) {
|
|
127
|
-
report.reasons.push(`Envelope missing success indicator — expected one of: ${ENVELOPE_OK_KEY_MINIMAL}, ${ENVELOPE_OK_KEY_FULL}`);
|
|
69
|
+
// Success-indicator field presence (`success`, not legacy `ok`)
|
|
70
|
+
if (!(ENVELOPE_SUCCESS_KEY in obj)) {
|
|
71
|
+
report.reasons.push(`Envelope missing success indicator — expected: "${ENVELOPE_SUCCESS_KEY}"`);
|
|
128
72
|
return report;
|
|
129
73
|
}
|
|
130
74
|
report.hasSuccessField = true;
|
|
131
|
-
const successValue =
|
|
75
|
+
const successValue = obj[ENVELOPE_SUCCESS_KEY];
|
|
132
76
|
if (typeof successValue !== 'boolean') {
|
|
133
|
-
report.reasons.push(`Envelope
|
|
77
|
+
report.reasons.push(`Envelope "${ENVELOPE_SUCCESS_KEY}" field must be boolean, got ${typeof successValue}`);
|
|
134
78
|
return report;
|
|
135
79
|
}
|
|
136
80
|
report.successIsBoolean = true;
|
|
137
|
-
//
|
|
138
|
-
report.hasMeta =
|
|
81
|
+
// `meta` MUST be present and an object on every envelope (ADR-039)
|
|
82
|
+
report.hasMeta = ENVELOPE_META_KEY in obj && typeof obj[ENVELOPE_META_KEY] === 'object';
|
|
139
83
|
if (!report.hasMeta) {
|
|
140
|
-
report.reasons.push(`Envelope missing
|
|
84
|
+
report.reasons.push(`Envelope missing required "${ENVELOPE_META_KEY}" object (ADR-039 — every envelope must carry meta)`);
|
|
141
85
|
}
|
|
142
86
|
// Success / error invariants
|
|
143
87
|
if (successValue === true) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
88
|
+
// Successful envelopes carry `data` (not legacy `result` or `r`)
|
|
89
|
+
const hasData = ENVELOPE_DATA_KEY in obj;
|
|
90
|
+
if (!hasData) {
|
|
91
|
+
report.reasons.push(`Successful envelope missing "${ENVELOPE_DATA_KEY}" field (legacy "result" / "r" are no longer valid — ADR-039)`);
|
|
147
92
|
}
|
|
148
93
|
else {
|
|
149
94
|
report.resultOrErrorValid = true;
|
|
@@ -152,14 +97,14 @@ export function validateLafsShape(envelope) {
|
|
|
152
97
|
else {
|
|
153
98
|
const errorField = obj['error'];
|
|
154
99
|
if (typeof errorField !== 'object' || errorField === null) {
|
|
155
|
-
report.reasons.push('Failed envelope missing error object');
|
|
100
|
+
report.reasons.push('Failed envelope missing "error" object');
|
|
156
101
|
}
|
|
157
102
|
else {
|
|
158
103
|
const err = errorField;
|
|
159
104
|
const hasCode = 'code' in err;
|
|
160
105
|
const hasMessage = 'message' in err && typeof err['message'] === 'string';
|
|
161
106
|
if (!hasCode || !hasMessage) {
|
|
162
|
-
report.reasons.push('Failed envelope error object must contain code and message (string)');
|
|
107
|
+
report.reasons.push('Failed envelope "error" object must contain "code" and "message" (string)');
|
|
163
108
|
}
|
|
164
109
|
else {
|
|
165
110
|
report.resultOrErrorValid = true;
|
|
@@ -207,20 +152,22 @@ export class LafsViolationError extends Error {
|
|
|
207
152
|
* emitted envelope turns out to be malformed.
|
|
208
153
|
*/
|
|
209
154
|
export function emitLafsViolation(err) {
|
|
155
|
+
// Emit canonical CLI envelope shape (ADR-039) even for violation errors
|
|
210
156
|
const envelope = {
|
|
211
|
-
|
|
157
|
+
success: false,
|
|
212
158
|
error: {
|
|
213
|
-
code:
|
|
159
|
+
code: ExitCode.LAFS_VIOLATION,
|
|
160
|
+
codeName: 'E_LAFS_VIOLATION',
|
|
214
161
|
message: err.message,
|
|
215
|
-
category: 'internal',
|
|
216
162
|
details: {
|
|
217
|
-
exitCode: ExitCode.LAFS_VIOLATION,
|
|
218
163
|
report: err.report,
|
|
219
164
|
},
|
|
220
165
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
166
|
+
meta: {
|
|
167
|
+
operation: 'cli.lafs-validator',
|
|
168
|
+
requestId: 'lafs-validator-emit',
|
|
169
|
+
duration_ms: 0,
|
|
170
|
+
timestamp: new Date().toISOString(),
|
|
224
171
|
},
|
|
225
172
|
};
|
|
226
173
|
process.stderr.write(`${JSON.stringify(envelope)}\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lafs-validator.js","sourceRoot":"","sources":["../../../src/cli/renderers/lafs-validator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lafs-validator.js","sourceRoot":"","sources":["../../../src/cli/renderers/lafs-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAuB/C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAiB;IACjD,MAAM,MAAM,GAAuB;QACjC,QAAQ,EAAE,KAAK;QACf,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,OAAO,EAAE,KAAK;QACd,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,qEAAqE;IACrE,IAAI,MAAM,GAAY,QAAQ,CAAC;IAC/B,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAA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EACd,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CA2C3B"}
|
|
@@ -169,8 +169,8 @@ export async function dispatchFromCli(gateway, domain, operation, params, output
|
|
|
169
169
|
gateway,
|
|
170
170
|
domain,
|
|
171
171
|
operation,
|
|
172
|
-
sessionId: response.
|
|
173
|
-
requestId: response.
|
|
172
|
+
sessionId: response.meta.sessionId,
|
|
173
|
+
requestId: response.meta.requestId,
|
|
174
174
|
cwd: getProjectRoot(),
|
|
175
175
|
});
|
|
176
176
|
const opts = {
|
|
@@ -191,6 +191,13 @@ export async function dispatchFromCli(gateway, domain, operation, params, output
|
|
|
191
191
|
name: errorCode,
|
|
192
192
|
details: response.error?.details,
|
|
193
193
|
fix: response.error?.fix,
|
|
194
|
+
alternatives: response.error?.alternatives,
|
|
195
|
+
}, {
|
|
196
|
+
operation: `${domain}.${operation}`,
|
|
197
|
+
requestId: response.meta.requestId,
|
|
198
|
+
duration_ms: response.meta.duration_ms,
|
|
199
|
+
timestamp: response.meta.timestamp,
|
|
200
|
+
...(response.meta.sessionId ? { sessionId: response.meta.sessionId } : {}),
|
|
194
201
|
});
|
|
195
202
|
process.exit(exitCode);
|
|
196
203
|
}
|
|
@@ -210,6 +217,13 @@ export function handleRawError(response, _opts) {
|
|
|
210
217
|
name: errorCode,
|
|
211
218
|
details: response.error?.details,
|
|
212
219
|
fix: response.error?.fix,
|
|
220
|
+
alternatives: response.error?.alternatives,
|
|
221
|
+
}, {
|
|
222
|
+
operation: _opts.operation,
|
|
223
|
+
requestId: response.meta.requestId,
|
|
224
|
+
duration_ms: response.meta.duration_ms,
|
|
225
|
+
timestamp: response.meta.timestamp,
|
|
226
|
+
...(response.meta.sessionId ? { sessionId: response.meta.sessionId } : {}),
|
|
213
227
|
});
|
|
214
228
|
process.exit(exitCode);
|
|
215
229
|
}
|