@lightdash-tools/cli 0.2.6 → 0.3.1

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.
@@ -0,0 +1,511 @@
1
+ /**
2
+ * Project-scoped AI agents command implementation.
3
+ *
4
+ * Covers: agent CRUD, thread management, and evaluation lifecycle.
5
+ * All commands require --project <projectUuid>.
6
+ */
7
+
8
+ 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
+
13
+ /**
14
+ * Registers the `agents` command group (project-scoped).
15
+ */
16
+ export function registerAgentsCommand(program: Command): void {
17
+ const agentsCmd = program
18
+ .command('agents')
19
+ .description('Manage AI agents within a project (project-scoped)');
20
+
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
+ );
511
+ }
@@ -1,21 +1,24 @@
1
1
  /**
2
- * AI agents (v1) command implementation.
2
+ * AI agents (v1) command implementation — admin endpoints.
3
3
  */
4
4
 
5
5
  import type { Command } from 'commander';
6
- import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+ import type { GetAdminThreadsParams, UpdateAiOrganizationSettings } from '@lightdash-tools/common';
7
+ import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from '@lightdash-tools/common';
7
8
  import { getClient } from '../utils/client';
8
9
  import { wrapAction } from '../utils/safety';
9
10
 
10
11
  /**
11
- * Registers the top-level ai-agents command and its subcommands.
12
+ * Registers the top-level ai-agents command and its subcommands (admin scope).
12
13
  */
13
14
  export function registerAiAgentsCommand(program: Command): void {
14
- const aiAgentsCmd = program.command('ai-agents').description('Manage AI agents (admin, v1)');
15
+ const aiAgentsCmd = program
16
+ .command('ai-agents')
17
+ .description('Manage AI agents — admin endpoints (cross-project)');
15
18
 
16
19
  aiAgentsCmd
17
20
  .command('list')
18
- .description('List all AI agents (admin)')
21
+ .description('List all AI agents across the organization (admin)')
19
22
  .action(
20
23
  wrapAction(READ_ONLY_DEFAULT, async () => {
21
24
  try {
@@ -34,17 +37,51 @@ export function registerAiAgentsCommand(program: Command): void {
34
37
 
35
38
  aiAgentsCmd
36
39
  .command('threads')
37
- .description('List AI agent threads (admin)')
40
+ .description('List AI agent threads across the organization (admin)')
38
41
  .option('--page <number>', 'Page number', (v: string) => parseInt(v, 10))
39
42
  .option('--page-size <number>', 'Page size', (v: string) => parseInt(v, 10))
43
+ .option('--agent <uuid>', 'Filter by agent UUID (repeatable)', (v, prev: string[]) => [
44
+ ...(prev ?? []),
45
+ v,
46
+ ])
47
+ .option('--project <uuid>', 'Filter by project UUID (repeatable)', (v, prev: string[]) => [
48
+ ...(prev ?? []),
49
+ v,
50
+ ])
51
+ .option('--human-score <number>', 'Filter by human score (-1, 0, or 1)', (v: string) =>
52
+ parseInt(v, 10),
53
+ )
54
+ .option('--date-from <date>', 'Start date filter (YYYY-MM-DD)')
55
+ .option('--date-to <date>', 'End date filter (YYYY-MM-DD)')
56
+ .option('--sort <field>', 'Sort field: createdAt | title')
57
+ .option('--sort-direction <dir>', 'Sort direction: asc | desc')
40
58
  .action(
41
59
  wrapAction(READ_ONLY_DEFAULT, async function (this: Command) {
42
- const options = this.opts() as { page?: number; pageSize?: number };
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
+ };
43
71
  try {
44
72
  const client = getClient();
45
- const params: { page?: number; pageSize?: number } = {};
73
+ const params: GetAdminThreadsParams = {};
46
74
  if (options.page != null) params.page = options.page;
47
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';
48
85
  const result = await client.v1.aiAgents.getAdminThreads(
49
86
  Object.keys(params).length > 0 ? params : undefined,
50
87
  );
@@ -59,8 +96,12 @@ export function registerAiAgentsCommand(program: Command): void {
59
96
  }),
60
97
  );
61
98
 
62
- aiAgentsCmd
99
+ const settingsCmd = aiAgentsCmd
63
100
  .command('settings')
101
+ .description('Manage AI organization settings');
102
+
103
+ settingsCmd
104
+ .command('get')
64
105
  .description('Get AI organization settings')
65
106
  .action(
66
107
  wrapAction(READ_ONLY_DEFAULT, async () => {
@@ -77,4 +118,41 @@ export function registerAiAgentsCommand(program: Command): void {
77
118
  }
78
119
  }),
79
120
  );
121
+
122
+ settingsCmd
123
+ .command('update')
124
+ .description('Update AI organization settings')
125
+ .option('--ai-agents-visible <bool>', 'Show/hide AI agents feature (true|false)')
126
+ .action(
127
+ wrapAction(WRITE_IDEMPOTENT, async function (this: Command) {
128
+ const options = this.opts() as { aiAgentsVisible?: string };
129
+ const body: Partial<UpdateAiOrganizationSettings> = {};
130
+ if (options.aiAgentsVisible != null) {
131
+ if (options.aiAgentsVisible !== 'true' && options.aiAgentsVisible !== 'false') {
132
+ console.error(
133
+ `Error: --ai-agents-visible must be 'true' or 'false', got: '${options.aiAgentsVisible}'`,
134
+ );
135
+ process.exit(1);
136
+ }
137
+ (body as Record<string, unknown>)['aiAgentsVisible'] = options.aiAgentsVisible === 'true';
138
+ }
139
+ if (Object.keys(body).length === 0) {
140
+ console.error('Error: at least one option is required (e.g. --ai-agents-visible)');
141
+ process.exit(1);
142
+ }
143
+ try {
144
+ const client = getClient();
145
+ const result = await client.v1.aiAgents.updateAiOrganizationSettings(
146
+ body as UpdateAiOrganizationSettings,
147
+ );
148
+ console.log(JSON.stringify(result, null, 2));
149
+ } catch (error) {
150
+ console.error(
151
+ 'Error updating AI organization settings:',
152
+ error instanceof Error ? error.message : String(error),
153
+ );
154
+ process.exit(1);
155
+ }
156
+ }),
157
+ );
80
158
  }
@@ -16,7 +16,7 @@ export function registerContentCommand(program: Command): void {
16
16
  contentCmd
17
17
  .command('search <query>')
18
18
  .description('Search project content (charts, dashboards, spaces)')
19
- .option('--project <uuids...>', 'Filter by project UUIDs')
19
+ .option('--projects <uuids...>', 'Filter by project UUIDs')
20
20
  .option('--type <types...>', 'Filter by content types (chart, dashboard, space)')
21
21
  .option('--page <number>', 'Page number', (v) => parseInt(v, 10))
22
22
  .option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
@@ -26,7 +26,7 @@ export function registerContentCommand(program: Command): void {
26
26
  async (
27
27
  query: string,
28
28
  options: {
29
- project?: string[];
29
+ projects?: string[];
30
30
  type?: ('chart' | 'dashboard' | 'space')[];
31
31
  page?: number;
32
32
  pageSize?: number;
@@ -36,7 +36,7 @@ export function registerContentCommand(program: Command): void {
36
36
  const client = getClient();
37
37
  const result = await client.v2.content.searchContent({
38
38
  search: query,
39
- projectUuids: options.project,
39
+ projectUuids: options.projects,
40
40
  contentTypes: options.type,
41
41
  page: options.page,
42
42
  pageSize: options.pageSize,