@lightdash-tools/cli 0.5.0 → 0.7.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 (109) hide show
  1. package/README.md +6 -2
  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.js +33 -10
  46. package/dist/commands/schema.test.js +58 -1
  47. package/dist/commands/space-access.js +12 -21
  48. package/dist/commands/spaces.js +6 -15
  49. package/dist/commands/tags.js +6 -15
  50. package/dist/commands/users.js +23 -41
  51. package/dist/index.js +18 -16
  52. package/dist/index.test.js +9 -9
  53. package/dist/utils/cli-params.d.ts +4 -0
  54. package/dist/utils/cli-params.js +15 -0
  55. package/dist/utils/cli-params.test.d.ts +1 -0
  56. package/dist/utils/cli-params.test.js +12 -0
  57. package/dist/utils/file-input.d.ts +30 -0
  58. package/dist/utils/file-input.js +77 -0
  59. package/dist/utils/file-input.test.d.ts +1 -0
  60. package/dist/utils/file-input.test.js +68 -0
  61. package/dist/utils/safety.d.ts +5 -0
  62. package/dist/utils/safety.js +97 -109
  63. package/dist/utils/safety.test.js +135 -33
  64. package/package.json +14 -5
  65. package/src/commands/agentops/apply.ts +77 -0
  66. package/src/commands/agentops/bundle-schema.ts +20 -0
  67. package/src/commands/agentops/drift.ts +63 -0
  68. package/src/commands/agentops/evaluate-gate.ts +128 -0
  69. package/src/commands/agentops/gate-schema.ts +20 -0
  70. package/src/commands/agentops/plan.ts +55 -0
  71. package/src/commands/agentops/state.ts +5 -0
  72. package/src/commands/agentops.test.ts +454 -0
  73. package/src/commands/agentops.ts +28 -0
  74. package/src/commands/agents-crud.ts +193 -0
  75. package/src/commands/agents-discovery.test.ts +16 -0
  76. package/src/commands/agents-discovery.ts +180 -0
  77. package/src/commands/agents-evals.ts +353 -0
  78. package/src/commands/agents-threads.ts +116 -0
  79. package/src/commands/agents.ts +9 -493
  80. package/src/commands/ai-agents.ts +37 -28
  81. package/src/commands/charts.ts +6 -3
  82. package/src/commands/content.ts +3 -1
  83. package/src/commands/dashboards.ts +3 -1
  84. package/src/commands/explores.ts +3 -1
  85. package/src/commands/groups.ts +33 -33
  86. package/src/commands/metrics.ts +3 -1
  87. package/src/commands/organization-roles.ts +3 -1
  88. package/src/commands/organization.ts +3 -1
  89. package/src/commands/project-access.ts +3 -1
  90. package/src/commands/project-role-assignments.ts +3 -1
  91. package/src/commands/projects.ts +44 -18
  92. package/src/commands/query.ts +4 -1
  93. package/src/commands/schedulers.ts +3 -1
  94. package/src/commands/schema.test.ts +72 -1
  95. package/src/commands/schema.ts +60 -14
  96. package/src/commands/space-access.ts +3 -1
  97. package/src/commands/spaces.ts +3 -1
  98. package/src/commands/tags.ts +3 -1
  99. package/src/commands/users.ts +29 -25
  100. package/src/index.test.ts +10 -9
  101. package/src/index.ts +19 -16
  102. package/src/utils/cli-params.test.ts +13 -0
  103. package/src/utils/cli-params.ts +12 -0
  104. package/src/utils/client.test.ts +1 -0
  105. package/src/utils/file-input.test.ts +91 -0
  106. package/src/utils/file-input.ts +83 -0
  107. package/src/utils/safety.test.ts +158 -2
  108. package/src/utils/safety.ts +27 -20
  109. package/tsconfig.json +2 -1
@@ -5,10 +5,12 @@
5
5
  * All commands require --project <projectUuid>.
6
6
  */
7
7
 
8
+ import { registerAgentsCrudCommands } from './agents-crud';
9
+ import { registerAgentsDiscoveryCommands } from './agents-discovery';
10
+ import { registerAgentsEvalCommands } from './agents-evals';
11
+ import { registerAgentsThreadCommands } from './agents-threads';
12
+
8
13
  import type { Command } from 'commander';
9
- import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT, WRITE_DESTRUCTIVE } from '@lightdash-tools/common';
10
- import { getClient } from '../utils/client';
11
- import { wrapAction } from '../utils/safety';
12
14
 
13
15
  /**
14
16
  * Registers the `agents` command group (project-scoped).
@@ -18,494 +20,8 @@ export function registerAgentsCommand(program: Command): void {
18
20
  .command('agents')
19
21
  .description('Manage AI agents within a project (project-scoped)');
20
22
 
21
- // ─── Agent CRUD ──────────────────────────────────────────────────────────────
22
-
23
- agentsCmd
24
- .command('list')
25
- .description('List all agents in a project')
26
- .requiredOption('--project <uuid>', 'Project UUID')
27
- .action(
28
- wrapAction(READ_ONLY_DEFAULT, async function (this: Command) {
29
- const { project } = this.opts() as { project: string };
30
- try {
31
- const client = getClient();
32
- const result = await client.v1.aiAgents.listAgents(project);
33
- console.log(JSON.stringify(result, null, 2));
34
- } catch (error) {
35
- console.error(
36
- 'Error listing agents:',
37
- error instanceof Error ? error.message : String(error),
38
- );
39
- process.exit(1);
40
- }
41
- }),
42
- );
43
-
44
- agentsCmd
45
- .command('get <agentUuid>')
46
- .description('Get a single agent by UUID')
47
- .requiredOption('--project <uuid>', 'Project UUID')
48
- .action(
49
- wrapAction(READ_ONLY_DEFAULT, async (agentUuid: string, cmd: Command) => {
50
- const { project } = cmd.opts() as { project: string };
51
- try {
52
- const client = getClient();
53
- const result = await client.v1.aiAgents.getAgent(project, agentUuid);
54
- console.log(JSON.stringify(result, null, 2));
55
- } catch (error) {
56
- console.error(
57
- 'Error fetching agent:',
58
- error instanceof Error ? error.message : String(error),
59
- );
60
- process.exit(1);
61
- }
62
- }),
63
- );
64
-
65
- agentsCmd
66
- .command('create')
67
- .description('Create a new agent in a project')
68
- .requiredOption('--project <uuid>', 'Project UUID')
69
- .requiredOption('--name <name>', 'Agent name')
70
- .option('--description <text>', 'Agent description')
71
- .option('--instruction <text>', 'System instruction for the agent')
72
- .action(
73
- wrapAction(WRITE_IDEMPOTENT, async function (this: Command) {
74
- const options = this.opts() as {
75
- project: string;
76
- name: string;
77
- description?: string;
78
- instruction?: string;
79
- };
80
- try {
81
- const client = getClient();
82
- const body = {
83
- name: options.name,
84
- projectUuid: options.project,
85
- ...(options.description != null ? { description: options.description } : {}),
86
- ...(options.instruction != null ? { instruction: options.instruction } : {}),
87
- } as Parameters<typeof client.v1.aiAgents.createAgent>[1];
88
- const result = await client.v1.aiAgents.createAgent(options.project, body);
89
- console.log(JSON.stringify(result, null, 2));
90
- } catch (error) {
91
- console.error(
92
- 'Error creating agent:',
93
- error instanceof Error ? error.message : String(error),
94
- );
95
- process.exit(1);
96
- }
97
- }),
98
- );
99
-
100
- agentsCmd
101
- .command('update <agentUuid>')
102
- .description('Update an existing agent')
103
- .requiredOption('--project <uuid>', 'Project UUID')
104
- .option('--name <name>', 'New agent name')
105
- .option('--description <text>', 'New agent description')
106
- .option('--instruction <text>', 'New system instruction')
107
- .action(
108
- wrapAction(WRITE_IDEMPOTENT, async (agentUuid: string, cmd: Command) => {
109
- const options = cmd.opts() as {
110
- project: string;
111
- name?: string;
112
- description?: string;
113
- instruction?: string;
114
- };
115
- const body: Record<string, unknown> = {};
116
- if (options.name != null) body['name'] = options.name;
117
- if (options.description != null) body['description'] = options.description;
118
- if (options.instruction != null) body['instruction'] = options.instruction;
119
- if (Object.keys(body).length === 0) {
120
- console.error('Error: at least one of --name, --description, --instruction is required');
121
- process.exit(1);
122
- }
123
- try {
124
- const client = getClient();
125
- const result = await client.v1.aiAgents.updateAgent(
126
- options.project,
127
- agentUuid,
128
- body as Parameters<typeof client.v1.aiAgents.updateAgent>[2],
129
- );
130
- console.log(JSON.stringify(result, null, 2));
131
- } catch (error) {
132
- console.error(
133
- 'Error updating agent:',
134
- error instanceof Error ? error.message : String(error),
135
- );
136
- process.exit(1);
137
- }
138
- }),
139
- );
140
-
141
- agentsCmd
142
- .command('delete <agentUuid>')
143
- .description('Delete an agent')
144
- .requiredOption('--project <uuid>', 'Project UUID')
145
- .action(
146
- wrapAction(WRITE_DESTRUCTIVE, async (agentUuid: string, cmd: Command) => {
147
- const { project } = cmd.opts() as { project: string };
148
- try {
149
- const client = getClient();
150
- await client.v1.aiAgents.deleteAgent(project, agentUuid);
151
- console.error(`Agent ${agentUuid} deleted successfully`);
152
- } catch (error) {
153
- console.error(
154
- 'Error deleting agent:',
155
- error instanceof Error ? error.message : String(error),
156
- );
157
- process.exit(1);
158
- }
159
- }),
160
- );
161
-
162
- // ─── Thread management ───────────────────────────────────────────────────────
163
-
164
- const threadsCmd = agentsCmd.command('threads').description('Manage agent conversation threads');
165
-
166
- threadsCmd
167
- .command('list <agentUuid>')
168
- .description('List all threads for an agent')
169
- .requiredOption('--project <uuid>', 'Project UUID')
170
- .action(
171
- wrapAction(READ_ONLY_DEFAULT, async (agentUuid: string, cmd: Command) => {
172
- const { project } = cmd.opts() as { project: string };
173
- try {
174
- const client = getClient();
175
- const result = await client.v1.aiAgents.listAgentThreads(project, agentUuid);
176
- console.log(JSON.stringify(result, null, 2));
177
- } catch (error) {
178
- console.error(
179
- 'Error listing threads:',
180
- error instanceof Error ? error.message : String(error),
181
- );
182
- process.exit(1);
183
- }
184
- }),
185
- );
186
-
187
- threadsCmd
188
- .command('get <agentUuid> <threadUuid>')
189
- .description('Get a thread with all its messages')
190
- .requiredOption('--project <uuid>', 'Project UUID')
191
- .action(
192
- wrapAction(READ_ONLY_DEFAULT, async (agentUuid: string, threadUuid: string, cmd: Command) => {
193
- const { project } = cmd.opts() as { project: string };
194
- try {
195
- const client = getClient();
196
- const result = await client.v1.aiAgents.getAgentThread(project, agentUuid, threadUuid);
197
- console.log(JSON.stringify(result, null, 2));
198
- } catch (error) {
199
- console.error(
200
- 'Error fetching thread:',
201
- error instanceof Error ? error.message : String(error),
202
- );
203
- process.exit(1);
204
- }
205
- }),
206
- );
207
-
208
- threadsCmd
209
- .command('generate <agentUuid>')
210
- .description('Start a new thread and generate the first agent response')
211
- .requiredOption('--project <uuid>', 'Project UUID')
212
- .requiredOption('--prompt <text>', 'User prompt')
213
- .action(
214
- wrapAction(WRITE_IDEMPOTENT, async (agentUuid: string, cmd: Command) => {
215
- const options = cmd.opts() as { project: string; prompt: string };
216
- try {
217
- const client = getClient();
218
- // 1. Create thread
219
- const thread = await client.v1.aiAgents.createAgentThread(options.project, agentUuid);
220
- // 2. Generate response
221
- const result = await client.v1.aiAgents.generateAgentThreadResponse(
222
- options.project,
223
- agentUuid,
224
- thread.uuid,
225
- { prompt: options.prompt },
226
- );
227
- console.log(JSON.stringify({ threadUuid: thread.uuid, ...result }, null, 2));
228
- } catch (error) {
229
- console.error(
230
- 'Error generating agent response:',
231
- error instanceof Error ? error.message : String(error),
232
- );
233
- process.exit(1);
234
- }
235
- }),
236
- );
237
-
238
- threadsCmd
239
- .command('continue <agentUuid> <threadUuid>')
240
- .description('Continue an existing thread with a new prompt')
241
- .requiredOption('--project <uuid>', 'Project UUID')
242
- .requiredOption('--prompt <text>', 'User prompt')
243
- .action(
244
- wrapAction(WRITE_IDEMPOTENT, async (agentUuid: string, threadUuid: string, cmd: Command) => {
245
- const options = cmd.opts() as { project: string; prompt: string };
246
- try {
247
- const client = getClient();
248
- const result = await client.v1.aiAgents.generateAgentThreadResponse(
249
- options.project,
250
- agentUuid,
251
- threadUuid,
252
- { prompt: options.prompt },
253
- );
254
- console.log(JSON.stringify(result, null, 2));
255
- } catch (error) {
256
- console.error(
257
- 'Error continuing thread:',
258
- error instanceof Error ? error.message : String(error),
259
- );
260
- process.exit(1);
261
- }
262
- }),
263
- );
264
-
265
- // ─── Evaluations ─────────────────────────────────────────────────────────────
266
-
267
- const evalsCmd = agentsCmd
268
- .command('evals')
269
- .description('Manage agent evaluations and run test suites');
270
-
271
- evalsCmd
272
- .command('list <agentUuid>')
273
- .description('List all evaluations for an agent')
274
- .requiredOption('--project <uuid>', 'Project UUID')
275
- .action(
276
- wrapAction(READ_ONLY_DEFAULT, async (agentUuid: string, cmd: Command) => {
277
- const { project } = cmd.opts() as { project: string };
278
- try {
279
- const client = getClient();
280
- const result = await client.v1.aiAgents.listEvaluations(project, agentUuid);
281
- console.log(JSON.stringify(result, null, 2));
282
- } catch (error) {
283
- console.error(
284
- 'Error listing evaluations:',
285
- error instanceof Error ? error.message : String(error),
286
- );
287
- process.exit(1);
288
- }
289
- }),
290
- );
291
-
292
- evalsCmd
293
- .command('get <agentUuid> <evalUuid>')
294
- .description('Get a full evaluation including its prompts')
295
- .requiredOption('--project <uuid>', 'Project UUID')
296
- .action(
297
- wrapAction(READ_ONLY_DEFAULT, async (agentUuid: string, evalUuid: string, cmd: Command) => {
298
- const { project } = cmd.opts() as { project: string };
299
- try {
300
- const client = getClient();
301
- const result = await client.v1.aiAgents.getEvaluation(project, agentUuid, evalUuid);
302
- console.log(JSON.stringify(result, null, 2));
303
- } catch (error) {
304
- console.error(
305
- 'Error fetching evaluation:',
306
- error instanceof Error ? error.message : String(error),
307
- );
308
- process.exit(1);
309
- }
310
- }),
311
- );
312
-
313
- evalsCmd
314
- .command('create <agentUuid>')
315
- .description('Create a new evaluation with a title and optional prompts (JSON file)')
316
- .requiredOption('--project <uuid>', 'Project UUID')
317
- .requiredOption('--title <title>', 'Evaluation title')
318
- .option('--description <text>', 'Evaluation description')
319
- .option(
320
- '--prompts <json>',
321
- 'JSON array of prompt objects: [{"prompt":"...","expectedResponse":"..."}]',
322
- )
323
- .action(
324
- wrapAction(WRITE_IDEMPOTENT, async (agentUuid: string, cmd: Command) => {
325
- const options = cmd.opts() as {
326
- project: string;
327
- title: string;
328
- description?: string;
329
- prompts?: string;
330
- };
331
- try {
332
- const client = getClient();
333
- const body: Parameters<typeof client.v1.aiAgents.createEvaluation>[2] = {
334
- title: options.title,
335
- prompts: options.prompts ? (JSON.parse(options.prompts) as never) : [],
336
- };
337
- if (options.description != null) body.description = options.description;
338
- const result = await client.v1.aiAgents.createEvaluation(
339
- options.project,
340
- agentUuid,
341
- body,
342
- );
343
- console.log(JSON.stringify(result, null, 2));
344
- } catch (error) {
345
- console.error(
346
- 'Error creating evaluation:',
347
- error instanceof Error ? error.message : String(error),
348
- );
349
- process.exit(1);
350
- }
351
- }),
352
- );
353
-
354
- evalsCmd
355
- .command('update <agentUuid> <evalUuid>')
356
- .description('Update an evaluation title, description, or prompts')
357
- .requiredOption('--project <uuid>', 'Project UUID')
358
- .option('--title <title>', 'New title')
359
- .option('--description <text>', 'New description')
360
- .option('--prompts <json>', 'Replacement JSON array of prompt objects')
361
- .action(
362
- wrapAction(WRITE_IDEMPOTENT, async (agentUuid: string, evalUuid: string, cmd: Command) => {
363
- const options = cmd.opts() as {
364
- project: string;
365
- title?: string;
366
- description?: string;
367
- prompts?: string;
368
- };
369
- const body: Record<string, unknown> = {};
370
- if (options.title != null) body['title'] = options.title;
371
- if (options.description != null) body['description'] = options.description;
372
- if (options.prompts != null) body['prompts'] = JSON.parse(options.prompts);
373
- if (Object.keys(body).length === 0) {
374
- console.error('Error: at least one of --title, --description, --prompts is required');
375
- process.exit(1);
376
- }
377
- try {
378
- const client = getClient();
379
- const result = await client.v1.aiAgents.updateEvaluation(
380
- options.project,
381
- agentUuid,
382
- evalUuid,
383
- body as Parameters<typeof client.v1.aiAgents.updateEvaluation>[3],
384
- );
385
- console.log(JSON.stringify(result, null, 2));
386
- } catch (error) {
387
- console.error(
388
- 'Error updating evaluation:',
389
- error instanceof Error ? error.message : String(error),
390
- );
391
- process.exit(1);
392
- }
393
- }),
394
- );
395
-
396
- evalsCmd
397
- .command('append <agentUuid> <evalUuid>')
398
- .description('Append additional prompts to an existing evaluation')
399
- .requiredOption('--project <uuid>', 'Project UUID')
400
- .requiredOption('--prompts <json>', 'JSON array of prompt objects to append')
401
- .action(
402
- wrapAction(WRITE_IDEMPOTENT, async (agentUuid: string, evalUuid: string, cmd: Command) => {
403
- const options = cmd.opts() as { project: string; prompts: string };
404
- try {
405
- const client = getClient();
406
- await client.v1.aiAgents.appendToEvaluation(options.project, agentUuid, evalUuid, {
407
- prompts: JSON.parse(options.prompts) as never,
408
- });
409
- console.error(`Prompts appended to evaluation ${evalUuid} successfully`);
410
- } catch (error) {
411
- console.error(
412
- 'Error appending to evaluation:',
413
- error instanceof Error ? error.message : String(error),
414
- );
415
- process.exit(1);
416
- }
417
- }),
418
- );
419
-
420
- evalsCmd
421
- .command('delete <agentUuid> <evalUuid>')
422
- .description('Delete an evaluation')
423
- .requiredOption('--project <uuid>', 'Project UUID')
424
- .action(
425
- wrapAction(WRITE_DESTRUCTIVE, async (agentUuid: string, evalUuid: string, cmd: Command) => {
426
- const { project } = cmd.opts() as { project: string };
427
- try {
428
- const client = getClient();
429
- await client.v1.aiAgents.deleteEvaluation(project, agentUuid, evalUuid);
430
- console.error(`Evaluation ${evalUuid} deleted successfully`);
431
- } catch (error) {
432
- console.error(
433
- 'Error deleting evaluation:',
434
- error instanceof Error ? error.message : String(error),
435
- );
436
- process.exit(1);
437
- }
438
- }),
439
- );
440
-
441
- evalsCmd
442
- .command('run <agentUuid> <evalUuid>')
443
- .description('Trigger a new evaluation run')
444
- .requiredOption('--project <uuid>', 'Project UUID')
445
- .action(
446
- wrapAction(WRITE_IDEMPOTENT, async (agentUuid: string, evalUuid: string, cmd: Command) => {
447
- const { project } = cmd.opts() as { project: string };
448
- try {
449
- const client = getClient();
450
- const result = await client.v1.aiAgents.runEvaluation(project, agentUuid, evalUuid);
451
- console.log(JSON.stringify(result, null, 2));
452
- } catch (error) {
453
- console.error(
454
- 'Error running evaluation:',
455
- error instanceof Error ? error.message : String(error),
456
- );
457
- process.exit(1);
458
- }
459
- }),
460
- );
461
-
462
- evalsCmd
463
- .command('runs <agentUuid> <evalUuid>')
464
- .description('List all runs for an evaluation')
465
- .requiredOption('--project <uuid>', 'Project UUID')
466
- .action(
467
- wrapAction(READ_ONLY_DEFAULT, async (agentUuid: string, evalUuid: string, cmd: Command) => {
468
- const { project } = cmd.opts() as { project: string };
469
- try {
470
- const client = getClient();
471
- const result = await client.v1.aiAgents.listEvaluationRuns(project, agentUuid, evalUuid);
472
- console.log(JSON.stringify(result, null, 2));
473
- } catch (error) {
474
- console.error(
475
- 'Error listing evaluation runs:',
476
- error instanceof Error ? error.message : String(error),
477
- );
478
- process.exit(1);
479
- }
480
- }),
481
- );
482
-
483
- evalsCmd
484
- .command('run-results <agentUuid> <evalUuid> <runUuid>')
485
- .description('Get detailed results for a specific evaluation run')
486
- .requiredOption('--project <uuid>', 'Project UUID')
487
- .action(
488
- wrapAction(
489
- READ_ONLY_DEFAULT,
490
- async (agentUuid: string, evalUuid: string, runUuid: string, cmd: Command) => {
491
- const { project } = cmd.opts() as { project: string };
492
- try {
493
- const client = getClient();
494
- const result = await client.v1.aiAgents.getEvaluationRunResults(
495
- project,
496
- agentUuid,
497
- evalUuid,
498
- runUuid,
499
- );
500
- console.log(JSON.stringify(result, null, 2));
501
- } catch (error) {
502
- console.error(
503
- 'Error fetching evaluation run results:',
504
- error instanceof Error ? error.message : String(error),
505
- );
506
- process.exit(1);
507
- }
508
- },
509
- ),
510
- );
23
+ registerAgentsCrudCommands(agentsCmd);
24
+ registerAgentsDiscoveryCommands(agentsCmd);
25
+ registerAgentsThreadCommands(agentsCmd);
26
+ registerAgentsEvalCommands(agentsCmd);
511
27
  }
@@ -2,12 +2,45 @@
2
2
  * AI agents (v1) command implementation — admin endpoints.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
- import type { GetAdminThreadsParams, UpdateAiOrganizationSettings } from '@lightdash-tools/common';
7
5
  import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from '@lightdash-tools/common';
6
+
7
+ import { pickDefined } from '../utils/cli-params';
8
8
  import { getClient } from '../utils/client';
9
9
  import { wrapAction } from '../utils/safety';
10
10
 
11
+ import type { GetAdminThreadsParams, UpdateAiOrganizationSettings } from '@lightdash-tools/common';
12
+ import type { Command } from 'commander';
13
+
14
+ type AdminThreadsCliOptions = {
15
+ page?: number;
16
+ pageSize?: number;
17
+ agent?: string[];
18
+ project?: string[];
19
+ humanScore?: number;
20
+ dateFrom?: string;
21
+ dateTo?: string;
22
+ sort?: string;
23
+ sortDirection?: string;
24
+ };
25
+
26
+ function buildAdminThreadsParams(
27
+ options: AdminThreadsCliOptions,
28
+ ): GetAdminThreadsParams | undefined {
29
+ return pickDefined({
30
+ page: options.page,
31
+ pageSize: options.pageSize,
32
+ agentUuids: options.agent,
33
+ projectUuids: options.project,
34
+ humanScore: options.humanScore,
35
+ dateFrom: options.dateFrom,
36
+ dateTo: options.dateTo,
37
+ sortField:
38
+ options.sort != null ? (options.sort as GetAdminThreadsParams['sortField']) : undefined,
39
+ sortDirection:
40
+ options.sortDirection != null ? (options.sortDirection as 'asc' | 'desc') : undefined,
41
+ }) as GetAdminThreadsParams | undefined;
42
+ }
43
+
11
44
  /**
12
45
  * Registers the top-level ai-agents command and its subcommands (admin scope).
13
46
  */
@@ -57,34 +90,10 @@ export function registerAiAgentsCommand(program: Command): void {
57
90
  .option('--sort-direction <dir>', 'Sort direction: asc | desc')
58
91
  .action(
59
92
  wrapAction(READ_ONLY_DEFAULT, async function (this: Command) {
60
- const options = this.opts() as {
61
- page?: number;
62
- pageSize?: number;
63
- agent?: string[];
64
- project?: string[];
65
- humanScore?: number;
66
- dateFrom?: string;
67
- dateTo?: string;
68
- sort?: string;
69
- sortDirection?: string;
70
- };
93
+ const options = this.opts() as AdminThreadsCliOptions;
71
94
  try {
72
95
  const client = getClient();
73
- const params: GetAdminThreadsParams = {};
74
- if (options.page != null) params.page = options.page;
75
- if (options.pageSize != null) params.pageSize = options.pageSize;
76
- if (options.agent != null) params.agentUuids = options.agent;
77
- if (options.project != null) params.projectUuids = options.project;
78
- if (options.humanScore != null) params.humanScore = options.humanScore;
79
- if (options.dateFrom != null) params.dateFrom = options.dateFrom;
80
- if (options.dateTo != null) params.dateTo = options.dateTo;
81
- if (options.sort != null)
82
- params.sortField = options.sort as GetAdminThreadsParams['sortField'];
83
- if (options.sortDirection != null)
84
- params.sortDirection = options.sortDirection as 'asc' | 'desc';
85
- const result = await client.v1.aiAgents.getAdminThreads(
86
- Object.keys(params).length > 0 ? params : undefined,
87
- );
96
+ const result = await client.v1.aiAgents.getAdminThreads(buildAdminThreadsParams(options));
88
97
  console.log(JSON.stringify(result, null, 2));
89
98
  } catch (error) {
90
99
  console.error(
@@ -2,12 +2,15 @@
2
2
  * Charts (v1) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { readFileSync } from 'fs';
6
+
7
7
  import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from '@lightdash-tools/common';
8
+
8
9
  import { getClient } from '../utils/client';
9
10
  import { wrapAction } from '../utils/safety';
11
+
10
12
  import type { UpsertChartAsCodeBody } from '@lightdash-tools/common';
13
+ import type { Command } from 'commander';
11
14
 
12
15
  /**
13
16
  * Reads JSON from stdin or a file (for chart-as-code upsert body).
@@ -58,12 +61,12 @@ export function registerChartsCommand(program: Command): void {
58
61
 
59
62
  chartsCmd
60
63
  .command('list <projectUuid>')
61
- .description('List charts in a project')
64
+ .description('List charts in a project (using charts-as-code API)')
62
65
  .action(
63
66
  wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string) => {
64
67
  try {
65
68
  const client = getClient();
66
- const result = await client.v1.charts.listCharts(projectUuid);
69
+ const result = await client.v1.charts.getChartsAsCode(projectUuid);
67
70
  console.log(JSON.stringify(result, null, 2));
68
71
  } catch (error) {
69
72
  console.error(
@@ -2,11 +2,13 @@
2
2
  * Content command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the content command and its subcommands.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Dashboards (v1) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the projects dashboards subcommands under the existing projects command.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Explores (v1) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the projects explores subcommands under the existing projects command.
12
14
  */