@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
@@ -5,20 +5,12 @@
5
5
  * Covers: agent CRUD, thread management, and evaluation lifecycle.
6
6
  * All commands require --project <projectUuid>.
7
7
  */
8
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
8
  Object.defineProperty(exports, "__esModule", { value: true });
18
9
  exports.registerAgentsCommand = registerAgentsCommand;
19
- const common_1 = require("@lightdash-tools/common");
20
- const client_1 = require("../utils/client");
21
- const safety_1 = require("../utils/safety");
10
+ const agents_crud_1 = require("./agents-crud");
11
+ const agents_discovery_1 = require("./agents-discovery");
12
+ const agents_evals_1 = require("./agents-evals");
13
+ const agents_threads_1 = require("./agents-threads");
22
14
  /**
23
15
  * Registers the `agents` command group (project-scoped).
24
16
  */
@@ -26,352 +18,8 @@ function registerAgentsCommand(program) {
26
18
  const agentsCmd = program
27
19
  .command('agents')
28
20
  .description('Manage AI agents within a project (project-scoped)');
29
- // ─── Agent CRUD ──────────────────────────────────────────────────────────────
30
- agentsCmd
31
- .command('list')
32
- .description('List all agents in a project')
33
- .requiredOption('--project <uuid>', 'Project UUID')
34
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const { project } = this.opts();
37
- try {
38
- const client = (0, client_1.getClient)();
39
- const result = yield client.v1.aiAgents.listAgents(project);
40
- console.log(JSON.stringify(result, null, 2));
41
- }
42
- catch (error) {
43
- console.error('Error listing agents:', error instanceof Error ? error.message : String(error));
44
- process.exit(1);
45
- }
46
- });
47
- }));
48
- agentsCmd
49
- .command('get <agentUuid>')
50
- .description('Get a single agent by UUID')
51
- .requiredOption('--project <uuid>', 'Project UUID')
52
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (agentUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
53
- const { project } = cmd.opts();
54
- try {
55
- const client = (0, client_1.getClient)();
56
- const result = yield client.v1.aiAgents.getAgent(project, agentUuid);
57
- console.log(JSON.stringify(result, null, 2));
58
- }
59
- catch (error) {
60
- console.error('Error fetching agent:', error instanceof Error ? error.message : String(error));
61
- process.exit(1);
62
- }
63
- })));
64
- agentsCmd
65
- .command('create')
66
- .description('Create a new agent in a project')
67
- .requiredOption('--project <uuid>', 'Project UUID')
68
- .requiredOption('--name <name>', 'Agent name')
69
- .option('--description <text>', 'Agent description')
70
- .option('--instruction <text>', 'System instruction for the agent')
71
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, function () {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const options = this.opts();
74
- try {
75
- const client = (0, client_1.getClient)();
76
- const body = Object.assign(Object.assign({ name: options.name, projectUuid: options.project }, (options.description != null ? { description: options.description } : {})), (options.instruction != null ? { instruction: options.instruction } : {}));
77
- const result = yield client.v1.aiAgents.createAgent(options.project, body);
78
- console.log(JSON.stringify(result, null, 2));
79
- }
80
- catch (error) {
81
- console.error('Error creating agent:', error instanceof Error ? error.message : String(error));
82
- process.exit(1);
83
- }
84
- });
85
- }));
86
- agentsCmd
87
- .command('update <agentUuid>')
88
- .description('Update an existing agent')
89
- .requiredOption('--project <uuid>', 'Project UUID')
90
- .option('--name <name>', 'New agent name')
91
- .option('--description <text>', 'New agent description')
92
- .option('--instruction <text>', 'New system instruction')
93
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (agentUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
94
- const options = cmd.opts();
95
- const body = {};
96
- if (options.name != null)
97
- body['name'] = options.name;
98
- if (options.description != null)
99
- body['description'] = options.description;
100
- if (options.instruction != null)
101
- body['instruction'] = options.instruction;
102
- if (Object.keys(body).length === 0) {
103
- console.error('Error: at least one of --name, --description, --instruction is required');
104
- process.exit(1);
105
- }
106
- try {
107
- const client = (0, client_1.getClient)();
108
- const result = yield client.v1.aiAgents.updateAgent(options.project, agentUuid, body);
109
- console.log(JSON.stringify(result, null, 2));
110
- }
111
- catch (error) {
112
- console.error('Error updating agent:', error instanceof Error ? error.message : String(error));
113
- process.exit(1);
114
- }
115
- })));
116
- agentsCmd
117
- .command('delete <agentUuid>')
118
- .description('Delete an agent')
119
- .requiredOption('--project <uuid>', 'Project UUID')
120
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (agentUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
121
- const { project } = cmd.opts();
122
- try {
123
- const client = (0, client_1.getClient)();
124
- yield client.v1.aiAgents.deleteAgent(project, agentUuid);
125
- console.error(`Agent ${agentUuid} deleted successfully`);
126
- }
127
- catch (error) {
128
- console.error('Error deleting agent:', error instanceof Error ? error.message : String(error));
129
- process.exit(1);
130
- }
131
- })));
132
- // ─── Thread management ───────────────────────────────────────────────────────
133
- const threadsCmd = agentsCmd.command('threads').description('Manage agent conversation threads');
134
- threadsCmd
135
- .command('list <agentUuid>')
136
- .description('List all threads for an agent')
137
- .requiredOption('--project <uuid>', 'Project UUID')
138
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (agentUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
139
- const { project } = cmd.opts();
140
- try {
141
- const client = (0, client_1.getClient)();
142
- const result = yield client.v1.aiAgents.listAgentThreads(project, agentUuid);
143
- console.log(JSON.stringify(result, null, 2));
144
- }
145
- catch (error) {
146
- console.error('Error listing threads:', error instanceof Error ? error.message : String(error));
147
- process.exit(1);
148
- }
149
- })));
150
- threadsCmd
151
- .command('get <agentUuid> <threadUuid>')
152
- .description('Get a thread with all its messages')
153
- .requiredOption('--project <uuid>', 'Project UUID')
154
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (agentUuid, threadUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
155
- const { project } = cmd.opts();
156
- try {
157
- const client = (0, client_1.getClient)();
158
- const result = yield client.v1.aiAgents.getAgentThread(project, agentUuid, threadUuid);
159
- console.log(JSON.stringify(result, null, 2));
160
- }
161
- catch (error) {
162
- console.error('Error fetching thread:', error instanceof Error ? error.message : String(error));
163
- process.exit(1);
164
- }
165
- })));
166
- threadsCmd
167
- .command('generate <agentUuid>')
168
- .description('Start a new thread and generate the first agent response')
169
- .requiredOption('--project <uuid>', 'Project UUID')
170
- .requiredOption('--prompt <text>', 'User prompt')
171
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (agentUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
172
- const options = cmd.opts();
173
- try {
174
- const client = (0, client_1.getClient)();
175
- // 1. Create thread
176
- const thread = yield client.v1.aiAgents.createAgentThread(options.project, agentUuid);
177
- // 2. Generate response
178
- const result = yield client.v1.aiAgents.generateAgentThreadResponse(options.project, agentUuid, thread.uuid, { prompt: options.prompt });
179
- console.log(JSON.stringify(Object.assign({ threadUuid: thread.uuid }, result), null, 2));
180
- }
181
- catch (error) {
182
- console.error('Error generating agent response:', error instanceof Error ? error.message : String(error));
183
- process.exit(1);
184
- }
185
- })));
186
- threadsCmd
187
- .command('continue <agentUuid> <threadUuid>')
188
- .description('Continue an existing thread with a new prompt')
189
- .requiredOption('--project <uuid>', 'Project UUID')
190
- .requiredOption('--prompt <text>', 'User prompt')
191
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (agentUuid, threadUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
192
- const options = cmd.opts();
193
- try {
194
- const client = (0, client_1.getClient)();
195
- const result = yield client.v1.aiAgents.generateAgentThreadResponse(options.project, agentUuid, threadUuid, { prompt: options.prompt });
196
- console.log(JSON.stringify(result, null, 2));
197
- }
198
- catch (error) {
199
- console.error('Error continuing thread:', error instanceof Error ? error.message : String(error));
200
- process.exit(1);
201
- }
202
- })));
203
- // ─── Evaluations ─────────────────────────────────────────────────────────────
204
- const evalsCmd = agentsCmd
205
- .command('evals')
206
- .description('Manage agent evaluations and run test suites');
207
- evalsCmd
208
- .command('list <agentUuid>')
209
- .description('List all evaluations for an agent')
210
- .requiredOption('--project <uuid>', 'Project UUID')
211
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (agentUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
212
- const { project } = cmd.opts();
213
- try {
214
- const client = (0, client_1.getClient)();
215
- const result = yield client.v1.aiAgents.listEvaluations(project, agentUuid);
216
- console.log(JSON.stringify(result, null, 2));
217
- }
218
- catch (error) {
219
- console.error('Error listing evaluations:', error instanceof Error ? error.message : String(error));
220
- process.exit(1);
221
- }
222
- })));
223
- evalsCmd
224
- .command('get <agentUuid> <evalUuid>')
225
- .description('Get a full evaluation including its prompts')
226
- .requiredOption('--project <uuid>', 'Project UUID')
227
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (agentUuid, evalUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
228
- const { project } = cmd.opts();
229
- try {
230
- const client = (0, client_1.getClient)();
231
- const result = yield client.v1.aiAgents.getEvaluation(project, agentUuid, evalUuid);
232
- console.log(JSON.stringify(result, null, 2));
233
- }
234
- catch (error) {
235
- console.error('Error fetching evaluation:', error instanceof Error ? error.message : String(error));
236
- process.exit(1);
237
- }
238
- })));
239
- evalsCmd
240
- .command('create <agentUuid>')
241
- .description('Create a new evaluation with a title and optional prompts (JSON file)')
242
- .requiredOption('--project <uuid>', 'Project UUID')
243
- .requiredOption('--title <title>', 'Evaluation title')
244
- .option('--description <text>', 'Evaluation description')
245
- .option('--prompts <json>', 'JSON array of prompt objects: [{"prompt":"...","expectedResponse":"..."}]')
246
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (agentUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
247
- const options = cmd.opts();
248
- try {
249
- const client = (0, client_1.getClient)();
250
- const body = {
251
- title: options.title,
252
- prompts: options.prompts ? JSON.parse(options.prompts) : [],
253
- };
254
- if (options.description != null)
255
- body.description = options.description;
256
- const result = yield client.v1.aiAgents.createEvaluation(options.project, agentUuid, body);
257
- console.log(JSON.stringify(result, null, 2));
258
- }
259
- catch (error) {
260
- console.error('Error creating evaluation:', error instanceof Error ? error.message : String(error));
261
- process.exit(1);
262
- }
263
- })));
264
- evalsCmd
265
- .command('update <agentUuid> <evalUuid>')
266
- .description('Update an evaluation title, description, or prompts')
267
- .requiredOption('--project <uuid>', 'Project UUID')
268
- .option('--title <title>', 'New title')
269
- .option('--description <text>', 'New description')
270
- .option('--prompts <json>', 'Replacement JSON array of prompt objects')
271
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (agentUuid, evalUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
272
- const options = cmd.opts();
273
- const body = {};
274
- if (options.title != null)
275
- body['title'] = options.title;
276
- if (options.description != null)
277
- body['description'] = options.description;
278
- if (options.prompts != null)
279
- body['prompts'] = JSON.parse(options.prompts);
280
- if (Object.keys(body).length === 0) {
281
- console.error('Error: at least one of --title, --description, --prompts is required');
282
- process.exit(1);
283
- }
284
- try {
285
- const client = (0, client_1.getClient)();
286
- const result = yield client.v1.aiAgents.updateEvaluation(options.project, agentUuid, evalUuid, body);
287
- console.log(JSON.stringify(result, null, 2));
288
- }
289
- catch (error) {
290
- console.error('Error updating evaluation:', error instanceof Error ? error.message : String(error));
291
- process.exit(1);
292
- }
293
- })));
294
- evalsCmd
295
- .command('append <agentUuid> <evalUuid>')
296
- .description('Append additional prompts to an existing evaluation')
297
- .requiredOption('--project <uuid>', 'Project UUID')
298
- .requiredOption('--prompts <json>', 'JSON array of prompt objects to append')
299
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (agentUuid, evalUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
300
- const options = cmd.opts();
301
- try {
302
- const client = (0, client_1.getClient)();
303
- yield client.v1.aiAgents.appendToEvaluation(options.project, agentUuid, evalUuid, {
304
- prompts: JSON.parse(options.prompts),
305
- });
306
- console.error(`Prompts appended to evaluation ${evalUuid} successfully`);
307
- }
308
- catch (error) {
309
- console.error('Error appending to evaluation:', error instanceof Error ? error.message : String(error));
310
- process.exit(1);
311
- }
312
- })));
313
- evalsCmd
314
- .command('delete <agentUuid> <evalUuid>')
315
- .description('Delete an evaluation')
316
- .requiredOption('--project <uuid>', 'Project UUID')
317
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (agentUuid, evalUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
318
- const { project } = cmd.opts();
319
- try {
320
- const client = (0, client_1.getClient)();
321
- yield client.v1.aiAgents.deleteEvaluation(project, agentUuid, evalUuid);
322
- console.error(`Evaluation ${evalUuid} deleted successfully`);
323
- }
324
- catch (error) {
325
- console.error('Error deleting evaluation:', error instanceof Error ? error.message : String(error));
326
- process.exit(1);
327
- }
328
- })));
329
- evalsCmd
330
- .command('run <agentUuid> <evalUuid>')
331
- .description('Trigger a new evaluation run')
332
- .requiredOption('--project <uuid>', 'Project UUID')
333
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (agentUuid, evalUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
334
- const { project } = cmd.opts();
335
- try {
336
- const client = (0, client_1.getClient)();
337
- const result = yield client.v1.aiAgents.runEvaluation(project, agentUuid, evalUuid);
338
- console.log(JSON.stringify(result, null, 2));
339
- }
340
- catch (error) {
341
- console.error('Error running evaluation:', error instanceof Error ? error.message : String(error));
342
- process.exit(1);
343
- }
344
- })));
345
- evalsCmd
346
- .command('runs <agentUuid> <evalUuid>')
347
- .description('List all runs for an evaluation')
348
- .requiredOption('--project <uuid>', 'Project UUID')
349
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (agentUuid, evalUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
350
- const { project } = cmd.opts();
351
- try {
352
- const client = (0, client_1.getClient)();
353
- const result = yield client.v1.aiAgents.listEvaluationRuns(project, agentUuid, evalUuid);
354
- console.log(JSON.stringify(result, null, 2));
355
- }
356
- catch (error) {
357
- console.error('Error listing evaluation runs:', error instanceof Error ? error.message : String(error));
358
- process.exit(1);
359
- }
360
- })));
361
- evalsCmd
362
- .command('run-results <agentUuid> <evalUuid> <runUuid>')
363
- .description('Get detailed results for a specific evaluation run')
364
- .requiredOption('--project <uuid>', 'Project UUID')
365
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (agentUuid, evalUuid, runUuid, cmd) => __awaiter(this, void 0, void 0, function* () {
366
- const { project } = cmd.opts();
367
- try {
368
- const client = (0, client_1.getClient)();
369
- const result = yield client.v1.aiAgents.getEvaluationRunResults(project, agentUuid, evalUuid, runUuid);
370
- console.log(JSON.stringify(result, null, 2));
371
- }
372
- catch (error) {
373
- console.error('Error fetching evaluation run results:', error instanceof Error ? error.message : String(error));
374
- process.exit(1);
375
- }
376
- })));
21
+ (0, agents_crud_1.registerAgentsCrudCommands)(agentsCmd);
22
+ (0, agents_discovery_1.registerAgentsDiscoveryCommands)(agentsCmd);
23
+ (0, agents_threads_1.registerAgentsThreadCommands)(agentsCmd);
24
+ (0, agents_evals_1.registerAgentsEvalCommands)(agentsCmd);
377
25
  }
@@ -2,20 +2,25 @@
2
2
  /**
3
3
  * AI agents (v1) command implementation — admin endpoints.
4
4
  */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.registerAiAgentsCommand = registerAiAgentsCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
8
+ const cli_params_1 = require("../utils/cli-params");
17
9
  const client_1 = require("../utils/client");
18
10
  const safety_1 = require("../utils/safety");
11
+ function buildAdminThreadsParams(options) {
12
+ return (0, cli_params_1.pickDefined)({
13
+ page: options.page,
14
+ pageSize: options.pageSize,
15
+ agentUuids: options.agent,
16
+ projectUuids: options.project,
17
+ humanScore: options.humanScore,
18
+ dateFrom: options.dateFrom,
19
+ dateTo: options.dateTo,
20
+ sortField: options.sort != null ? options.sort : undefined,
21
+ sortDirection: options.sortDirection != null ? options.sortDirection : undefined,
22
+ });
23
+ }
19
24
  /**
20
25
  * Registers the top-level ai-agents command and its subcommands (admin scope).
21
26
  */
@@ -26,17 +31,17 @@ function registerAiAgentsCommand(program) {
26
31
  aiAgentsCmd
27
32
  .command('list')
28
33
  .description('List all AI agents across the organization (admin)')
29
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
34
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async () => {
30
35
  try {
31
36
  const client = (0, client_1.getClient)();
32
- const result = yield client.v1.aiAgents.listAdminAgents();
37
+ const result = await client.v1.aiAgents.listAdminAgents();
33
38
  console.log(JSON.stringify(result, null, 2));
34
39
  }
35
40
  catch (error) {
36
41
  console.error('Error listing AI agents:', error instanceof Error ? error.message : String(error));
37
42
  process.exit(1);
38
43
  }
39
- })));
44
+ }));
40
45
  aiAgentsCmd
41
46
  .command('threads')
42
47
  .description('List AI agent threads across the organization (admin)')
@@ -55,38 +60,17 @@ function registerAiAgentsCommand(program) {
55
60
  .option('--date-to <date>', 'End date filter (YYYY-MM-DD)')
56
61
  .option('--sort <field>', 'Sort field: createdAt | title')
57
62
  .option('--sort-direction <dir>', 'Sort direction: asc | desc')
58
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- const options = this.opts();
61
- try {
62
- const client = (0, client_1.getClient)();
63
- const params = {};
64
- if (options.page != null)
65
- params.page = options.page;
66
- if (options.pageSize != null)
67
- params.pageSize = options.pageSize;
68
- if (options.agent != null)
69
- params.agentUuids = options.agent;
70
- if (options.project != null)
71
- params.projectUuids = options.project;
72
- if (options.humanScore != null)
73
- params.humanScore = options.humanScore;
74
- if (options.dateFrom != null)
75
- params.dateFrom = options.dateFrom;
76
- if (options.dateTo != null)
77
- params.dateTo = options.dateTo;
78
- if (options.sort != null)
79
- params.sortField = options.sort;
80
- if (options.sortDirection != null)
81
- params.sortDirection = options.sortDirection;
82
- const result = yield client.v1.aiAgents.getAdminThreads(Object.keys(params).length > 0 ? params : undefined);
83
- console.log(JSON.stringify(result, null, 2));
84
- }
85
- catch (error) {
86
- console.error('Error listing AI agent threads:', error instanceof Error ? error.message : String(error));
87
- process.exit(1);
88
- }
89
- });
63
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async function () {
64
+ const options = this.opts();
65
+ try {
66
+ const client = (0, client_1.getClient)();
67
+ const result = await client.v1.aiAgents.getAdminThreads(buildAdminThreadsParams(options));
68
+ console.log(JSON.stringify(result, null, 2));
69
+ }
70
+ catch (error) {
71
+ console.error('Error listing AI agent threads:', error instanceof Error ? error.message : String(error));
72
+ process.exit(1);
73
+ }
90
74
  }));
91
75
  const settingsCmd = aiAgentsCmd
92
76
  .command('settings')
@@ -94,45 +78,43 @@ function registerAiAgentsCommand(program) {
94
78
  settingsCmd
95
79
  .command('get')
96
80
  .description('Get AI organization settings')
97
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => __awaiter(this, void 0, void 0, function* () {
81
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async () => {
98
82
  try {
99
83
  const client = (0, client_1.getClient)();
100
- const result = yield client.v1.aiAgents.getAiOrganizationSettings();
84
+ const result = await client.v1.aiAgents.getAiOrganizationSettings();
101
85
  console.log(JSON.stringify(result, null, 2));
102
86
  }
103
87
  catch (error) {
104
88
  console.error('Error fetching AI organization settings:', error instanceof Error ? error.message : String(error));
105
89
  process.exit(1);
106
90
  }
107
- })));
91
+ }));
108
92
  settingsCmd
109
93
  .command('update')
110
94
  .description('Update AI organization settings')
111
95
  .option('--ai-agents-visible <bool>', 'Show/hide AI agents feature (true|false)')
112
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, function () {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- const options = this.opts();
115
- const body = {};
116
- if (options.aiAgentsVisible != null) {
117
- if (options.aiAgentsVisible !== 'true' && options.aiAgentsVisible !== 'false') {
118
- console.error(`Error: --ai-agents-visible must be 'true' or 'false', got: '${options.aiAgentsVisible}'`);
119
- process.exit(1);
120
- }
121
- body['aiAgentsVisible'] = options.aiAgentsVisible === 'true';
122
- }
123
- if (Object.keys(body).length === 0) {
124
- console.error('Error: at least one option is required (e.g. --ai-agents-visible)');
125
- process.exit(1);
126
- }
127
- try {
128
- const client = (0, client_1.getClient)();
129
- const result = yield client.v1.aiAgents.updateAiOrganizationSettings(body);
130
- console.log(JSON.stringify(result, null, 2));
131
- }
132
- catch (error) {
133
- console.error('Error updating AI organization settings:', error instanceof Error ? error.message : String(error));
96
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async function () {
97
+ const options = this.opts();
98
+ const body = {};
99
+ if (options.aiAgentsVisible != null) {
100
+ if (options.aiAgentsVisible !== 'true' && options.aiAgentsVisible !== 'false') {
101
+ console.error(`Error: --ai-agents-visible must be 'true' or 'false', got: '${options.aiAgentsVisible}'`);
134
102
  process.exit(1);
135
103
  }
136
- });
104
+ body['aiAgentsVisible'] = options.aiAgentsVisible === 'true';
105
+ }
106
+ if (Object.keys(body).length === 0) {
107
+ console.error('Error: at least one option is required (e.g. --ai-agents-visible)');
108
+ process.exit(1);
109
+ }
110
+ try {
111
+ const client = (0, client_1.getClient)();
112
+ const result = await client.v1.aiAgents.updateAiOrganizationSettings(body);
113
+ console.log(JSON.stringify(result, null, 2));
114
+ }
115
+ catch (error) {
116
+ console.error('Error updating AI organization settings:', error instanceof Error ? error.message : String(error));
117
+ process.exit(1);
118
+ }
137
119
  }));
138
120
  }