@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
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Schema introspection command for agent discoverability.
4
- * Outputs machine-readable JSON describing API paths, methods, and parameters.
3
+ * Shared CLI schema command — catalog-only introspection (ADR-0013).
5
4
  */
6
5
  Object.defineProperty(exports, "__esModule", { value: true });
7
6
  exports.getSchema = getSchema;
@@ -9,102 +8,30 @@ exports.listResources = listResources;
9
8
  exports.registerSchemaCommand = registerSchemaCommand;
10
9
  const common_1 = require("@lightdash-tools/common");
11
10
  const safety_1 = require("../utils/safety");
12
- /** Maps resource identifiers to API path + method + description. */
13
- const SCHEMA_REGISTRY = {
14
- 'organization.get': {
15
- path: '/api/v1/org',
16
- method: 'GET',
17
- description: 'Get current organization details',
18
- },
19
- 'projects.list': {
20
- path: '/api/v1/org/projects',
21
- method: 'GET',
22
- description: 'List all projects in the organization',
23
- },
24
- 'projects.get': {
25
- path: '/api/v1/projects/{projectUuid}',
26
- method: 'GET',
27
- description: 'Get project by UUID',
28
- params: ['projectUuid'],
29
- },
30
- 'charts.list': {
31
- path: '/api/v1/projects/{projectUuid}/charts',
32
- method: 'GET',
33
- description: 'List charts in a project',
34
- params: ['projectUuid'],
35
- },
36
- 'charts.code.list': {
37
- path: '/api/v1/projects/{projectUuid}/charts/code',
38
- method: 'GET',
39
- description: 'Get charts in code representation',
40
- params: ['projectUuid'],
41
- },
42
- 'charts.code.upsert': {
43
- path: '/api/v1/projects/{projectUuid}/charts/{slug}/code',
44
- method: 'POST',
45
- description: 'Create or update chart by slug',
46
- params: ['projectUuid', 'slug'],
47
- },
48
- 'dashboards.list': {
49
- path: '/api/v1/projects/{projectUuid}/dashboards',
50
- method: 'GET',
51
- description: 'List dashboards in a project',
52
- params: ['projectUuid'],
53
- },
54
- 'spaces.list': {
55
- path: '/api/v1/projects/{projectUuid}/spaces',
56
- method: 'GET',
57
- description: 'List spaces in a project',
58
- params: ['projectUuid'],
59
- },
60
- 'ai-agents.list': {
61
- path: '/api/v1/aiAgents/admin/agents',
62
- method: 'GET',
63
- description: 'List AI agents (admin)',
64
- },
65
- 'ai-agents.threads': {
66
- path: '/api/v1/aiAgents/admin/threads',
67
- method: 'GET',
68
- description: 'List AI agent threads (admin)',
69
- },
70
- 'ai-agents.settings.get': {
71
- path: '/api/v1/aiAgents/admin/settings',
72
- method: 'GET',
73
- description: 'Get AI organization settings',
74
- },
75
- 'ai-agents.settings.update': {
76
- path: '/api/v1/aiAgents/admin/settings',
77
- method: 'PATCH',
78
- description: 'Update AI organization settings',
79
- },
80
- 'projects.validate.run': {
81
- path: '/api/v1/projects/{projectUuid}/validate',
82
- method: 'POST',
83
- description: 'Start project validation job',
84
- params: ['projectUuid'],
85
- },
86
- 'projects.validate.results': {
87
- path: '/api/v1/projects/{projectUuid}/validate',
88
- method: 'GET',
89
- description: 'Get latest validation results',
90
- params: ['projectUuid'],
91
- },
92
- };
93
- function getSchema(resource) {
11
+ function extractPathParams(path) {
12
+ const params = [];
13
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
14
+ params.push(match[1]);
15
+ }
16
+ return params;
17
+ }
18
+ function operationToSchema(operation) {
94
19
  var _a;
95
- const entry = SCHEMA_REGISTRY[resource];
96
- if (!entry)
97
- return null;
98
- return {
99
- resource,
100
- path: entry.path,
101
- method: entry.method,
102
- description: entry.description,
103
- params: (_a = entry.params) !== null && _a !== void 0 ? _a : [],
104
- };
20
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ resource: operation.id, path: operation.http.path, method: operation.http.method, description: operation.summary, params: extractPathParams(operation.http.path) }, (operation.cli != null ? { cliCommand: operation.cli.commandPath } : {})), (((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) === true ? { mcpToolName: operation.mcp.toolName } : {})), (operation.bannedMcpToolName != null
21
+ ? { bannedMcpToolName: operation.bannedMcpToolName }
22
+ : {})), { agentExposure: operation.agentExposure, sensitivity: operation.sensitivity, profiles: [...operation.profiles], safetyImpact: operation.authorization.safetyImpact }), (operation.workflow != null ? { workflow: [...operation.workflow] } : {}));
23
+ }
24
+ function getSchema(resource) {
25
+ const operation = (0, common_1.getOperation)(resource);
26
+ if (operation) {
27
+ return operationToSchema(operation);
28
+ }
29
+ return null;
105
30
  }
106
31
  function listResources() {
107
- return Object.keys(SCHEMA_REGISTRY).sort();
32
+ return (0, common_1.listOperations)()
33
+ .map((operation) => operation.id)
34
+ .sort();
108
35
  }
109
36
  /**
110
37
  * Registers the schema introspection command.
@@ -115,14 +42,14 @@ function registerSchemaCommand(program) {
115
42
  .description('Introspect API schema for agent discoverability');
116
43
  schemaCmd
117
44
  .command('list')
118
- .description('List all introspectable resources')
45
+ .description('List all introspectable resources from the operation catalog')
119
46
  .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => {
120
47
  const resources = listResources();
121
48
  console.log(JSON.stringify({ resources }, null, 2));
122
49
  }));
123
50
  schemaCmd
124
51
  .command('get <resource>')
125
- .description('Get schema for a resource (e.g. charts.list, ai-agents.settings.get)')
52
+ .description('Get schema for a catalog operation id (e.g. ai-agents.project.agents.list)')
126
53
  .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (resource) => {
127
54
  const schema = getSchema(resource);
128
55
  if (!schema) {
@@ -4,36 +4,101 @@ const vitest_1 = require("vitest");
4
4
  const schema_1 = require("./schema");
5
5
  (0, vitest_1.describe)('schema command', () => {
6
6
  (0, vitest_1.describe)('getSchema', () => {
7
- (0, vitest_1.it)('returns JSON with path, method, params for charts.list', () => {
8
- const schema = (0, schema_1.getSchema)('charts.list');
7
+ (0, vitest_1.it)('returns schema for ai-agents.project.agents.list from the operation catalog', () => {
8
+ const schema = (0, schema_1.getSchema)('ai-agents.project.agents.list');
9
9
  (0, vitest_1.expect)(schema).not.toBeNull();
10
- (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/charts');
10
+ (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents');
11
11
  (0, vitest_1.expect)(schema).toHaveProperty('method', 'GET');
12
- (0, vitest_1.expect)(schema).toHaveProperty('params');
13
- (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.params).toEqual(['projectUuid']);
14
- (0, vitest_1.expect)(schema).toHaveProperty('description');
15
- (0, vitest_1.expect)(schema).toHaveProperty('resource', 'charts.list');
12
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents list');
13
+ (0, vitest_1.expect)(schema).not.toHaveProperty('mcpToolName');
14
+ (0, vitest_1.expect)(schema).toHaveProperty('profiles');
15
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.profiles).toContain('core-lifecycle');
16
+ (0, vitest_1.expect)(schema).toHaveProperty('sensitivity', 'none');
16
17
  });
17
- (0, vitest_1.it)('returns schema for ai-agents.settings.update', () => {
18
- const schema = (0, schema_1.getSchema)('ai-agents.settings.update');
18
+ (0, vitest_1.it)('returns schema for ai-agents.admin.settings.update from the operation catalog', () => {
19
+ const schema = (0, schema_1.getSchema)('ai-agents.admin.settings.update');
19
20
  (0, vitest_1.expect)(schema).not.toBeNull();
20
21
  (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/aiAgents/admin/settings');
21
22
  (0, vitest_1.expect)(schema).toHaveProperty('method', 'PATCH');
23
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'ai-agents settings update');
24
+ (0, vitest_1.expect)(schema).not.toHaveProperty('mcpToolName');
25
+ });
26
+ (0, vitest_1.it)('returns schema for cli.charts.list from the operation catalog', () => {
27
+ const schema = (0, schema_1.getSchema)('cli.charts.list');
28
+ (0, vitest_1.expect)(schema).not.toBeNull();
29
+ (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/code/charts');
30
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'GET');
31
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.params).toEqual(['projectUuid']);
32
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'projects charts list');
33
+ });
34
+ (0, vitest_1.it)('returns schema for semantic.projects.list with exposed MCP tool name', () => {
35
+ const schema = (0, schema_1.getSchema)('semantic.projects.list');
36
+ (0, vitest_1.expect)(schema).not.toBeNull();
37
+ (0, vitest_1.expect)(schema).toHaveProperty('mcpToolName', 'list_projects');
38
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'projects list');
39
+ });
40
+ (0, vitest_1.it)('returns schema for ai-agents.project.evaluations.create from the operation catalog', () => {
41
+ const schema = (0, schema_1.getSchema)('ai-agents.project.evaluations.create');
42
+ (0, vitest_1.expect)(schema).not.toBeNull();
43
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'POST');
44
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents evals create');
45
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.params).toEqual(vitest_1.expect.arrayContaining(['projectUuid', 'agentUuid']));
46
+ });
47
+ (0, vitest_1.it)('returns schema for ai-agents.project.threads.start from the operation catalog', () => {
48
+ const schema = (0, schema_1.getSchema)('ai-agents.project.threads.start');
49
+ (0, vitest_1.expect)(schema).not.toBeNull();
50
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'POST');
51
+ (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads');
52
+ (0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents threads start');
53
+ (0, vitest_1.expect)(schema).toHaveProperty('safetyImpact', 'external-side-effect');
54
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.workflow).toEqual(vitest_1.expect.arrayContaining([
55
+ vitest_1.expect.objectContaining({
56
+ method: 'POST',
57
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
58
+ }),
59
+ ]));
60
+ });
61
+ (0, vitest_1.it)('returns workflow for ai-agents.project.threads.continue from the operation catalog', () => {
62
+ const schema = (0, schema_1.getSchema)('ai-agents.project.threads.continue');
63
+ (0, vitest_1.expect)(schema).not.toBeNull();
64
+ (0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.workflow).toEqual(vitest_1.expect.arrayContaining([
65
+ vitest_1.expect.objectContaining({
66
+ method: 'POST',
67
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/messages',
68
+ }),
69
+ vitest_1.expect.objectContaining({
70
+ method: 'POST',
71
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
72
+ }),
73
+ ]));
74
+ });
75
+ (0, vitest_1.it)('returns schema for users.members.delete with client-only exposure', () => {
76
+ const schema = (0, schema_1.getSchema)('users.members.delete');
77
+ (0, vitest_1.expect)(schema).not.toBeNull();
78
+ (0, vitest_1.expect)(schema).toHaveProperty('method', 'DELETE');
79
+ (0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/org/user/{userUuid}');
80
+ (0, vitest_1.expect)(schema).toHaveProperty('agentExposure', 'client-only');
81
+ (0, vitest_1.expect)(schema).toHaveProperty('bannedMcpToolName', 'delete_member');
22
82
  });
23
83
  (0, vitest_1.it)('returns null for unknown resource', () => {
24
84
  const schema = (0, schema_1.getSchema)('unknown.resource');
25
85
  (0, vitest_1.expect)(schema).toBeNull();
26
86
  });
87
+ (0, vitest_1.it)('does not resolve retired legacy schema keys', () => {
88
+ (0, vitest_1.expect)((0, schema_1.getSchema)('charts.list')).toBeNull();
89
+ (0, vitest_1.expect)((0, schema_1.getSchema)('ai-agents.settings.update')).toBeNull();
90
+ });
27
91
  });
28
92
  (0, vitest_1.describe)('listResources', () => {
29
- (0, vitest_1.it)('returns sorted list of resource identifiers', () => {
93
+ (0, vitest_1.it)('returns sorted catalog operation ids only', () => {
30
94
  const resources = (0, schema_1.listResources)();
31
- (0, vitest_1.expect)(resources).toContain('charts.list');
32
- (0, vitest_1.expect)(resources).toContain('ai-agents.settings.get');
33
95
  (0, vitest_1.expect)(resources).toEqual([...resources].sort());
34
- });
35
- (0, vitest_1.it)('includes charts.list', () => {
36
- (0, vitest_1.expect)((0, schema_1.listResources)()).toContain('charts.list');
96
+ (0, vitest_1.expect)(resources).not.toContain('charts.list');
97
+ (0, vitest_1.expect)(resources).toContain('cli.charts.list');
98
+ (0, vitest_1.expect)(resources).toContain('ai-agents.project.agents.list');
99
+ (0, vitest_1.expect)(resources).toContain('ai-agents.project.evaluations.run');
100
+ (0, vitest_1.expect)(resources).toContain('ai-agents.project.threads.continue');
101
+ (0, vitest_1.expect)(resources).toContain('semantic.projects.list');
37
102
  });
38
103
  });
39
104
  });
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Space access (v1) command implementation.
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.registerSpaceAccessCommand = registerSpaceAccessCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -31,10 +22,10 @@ function registerSpaceAccessCommand(program) {
31
22
  userCmd
32
23
  .command('grant <projectUuid> <spaceUuid> <userUuid> <role>')
33
24
  .description('Grant a user access to a space')
34
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, spaceUuid, userUuid, role) => __awaiter(this, void 0, void 0, function* () {
25
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid, spaceUuid, userUuid, role) => {
35
26
  try {
36
27
  const client = (0, client_1.getClient)();
37
- yield client.v1.spaces.grantUserAccessToSpace(projectUuid, spaceUuid, {
28
+ await client.v1.spaces.grantUserAccessToSpace(projectUuid, spaceUuid, {
38
29
  userUuid,
39
30
  spaceRole: role,
40
31
  });
@@ -44,29 +35,29 @@ function registerSpaceAccessCommand(program) {
44
35
  console.error('Error granting user access to space:', error instanceof Error ? error.message : String(error));
45
36
  process.exit(1);
46
37
  }
47
- })));
38
+ }));
48
39
  userCmd
49
40
  .command('revoke <projectUuid> <spaceUuid> <userUuid>')
50
41
  .description("Revoke a user's access to a space")
51
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (projectUuid, spaceUuid, userUuid) => __awaiter(this, void 0, void 0, function* () {
42
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (projectUuid, spaceUuid, userUuid) => {
52
43
  try {
53
44
  const client = (0, client_1.getClient)();
54
- yield client.v1.spaces.revokeUserAccessToSpace(projectUuid, spaceUuid, userUuid);
45
+ await client.v1.spaces.revokeUserAccessToSpace(projectUuid, spaceUuid, userUuid);
55
46
  console.error(`Successfully revoked access for user ${userUuid} in space ${spaceUuid}`);
56
47
  }
57
48
  catch (error) {
58
49
  console.error('Error revoking user access from space:', error instanceof Error ? error.message : String(error));
59
50
  process.exit(1);
60
51
  }
61
- })));
52
+ }));
62
53
  const groupCmd = spaceAccessCmd.command('group').description('Manage group access to a space');
63
54
  groupCmd
64
55
  .command('grant <projectUuid> <spaceUuid> <groupUuid> <role>')
65
56
  .description('Grant a group access to a space')
66
- .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, (projectUuid, spaceUuid, groupUuid, role) => __awaiter(this, void 0, void 0, function* () {
57
+ .action((0, safety_1.wrapAction)(common_1.WRITE_IDEMPOTENT, async (projectUuid, spaceUuid, groupUuid, role) => {
67
58
  try {
68
59
  const client = (0, client_1.getClient)();
69
- yield client.v1.spaces.grantGroupAccessToSpace(projectUuid, spaceUuid, {
60
+ await client.v1.spaces.grantGroupAccessToSpace(projectUuid, spaceUuid, {
70
61
  groupUuid,
71
62
  spaceRole: role,
72
63
  });
@@ -76,19 +67,19 @@ function registerSpaceAccessCommand(program) {
76
67
  console.error('Error granting group access to space:', error instanceof Error ? error.message : String(error));
77
68
  process.exit(1);
78
69
  }
79
- })));
70
+ }));
80
71
  groupCmd
81
72
  .command('revoke <projectUuid> <spaceUuid> <groupUuid>')
82
73
  .description("Revoke a group's access to a space")
83
- .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, (projectUuid, spaceUuid, groupUuid) => __awaiter(this, void 0, void 0, function* () {
74
+ .action((0, safety_1.wrapAction)(common_1.WRITE_DESTRUCTIVE, async (projectUuid, spaceUuid, groupUuid) => {
84
75
  try {
85
76
  const client = (0, client_1.getClient)();
86
- yield client.v1.spaces.revokeGroupAccessToSpace(projectUuid, spaceUuid, groupUuid);
77
+ await client.v1.spaces.revokeGroupAccessToSpace(projectUuid, spaceUuid, groupUuid);
87
78
  console.error(`Successfully revoked access for group ${groupUuid} in space ${spaceUuid}`);
88
79
  }
89
80
  catch (error) {
90
81
  console.error('Error revoking group access from space:', error instanceof Error ? error.message : String(error));
91
82
  process.exit(1);
92
83
  }
93
- })));
84
+ }));
94
85
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Spaces (v1) command implementation.
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.registerSpacesCommand = registerSpacesCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -28,29 +19,29 @@ function registerSpacesCommand(program) {
28
19
  spacesCmd
29
20
  .command('list <projectUuid>')
30
21
  .description('List spaces in a project')
31
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
22
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
32
23
  try {
33
24
  const client = (0, client_1.getClient)();
34
- const result = yield client.v1.spaces.listSpacesInProject(projectUuid);
25
+ const result = await client.v1.spaces.listSpacesInProject(projectUuid);
35
26
  console.log(JSON.stringify(result, null, 2));
36
27
  }
37
28
  catch (error) {
38
29
  console.error('Error listing spaces:', error instanceof Error ? error.message : String(error));
39
30
  process.exit(1);
40
31
  }
41
- })));
32
+ }));
42
33
  spacesCmd
43
34
  .command('get <projectUuid> <spaceUuid>')
44
35
  .description('Get a space by UUID')
45
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, spaceUuid) => __awaiter(this, void 0, void 0, function* () {
36
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, spaceUuid) => {
46
37
  try {
47
38
  const client = (0, client_1.getClient)();
48
- const result = yield client.v1.spaces.getSpace(projectUuid, spaceUuid);
39
+ const result = await client.v1.spaces.getSpace(projectUuid, spaceUuid);
49
40
  console.log(JSON.stringify(result, null, 2));
50
41
  }
51
42
  catch (error) {
52
43
  console.error('Error fetching space:', error instanceof Error ? error.message : String(error));
53
44
  process.exit(1);
54
45
  }
55
- })));
46
+ }));
56
47
  }
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Tags command implementation.
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.registerTagsCommand = registerTagsCommand;
16
7
  const common_1 = require("@lightdash-tools/common");
@@ -24,29 +15,29 @@ function registerTagsCommand(program) {
24
15
  tagsCmd
25
16
  .command('list <projectUuid>')
26
17
  .description('List tags in a project')
27
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid) => __awaiter(this, void 0, void 0, function* () {
18
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid) => {
28
19
  try {
29
20
  const client = (0, client_1.getClient)();
30
- const result = yield client.v1.tags.listTags(projectUuid);
21
+ const result = await client.v1.tags.listTags(projectUuid);
31
22
  console.log(JSON.stringify(result, null, 2));
32
23
  }
33
24
  catch (error) {
34
25
  console.error('Error listing tags:', error instanceof Error ? error.message : String(error));
35
26
  process.exit(1);
36
27
  }
37
- })));
28
+ }));
38
29
  tagsCmd
39
30
  .command('get <projectUuid> <tagUuid>')
40
31
  .description('Get a tag by UUID')
41
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (projectUuid, tagUuid) => __awaiter(this, void 0, void 0, function* () {
32
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (projectUuid, tagUuid) => {
42
33
  try {
43
34
  const client = (0, client_1.getClient)();
44
- const result = yield client.v1.tags.getTag(projectUuid, tagUuid);
35
+ const result = await client.v1.tags.getTag(projectUuid, tagUuid);
45
36
  console.log(JSON.stringify(result, null, 2));
46
37
  }
47
38
  catch (error) {
48
39
  console.error('Error fetching tag:', error instanceof Error ? error.message : String(error));
49
40
  process.exit(1);
50
41
  }
51
- })));
42
+ }));
52
43
  }
@@ -2,20 +2,22 @@
2
2
  /**
3
3
  * Users command implementation.
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.registerUsersCommand = registerUsersCommand;
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
+ async function listUsers(client, options) {
12
+ const searchQuery = options.search;
13
+ if (options.all) {
14
+ const list = await client.v1.users.listAllMembers((0, cli_params_1.pickDefined)({ searchQuery }));
15
+ console.log(JSON.stringify(list, null, 2));
16
+ return;
17
+ }
18
+ const result = await client.v1.users.listMembers((0, cli_params_1.pickDefined)({ page: options.page, pageSize: options.pageSize, searchQuery }));
19
+ console.log(JSON.stringify(result, null, 2));
20
+ }
19
21
  /**
20
22
  * Registers the users command and its subcommands.
21
23
  * Uses client.v1.users (typed client) per ADR-0010.
@@ -29,48 +31,28 @@ function registerUsersCommand(program) {
29
31
  .option('--page <number>', 'Page number (1-based)', (v) => parseInt(v, 10))
30
32
  .option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
31
33
  .option('--search <query>', 'Search query')
32
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, function () {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const options = this.opts();
35
- try {
36
- const client = (0, client_1.getClient)();
37
- if (options.all) {
38
- const listParams = {};
39
- if (options.search != null)
40
- listParams.searchQuery = options.search;
41
- const list = yield client.v1.users.listAllMembers(Object.keys(listParams).length > 0 ? listParams : undefined);
42
- console.log(JSON.stringify(list, null, 2));
43
- }
44
- else {
45
- const params = {};
46
- if (options.page != null)
47
- params.page = options.page;
48
- if (options.pageSize != null)
49
- params.pageSize = options.pageSize;
50
- if (options.search != null)
51
- params.searchQuery = options.search;
52
- const result = yield client.v1.users.listMembers(Object.keys(params).length > 0 ? params : undefined);
53
- console.log(JSON.stringify(result, null, 2));
54
- }
55
- }
56
- catch (error) {
57
- console.error('Error listing users:', error instanceof Error ? error.message : String(error));
58
- process.exit(1);
59
- }
60
- });
34
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async function () {
35
+ const options = this.opts();
36
+ try {
37
+ await listUsers((0, client_1.getClient)(), options);
38
+ }
39
+ catch (error) {
40
+ console.error('Error listing users:', error instanceof Error ? error.message : String(error));
41
+ process.exit(1);
42
+ }
61
43
  }));
62
44
  usersCmd
63
45
  .command('get <userUuid>')
64
46
  .description('Get a user by UUID')
65
- .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (userUuid) => __awaiter(this, void 0, void 0, function* () {
47
+ .action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, async (userUuid) => {
66
48
  try {
67
49
  const client = (0, client_1.getClient)();
68
- const member = yield client.v1.users.getMemberByUuid(userUuid);
50
+ const member = await client.v1.users.getMemberByUuid(userUuid);
69
51
  console.log(JSON.stringify(member, null, 2));
70
52
  }
71
53
  catch (error) {
72
54
  console.error('Error fetching user:', error instanceof Error ? error.message : String(error));
73
55
  process.exit(1);
74
56
  }
75
- })));
57
+ }));
76
58
  }
package/dist/index.js CHANGED
@@ -4,35 +4,36 @@
4
4
  * Main entry point for Lightdash AI CLI.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
7
  const common_1 = require("@lightdash-tools/common");
9
- const organization_1 = require("./commands/organization");
10
- const organization_roles_1 = require("./commands/organization-roles");
11
- const projects_1 = require("./commands/projects");
12
- const project_role_assignments_1 = require("./commands/project-role-assignments");
13
- const project_access_1 = require("./commands/project-access");
14
- const spaces_1 = require("./commands/spaces");
15
- const space_access_1 = require("./commands/space-access");
8
+ const commander_1 = require("commander");
9
+ const agentops_1 = require("./commands/agentops");
10
+ const agents_1 = require("./commands/agents");
11
+ const ai_agents_1 = require("./commands/ai-agents");
16
12
  const charts_1 = require("./commands/charts");
13
+ const content_1 = require("./commands/content");
17
14
  const dashboards_1 = require("./commands/dashboards");
18
- const ai_agents_1 = require("./commands/ai-agents");
19
- const agents_1 = require("./commands/agents");
20
- const groups_1 = require("./commands/groups");
21
- const users_1 = require("./commands/users");
22
- const query_1 = require("./commands/query");
23
15
  const explores_1 = require("./commands/explores");
16
+ const groups_1 = require("./commands/groups");
24
17
  const metrics_1 = require("./commands/metrics");
18
+ const organization_1 = require("./commands/organization");
19
+ const organization_roles_1 = require("./commands/organization-roles");
20
+ const project_access_1 = require("./commands/project-access");
21
+ const project_role_assignments_1 = require("./commands/project-role-assignments");
22
+ const projects_1 = require("./commands/projects");
23
+ const query_1 = require("./commands/query");
25
24
  const schedulers_1 = require("./commands/schedulers");
26
- const tags_1 = require("./commands/tags");
27
- const content_1 = require("./commands/content");
28
25
  const schema_1 = require("./commands/schema");
26
+ const space_access_1 = require("./commands/space-access");
27
+ const spaces_1 = require("./commands/spaces");
28
+ const tags_1 = require("./commands/tags");
29
+ const users_1 = require("./commands/users");
29
30
  // Initialise audit log before any command runs (uses LIGHTDASH_TOOLS_AUDIT_LOG env var).
30
31
  (0, common_1.initAuditLog)(process.env.LIGHTDASH_TOOLS_AUDIT_LOG);
31
32
  const program = new commander_1.Command();
32
33
  program
33
34
  .name('lightdash-ai')
34
35
  .description('CLI for Lightdash AI')
35
- .version('0.6.0')
36
+ .version('0.8.0')
36
37
  .option('--safety-mode <mode>', 'Safety mode (read-only, write-idempotent, write-destructive)', 'read-only')
37
38
  .option('--projects <uuids>', 'Comma-separated list of allowed project UUIDs (security guardrail)')
38
39
  .option('--dry-run', 'Simulate mutating operations without executing (env: LIGHTDASH_TOOLS_DRY_RUN=1)');
@@ -47,6 +48,7 @@ program
47
48
  (0, charts_1.registerChartsCommand)(program);
48
49
  (0, dashboards_1.registerDashboardsCommand)(program);
49
50
  (0, ai_agents_1.registerAiAgentsCommand)(program);
51
+ (0, agentops_1.registerAgentopsCommand)(program);
50
52
  (0, agents_1.registerAgentsCommand)(program);
51
53
  (0, groups_1.registerGroupsCommand)(program);
52
54
  (0, users_1.registerUsersCommand)(program);
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
3
  const commander_1 = require("commander");
4
+ const vitest_1 = require("vitest");
5
+ const ai_agents_1 = require("./commands/ai-agents");
6
+ const charts_1 = require("./commands/charts");
7
+ const dashboards_1 = require("./commands/dashboards");
8
+ const explores_1 = require("./commands/explores");
9
+ const groups_1 = require("./commands/groups");
5
10
  const organization_1 = require("./commands/organization");
6
11
  const organization_roles_1 = require("./commands/organization-roles");
7
- const projects_1 = require("./commands/projects");
8
- const project_role_assignments_1 = require("./commands/project-role-assignments");
9
12
  const project_access_1 = require("./commands/project-access");
10
- const spaces_1 = require("./commands/spaces");
13
+ const project_role_assignments_1 = require("./commands/project-role-assignments");
14
+ const projects_1 = require("./commands/projects");
11
15
  const space_access_1 = require("./commands/space-access");
12
- const charts_1 = require("./commands/charts");
13
- const dashboards_1 = require("./commands/dashboards");
14
- const ai_agents_1 = require("./commands/ai-agents");
15
- const groups_1 = require("./commands/groups");
16
+ const spaces_1 = require("./commands/spaces");
16
17
  const users_1 = require("./commands/users");
17
- const explores_1 = require("./commands/explores");
18
18
  (0, vitest_1.describe)('CLI Command Registration', () => {
19
19
  (0, vitest_1.it)('should register organization command', () => {
20
20
  const program = new commander_1.Command();