@lightdash-tools/cli 0.11.0 → 0.13.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.
- package/README.md +5 -6
- package/dist/index.js +1 -3
- package/package.json +3 -3
- package/src/index.ts +1 -3
- package/dist/commands/schema.d.ts +0 -10
- package/dist/commands/schema.js +0 -62
- package/dist/commands/schema.test.d.ts +0 -1
- package/dist/commands/schema.test.js +0 -104
- package/src/commands/schema.test.ts +0 -121
- package/src/commands/schema.ts +0 -86
package/README.md
CHANGED
|
@@ -161,15 +161,14 @@ lightdash-ai ai-agents list
|
|
|
161
161
|
lightdash-ai ai-agents threads --page 1 --page-size 10
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
####
|
|
164
|
+
#### Discovery
|
|
165
165
|
|
|
166
166
|
```bash
|
|
167
|
-
#
|
|
168
|
-
lightdash-ai
|
|
167
|
+
# CLI command help (Commander)
|
|
168
|
+
lightdash-ai agents --help
|
|
169
|
+
lightdash-ai ai-agents --help
|
|
169
170
|
|
|
170
|
-
#
|
|
171
|
-
lightdash-ai schema get cli.charts.list
|
|
172
|
-
lightdash-ai schema get ai-agents.admin.settings.update
|
|
171
|
+
# MCP: connect a profile and call tools/list (e.g. ai-agent-ops)
|
|
173
172
|
```
|
|
174
173
|
|
|
175
174
|
### Global Options
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ const project_role_assignments_1 = require("./commands/project-role-assignments"
|
|
|
22
22
|
const projects_1 = require("./commands/projects");
|
|
23
23
|
const query_1 = require("./commands/query");
|
|
24
24
|
const schedulers_1 = require("./commands/schedulers");
|
|
25
|
-
const schema_1 = require("./commands/schema");
|
|
26
25
|
const space_access_1 = require("./commands/space-access");
|
|
27
26
|
const spaces_1 = require("./commands/spaces");
|
|
28
27
|
const tags_1 = require("./commands/tags");
|
|
@@ -33,7 +32,7 @@ const program = new commander_1.Command();
|
|
|
33
32
|
program
|
|
34
33
|
.name('lightdash-ai')
|
|
35
34
|
.description('CLI for Lightdash AI')
|
|
36
|
-
.version('0.
|
|
35
|
+
.version('0.13.0')
|
|
37
36
|
.option('--safety-mode <mode>', 'Safety mode (read-only, write-idempotent, write-destructive)', 'read-only')
|
|
38
37
|
.option('--projects <uuids>', 'Comma-separated list of allowed project UUIDs (security guardrail)')
|
|
39
38
|
.option('--dry-run', 'Simulate mutating operations without executing (env: LIGHTDASH_TOOLS_DRY_RUN=1)');
|
|
@@ -58,6 +57,5 @@ program
|
|
|
58
57
|
(0, schedulers_1.registerSchedulersCommand)(program);
|
|
59
58
|
(0, tags_1.registerTagsCommand)(program);
|
|
60
59
|
(0, content_1.registerContentCommand)(program);
|
|
61
|
-
(0, schema_1.registerSchemaCommand)(program);
|
|
62
60
|
// Parse command line arguments
|
|
63
61
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash-tools/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "CLI for Lightdash AI.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"commander": "^15.0.0",
|
|
20
20
|
"yaml": "^2.9.0",
|
|
21
|
-
"@lightdash-tools/client": "0.
|
|
22
|
-
"@lightdash-tools/common": "0.
|
|
21
|
+
"@lightdash-tools/client": "0.13.0",
|
|
22
|
+
"@lightdash-tools/common": "0.13.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^25.9.3"
|
package/src/index.ts
CHANGED
|
@@ -22,7 +22,6 @@ import { registerProjectRoleAssignmentsCommand } from './commands/project-role-a
|
|
|
22
22
|
import { registerProjectsCommand } from './commands/projects';
|
|
23
23
|
import { registerQueryCommand } from './commands/query';
|
|
24
24
|
import { registerSchedulersCommand } from './commands/schedulers';
|
|
25
|
-
import { registerSchemaCommand } from './commands/schema';
|
|
26
25
|
import { registerSpaceAccessCommand } from './commands/space-access';
|
|
27
26
|
import { registerSpacesCommand } from './commands/spaces';
|
|
28
27
|
import { registerTagsCommand } from './commands/tags';
|
|
@@ -36,7 +35,7 @@ const program = new Command();
|
|
|
36
35
|
program
|
|
37
36
|
.name('lightdash-ai')
|
|
38
37
|
.description('CLI for Lightdash AI')
|
|
39
|
-
.version('0.
|
|
38
|
+
.version('0.13.0')
|
|
40
39
|
.option(
|
|
41
40
|
'--safety-mode <mode>',
|
|
42
41
|
'Safety mode (read-only, write-idempotent, write-destructive)',
|
|
@@ -72,7 +71,6 @@ registerMetricsCommand(program);
|
|
|
72
71
|
registerSchedulersCommand(program);
|
|
73
72
|
registerTagsCommand(program);
|
|
74
73
|
registerContentCommand(program);
|
|
75
|
-
registerSchemaCommand(program);
|
|
76
74
|
|
|
77
75
|
// Parse command line arguments
|
|
78
76
|
program.parse(process.argv);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared CLI schema command — catalog-only introspection (ADR-0013).
|
|
3
|
-
*/
|
|
4
|
-
import type { Command } from 'commander';
|
|
5
|
-
export declare function getSchema(resource: string): Record<string, unknown> | null;
|
|
6
|
-
export declare function listResources(): string[];
|
|
7
|
-
/**
|
|
8
|
-
* Registers the schema introspection command.
|
|
9
|
-
*/
|
|
10
|
-
export declare function registerSchemaCommand(program: Command): void;
|
package/dist/commands/schema.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Shared CLI schema command — catalog-only introspection (ADR-0013).
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSchema = getSchema;
|
|
7
|
-
exports.listResources = listResources;
|
|
8
|
-
exports.registerSchemaCommand = registerSchemaCommand;
|
|
9
|
-
const common_1 = require("@lightdash-tools/common");
|
|
10
|
-
const safety_1 = require("../utils/safety");
|
|
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) {
|
|
19
|
-
var _a;
|
|
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;
|
|
30
|
-
}
|
|
31
|
-
function listResources() {
|
|
32
|
-
return (0, common_1.listOperations)()
|
|
33
|
-
.map((operation) => operation.id)
|
|
34
|
-
.sort();
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Registers the schema introspection command.
|
|
38
|
-
*/
|
|
39
|
-
function registerSchemaCommand(program) {
|
|
40
|
-
const schemaCmd = program
|
|
41
|
-
.command('schema')
|
|
42
|
-
.description('Introspect API schema for agent discoverability');
|
|
43
|
-
schemaCmd
|
|
44
|
-
.command('list')
|
|
45
|
-
.description('List all introspectable resources from the operation catalog')
|
|
46
|
-
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => {
|
|
47
|
-
const resources = listResources();
|
|
48
|
-
console.log(JSON.stringify({ resources }, null, 2));
|
|
49
|
-
}));
|
|
50
|
-
schemaCmd
|
|
51
|
-
.command('get <resource>')
|
|
52
|
-
.description('Get schema for a catalog operation id (e.g. ai-agents.project.agents.list)')
|
|
53
|
-
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (resource) => {
|
|
54
|
-
const schema = getSchema(resource);
|
|
55
|
-
if (!schema) {
|
|
56
|
-
const available = listResources().join(', ');
|
|
57
|
-
console.error(`Error: Unknown resource '${resource}'. Available: ${available}`);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
console.log(JSON.stringify(schema, null, 2));
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const schema_1 = require("./schema");
|
|
5
|
-
(0, vitest_1.describe)('schema command', () => {
|
|
6
|
-
(0, vitest_1.describe)('getSchema', () => {
|
|
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
|
-
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
10
|
-
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents');
|
|
11
|
-
(0, vitest_1.expect)(schema).toHaveProperty('method', 'GET');
|
|
12
|
-
(0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents list');
|
|
13
|
-
(0, vitest_1.expect)(schema).toHaveProperty('mcpToolName', 'list_project_agents');
|
|
14
|
-
(0, vitest_1.expect)(schema).toHaveProperty('profiles');
|
|
15
|
-
(0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.profiles).toEqual(['ai-agent-ops']);
|
|
16
|
-
(0, vitest_1.expect)(schema).toHaveProperty('sensitivity', 'none');
|
|
17
|
-
});
|
|
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');
|
|
20
|
-
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
21
|
-
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/aiAgents/admin/settings');
|
|
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');
|
|
82
|
-
});
|
|
83
|
-
(0, vitest_1.it)('returns null for unknown resource', () => {
|
|
84
|
-
const schema = (0, schema_1.getSchema)('unknown.resource');
|
|
85
|
-
(0, vitest_1.expect)(schema).toBeNull();
|
|
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
|
-
});
|
|
91
|
-
});
|
|
92
|
-
(0, vitest_1.describe)('listResources', () => {
|
|
93
|
-
(0, vitest_1.it)('returns sorted catalog operation ids only', () => {
|
|
94
|
-
const resources = (0, schema_1.listResources)();
|
|
95
|
-
(0, vitest_1.expect)(resources).toEqual([...resources].sort());
|
|
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');
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { getSchema, listResources } from './schema';
|
|
4
|
-
|
|
5
|
-
describe('schema command', () => {
|
|
6
|
-
describe('getSchema', () => {
|
|
7
|
-
it('returns schema for ai-agents.project.agents.list from the operation catalog', () => {
|
|
8
|
-
const schema = getSchema('ai-agents.project.agents.list');
|
|
9
|
-
expect(schema).not.toBeNull();
|
|
10
|
-
expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents');
|
|
11
|
-
expect(schema).toHaveProperty('method', 'GET');
|
|
12
|
-
expect(schema).toHaveProperty('cliCommand', 'agents list');
|
|
13
|
-
expect(schema).toHaveProperty('mcpToolName', 'list_project_agents');
|
|
14
|
-
expect(schema).toHaveProperty('profiles');
|
|
15
|
-
expect(schema?.profiles).toEqual(['ai-agent-ops']);
|
|
16
|
-
expect(schema).toHaveProperty('sensitivity', 'none');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('returns schema for ai-agents.admin.settings.update from the operation catalog', () => {
|
|
20
|
-
const schema = getSchema('ai-agents.admin.settings.update');
|
|
21
|
-
expect(schema).not.toBeNull();
|
|
22
|
-
expect(schema).toHaveProperty('path', '/api/v1/aiAgents/admin/settings');
|
|
23
|
-
expect(schema).toHaveProperty('method', 'PATCH');
|
|
24
|
-
expect(schema).toHaveProperty('cliCommand', 'ai-agents settings update');
|
|
25
|
-
expect(schema).not.toHaveProperty('mcpToolName');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('returns schema for cli.charts.list from the operation catalog', () => {
|
|
29
|
-
const schema = getSchema('cli.charts.list');
|
|
30
|
-
expect(schema).not.toBeNull();
|
|
31
|
-
expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/code/charts');
|
|
32
|
-
expect(schema).toHaveProperty('method', 'GET');
|
|
33
|
-
expect(schema?.params).toEqual(['projectUuid']);
|
|
34
|
-
expect(schema).toHaveProperty('cliCommand', 'projects charts list');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('returns schema for semantic.projects.list with exposed MCP tool name', () => {
|
|
38
|
-
const schema = getSchema('semantic.projects.list');
|
|
39
|
-
expect(schema).not.toBeNull();
|
|
40
|
-
expect(schema).toHaveProperty('mcpToolName', 'list_projects');
|
|
41
|
-
expect(schema).toHaveProperty('cliCommand', 'projects list');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('returns schema for ai-agents.project.evaluations.create from the operation catalog', () => {
|
|
45
|
-
const schema = getSchema('ai-agents.project.evaluations.create');
|
|
46
|
-
expect(schema).not.toBeNull();
|
|
47
|
-
expect(schema).toHaveProperty('method', 'POST');
|
|
48
|
-
expect(schema).toHaveProperty('cliCommand', 'agents evals create');
|
|
49
|
-
expect(schema?.params).toEqual(expect.arrayContaining(['projectUuid', 'agentUuid']));
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('returns schema for ai-agents.project.threads.start from the operation catalog', () => {
|
|
53
|
-
const schema = getSchema('ai-agents.project.threads.start');
|
|
54
|
-
expect(schema).not.toBeNull();
|
|
55
|
-
expect(schema).toHaveProperty('method', 'POST');
|
|
56
|
-
expect(schema).toHaveProperty(
|
|
57
|
-
'path',
|
|
58
|
-
'/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads',
|
|
59
|
-
);
|
|
60
|
-
expect(schema).toHaveProperty('cliCommand', 'agents threads start');
|
|
61
|
-
expect(schema).toHaveProperty('safetyImpact', 'external-side-effect');
|
|
62
|
-
expect(schema?.workflow).toEqual(
|
|
63
|
-
expect.arrayContaining([
|
|
64
|
-
expect.objectContaining({
|
|
65
|
-
method: 'POST',
|
|
66
|
-
path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
|
|
67
|
-
}),
|
|
68
|
-
]),
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('returns workflow for ai-agents.project.threads.continue from the operation catalog', () => {
|
|
73
|
-
const schema = getSchema('ai-agents.project.threads.continue');
|
|
74
|
-
expect(schema).not.toBeNull();
|
|
75
|
-
expect(schema?.workflow).toEqual(
|
|
76
|
-
expect.arrayContaining([
|
|
77
|
-
expect.objectContaining({
|
|
78
|
-
method: 'POST',
|
|
79
|
-
path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/messages',
|
|
80
|
-
}),
|
|
81
|
-
expect.objectContaining({
|
|
82
|
-
method: 'POST',
|
|
83
|
-
path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
|
|
84
|
-
}),
|
|
85
|
-
]),
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('returns schema for users.members.delete with client-only exposure', () => {
|
|
90
|
-
const schema = getSchema('users.members.delete');
|
|
91
|
-
expect(schema).not.toBeNull();
|
|
92
|
-
expect(schema).toHaveProperty('method', 'DELETE');
|
|
93
|
-
expect(schema).toHaveProperty('path', '/api/v1/org/user/{userUuid}');
|
|
94
|
-
expect(schema).toHaveProperty('agentExposure', 'client-only');
|
|
95
|
-
expect(schema).toHaveProperty('bannedMcpToolName', 'delete_member');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('returns null for unknown resource', () => {
|
|
99
|
-
const schema = getSchema('unknown.resource');
|
|
100
|
-
expect(schema).toBeNull();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('does not resolve retired legacy schema keys', () => {
|
|
104
|
-
expect(getSchema('charts.list')).toBeNull();
|
|
105
|
-
expect(getSchema('ai-agents.settings.update')).toBeNull();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('listResources', () => {
|
|
110
|
-
it('returns sorted catalog operation ids only', () => {
|
|
111
|
-
const resources = listResources();
|
|
112
|
-
expect(resources).toEqual([...resources].sort());
|
|
113
|
-
expect(resources).not.toContain('charts.list');
|
|
114
|
-
expect(resources).toContain('cli.charts.list');
|
|
115
|
-
expect(resources).toContain('ai-agents.project.agents.list');
|
|
116
|
-
expect(resources).toContain('ai-agents.project.evaluations.run');
|
|
117
|
-
expect(resources).toContain('ai-agents.project.threads.continue');
|
|
118
|
-
expect(resources).toContain('semantic.projects.list');
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
package/src/commands/schema.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared CLI schema command — catalog-only introspection (ADR-0013).
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { getOperation, listOperations, READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
6
|
-
|
|
7
|
-
import { wrapAction } from '../utils/safety';
|
|
8
|
-
|
|
9
|
-
import type { OperationDescriptor } from '@lightdash-tools/common';
|
|
10
|
-
import type { Command } from 'commander';
|
|
11
|
-
|
|
12
|
-
function extractPathParams(path: string): string[] {
|
|
13
|
-
const params: string[] = [];
|
|
14
|
-
for (const match of path.matchAll(/\{([^}]+)\}/g)) {
|
|
15
|
-
params.push(match[1]);
|
|
16
|
-
}
|
|
17
|
-
return params;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function operationToSchema(operation: OperationDescriptor): Record<string, unknown> {
|
|
21
|
-
return {
|
|
22
|
-
resource: operation.id,
|
|
23
|
-
path: operation.http.path,
|
|
24
|
-
method: operation.http.method,
|
|
25
|
-
description: operation.summary,
|
|
26
|
-
params: extractPathParams(operation.http.path),
|
|
27
|
-
...(operation.cli != null ? { cliCommand: operation.cli.commandPath } : {}),
|
|
28
|
-
...(operation.mcp?.taskSupport.exposed === true ? { mcpToolName: operation.mcp.toolName } : {}),
|
|
29
|
-
...(operation.bannedMcpToolName != null
|
|
30
|
-
? { bannedMcpToolName: operation.bannedMcpToolName }
|
|
31
|
-
: {}),
|
|
32
|
-
agentExposure: operation.agentExposure,
|
|
33
|
-
sensitivity: operation.sensitivity,
|
|
34
|
-
profiles: [...operation.profiles],
|
|
35
|
-
safetyImpact: operation.authorization.safetyImpact,
|
|
36
|
-
...(operation.workflow != null ? { workflow: [...operation.workflow] } : {}),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getSchema(resource: string): Record<string, unknown> | null {
|
|
41
|
-
const operation = getOperation(resource);
|
|
42
|
-
if (operation) {
|
|
43
|
-
return operationToSchema(operation);
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function listResources(): string[] {
|
|
49
|
-
return listOperations()
|
|
50
|
-
.map((operation) => operation.id)
|
|
51
|
-
.sort();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Registers the schema introspection command.
|
|
56
|
-
*/
|
|
57
|
-
export function registerSchemaCommand(program: Command): void {
|
|
58
|
-
const schemaCmd = program
|
|
59
|
-
.command('schema')
|
|
60
|
-
.description('Introspect API schema for agent discoverability');
|
|
61
|
-
|
|
62
|
-
schemaCmd
|
|
63
|
-
.command('list')
|
|
64
|
-
.description('List all introspectable resources from the operation catalog')
|
|
65
|
-
.action(
|
|
66
|
-
wrapAction(READ_ONLY_DEFAULT, () => {
|
|
67
|
-
const resources = listResources();
|
|
68
|
-
console.log(JSON.stringify({ resources }, null, 2));
|
|
69
|
-
}),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
schemaCmd
|
|
73
|
-
.command('get <resource>')
|
|
74
|
-
.description('Get schema for a catalog operation id (e.g. ai-agents.project.agents.list)')
|
|
75
|
-
.action(
|
|
76
|
-
wrapAction(READ_ONLY_DEFAULT, (resource: string) => {
|
|
77
|
-
const schema = getSchema(resource);
|
|
78
|
-
if (!schema) {
|
|
79
|
-
const available = listResources().join(', ');
|
|
80
|
-
console.error(`Error: Unknown resource '${resource}'. Available: ${available}`);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
console.log(JSON.stringify(schema, null, 2));
|
|
84
|
-
}),
|
|
85
|
-
);
|
|
86
|
-
}
|