@lightdash-tools/common 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.
Files changed (66) hide show
  1. package/dist/agent-safe.d.ts +4 -0
  2. package/dist/agent-safe.js +13 -0
  3. package/dist/audit.d.ts +1 -1
  4. package/dist/index.d.ts +2 -1
  5. package/dist/index.js +4 -2
  6. package/dist/profile-ids.d.ts +5 -0
  7. package/dist/profile-ids.js +15 -0
  8. package/package.json +1 -3
  9. package/src/agent-safe.ts +11 -0
  10. package/src/audit.ts +1 -1
  11. package/src/index.ts +5 -2
  12. package/src/profile-ids.ts +15 -0
  13. package/dist/operations/agent-safe.d.ts +0 -5
  14. package/dist/operations/agent-safe.js +0 -9
  15. package/dist/operations/ai-agents.d.ts +0 -6
  16. package/dist/operations/ai-agents.js +0 -495
  17. package/dist/operations/cli-content.d.ts +0 -5
  18. package/dist/operations/cli-content.js +0 -69
  19. package/dist/operations/client-coverage.d.ts +0 -120
  20. package/dist/operations/client-coverage.js +0 -139
  21. package/dist/operations/client-coverage.test.d.ts +0 -1
  22. package/dist/operations/client-coverage.test.js +0 -22
  23. package/dist/operations/content-developer.d.ts +0 -2
  24. package/dist/operations/content-developer.js +0 -471
  25. package/dist/operations/content-governance.d.ts +0 -7
  26. package/dist/operations/content-governance.js +0 -98
  27. package/dist/operations/content-reader.d.ts +0 -2
  28. package/dist/operations/content-reader.js +0 -198
  29. package/dist/operations/data-analyst.d.ts +0 -5
  30. package/dist/operations/data-analyst.js +0 -23
  31. package/dist/operations/index.d.ts +0 -13
  32. package/dist/operations/index.js +0 -37
  33. package/dist/operations/organization-audit.d.ts +0 -2
  34. package/dist/operations/organization-audit.js +0 -273
  35. package/dist/operations/parity.test.d.ts +0 -1
  36. package/dist/operations/parity.test.js +0 -29
  37. package/dist/operations/registry.d.ts +0 -18
  38. package/dist/operations/registry.js +0 -136
  39. package/dist/operations/registry.test.d.ts +0 -1
  40. package/dist/operations/registry.test.js +0 -201
  41. package/dist/operations/semantic-layer.d.ts +0 -6
  42. package/dist/operations/semantic-layer.js +0 -155
  43. package/dist/operations/types.d.ts +0 -90
  44. package/dist/operations/types.js +0 -113
  45. package/dist/operations/types.test.d.ts +0 -1
  46. package/dist/operations/types.test.js +0 -101
  47. package/dist/operations/users.d.ts +0 -6
  48. package/dist/operations/users.js +0 -56
  49. package/src/operations/agent-safe.ts +0 -8
  50. package/src/operations/ai-agents.ts +0 -539
  51. package/src/operations/cli-content.ts +0 -76
  52. package/src/operations/client-coverage.test.ts +0 -23
  53. package/src/operations/client-coverage.ts +0 -156
  54. package/src/operations/content-developer.ts +0 -501
  55. package/src/operations/content-governance.ts +0 -110
  56. package/src/operations/content-reader.ts +0 -213
  57. package/src/operations/data-analyst.ts +0 -27
  58. package/src/operations/index.ts +0 -44
  59. package/src/operations/organization-audit.ts +0 -293
  60. package/src/operations/parity.test.ts +0 -33
  61. package/src/operations/registry.test.ts +0 -229
  62. package/src/operations/registry.ts +0 -158
  63. package/src/operations/semantic-layer.ts +0 -167
  64. package/src/operations/types.test.ts +0 -138
  65. package/src/operations/types.ts +0 -241
  66. package/src/operations/users.ts +0 -62
@@ -1,136 +0,0 @@
1
- "use strict";
2
- /**
3
- * Central operation catalog — aggregates domain modules and exposes lookup helpers.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOperation = getOperation;
7
- exports.getOperationByMcpToolName = getOperationByMcpToolName;
8
- exports.listOperations = listOperations;
9
- exports.getOperationsByProfile = getOperationsByProfile;
10
- exports.listExposedMcpToolNames = listExposedMcpToolNames;
11
- exports.listBannedMcpToolNames = listBannedMcpToolNames;
12
- exports.listMcpToolNamesByProfile = listMcpToolNamesByProfile;
13
- const ai_agents_1 = require("./ai-agents");
14
- const cli_content_1 = require("./cli-content");
15
- const content_developer_1 = require("./content-developer");
16
- const content_governance_1 = require("./content-governance");
17
- const content_reader_1 = require("./content-reader");
18
- const data_analyst_1 = require("./data-analyst");
19
- const organization_audit_1 = require("./organization-audit");
20
- const semantic_layer_1 = require("./semantic-layer");
21
- const types_1 = require("./types");
22
- const users_1 = require("./users");
23
- const AGENT_EXPOSURE_CLIENT_ONLY = 'client-only';
24
- const ALL_OPERATIONS = [
25
- ...ai_agents_1.AI_AGENT_OPERATIONS,
26
- ...users_1.USER_OPERATIONS,
27
- ...semantic_layer_1.SEMANTIC_LAYER_OPERATIONS,
28
- ...organization_audit_1.ORGANIZATION_AUDIT_OPERATIONS,
29
- ...content_reader_1.CONTENT_READER_OPERATIONS,
30
- ...content_developer_1.CONTENT_DEVELOPER_OPERATIONS,
31
- ...content_governance_1.CONTENT_GOVERNANCE_OPERATIONS,
32
- ...data_analyst_1.DATA_ANALYST_OPERATIONS,
33
- ...cli_content_1.CLI_CONTENT_OPERATIONS,
34
- ];
35
- const operationsById = new Map(ALL_OPERATIONS.map((operation) => [operation.id, operation]));
36
- if (operationsById.size !== ALL_OPERATIONS.length) {
37
- const seen = new Set();
38
- const duplicates = [];
39
- for (const operation of ALL_OPERATIONS) {
40
- if (seen.has(operation.id)) {
41
- duplicates.push(operation.id);
42
- }
43
- seen.add(operation.id);
44
- }
45
- throw new Error(`Duplicate operation ids in registry: ${duplicates.join(', ')}`);
46
- }
47
- const operationsByMcpToolName = new Map();
48
- for (const operation of ALL_OPERATIONS) {
49
- if (operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY || operation.mcp === undefined) {
50
- continue;
51
- }
52
- // Index only exposed tools so lookups match registerToolsByIds / schema honesty.
53
- if (!operation.mcp.taskSupport.exposed) {
54
- continue;
55
- }
56
- const toolName = operation.mcp.toolName;
57
- if (operationsByMcpToolName.has(toolName)) {
58
- throw new Error(`Duplicate MCP toolName in operation catalog: ${toolName}`);
59
- }
60
- operationsByMcpToolName.set(toolName, operation);
61
- }
62
- const EXPOSED_MCP_TOOL_NAMES = ALL_OPERATIONS.filter((operation) => operation.agentExposure === 'agent' &&
63
- operation.mcp !== undefined &&
64
- operation.mcp.taskSupport.exposed).map((operation) => {
65
- const mcp = operation.mcp;
66
- if (mcp === undefined) {
67
- throw new Error(`Invariant: exposed filter retained operation without mcp (${operation.id})`);
68
- }
69
- return mcp.toolName;
70
- });
71
- const BANNED_MCP_TOOL_NAMES = ALL_OPERATIONS.filter((operation) => operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY &&
72
- typeof operation.bannedMcpToolName === 'string' &&
73
- operation.bannedMcpToolName.trim().length > 0).map((operation) => {
74
- const banned = operation.bannedMcpToolName;
75
- if (banned === undefined) {
76
- throw new Error(`Invariant: banned filter retained operation without name (${operation.id})`);
77
- }
78
- return banned;
79
- });
80
- /** Precomputed tool names per serving profile (ADR-0006 registration source). */
81
- const MCP_TOOL_NAMES_BY_PROFILE = (() => {
82
- const map = new Map(types_1.PROFILE_IDS.map((id) => [id, []]));
83
- for (const operation of ALL_OPERATIONS) {
84
- if (operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY) {
85
- continue;
86
- }
87
- const mcp = operation.mcp;
88
- if (mcp === undefined || mcp.taskSupport.exposed !== true) {
89
- continue;
90
- }
91
- for (const profile of operation.profiles) {
92
- const names = map.get(profile);
93
- if (names === undefined) {
94
- throw new Error(`Unknown profile '${profile}' on operation '${operation.id}' while indexing MCP tools`);
95
- }
96
- names.push(mcp.toolName);
97
- }
98
- }
99
- for (const [id, names] of map) {
100
- Object.freeze(names);
101
- map.set(id, names);
102
- }
103
- return map;
104
- })();
105
- /** Returns a registered operation by id, or undefined when not found. */
106
- function getOperation(id) {
107
- return operationsById.get(id);
108
- }
109
- /** Returns the agent operation registered for an MCP tool name (sans prefix), if any. */
110
- function getOperationByMcpToolName(toolName) {
111
- return operationsByMcpToolName.get(toolName);
112
- }
113
- /** Returns every registered operation descriptor. */
114
- function listOperations() {
115
- return ALL_OPERATIONS;
116
- }
117
- /** Returns agent-surface operations that include the given MCP serving profile. */
118
- function getOperationsByProfile(profile) {
119
- return ALL_OPERATIONS.filter((operation) => operation.agentExposure !== 'client-only' && operation.profiles.includes(profile));
120
- }
121
- /** MCP tool names (sans prefix) with `mcp.taskSupport.exposed === true`. */
122
- function listExposedMcpToolNames() {
123
- return EXPOSED_MCP_TOOL_NAMES;
124
- }
125
- /** MCP tool names that must never be registered (client-only denylist). */
126
- function listBannedMcpToolNames() {
127
- return BANNED_MCP_TOOL_NAMES;
128
- }
129
- /** Exposed MCP tool names for a serving profile (registration source, ADR-0006). */
130
- function listMcpToolNamesByProfile(profile) {
131
- const names = MCP_TOOL_NAMES_BY_PROFILE.get(profile);
132
- if (names === undefined) {
133
- throw new Error(`Unknown profile id: ${profile}`);
134
- }
135
- return names;
136
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,201 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const ai_agents_1 = require("./ai-agents");
5
- const cli_content_1 = require("./cli-content");
6
- const content_developer_1 = require("./content-developer");
7
- const content_governance_1 = require("./content-governance");
8
- const content_reader_1 = require("./content-reader");
9
- const data_analyst_1 = require("./data-analyst");
10
- const organization_audit_1 = require("./organization-audit");
11
- const registry_1 = require("./registry");
12
- const semantic_layer_1 = require("./semantic-layer");
13
- const types_1 = require("./types");
14
- const users_1 = require("./users");
15
- const P0_OPERATION_IDS = [
16
- 'ai-agents.admin.agents.list',
17
- 'ai-agents.admin.settings.get',
18
- 'ai-agents.admin.settings.update',
19
- 'ai-agents.project.agents.list',
20
- 'ai-agents.project.agents.get',
21
- 'ai-agents.project.agents.create',
22
- 'ai-agents.project.agents.update',
23
- 'ai-agents.project.agents.delete',
24
- 'ai-agents.project.threads.start',
25
- 'ai-agents.project.threads.continue',
26
- 'ai-agents.project.evaluations.list',
27
- 'ai-agents.project.evaluations.get',
28
- 'ai-agents.project.evaluations.create',
29
- 'ai-agents.project.evaluations.update',
30
- 'ai-agents.project.evaluations.append',
31
- 'ai-agents.project.evaluations.delete',
32
- 'ai-agents.project.evaluations.run',
33
- 'ai-agents.project.evaluations.runs.list',
34
- ];
35
- const ALL_PROFILES = [...types_1.PROFILE_IDS];
36
- function requiredFields(operation) {
37
- var _a;
38
- const agentExposure = (_a = operation.agentExposure) !== null && _a !== void 0 ? _a : 'agent';
39
- const fields = [
40
- operation.id,
41
- operation.summary,
42
- operation.http.method,
43
- operation.http.path,
44
- operation.authorization.safetyImpact,
45
- operation.sensitivity,
46
- agentExposure,
47
- ];
48
- if (agentExposure === 'agent') {
49
- if (operation.mcp !== undefined) {
50
- fields.push(operation.mcp.toolName);
51
- }
52
- if (operation.cli !== undefined) {
53
- fields.push(operation.cli.commandPath);
54
- }
55
- }
56
- return fields;
57
- }
58
- (0, vitest_1.describe)('operation registry', () => {
59
- (0, vitest_1.it)('registers all P0 operation ids', () => {
60
- for (const id of P0_OPERATION_IDS) {
61
- (0, vitest_1.expect)((0, registry_1.getOperation)(id)).toBeDefined();
62
- }
63
- });
64
- (0, vitest_1.it)('has no duplicate operation ids', () => {
65
- const ids = (0, registry_1.listOperations)().map((operation) => operation.id);
66
- (0, vitest_1.expect)(new Set(ids).size).toBe(ids.length);
67
- });
68
- (0, vitest_1.it)('matches aggregated domain export count', () => {
69
- (0, vitest_1.expect)((0, registry_1.listOperations)()).toHaveLength(ai_agents_1.AI_AGENT_OPERATIONS.length +
70
- users_1.USER_OPERATIONS.length +
71
- semantic_layer_1.SEMANTIC_LAYER_OPERATIONS.length +
72
- organization_audit_1.ORGANIZATION_AUDIT_OPERATIONS.length +
73
- content_reader_1.CONTENT_READER_OPERATIONS.length +
74
- content_developer_1.CONTENT_DEVELOPER_OPERATIONS.length +
75
- content_governance_1.CONTENT_GOVERNANCE_OPERATIONS.length +
76
- data_analyst_1.DATA_ANALYST_OPERATIONS.length +
77
- cli_content_1.CLI_CONTENT_OPERATIONS.length);
78
- });
79
- (0, vitest_1.it)('includes required descriptor fields on every operation', () => {
80
- var _a;
81
- for (const operation of (0, registry_1.listOperations)()) {
82
- for (const field of requiredFields(operation)) {
83
- (0, vitest_1.expect)(field).toBeTruthy();
84
- }
85
- if (operation.agentExposure === 'agent') {
86
- (0, vitest_1.expect)(operation.mcp !== undefined || operation.cli !== undefined).toBe(true);
87
- }
88
- const mcpExposed = ((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) === true;
89
- if (mcpExposed) {
90
- (0, vitest_1.expect)(operation.profiles.length).toBeGreaterThan(0);
91
- }
92
- else {
93
- (0, vitest_1.expect)(operation.profiles).toEqual([]);
94
- }
95
- (0, vitest_1.expect)(operation.http.path.startsWith('/api/v1/') || operation.http.path.startsWith('/api/v2/')).toBe(true);
96
- }
97
- });
98
- (0, vitest_1.it)('assigns idempotentHint correctly for read and destructive agent operations', () => {
99
- for (const operation of (0, registry_1.listOperations)()) {
100
- if (operation.mcp === undefined) {
101
- continue;
102
- }
103
- const { annotations } = operation.mcp;
104
- if (operation.authorization.safetyImpact === 'read') {
105
- (0, vitest_1.expect)(annotations.readOnlyHint).toBe(true);
106
- }
107
- if (operation.authorization.safetyImpact === 'write-destructive') {
108
- (0, vitest_1.expect)(annotations.destructiveHint).toBe(true);
109
- (0, vitest_1.expect)(annotations.idempotentHint).toBe(false);
110
- }
111
- }
112
- });
113
- (0, vitest_1.it)('exposes profile filters for all serving profiles', () => {
114
- for (const profile of ALL_PROFILES) {
115
- const operations = (0, registry_1.getOperationsByProfile)(profile);
116
- (0, vitest_1.expect)(operations.length).toBeGreaterThan(0);
117
- for (const operation of operations) {
118
- (0, vitest_1.expect)(operation.profiles).toContain(profile);
119
- }
120
- }
121
- });
122
- (0, vitest_1.it)('listMcpToolNamesByProfile matches exposed ops per profile', () => {
123
- for (const profile of ALL_PROFILES) {
124
- const toolNames = (0, registry_1.listMcpToolNamesByProfile)(profile);
125
- const exposedOps = (0, registry_1.getOperationsByProfile)(profile).filter((operation) => { var _a; return ((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) === true; });
126
- (0, vitest_1.expect)(toolNames).toHaveLength(exposedOps.length);
127
- (0, vitest_1.expect)(new Set(toolNames).size).toBe(toolNames.length);
128
- }
129
- });
130
- (0, vitest_1.it)('maps exposed ai-agent-ops tools to ai-agent-ops profile only', () => {
131
- var _a, _b;
132
- (0, vitest_1.expect)((_a = (0, registry_1.getOperation)('ai-agents.project.agents.list')) === null || _a === void 0 ? void 0 : _a.profiles).toEqual(['ai-agent-ops']);
133
- (0, vitest_1.expect)((_b = (0, registry_1.getOperation)('ai-agents.project.agents.create')) === null || _b === void 0 ? void 0 : _b.profiles).toEqual([]);
134
- });
135
- (0, vitest_1.it)('documents multi-step workflow for thread start', () => {
136
- var _a, _b;
137
- const operation = (0, registry_1.getOperation)('ai-agents.project.threads.start');
138
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.http.path).toBe('/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads');
139
- (0, vitest_1.expect)((_a = operation === null || operation === void 0 ? void 0 : operation.cli) === null || _a === void 0 ? void 0 : _a.commandPath).toBe('agents threads start');
140
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.workflow).toHaveLength(3);
141
- const lastStep = (_b = operation === null || operation === void 0 ? void 0 : operation.workflow) === null || _b === void 0 ? void 0 : _b[operation.workflow.length - 1];
142
- (0, vitest_1.expect)(lastStep === null || lastStep === void 0 ? void 0 : lastStep.path).toContain('/generate');
143
- });
144
- (0, vitest_1.it)('documents multi-step workflow for thread continue', () => {
145
- var _a, _b, _c, _d;
146
- const operation = (0, registry_1.getOperation)('ai-agents.project.threads.continue');
147
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.workflow).toHaveLength(2);
148
- (0, vitest_1.expect)((_b = (_a = operation === null || operation === void 0 ? void 0 : operation.workflow) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.path).toContain('/messages');
149
- (0, vitest_1.expect)((_d = (_c = operation === null || operation === void 0 ? void 0 : operation.workflow) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.path).toContain('/generate');
150
- });
151
- (0, vitest_1.it)('returns undefined for unknown operation id', () => {
152
- (0, vitest_1.expect)((0, registry_1.getOperation)('ai-agents.unknown.operation')).toBeUndefined();
153
- });
154
- (0, vitest_1.it)('registers users.members.delete as client-only', () => {
155
- const operation = (0, registry_1.getOperation)('users.members.delete');
156
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.agentExposure).toBe('client-only');
157
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.mcp).toBeUndefined();
158
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.cli).toBeUndefined();
159
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.bannedMcpToolName).toBe('delete_member');
160
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.http.path).toBe('/api/v1/org/user/{userUuid}');
161
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.profiles).toEqual([]);
162
- });
163
- (0, vitest_1.it)('excludes client-only operations from profile discovery catalogs', () => {
164
- for (const profile of ALL_PROFILES) {
165
- for (const operation of (0, registry_1.getOperationsByProfile)(profile)) {
166
- (0, vitest_1.expect)(operation.agentExposure).not.toBe('client-only');
167
- }
168
- }
169
- (0, vitest_1.expect)((0, registry_1.getOperation)('users.members.delete')).toBeDefined();
170
- });
171
- (0, vitest_1.it)('never exposes client-only operations on MCP', () => {
172
- for (const operation of (0, registry_1.listOperations)()) {
173
- if (operation.agentExposure === 'client-only') {
174
- (0, vitest_1.expect)(operation.mcp).toBeUndefined();
175
- (0, vitest_1.expect)(operation.cli).toBeUndefined();
176
- }
177
- }
178
- });
179
- (0, vitest_1.it)('rejects descriptors whose safetyImpact disagrees with MCP annotations', () => {
180
- (0, vitest_1.expect)(() => (0, types_1.defineOperation)({
181
- id: 'test.invalid-impact',
182
- summary: 'Invalid impact pairing',
183
- http: { method: 'GET', path: '/api/v1/test' },
184
- authorization: { safetyImpact: 'write-destructive' },
185
- sensitivity: 'none',
186
- mcp: {
187
- toolName: 'test_tool',
188
- annotations: {
189
- readOnlyHint: true,
190
- destructiveHint: false,
191
- idempotentHint: true,
192
- openWorldHint: false,
193
- },
194
- taskSupport: { exposed: true, taskEligible: false },
195
- },
196
- cli: { commandPath: 'test' },
197
- agentExposure: 'agent',
198
- profiles: ['semantic-layer'],
199
- })).toThrow(/authorization\.safetyImpact/);
200
- });
201
- });
@@ -1,6 +0,0 @@
1
- /**
2
- * Semantic-layer MCP/CLI operations in the shared operation catalog (ADR-0013).
3
- */
4
- import type { OperationDescriptor } from './types';
5
- /** Semantic-layer operations registered in the shared operation catalog. */
6
- export declare const SEMANTIC_LAYER_OPERATIONS: readonly OperationDescriptor[];
@@ -1,155 +0,0 @@
1
- "use strict";
2
- /**
3
- * Semantic-layer MCP/CLI operations in the shared operation catalog (ADR-0013).
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SEMANTIC_LAYER_OPERATIONS = void 0;
7
- const safety_1 = require("../safety");
8
- const types_1 = require("./types");
9
- const PROFILE_SEMANTIC = 'semantic-layer';
10
- const PROFILE_DATA_ANALYST = 'data-analyst';
11
- const API_V1 = '/api/v1';
12
- const listProjects = (0, types_1.defineOperation)({
13
- id: 'semantic.projects.list',
14
- summary: 'List organization projects (or pinned project when HTTP pin is set)',
15
- http: { method: 'GET', path: `${API_V1}/org/projects` },
16
- authorization: { safetyImpact: 'read' },
17
- sensitivity: 'secret.connection',
18
- mcp: {
19
- toolName: 'list_projects',
20
- annotations: safety_1.READ_ONLY_DEFAULT,
21
- taskSupport: { exposed: true, taskEligible: false },
22
- },
23
- cli: { commandPath: 'projects list' },
24
- profiles: [PROFILE_SEMANTIC],
25
- });
26
- const getProject = (0, types_1.defineOperation)({
27
- id: 'semantic.projects.get',
28
- summary: 'Get a project by UUID (connection secrets omitted on MCP)',
29
- http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}` },
30
- authorization: { safetyImpact: 'read' },
31
- sensitivity: 'secret.connection',
32
- mcp: {
33
- toolName: 'get_project',
34
- annotations: safety_1.READ_ONLY_DEFAULT,
35
- taskSupport: { exposed: true, taskEligible: false },
36
- },
37
- cli: { commandPath: 'projects get' },
38
- profiles: [PROFILE_SEMANTIC, 'content-reader', 'content-developer', PROFILE_DATA_ANALYST],
39
- });
40
- const listExplores = (0, types_1.defineOperation)({
41
- id: 'semantic.explores.list',
42
- summary: 'List explores in a project',
43
- http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores` },
44
- authorization: { safetyImpact: 'read' },
45
- sensitivity: 'none',
46
- mcp: {
47
- toolName: 'list_explores',
48
- annotations: safety_1.READ_ONLY_DEFAULT,
49
- taskSupport: { exposed: true, taskEligible: false },
50
- },
51
- cli: { commandPath: 'projects explores list' },
52
- profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
53
- });
54
- const getExplore = (0, types_1.defineOperation)({
55
- id: 'semantic.explores.get',
56
- summary: 'Get a full explore definition',
57
- http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
58
- authorization: { safetyImpact: 'read' },
59
- sensitivity: 'none',
60
- mcp: {
61
- toolName: 'get_explore',
62
- annotations: safety_1.READ_ONLY_DEFAULT,
63
- taskSupport: { exposed: true, taskEligible: false },
64
- },
65
- cli: { commandPath: 'projects explores get' },
66
- profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
67
- });
68
- const listDimensions = (0, types_1.defineOperation)({
69
- id: 'semantic.explores.list_dimensions',
70
- summary: 'List dimensions for an explore (derived from get explore)',
71
- http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
72
- authorization: { safetyImpact: 'read' },
73
- sensitivity: 'none',
74
- mcp: {
75
- toolName: 'list_dimensions',
76
- annotations: safety_1.READ_ONLY_DEFAULT,
77
- taskSupport: { exposed: true, taskEligible: false },
78
- },
79
- cli: { commandPath: 'projects explores dimensions' },
80
- profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
81
- });
82
- const getFieldLineage = (0, types_1.defineOperation)({
83
- id: 'semantic.explores.get_field_lineage',
84
- summary: 'Get field lineage for an explore field (derived from get explore)',
85
- http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
86
- authorization: { safetyImpact: 'read' },
87
- sensitivity: 'none',
88
- mcp: {
89
- toolName: 'get_field_lineage',
90
- annotations: safety_1.READ_ONLY_DEFAULT,
91
- taskSupport: { exposed: true, taskEligible: false },
92
- },
93
- cli: { commandPath: 'projects explores lineage' },
94
- profiles: [PROFILE_SEMANTIC],
95
- });
96
- const listMetrics = (0, types_1.defineOperation)({
97
- id: 'semantic.metrics.list',
98
- summary: 'List metrics in the project data catalog',
99
- http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics` },
100
- authorization: { safetyImpact: 'read' },
101
- sensitivity: 'none',
102
- mcp: {
103
- toolName: 'list_metrics',
104
- annotations: safety_1.READ_ONLY_DEFAULT,
105
- taskSupport: { exposed: true, taskEligible: false },
106
- },
107
- cli: { commandPath: 'metrics list' },
108
- profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
109
- });
110
- const getMetric = (0, types_1.defineOperation)({
111
- id: 'semantic.metrics.get',
112
- summary: 'Get a metric from the project data catalog',
113
- http: {
114
- method: 'GET',
115
- path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics/{tableName}/{metricName}`,
116
- },
117
- authorization: { safetyImpact: 'read' },
118
- sensitivity: 'none',
119
- mcp: {
120
- toolName: 'get_metric',
121
- annotations: safety_1.READ_ONLY_DEFAULT,
122
- taskSupport: { exposed: true, taskEligible: false },
123
- },
124
- cli: { commandPath: 'metrics get' },
125
- profiles: [PROFILE_SEMANTIC],
126
- });
127
- const compileQuery = (0, types_1.defineOperation)({
128
- id: 'semantic.query.compile',
129
- summary: 'Compile a metric query to SQL without executing warehouse rows',
130
- http: {
131
- method: 'POST',
132
- path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}/compileQuery`,
133
- },
134
- authorization: { safetyImpact: 'read' },
135
- sensitivity: 'none',
136
- mcp: {
137
- toolName: 'compile_query',
138
- annotations: safety_1.READ_ONLY_DEFAULT,
139
- taskSupport: { exposed: true, taskEligible: false },
140
- },
141
- cli: { commandPath: 'query compile' },
142
- profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
143
- });
144
- /** Semantic-layer operations registered in the shared operation catalog. */
145
- exports.SEMANTIC_LAYER_OPERATIONS = [
146
- listProjects,
147
- getProject,
148
- listExplores,
149
- getExplore,
150
- listDimensions,
151
- getFieldLineage,
152
- listMetrics,
153
- getMetric,
154
- compileQuery,
155
- ];
@@ -1,90 +0,0 @@
1
- /**
2
- * Shared typed operation catalog (ADR-0013 / ADR-0006).
3
- * Single source of truth for HTTP, CLI, and MCP exposure of Lightdash API operations.
4
- */
5
- import type { SafetyImpact, ToolAnnotations } from '../safety';
6
- export type { SafetyImpact };
7
- /** Whether an operation may appear on MCP/CLI agent surfaces. */
8
- export type AgentExposure = 'agent' | 'client-only';
9
- /** HTTP verbs supported by registered operations. */
10
- export type HttpMethod = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
11
- /** Runtime list of every MCP serving profile id (ADR-0006; fixed mounts / stdio). */
12
- export declare const PROFILE_IDS: readonly ["ai-agent-ops", "content-developer", "content-governance", "content-reader", "data-analyst", "organization-audit", "semantic-layer"];
13
- /** MCP serving profile ids aligned to fixed HTTP mounts / stdio subcommands (ADR-0006). */
14
- export type ProfileId = (typeof PROFILE_IDS)[number];
15
- /**
16
- * MCP response sensitivity class (ADR-0011).
17
- * Documents which redaction class handlers must apply; does not auto-redact.
18
- */
19
- export type SensitivityClass = 'none' | 'pii.email' | 'secret.connection' | 'secret.destination';
20
- /** MCP task semantics for an operation. */
21
- export type McpTaskSupport = {
22
- /** When true, the operation is exposed as an MCP tool. */
23
- exposed: boolean;
24
- /**
25
- * When true, the operation may complete asynchronously via MCP Tasks.
26
- * Long-running evaluation runs and LLM generation are task-eligible.
27
- */
28
- taskEligible: boolean;
29
- };
30
- export type OperationAuthorization = {
31
- safetyImpact: SafetyImpact;
32
- };
33
- export type OperationHttp = {
34
- method: HttpMethod;
35
- /** OpenAPI-style path template (includes `/api/v1` or `/api/v2` prefix). */
36
- path: string;
37
- };
38
- export type OperationMcp = {
39
- /** MCP tool name without the `lightdash_` prefix. */
40
- toolName: string;
41
- annotations: ToolAnnotations;
42
- taskSupport: McpTaskSupport;
43
- };
44
- export type OperationCli = {
45
- /** Space-delimited CLI command path from the root program (e.g. `agents list`). */
46
- commandPath: string;
47
- };
48
- /** Optional multi-step HTTP workflow when a single registry entry orchestrates several API calls. */
49
- export type OperationWorkflowStep = {
50
- method: HttpMethod;
51
- path: string;
52
- summary: string;
53
- };
54
- export type OperationDescriptor = {
55
- /** Stable dot-separated identifier (e.g. `ai-agents.project.agents.list`). */
56
- id: string;
57
- summary: string;
58
- http: OperationHttp;
59
- authorization: OperationAuthorization;
60
- /**
61
- * Response sensitivity class for agent surfaces (ADR-0011).
62
- * Defaults to `none` when omitted from `defineOperation` input.
63
- */
64
- sensitivity: SensitivityClass;
65
- /**
66
- * MCP mounts that expose this op when `mcp.taskSupport.exposed` is true (ADR-0006).
67
- * Empty when the op is not MCP-exposed (CLI-only / reserved / client-only).
68
- */
69
- profiles: readonly ProfileId[];
70
- /** `agent` (default) = may appear on MCP and/or CLI; `client-only` = typed client only. */
71
- agentExposure: AgentExposure;
72
- /** Present when the operation is registered (or reserved) as an MCP tool. */
73
- mcp?: OperationMcp;
74
- /** Present when a real CLI command exists (`commandPath` must match Commander). */
75
- cli?: OperationCli;
76
- /** Irrecoverable denylist name for client-only ops (sans `lightdash_` prefix). */
77
- bannedMcpToolName?: string;
78
- /** When set, documents the ordered client-side HTTP steps behind this operation. */
79
- workflow?: readonly OperationWorkflowStep[];
80
- };
81
- /** Input to `defineOperation` before defaults are applied. */
82
- export type OperationDefinitionInput = Omit<OperationDescriptor, 'agentExposure' | 'sensitivity'> & {
83
- agentExposure?: AgentExposure;
84
- sensitivity?: SensitivityClass;
85
- };
86
- /**
87
- * Defines a typed operation descriptor with catalog consistency checks (ADR-0013).
88
- * Agent ops require at least one of `mcp` or `cli`. Client-only ops omit both.
89
- */
90
- export declare function defineOperation(input: OperationDefinitionInput): OperationDescriptor;