@lightdash-tools/cli 0.6.0 → 0.8.0

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 (110) hide show
  1. package/README.md +8 -4
  2. package/dist/commands/agentops/apply.d.ts +5 -0
  3. package/dist/commands/agentops/apply.js +53 -0
  4. package/dist/commands/agentops/bundle-schema.d.ts +5 -0
  5. package/dist/commands/agentops/bundle-schema.js +16 -0
  6. package/dist/commands/agentops/drift.d.ts +5 -0
  7. package/dist/commands/agentops/drift.js +46 -0
  8. package/dist/commands/agentops/evaluate-gate.d.ts +5 -0
  9. package/dist/commands/agentops/evaluate-gate.js +89 -0
  10. package/dist/commands/agentops/gate-schema.d.ts +5 -0
  11. package/dist/commands/agentops/gate-schema.js +16 -0
  12. package/dist/commands/agentops/plan.d.ts +5 -0
  13. package/dist/commands/agentops/plan.js +42 -0
  14. package/dist/commands/agentops/state.d.ts +4 -0
  15. package/dist/commands/agentops/state.js +8 -0
  16. package/dist/commands/agentops.d.ts +8 -0
  17. package/dist/commands/agentops.js +26 -0
  18. package/dist/commands/agentops.test.d.ts +1 -0
  19. package/dist/commands/agentops.test.js +400 -0
  20. package/dist/commands/agents-crud.d.ts +8 -0
  21. package/dist/commands/agents-crud.js +144 -0
  22. package/dist/commands/agents-discovery.d.ts +8 -0
  23. package/dist/commands/agents-discovery.js +139 -0
  24. package/dist/commands/agents-discovery.test.d.ts +1 -0
  25. package/dist/commands/agents-discovery.test.js +13 -0
  26. package/dist/commands/agents-evals.d.ts +8 -0
  27. package/dist/commands/agents-evals.js +246 -0
  28. package/dist/commands/agents-threads.d.ts +8 -0
  29. package/dist/commands/agents-threads.js +83 -0
  30. package/dist/commands/agents.js +8 -360
  31. package/dist/commands/ai-agents.js +52 -70
  32. package/dist/commands/charts.js +35 -46
  33. package/dist/commands/content.js +3 -12
  34. package/dist/commands/dashboards.js +3 -12
  35. package/dist/commands/explores.js +12 -21
  36. package/dist/commands/groups.js +44 -63
  37. package/dist/commands/metrics.js +6 -15
  38. package/dist/commands/organization-roles.js +28 -39
  39. package/dist/commands/organization.js +3 -12
  40. package/dist/commands/project-access.js +9 -18
  41. package/dist/commands/project-role-assignments.js +15 -24
  42. package/dist/commands/projects.js +33 -26
  43. package/dist/commands/query.js +30 -41
  44. package/dist/commands/schedulers.js +6 -15
  45. package/dist/commands/schema.d.ts +1 -2
  46. package/dist/commands/schema.js +24 -97
  47. package/dist/commands/schema.test.js +80 -15
  48. package/dist/commands/space-access.js +12 -21
  49. package/dist/commands/spaces.js +6 -15
  50. package/dist/commands/tags.js +6 -15
  51. package/dist/commands/users.js +23 -41
  52. package/dist/index.js +18 -16
  53. package/dist/index.test.js +9 -9
  54. package/dist/utils/cli-params.d.ts +4 -0
  55. package/dist/utils/cli-params.js +15 -0
  56. package/dist/utils/cli-params.test.d.ts +1 -0
  57. package/dist/utils/cli-params.test.js +12 -0
  58. package/dist/utils/file-input.d.ts +30 -0
  59. package/dist/utils/file-input.js +77 -0
  60. package/dist/utils/file-input.test.d.ts +1 -0
  61. package/dist/utils/file-input.test.js +68 -0
  62. package/dist/utils/safety.d.ts +5 -0
  63. package/dist/utils/safety.js +97 -109
  64. package/dist/utils/safety.test.js +135 -33
  65. package/package.json +14 -5
  66. package/src/commands/agentops/apply.ts +77 -0
  67. package/src/commands/agentops/bundle-schema.ts +20 -0
  68. package/src/commands/agentops/drift.ts +63 -0
  69. package/src/commands/agentops/evaluate-gate.ts +128 -0
  70. package/src/commands/agentops/gate-schema.ts +20 -0
  71. package/src/commands/agentops/plan.ts +55 -0
  72. package/src/commands/agentops/state.ts +5 -0
  73. package/src/commands/agentops.test.ts +454 -0
  74. package/src/commands/agentops.ts +28 -0
  75. package/src/commands/agents-crud.ts +193 -0
  76. package/src/commands/agents-discovery.test.ts +16 -0
  77. package/src/commands/agents-discovery.ts +180 -0
  78. package/src/commands/agents-evals.ts +353 -0
  79. package/src/commands/agents-threads.ts +116 -0
  80. package/src/commands/agents.ts +9 -493
  81. package/src/commands/ai-agents.ts +37 -28
  82. package/src/commands/charts.ts +6 -3
  83. package/src/commands/content.ts +3 -1
  84. package/src/commands/dashboards.ts +3 -1
  85. package/src/commands/explores.ts +3 -1
  86. package/src/commands/groups.ts +33 -33
  87. package/src/commands/metrics.ts +3 -1
  88. package/src/commands/organization-roles.ts +3 -1
  89. package/src/commands/organization.ts +3 -1
  90. package/src/commands/project-access.ts +3 -1
  91. package/src/commands/project-role-assignments.ts +3 -1
  92. package/src/commands/projects.ts +44 -18
  93. package/src/commands/query.ts +4 -1
  94. package/src/commands/schedulers.ts +3 -1
  95. package/src/commands/schema.test.ts +95 -16
  96. package/src/commands/schema.ts +42 -99
  97. package/src/commands/space-access.ts +3 -1
  98. package/src/commands/spaces.ts +3 -1
  99. package/src/commands/tags.ts +3 -1
  100. package/src/commands/users.ts +29 -25
  101. package/src/index.test.ts +10 -9
  102. package/src/index.ts +19 -16
  103. package/src/utils/cli-params.test.ts +13 -0
  104. package/src/utils/cli-params.ts +12 -0
  105. package/src/utils/client.test.ts +1 -0
  106. package/src/utils/file-input.test.ts +91 -0
  107. package/src/utils/file-input.ts +83 -0
  108. package/src/utils/safety.test.ts +158 -2
  109. package/src/utils/safety.ts +27 -20
  110. package/tsconfig.json +2 -1
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_1 = require("@lightdash-tools/common");
4
+ const vitest_1 = require("vitest");
5
+ const PROJECT_UUID = '00000000-0000-4000-8000-000000000001';
6
+ const AGENT_UUID = '00000000-0000-4000-8000-000000000010';
7
+ const EVAL_UUID = '00000000-0000-4000-8000-000000000020';
8
+ const validBundleYaml = `
9
+ apiVersion: lightdash.ai/v1alpha1
10
+ kind: LightdashAiAgentBundle
11
+ metadata:
12
+ name: sales-bundle
13
+ spec:
14
+ projectUuid: ${PROJECT_UUID}
15
+ agents:
16
+ - key: sales
17
+ uuid: ${AGENT_UUID}
18
+ name: Sales Agent
19
+ instruction: Help with sales
20
+ evaluations:
21
+ - key: smoke
22
+ uuid: ${EVAL_UUID}
23
+ title: Smoke Tests
24
+ prompts:
25
+ - prompt: What are total sales?
26
+ expectedResponse: null
27
+ `;
28
+ const validGateYaml = `
29
+ apiVersion: lightdash.ai/v1alpha1
30
+ kind: LightdashAiEvaluationGate
31
+ metadata:
32
+ name: release-gate
33
+ spec:
34
+ projectUuid: ${PROJECT_UUID}
35
+ agentUuid: ${AGENT_UUID}
36
+ evaluationUuid: ${EVAL_UUID}
37
+ policy:
38
+ minPassRate: 0.9
39
+ maxFailedAssessments: 0
40
+ triggerRun: true
41
+ `;
42
+ (0, vitest_1.describe)('AgentOps schema validation', () => {
43
+ (0, vitest_1.it)('parses a valid LightdashAiAgentBundle', () => {
44
+ var _a;
45
+ const bundle = (0, common_1.parseLightdashAiAgentBundle)(validBundleYaml);
46
+ (0, vitest_1.expect)(bundle.kind).toBe('LightdashAiAgentBundle');
47
+ (0, vitest_1.expect)(bundle.metadata.name).toBe('sales-bundle');
48
+ (0, vitest_1.expect)(bundle.spec.agents).toHaveLength(1);
49
+ (0, vitest_1.expect)((_a = bundle.spec.agents[0]) === null || _a === void 0 ? void 0 : _a.key).toBe('sales');
50
+ });
51
+ (0, vitest_1.it)('rejects bundle with wrong apiVersion', () => {
52
+ const yaml = validBundleYaml.replace('lightdash.ai/v1alpha1', 'v1');
53
+ (0, vitest_1.expect)(() => (0, common_1.parseLightdashAiAgentBundle)(yaml)).toThrow(/Invalid LightdashAiAgentBundle/);
54
+ });
55
+ (0, vitest_1.it)('rejects bundle without agents', () => {
56
+ const yaml = validBundleYaml.replace(/agents:[\s\S]*/, 'agents: []\n');
57
+ (0, vitest_1.expect)(() => (0, common_1.parseLightdashAiAgentBundle)(yaml)).toThrow(/Invalid LightdashAiAgentBundle/);
58
+ });
59
+ (0, vitest_1.it)('parses a valid LightdashAiEvaluationGate', () => {
60
+ const gate = (0, common_1.parseLightdashAiEvaluationGate)(validGateYaml);
61
+ (0, vitest_1.expect)(gate.kind).toBe('LightdashAiEvaluationGate');
62
+ (0, vitest_1.expect)(gate.spec.policy.minPassRate).toBe(0.9);
63
+ (0, vitest_1.expect)(gate.spec.triggerRun).toBe(true);
64
+ });
65
+ (0, vitest_1.it)('rejects gate with invalid project UUID', () => {
66
+ const yaml = validGateYaml.replace(PROJECT_UUID, 'not-a-uuid');
67
+ (0, vitest_1.expect)(() => (0, common_1.parseLightdashAiEvaluationGate)(yaml)).toThrow(/Invalid LightdashAiEvaluationGate/);
68
+ });
69
+ });
70
+ (0, vitest_1.describe)('AgentOps bundle diff', () => {
71
+ const bundle = (0, common_1.parseLightdashAiAgentBundle)(validBundleYaml);
72
+ (0, vitest_1.it)('reports noop when current state matches desired state', () => {
73
+ const current = {
74
+ projectUuid: PROJECT_UUID,
75
+ agents: [
76
+ {
77
+ agent: {
78
+ uuid: AGENT_UUID,
79
+ name: 'Sales Agent',
80
+ description: null,
81
+ instruction: 'Help with sales',
82
+ tags: null,
83
+ },
84
+ evaluations: [
85
+ {
86
+ evalUuid: EVAL_UUID,
87
+ title: 'Smoke Tests',
88
+ description: null,
89
+ prompts: [
90
+ {
91
+ type: 'string',
92
+ prompt: 'What are total sales?',
93
+ expectedResponse: null,
94
+ },
95
+ ],
96
+ },
97
+ ],
98
+ },
99
+ ],
100
+ };
101
+ const diff = (0, common_1.computeBundleDiff)(bundle, current);
102
+ (0, vitest_1.expect)(diff.hasDrift).toBe(false);
103
+ (0, vitest_1.expect)(diff.summary.creates).toBe(0);
104
+ (0, vitest_1.expect)(diff.summary.updates).toBe(0);
105
+ (0, vitest_1.expect)(diff.summary.deletes).toBe(0);
106
+ (0, vitest_1.expect)(diff.summary.noops).toBe(2);
107
+ });
108
+ (0, vitest_1.it)('reports create when agent is missing', () => {
109
+ const diff = (0, common_1.computeBundleDiff)(bundle, { projectUuid: PROJECT_UUID, agents: [] });
110
+ (0, vitest_1.expect)(diff.hasDrift).toBe(true);
111
+ (0, vitest_1.expect)(diff.summary.creates).toBe(2);
112
+ (0, vitest_1.expect)(diff.changes.some((c) => c.resourceType === 'agent' && c.operation === 'create')).toBe(true);
113
+ });
114
+ (0, vitest_1.it)('reports update when agent instruction drifts', () => {
115
+ var _a, _b;
116
+ const current = {
117
+ projectUuid: PROJECT_UUID,
118
+ agents: [
119
+ {
120
+ agent: {
121
+ uuid: AGENT_UUID,
122
+ name: 'Sales Agent',
123
+ description: null,
124
+ instruction: 'Old instruction',
125
+ tags: null,
126
+ },
127
+ evaluations: [
128
+ {
129
+ evalUuid: EVAL_UUID,
130
+ title: 'Smoke Tests',
131
+ description: null,
132
+ prompts: [
133
+ {
134
+ type: 'string',
135
+ prompt: 'What are total sales?',
136
+ expectedResponse: null,
137
+ },
138
+ ],
139
+ },
140
+ ],
141
+ },
142
+ ],
143
+ };
144
+ const diff = (0, common_1.computeBundleDiff)(bundle, current);
145
+ (0, vitest_1.expect)(diff.summary.updates).toBe(1);
146
+ (0, vitest_1.expect)((_b = (_a = diff.changes.find((c) => c.resourceType === 'agent')) === null || _a === void 0 ? void 0 : _a.fields) === null || _b === void 0 ? void 0 : _b.instruction).toEqual({
147
+ from: 'Old instruction',
148
+ to: 'Help with sales',
149
+ });
150
+ });
151
+ (0, vitest_1.it)('reports noop when bundle omits enableReasoning and API agent has undefined', () => {
152
+ const bundleWithoutReasoning = (0, common_1.parseLightdashAiAgentBundle)(`
153
+ apiVersion: lightdash.ai/v1alpha1
154
+ kind: LightdashAiAgentBundle
155
+ metadata:
156
+ name: sales-bundle
157
+ spec:
158
+ projectUuid: ${PROJECT_UUID}
159
+ agents:
160
+ - key: sales
161
+ uuid: ${AGENT_UUID}
162
+ name: Sales Agent
163
+ instruction: Help with sales
164
+ evaluations: []
165
+ `);
166
+ const current = {
167
+ projectUuid: PROJECT_UUID,
168
+ agents: [
169
+ {
170
+ agent: {
171
+ uuid: AGENT_UUID,
172
+ name: 'Sales Agent',
173
+ description: null,
174
+ instruction: 'Help with sales',
175
+ tags: null,
176
+ enableDataAccess: false,
177
+ enableSelfImprovement: false,
178
+ },
179
+ evaluations: [],
180
+ },
181
+ ],
182
+ };
183
+ const diff = (0, common_1.computeBundleDiff)(bundleWithoutReasoning, current);
184
+ (0, vitest_1.expect)(diff.hasDrift).toBe(false);
185
+ (0, vitest_1.expect)(diff.summary.updates).toBe(0);
186
+ (0, vitest_1.expect)(diff.summary.noops).toBe(1);
187
+ });
188
+ (0, vitest_1.it)('reports noop when bundle tags are empty array and API has null tags', () => {
189
+ const bundleWithEmptyTags = (0, common_1.parseLightdashAiAgentBundle)(`
190
+ apiVersion: lightdash.ai/v1alpha1
191
+ kind: LightdashAiAgentBundle
192
+ metadata:
193
+ name: sales-bundle
194
+ spec:
195
+ projectUuid: ${PROJECT_UUID}
196
+ agents:
197
+ - key: sales
198
+ uuid: ${AGENT_UUID}
199
+ name: Sales Agent
200
+ instruction: Help with sales
201
+ tags: []
202
+ evaluations: []
203
+ `);
204
+ const current = {
205
+ projectUuid: PROJECT_UUID,
206
+ agents: [
207
+ {
208
+ agent: {
209
+ uuid: AGENT_UUID,
210
+ name: 'Sales Agent',
211
+ description: null,
212
+ instruction: 'Help with sales',
213
+ tags: null,
214
+ },
215
+ evaluations: [],
216
+ },
217
+ ],
218
+ };
219
+ const diff = (0, common_1.computeBundleDiff)(bundleWithEmptyTags, current);
220
+ (0, vitest_1.expect)(diff.hasDrift).toBe(false);
221
+ (0, vitest_1.expect)(diff.summary.updates).toBe(0);
222
+ (0, vitest_1.expect)(diff.summary.noops).toBe(1);
223
+ });
224
+ (0, vitest_1.it)('reports noop when API has false booleans and bundle omits them', () => {
225
+ const bundleWithoutBooleans = (0, common_1.parseLightdashAiAgentBundle)(`
226
+ apiVersion: lightdash.ai/v1alpha1
227
+ kind: LightdashAiAgentBundle
228
+ metadata:
229
+ name: sales-bundle
230
+ spec:
231
+ projectUuid: ${PROJECT_UUID}
232
+ agents:
233
+ - key: sales
234
+ uuid: ${AGENT_UUID}
235
+ name: Sales Agent
236
+ instruction: Help with sales
237
+ evaluations: []
238
+ `);
239
+ const current = {
240
+ projectUuid: PROJECT_UUID,
241
+ agents: [
242
+ {
243
+ agent: {
244
+ uuid: AGENT_UUID,
245
+ name: 'Sales Agent',
246
+ description: null,
247
+ instruction: 'Help with sales',
248
+ tags: null,
249
+ enableDataAccess: false,
250
+ enableSelfImprovement: false,
251
+ },
252
+ evaluations: [],
253
+ },
254
+ ],
255
+ };
256
+ const diff = (0, common_1.computeBundleDiff)(bundleWithoutBooleans, current);
257
+ (0, vitest_1.expect)(diff.hasDrift).toBe(false);
258
+ (0, vitest_1.expect)(diff.summary.updates).toBe(0);
259
+ (0, vitest_1.expect)(diff.summary.noops).toBe(1);
260
+ });
261
+ (0, vitest_1.it)('includes agentUuid on name-matched agent update changes', () => {
262
+ const nameMatchedBundle = (0, common_1.parseLightdashAiAgentBundle)(`
263
+ apiVersion: lightdash.ai/v1alpha1
264
+ kind: LightdashAiAgentBundle
265
+ metadata:
266
+ name: sales-bundle
267
+ spec:
268
+ projectUuid: ${PROJECT_UUID}
269
+ agents:
270
+ - key: sales
271
+ name: Sales Agent
272
+ instruction: Updated instruction
273
+ evaluations: []
274
+ `);
275
+ const current = {
276
+ projectUuid: PROJECT_UUID,
277
+ agents: [
278
+ {
279
+ agent: {
280
+ uuid: AGENT_UUID,
281
+ name: 'Sales Agent',
282
+ description: null,
283
+ instruction: 'Help with sales',
284
+ tags: null,
285
+ },
286
+ evaluations: [],
287
+ },
288
+ ],
289
+ };
290
+ const diff = (0, common_1.computeBundleDiff)(nameMatchedBundle, current);
291
+ const agentUpdate = diff.changes.find((c) => c.resourceType === 'agent' && c.operation === 'update');
292
+ (0, vitest_1.expect)(agentUpdate === null || agentUpdate === void 0 ? void 0 : agentUpdate.agentUuid).toBe(AGENT_UUID);
293
+ });
294
+ (0, vitest_1.it)('reports delete for agents not in bundle', () => {
295
+ const orphanUuid = '00000000-0000-4000-8000-000000000099';
296
+ const current = {
297
+ projectUuid: PROJECT_UUID,
298
+ agents: [
299
+ {
300
+ agent: {
301
+ uuid: AGENT_UUID,
302
+ name: 'Sales Agent',
303
+ description: null,
304
+ instruction: 'Help with sales',
305
+ tags: null,
306
+ },
307
+ evaluations: [
308
+ {
309
+ evalUuid: EVAL_UUID,
310
+ title: 'Smoke Tests',
311
+ description: null,
312
+ prompts: [
313
+ {
314
+ type: 'string',
315
+ prompt: 'What are total sales?',
316
+ expectedResponse: null,
317
+ },
318
+ ],
319
+ },
320
+ ],
321
+ },
322
+ {
323
+ agent: {
324
+ uuid: orphanUuid,
325
+ name: 'Orphan Agent',
326
+ description: null,
327
+ instruction: null,
328
+ tags: null,
329
+ },
330
+ evaluations: [],
331
+ },
332
+ ],
333
+ };
334
+ const diff = (0, common_1.computeBundleDiff)(bundle, current);
335
+ (0, vitest_1.expect)(diff.changes.some((c) => c.operation === 'delete' && c.key === orphanUuid)).toBe(true);
336
+ });
337
+ });
338
+ (0, vitest_1.describe)('AgentOps evaluate-gate CLI options', () => {
339
+ (0, vitest_1.it)('rejects non-numeric timeout values', () => {
340
+ const parse = (value) => {
341
+ const parsed = Number.parseInt(value, 10);
342
+ if (!Number.isFinite(parsed) || parsed <= 0) {
343
+ throw new Error('--timeout must be a positive integer');
344
+ }
345
+ return parsed;
346
+ };
347
+ (0, vitest_1.expect)(() => parse('abc')).toThrow('--timeout must be a positive integer');
348
+ (0, vitest_1.expect)(() => parse('0')).toThrow('--timeout must be a positive integer');
349
+ (0, vitest_1.expect)(parse('30')).toBe(30);
350
+ });
351
+ });
352
+ (0, vitest_1.describe)('AgentOps gate policy evaluation', () => {
353
+ const baseRun = {
354
+ runUuid: '00000000-0000-4000-8000-000000000030',
355
+ status: 'completed',
356
+ passedAssessments: 9,
357
+ failedAssessments: 1,
358
+ completedAt: '2026-01-01T00:00:00.000Z',
359
+ };
360
+ (0, vitest_1.it)('passes when policy thresholds are met', () => {
361
+ const result = (0, common_1.evaluateGatePolicy)({ minPassRate: 0.8, maxFailedAssessments: 2 }, baseRun);
362
+ (0, vitest_1.expect)(result.passed).toBe(true);
363
+ (0, vitest_1.expect)(result.exitCode).toBe(common_1.GateExitCode.PASSED);
364
+ (0, vitest_1.expect)(result.metrics.passRate).toBe(0.9);
365
+ });
366
+ (0, vitest_1.it)('fails with POLICY_FAILED when minPassRate is not met', () => {
367
+ const result = (0, common_1.evaluateGatePolicy)({ minPassRate: 0.95 }, baseRun);
368
+ (0, vitest_1.expect)(result.passed).toBe(false);
369
+ (0, vitest_1.expect)(result.exitCode).toBe(common_1.GateExitCode.POLICY_FAILED);
370
+ (0, vitest_1.expect)(result.reasons[0]).toMatch(/minPassRate/);
371
+ });
372
+ (0, vitest_1.it)('returns RUN_FAILED for failed runs', () => {
373
+ const result = (0, common_1.evaluateGatePolicy)({ minPassRate: 0.5 }, Object.assign(Object.assign({}, baseRun), { status: 'failed', passedAssessments: 0, failedAssessments: 0 }));
374
+ (0, vitest_1.expect)(result.exitCode).toBe(common_1.GateExitCode.RUN_FAILED);
375
+ });
376
+ (0, vitest_1.it)('returns RUN_IN_PROGRESS for pending runs', () => {
377
+ const result = (0, common_1.evaluateGatePolicy)({ minPassRate: 0.5 }, Object.assign(Object.assign({}, baseRun), { status: 'running', completedAt: null }));
378
+ (0, vitest_1.expect)(result.exitCode).toBe(common_1.GateExitCode.RUN_IN_PROGRESS);
379
+ });
380
+ (0, vitest_1.it)('enforces requireAllPassed', () => {
381
+ const result = (0, common_1.evaluateGatePolicy)({ requireAllPassed: true }, baseRun);
382
+ (0, vitest_1.expect)(result.passed).toBe(false);
383
+ (0, vitest_1.expect)(result.exitCode).toBe(common_1.GateExitCode.POLICY_FAILED);
384
+ });
385
+ (0, vitest_1.it)('fails when maxFailedAssessments exceeded', () => {
386
+ const result = (0, common_1.evaluateGatePolicy)({ maxFailedAssessments: 0 }, baseRun);
387
+ (0, vitest_1.expect)(result.passed).toBe(false);
388
+ (0, vitest_1.expect)(result.reasons[0]).toMatch(/maxFailedAssessments/);
389
+ });
390
+ (0, vitest_1.it)('fails when minPassedAssessments not met', () => {
391
+ const result = (0, common_1.evaluateGatePolicy)({ minPassedAssessments: 10 }, baseRun);
392
+ (0, vitest_1.expect)(result.passed).toBe(false);
393
+ (0, vitest_1.expect)(result.reasons[0]).toMatch(/minPassedAssessments/);
394
+ });
395
+ (0, vitest_1.it)('fails minPassRate when no assessments exist', () => {
396
+ const result = (0, common_1.evaluateGatePolicy)({ minPassRate: 0.5 }, Object.assign(Object.assign({}, baseRun), { passedAssessments: 0, failedAssessments: 0 }));
397
+ (0, vitest_1.expect)(result.passed).toBe(false);
398
+ (0, vitest_1.expect)(result.reasons[0]).toMatch(/at least one assessment/);
399
+ });
400
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Agent CRUD commands (list, get, create, update, delete).
3
+ */
4
+ import type { Command } from 'commander';
5
+ /**
6
+ * Registers agent CRUD subcommands on the `agents` command group.
7
+ */
8
+ export declare function registerAgentsCrudCommands(agentsCmd: Command): void;
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ /**
3
+ * Agent CRUD commands (list, get, create, update, delete).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerAgentsCrudCommands = registerAgentsCrudCommands;
7
+ const common_1 = require("@lightdash-tools/common");
8
+ const client_1 = require("../utils/client");
9
+ const file_input_1 = require("../utils/file-input");
10
+ const safety_1 = require("../utils/safety");
11
+ /**
12
+ * Registers agent CRUD subcommands on the `agents` command group.
13
+ */
14
+ function registerAgentsCrudCommands(agentsCmd) {
15
+ agentsCmd
16
+ .command('list')
17
+ .description('List all agents in a project')
18
+ .requiredOption('--project <uuid>', 'Project UUID')
19
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async function () {
20
+ const { project } = this.opts();
21
+ try {
22
+ const client = (0, client_1.getClient)();
23
+ const result = await client.v1.aiAgents.listAgents(project);
24
+ console.log(JSON.stringify(result, null, 2));
25
+ }
26
+ catch (error) {
27
+ console.error('Error listing agents:', error instanceof Error ? error.message : String(error));
28
+ process.exit(1);
29
+ }
30
+ }));
31
+ agentsCmd
32
+ .command('get <agentUuid>')
33
+ .description('Get a single agent by UUID')
34
+ .requiredOption('--project <uuid>', 'Project UUID')
35
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (agentUuid, cmd) => {
36
+ const { project } = cmd.opts();
37
+ try {
38
+ const client = (0, client_1.getClient)();
39
+ const result = await client.v1.aiAgents.getAgent(project, agentUuid);
40
+ console.log(JSON.stringify(result, null, 2));
41
+ }
42
+ catch (error) {
43
+ console.error('Error fetching agent:', error instanceof Error ? error.message : String(error));
44
+ process.exit(1);
45
+ }
46
+ }));
47
+ agentsCmd
48
+ .command('create')
49
+ .description('Create a new agent in a project')
50
+ .requiredOption('--project <uuid>', 'Project UUID')
51
+ .option('--name <name>', 'Agent name')
52
+ .option('--description <text>', 'Agent description')
53
+ .option('--instruction <text>', 'System instruction for the agent')
54
+ .option('--file <path>', 'Read agent JSON/YAML from file')
55
+ .option('--stdin', 'Read agent JSON/YAML from stdin')
56
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async function () {
57
+ const options = this.opts();
58
+ try {
59
+ const client = (0, client_1.getClient)();
60
+ let body;
61
+ if ((0, file_input_1.hasExplicitFileInput)(options)) {
62
+ const parsed = await (0, file_input_1.readParsedInput)({ file: options.file, stdin: options.stdin });
63
+ if (parsed == null || typeof parsed !== 'object' || Array.isArray(parsed)) {
64
+ console.error('Error: agent input must be a JSON/YAML object');
65
+ process.exit(1);
66
+ }
67
+ body = Object.assign(Object.assign({}, parsed), { projectUuid: options.project });
68
+ }
69
+ else {
70
+ if (options.name == null) {
71
+ console.error('Error: --name is required unless using --file or --stdin');
72
+ process.exit(1);
73
+ }
74
+ body = Object.assign(Object.assign({ name: options.name, projectUuid: options.project }, (options.description != null ? { description: options.description } : {})), (options.instruction != null ? { instruction: options.instruction } : {}));
75
+ }
76
+ const result = await client.v1.aiAgents.createAgent(options.project, body);
77
+ console.log(JSON.stringify(result, null, 2));
78
+ }
79
+ catch (error) {
80
+ console.error('Error creating agent:', error instanceof Error ? error.message : String(error));
81
+ process.exit(1);
82
+ }
83
+ }));
84
+ agentsCmd
85
+ .command('update <agentUuid>')
86
+ .description('Update an existing agent')
87
+ .requiredOption('--project <uuid>', 'Project UUID')
88
+ .option('--name <name>', 'New agent name')
89
+ .option('--description <text>', 'New agent description')
90
+ .option('--instruction <text>', 'New system instruction')
91
+ .option('--file <path>', 'Read agent patch JSON/YAML from file')
92
+ .option('--stdin', 'Read agent patch JSON/YAML from stdin')
93
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (agentUuid, cmd) => {
94
+ const options = cmd.opts();
95
+ try {
96
+ const client = (0, client_1.getClient)();
97
+ let body;
98
+ if ((0, file_input_1.hasExplicitFileInput)(options)) {
99
+ const parsed = await (0, file_input_1.readParsedInput)({ file: options.file, stdin: options.stdin });
100
+ if (parsed == null || typeof parsed !== 'object' || Array.isArray(parsed)) {
101
+ console.error('Error: agent patch input must be a JSON/YAML object');
102
+ process.exit(1);
103
+ }
104
+ body = parsed;
105
+ }
106
+ else {
107
+ const patch = {};
108
+ if (options.name != null)
109
+ patch['name'] = options.name;
110
+ if (options.description != null)
111
+ patch['description'] = options.description;
112
+ if (options.instruction != null)
113
+ patch['instruction'] = options.instruction;
114
+ if (Object.keys(patch).length === 0) {
115
+ console.error('Error: at least one of --name, --description, --instruction, --file, --stdin is required');
116
+ process.exit(1);
117
+ }
118
+ body = patch;
119
+ }
120
+ const result = await client.v1.aiAgents.updateAgent(options.project, agentUuid, body);
121
+ console.log(JSON.stringify(result, null, 2));
122
+ }
123
+ catch (error) {
124
+ console.error('Error updating agent:', error instanceof Error ? error.message : String(error));
125
+ process.exit(1);
126
+ }
127
+ }));
128
+ agentsCmd
129
+ .command('delete <agentUuid>')
130
+ .description('Delete an agent')
131
+ .requiredOption('--project <uuid>', 'Project UUID')
132
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (agentUuid, cmd) => {
133
+ const { project } = cmd.opts();
134
+ try {
135
+ const client = (0, client_1.getClient)();
136
+ await client.v1.aiAgents.deleteAgent(project, agentUuid);
137
+ console.error(`Agent ${agentUuid} deleted successfully`);
138
+ }
139
+ catch (error) {
140
+ console.error('Error deleting agent:', error instanceof Error ? error.message : String(error));
141
+ process.exit(1);
142
+ }
143
+ }));
144
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Agent discovery commands — preferences, suggestions, models, readiness.
3
+ */
4
+ import type { Command } from 'commander';
5
+ /**
6
+ * Registers discovery subcommands on the `agents` command group.
7
+ */
8
+ export declare function registerAgentsDiscoveryCommands(agentsCmd: Command): void;