@lightdash-tools/common 0.8.0 → 0.11.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/audit.d.ts +29 -8
- 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/operations/ai-agents.js +108 -40
- package/dist/operations/cli-content.js +6 -8
- package/dist/operations/client-coverage.d.ts +7 -0
- package/dist/operations/client-coverage.js +13 -4
- package/dist/operations/content-developer.js +19 -5
- package/dist/operations/content-governance.js +1 -1
- package/dist/operations/content-reader.js +19 -4
- package/dist/operations/data-analyst.d.ts +5 -0
- package/dist/operations/data-analyst.js +23 -0
- package/dist/operations/index.d.ts +2 -1
- package/dist/operations/index.js +4 -1
- package/dist/operations/organization-audit.js +1 -1
- package/dist/operations/registry.d.ts +5 -5
- package/dist/operations/registry.js +35 -9
- package/dist/operations/registry.test.js +23 -45
- package/dist/operations/semantic-layer.js +8 -7
- package/dist/operations/types.d.ts +10 -6
- package/dist/operations/types.js +23 -14
- package/dist/operations/types.test.js +14 -5
- package/dist/operations/users.js +3 -5
- package/dist/safety.d.ts +3 -2
- package/dist/safety.js +11 -3
- package/dist/safety.test.js +29 -6
- package/package.json +1 -1
- package/src/audit.test.ts +70 -30
- package/src/audit.ts +78 -11
- package/src/env.ts +1 -1
- package/src/operations/ai-agents.ts +113 -41
- package/src/operations/cli-content.ts +7 -10
- package/src/operations/client-coverage.ts +14 -5
- package/src/operations/content-developer.ts +23 -7
- package/src/operations/content-governance.ts +3 -3
- package/src/operations/content-reader.ts +23 -7
- package/src/operations/data-analyst.ts +27 -0
- package/src/operations/index.ts +3 -1
- package/src/operations/organization-audit.ts +2 -2
- package/src/operations/registry.test.ts +31 -52
- package/src/operations/registry.ts +42 -12
- package/src/operations/semantic-layer.ts +9 -8
- package/src/operations/types.test.ts +34 -6
- package/src/operations/types.ts +41 -31
- package/src/operations/users.ts +4 -7
- package/src/safety.test.ts +32 -6
- package/src/safety.ts +15 -4
package/dist/audit.d.ts
CHANGED
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Structured audit logger for Lightdash tool invocations (MCP and CLI).
|
|
3
3
|
*
|
|
4
|
-
* Each operation is recorded as a single NDJSON line
|
|
5
|
-
*
|
|
6
|
-
* and optional OAuth attribution fields (tokenHash, subject) when available.
|
|
4
|
+
* Each operation is recorded as a single NDJSON line. On stderr the line is pure JSON
|
|
5
|
+
* (Cloud Logging–parseable); text prefixes prevent jsonPayload parsing on Cloud Run.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* - If LIGHTDASH_TOOLS_AUDIT_LOG is set to a file path, entries are appended to that file.
|
|
10
|
-
* - Otherwise entries are written to stderr with an "[audit]" prefix.
|
|
7
|
+
* If LIGHTDASH_TOOLS_AUDIT_LOG is a file path, entries are appended there; otherwise stderr.
|
|
11
8
|
*/
|
|
9
|
+
import type { ProfileId } from './operations/types';
|
|
12
10
|
export type AuditStatus = 'blocked' | 'confirmation_cancelled' | 'confirmation_declined' | 'confirmation_requested' | 'deletion_failed' | 'deletion_succeeded' | 'error' | 'promotion_failed' | 'promotion_succeeded' | 'resource_changed' | 'success';
|
|
11
|
+
/** Cloud Logging LogSeverity-compatible strings for structured stderr JSON. */
|
|
12
|
+
export type AuditSeverity = 'ERROR' | 'INFO' | 'NOTICE' | 'WARNING';
|
|
13
13
|
export type AuditLogEntry = {
|
|
14
|
+
/** Stable filter key for Cloud Logging (`jsonPayload.channel="audit"`). */
|
|
15
|
+
channel: 'audit';
|
|
16
|
+
severity: AuditSeverity;
|
|
17
|
+
message: string;
|
|
14
18
|
timestamp: string;
|
|
19
|
+
/** Process-lifetime instance id (not the MCP client session). */
|
|
15
20
|
sessionId: string;
|
|
16
|
-
/** MCP tool name or CLI command name. */
|
|
17
21
|
tool: string;
|
|
18
|
-
/** Project UUIDs involved in the call, if any (covers both projectUuid and projectUuids[]). */
|
|
19
22
|
projectUuids?: string[];
|
|
20
23
|
/** SHA-256 hash of the OAuth bearer token (never the raw token). */
|
|
21
24
|
tokenHash?: string;
|
|
22
25
|
/** Lightdash user UUID when the call runs under OAuth bearer auth. */
|
|
23
26
|
subject?: string;
|
|
27
|
+
clientSessionId?: string;
|
|
28
|
+
profileId?: ProfileId;
|
|
24
29
|
status: AuditStatus;
|
|
25
30
|
durationMs: number;
|
|
26
31
|
};
|
|
32
|
+
export type BuildAuditLogEntryInput = {
|
|
33
|
+
tool: string;
|
|
34
|
+
status: AuditStatus;
|
|
35
|
+
/** Epoch ms when the operation started (`durationMs = now - startMs`). */
|
|
36
|
+
startMs: number;
|
|
37
|
+
projectUuids?: string[];
|
|
38
|
+
tokenHash?: string;
|
|
39
|
+
subject?: string;
|
|
40
|
+
clientSessionId?: string;
|
|
41
|
+
profileId?: ProfileId;
|
|
42
|
+
};
|
|
27
43
|
export declare function getSessionId(): string;
|
|
44
|
+
/** Map audit status to Cloud Logging severity. */
|
|
45
|
+
export declare function auditSeverityForStatus(status: AuditStatus): AuditSeverity;
|
|
46
|
+
/** Assemble a full audit entry (shared by CLI and MCP). */
|
|
47
|
+
export declare function buildAuditLogEntry(input: BuildAuditLogEntryInput): AuditLogEntry;
|
|
28
48
|
/**
|
|
29
49
|
* Initialise the audit log. Call once at process startup.
|
|
30
50
|
* If filePath is provided, entries are appended to that file; otherwise stderr is used.
|
|
51
|
+
* Startup banners go to stdout so they do not mix with structured audit JSON on stderr.
|
|
31
52
|
*/
|
|
32
53
|
export declare function initAuditLog(filePath?: string): void;
|
|
33
54
|
/** Append one NDJSON entry to the configured output. */
|
package/dist/audit.js
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Structured audit logger for Lightdash tool invocations (MCP and CLI).
|
|
4
4
|
*
|
|
5
|
-
* Each operation is recorded as a single NDJSON line
|
|
6
|
-
*
|
|
7
|
-
* and optional OAuth attribution fields (tokenHash, subject) when available.
|
|
5
|
+
* Each operation is recorded as a single NDJSON line. On stderr the line is pure JSON
|
|
6
|
+
* (Cloud Logging–parseable); text prefixes prevent jsonPayload parsing on Cloud Run.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
* - If LIGHTDASH_TOOLS_AUDIT_LOG is set to a file path, entries are appended to that file.
|
|
11
|
-
* - Otherwise entries are written to stderr with an "[audit]" prefix.
|
|
8
|
+
* If LIGHTDASH_TOOLS_AUDIT_LOG is a file path, entries are appended there; otherwise stderr.
|
|
12
9
|
*/
|
|
13
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
11
|
exports.getSessionId = getSessionId;
|
|
12
|
+
exports.auditSeverityForStatus = auditSeverityForStatus;
|
|
13
|
+
exports.buildAuditLogEntry = buildAuditLogEntry;
|
|
15
14
|
exports.initAuditLog = initAuditLog;
|
|
16
15
|
exports.logAuditEntry = logAuditEntry;
|
|
17
16
|
exports.closeAuditLog = closeAuditLog;
|
|
@@ -23,20 +22,65 @@ let _writeStream;
|
|
|
23
22
|
function getSessionId() {
|
|
24
23
|
return SESSION_ID;
|
|
25
24
|
}
|
|
25
|
+
/** Map audit status to Cloud Logging severity. */
|
|
26
|
+
function auditSeverityForStatus(status) {
|
|
27
|
+
switch (status) {
|
|
28
|
+
case 'success':
|
|
29
|
+
return 'INFO';
|
|
30
|
+
case 'deletion_succeeded':
|
|
31
|
+
case 'promotion_succeeded':
|
|
32
|
+
return 'NOTICE';
|
|
33
|
+
case 'blocked':
|
|
34
|
+
case 'confirmation_cancelled':
|
|
35
|
+
case 'confirmation_declined':
|
|
36
|
+
case 'confirmation_requested':
|
|
37
|
+
case 'resource_changed':
|
|
38
|
+
return 'WARNING';
|
|
39
|
+
case 'deletion_failed':
|
|
40
|
+
case 'error':
|
|
41
|
+
case 'promotion_failed':
|
|
42
|
+
return 'ERROR';
|
|
43
|
+
default: {
|
|
44
|
+
const _exhaustive = status;
|
|
45
|
+
return _exhaustive;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Assemble a full audit entry (shared by CLI and MCP). */
|
|
50
|
+
function buildAuditLogEntry(input) {
|
|
51
|
+
const projectUuids = input.projectUuids && input.projectUuids.length > 0 ? input.projectUuids : undefined;
|
|
52
|
+
return {
|
|
53
|
+
channel: 'audit',
|
|
54
|
+
severity: auditSeverityForStatus(input.status),
|
|
55
|
+
message: `${input.tool} ${input.status}`,
|
|
56
|
+
timestamp: new Date().toISOString(),
|
|
57
|
+
sessionId: SESSION_ID,
|
|
58
|
+
tool: input.tool,
|
|
59
|
+
projectUuids,
|
|
60
|
+
tokenHash: input.tokenHash,
|
|
61
|
+
subject: input.subject,
|
|
62
|
+
clientSessionId: input.clientSessionId,
|
|
63
|
+
profileId: input.profileId,
|
|
64
|
+
status: input.status,
|
|
65
|
+
durationMs: Date.now() - input.startMs,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
26
68
|
/**
|
|
27
69
|
* Initialise the audit log. Call once at process startup.
|
|
28
70
|
* If filePath is provided, entries are appended to that file; otherwise stderr is used.
|
|
71
|
+
* Startup banners go to stdout so they do not mix with structured audit JSON on stderr.
|
|
29
72
|
*/
|
|
30
73
|
function initAuditLog(filePath) {
|
|
31
74
|
if (filePath) {
|
|
32
75
|
_writeStream = (0, node_fs_1.createWriteStream)(filePath, { flags: 'a' });
|
|
33
76
|
_writeStream.on('error', (err) => {
|
|
77
|
+
// Diagnostic only — not an audit row.
|
|
34
78
|
console.error('[audit] Failed to write to audit log file:', err);
|
|
35
79
|
});
|
|
36
|
-
console.
|
|
80
|
+
console.log(`[audit] Writing to file: ${filePath} (session: ${SESSION_ID})`);
|
|
37
81
|
}
|
|
38
82
|
else {
|
|
39
|
-
console.
|
|
83
|
+
console.log(`[audit] Writing to stderr (session: ${SESSION_ID})`);
|
|
40
84
|
}
|
|
41
85
|
}
|
|
42
86
|
/** Append one NDJSON entry to the configured output. */
|
|
@@ -46,7 +90,7 @@ function logAuditEntry(entry) {
|
|
|
46
90
|
_writeStream.write(line);
|
|
47
91
|
}
|
|
48
92
|
else {
|
|
49
|
-
process.stderr.write(
|
|
93
|
+
process.stderr.write(line);
|
|
50
94
|
}
|
|
51
95
|
}
|
|
52
96
|
/** Closes the file stream, if any. Awaits pending writes before resolving. */
|
package/dist/audit.test.js
CHANGED
|
@@ -14,56 +14,83 @@ const audit_1 = require("./audit");
|
|
|
14
14
|
(0, vitest_1.expect)((0, audit_1.getSessionId)()).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
15
15
|
(0, vitest_1.expect)((0, audit_1.getSessionId)()).toBe((0, audit_1.getSessionId)());
|
|
16
16
|
});
|
|
17
|
-
(0, vitest_1.it)('
|
|
18
|
-
|
|
17
|
+
(0, vitest_1.it)('auditSeverityForStatus maps statuses for Cloud Logging', () => {
|
|
18
|
+
(0, vitest_1.expect)((0, audit_1.auditSeverityForStatus)('success')).toBe('INFO');
|
|
19
|
+
(0, vitest_1.expect)((0, audit_1.auditSeverityForStatus)('deletion_succeeded')).toBe('NOTICE');
|
|
20
|
+
(0, vitest_1.expect)((0, audit_1.auditSeverityForStatus)('blocked')).toBe('WARNING');
|
|
21
|
+
(0, vitest_1.expect)((0, audit_1.auditSeverityForStatus)('error')).toBe('ERROR');
|
|
22
|
+
});
|
|
23
|
+
(0, vitest_1.it)('buildAuditLogEntry derives channel, severity, and message', () => {
|
|
24
|
+
const entry = (0, audit_1.buildAuditLogEntry)({
|
|
25
|
+
tool: 'demo_tool',
|
|
26
|
+
status: 'blocked',
|
|
27
|
+
startMs: Date.now() - 5,
|
|
28
|
+
projectUuids: [],
|
|
29
|
+
profileId: 'semantic-layer',
|
|
30
|
+
});
|
|
31
|
+
(0, vitest_1.expect)(entry.channel).toBe('audit');
|
|
32
|
+
(0, vitest_1.expect)(entry.severity).toBe('WARNING');
|
|
33
|
+
(0, vitest_1.expect)(entry.message).toBe('demo_tool blocked');
|
|
34
|
+
(0, vitest_1.expect)(entry.projectUuids).toBeUndefined();
|
|
35
|
+
(0, vitest_1.expect)(entry.profileId).toBe('semantic-layer');
|
|
36
|
+
(0, vitest_1.expect)(entry.sessionId).toBe((0, audit_1.getSessionId)());
|
|
37
|
+
});
|
|
38
|
+
(0, vitest_1.it)('initAuditLog announces stderr destination on stdout when no file path is given', () => {
|
|
39
|
+
const consoleLogSpy = vitest_1.vi.spyOn(console, 'log').mockImplementation(() => { });
|
|
19
40
|
try {
|
|
20
41
|
(0, audit_1.initAuditLog)();
|
|
21
|
-
(0, vitest_1.expect)(
|
|
42
|
+
(0, vitest_1.expect)(consoleLogSpy).toHaveBeenCalledWith(vitest_1.expect.stringContaining('[audit] Writing to stderr'));
|
|
22
43
|
}
|
|
23
44
|
finally {
|
|
24
|
-
|
|
45
|
+
consoleLogSpy.mockRestore();
|
|
25
46
|
}
|
|
26
47
|
});
|
|
27
|
-
(0, vitest_1.it)('logAuditEntry writes NDJSON to stderr
|
|
48
|
+
(0, vitest_1.it)('logAuditEntry writes pure JSON NDJSON to stderr (Cloud Logging–parseable)', () => {
|
|
28
49
|
(0, audit_1.initAuditLog)();
|
|
29
|
-
(0, audit_1.logAuditEntry)({
|
|
30
|
-
timestamp: '2026-01-01T00:00:00.000Z',
|
|
31
|
-
sessionId: (0, audit_1.getSessionId)(),
|
|
50
|
+
(0, audit_1.logAuditEntry)((0, audit_1.buildAuditLogEntry)({
|
|
32
51
|
tool: 'test_tool',
|
|
52
|
+
status: 'success',
|
|
53
|
+
startMs: Date.now() - 12,
|
|
33
54
|
tokenHash: 'abc123',
|
|
34
55
|
subject: 'user-uuid',
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
56
|
+
clientSessionId: 'mcp-session-1',
|
|
57
|
+
profileId: 'semantic-layer',
|
|
58
|
+
}));
|
|
38
59
|
const auditLine = stderrSpy.mock.calls
|
|
39
60
|
.map(([chunk]) => String(chunk))
|
|
40
61
|
.find((line) => line.includes('"tool":"test_tool"'));
|
|
41
62
|
(0, vitest_1.expect)(auditLine).toBeDefined();
|
|
42
|
-
(0, vitest_1.expect)(auditLine).toContain('[audit]');
|
|
43
|
-
|
|
44
|
-
(0, vitest_1.expect)(
|
|
45
|
-
(0, vitest_1.expect)(
|
|
63
|
+
(0, vitest_1.expect)(auditLine).not.toContain('[audit]');
|
|
64
|
+
const parsed = JSON.parse(auditLine.trim());
|
|
65
|
+
(0, vitest_1.expect)(parsed.channel).toBe('audit');
|
|
66
|
+
(0, vitest_1.expect)(parsed.severity).toBe('INFO');
|
|
67
|
+
(0, vitest_1.expect)(parsed.message).toBe('test_tool success');
|
|
68
|
+
(0, vitest_1.expect)(parsed.status).toBe('success');
|
|
69
|
+
(0, vitest_1.expect)(parsed.tokenHash).toBe('abc123');
|
|
70
|
+
(0, vitest_1.expect)(parsed.subject).toBe('user-uuid');
|
|
71
|
+
(0, vitest_1.expect)(parsed.clientSessionId).toBe('mcp-session-1');
|
|
72
|
+
(0, vitest_1.expect)(parsed.profileId).toBe('semantic-layer');
|
|
46
73
|
});
|
|
47
74
|
(0, vitest_1.it)('logAuditEntry appends to a file when initAuditLog receives a path', async () => {
|
|
48
75
|
const dir = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'audit-test-'));
|
|
49
76
|
const filePath = (0, node_path_1.join)(dir, 'audit.ndjson');
|
|
50
77
|
try {
|
|
51
78
|
(0, audit_1.initAuditLog)(filePath);
|
|
52
|
-
(0, audit_1.logAuditEntry)({
|
|
53
|
-
timestamp: '2026-01-01T00:00:00.000Z',
|
|
54
|
-
sessionId: (0, audit_1.getSessionId)(),
|
|
79
|
+
(0, audit_1.logAuditEntry)((0, audit_1.buildAuditLogEntry)({
|
|
55
80
|
tool: 'file_tool',
|
|
56
|
-
projectUuids: ['uuid-a'],
|
|
57
81
|
status: 'blocked',
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
startMs: Date.now() - 3,
|
|
83
|
+
projectUuids: ['uuid-a'],
|
|
84
|
+
}));
|
|
60
85
|
await (0, audit_1.closeAuditLog)();
|
|
61
86
|
// filePath is a temp path from mkdtempSync in this test only
|
|
62
87
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
63
88
|
const contents = (0, node_fs_1.readFileSync)(filePath, 'utf8');
|
|
64
|
-
|
|
65
|
-
(0, vitest_1.expect)(
|
|
66
|
-
(0, vitest_1.expect)(
|
|
89
|
+
const parsed = JSON.parse(contents.trim());
|
|
90
|
+
(0, vitest_1.expect)(parsed.channel).toBe('audit');
|
|
91
|
+
(0, vitest_1.expect)(parsed.tool).toBe('file_tool');
|
|
92
|
+
(0, vitest_1.expect)(parsed.projectUuids).toEqual(['uuid-a']);
|
|
93
|
+
(0, vitest_1.expect)(parsed.status).toBe('blocked');
|
|
67
94
|
}
|
|
68
95
|
finally {
|
|
69
96
|
await (0, audit_1.closeAuditLog)();
|
package/dist/env.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export declare const ENV_LIGHTDASH_TOOLS_DRY_RUN = "LIGHTDASH_TOOLS_DRY_RUN";
|
|
7
7
|
export declare const ENV_LIGHTDASH_TOOLS_AUDIT_LOG = "LIGHTDASH_TOOLS_AUDIT_LOG";
|
|
8
8
|
export declare const ENV_LIGHTDASH_TOOLS_SAFETY_MODE = "LIGHTDASH_TOOLS_SAFETY_MODE";
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = "LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS";
|
|
10
10
|
/** MCP HTTP server env vars (`LIGHTDASH_TOOLS_MCP_*` / `LIGHTDASH_TOOLS_OAUTH_*` per ADR-0009). */
|
|
11
11
|
/** @deprecated Removed — auth is credential-inferred (ADR-0007). Kept for migration error messages. */
|
|
12
12
|
export declare const ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = "LIGHTDASH_TOOLS_MCP_AUTH_MODE";
|
package/dist/env.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* from official Lightdash vars (LIGHTDASH_URL, LIGHTDASH_API_KEY).
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET = exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_ID = exports.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY = exports.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_PORT = exports.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = exports.
|
|
8
|
+
exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET = exports.ENV_LIGHTDASH_TOOLS_OAUTH_CLIENT_ID = exports.ENV_LIGHTDASH_TOOLS_MCP_SHARED_KEY = exports.ENV_LIGHTDASH_TOOLS_MCP_PUBLIC_URL = exports.ENV_LIGHTDASH_TOOLS_MCP_HTTP_PORT = exports.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = exports.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = exports.ENV_LIGHTDASH_TOOLS_SAFETY_MODE = exports.ENV_LIGHTDASH_TOOLS_AUDIT_LOG = exports.ENV_LIGHTDASH_TOOLS_DRY_RUN = void 0;
|
|
9
9
|
exports.ENV_LIGHTDASH_TOOLS_DRY_RUN = 'LIGHTDASH_TOOLS_DRY_RUN';
|
|
10
10
|
exports.ENV_LIGHTDASH_TOOLS_AUDIT_LOG = 'LIGHTDASH_TOOLS_AUDIT_LOG';
|
|
11
11
|
exports.ENV_LIGHTDASH_TOOLS_SAFETY_MODE = 'LIGHTDASH_TOOLS_SAFETY_MODE';
|
|
12
|
-
exports.
|
|
12
|
+
exports.ENV_LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS = 'LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS';
|
|
13
13
|
/** MCP HTTP server env vars (`LIGHTDASH_TOOLS_MCP_*` / `LIGHTDASH_TOOLS_OAUTH_*` per ADR-0009). */
|
|
14
14
|
/** @deprecated Removed — auth is credential-inferred (ADR-0007). Kept for migration error messages. */
|
|
15
15
|
exports.ENV_LIGHTDASH_TOOLS_MCP_AUTH_MODE = 'LIGHTDASH_TOOLS_MCP_AUTH_MODE';
|
|
@@ -10,10 +10,7 @@ const IMPACT_READ = 'read';
|
|
|
10
10
|
const IMPACT_WRITE_NONDESTRUCTIVE = 'write-nondestructive';
|
|
11
11
|
const IMPACT_WRITE_DESTRUCTIVE = 'write-destructive';
|
|
12
12
|
const IMPACT_EXTERNAL = 'external-side-effect';
|
|
13
|
-
const
|
|
14
|
-
const PROFILE_DISCOVERY = 'discovery-readonly';
|
|
15
|
-
const PROFILE_CONVERSATIONS = 'conversations';
|
|
16
|
-
const PROFILE_EVALUATIONS = 'evaluations';
|
|
13
|
+
const PROFILE_AI_AGENT_OPS = 'ai-agent-ops';
|
|
17
14
|
const API_V1 = '/api/v1';
|
|
18
15
|
const PROJECT_AGENTS_PATH = `${API_V1}/projects/{projectUuid}/aiAgents`;
|
|
19
16
|
const PROJECT_AGENT_PATH = `${PROJECT_AGENTS_PATH}/{agentUuid}`;
|
|
@@ -29,7 +26,7 @@ const adminListAgents = (0, types_1.defineOperation)({
|
|
|
29
26
|
taskSupport: { exposed: false, taskEligible: false },
|
|
30
27
|
},
|
|
31
28
|
cli: { commandPath: 'ai-agents list' },
|
|
32
|
-
profiles: [
|
|
29
|
+
profiles: [],
|
|
33
30
|
});
|
|
34
31
|
const adminListThreads = (0, types_1.defineOperation)({
|
|
35
32
|
id: 'ai-agents.admin.threads.list',
|
|
@@ -43,7 +40,7 @@ const adminListThreads = (0, types_1.defineOperation)({
|
|
|
43
40
|
taskSupport: { exposed: false, taskEligible: false },
|
|
44
41
|
},
|
|
45
42
|
cli: { commandPath: 'ai-agents threads' },
|
|
46
|
-
profiles: [
|
|
43
|
+
profiles: [],
|
|
47
44
|
});
|
|
48
45
|
const adminSettingsGet = (0, types_1.defineOperation)({
|
|
49
46
|
id: 'ai-agents.admin.settings.get',
|
|
@@ -57,7 +54,7 @@ const adminSettingsGet = (0, types_1.defineOperation)({
|
|
|
57
54
|
taskSupport: { exposed: false, taskEligible: false },
|
|
58
55
|
},
|
|
59
56
|
cli: { commandPath: 'ai-agents settings get' },
|
|
60
|
-
profiles: [
|
|
57
|
+
profiles: [],
|
|
61
58
|
});
|
|
62
59
|
const adminSettingsUpdate = (0, types_1.defineOperation)({
|
|
63
60
|
id: 'ai-agents.admin.settings.update',
|
|
@@ -71,7 +68,7 @@ const adminSettingsUpdate = (0, types_1.defineOperation)({
|
|
|
71
68
|
taskSupport: { exposed: false, taskEligible: false },
|
|
72
69
|
},
|
|
73
70
|
cli: { commandPath: 'ai-agents settings update' },
|
|
74
|
-
profiles: [
|
|
71
|
+
profiles: [],
|
|
75
72
|
});
|
|
76
73
|
const projectAgentsList = (0, types_1.defineOperation)({
|
|
77
74
|
id: 'ai-agents.project.agents.list',
|
|
@@ -82,10 +79,10 @@ const projectAgentsList = (0, types_1.defineOperation)({
|
|
|
82
79
|
mcp: {
|
|
83
80
|
toolName: 'list_project_agents',
|
|
84
81
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
85
|
-
taskSupport: { exposed:
|
|
82
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
86
83
|
},
|
|
87
84
|
cli: { commandPath: 'agents list' },
|
|
88
|
-
profiles: [
|
|
85
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
89
86
|
});
|
|
90
87
|
const projectAgentsGet = (0, types_1.defineOperation)({
|
|
91
88
|
id: 'ai-agents.project.agents.get',
|
|
@@ -96,10 +93,10 @@ const projectAgentsGet = (0, types_1.defineOperation)({
|
|
|
96
93
|
mcp: {
|
|
97
94
|
toolName: 'get_project_agent',
|
|
98
95
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
99
|
-
taskSupport: { exposed:
|
|
96
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
100
97
|
},
|
|
101
98
|
cli: { commandPath: 'agents get' },
|
|
102
|
-
profiles: [
|
|
99
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
103
100
|
});
|
|
104
101
|
const projectAgentsCreate = (0, types_1.defineOperation)({
|
|
105
102
|
id: 'ai-agents.project.agents.create',
|
|
@@ -113,7 +110,7 @@ const projectAgentsCreate = (0, types_1.defineOperation)({
|
|
|
113
110
|
taskSupport: { exposed: false, taskEligible: false },
|
|
114
111
|
},
|
|
115
112
|
cli: { commandPath: 'agents create' },
|
|
116
|
-
profiles: [
|
|
113
|
+
profiles: [],
|
|
117
114
|
});
|
|
118
115
|
const projectAgentsUpdate = (0, types_1.defineOperation)({
|
|
119
116
|
id: 'ai-agents.project.agents.update',
|
|
@@ -127,7 +124,7 @@ const projectAgentsUpdate = (0, types_1.defineOperation)({
|
|
|
127
124
|
taskSupport: { exposed: false, taskEligible: false },
|
|
128
125
|
},
|
|
129
126
|
cli: { commandPath: 'agents update' },
|
|
130
|
-
profiles: [
|
|
127
|
+
profiles: [],
|
|
131
128
|
});
|
|
132
129
|
const projectAgentsDelete = (0, types_1.defineOperation)({
|
|
133
130
|
id: 'ai-agents.project.agents.delete',
|
|
@@ -141,7 +138,7 @@ const projectAgentsDelete = (0, types_1.defineOperation)({
|
|
|
141
138
|
taskSupport: { exposed: false, taskEligible: false },
|
|
142
139
|
},
|
|
143
140
|
cli: { commandPath: 'agents delete' },
|
|
144
|
-
profiles: [
|
|
141
|
+
profiles: [],
|
|
145
142
|
});
|
|
146
143
|
const PROJECT_AGENT_THREADS_PATH = `${PROJECT_AGENT_PATH}/threads`;
|
|
147
144
|
const threadsList = (0, types_1.defineOperation)({
|
|
@@ -156,10 +153,10 @@ const threadsList = (0, types_1.defineOperation)({
|
|
|
156
153
|
mcp: {
|
|
157
154
|
toolName: 'list_agent_threads',
|
|
158
155
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
159
|
-
taskSupport: { exposed:
|
|
156
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
160
157
|
},
|
|
161
158
|
cli: { commandPath: 'agents threads list' },
|
|
162
|
-
profiles: [
|
|
159
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
163
160
|
});
|
|
164
161
|
const PROJECT_AGENT_THREAD_PATH = `${PROJECT_AGENT_THREADS_PATH}/{threadUuid}`;
|
|
165
162
|
const threadsGet = (0, types_1.defineOperation)({
|
|
@@ -174,10 +171,10 @@ const threadsGet = (0, types_1.defineOperation)({
|
|
|
174
171
|
mcp: {
|
|
175
172
|
toolName: 'get_agent_thread',
|
|
176
173
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
177
|
-
taskSupport: { exposed:
|
|
174
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
178
175
|
},
|
|
179
176
|
cli: { commandPath: 'agents threads get' },
|
|
180
|
-
profiles: [
|
|
177
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
181
178
|
});
|
|
182
179
|
const PROJECT_AGENT_THREAD_MESSAGES_PATH = `${PROJECT_AGENT_THREAD_PATH}/messages`;
|
|
183
180
|
const PROJECT_AGENT_THREAD_GENERATE_PATH = `${PROJECT_AGENT_THREAD_PATH}/generate`;
|
|
@@ -213,7 +210,7 @@ const threadsStart = (0, types_1.defineOperation)({
|
|
|
213
210
|
taskSupport: { exposed: false, taskEligible: true },
|
|
214
211
|
},
|
|
215
212
|
cli: { commandPath: 'agents threads start' },
|
|
216
|
-
profiles: [
|
|
213
|
+
profiles: [],
|
|
217
214
|
});
|
|
218
215
|
const threadsContinue = (0, types_1.defineOperation)({
|
|
219
216
|
id: 'ai-agents.project.threads.continue',
|
|
@@ -242,7 +239,7 @@ const threadsContinue = (0, types_1.defineOperation)({
|
|
|
242
239
|
taskSupport: { exposed: false, taskEligible: true },
|
|
243
240
|
},
|
|
244
241
|
cli: { commandPath: 'agents threads continue' },
|
|
245
|
-
profiles: [
|
|
242
|
+
profiles: [],
|
|
246
243
|
});
|
|
247
244
|
const PROJECT_AGENT_EVALUATIONS_PATH = `${PROJECT_AGENT_PATH}/evaluations`;
|
|
248
245
|
const evaluationsList = (0, types_1.defineOperation)({
|
|
@@ -257,10 +254,10 @@ const evaluationsList = (0, types_1.defineOperation)({
|
|
|
257
254
|
mcp: {
|
|
258
255
|
toolName: 'list_agent_evaluations',
|
|
259
256
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
260
|
-
taskSupport: { exposed:
|
|
257
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
261
258
|
},
|
|
262
259
|
cli: { commandPath: 'agents evals list' },
|
|
263
|
-
profiles: [
|
|
260
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
264
261
|
});
|
|
265
262
|
const PROJECT_AGENT_EVALUATION_PATH = `${PROJECT_AGENT_EVALUATIONS_PATH}/{evalUuid}`;
|
|
266
263
|
const evaluationsGet = (0, types_1.defineOperation)({
|
|
@@ -275,10 +272,10 @@ const evaluationsGet = (0, types_1.defineOperation)({
|
|
|
275
272
|
mcp: {
|
|
276
273
|
toolName: 'get_agent_evaluation',
|
|
277
274
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
278
|
-
taskSupport: { exposed:
|
|
275
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
279
276
|
},
|
|
280
277
|
cli: { commandPath: 'agents evals get' },
|
|
281
|
-
profiles: [
|
|
278
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
282
279
|
});
|
|
283
280
|
const evaluationsCreate = (0, types_1.defineOperation)({
|
|
284
281
|
id: 'ai-agents.project.evaluations.create',
|
|
@@ -292,10 +289,10 @@ const evaluationsCreate = (0, types_1.defineOperation)({
|
|
|
292
289
|
mcp: {
|
|
293
290
|
toolName: 'create_agent_evaluation',
|
|
294
291
|
annotations: safety_1.WRITE_NONDESTRUCTIVE,
|
|
295
|
-
taskSupport: { exposed:
|
|
292
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
296
293
|
},
|
|
297
294
|
cli: { commandPath: 'agents evals create' },
|
|
298
|
-
profiles: [
|
|
295
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
299
296
|
});
|
|
300
297
|
const evaluationsUpdate = (0, types_1.defineOperation)({
|
|
301
298
|
id: 'ai-agents.project.evaluations.update',
|
|
@@ -309,10 +306,10 @@ const evaluationsUpdate = (0, types_1.defineOperation)({
|
|
|
309
306
|
mcp: {
|
|
310
307
|
toolName: 'update_agent_evaluation',
|
|
311
308
|
annotations: safety_1.WRITE_NONDESTRUCTIVE,
|
|
312
|
-
taskSupport: { exposed:
|
|
309
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
313
310
|
},
|
|
314
311
|
cli: { commandPath: 'agents evals update' },
|
|
315
|
-
profiles: [
|
|
312
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
316
313
|
});
|
|
317
314
|
const evaluationsAppend = (0, types_1.defineOperation)({
|
|
318
315
|
id: 'ai-agents.project.evaluations.append',
|
|
@@ -326,10 +323,10 @@ const evaluationsAppend = (0, types_1.defineOperation)({
|
|
|
326
323
|
mcp: {
|
|
327
324
|
toolName: 'append_agent_evaluation_prompts',
|
|
328
325
|
annotations: safety_1.WRITE_NONDESTRUCTIVE,
|
|
329
|
-
taskSupport: { exposed:
|
|
326
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
330
327
|
},
|
|
331
328
|
cli: { commandPath: 'agents evals append' },
|
|
332
|
-
profiles: [
|
|
329
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
333
330
|
});
|
|
334
331
|
const evaluationsDelete = (0, types_1.defineOperation)({
|
|
335
332
|
id: 'ai-agents.project.evaluations.delete',
|
|
@@ -343,10 +340,10 @@ const evaluationsDelete = (0, types_1.defineOperation)({
|
|
|
343
340
|
mcp: {
|
|
344
341
|
toolName: 'delete_agent_evaluation',
|
|
345
342
|
annotations: safety_1.WRITE_DESTRUCTIVE,
|
|
346
|
-
taskSupport: { exposed:
|
|
343
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
347
344
|
},
|
|
348
345
|
cli: { commandPath: 'agents evals delete' },
|
|
349
|
-
profiles: [
|
|
346
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
350
347
|
});
|
|
351
348
|
const evaluationsRun = (0, types_1.defineOperation)({
|
|
352
349
|
id: 'ai-agents.project.evaluations.run',
|
|
@@ -360,10 +357,10 @@ const evaluationsRun = (0, types_1.defineOperation)({
|
|
|
360
357
|
mcp: {
|
|
361
358
|
toolName: 'run_agent_evaluation',
|
|
362
359
|
annotations: safety_1.WRITE_OPEN_WORLD,
|
|
363
|
-
taskSupport: { exposed:
|
|
360
|
+
taskSupport: { exposed: true, taskEligible: true },
|
|
364
361
|
},
|
|
365
362
|
cli: { commandPath: 'agents evals run' },
|
|
366
|
-
profiles: [
|
|
363
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
367
364
|
});
|
|
368
365
|
const PROJECT_AGENT_EVALUATION_RUNS_PATH = `${PROJECT_AGENT_EVALUATION_PATH}/runs`;
|
|
369
366
|
const evaluationsRunsList = (0, types_1.defineOperation)({
|
|
@@ -378,10 +375,10 @@ const evaluationsRunsList = (0, types_1.defineOperation)({
|
|
|
378
375
|
mcp: {
|
|
379
376
|
toolName: 'list_agent_evaluation_runs',
|
|
380
377
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
381
|
-
taskSupport: { exposed:
|
|
378
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
382
379
|
},
|
|
383
380
|
cli: { commandPath: 'agents evals runs' },
|
|
384
|
-
profiles: [
|
|
381
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
385
382
|
});
|
|
386
383
|
const evaluationsRunResultsGet = (0, types_1.defineOperation)({
|
|
387
384
|
id: 'ai-agents.project.evaluations.runs.get',
|
|
@@ -393,12 +390,79 @@ const evaluationsRunResultsGet = (0, types_1.defineOperation)({
|
|
|
393
390
|
authorization: { safetyImpact: IMPACT_READ },
|
|
394
391
|
sensitivity: 'none',
|
|
395
392
|
mcp: {
|
|
396
|
-
toolName: '
|
|
393
|
+
toolName: 'get_agent_eval_run_results',
|
|
397
394
|
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
398
|
-
taskSupport: { exposed:
|
|
395
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
399
396
|
},
|
|
400
397
|
cli: { commandPath: 'agents evals run-results' },
|
|
401
|
-
profiles: [
|
|
398
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
399
|
+
});
|
|
400
|
+
const evaluateAgentReadiness = (0, types_1.defineOperation)({
|
|
401
|
+
id: 'ai-agents.project.agents.evaluate-readiness',
|
|
402
|
+
summary: 'Evaluate release readiness score for an agent (not an evaluation-suite run)',
|
|
403
|
+
http: {
|
|
404
|
+
method: 'POST',
|
|
405
|
+
path: `${PROJECT_AGENT_PATH}/evaluateReadiness`,
|
|
406
|
+
},
|
|
407
|
+
authorization: { safetyImpact: IMPACT_READ },
|
|
408
|
+
sensitivity: 'none',
|
|
409
|
+
mcp: {
|
|
410
|
+
toolName: 'evaluate_agent_readiness',
|
|
411
|
+
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
412
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
413
|
+
},
|
|
414
|
+
cli: { commandPath: 'agents readiness evaluate' },
|
|
415
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
416
|
+
});
|
|
417
|
+
const getAgentSuggestions = (0, types_1.defineOperation)({
|
|
418
|
+
id: 'ai-agents.project.agents.suggestions',
|
|
419
|
+
summary: 'List suggestion chips for an agent',
|
|
420
|
+
http: {
|
|
421
|
+
method: 'GET',
|
|
422
|
+
path: `${PROJECT_AGENT_PATH}/suggestions`,
|
|
423
|
+
},
|
|
424
|
+
authorization: { safetyImpact: IMPACT_READ },
|
|
425
|
+
sensitivity: 'none',
|
|
426
|
+
mcp: {
|
|
427
|
+
toolName: 'get_agent_suggestions',
|
|
428
|
+
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
429
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
430
|
+
},
|
|
431
|
+
cli: { commandPath: 'agents suggestions' },
|
|
432
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
433
|
+
});
|
|
434
|
+
const getAgentModels = (0, types_1.defineOperation)({
|
|
435
|
+
id: 'ai-agents.project.agents.models',
|
|
436
|
+
summary: 'List available AI model options for an agent',
|
|
437
|
+
http: {
|
|
438
|
+
method: 'GET',
|
|
439
|
+
path: `${PROJECT_AGENT_PATH}/models`,
|
|
440
|
+
},
|
|
441
|
+
authorization: { safetyImpact: IMPACT_READ },
|
|
442
|
+
sensitivity: 'none',
|
|
443
|
+
mcp: {
|
|
444
|
+
toolName: 'get_agent_models',
|
|
445
|
+
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
446
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
447
|
+
},
|
|
448
|
+
cli: { commandPath: 'agents models' },
|
|
449
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
450
|
+
});
|
|
451
|
+
const getExploreAccessSummary = (0, types_1.defineOperation)({
|
|
452
|
+
id: 'ai-agents.project.explore-access-summary',
|
|
453
|
+
summary: 'Summarize explore access for tag-filtered explores',
|
|
454
|
+
http: {
|
|
455
|
+
method: 'POST',
|
|
456
|
+
path: `${PROJECT_AGENTS_PATH}/explore-access-summary`,
|
|
457
|
+
},
|
|
458
|
+
authorization: { safetyImpact: IMPACT_READ },
|
|
459
|
+
sensitivity: 'none',
|
|
460
|
+
mcp: {
|
|
461
|
+
toolName: 'get_explore_access_summary',
|
|
462
|
+
annotations: safety_1.READ_ONLY_DEFAULT,
|
|
463
|
+
taskSupport: { exposed: true, taskEligible: false },
|
|
464
|
+
},
|
|
465
|
+
profiles: [PROFILE_AI_AGENT_OPS],
|
|
402
466
|
});
|
|
403
467
|
/** All registered P0 AI agent operations. */
|
|
404
468
|
exports.AI_AGENT_OPERATIONS = [
|
|
@@ -411,6 +475,10 @@ exports.AI_AGENT_OPERATIONS = [
|
|
|
411
475
|
projectAgentsCreate,
|
|
412
476
|
projectAgentsUpdate,
|
|
413
477
|
projectAgentsDelete,
|
|
478
|
+
evaluateAgentReadiness,
|
|
479
|
+
getAgentSuggestions,
|
|
480
|
+
getAgentModels,
|
|
481
|
+
getExploreAccessSummary,
|
|
414
482
|
threadsList,
|
|
415
483
|
threadsGet,
|
|
416
484
|
threadsStart,
|