@lightdash-tools/common 0.7.0 → 0.9.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 (71) hide show
  1. package/dist/argument-validation.js +20 -2
  2. package/dist/argument-validation.test.js +22 -0
  3. package/dist/audit.d.ts +29 -9
  4. package/dist/audit.js +53 -9
  5. package/dist/audit.test.js +51 -24
  6. package/dist/env.d.ts +1 -1
  7. package/dist/env.js +2 -2
  8. package/dist/index.d.ts +1 -3
  9. package/dist/index.js +6 -8
  10. package/dist/operations/agent-safe.d.ts +1 -3
  11. package/dist/operations/agent-safe.js +2 -9
  12. package/dist/operations/ai-agents.js +118 -30
  13. package/dist/operations/cli-content.d.ts +5 -0
  14. package/dist/operations/cli-content.js +71 -0
  15. package/dist/operations/client-coverage.d.ts +119 -0
  16. package/dist/operations/client-coverage.js +137 -0
  17. package/dist/operations/client-coverage.test.d.ts +1 -0
  18. package/dist/operations/client-coverage.test.js +22 -0
  19. package/dist/operations/content-developer.d.ts +2 -0
  20. package/dist/operations/content-developer.js +471 -0
  21. package/dist/operations/content-governance.d.ts +7 -0
  22. package/dist/operations/content-governance.js +98 -0
  23. package/dist/operations/content-reader.d.ts +2 -0
  24. package/dist/operations/content-reader.js +197 -0
  25. package/dist/operations/index.d.ts +10 -3
  26. package/dist/operations/index.js +20 -2
  27. package/dist/operations/organization-audit.d.ts +2 -0
  28. package/dist/operations/organization-audit.js +273 -0
  29. package/dist/operations/parity.test.js +12 -11
  30. package/dist/operations/registry.d.ts +9 -1
  31. package/dist/operations/registry.js +77 -2
  32. package/dist/operations/registry.test.js +39 -11
  33. package/dist/operations/semantic-layer.d.ts +6 -0
  34. package/dist/operations/semantic-layer.js +154 -0
  35. package/dist/operations/types.d.ts +29 -12
  36. package/dist/operations/types.js +64 -29
  37. package/dist/operations/types.test.js +33 -45
  38. package/dist/operations/users.d.ts +2 -2
  39. package/dist/operations/users.js +8 -10
  40. package/dist/safety.d.ts +8 -2
  41. package/dist/safety.js +22 -4
  42. package/dist/safety.test.js +29 -6
  43. package/dist/types/index.d.ts +12 -0
  44. package/dist/types/index.js +29 -0
  45. package/package.json +2 -1
  46. package/src/argument-validation.test.ts +31 -0
  47. package/src/argument-validation.ts +20 -2
  48. package/src/audit.test.ts +70 -30
  49. package/src/audit.ts +88 -12
  50. package/src/env.ts +1 -1
  51. package/src/index.ts +5 -9
  52. package/src/operations/agent-safe.ts +2 -12
  53. package/src/operations/ai-agents.ts +123 -31
  54. package/src/operations/cli-content.ts +79 -0
  55. package/src/operations/client-coverage.test.ts +23 -0
  56. package/src/operations/client-coverage.ts +153 -0
  57. package/src/operations/content-developer.ts +501 -0
  58. package/src/operations/content-governance.ts +110 -0
  59. package/src/operations/content-reader.ts +212 -0
  60. package/src/operations/index.ts +25 -2
  61. package/src/operations/organization-audit.ts +293 -0
  62. package/src/operations/parity.test.ts +12 -14
  63. package/src/operations/registry.test.ts +41 -9
  64. package/src/operations/registry.ts +86 -2
  65. package/src/operations/semantic-layer.ts +166 -0
  66. package/src/operations/types.test.ts +38 -76
  67. package/src/operations/types.ts +112 -47
  68. package/src/operations/users.ts +9 -11
  69. package/src/safety.test.ts +32 -6
  70. package/src/safety.ts +26 -4
  71. package/src/types/index.ts +13 -0
@@ -1,27 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
- const agent_safe_1 = require("./agent-safe");
5
4
  const registry_1 = require("./registry");
6
5
  (0, vitest_1.describe)('agent-safe surface parity', () => {
7
- (0, vitest_1.it)('requires MCP tool name and CLI path for exposed agent operations', () => {
8
- const exposedAgentOps = (0, registry_1.listOperations)().filter((operation) => operation.agentExposure === 'agent' && operation.mcp.taskSupport.exposed === true);
9
- (0, vitest_1.expect)(exposedAgentOps.length).toBeGreaterThan(0);
10
- for (const operation of exposedAgentOps) {
11
- (0, vitest_1.expect)(operation.mcp.toolName.trim().length).toBeGreaterThan(0);
12
- (0, vitest_1.expect)(operation.cli.commandPath.trim().length).toBeGreaterThan(0);
6
+ (0, vitest_1.it)('requires MCP tool name or CLI path for agent operations', () => {
7
+ const agentOps = (0, registry_1.listOperations)().filter((operation) => operation.agentExposure === 'agent');
8
+ (0, vitest_1.expect)(agentOps.length).toBeGreaterThan(0);
9
+ for (const operation of agentOps) {
10
+ const hasMcp = operation.mcp !== undefined && operation.mcp.toolName.trim().length > 0;
11
+ const hasCli = operation.cli !== undefined && operation.cli.commandPath.trim().length > 0;
12
+ (0, vitest_1.expect)(hasMcp || hasCli).toBe(true);
13
13
  }
14
14
  });
15
15
  (0, vitest_1.it)('keeps client-only banned MCP tool names off the agent surface', () => {
16
- const banned = (0, agent_safe_1.listBannedMcpToolNames)();
16
+ const banned = (0, registry_1.listBannedMcpToolNames)();
17
17
  (0, vitest_1.expect)(banned).toContain('delete_member');
18
18
  for (const operation of (0, registry_1.listOperations)()) {
19
19
  if (operation.agentExposure !== 'client-only') {
20
20
  continue;
21
21
  }
22
- (0, vitest_1.expect)(operation.mcp.taskSupport.exposed).toBe(false);
23
- if (operation.mcp.toolName.trim().length > 0) {
24
- (0, vitest_1.expect)(banned).toContain(operation.mcp.toolName);
22
+ (0, vitest_1.expect)(operation.mcp).toBeUndefined();
23
+ (0, vitest_1.expect)(operation.cli).toBeUndefined();
24
+ if (operation.bannedMcpToolName) {
25
+ (0, vitest_1.expect)(banned).toContain(operation.bannedMcpToolName);
25
26
  }
26
27
  }
27
28
  });
@@ -1,10 +1,18 @@
1
1
  /**
2
- * Central operation registry — aggregates domain modules and exposes lookup helpers.
2
+ * Central operation catalog — aggregates domain modules and exposes lookup helpers.
3
3
  */
4
4
  import type { CapabilityProfile, OperationDescriptor } from './types';
5
5
  /** Returns a registered operation by id, or undefined when not found. */
6
6
  export declare function getOperation(id: string): OperationDescriptor | undefined;
7
+ /** Returns the agent operation registered for an MCP tool name (sans prefix), if any. */
8
+ export declare function getOperationByMcpToolName(toolName: string): OperationDescriptor | undefined;
7
9
  /** Returns every registered operation descriptor. */
8
10
  export declare function listOperations(): readonly OperationDescriptor[];
9
11
  /** Returns agent-surface operations that include the given capability profile. */
10
12
  export declare function getOperationsByProfile(profile: CapabilityProfile): readonly OperationDescriptor[];
13
+ /** MCP tool names (sans prefix) with `mcp.taskSupport.exposed === true`. */
14
+ export declare function listExposedMcpToolNames(): readonly string[];
15
+ /** MCP tool names that must never be registered (client-only denylist). */
16
+ export declare function listBannedMcpToolNames(): readonly string[];
17
+ /** Exposed MCP tool names for a capability profile (persona allowlist source). */
18
+ export declare function listMcpToolNamesByProfile(profile: CapabilityProfile): readonly string[];
@@ -1,14 +1,34 @@
1
1
  "use strict";
2
2
  /**
3
- * Central operation registry — aggregates domain modules and exposes lookup helpers.
3
+ * Central operation catalog — aggregates domain modules and exposes lookup helpers.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getOperation = getOperation;
7
+ exports.getOperationByMcpToolName = getOperationByMcpToolName;
7
8
  exports.listOperations = listOperations;
8
9
  exports.getOperationsByProfile = getOperationsByProfile;
10
+ exports.listExposedMcpToolNames = listExposedMcpToolNames;
11
+ exports.listBannedMcpToolNames = listBannedMcpToolNames;
12
+ exports.listMcpToolNamesByProfile = listMcpToolNamesByProfile;
9
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 organization_audit_1 = require("./organization-audit");
19
+ const semantic_layer_1 = require("./semantic-layer");
10
20
  const users_1 = require("./users");
11
- const ALL_OPERATIONS = [...ai_agents_1.AI_AGENT_OPERATIONS, ...users_1.USER_OPERATIONS];
21
+ const AGENT_EXPOSURE_CLIENT_ONLY = 'client-only';
22
+ const ALL_OPERATIONS = [
23
+ ...ai_agents_1.AI_AGENT_OPERATIONS,
24
+ ...users_1.USER_OPERATIONS,
25
+ ...semantic_layer_1.SEMANTIC_LAYER_OPERATIONS,
26
+ ...organization_audit_1.ORGANIZATION_AUDIT_OPERATIONS,
27
+ ...content_reader_1.CONTENT_READER_OPERATIONS,
28
+ ...content_developer_1.CONTENT_DEVELOPER_OPERATIONS,
29
+ ...content_governance_1.CONTENT_GOVERNANCE_OPERATIONS,
30
+ ...cli_content_1.CLI_CONTENT_OPERATIONS,
31
+ ];
12
32
  const operationsById = new Map(ALL_OPERATIONS.map((operation) => [operation.id, operation]));
13
33
  if (operationsById.size !== ALL_OPERATIONS.length) {
14
34
  const seen = new Set();
@@ -21,10 +41,47 @@ if (operationsById.size !== ALL_OPERATIONS.length) {
21
41
  }
22
42
  throw new Error(`Duplicate operation ids in registry: ${duplicates.join(', ')}`);
23
43
  }
44
+ const operationsByMcpToolName = new Map();
45
+ for (const operation of ALL_OPERATIONS) {
46
+ if (operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY || operation.mcp === undefined) {
47
+ continue;
48
+ }
49
+ // Index only exposed tools so lookups match registerToolsByIds / schema honesty.
50
+ if (!operation.mcp.taskSupport.exposed) {
51
+ continue;
52
+ }
53
+ const toolName = operation.mcp.toolName;
54
+ if (operationsByMcpToolName.has(toolName)) {
55
+ throw new Error(`Duplicate MCP toolName in operation catalog: ${toolName}`);
56
+ }
57
+ operationsByMcpToolName.set(toolName, operation);
58
+ }
59
+ const EXPOSED_MCP_TOOL_NAMES = ALL_OPERATIONS.filter((operation) => operation.agentExposure === 'agent' &&
60
+ operation.mcp !== undefined &&
61
+ operation.mcp.taskSupport.exposed).map((operation) => {
62
+ const mcp = operation.mcp;
63
+ if (mcp === undefined) {
64
+ throw new Error(`Invariant: exposed filter retained operation without mcp (${operation.id})`);
65
+ }
66
+ return mcp.toolName;
67
+ });
68
+ const BANNED_MCP_TOOL_NAMES = ALL_OPERATIONS.filter((operation) => operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY &&
69
+ typeof operation.bannedMcpToolName === 'string' &&
70
+ operation.bannedMcpToolName.trim().length > 0).map((operation) => {
71
+ const banned = operation.bannedMcpToolName;
72
+ if (banned === undefined) {
73
+ throw new Error(`Invariant: banned filter retained operation without name (${operation.id})`);
74
+ }
75
+ return banned;
76
+ });
24
77
  /** Returns a registered operation by id, or undefined when not found. */
25
78
  function getOperation(id) {
26
79
  return operationsById.get(id);
27
80
  }
81
+ /** Returns the agent operation registered for an MCP tool name (sans prefix), if any. */
82
+ function getOperationByMcpToolName(toolName) {
83
+ return operationsByMcpToolName.get(toolName);
84
+ }
28
85
  /** Returns every registered operation descriptor. */
29
86
  function listOperations() {
30
87
  return ALL_OPERATIONS;
@@ -33,3 +90,21 @@ function listOperations() {
33
90
  function getOperationsByProfile(profile) {
34
91
  return ALL_OPERATIONS.filter((operation) => operation.agentExposure !== 'client-only' && operation.profiles.includes(profile));
35
92
  }
93
+ /** MCP tool names (sans prefix) with `mcp.taskSupport.exposed === true`. */
94
+ function listExposedMcpToolNames() {
95
+ return EXPOSED_MCP_TOOL_NAMES;
96
+ }
97
+ /** MCP tool names that must never be registered (client-only denylist). */
98
+ function listBannedMcpToolNames() {
99
+ return BANNED_MCP_TOOL_NAMES;
100
+ }
101
+ /** Exposed MCP tool names for a capability profile (persona allowlist source). */
102
+ function listMcpToolNamesByProfile(profile) {
103
+ return getOperationsByProfile(profile).flatMap((operation) => {
104
+ const mcp = operation.mcp;
105
+ if (mcp === undefined || mcp.taskSupport.exposed !== true) {
106
+ return [];
107
+ }
108
+ return [mcp.toolName];
109
+ });
110
+ }
@@ -2,7 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
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 organization_audit_1 = require("./organization-audit");
5
10
  const registry_1 = require("./registry");
11
+ const semantic_layer_1 = require("./semantic-layer");
6
12
  const types_1 = require("./types");
7
13
  const users_1 = require("./users");
8
14
  const P0_OPERATION_IDS = [
@@ -26,6 +32,7 @@ const P0_OPERATION_IDS = [
26
32
  'ai-agents.project.evaluations.runs.list',
27
33
  ];
28
34
  const ALL_PROFILES = [
35
+ 'ai-agent-ops',
29
36
  'core-lifecycle',
30
37
  'evaluations',
31
38
  'conversations',
@@ -40,10 +47,16 @@ function requiredFields(operation) {
40
47
  operation.http.method,
41
48
  operation.http.path,
42
49
  operation.authorization.safetyImpact,
50
+ operation.sensitivity,
43
51
  agentExposure,
44
52
  ];
45
53
  if (agentExposure === 'agent') {
46
- fields.push(operation.mcp.toolName, operation.cli.commandPath);
54
+ if (operation.mcp !== undefined) {
55
+ fields.push(operation.mcp.toolName);
56
+ }
57
+ if (operation.cli !== undefined) {
58
+ fields.push(operation.cli.commandPath);
59
+ }
47
60
  }
48
61
  return fields;
49
62
  }
@@ -58,22 +71,34 @@ function requiredFields(operation) {
58
71
  (0, vitest_1.expect)(new Set(ids).size).toBe(ids.length);
59
72
  });
60
73
  (0, vitest_1.it)('matches aggregated domain export count', () => {
61
- (0, vitest_1.expect)((0, registry_1.listOperations)()).toHaveLength(ai_agents_1.AI_AGENT_OPERATIONS.length + users_1.USER_OPERATIONS.length);
74
+ (0, vitest_1.expect)((0, registry_1.listOperations)()).toHaveLength(ai_agents_1.AI_AGENT_OPERATIONS.length +
75
+ users_1.USER_OPERATIONS.length +
76
+ semantic_layer_1.SEMANTIC_LAYER_OPERATIONS.length +
77
+ organization_audit_1.ORGANIZATION_AUDIT_OPERATIONS.length +
78
+ content_reader_1.CONTENT_READER_OPERATIONS.length +
79
+ content_developer_1.CONTENT_DEVELOPER_OPERATIONS.length +
80
+ content_governance_1.CONTENT_GOVERNANCE_OPERATIONS.length +
81
+ cli_content_1.CLI_CONTENT_OPERATIONS.length);
62
82
  });
63
83
  (0, vitest_1.it)('includes required descriptor fields on every operation', () => {
64
84
  for (const operation of (0, registry_1.listOperations)()) {
65
85
  for (const field of requiredFields(operation)) {
66
86
  (0, vitest_1.expect)(field).toBeTruthy();
67
87
  }
88
+ if (operation.agentExposure === 'agent') {
89
+ (0, vitest_1.expect)(operation.mcp !== undefined || operation.cli !== undefined).toBe(true);
90
+ }
68
91
  (0, vitest_1.expect)(operation.profiles.length).toBeGreaterThan(0);
69
- (0, vitest_1.expect)(operation.http.path.startsWith('/api/v1/')).toBe(true);
92
+ (0, vitest_1.expect)(operation.http.path.startsWith('/api/v1/') || operation.http.path.startsWith('/api/v2/')).toBe(true);
70
93
  }
71
94
  });
72
- (0, vitest_1.it)('assigns idempotentHint correctly for read and destructive operations', () => {
95
+ (0, vitest_1.it)('assigns idempotentHint correctly for read and destructive agent operations', () => {
73
96
  for (const operation of (0, registry_1.listOperations)()) {
97
+ if (operation.mcp === undefined) {
98
+ continue;
99
+ }
74
100
  const { annotations } = operation.mcp;
75
101
  if (operation.authorization.safetyImpact === 'read') {
76
- (0, vitest_1.expect)(annotations.idempotentHint).toBe(true);
77
102
  (0, vitest_1.expect)(annotations.readOnlyHint).toBe(true);
78
103
  }
79
104
  if (operation.authorization.safetyImpact === 'write-destructive') {
@@ -110,12 +135,12 @@ function requiredFields(operation) {
110
135
  (0, vitest_1.expect)((_b = (0, registry_1.getOperation)('ai-agents.project.threads.continue')) === null || _b === void 0 ? void 0 : _b.profiles).toContain('conversations');
111
136
  });
112
137
  (0, vitest_1.it)('documents multi-step workflow for thread start', () => {
113
- var _a;
138
+ var _a, _b;
114
139
  const operation = (0, registry_1.getOperation)('ai-agents.project.threads.start');
115
140
  (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.http.path).toBe('/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads');
116
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.cli.commandPath).toBe('agents threads start');
141
+ (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');
117
142
  (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.workflow).toHaveLength(3);
118
- const lastStep = (_a = operation === null || operation === void 0 ? void 0 : operation.workflow) === null || _a === void 0 ? void 0 : _a[operation.workflow.length - 1];
143
+ const lastStep = (_b = operation === null || operation === void 0 ? void 0 : operation.workflow) === null || _b === void 0 ? void 0 : _b[operation.workflow.length - 1];
119
144
  (0, vitest_1.expect)(lastStep === null || lastStep === void 0 ? void 0 : lastStep.path).toContain('/generate');
120
145
  });
121
146
  (0, vitest_1.it)('documents multi-step workflow for thread continue', () => {
@@ -147,8 +172,9 @@ function requiredFields(operation) {
147
172
  (0, vitest_1.it)('registers users.members.delete as client-only', () => {
148
173
  const operation = (0, registry_1.getOperation)('users.members.delete');
149
174
  (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.agentExposure).toBe('client-only');
150
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.mcp.taskSupport.exposed).toBe(false);
151
- (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.mcp.toolName).toBe('delete_member');
175
+ (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.mcp).toBeUndefined();
176
+ (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.cli).toBeUndefined();
177
+ (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.bannedMcpToolName).toBe('delete_member');
152
178
  (0, vitest_1.expect)(operation === null || operation === void 0 ? void 0 : operation.http.path).toBe('/api/v1/org/user/{userUuid}');
153
179
  });
154
180
  (0, vitest_1.it)('excludes client-only operations from profile discovery catalogs', () => {
@@ -168,7 +194,8 @@ function requiredFields(operation) {
168
194
  (0, vitest_1.it)('never exposes client-only operations on MCP', () => {
169
195
  for (const operation of (0, registry_1.listOperations)()) {
170
196
  if (operation.agentExposure === 'client-only') {
171
- (0, vitest_1.expect)(operation.mcp.taskSupport.exposed).toBe(false);
197
+ (0, vitest_1.expect)(operation.mcp).toBeUndefined();
198
+ (0, vitest_1.expect)(operation.cli).toBeUndefined();
172
199
  }
173
200
  }
174
201
  });
@@ -178,6 +205,7 @@ function requiredFields(operation) {
178
205
  summary: 'Invalid impact pairing',
179
206
  http: { method: 'GET', path: '/api/v1/test' },
180
207
  authorization: { safetyImpact: 'write-destructive' },
208
+ sensitivity: 'none',
181
209
  mcp: {
182
210
  toolName: 'test_tool',
183
211
  annotations: {
@@ -0,0 +1,6 @@
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[];
@@ -0,0 +1,154 @@
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-discovery';
10
+ const API_V1 = '/api/v1';
11
+ const listProjects = (0, types_1.defineOperation)({
12
+ id: 'semantic.projects.list',
13
+ summary: 'List organization projects (or pinned project when HTTP pin is set)',
14
+ http: { method: 'GET', path: `${API_V1}/org/projects` },
15
+ authorization: { safetyImpact: 'read' },
16
+ sensitivity: 'secret.connection',
17
+ mcp: {
18
+ toolName: 'list_projects',
19
+ annotations: safety_1.READ_ONLY_DEFAULT,
20
+ taskSupport: { exposed: true, taskEligible: false },
21
+ },
22
+ cli: { commandPath: 'projects list' },
23
+ profiles: [PROFILE_SEMANTIC],
24
+ });
25
+ const getProject = (0, types_1.defineOperation)({
26
+ id: 'semantic.projects.get',
27
+ summary: 'Get a project by UUID (connection secrets omitted on MCP)',
28
+ http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}` },
29
+ authorization: { safetyImpact: 'read' },
30
+ sensitivity: 'secret.connection',
31
+ mcp: {
32
+ toolName: 'get_project',
33
+ annotations: safety_1.READ_ONLY_DEFAULT,
34
+ taskSupport: { exposed: true, taskEligible: false },
35
+ },
36
+ cli: { commandPath: 'projects get' },
37
+ profiles: [PROFILE_SEMANTIC, 'content-reader', 'content-developer'],
38
+ });
39
+ const listExplores = (0, types_1.defineOperation)({
40
+ id: 'semantic.explores.list',
41
+ summary: 'List explores in a project',
42
+ http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores` },
43
+ authorization: { safetyImpact: 'read' },
44
+ sensitivity: 'none',
45
+ mcp: {
46
+ toolName: 'list_explores',
47
+ annotations: safety_1.READ_ONLY_DEFAULT,
48
+ taskSupport: { exposed: true, taskEligible: false },
49
+ },
50
+ cli: { commandPath: 'projects explores list' },
51
+ profiles: [PROFILE_SEMANTIC],
52
+ });
53
+ const getExplore = (0, types_1.defineOperation)({
54
+ id: 'semantic.explores.get',
55
+ summary: 'Get a full explore definition',
56
+ http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
57
+ authorization: { safetyImpact: 'read' },
58
+ sensitivity: 'none',
59
+ mcp: {
60
+ toolName: 'get_explore',
61
+ annotations: safety_1.READ_ONLY_DEFAULT,
62
+ taskSupport: { exposed: true, taskEligible: false },
63
+ },
64
+ cli: { commandPath: 'projects explores get' },
65
+ profiles: [PROFILE_SEMANTIC],
66
+ });
67
+ const listDimensions = (0, types_1.defineOperation)({
68
+ id: 'semantic.explores.list_dimensions',
69
+ summary: 'List dimensions for an explore (derived from get explore)',
70
+ http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
71
+ authorization: { safetyImpact: 'read' },
72
+ sensitivity: 'none',
73
+ mcp: {
74
+ toolName: 'list_dimensions',
75
+ annotations: safety_1.READ_ONLY_DEFAULT,
76
+ taskSupport: { exposed: true, taskEligible: false },
77
+ },
78
+ cli: { commandPath: 'projects explores dimensions' },
79
+ profiles: [PROFILE_SEMANTIC],
80
+ });
81
+ const getFieldLineage = (0, types_1.defineOperation)({
82
+ id: 'semantic.explores.get_field_lineage',
83
+ summary: 'Get field lineage for an explore field (derived from get explore)',
84
+ http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
85
+ authorization: { safetyImpact: 'read' },
86
+ sensitivity: 'none',
87
+ mcp: {
88
+ toolName: 'get_field_lineage',
89
+ annotations: safety_1.READ_ONLY_DEFAULT,
90
+ taskSupport: { exposed: true, taskEligible: false },
91
+ },
92
+ cli: { commandPath: 'projects explores lineage' },
93
+ profiles: [PROFILE_SEMANTIC],
94
+ });
95
+ const listMetrics = (0, types_1.defineOperation)({
96
+ id: 'semantic.metrics.list',
97
+ summary: 'List metrics in the project data catalog',
98
+ http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics` },
99
+ authorization: { safetyImpact: 'read' },
100
+ sensitivity: 'none',
101
+ mcp: {
102
+ toolName: 'list_metrics',
103
+ annotations: safety_1.READ_ONLY_DEFAULT,
104
+ taskSupport: { exposed: true, taskEligible: false },
105
+ },
106
+ cli: { commandPath: 'metrics list' },
107
+ profiles: [PROFILE_SEMANTIC],
108
+ });
109
+ const getMetric = (0, types_1.defineOperation)({
110
+ id: 'semantic.metrics.get',
111
+ summary: 'Get a metric from the project data catalog',
112
+ http: {
113
+ method: 'GET',
114
+ path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics/{tableName}/{metricName}`,
115
+ },
116
+ authorization: { safetyImpact: 'read' },
117
+ sensitivity: 'none',
118
+ mcp: {
119
+ toolName: 'get_metric',
120
+ annotations: safety_1.READ_ONLY_DEFAULT,
121
+ taskSupport: { exposed: true, taskEligible: false },
122
+ },
123
+ cli: { commandPath: 'metrics get' },
124
+ profiles: [PROFILE_SEMANTIC],
125
+ });
126
+ const compileQuery = (0, types_1.defineOperation)({
127
+ id: 'semantic.query.compile',
128
+ summary: 'Compile a metric query to SQL without executing warehouse rows',
129
+ http: {
130
+ method: 'POST',
131
+ path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}/compileQuery`,
132
+ },
133
+ authorization: { safetyImpact: 'read' },
134
+ sensitivity: 'none',
135
+ mcp: {
136
+ toolName: 'compile_query',
137
+ annotations: safety_1.READ_ONLY_DEFAULT,
138
+ taskSupport: { exposed: true, taskEligible: false },
139
+ },
140
+ cli: { commandPath: 'query compile' },
141
+ profiles: [PROFILE_SEMANTIC],
142
+ });
143
+ /** Semantic-layer operations registered in the shared operation catalog. */
144
+ exports.SEMANTIC_LAYER_OPERATIONS = [
145
+ listProjects,
146
+ getProject,
147
+ listExplores,
148
+ getExplore,
149
+ listDimensions,
150
+ getFieldLineage,
151
+ listMetrics,
152
+ getMetric,
153
+ compileQuery,
154
+ ];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Shared typed operation registry (RFC Section 7).
2
+ * Shared typed operation catalog (ADR-0013).
3
3
  * Single source of truth for HTTP, CLI, and MCP exposure of Lightdash API operations.
4
4
  */
5
5
  import type { SafetyImpact, ToolAnnotations } from '../safety';
@@ -11,7 +11,12 @@ export type HttpMethod = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
11
11
  /**
12
12
  * Capability profiles group operations for selective exposure (CLI profiles, MCP subsets).
13
13
  */
14
- export type CapabilityProfile = 'conversations' | 'core-lifecycle' | 'discovery-readonly' | 'evaluations';
14
+ export type CapabilityProfile = 'ai-agent-ops' | 'content-developer' | 'content-governance' | 'content-reader' | 'conversations' | 'core-lifecycle' | 'discovery-readonly' | 'evaluations' | 'org-audit-readonly' | 'semantic-discovery';
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';
15
20
  /** MCP task semantics for an operation. */
16
21
  export type McpTaskSupport = {
17
22
  /** When true, the operation is exposed as an MCP tool. */
@@ -27,7 +32,7 @@ export type OperationAuthorization = {
27
32
  };
28
33
  export type OperationHttp = {
29
34
  method: HttpMethod;
30
- /** OpenAPI-style path template (includes `/api/v1` prefix). */
35
+ /** OpenAPI-style path template (includes `/api/v1` or `/api/v2` prefix). */
31
36
  path: string;
32
37
  };
33
38
  export type OperationMcp = {
@@ -52,18 +57,30 @@ export type OperationDescriptor = {
52
57
  summary: string;
53
58
  http: OperationHttp;
54
59
  authorization: OperationAuthorization;
55
- mcp: OperationMcp;
56
- cli: OperationCli;
57
- /** `agent` (default) = may be exposed on MCP/CLI; `client-only` = typed client only. */
58
- agentExposure?: AgentExposure;
60
+ /**
61
+ * Response sensitivity class for agent surfaces (ADR-0011).
62
+ * Defaults to `none` when omitted from `defineOperation` input.
63
+ */
64
+ sensitivity: SensitivityClass;
59
65
  profiles: readonly CapabilityProfile[];
66
+ /** `agent` (default) = may appear on MCP and/or CLI; `client-only` = typed client only. */
67
+ agentExposure: AgentExposure;
68
+ /** Present when the operation is registered (or reserved) as an MCP tool. */
69
+ mcp?: OperationMcp;
70
+ /** Present when a real CLI command exists (`commandPath` must match Commander). */
71
+ cli?: OperationCli;
72
+ /** Irrecoverable denylist name for client-only ops (sans `lightdash_` prefix). */
73
+ bannedMcpToolName?: string;
60
74
  /** When set, documents the ordered client-side HTTP steps behind this operation. */
61
75
  workflow?: readonly OperationWorkflowStep[];
62
76
  };
77
+ /** Input to `defineOperation` before defaults are applied. */
78
+ export type OperationDefinitionInput = Omit<OperationDescriptor, 'agentExposure' | 'sensitivity'> & {
79
+ agentExposure?: AgentExposure;
80
+ sensitivity?: SensitivityClass;
81
+ };
63
82
  /**
64
- * Defines a typed operation descriptor with RFC consistency checks.
65
- * Throws when authorization impact disagrees with MCP annotations or profiles are invalid.
83
+ * Defines a typed operation descriptor with catalog consistency checks (ADR-0013).
84
+ * Agent ops require at least one of `mcp` or `cli`. Client-only ops omit both.
66
85
  */
67
- export declare function defineOperation<T extends OperationDescriptor>(descriptor: T): T & {
68
- agentExposure: AgentExposure;
69
- };
86
+ export declare function defineOperation(input: OperationDefinitionInput): OperationDescriptor;
@@ -1,15 +1,27 @@
1
1
  "use strict";
2
2
  /**
3
- * Shared typed operation registry (RFC Section 7).
3
+ * Shared typed operation catalog (ADR-0013).
4
4
  * Single source of truth for HTTP, CLI, and MCP exposure of Lightdash API operations.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.defineOperation = defineOperation;
8
8
  const VALID_PROFILES = new Set([
9
+ 'ai-agent-ops',
10
+ 'content-developer',
11
+ 'content-governance',
12
+ 'content-reader',
9
13
  'conversations',
10
14
  'core-lifecycle',
11
15
  'discovery-readonly',
12
16
  'evaluations',
17
+ 'org-audit-readonly',
18
+ 'semantic-discovery',
19
+ ]);
20
+ const VALID_SENSITIVITY = new Set([
21
+ 'none',
22
+ 'pii.email',
23
+ 'secret.connection',
24
+ 'secret.destination',
13
25
  ]);
14
26
  function assertNonEmpty(value, field) {
15
27
  if (value.trim().length === 0) {
@@ -29,42 +41,65 @@ function expectedImpactFromAnnotations(annotations) {
29
41
  return 'write-nondestructive';
30
42
  }
31
43
  function validateIdempotentHint(annotations, impact, id) {
32
- if (impact === 'read' && annotations.idempotentHint !== true) {
33
- throw new Error(`Operation '${id}': read operations must set mcp.annotations.idempotentHint = true`);
34
- }
35
44
  if (impact === 'write-destructive' && annotations.idempotentHint === true) {
36
45
  throw new Error(`Operation '${id}': destructive operations must not set mcp.annotations.idempotentHint = true`);
37
46
  }
38
47
  }
39
- /**
40
- * Defines a typed operation descriptor with RFC consistency checks.
41
- * Throws when authorization impact disagrees with MCP annotations or profiles are invalid.
42
- */
43
- function defineOperation(descriptor) {
48
+ function validateProfiles(id, profiles) {
49
+ if (profiles.length === 0) {
50
+ throw new Error(`Operation '${id}' must declare at least one capability profile`);
51
+ }
52
+ for (const profile of profiles) {
53
+ if (!VALID_PROFILES.has(profile)) {
54
+ throw new Error(`Operation '${id}' has unknown capability profile '${profile}'`);
55
+ }
56
+ }
57
+ }
58
+ function validateClientOnlyOperation(input) {
44
59
  var _a;
45
- assertNonEmpty(descriptor.id, 'id');
46
- assertNonEmpty(descriptor.summary, 'summary');
47
- assertNonEmpty(descriptor.http.path, 'http.path');
48
- const agentExposure = (_a = descriptor.agentExposure) !== null && _a !== void 0 ? _a : 'agent';
49
- if (agentExposure === 'agent') {
50
- assertNonEmpty(descriptor.mcp.toolName, 'mcp.toolName');
51
- assertNonEmpty(descriptor.cli.commandPath, 'cli.commandPath');
60
+ if (input.mcp !== undefined || input.cli !== undefined) {
61
+ throw new Error(`Operation '${input.id}': client-only operations must omit mcp and cli metadata`);
52
62
  }
53
- if (agentExposure === 'client-only' && descriptor.mcp.taskSupport.exposed) {
54
- throw new Error(`Operation '${descriptor.id}': client-only operations must set mcp.taskSupport.exposed to false`);
63
+ if (input.bannedMcpToolName !== undefined && input.bannedMcpToolName.trim().length === 0) {
64
+ throw new Error(`Operation '${input.id}': bannedMcpToolName must be non-empty when set`);
55
65
  }
56
- if (descriptor.profiles.length === 0) {
57
- throw new Error(`Operation '${descriptor.id}' must declare at least one capability profile`);
66
+ return Object.assign(Object.assign({}, input), { agentExposure: 'client-only', sensitivity: (_a = input.sensitivity) !== null && _a !== void 0 ? _a : 'none' });
67
+ }
68
+ function validateAgentMcp(input) {
69
+ if (input.mcp === undefined) {
70
+ return;
58
71
  }
59
- for (const profile of descriptor.profiles) {
60
- if (!VALID_PROFILES.has(profile)) {
61
- throw new Error(`Operation '${descriptor.id}' has unknown capability profile '${profile}'`);
62
- }
72
+ assertNonEmpty(input.mcp.toolName, 'mcp.toolName');
73
+ const expectedImpact = expectedImpactFromAnnotations(input.mcp.annotations);
74
+ if (input.authorization.safetyImpact !== expectedImpact) {
75
+ throw new Error(`Operation '${input.id}': authorization.safetyImpact is '${input.authorization.safetyImpact}' but MCP annotations imply '${expectedImpact}'`);
76
+ }
77
+ validateIdempotentHint(input.mcp.annotations, input.authorization.safetyImpact, input.id);
78
+ }
79
+ /**
80
+ * Defines a typed operation descriptor with catalog consistency checks (ADR-0013).
81
+ * Agent ops require at least one of `mcp` or `cli`. Client-only ops omit both.
82
+ */
83
+ function defineOperation(input) {
84
+ var _a, _b;
85
+ assertNonEmpty(input.id, 'id');
86
+ assertNonEmpty(input.summary, 'summary');
87
+ assertNonEmpty(input.http.path, 'http.path');
88
+ const sensitivity = (_a = input.sensitivity) !== null && _a !== void 0 ? _a : 'none';
89
+ if (!VALID_SENSITIVITY.has(sensitivity)) {
90
+ throw new Error(`Operation '${input.id}' has unknown sensitivity '${String(sensitivity)}'`);
91
+ }
92
+ validateProfiles(input.id, input.profiles);
93
+ const agentExposure = (_b = input.agentExposure) !== null && _b !== void 0 ? _b : 'agent';
94
+ if (agentExposure === 'client-only') {
95
+ return validateClientOnlyOperation(Object.assign(Object.assign({}, input), { sensitivity }));
96
+ }
97
+ if (input.mcp === undefined && input.cli === undefined) {
98
+ throw new Error(`Operation '${input.id}': agent operations require mcp and/or cli metadata`);
63
99
  }
64
- const expectedImpact = expectedImpactFromAnnotations(descriptor.mcp.annotations);
65
- if (descriptor.authorization.safetyImpact !== expectedImpact) {
66
- throw new Error(`Operation '${descriptor.id}': authorization.safetyImpact is '${descriptor.authorization.safetyImpact}' but MCP annotations imply '${expectedImpact}'`);
100
+ validateAgentMcp(input);
101
+ if (input.cli !== undefined) {
102
+ assertNonEmpty(input.cli.commandPath, 'cli.commandPath');
67
103
  }
68
- validateIdempotentHint(descriptor.mcp.annotations, descriptor.authorization.safetyImpact, descriptor.id);
69
- return Object.assign(Object.assign({}, descriptor), { agentExposure });
104
+ return Object.assign(Object.assign({}, input), { agentExposure: 'agent', sensitivity });
70
105
  }