@lightdash-tools/common 0.12.0 → 0.13.1
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/agent-safe.d.ts +4 -0
- package/dist/agent-safe.js +13 -0
- package/dist/audit.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/profile-ids.d.ts +5 -0
- package/dist/profile-ids.js +15 -0
- package/package.json +1 -3
- package/src/agent-safe.ts +11 -0
- package/src/audit.ts +1 -1
- package/src/index.ts +5 -2
- package/src/profile-ids.ts +15 -0
- package/dist/operations/agent-safe.d.ts +0 -5
- package/dist/operations/agent-safe.js +0 -9
- package/dist/operations/ai-agents.d.ts +0 -6
- package/dist/operations/ai-agents.js +0 -495
- package/dist/operations/cli-content.d.ts +0 -5
- package/dist/operations/cli-content.js +0 -69
- package/dist/operations/client-coverage.d.ts +0 -120
- package/dist/operations/client-coverage.js +0 -139
- package/dist/operations/client-coverage.test.d.ts +0 -1
- package/dist/operations/client-coverage.test.js +0 -22
- package/dist/operations/content-developer.d.ts +0 -2
- package/dist/operations/content-developer.js +0 -471
- package/dist/operations/content-governance.d.ts +0 -7
- package/dist/operations/content-governance.js +0 -98
- package/dist/operations/content-reader.d.ts +0 -2
- package/dist/operations/content-reader.js +0 -198
- package/dist/operations/data-analyst.d.ts +0 -5
- package/dist/operations/data-analyst.js +0 -23
- package/dist/operations/index.d.ts +0 -13
- package/dist/operations/index.js +0 -37
- package/dist/operations/organization-audit.d.ts +0 -2
- package/dist/operations/organization-audit.js +0 -273
- package/dist/operations/parity.test.d.ts +0 -1
- package/dist/operations/parity.test.js +0 -29
- package/dist/operations/registry.d.ts +0 -18
- package/dist/operations/registry.js +0 -136
- package/dist/operations/registry.test.d.ts +0 -1
- package/dist/operations/registry.test.js +0 -201
- package/dist/operations/semantic-layer.d.ts +0 -6
- package/dist/operations/semantic-layer.js +0 -155
- package/dist/operations/types.d.ts +0 -90
- package/dist/operations/types.js +0 -113
- package/dist/operations/types.test.d.ts +0 -1
- package/dist/operations/types.test.js +0 -101
- package/dist/operations/users.d.ts +0 -6
- package/dist/operations/users.js +0 -56
- package/src/operations/agent-safe.ts +0 -8
- package/src/operations/ai-agents.ts +0 -539
- package/src/operations/cli-content.ts +0 -76
- package/src/operations/client-coverage.test.ts +0 -23
- package/src/operations/client-coverage.ts +0 -156
- package/src/operations/content-developer.ts +0 -501
- package/src/operations/content-governance.ts +0 -110
- package/src/operations/content-reader.ts +0 -213
- package/src/operations/data-analyst.ts +0 -27
- package/src/operations/index.ts +0 -44
- package/src/operations/organization-audit.ts +0 -293
- package/src/operations/parity.test.ts +0 -33
- package/src/operations/registry.test.ts +0 -229
- package/src/operations/registry.ts +0 -158
- package/src/operations/semantic-layer.ts +0 -167
- package/src/operations/types.test.ts +0 -138
- package/src/operations/types.ts +0 -241
- package/src/operations/users.ts +0 -62
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { listBannedMcpToolNames, listOperations } from './registry';
|
|
4
|
-
|
|
5
|
-
describe('agent-safe surface parity', () => {
|
|
6
|
-
it('requires MCP tool name or CLI path for agent operations', () => {
|
|
7
|
-
const agentOps = listOperations().filter((operation) => operation.agentExposure === 'agent');
|
|
8
|
-
|
|
9
|
-
expect(agentOps.length).toBeGreaterThan(0);
|
|
10
|
-
|
|
11
|
-
for (const operation of agentOps) {
|
|
12
|
-
const hasMcp = operation.mcp !== undefined && operation.mcp.toolName.trim().length > 0;
|
|
13
|
-
const hasCli = operation.cli !== undefined && operation.cli.commandPath.trim().length > 0;
|
|
14
|
-
expect(hasMcp || hasCli).toBe(true);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('keeps client-only banned MCP tool names off the agent surface', () => {
|
|
19
|
-
const banned = listBannedMcpToolNames();
|
|
20
|
-
expect(banned).toContain('delete_member');
|
|
21
|
-
|
|
22
|
-
for (const operation of listOperations()) {
|
|
23
|
-
if (operation.agentExposure !== 'client-only') {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
expect(operation.mcp).toBeUndefined();
|
|
27
|
-
expect(operation.cli).toBeUndefined();
|
|
28
|
-
if (operation.bannedMcpToolName) {
|
|
29
|
-
expect(banned).toContain(operation.bannedMcpToolName);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
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 { DATA_ANALYST_OPERATIONS } from './data-analyst';
|
|
9
|
-
import { ORGANIZATION_AUDIT_OPERATIONS } from './organization-audit';
|
|
10
|
-
import {
|
|
11
|
-
getOperation,
|
|
12
|
-
getOperationsByProfile,
|
|
13
|
-
listMcpToolNamesByProfile,
|
|
14
|
-
listOperations,
|
|
15
|
-
} from './registry';
|
|
16
|
-
import { SEMANTIC_LAYER_OPERATIONS } from './semantic-layer';
|
|
17
|
-
import { defineOperation, PROFILE_IDS } from './types';
|
|
18
|
-
import { USER_OPERATIONS } from './users';
|
|
19
|
-
|
|
20
|
-
import type { OperationDescriptor, ProfileId } from './types';
|
|
21
|
-
|
|
22
|
-
const P0_OPERATION_IDS = [
|
|
23
|
-
'ai-agents.admin.agents.list',
|
|
24
|
-
'ai-agents.admin.settings.get',
|
|
25
|
-
'ai-agents.admin.settings.update',
|
|
26
|
-
'ai-agents.project.agents.list',
|
|
27
|
-
'ai-agents.project.agents.get',
|
|
28
|
-
'ai-agents.project.agents.create',
|
|
29
|
-
'ai-agents.project.agents.update',
|
|
30
|
-
'ai-agents.project.agents.delete',
|
|
31
|
-
'ai-agents.project.threads.start',
|
|
32
|
-
'ai-agents.project.threads.continue',
|
|
33
|
-
'ai-agents.project.evaluations.list',
|
|
34
|
-
'ai-agents.project.evaluations.get',
|
|
35
|
-
'ai-agents.project.evaluations.create',
|
|
36
|
-
'ai-agents.project.evaluations.update',
|
|
37
|
-
'ai-agents.project.evaluations.append',
|
|
38
|
-
'ai-agents.project.evaluations.delete',
|
|
39
|
-
'ai-agents.project.evaluations.run',
|
|
40
|
-
'ai-agents.project.evaluations.runs.list',
|
|
41
|
-
] as const;
|
|
42
|
-
|
|
43
|
-
const ALL_PROFILES: ProfileId[] = [...PROFILE_IDS];
|
|
44
|
-
|
|
45
|
-
function requiredFields(operation: OperationDescriptor): string[] {
|
|
46
|
-
const agentExposure = operation.agentExposure ?? 'agent';
|
|
47
|
-
const fields = [
|
|
48
|
-
operation.id,
|
|
49
|
-
operation.summary,
|
|
50
|
-
operation.http.method,
|
|
51
|
-
operation.http.path,
|
|
52
|
-
operation.authorization.safetyImpact,
|
|
53
|
-
operation.sensitivity,
|
|
54
|
-
agentExposure,
|
|
55
|
-
];
|
|
56
|
-
if (agentExposure === 'agent') {
|
|
57
|
-
if (operation.mcp !== undefined) {
|
|
58
|
-
fields.push(operation.mcp.toolName);
|
|
59
|
-
}
|
|
60
|
-
if (operation.cli !== undefined) {
|
|
61
|
-
fields.push(operation.cli.commandPath);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return fields;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
describe('operation registry', () => {
|
|
68
|
-
it('registers all P0 operation ids', () => {
|
|
69
|
-
for (const id of P0_OPERATION_IDS) {
|
|
70
|
-
expect(getOperation(id)).toBeDefined();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('has no duplicate operation ids', () => {
|
|
75
|
-
const ids = listOperations().map((operation) => operation.id);
|
|
76
|
-
expect(new Set(ids).size).toBe(ids.length);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('matches aggregated domain export count', () => {
|
|
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
|
-
DATA_ANALYST_OPERATIONS.length +
|
|
89
|
-
CLI_CONTENT_OPERATIONS.length,
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('includes required descriptor fields on every operation', () => {
|
|
94
|
-
for (const operation of listOperations()) {
|
|
95
|
-
for (const field of requiredFields(operation)) {
|
|
96
|
-
expect(field).toBeTruthy();
|
|
97
|
-
}
|
|
98
|
-
if (operation.agentExposure === 'agent') {
|
|
99
|
-
expect(operation.mcp !== undefined || operation.cli !== undefined).toBe(true);
|
|
100
|
-
}
|
|
101
|
-
const mcpExposed = operation.mcp?.taskSupport.exposed === true;
|
|
102
|
-
if (mcpExposed) {
|
|
103
|
-
expect(operation.profiles.length).toBeGreaterThan(0);
|
|
104
|
-
} else {
|
|
105
|
-
expect(operation.profiles).toEqual([]);
|
|
106
|
-
}
|
|
107
|
-
expect(
|
|
108
|
-
operation.http.path.startsWith('/api/v1/') || operation.http.path.startsWith('/api/v2/'),
|
|
109
|
-
).toBe(true);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('assigns idempotentHint correctly for read and destructive agent operations', () => {
|
|
114
|
-
for (const operation of listOperations()) {
|
|
115
|
-
if (operation.mcp === undefined) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
const { annotations } = operation.mcp;
|
|
119
|
-
if (operation.authorization.safetyImpact === 'read') {
|
|
120
|
-
expect(annotations.readOnlyHint).toBe(true);
|
|
121
|
-
}
|
|
122
|
-
if (operation.authorization.safetyImpact === 'write-destructive') {
|
|
123
|
-
expect(annotations.destructiveHint).toBe(true);
|
|
124
|
-
expect(annotations.idempotentHint).toBe(false);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('exposes profile filters for all serving profiles', () => {
|
|
130
|
-
for (const profile of ALL_PROFILES) {
|
|
131
|
-
const operations = getOperationsByProfile(profile);
|
|
132
|
-
expect(operations.length).toBeGreaterThan(0);
|
|
133
|
-
for (const operation of operations) {
|
|
134
|
-
expect(operation.profiles).toContain(profile);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('listMcpToolNamesByProfile matches exposed ops per profile', () => {
|
|
140
|
-
for (const profile of ALL_PROFILES) {
|
|
141
|
-
const toolNames = listMcpToolNamesByProfile(profile);
|
|
142
|
-
const exposedOps = getOperationsByProfile(profile).filter(
|
|
143
|
-
(operation) => operation.mcp?.taskSupport.exposed === true,
|
|
144
|
-
);
|
|
145
|
-
expect(toolNames).toHaveLength(exposedOps.length);
|
|
146
|
-
expect(new Set(toolNames).size).toBe(toolNames.length);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('maps exposed ai-agent-ops tools to ai-agent-ops profile only', () => {
|
|
151
|
-
expect(getOperation('ai-agents.project.agents.list')?.profiles).toEqual(['ai-agent-ops']);
|
|
152
|
-
expect(getOperation('ai-agents.project.agents.create')?.profiles).toEqual([]);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('documents multi-step workflow for thread start', () => {
|
|
156
|
-
const operation = getOperation('ai-agents.project.threads.start');
|
|
157
|
-
expect(operation?.http.path).toBe(
|
|
158
|
-
'/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads',
|
|
159
|
-
);
|
|
160
|
-
expect(operation?.cli?.commandPath).toBe('agents threads start');
|
|
161
|
-
expect(operation?.workflow).toHaveLength(3);
|
|
162
|
-
const lastStep = operation?.workflow?.[operation.workflow.length - 1];
|
|
163
|
-
expect(lastStep?.path).toContain('/generate');
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('documents multi-step workflow for thread continue', () => {
|
|
167
|
-
const operation = getOperation('ai-agents.project.threads.continue');
|
|
168
|
-
expect(operation?.workflow).toHaveLength(2);
|
|
169
|
-
expect(operation?.workflow?.[0]?.path).toContain('/messages');
|
|
170
|
-
expect(operation?.workflow?.[1]?.path).toContain('/generate');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('returns undefined for unknown operation id', () => {
|
|
174
|
-
expect(getOperation('ai-agents.unknown.operation')).toBeUndefined();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('registers users.members.delete as client-only', () => {
|
|
178
|
-
const operation = getOperation('users.members.delete');
|
|
179
|
-
expect(operation?.agentExposure).toBe('client-only');
|
|
180
|
-
expect(operation?.mcp).toBeUndefined();
|
|
181
|
-
expect(operation?.cli).toBeUndefined();
|
|
182
|
-
expect(operation?.bannedMcpToolName).toBe('delete_member');
|
|
183
|
-
expect(operation?.http.path).toBe('/api/v1/org/user/{userUuid}');
|
|
184
|
-
expect(operation?.profiles).toEqual([]);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('excludes client-only operations from profile discovery catalogs', () => {
|
|
188
|
-
for (const profile of ALL_PROFILES) {
|
|
189
|
-
for (const operation of getOperationsByProfile(profile)) {
|
|
190
|
-
expect(operation.agentExposure).not.toBe('client-only');
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
expect(getOperation('users.members.delete')).toBeDefined();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('never exposes client-only operations on MCP', () => {
|
|
197
|
-
for (const operation of listOperations()) {
|
|
198
|
-
if (operation.agentExposure === 'client-only') {
|
|
199
|
-
expect(operation.mcp).toBeUndefined();
|
|
200
|
-
expect(operation.cli).toBeUndefined();
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('rejects descriptors whose safetyImpact disagrees with MCP annotations', () => {
|
|
206
|
-
expect(() =>
|
|
207
|
-
defineOperation({
|
|
208
|
-
id: 'test.invalid-impact',
|
|
209
|
-
summary: 'Invalid impact pairing',
|
|
210
|
-
http: { method: 'GET', path: '/api/v1/test' },
|
|
211
|
-
authorization: { safetyImpact: 'write-destructive' },
|
|
212
|
-
sensitivity: 'none',
|
|
213
|
-
mcp: {
|
|
214
|
-
toolName: 'test_tool',
|
|
215
|
-
annotations: {
|
|
216
|
-
readOnlyHint: true,
|
|
217
|
-
destructiveHint: false,
|
|
218
|
-
idempotentHint: true,
|
|
219
|
-
openWorldHint: false,
|
|
220
|
-
},
|
|
221
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
222
|
-
},
|
|
223
|
-
cli: { commandPath: 'test' },
|
|
224
|
-
agentExposure: 'agent',
|
|
225
|
-
profiles: ['semantic-layer'],
|
|
226
|
-
}),
|
|
227
|
-
).toThrow(/authorization\.safetyImpact/);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Central operation catalog — aggregates domain modules and exposes lookup helpers.
|
|
3
|
-
*/
|
|
4
|
-
|
|
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 { DATA_ANALYST_OPERATIONS } from './data-analyst';
|
|
11
|
-
import { ORGANIZATION_AUDIT_OPERATIONS } from './organization-audit';
|
|
12
|
-
import { SEMANTIC_LAYER_OPERATIONS } from './semantic-layer';
|
|
13
|
-
import { PROFILE_IDS } from './types';
|
|
14
|
-
import { USER_OPERATIONS } from './users';
|
|
15
|
-
|
|
16
|
-
import type { OperationDescriptor, ProfileId } from './types';
|
|
17
|
-
|
|
18
|
-
const AGENT_EXPOSURE_CLIENT_ONLY = 'client-only' as const;
|
|
19
|
-
|
|
20
|
-
const ALL_OPERATIONS: readonly OperationDescriptor[] = [
|
|
21
|
-
...AI_AGENT_OPERATIONS,
|
|
22
|
-
...USER_OPERATIONS,
|
|
23
|
-
...SEMANTIC_LAYER_OPERATIONS,
|
|
24
|
-
...ORGANIZATION_AUDIT_OPERATIONS,
|
|
25
|
-
...CONTENT_READER_OPERATIONS,
|
|
26
|
-
...CONTENT_DEVELOPER_OPERATIONS,
|
|
27
|
-
...CONTENT_GOVERNANCE_OPERATIONS,
|
|
28
|
-
...DATA_ANALYST_OPERATIONS,
|
|
29
|
-
...CLI_CONTENT_OPERATIONS,
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const operationsById = new Map<string, OperationDescriptor>(
|
|
33
|
-
ALL_OPERATIONS.map((operation) => [operation.id, operation]),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
if (operationsById.size !== ALL_OPERATIONS.length) {
|
|
37
|
-
const seen = new Set<string>();
|
|
38
|
-
const duplicates: string[] = [];
|
|
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
|
-
|
|
48
|
-
const operationsByMcpToolName = new Map<string, OperationDescriptor>();
|
|
49
|
-
for (const operation of ALL_OPERATIONS) {
|
|
50
|
-
if (operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY || operation.mcp === undefined) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
// Index only exposed tools so lookups match registerToolsByIds / schema honesty.
|
|
54
|
-
if (!operation.mcp.taskSupport.exposed) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const toolName = operation.mcp.toolName;
|
|
58
|
-
if (operationsByMcpToolName.has(toolName)) {
|
|
59
|
-
throw new Error(`Duplicate MCP toolName in operation catalog: ${toolName}`);
|
|
60
|
-
}
|
|
61
|
-
operationsByMcpToolName.set(toolName, operation);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const EXPOSED_MCP_TOOL_NAMES: readonly string[] = ALL_OPERATIONS.filter(
|
|
65
|
-
(operation) =>
|
|
66
|
-
operation.agentExposure === 'agent' &&
|
|
67
|
-
operation.mcp !== undefined &&
|
|
68
|
-
operation.mcp.taskSupport.exposed,
|
|
69
|
-
).map((operation) => {
|
|
70
|
-
const mcp = operation.mcp;
|
|
71
|
-
if (mcp === undefined) {
|
|
72
|
-
throw new Error(`Invariant: exposed filter retained operation without mcp (${operation.id})`);
|
|
73
|
-
}
|
|
74
|
-
return mcp.toolName;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const BANNED_MCP_TOOL_NAMES: readonly string[] = ALL_OPERATIONS.filter(
|
|
78
|
-
(operation) =>
|
|
79
|
-
operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY &&
|
|
80
|
-
typeof operation.bannedMcpToolName === 'string' &&
|
|
81
|
-
operation.bannedMcpToolName.trim().length > 0,
|
|
82
|
-
).map((operation) => {
|
|
83
|
-
const banned = operation.bannedMcpToolName;
|
|
84
|
-
if (banned === undefined) {
|
|
85
|
-
throw new Error(`Invariant: banned filter retained operation without name (${operation.id})`);
|
|
86
|
-
}
|
|
87
|
-
return banned;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
/** Precomputed tool names per serving profile (ADR-0006 registration source). */
|
|
91
|
-
const MCP_TOOL_NAMES_BY_PROFILE: ReadonlyMap<ProfileId, readonly string[]> = (() => {
|
|
92
|
-
const map = new Map<ProfileId, string[]>(PROFILE_IDS.map((id) => [id, []]));
|
|
93
|
-
for (const operation of ALL_OPERATIONS) {
|
|
94
|
-
if (operation.agentExposure === AGENT_EXPOSURE_CLIENT_ONLY) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
const mcp = operation.mcp;
|
|
98
|
-
if (mcp === undefined || mcp.taskSupport.exposed !== true) {
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
for (const profile of operation.profiles) {
|
|
102
|
-
const names = map.get(profile);
|
|
103
|
-
if (names === undefined) {
|
|
104
|
-
throw new Error(
|
|
105
|
-
`Unknown profile '${profile}' on operation '${operation.id}' while indexing MCP tools`,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
names.push(mcp.toolName);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
for (const [id, names] of map) {
|
|
112
|
-
Object.freeze(names);
|
|
113
|
-
map.set(id, names);
|
|
114
|
-
}
|
|
115
|
-
return map;
|
|
116
|
-
})();
|
|
117
|
-
|
|
118
|
-
/** Returns a registered operation by id, or undefined when not found. */
|
|
119
|
-
export function getOperation(id: string): OperationDescriptor | undefined {
|
|
120
|
-
return operationsById.get(id);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/** Returns the agent operation registered for an MCP tool name (sans prefix), if any. */
|
|
124
|
-
export function getOperationByMcpToolName(toolName: string): OperationDescriptor | undefined {
|
|
125
|
-
return operationsByMcpToolName.get(toolName);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** Returns every registered operation descriptor. */
|
|
129
|
-
export function listOperations(): readonly OperationDescriptor[] {
|
|
130
|
-
return ALL_OPERATIONS;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** Returns agent-surface operations that include the given MCP serving profile. */
|
|
134
|
-
export function getOperationsByProfile(profile: ProfileId): readonly OperationDescriptor[] {
|
|
135
|
-
return ALL_OPERATIONS.filter(
|
|
136
|
-
(operation) =>
|
|
137
|
-
operation.agentExposure !== 'client-only' && operation.profiles.includes(profile),
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** MCP tool names (sans prefix) with `mcp.taskSupport.exposed === true`. */
|
|
142
|
-
export function listExposedMcpToolNames(): readonly string[] {
|
|
143
|
-
return EXPOSED_MCP_TOOL_NAMES;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/** MCP tool names that must never be registered (client-only denylist). */
|
|
147
|
-
export function listBannedMcpToolNames(): readonly string[] {
|
|
148
|
-
return BANNED_MCP_TOOL_NAMES;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/** Exposed MCP tool names for a serving profile (registration source, ADR-0006). */
|
|
152
|
-
export function listMcpToolNamesByProfile(profile: ProfileId): readonly string[] {
|
|
153
|
-
const names = MCP_TOOL_NAMES_BY_PROFILE.get(profile);
|
|
154
|
-
if (names === undefined) {
|
|
155
|
-
throw new Error(`Unknown profile id: ${profile}`);
|
|
156
|
-
}
|
|
157
|
-
return names;
|
|
158
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
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 { ProfileId, OperationDescriptor } from './types';
|
|
10
|
-
|
|
11
|
-
const PROFILE_SEMANTIC: ProfileId = 'semantic-layer';
|
|
12
|
-
const PROFILE_DATA_ANALYST: ProfileId = 'data-analyst';
|
|
13
|
-
const API_V1 = '/api/v1';
|
|
14
|
-
|
|
15
|
-
const listProjects = defineOperation({
|
|
16
|
-
id: 'semantic.projects.list',
|
|
17
|
-
summary: 'List organization projects (or pinned project when HTTP pin is set)',
|
|
18
|
-
http: { method: 'GET', path: `${API_V1}/org/projects` },
|
|
19
|
-
authorization: { safetyImpact: 'read' },
|
|
20
|
-
sensitivity: 'secret.connection',
|
|
21
|
-
mcp: {
|
|
22
|
-
toolName: 'list_projects',
|
|
23
|
-
annotations: READ_ONLY_DEFAULT,
|
|
24
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
25
|
-
},
|
|
26
|
-
cli: { commandPath: 'projects list' },
|
|
27
|
-
profiles: [PROFILE_SEMANTIC],
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const getProject = defineOperation({
|
|
31
|
-
id: 'semantic.projects.get',
|
|
32
|
-
summary: 'Get a project by UUID (connection secrets omitted on MCP)',
|
|
33
|
-
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}` },
|
|
34
|
-
authorization: { safetyImpact: 'read' },
|
|
35
|
-
sensitivity: 'secret.connection',
|
|
36
|
-
mcp: {
|
|
37
|
-
toolName: 'get_project',
|
|
38
|
-
annotations: READ_ONLY_DEFAULT,
|
|
39
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
40
|
-
},
|
|
41
|
-
cli: { commandPath: 'projects get' },
|
|
42
|
-
profiles: [PROFILE_SEMANTIC, 'content-reader', 'content-developer', PROFILE_DATA_ANALYST],
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const listExplores = defineOperation({
|
|
46
|
-
id: 'semantic.explores.list',
|
|
47
|
-
summary: 'List explores in a project',
|
|
48
|
-
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores` },
|
|
49
|
-
authorization: { safetyImpact: 'read' },
|
|
50
|
-
sensitivity: 'none',
|
|
51
|
-
mcp: {
|
|
52
|
-
toolName: 'list_explores',
|
|
53
|
-
annotations: READ_ONLY_DEFAULT,
|
|
54
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
55
|
-
},
|
|
56
|
-
cli: { commandPath: 'projects explores list' },
|
|
57
|
-
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const getExplore = defineOperation({
|
|
61
|
-
id: 'semantic.explores.get',
|
|
62
|
-
summary: 'Get a full explore definition',
|
|
63
|
-
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
|
|
64
|
-
authorization: { safetyImpact: 'read' },
|
|
65
|
-
sensitivity: 'none',
|
|
66
|
-
mcp: {
|
|
67
|
-
toolName: 'get_explore',
|
|
68
|
-
annotations: READ_ONLY_DEFAULT,
|
|
69
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
70
|
-
},
|
|
71
|
-
cli: { commandPath: 'projects explores get' },
|
|
72
|
-
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const listDimensions = defineOperation({
|
|
76
|
-
id: 'semantic.explores.list_dimensions',
|
|
77
|
-
summary: 'List dimensions for an explore (derived from get explore)',
|
|
78
|
-
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
|
|
79
|
-
authorization: { safetyImpact: 'read' },
|
|
80
|
-
sensitivity: 'none',
|
|
81
|
-
mcp: {
|
|
82
|
-
toolName: 'list_dimensions',
|
|
83
|
-
annotations: READ_ONLY_DEFAULT,
|
|
84
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
85
|
-
},
|
|
86
|
-
cli: { commandPath: 'projects explores dimensions' },
|
|
87
|
-
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const getFieldLineage = defineOperation({
|
|
91
|
-
id: 'semantic.explores.get_field_lineage',
|
|
92
|
-
summary: 'Get field lineage for an explore field (derived from get explore)',
|
|
93
|
-
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}` },
|
|
94
|
-
authorization: { safetyImpact: 'read' },
|
|
95
|
-
sensitivity: 'none',
|
|
96
|
-
mcp: {
|
|
97
|
-
toolName: 'get_field_lineage',
|
|
98
|
-
annotations: READ_ONLY_DEFAULT,
|
|
99
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
100
|
-
},
|
|
101
|
-
cli: { commandPath: 'projects explores lineage' },
|
|
102
|
-
profiles: [PROFILE_SEMANTIC],
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const listMetrics = defineOperation({
|
|
106
|
-
id: 'semantic.metrics.list',
|
|
107
|
-
summary: 'List metrics in the project data catalog',
|
|
108
|
-
http: { method: 'GET', path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics` },
|
|
109
|
-
authorization: { safetyImpact: 'read' },
|
|
110
|
-
sensitivity: 'none',
|
|
111
|
-
mcp: {
|
|
112
|
-
toolName: 'list_metrics',
|
|
113
|
-
annotations: READ_ONLY_DEFAULT,
|
|
114
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
115
|
-
},
|
|
116
|
-
cli: { commandPath: 'metrics list' },
|
|
117
|
-
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const getMetric = defineOperation({
|
|
121
|
-
id: 'semantic.metrics.get',
|
|
122
|
-
summary: 'Get a metric from the project data catalog',
|
|
123
|
-
http: {
|
|
124
|
-
method: 'GET',
|
|
125
|
-
path: `${API_V1}/projects/{projectUuid}/dataCatalog/metrics/{tableName}/{metricName}`,
|
|
126
|
-
},
|
|
127
|
-
authorization: { safetyImpact: 'read' },
|
|
128
|
-
sensitivity: 'none',
|
|
129
|
-
mcp: {
|
|
130
|
-
toolName: 'get_metric',
|
|
131
|
-
annotations: READ_ONLY_DEFAULT,
|
|
132
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
133
|
-
},
|
|
134
|
-
cli: { commandPath: 'metrics get' },
|
|
135
|
-
profiles: [PROFILE_SEMANTIC],
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const compileQuery = defineOperation({
|
|
139
|
-
id: 'semantic.query.compile',
|
|
140
|
-
summary: 'Compile a metric query to SQL without executing warehouse rows',
|
|
141
|
-
http: {
|
|
142
|
-
method: 'POST',
|
|
143
|
-
path: `${API_V1}/projects/{projectUuid}/explores/{exploreId}/compileQuery`,
|
|
144
|
-
},
|
|
145
|
-
authorization: { safetyImpact: 'read' },
|
|
146
|
-
sensitivity: 'none',
|
|
147
|
-
mcp: {
|
|
148
|
-
toolName: 'compile_query',
|
|
149
|
-
annotations: READ_ONLY_DEFAULT,
|
|
150
|
-
taskSupport: { exposed: true, taskEligible: false },
|
|
151
|
-
},
|
|
152
|
-
cli: { commandPath: 'query compile' },
|
|
153
|
-
profiles: [PROFILE_SEMANTIC, PROFILE_DATA_ANALYST],
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
/** Semantic-layer operations registered in the shared operation catalog. */
|
|
157
|
-
export const SEMANTIC_LAYER_OPERATIONS: readonly OperationDescriptor[] = [
|
|
158
|
-
listProjects,
|
|
159
|
-
getProject,
|
|
160
|
-
listExplores,
|
|
161
|
-
getExplore,
|
|
162
|
-
listDimensions,
|
|
163
|
-
getFieldLineage,
|
|
164
|
-
listMetrics,
|
|
165
|
-
getMetric,
|
|
166
|
-
compileQuery,
|
|
167
|
-
];
|