@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.
- package/dist/argument-validation.js +20 -2
- package/dist/argument-validation.test.js +22 -0
- package/dist/audit.d.ts +29 -9
- package/dist/audit.js +53 -9
- package/dist/audit.test.js +51 -24
- package/dist/env.d.ts +1 -1
- package/dist/env.js +2 -2
- package/dist/index.d.ts +1 -3
- package/dist/index.js +6 -8
- package/dist/operations/agent-safe.d.ts +1 -3
- package/dist/operations/agent-safe.js +2 -9
- package/dist/operations/ai-agents.js +118 -30
- package/dist/operations/cli-content.d.ts +5 -0
- package/dist/operations/cli-content.js +71 -0
- package/dist/operations/client-coverage.d.ts +119 -0
- package/dist/operations/client-coverage.js +137 -0
- package/dist/operations/client-coverage.test.d.ts +1 -0
- package/dist/operations/client-coverage.test.js +22 -0
- package/dist/operations/content-developer.d.ts +2 -0
- package/dist/operations/content-developer.js +471 -0
- package/dist/operations/content-governance.d.ts +7 -0
- package/dist/operations/content-governance.js +98 -0
- package/dist/operations/content-reader.d.ts +2 -0
- package/dist/operations/content-reader.js +197 -0
- package/dist/operations/index.d.ts +10 -3
- package/dist/operations/index.js +20 -2
- package/dist/operations/organization-audit.d.ts +2 -0
- package/dist/operations/organization-audit.js +273 -0
- package/dist/operations/parity.test.js +12 -11
- package/dist/operations/registry.d.ts +9 -1
- package/dist/operations/registry.js +77 -2
- package/dist/operations/registry.test.js +39 -11
- package/dist/operations/semantic-layer.d.ts +6 -0
- package/dist/operations/semantic-layer.js +154 -0
- package/dist/operations/types.d.ts +29 -12
- package/dist/operations/types.js +64 -29
- package/dist/operations/types.test.js +33 -45
- package/dist/operations/users.d.ts +2 -2
- package/dist/operations/users.js +8 -10
- package/dist/safety.d.ts +8 -2
- package/dist/safety.js +22 -4
- package/dist/safety.test.js +29 -6
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +29 -0
- package/package.json +2 -1
- package/src/argument-validation.test.ts +31 -0
- package/src/argument-validation.ts +20 -2
- package/src/audit.test.ts +70 -30
- package/src/audit.ts +88 -12
- package/src/env.ts +1 -1
- package/src/index.ts +5 -9
- package/src/operations/agent-safe.ts +2 -12
- package/src/operations/ai-agents.ts +123 -31
- package/src/operations/cli-content.ts +79 -0
- package/src/operations/client-coverage.test.ts +23 -0
- package/src/operations/client-coverage.ts +153 -0
- package/src/operations/content-developer.ts +501 -0
- package/src/operations/content-governance.ts +110 -0
- package/src/operations/content-reader.ts +212 -0
- package/src/operations/index.ts +25 -2
- package/src/operations/organization-audit.ts +293 -0
- package/src/operations/parity.test.ts +12 -14
- package/src/operations/registry.test.ts +41 -9
- package/src/operations/registry.ts +86 -2
- package/src/operations/semantic-layer.ts +166 -0
- package/src/operations/types.test.ts +38 -76
- package/src/operations/types.ts +112 -47
- package/src/operations/users.ts +9 -11
- package/src/safety.test.ts +32 -6
- package/src/safety.ts +26 -4
- package/src/types/index.ts +13 -0
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
|
|
3
3
|
import { AI_AGENT_OPERATIONS } from './ai-agents';
|
|
4
|
+
import { CLI_CONTENT_OPERATIONS } from './cli-content';
|
|
5
|
+
import { CONTENT_DEVELOPER_OPERATIONS } from './content-developer';
|
|
6
|
+
import { CONTENT_GOVERNANCE_OPERATIONS } from './content-governance';
|
|
7
|
+
import { CONTENT_READER_OPERATIONS } from './content-reader';
|
|
8
|
+
import { ORGANIZATION_AUDIT_OPERATIONS } from './organization-audit';
|
|
4
9
|
import { getOperation, getOperationsByProfile, listOperations } from './registry';
|
|
10
|
+
import { SEMANTIC_LAYER_OPERATIONS } from './semantic-layer';
|
|
5
11
|
import { defineOperation } from './types';
|
|
6
12
|
import { USER_OPERATIONS } from './users';
|
|
7
13
|
|
|
@@ -29,6 +35,7 @@ const P0_OPERATION_IDS = [
|
|
|
29
35
|
] as const;
|
|
30
36
|
|
|
31
37
|
const ALL_PROFILES: CapabilityProfile[] = [
|
|
38
|
+
'ai-agent-ops',
|
|
32
39
|
'core-lifecycle',
|
|
33
40
|
'evaluations',
|
|
34
41
|
'conversations',
|
|
@@ -43,10 +50,16 @@ function requiredFields(operation: OperationDescriptor): string[] {
|
|
|
43
50
|
operation.http.method,
|
|
44
51
|
operation.http.path,
|
|
45
52
|
operation.authorization.safetyImpact,
|
|
53
|
+
operation.sensitivity,
|
|
46
54
|
agentExposure,
|
|
47
55
|
];
|
|
48
56
|
if (agentExposure === 'agent') {
|
|
49
|
-
|
|
57
|
+
if (operation.mcp !== undefined) {
|
|
58
|
+
fields.push(operation.mcp.toolName);
|
|
59
|
+
}
|
|
60
|
+
if (operation.cli !== undefined) {
|
|
61
|
+
fields.push(operation.cli.commandPath);
|
|
62
|
+
}
|
|
50
63
|
}
|
|
51
64
|
return fields;
|
|
52
65
|
}
|
|
@@ -64,7 +77,16 @@ describe('operation registry', () => {
|
|
|
64
77
|
});
|
|
65
78
|
|
|
66
79
|
it('matches aggregated domain export count', () => {
|
|
67
|
-
expect(listOperations()).toHaveLength(
|
|
80
|
+
expect(listOperations()).toHaveLength(
|
|
81
|
+
AI_AGENT_OPERATIONS.length +
|
|
82
|
+
USER_OPERATIONS.length +
|
|
83
|
+
SEMANTIC_LAYER_OPERATIONS.length +
|
|
84
|
+
ORGANIZATION_AUDIT_OPERATIONS.length +
|
|
85
|
+
CONTENT_READER_OPERATIONS.length +
|
|
86
|
+
CONTENT_DEVELOPER_OPERATIONS.length +
|
|
87
|
+
CONTENT_GOVERNANCE_OPERATIONS.length +
|
|
88
|
+
CLI_CONTENT_OPERATIONS.length,
|
|
89
|
+
);
|
|
68
90
|
});
|
|
69
91
|
|
|
70
92
|
it('includes required descriptor fields on every operation', () => {
|
|
@@ -72,16 +94,23 @@ describe('operation registry', () => {
|
|
|
72
94
|
for (const field of requiredFields(operation)) {
|
|
73
95
|
expect(field).toBeTruthy();
|
|
74
96
|
}
|
|
97
|
+
if (operation.agentExposure === 'agent') {
|
|
98
|
+
expect(operation.mcp !== undefined || operation.cli !== undefined).toBe(true);
|
|
99
|
+
}
|
|
75
100
|
expect(operation.profiles.length).toBeGreaterThan(0);
|
|
76
|
-
expect(
|
|
101
|
+
expect(
|
|
102
|
+
operation.http.path.startsWith('/api/v1/') || operation.http.path.startsWith('/api/v2/'),
|
|
103
|
+
).toBe(true);
|
|
77
104
|
}
|
|
78
105
|
});
|
|
79
106
|
|
|
80
|
-
it('assigns idempotentHint correctly for read and destructive operations', () => {
|
|
107
|
+
it('assigns idempotentHint correctly for read and destructive agent operations', () => {
|
|
81
108
|
for (const operation of listOperations()) {
|
|
109
|
+
if (operation.mcp === undefined) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
82
112
|
const { annotations } = operation.mcp;
|
|
83
113
|
if (operation.authorization.safetyImpact === 'read') {
|
|
84
|
-
expect(annotations.idempotentHint).toBe(true);
|
|
85
114
|
expect(annotations.readOnlyHint).toBe(true);
|
|
86
115
|
}
|
|
87
116
|
if (operation.authorization.safetyImpact === 'write-destructive') {
|
|
@@ -125,7 +154,7 @@ describe('operation registry', () => {
|
|
|
125
154
|
expect(operation?.http.path).toBe(
|
|
126
155
|
'/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads',
|
|
127
156
|
);
|
|
128
|
-
expect(operation?.cli
|
|
157
|
+
expect(operation?.cli?.commandPath).toBe('agents threads start');
|
|
129
158
|
expect(operation?.workflow).toHaveLength(3);
|
|
130
159
|
const lastStep = operation?.workflow?.[operation.workflow.length - 1];
|
|
131
160
|
expect(lastStep?.path).toContain('/generate');
|
|
@@ -162,8 +191,9 @@ describe('operation registry', () => {
|
|
|
162
191
|
it('registers users.members.delete as client-only', () => {
|
|
163
192
|
const operation = getOperation('users.members.delete');
|
|
164
193
|
expect(operation?.agentExposure).toBe('client-only');
|
|
165
|
-
expect(operation?.mcp
|
|
166
|
-
expect(operation?.
|
|
194
|
+
expect(operation?.mcp).toBeUndefined();
|
|
195
|
+
expect(operation?.cli).toBeUndefined();
|
|
196
|
+
expect(operation?.bannedMcpToolName).toBe('delete_member');
|
|
167
197
|
expect(operation?.http.path).toBe('/api/v1/org/user/{userUuid}');
|
|
168
198
|
});
|
|
169
199
|
|
|
@@ -188,7 +218,8 @@ describe('operation registry', () => {
|
|
|
188
218
|
it('never exposes client-only operations on MCP', () => {
|
|
189
219
|
for (const operation of listOperations()) {
|
|
190
220
|
if (operation.agentExposure === 'client-only') {
|
|
191
|
-
expect(operation.mcp
|
|
221
|
+
expect(operation.mcp).toBeUndefined();
|
|
222
|
+
expect(operation.cli).toBeUndefined();
|
|
192
223
|
}
|
|
193
224
|
}
|
|
194
225
|
});
|
|
@@ -200,6 +231,7 @@ describe('operation registry', () => {
|
|
|
200
231
|
summary: 'Invalid impact pairing',
|
|
201
232
|
http: { method: 'GET', path: '/api/v1/test' },
|
|
202
233
|
authorization: { safetyImpact: 'write-destructive' },
|
|
234
|
+
sensitivity: 'none',
|
|
203
235
|
mcp: {
|
|
204
236
|
toolName: 'test_tool',
|
|
205
237
|
annotations: {
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Central operation
|
|
2
|
+
* Central operation catalog — aggregates domain modules and exposes lookup helpers.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { AI_AGENT_OPERATIONS } from './ai-agents';
|
|
6
|
+
import { CLI_CONTENT_OPERATIONS } from './cli-content';
|
|
7
|
+
import { CONTENT_DEVELOPER_OPERATIONS } from './content-developer';
|
|
8
|
+
import { CONTENT_GOVERNANCE_OPERATIONS } from './content-governance';
|
|
9
|
+
import { CONTENT_READER_OPERATIONS } from './content-reader';
|
|
10
|
+
import { ORGANIZATION_AUDIT_OPERATIONS } from './organization-audit';
|
|
11
|
+
import { SEMANTIC_LAYER_OPERATIONS } from './semantic-layer';
|
|
6
12
|
import { USER_OPERATIONS } from './users';
|
|
7
13
|
|
|
8
14
|
import type { CapabilityProfile, OperationDescriptor } from './types';
|
|
9
15
|
|
|
10
|
-
const
|
|
16
|
+
const AGENT_EXPOSURE_CLIENT_ONLY = 'client-only' as const;
|
|
17
|
+
|
|
18
|
+
const ALL_OPERATIONS: readonly OperationDescriptor[] = [
|
|
19
|
+
...AI_AGENT_OPERATIONS,
|
|
20
|
+
...USER_OPERATIONS,
|
|
21
|
+
...SEMANTIC_LAYER_OPERATIONS,
|
|
22
|
+
...ORGANIZATION_AUDIT_OPERATIONS,
|
|
23
|
+
...CONTENT_READER_OPERATIONS,
|
|
24
|
+
...CONTENT_DEVELOPER_OPERATIONS,
|
|
25
|
+
...CONTENT_GOVERNANCE_OPERATIONS,
|
|
26
|
+
...CLI_CONTENT_OPERATIONS,
|
|
27
|
+
];
|
|
11
28
|
|
|
12
29
|
const operationsById = new Map<string, OperationDescriptor>(
|
|
13
30
|
ALL_OPERATIONS.map((operation) => [operation.id, operation]),
|
|
@@ -25,11 +42,57 @@ if (operationsById.size !== ALL_OPERATIONS.length) {
|
|
|
25
42
|
throw new Error(`Duplicate operation ids in registry: ${duplicates.join(', ')}`);
|
|
26
43
|
}
|
|
27
44
|
|
|
45
|
+
const operationsByMcpToolName = new Map<string, OperationDescriptor>();
|
|
46
|
+
for (const operation of ALL_OPERATIONS) {
|
|
47
|
+
if (operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY || operation.mcp === undefined) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// Index only exposed tools so lookups match registerToolsByIds / schema honesty.
|
|
51
|
+
if (!operation.mcp.taskSupport.exposed) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const toolName = operation.mcp.toolName;
|
|
55
|
+
if (operationsByMcpToolName.has(toolName)) {
|
|
56
|
+
throw new Error(`Duplicate MCP toolName in operation catalog: ${toolName}`);
|
|
57
|
+
}
|
|
58
|
+
operationsByMcpToolName.set(toolName, operation);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const EXPOSED_MCP_TOOL_NAMES: readonly string[] = ALL_OPERATIONS.filter(
|
|
62
|
+
(operation) =>
|
|
63
|
+
operation.agentExposure === 'agent' &&
|
|
64
|
+
operation.mcp !== undefined &&
|
|
65
|
+
operation.mcp.taskSupport.exposed,
|
|
66
|
+
).map((operation) => {
|
|
67
|
+
const mcp = operation.mcp;
|
|
68
|
+
if (mcp === undefined) {
|
|
69
|
+
throw new Error(`Invariant: exposed filter retained operation without mcp (${operation.id})`);
|
|
70
|
+
}
|
|
71
|
+
return mcp.toolName;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const BANNED_MCP_TOOL_NAMES: readonly string[] = ALL_OPERATIONS.filter(
|
|
75
|
+
(operation) =>
|
|
76
|
+
operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY &&
|
|
77
|
+
typeof operation.bannedMcpToolName === 'string' &&
|
|
78
|
+
operation.bannedMcpToolName.trim().length > 0,
|
|
79
|
+
).map((operation) => {
|
|
80
|
+
const banned = operation.bannedMcpToolName;
|
|
81
|
+
if (banned === undefined) {
|
|
82
|
+
throw new Error(`Invariant: banned filter retained operation without name (${operation.id})`);
|
|
83
|
+
}
|
|
84
|
+
return banned;
|
|
85
|
+
});
|
|
28
86
|
/** Returns a registered operation by id, or undefined when not found. */
|
|
29
87
|
export function getOperation(id: string): OperationDescriptor | undefined {
|
|
30
88
|
return operationsById.get(id);
|
|
31
89
|
}
|
|
32
90
|
|
|
91
|
+
/** Returns the agent operation registered for an MCP tool name (sans prefix), if any. */
|
|
92
|
+
export function getOperationByMcpToolName(toolName: string): OperationDescriptor | undefined {
|
|
93
|
+
return operationsByMcpToolName.get(toolName);
|
|
94
|
+
}
|
|
95
|
+
|
|
33
96
|
/** Returns every registered operation descriptor. */
|
|
34
97
|
export function listOperations(): readonly OperationDescriptor[] {
|
|
35
98
|
return ALL_OPERATIONS;
|
|
@@ -42,3 +105,24 @@ export function getOperationsByProfile(profile: CapabilityProfile): readonly Ope
|
|
|
42
105
|
operation.agentExposure !== 'client-only' && operation.profiles.includes(profile),
|
|
43
106
|
);
|
|
44
107
|
}
|
|
108
|
+
|
|
109
|
+
/** MCP tool names (sans prefix) with `mcp.taskSupport.exposed === true`. */
|
|
110
|
+
export function listExposedMcpToolNames(): readonly string[] {
|
|
111
|
+
return EXPOSED_MCP_TOOL_NAMES;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** MCP tool names that must never be registered (client-only denylist). */
|
|
115
|
+
export function listBannedMcpToolNames(): readonly string[] {
|
|
116
|
+
return BANNED_MCP_TOOL_NAMES;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Exposed MCP tool names for a capability profile (persona allowlist source). */
|
|
120
|
+
export function listMcpToolNamesByProfile(profile: CapabilityProfile): readonly string[] {
|
|
121
|
+
return getOperationsByProfile(profile).flatMap((operation) => {
|
|
122
|
+
const mcp = operation.mcp;
|
|
123
|
+
if (mcp === undefined || mcp.taskSupport.exposed !== true) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
return [mcp.toolName];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic-layer MCP/CLI operations in the shared operation catalog (ADR-0013).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { READ_ONLY_DEFAULT } from '../safety';
|
|
6
|
+
|
|
7
|
+
import { defineOperation } from './types';
|
|
8
|
+
|
|
9
|
+
import type { CapabilityProfile, OperationDescriptor } from './types';
|
|
10
|
+
|
|
11
|
+
const PROFILE_SEMANTIC: CapabilityProfile = 'semantic-discovery';
|
|
12
|
+
const API_V1 = '/api/v1';
|
|
13
|
+
|
|
14
|
+
const listProjects = defineOperation({
|
|
15
|
+
id: 'semantic.projects.list',
|
|
16
|
+
summary: 'List organization projects (or pinned project when HTTP pin is set)',
|
|
17
|
+
http: { method: 'GET', path: `${API_V1}/org/projects` },
|
|
18
|
+
authorization: { safetyImpact: 'read' },
|
|
19
|
+
sensitivity: 'secret.connection',
|
|
20
|
+
mcp: {
|
|
21
|
+
toolName: 'list_projects',
|
|
22
|
+
annotations: READ_ONLY_DEFAULT,
|
|
23
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
24
|
+
},
|
|
25
|
+
cli: { commandPath: 'projects list' },
|
|
26
|
+
profiles: [PROFILE_SEMANTIC],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const getProject = defineOperation({
|
|
30
|
+
id: 'semantic.projects.get',
|
|
31
|
+
summary: 'Get a project by UUID (connection secrets omitted on MCP)',
|
|
32
|
+
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}` },
|
|
33
|
+
authorization: { safetyImpact: 'read' },
|
|
34
|
+
sensitivity: 'secret.connection',
|
|
35
|
+
mcp: {
|
|
36
|
+
toolName: 'get_project',
|
|
37
|
+
annotations: READ_ONLY_DEFAULT,
|
|
38
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
39
|
+
},
|
|
40
|
+
cli: { commandPath: 'projects get' },
|
|
41
|
+
profiles: [PROFILE_SEMANTIC, 'content-reader', 'content-developer'],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const listExplores = defineOperation({
|
|
45
|
+
id: 'semantic.explores.list',
|
|
46
|
+
summary: 'List explores in a project',
|
|
47
|
+
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores` },
|
|
48
|
+
authorization: { safetyImpact: 'read' },
|
|
49
|
+
sensitivity: 'none',
|
|
50
|
+
mcp: {
|
|
51
|
+
toolName: 'list_explores',
|
|
52
|
+
annotations: READ_ONLY_DEFAULT,
|
|
53
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
54
|
+
},
|
|
55
|
+
cli: { commandPath: 'projects explores list' },
|
|
56
|
+
profiles: [PROFILE_SEMANTIC],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const getExplore = defineOperation({
|
|
60
|
+
id: 'semantic.explores.get',
|
|
61
|
+
summary: 'Get a full explore definition',
|
|
62
|
+
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
|
|
63
|
+
authorization: { safetyImpact: 'read' },
|
|
64
|
+
sensitivity: 'none',
|
|
65
|
+
mcp: {
|
|
66
|
+
toolName: 'get_explore',
|
|
67
|
+
annotations: READ_ONLY_DEFAULT,
|
|
68
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
69
|
+
},
|
|
70
|
+
cli: { commandPath: 'projects explores get' },
|
|
71
|
+
profiles: [PROFILE_SEMANTIC],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const listDimensions = defineOperation({
|
|
75
|
+
id: 'semantic.explores.list_dimensions',
|
|
76
|
+
summary: 'List dimensions for an explore (derived from get explore)',
|
|
77
|
+
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
|
|
78
|
+
authorization: { safetyImpact: 'read' },
|
|
79
|
+
sensitivity: 'none',
|
|
80
|
+
mcp: {
|
|
81
|
+
toolName: 'list_dimensions',
|
|
82
|
+
annotations: READ_ONLY_DEFAULT,
|
|
83
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
84
|
+
},
|
|
85
|
+
cli: { commandPath: 'projects explores dimensions' },
|
|
86
|
+
profiles: [PROFILE_SEMANTIC],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const getFieldLineage = defineOperation({
|
|
90
|
+
id: 'semantic.explores.get_field_lineage',
|
|
91
|
+
summary: 'Get field lineage for an explore field (derived from get explore)',
|
|
92
|
+
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
|
|
93
|
+
authorization: { safetyImpact: 'read' },
|
|
94
|
+
sensitivity: 'none',
|
|
95
|
+
mcp: {
|
|
96
|
+
toolName: 'get_field_lineage',
|
|
97
|
+
annotations: READ_ONLY_DEFAULT,
|
|
98
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
99
|
+
},
|
|
100
|
+
cli: { commandPath: 'projects explores lineage' },
|
|
101
|
+
profiles: [PROFILE_SEMANTIC],
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const listMetrics = defineOperation({
|
|
105
|
+
id: 'semantic.metrics.list',
|
|
106
|
+
summary: 'List metrics in the project data catalog',
|
|
107
|
+
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics` },
|
|
108
|
+
authorization: { safetyImpact: 'read' },
|
|
109
|
+
sensitivity: 'none',
|
|
110
|
+
mcp: {
|
|
111
|
+
toolName: 'list_metrics',
|
|
112
|
+
annotations: READ_ONLY_DEFAULT,
|
|
113
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
114
|
+
},
|
|
115
|
+
cli: { commandPath: 'metrics list' },
|
|
116
|
+
profiles: [PROFILE_SEMANTIC],
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const getMetric = defineOperation({
|
|
120
|
+
id: 'semantic.metrics.get',
|
|
121
|
+
summary: 'Get a metric from the project data catalog',
|
|
122
|
+
http: {
|
|
123
|
+
method: 'GET',
|
|
124
|
+
path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics/{tableName}/{metricName}`,
|
|
125
|
+
},
|
|
126
|
+
authorization: { safetyImpact: 'read' },
|
|
127
|
+
sensitivity: 'none',
|
|
128
|
+
mcp: {
|
|
129
|
+
toolName: 'get_metric',
|
|
130
|
+
annotations: READ_ONLY_DEFAULT,
|
|
131
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
132
|
+
},
|
|
133
|
+
cli: { commandPath: 'metrics get' },
|
|
134
|
+
profiles: [PROFILE_SEMANTIC],
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const compileQuery = defineOperation({
|
|
138
|
+
id: 'semantic.query.compile',
|
|
139
|
+
summary: 'Compile a metric query to SQL without executing warehouse rows',
|
|
140
|
+
http: {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}/compileQuery`,
|
|
143
|
+
},
|
|
144
|
+
authorization: { safetyImpact: 'read' },
|
|
145
|
+
sensitivity: 'none',
|
|
146
|
+
mcp: {
|
|
147
|
+
toolName: 'compile_query',
|
|
148
|
+
annotations: READ_ONLY_DEFAULT,
|
|
149
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
150
|
+
},
|
|
151
|
+
cli: { commandPath: 'query compile' },
|
|
152
|
+
profiles: [PROFILE_SEMANTIC],
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/** Semantic-layer operations registered in the shared operation catalog. */
|
|
156
|
+
export const SEMANTIC_LAYER_OPERATIONS: readonly OperationDescriptor[] = [
|
|
157
|
+
listProjects,
|
|
158
|
+
getProject,
|
|
159
|
+
listExplores,
|
|
160
|
+
getExplore,
|
|
161
|
+
listDimensions,
|
|
162
|
+
getFieldLineage,
|
|
163
|
+
listMetrics,
|
|
164
|
+
getMetric,
|
|
165
|
+
compileQuery,
|
|
166
|
+
];
|
|
@@ -7,6 +7,7 @@ const baseDescriptor = {
|
|
|
7
7
|
summary: 'Test operation',
|
|
8
8
|
http: { method: 'GET' as const, path: '/api/v1/test' },
|
|
9
9
|
authorization: { safetyImpact: 'read' as const },
|
|
10
|
+
sensitivity: 'none' as const,
|
|
10
11
|
mcp: {
|
|
11
12
|
toolName: 'test_op',
|
|
12
13
|
annotations: {
|
|
@@ -27,31 +28,40 @@ describe('defineOperation', () => {
|
|
|
27
28
|
expect(defineOperation(baseDescriptor)).toEqual({
|
|
28
29
|
...baseDescriptor,
|
|
29
30
|
agentExposure: 'agent',
|
|
31
|
+
sensitivity: 'none',
|
|
30
32
|
});
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
it('defaults agentExposure to agent', () => {
|
|
34
|
-
const { agentExposure, ...
|
|
35
|
+
it('defaults agentExposure to agent and sensitivity to none', () => {
|
|
36
|
+
const { agentExposure, sensitivity, ...withoutDefaults } = baseDescriptor;
|
|
35
37
|
void agentExposure;
|
|
36
|
-
|
|
38
|
+
void sensitivity;
|
|
39
|
+
const op = defineOperation(withoutDefaults);
|
|
40
|
+
expect(op.agentExposure).toBe('agent');
|
|
41
|
+
expect(op.sensitivity).toBe('none');
|
|
37
42
|
});
|
|
38
43
|
|
|
39
|
-
it('
|
|
40
|
-
|
|
44
|
+
it('allows agent ops with mcp only', () => {
|
|
45
|
+
const { cli: _cli, ...rest } = baseDescriptor;
|
|
46
|
+
void _cli;
|
|
47
|
+
expect(defineOperation(rest).cli).toBeUndefined();
|
|
41
48
|
});
|
|
42
49
|
|
|
43
|
-
it('
|
|
44
|
-
|
|
50
|
+
it('allows agent ops with cli only', () => {
|
|
51
|
+
const { mcp: _mcp, ...rest } = baseDescriptor;
|
|
52
|
+
void _mcp;
|
|
53
|
+
expect(defineOperation(rest).mcp).toBeUndefined();
|
|
45
54
|
});
|
|
46
55
|
|
|
47
|
-
it('rejects
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
it('rejects agent ops with neither mcp nor cli', () => {
|
|
57
|
+
const { mcp: _mcp, cli: _cli, ...rest } = baseDescriptor;
|
|
58
|
+
void _mcp;
|
|
59
|
+
void _cli;
|
|
60
|
+
expect(() => defineOperation(rest)).toThrow(/require mcp and\/or cli/);
|
|
51
61
|
});
|
|
52
62
|
|
|
53
|
-
it('rejects empty
|
|
54
|
-
expect(() => defineOperation({ ...baseDescriptor,
|
|
63
|
+
it('rejects empty id', () => {
|
|
64
|
+
expect(() => defineOperation({ ...baseDescriptor, id: ' ' })).toThrow(/id/);
|
|
55
65
|
});
|
|
56
66
|
|
|
57
67
|
it('rejects unknown profile', () => {
|
|
@@ -63,86 +73,38 @@ describe('defineOperation', () => {
|
|
|
63
73
|
).toThrow(/unknown capability profile/);
|
|
64
74
|
});
|
|
65
75
|
|
|
66
|
-
it('
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
mcp
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
).toThrow(/idempotentHint/);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('rejects destructive operation with idempotentHint true', () => {
|
|
79
|
-
expect(() =>
|
|
80
|
-
defineOperation({
|
|
81
|
-
...baseDescriptor,
|
|
82
|
-
authorization: { safetyImpact: 'write-destructive' },
|
|
83
|
-
mcp: {
|
|
84
|
-
...baseDescriptor.mcp,
|
|
85
|
-
annotations: {
|
|
86
|
-
readOnlyHint: false,
|
|
87
|
-
destructiveHint: true,
|
|
88
|
-
idempotentHint: true,
|
|
89
|
-
openWorldHint: false,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
}),
|
|
93
|
-
).toThrow(/destructive operations/);
|
|
76
|
+
it('allows read operation with idempotentHint false (transient execution)', () => {
|
|
77
|
+
const op = defineOperation({
|
|
78
|
+
...baseDescriptor,
|
|
79
|
+
mcp: {
|
|
80
|
+
...baseDescriptor.mcp,
|
|
81
|
+
annotations: { ...baseDescriptor.mcp.annotations, idempotentHint: false },
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
expect(op.mcp?.annotations.idempotentHint).toBe(false);
|
|
94
85
|
});
|
|
95
86
|
|
|
96
|
-
it('rejects client-only operation
|
|
87
|
+
it('rejects client-only operation that still has mcp', () => {
|
|
97
88
|
expect(() =>
|
|
98
89
|
defineOperation({
|
|
99
90
|
...baseDescriptor,
|
|
100
91
|
agentExposure: 'client-only',
|
|
101
|
-
mcp: {
|
|
102
|
-
...baseDescriptor.mcp,
|
|
103
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
104
|
-
},
|
|
105
92
|
}),
|
|
106
|
-
).toThrow(/
|
|
93
|
+
).toThrow(/must omit mcp and cli/);
|
|
107
94
|
});
|
|
108
95
|
|
|
109
|
-
it('allows client-only operation
|
|
96
|
+
it('allows client-only operation with bannedMcpToolName and no mcp/cli', () => {
|
|
110
97
|
const op = defineOperation({
|
|
111
98
|
id: 'test.client-only',
|
|
112
99
|
summary: 'Client only delete',
|
|
113
100
|
http: { method: 'DELETE', path: '/api/v1/test/{id}' },
|
|
114
101
|
authorization: { safetyImpact: 'write-destructive' },
|
|
115
|
-
mcp: {
|
|
116
|
-
toolName: '',
|
|
117
|
-
annotations: {
|
|
118
|
-
readOnlyHint: false,
|
|
119
|
-
destructiveHint: true,
|
|
120
|
-
idempotentHint: false,
|
|
121
|
-
openWorldHint: false,
|
|
122
|
-
},
|
|
123
|
-
taskSupport: { exposed: false, taskEligible: false },
|
|
124
|
-
},
|
|
125
|
-
cli: { commandPath: '' },
|
|
126
102
|
agentExposure: 'client-only',
|
|
103
|
+
bannedMcpToolName: 'delete_test',
|
|
127
104
|
profiles: ['discovery-readonly'],
|
|
128
105
|
});
|
|
129
106
|
expect(op.agentExposure).toBe('client-only');
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
it('maps openWorldHint to external-side-effect impact', () => {
|
|
133
|
-
const op = defineOperation({
|
|
134
|
-
...baseDescriptor,
|
|
135
|
-
authorization: { safetyImpact: 'external-side-effect' },
|
|
136
|
-
mcp: {
|
|
137
|
-
...baseDescriptor.mcp,
|
|
138
|
-
annotations: {
|
|
139
|
-
readOnlyHint: false,
|
|
140
|
-
destructiveHint: false,
|
|
141
|
-
idempotentHint: false,
|
|
142
|
-
openWorldHint: true,
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
expect(op.authorization.safetyImpact).toBe('external-side-effect');
|
|
107
|
+
expect(op.bannedMcpToolName).toBe('delete_test');
|
|
108
|
+
expect(op.sensitivity).toBe('none');
|
|
147
109
|
});
|
|
148
110
|
});
|