@lightdash-tools/mcp 0.8.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/README.md +108 -237
- package/dist/audit/server-persona.d.ts +10 -0
- package/dist/audit/server-persona.js +19 -0
- package/dist/auth/oauth-broker/pending-store.d.ts +6 -7
- package/dist/auth/oauth-broker/pending-store.js +3 -4
- package/dist/auth/oauth-broker/pending-store.test.d.ts +2 -3
- package/dist/auth/oauth-broker/pending-store.test.js +2 -39
- package/dist/auth/oauth-broker/routes.d.ts +1 -1
- package/dist/auth/oauth-broker/routes.js +3 -3
- package/dist/auth/oauth-broker/routes.test.js +1 -1
- package/dist/auth/request-state-key.d.ts +19 -0
- package/dist/auth/request-state-key.js +49 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +0 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +0 -19
- package/dist/auth/resource-server/www-authenticate.test.js +0 -2
- package/dist/bin.js +9 -2
- package/dist/config/env.d.ts +5 -15
- package/dist/config/env.js +6 -16
- package/dist/config/load-mcp-config.d.ts +0 -4
- package/dist/config/load-mcp-config.js +8 -9
- package/dist/config/normalize-url.test.js +14 -11
- package/dist/config/runtime.d.ts +3 -3
- package/dist/config/runtime.js +19 -23
- package/dist/config/runtime.test.js +23 -9
- package/dist/config/test-mcp-http-config.js +1 -1
- package/dist/destructive/content-promote.js +7 -1
- package/dist/destructive/promote-contract.test.js +106 -47
- package/dist/destructive/register-destructive-tool.js +6 -24
- package/dist/destructive/request-state.d.ts +2 -6
- package/dist/destructive/request-state.js +3 -38
- package/dist/destructive/types.d.ts +2 -1
- package/dist/governance/available-projects.d.ts +37 -0
- package/dist/governance/available-projects.js +132 -0
- package/dist/governance/available-projects.test.d.ts +4 -0
- package/dist/governance/available-projects.test.js +107 -0
- package/dist/governance/client-capabilities-cache.d.ts +44 -0
- package/dist/governance/client-capabilities-cache.js +142 -0
- package/dist/governance/client-capabilities-cache.test.js +148 -0
- package/dist/governance/mcp-client-session.d.ts +3 -2
- package/dist/governance/mcp-client-session.js +3 -2
- package/dist/governance/project-scope.d.ts +8 -22
- package/dist/governance/project-scope.js +36 -44
- package/dist/governance/project-scope.test.d.ts +1 -1
- package/dist/governance/project-scope.test.js +21 -44
- package/dist/governance/promote-allowlist.d.ts +18 -0
- package/dist/governance/promote-allowlist.js +66 -0
- package/dist/governance/promote-allowlist.test.d.ts +4 -0
- package/dist/governance/promote-allowlist.test.js +87 -0
- package/dist/http.integration.test.js +117 -262
- package/dist/http.test.js +0 -12
- package/dist/index.integration.test.js +0 -4
- package/dist/index.js +3 -1
- package/dist/personas/ai-agent-ops/v1/index.d.ts +8 -0
- package/dist/personas/ai-agent-ops/v1/index.js +41 -0
- package/dist/personas/ai-agent-ops/v1/prompts.d.ts +5 -0
- package/dist/personas/ai-agent-ops/v1/prompts.js +141 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.d.ts +4 -0
- package/dist/personas/ai-agent-ops/v1/prompts.test.js +26 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/core.md +39 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/evaluation.md +25 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/index.md +14 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +28 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks/release-gate.md +22 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.d.ts +10 -0
- package/dist/personas/ai-agent-ops/v1/resources/playbooks.js +41 -0
- package/dist/personas/content-developer/v1/index.d.ts +1 -1
- package/dist/personas/content-developer/v1/index.js +1 -0
- package/dist/personas/content-developer/v1/prompts.d.ts +3 -0
- package/dist/personas/content-developer/v1/prompts.js +80 -61
- package/dist/personas/content-developer/v1/prompts.test.js +159 -3
- package/dist/personas/content-developer/v1/resources/playbooks/chart-types.md +123 -0
- package/dist/personas/content-developer/v1/resources/playbooks/content-move.md +13 -6
- package/dist/personas/content-developer/v1/resources/playbooks/core.md +91 -49
- package/dist/personas/content-developer/v1/resources/playbooks/dashboard-design.md +153 -0
- package/dist/personas/content-developer/v1/resources/playbooks/dashboards.md +82 -34
- package/dist/personas/content-developer/v1/resources/playbooks/index.md +9 -7
- package/dist/personas/content-developer/v1/resources/playbooks.d.ts +1 -1
- package/dist/personas/content-developer/v1/resources/playbooks.js +29 -10
- package/dist/personas/content-governance/v1/resources/playbooks/core.md +1 -1
- package/dist/personas/content-governance/v1/resources/playbooks/dashboards.md +1 -1
- package/dist/personas/content-reader/v1/index.d.ts +1 -1
- package/dist/personas/content-reader/v1/index.js +1 -0
- package/dist/personas/content-reader/v1/prompts.js +64 -30
- package/dist/personas/content-reader/v1/resources/playbooks/compare.md +24 -9
- package/dist/personas/content-reader/v1/resources/playbooks/core.md +56 -29
- package/dist/personas/content-reader/v1/resources/playbooks/discover.md +27 -5
- package/dist/personas/content-reader/v1/resources/playbooks/explain-run.md +38 -8
- package/dist/personas/content-reader/v1/resources/playbooks/index.md +8 -8
- package/dist/personas/content-reader/v1/resources/playbooks.js +2 -2
- package/dist/personas/index.d.ts +1 -0
- package/dist/personas/index.js +27 -22
- package/dist/personas/index.test.js +68 -53
- package/dist/personas/lib/playbook-resources.d.ts +4 -3
- package/dist/personas/lib/playbook-resources.js +14 -10
- package/dist/personas/organization-audit/v1/prompts.js +68 -36
- package/dist/personas/organization-audit/v1/resources/playbooks/access.md +12 -4
- package/dist/personas/organization-audit/v1/resources/playbooks/content.md +13 -3
- package/dist/personas/organization-audit/v1/resources/playbooks/core.md +49 -16
- package/dist/personas/organization-audit/v1/resources/playbooks/deliveries.md +8 -3
- package/dist/personas/organization-audit/v1/resources/playbooks/index.md +8 -8
- package/dist/personas/organization-audit/v1/resources/playbooks.js +1 -1
- package/dist/personas/persona.parity.test.js +14 -10
- package/dist/personas/semantic-layer/v1/prompts.js +50 -39
- package/dist/personas/semantic-layer/v1/resources/playbooks/compose-compile.md +36 -31
- package/dist/personas/semantic-layer/v1/resources/playbooks/core.md +53 -21
- package/dist/personas/semantic-layer/v1/resources/playbooks/explore.md +42 -39
- package/dist/personas/semantic-layer/v1/resources/playbooks/index.md +6 -6
- package/dist/personas/semantic-layer/v1/resources/playbooks.js +2 -2
- package/dist/personas/types.d.ts +1 -1
- package/dist/policy/content-developer.d.ts +3 -3
- package/dist/policy/content-developer.js +3 -3
- package/dist/policy/content-developer.test.js +10 -4
- package/dist/policy/content-reader.d.ts +5 -1
- package/dist/policy/content-reader.js +18 -3
- package/dist/policy/content-reader.test.js +2 -1
- package/dist/policy/preview-ledger-fault.test.js +101 -426
- package/dist/policy/preview-ledger.d.ts +38 -74
- package/dist/policy/preview-ledger.js +108 -186
- package/dist/policy/preview-ledger.test.js +237 -111
- package/dist/policy/result-limits.d.ts +6 -1
- package/dist/policy/result-limits.js +28 -29
- package/dist/policy/result-limits.test.js +10 -1
- package/dist/server/capabilities.js +2 -0
- package/dist/server/capabilities.test.js +2 -0
- package/dist/server/server.js +12 -8
- package/dist/server/upstream-errors.d.ts +17 -0
- package/dist/server/upstream-errors.js +60 -0
- package/dist/server/upstream-errors.test.js +50 -0
- package/dist/stdio.process.test.js +4 -2
- package/dist/tools/ai-agents/agents.d.ts +7 -0
- package/dist/tools/ai-agents/agents.js +32 -0
- package/dist/tools/ai-agents/agents.test.js +176 -0
- package/dist/tools/ai-agents/discovery.d.ts +9 -0
- package/dist/tools/ai-agents/discovery.js +73 -0
- package/dist/tools/ai-agents/evaluations.d.ts +14 -0
- package/dist/tools/ai-agents/evaluations.js +177 -0
- package/dist/tools/ai-agents/helpers.d.ts +64 -0
- package/dist/tools/ai-agents/helpers.js +323 -0
- package/dist/tools/ai-agents/threads.d.ts +7 -0
- package/dist/tools/ai-agents/threads.js +40 -0
- package/dist/tools/organization/inventory.js +2 -1
- package/dist/tools/project/content.js +5 -1
- package/dist/tools/project/developer-content-preview.d.ts +2 -1
- package/dist/tools/project/developer-content-preview.js +40 -35
- package/dist/tools/project/developer-content-shared.d.ts +8 -2
- package/dist/tools/project/developer-content-shared.js +7 -3
- package/dist/tools/project/developer-content.d.ts +7 -8
- package/dist/tools/project/developer-content.js +72 -67
- package/dist/tools/project/developer-get-chart-as-code.d.ts +9 -0
- package/dist/tools/project/developer-get-chart-as-code.js +39 -0
- package/dist/tools/project/developer-get-chart-as-code.test.d.ts +4 -0
- package/dist/tools/project/developer-get-chart-as-code.test.js +70 -0
- package/dist/tools/project/developer-helpers.d.ts +1 -1
- package/dist/tools/project/developer-helpers.js +1 -1
- package/dist/tools/project/get-dashboard-promote-diff.js +12 -2
- package/dist/tools/project/invariants.test.js +5 -3
- package/dist/tools/project/projects.js +6 -4
- package/dist/tools/project/projects.test.js +44 -5
- package/dist/tools/project/reader-export-chart-image.d.ts +6 -0
- package/dist/tools/project/reader-export-chart-image.js +78 -0
- package/dist/tools/project/reader-export-chart-image.test.d.ts +4 -0
- package/dist/tools/project/reader-export-chart-image.test.js +149 -0
- package/dist/tools/query/bounded-saved-query.js +1 -1
- package/dist/tools/query/lifecycle.d.ts +1 -1
- package/dist/tools/query/lifecycle.js +17 -25
- package/dist/tools/query/query-ledger.d.ts +15 -8
- package/dist/tools/query/query-ledger.js +21 -15
- package/dist/tools/query/query-ledger.test.js +13 -11
- package/dist/tools/query/reader-tool-helpers.js +4 -6
- package/dist/tools/query/reader-tool-helpers.test.js +8 -4
- package/dist/tools/registry.d.ts +63 -0
- package/dist/tools/registry.js +26 -0
- package/dist/tools/shared.d.ts +27 -8
- package/dist/tools/shared.js +61 -28
- package/dist/tools/shared.test.js +100 -4
- package/dist/transports/streamable-http.js +48 -206
- package/dist/transports/streamable-http.test.js +10 -3
- package/package.json +5 -6
- package/dist/destructive/confirmation-claim.d.ts +0 -21
- package/dist/destructive/confirmation-claim.js +0 -87
- package/dist/destructive/confirmation-claim.test.js +0 -50
- package/dist/store/config.d.ts +0 -11
- package/dist/store/config.js +0 -50
- package/dist/store/config.test.js +0 -56
- package/dist/store/create-oauth-broker-store.d.ts +0 -6
- package/dist/store/create-oauth-broker-store.js +0 -16
- package/dist/store/create-preview-store.d.ts +0 -10
- package/dist/store/create-preview-store.js +0 -30
- package/dist/store/create-session-store.d.ts +0 -19
- package/dist/store/create-session-store.js +0 -24
- package/dist/store/in-memory-preview-store.d.ts +0 -17
- package/dist/store/in-memory-preview-store.js +0 -72
- package/dist/store/redis-client.d.ts +0 -11
- package/dist/store/redis-client.js +0 -48
- package/dist/store/redis-oauth-broker-store.d.ts +0 -42
- package/dist/store/redis-oauth-broker-store.js +0 -167
- package/dist/store/redis-oauth-broker-store.test.js +0 -80
- package/dist/store/redis-preview-store.d.ts +0 -23
- package/dist/store/redis-preview-store.js +0 -94
- package/dist/store/redis-preview-store.test.d.ts +0 -1
- package/dist/store/redis-preview-store.test.js +0 -39
- package/dist/store/redis-session-index.d.ts +0 -33
- package/dist/store/redis-session-index.js +0 -49
- package/dist/store/types.d.ts +0 -13
- package/dist/store/types.js +0 -8
- package/dist/transports/http-request-utils.d.ts +0 -2
- package/dist/transports/http-request-utils.js +0 -13
- package/dist/transports/session-store.d.ts +0 -72
- package/dist/transports/session-store.js +0 -143
- package/dist/transports/session-store.test.d.ts +0 -1
- package/dist/transports/session-store.test.js +0 -111
- /package/dist/{destructive/confirmation-claim.test.d.ts → governance/client-capabilities-cache.test.d.ts} +0 -0
- /package/dist/{store/config.test.d.ts → server/upstream-errors.test.d.ts} +0 -0
- /package/dist/{store/redis-oauth-broker-store.test.d.ts → tools/ai-agents/agents.test.d.ts} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Query lifecycle tools: poll results and cancel
|
|
3
|
+
* Query lifecycle tools: poll results and cancel queries by queryUuid handle.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerGetQueryResult = registerGetQueryResult;
|
|
7
7
|
exports.registerCancelQuery = registerCancelQuery;
|
|
8
8
|
const zod_1 = require("zod");
|
|
9
|
-
const tool_audit_context_js_1 = require("../../audit/tool-audit-context.js");
|
|
10
|
-
const mcp_client_session_js_1 = require("../../governance/mcp-client-session.js");
|
|
11
9
|
const project_scope_js_1 = require("../../governance/project-scope.js");
|
|
12
10
|
const content_reader_js_1 = require("../../policy/content-reader.js");
|
|
13
11
|
const envelope_js_1 = require("../../policy/envelope.js");
|
|
@@ -24,7 +22,7 @@ function isTerminalStatus(status) {
|
|
|
24
22
|
function registerGetQueryResult(server, contextProvider) {
|
|
25
23
|
(0, content_reader_js_1.registerContentReaderTool)(server, 'get_query_result', {
|
|
26
24
|
title: 'Get query result',
|
|
27
|
-
description: 'Poll or retrieve a query started by this persona (
|
|
25
|
+
description: 'Poll or retrieve a query started by this persona (by queryUuid handle)',
|
|
28
26
|
safety: content_reader_js_1.SAVED_EXECUTION_SAFETY,
|
|
29
27
|
inputSchema: {
|
|
30
28
|
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
@@ -34,20 +32,17 @@ function registerGetQueryResult(server, contextProvider) {
|
|
|
34
32
|
pageSize: zod_1.z.number().int().positive().max(1000).optional(),
|
|
35
33
|
},
|
|
36
34
|
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
37
|
-
var _a, _b, _c
|
|
35
|
+
var _a, _b, _c;
|
|
38
36
|
try {
|
|
39
37
|
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const ledgerEntry = (0, query_ledger_js_1.getOwnedQueryLedgerEntry)({
|
|
38
|
+
// Ledger is best-effort (same replica); queryUuid is the durable handle.
|
|
39
|
+
const ledgerEntry = (0, query_ledger_js_1.findQueryLedgerEntry)({
|
|
43
40
|
projectUuid: scope.projectUuid,
|
|
44
41
|
queryUuid: args.queryUuid,
|
|
45
|
-
sessionId,
|
|
46
|
-
userUuid,
|
|
47
42
|
});
|
|
48
|
-
const waitMs = (0, result_limits_js_1.clampWaitMs)((
|
|
49
|
-
const pageSize = (
|
|
50
|
-
const page = (
|
|
43
|
+
const waitMs = (0, result_limits_js_1.clampWaitMs)((_a = args.waitMs) !== null && _a !== void 0 ? _a : 0);
|
|
44
|
+
const pageSize = (_b = args.pageSize) !== null && _b !== void 0 ? _b : 100;
|
|
45
|
+
const page = (_c = args.page) !== null && _c !== void 0 ? _c : 1;
|
|
51
46
|
const normalized = waitMs > 0
|
|
52
47
|
? await (0, wait_for_async_js_1.waitForAsyncQueryResults)(c, scope.projectUuid, args.queryUuid, {
|
|
53
48
|
waitMs,
|
|
@@ -58,8 +53,8 @@ function registerGetQueryResult(server, contextProvider) {
|
|
|
58
53
|
page,
|
|
59
54
|
pageSize,
|
|
60
55
|
}), { maxRows: pageSize });
|
|
61
|
-
if (isTerminalStatus(normalized.status)) {
|
|
62
|
-
(0, query_ledger_js_1.
|
|
56
|
+
if (ledgerEntry && isTerminalStatus(normalized.status)) {
|
|
57
|
+
(0, query_ledger_js_1.releaseQueryLedgerBudget)(ledgerEntry);
|
|
63
58
|
}
|
|
64
59
|
return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)(normalized, {
|
|
65
60
|
projectUuid: scope.projectUuid,
|
|
@@ -70,7 +65,7 @@ function registerGetQueryResult(server, contextProvider) {
|
|
|
70
65
|
}));
|
|
71
66
|
}
|
|
72
67
|
catch (err) {
|
|
73
|
-
if (err instanceof project_scope_js_1.ProjectScopeError
|
|
68
|
+
if (err instanceof project_scope_js_1.ProjectScopeError) {
|
|
74
69
|
return (0, reader_tool_helpers_js_1.codedErrorResult)(err.code, err.message);
|
|
75
70
|
}
|
|
76
71
|
throw err;
|
|
@@ -80,30 +75,27 @@ function registerGetQueryResult(server, contextProvider) {
|
|
|
80
75
|
function registerCancelQuery(server, contextProvider) {
|
|
81
76
|
(0, content_reader_js_1.registerContentReaderTool)(server, 'cancel_query', {
|
|
82
77
|
title: 'Cancel query',
|
|
83
|
-
description: 'Cancel a running
|
|
78
|
+
description: 'Cancel a running query by queryUuid handle',
|
|
84
79
|
safety: content_reader_js_1.SAVED_EXECUTION_SAFETY,
|
|
85
80
|
inputSchema: {
|
|
86
81
|
projectUuid: (0, schema_fields_js_1.projectUuidField)().optional(),
|
|
87
82
|
queryUuid: zod_1.z.string(),
|
|
88
83
|
},
|
|
89
84
|
}, (0, shared_js_1.wrapTool)(contextProvider, (c) => async (args) => {
|
|
90
|
-
var _a;
|
|
91
85
|
try {
|
|
92
86
|
const scope = (0, project_scope_js_1.resolveProjectScope)({ projectUuid: args.projectUuid });
|
|
93
|
-
const
|
|
94
|
-
const userUuid = (_a = (0, tool_audit_context_js_1.getToolAuditAuth)()) === null || _a === void 0 ? void 0 : _a.subject;
|
|
95
|
-
const ledgerEntry = (0, query_ledger_js_1.getOwnedQueryLedgerEntry)({
|
|
87
|
+
const ledgerEntry = (0, query_ledger_js_1.findQueryLedgerEntry)({
|
|
96
88
|
projectUuid: scope.projectUuid,
|
|
97
89
|
queryUuid: args.queryUuid,
|
|
98
|
-
sessionId,
|
|
99
|
-
userUuid,
|
|
100
90
|
});
|
|
101
91
|
await c.v2.query.cancelAsyncQuery(scope.projectUuid, args.queryUuid);
|
|
102
|
-
|
|
92
|
+
if (ledgerEntry) {
|
|
93
|
+
(0, query_ledger_js_1.releaseQueryLedgerBudget)(ledgerEntry);
|
|
94
|
+
}
|
|
103
95
|
return (0, shared_js_1.jsonToolResult)((0, envelope_js_1.contentReaderEnvelope)({ queryUuid: args.queryUuid, cancelled: true }, { projectUuid: scope.projectUuid, projectPinned: scope.projectPinned }));
|
|
104
96
|
}
|
|
105
97
|
catch (err) {
|
|
106
|
-
if (err instanceof project_scope_js_1.ProjectScopeError
|
|
98
|
+
if (err instanceof project_scope_js_1.ProjectScopeError) {
|
|
107
99
|
return (0, reader_tool_helpers_js_1.codedErrorResult)(err.code, err.message);
|
|
108
100
|
}
|
|
109
101
|
throw err;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* In-memory query
|
|
2
|
+
* In-memory query handle ledger for content-reader (ADR-0012 / ADR-0019).
|
|
3
|
+
* Keyed by projectUuid+queryUuid; sessionId retained only for per-process budget release.
|
|
3
4
|
*/
|
|
4
5
|
export type ReaderQueryLedgerEntry = {
|
|
5
6
|
queryUuid: string;
|
|
6
7
|
sessionId: string;
|
|
7
8
|
userUuid?: string;
|
|
8
9
|
projectUuid: string;
|
|
9
|
-
persona: 'content-reader';
|
|
10
10
|
sourceType: 'chart' | 'dashboard_tile';
|
|
11
11
|
sourceUuid: string;
|
|
12
12
|
/** True while concurrency budget is held for this in-flight warehouse query. */
|
|
@@ -15,20 +15,27 @@ export type ReaderQueryLedgerEntry = {
|
|
|
15
15
|
expiresAt: string;
|
|
16
16
|
};
|
|
17
17
|
export declare class QueryLedgerError extends Error {
|
|
18
|
-
readonly code: '
|
|
18
|
+
readonly code: 'QUERY_NOT_FOUND';
|
|
19
19
|
constructor(code: QueryLedgerError['code'], message: string);
|
|
20
20
|
}
|
|
21
|
-
export declare function addQueryLedgerEntry(entry: Omit<ReaderQueryLedgerEntry, 'budgetHeld' | 'createdAt' | 'expiresAt'
|
|
21
|
+
export declare function addQueryLedgerEntry(entry: Omit<ReaderQueryLedgerEntry, 'budgetHeld' | 'createdAt' | 'expiresAt'> & {
|
|
22
22
|
ttlMs?: number;
|
|
23
23
|
budgetHeld?: boolean;
|
|
24
24
|
}): ReaderQueryLedgerEntry;
|
|
25
|
-
|
|
25
|
+
/** Look up a ledger entry by projectUuid+queryUuid (no session ownership check). */
|
|
26
|
+
export declare function getQueryLedgerEntry(input: {
|
|
26
27
|
projectUuid: string;
|
|
27
28
|
queryUuid: string;
|
|
28
|
-
sessionId: string;
|
|
29
|
-
userUuid?: string;
|
|
30
29
|
}): ReaderQueryLedgerEntry;
|
|
30
|
+
/**
|
|
31
|
+
* Best-effort ledger lookup for budget release. Missing/expired entries return undefined
|
|
32
|
+
* so get/cancel can still use the Lightdash queryUuid handle across replicas (ADR-0019).
|
|
33
|
+
*/
|
|
34
|
+
export declare function findQueryLedgerEntry(input: {
|
|
35
|
+
projectUuid: string;
|
|
36
|
+
queryUuid: string;
|
|
37
|
+
}): ReaderQueryLedgerEntry | undefined;
|
|
31
38
|
/** Release concurrency budget once when the warehouse query reaches a terminal state or is cancelled. */
|
|
32
|
-
export declare function
|
|
39
|
+
export declare function releaseQueryLedgerBudget(entry: ReaderQueryLedgerEntry): void;
|
|
33
40
|
/** Test helper. */
|
|
34
41
|
export declare function resetQueryLedgerForTests(): void;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* In-memory query
|
|
3
|
+
* In-memory query handle ledger for content-reader (ADR-0012 / ADR-0019).
|
|
4
|
+
* Keyed by projectUuid+queryUuid; sessionId retained only for per-process budget release.
|
|
4
5
|
*/
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
7
|
exports.QueryLedgerError = void 0;
|
|
7
8
|
exports.addQueryLedgerEntry = addQueryLedgerEntry;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
9
|
+
exports.getQueryLedgerEntry = getQueryLedgerEntry;
|
|
10
|
+
exports.findQueryLedgerEntry = findQueryLedgerEntry;
|
|
11
|
+
exports.releaseQueryLedgerBudget = releaseQueryLedgerBudget;
|
|
10
12
|
exports.resetQueryLedgerForTests = resetQueryLedgerForTests;
|
|
11
13
|
const result_limits_js_1 = require("../../policy/result-limits.js");
|
|
12
14
|
class QueryLedgerError extends Error {
|
|
@@ -46,7 +48,6 @@ function addQueryLedgerEntry(entry) {
|
|
|
46
48
|
sessionId: entry.sessionId,
|
|
47
49
|
userUuid: entry.userUuid,
|
|
48
50
|
projectUuid: entry.projectUuid,
|
|
49
|
-
persona: 'content-reader',
|
|
50
51
|
sourceType: entry.sourceType,
|
|
51
52
|
sourceUuid: entry.sourceUuid,
|
|
52
53
|
budgetHeld: (_b = entry.budgetHeld) !== null && _b !== void 0 ? _b : true,
|
|
@@ -56,29 +57,34 @@ function addQueryLedgerEntry(entry) {
|
|
|
56
57
|
ledger.set(entryKey(entry.projectUuid, entry.queryUuid), full);
|
|
57
58
|
return full;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
/** Look up a ledger entry by projectUuid+queryUuid (no session ownership check). */
|
|
61
|
+
function getQueryLedgerEntry(input) {
|
|
62
|
+
const entry = findQueryLedgerEntry(input);
|
|
63
|
+
if (!entry) {
|
|
64
|
+
throw new QueryLedgerError('QUERY_NOT_FOUND', `Query '${input.queryUuid}' not found or already expired`);
|
|
65
|
+
}
|
|
66
|
+
return entry;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Best-effort ledger lookup for budget release. Missing/expired entries return undefined
|
|
70
|
+
* so get/cancel can still use the Lightdash queryUuid handle across replicas (ADR-0019).
|
|
71
|
+
*/
|
|
72
|
+
function findQueryLedgerEntry(input) {
|
|
60
73
|
const key = entryKey(input.projectUuid, input.queryUuid);
|
|
61
74
|
const entry = ledger.get(key);
|
|
62
75
|
if (!entry) {
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
if (entry.sessionId !== input.sessionId) {
|
|
66
|
-
throw new QueryLedgerError('QUERY_NOT_OWNED', `Query '${input.queryUuid}' belongs to another session`);
|
|
67
|
-
}
|
|
68
|
-
if (entry.userUuid && input.userUuid && entry.userUuid !== input.userUuid) {
|
|
69
|
-
throw new QueryLedgerError('QUERY_NOT_OWNED', `Query '${input.queryUuid}' belongs to another user`);
|
|
76
|
+
return undefined;
|
|
70
77
|
}
|
|
71
78
|
if (Date.parse(entry.expiresAt) < Date.now()) {
|
|
72
79
|
releaseBudgetIfHeld(entry);
|
|
73
80
|
ledger.delete(key);
|
|
74
|
-
|
|
81
|
+
return undefined;
|
|
75
82
|
}
|
|
76
83
|
return entry;
|
|
77
84
|
}
|
|
78
85
|
/** Release concurrency budget once when the warehouse query reaches a terminal state or is cancelled. */
|
|
79
|
-
function
|
|
86
|
+
function releaseQueryLedgerBudget(entry) {
|
|
80
87
|
releaseBudgetIfHeld(entry);
|
|
81
|
-
ledger.set(entryKey(entry.projectUuid, entry.queryUuid), entry);
|
|
82
88
|
}
|
|
83
89
|
/** Test helper. */
|
|
84
90
|
function resetQueryLedgerForTests() {
|
|
@@ -8,7 +8,7 @@ const query_ledger_js_1 = require("./query-ledger.js");
|
|
|
8
8
|
(0, query_ledger_js_1.resetQueryLedgerForTests)();
|
|
9
9
|
(0, result_limits_js_1.resetQueryBudgetsForTests)();
|
|
10
10
|
});
|
|
11
|
-
(0, vitest_1.it)('stores and returns
|
|
11
|
+
(0, vitest_1.it)('stores and returns entries with budgetHeld', () => {
|
|
12
12
|
(0, query_ledger_js_1.addQueryLedgerEntry)({
|
|
13
13
|
queryUuid: 'q1',
|
|
14
14
|
sessionId: 's1',
|
|
@@ -16,15 +16,11 @@ const query_ledger_js_1 = require("./query-ledger.js");
|
|
|
16
16
|
sourceType: 'chart',
|
|
17
17
|
sourceUuid: 'c1',
|
|
18
18
|
});
|
|
19
|
-
const entry = (0, query_ledger_js_1.
|
|
20
|
-
projectUuid: 'p1',
|
|
21
|
-
queryUuid: 'q1',
|
|
22
|
-
sessionId: 's1',
|
|
23
|
-
});
|
|
19
|
+
const entry = (0, query_ledger_js_1.getQueryLedgerEntry)({ projectUuid: 'p1', queryUuid: 'q1' });
|
|
24
20
|
(0, vitest_1.expect)(entry.sourceUuid).toBe('c1');
|
|
25
21
|
(0, vitest_1.expect)(entry.budgetHeld).toBe(true);
|
|
26
22
|
});
|
|
27
|
-
(0, vitest_1.it)('
|
|
23
|
+
(0, vitest_1.it)('returns entries regardless of requesting session', () => {
|
|
28
24
|
(0, query_ledger_js_1.addQueryLedgerEntry)({
|
|
29
25
|
queryUuid: 'q1',
|
|
30
26
|
sessionId: 's1',
|
|
@@ -32,7 +28,12 @@ const query_ledger_js_1 = require("./query-ledger.js");
|
|
|
32
28
|
sourceType: 'chart',
|
|
33
29
|
sourceUuid: 'c1',
|
|
34
30
|
});
|
|
35
|
-
|
|
31
|
+
// Any caller can look up by projectUuid+queryUuid — no ownership check.
|
|
32
|
+
const entry = (0, query_ledger_js_1.getQueryLedgerEntry)({ projectUuid: 'p1', queryUuid: 'q1' });
|
|
33
|
+
(0, vitest_1.expect)(entry.sessionId).toBe('s1');
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.it)('rejects missing entries as QUERY_NOT_FOUND', () => {
|
|
36
|
+
(0, vitest_1.expect)(() => (0, query_ledger_js_1.getQueryLedgerEntry)({ projectUuid: 'p1', queryUuid: 'missing' })).toThrow(/QUERY_NOT_FOUND|not found/);
|
|
36
37
|
});
|
|
37
38
|
(0, vitest_1.it)('rejects expired entries and releases held budget', () => {
|
|
38
39
|
(0, result_limits_js_1.acquireQueryBudget)('s1');
|
|
@@ -45,7 +46,8 @@ const query_ledger_js_1 = require("./query-ledger.js");
|
|
|
45
46
|
ttlMs: -1,
|
|
46
47
|
budgetHeld: true,
|
|
47
48
|
});
|
|
48
|
-
(0, vitest_1.expect)((
|
|
49
|
+
(0, vitest_1.expect)((0, query_ledger_js_1.findQueryLedgerEntry)({ projectUuid: 'p1', queryUuid: 'q1' })).toBeUndefined();
|
|
50
|
+
(0, vitest_1.expect)(() => (0, query_ledger_js_1.getQueryLedgerEntry)({ projectUuid: 'p1', queryUuid: 'q1' })).toThrow(/QUERY_NOT_FOUND|not found/);
|
|
49
51
|
// Slot freed on expiry.
|
|
50
52
|
for (let i = 0; i < result_limits_js_1.MAX_CONCURRENT_QUERIES_PER_SESSION; i += 1) {
|
|
51
53
|
(0, result_limits_js_1.acquireQueryBudget)('s1');
|
|
@@ -62,8 +64,8 @@ const query_ledger_js_1 = require("./query-ledger.js");
|
|
|
62
64
|
sourceUuid: 'c1',
|
|
63
65
|
budgetHeld: true,
|
|
64
66
|
});
|
|
65
|
-
(0, query_ledger_js_1.
|
|
66
|
-
(0, query_ledger_js_1.
|
|
67
|
+
(0, query_ledger_js_1.releaseQueryLedgerBudget)(entry);
|
|
68
|
+
(0, query_ledger_js_1.releaseQueryLedgerBudget)(entry);
|
|
67
69
|
(0, vitest_1.expect)(entry.budgetHeld).toBe(false);
|
|
68
70
|
for (let i = 0; i < result_limits_js_1.MAX_CONCURRENT_QUERIES_PER_SESSION; i += 1) {
|
|
69
71
|
(0, result_limits_js_1.acquireQueryBudget)('s1');
|
|
@@ -12,29 +12,27 @@ const project_scope_js_1 = require("../../governance/project-scope.js");
|
|
|
12
12
|
const shared_js_1 = require("../shared.js");
|
|
13
13
|
/** Policy denials that should audit as `blocked` (stripped `_lightdashBlocked` marker). */
|
|
14
14
|
const BLOCKED_POLICY_CODES = new Set([
|
|
15
|
+
'PROJECT_NOT_AVAILABLE',
|
|
15
16
|
'PROJECT_SCOPE_MISMATCH',
|
|
16
17
|
'PROJECT_SCOPE_REQUIRED',
|
|
17
18
|
'CONTENT_NOT_EXECUTABLE',
|
|
18
19
|
'CONTENT_NOT_FOUND',
|
|
19
20
|
'INVALID_FILTER_OVERRIDE',
|
|
20
21
|
'INVALID_PARAMETER_OVERRIDE',
|
|
21
|
-
'
|
|
22
|
+
'QUERY_NOT_FOUND',
|
|
22
23
|
'QUERY_EXPIRED',
|
|
23
24
|
'QUERY_BUDGET_EXCEEDED',
|
|
24
25
|
'RATE_LIMITED',
|
|
25
26
|
'ROW_LIMIT_EXCEEDED',
|
|
26
|
-
// content-developer preview
|
|
27
|
+
// content-developer preview tokens (ADR-0014 / ADR-0019)
|
|
27
28
|
'PREVIEW_REQUIRED',
|
|
28
29
|
'PREVIEW_STALE',
|
|
29
|
-
'PREVIEW_EXPIRED',
|
|
30
30
|
'PREVIEW_NOT_VALIDATED',
|
|
31
31
|
'PREVIEW_NOT_OWNED',
|
|
32
|
-
'PREVIEW_RECONCILIATION_REQUIRED',
|
|
33
32
|
'CHART_SLUG_EXISTS',
|
|
34
33
|
]);
|
|
35
34
|
function codedErrorResult(code, message) {
|
|
36
|
-
const
|
|
37
|
-
const result = Object.assign(Object.assign({}, (0, shared_js_1.jsonToolResult)(body)), { isError: true });
|
|
35
|
+
const result = (0, shared_js_1.toolErrorResult)(code, message);
|
|
38
36
|
if (BLOCKED_POLICY_CODES.has(code)) {
|
|
39
37
|
return (0, shared_js_1.withLightdashBlockedMarker)(result);
|
|
40
38
|
}
|
|
@@ -9,9 +9,13 @@ const reader_tool_helpers_js_1 = require("./reader-tool-helpers.js");
|
|
|
9
9
|
(0, vitest_1.expect)(result.isError).toBe(true);
|
|
10
10
|
(0, vitest_1.expect)('_lightdashBlocked' in result).toBe(false);
|
|
11
11
|
(0, vitest_1.expect)(result.structuredContent).toEqual({ error: { code: 'QUERY_FAILED', message: 'boom' } });
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const first = result.content[0];
|
|
13
|
+
(0, vitest_1.expect)(first === null || first === void 0 ? void 0 : first.type).toBe('text');
|
|
14
|
+
if ((first === null || first === void 0 ? void 0 : first.type) === 'text') {
|
|
15
|
+
(0, vitest_1.expect)(JSON.parse(first.text)).toEqual({
|
|
16
|
+
error: { code: 'QUERY_FAILED', message: 'boom' },
|
|
17
|
+
});
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
(0, vitest_1.it)('marks scope / not-executable / ownership / budget denials as blocked', () => {
|
|
17
21
|
for (const code of [
|
|
@@ -20,7 +24,7 @@ const reader_tool_helpers_js_1 = require("./reader-tool-helpers.js");
|
|
|
20
24
|
'CONTENT_NOT_FOUND',
|
|
21
25
|
'INVALID_FILTER_OVERRIDE',
|
|
22
26
|
'INVALID_PARAMETER_OVERRIDE',
|
|
23
|
-
'
|
|
27
|
+
'QUERY_NOT_FOUND',
|
|
24
28
|
'QUERY_BUDGET_EXCEEDED',
|
|
25
29
|
'ROW_LIMIT_EXCEEDED',
|
|
26
30
|
'CHART_SLUG_EXISTS',
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* Wire names are always `lightdash_` + id via registerToolSafe.
|
|
4
4
|
* Persona allowlists must resolve through the operation catalog (ADR-0013).
|
|
5
5
|
*/
|
|
6
|
+
import { registerGetProjectAgent, registerListProjectAgents } from './ai-agents/agents.js';
|
|
7
|
+
import { registerEvaluateAgentReadiness, registerGetAgentModels, registerGetAgentSuggestions, registerGetExploreAccessSummary } from './ai-agents/discovery.js';
|
|
8
|
+
import { registerAppendAgentEvaluationPrompts, registerCreateAgentEvaluation, registerDeleteAgentEvaluation, registerGetAgentEvalRunResults, registerGetAgentEvaluation, registerListAgentEvaluationRuns, registerListAgentEvaluations, registerRunAgentEvaluation, registerUpdateAgentEvaluation } from './ai-agents/evaluations.js';
|
|
9
|
+
import { registerGetAgentThread, registerListAgentThreads } from './ai-agents/threads.js';
|
|
6
10
|
import { registerExplainContent } from './composition/explain-content.js';
|
|
7
11
|
import { registerGetOrgMember, registerGetOrgProfile, registerListOrgGroups, registerListOrgMembers, registerListOrgProjects } from './organization/inventory.js';
|
|
8
12
|
import { registerGetCustomRole, registerListCustomRoles, registerListOrgRoleAssignments, registerListProjectDirectAccess, registerListProjectRoles } from './organization/roles.js';
|
|
@@ -10,12 +14,14 @@ import { registerGetDashboardMeta, registerGetProjectUserActivity, registerListC
|
|
|
10
14
|
import { registerDeleteChart } from './project/delete-chart.js';
|
|
11
15
|
import { registerDeleteDashboard } from './project/delete-dashboard.js';
|
|
12
16
|
import { registerAddDashboardTile, registerCompareChartVersions, registerCompareDashboardVersions, registerConfirmPreview, registerCreateChart, registerCreateDashboard, registerDuplicateChart, registerDuplicateDashboard, registerMoveContent, registerMoveDashboardTile, registerPreviewChartChanges, registerPreviewContentMove, registerPreviewDashboardChanges, registerRemoveDashboardTile, registerResizeDashboardTile, registerUpdateChart, registerUpdateDashboard, registerValidateChart, registerValidateDashboard } from './project/developer-content.js';
|
|
17
|
+
import { registerGetChartAsCode } from './project/developer-get-chart-as-code.js';
|
|
13
18
|
import { registerGetDashboardPromoteDiff } from './project/get-dashboard-promote-diff.js';
|
|
14
19
|
import { registerGetProjectParameters, registerListProjectParameters } from './project/parameters.js';
|
|
15
20
|
import { registerGetProject, registerListProjects } from './project/projects.js';
|
|
16
21
|
import { registerPromoteDashboard } from './project/promote-dashboard.js';
|
|
17
22
|
import { registerGetChart, registerGetDashboard, registerSearchContent } from './project/reader-content.js';
|
|
18
23
|
import { registerRunChart, registerRunDashboardTile } from './project/reader-execution.js';
|
|
24
|
+
import { registerExportChartImage } from './project/reader-export-chart-image.js';
|
|
19
25
|
import { registerGetScheduler, registerListProjectSchedulers } from './project/schedulers.js';
|
|
20
26
|
import { registerGetSpace, registerListSpaces } from './project/spaces.js';
|
|
21
27
|
import { registerCancelQuery, registerGetQueryResult } from './query/lifecycle.js';
|
|
@@ -139,6 +145,9 @@ export declare const toolRegistry: {
|
|
|
139
145
|
readonly run_chart: {
|
|
140
146
|
readonly register: typeof registerRunChart;
|
|
141
147
|
};
|
|
148
|
+
readonly export_chart_image: {
|
|
149
|
+
readonly register: typeof registerExportChartImage;
|
|
150
|
+
};
|
|
142
151
|
readonly run_dashboard_tile: {
|
|
143
152
|
readonly register: typeof registerRunDashboardTile;
|
|
144
153
|
};
|
|
@@ -148,6 +157,9 @@ export declare const toolRegistry: {
|
|
|
148
157
|
readonly cancel_query: {
|
|
149
158
|
readonly register: typeof registerCancelQuery;
|
|
150
159
|
};
|
|
160
|
+
readonly get_chart_as_code: {
|
|
161
|
+
readonly register: typeof registerGetChartAsCode;
|
|
162
|
+
};
|
|
151
163
|
readonly preview_chart_changes: {
|
|
152
164
|
readonly register: typeof registerPreviewChartChanges;
|
|
153
165
|
};
|
|
@@ -217,6 +229,57 @@ export declare const toolRegistry: {
|
|
|
217
229
|
readonly promote_dashboard: {
|
|
218
230
|
readonly register: typeof registerPromoteDashboard;
|
|
219
231
|
};
|
|
232
|
+
readonly list_project_agents: {
|
|
233
|
+
readonly register: typeof registerListProjectAgents;
|
|
234
|
+
};
|
|
235
|
+
readonly get_project_agent: {
|
|
236
|
+
readonly register: typeof registerGetProjectAgent;
|
|
237
|
+
};
|
|
238
|
+
readonly evaluate_agent_readiness: {
|
|
239
|
+
readonly register: typeof registerEvaluateAgentReadiness;
|
|
240
|
+
};
|
|
241
|
+
readonly get_agent_suggestions: {
|
|
242
|
+
readonly register: typeof registerGetAgentSuggestions;
|
|
243
|
+
};
|
|
244
|
+
readonly get_agent_models: {
|
|
245
|
+
readonly register: typeof registerGetAgentModels;
|
|
246
|
+
};
|
|
247
|
+
readonly get_explore_access_summary: {
|
|
248
|
+
readonly register: typeof registerGetExploreAccessSummary;
|
|
249
|
+
};
|
|
250
|
+
readonly list_agent_threads: {
|
|
251
|
+
readonly register: typeof registerListAgentThreads;
|
|
252
|
+
};
|
|
253
|
+
readonly get_agent_thread: {
|
|
254
|
+
readonly register: typeof registerGetAgentThread;
|
|
255
|
+
};
|
|
256
|
+
readonly list_agent_evaluations: {
|
|
257
|
+
readonly register: typeof registerListAgentEvaluations;
|
|
258
|
+
};
|
|
259
|
+
readonly get_agent_evaluation: {
|
|
260
|
+
readonly register: typeof registerGetAgentEvaluation;
|
|
261
|
+
};
|
|
262
|
+
readonly create_agent_evaluation: {
|
|
263
|
+
readonly register: typeof registerCreateAgentEvaluation;
|
|
264
|
+
};
|
|
265
|
+
readonly update_agent_evaluation: {
|
|
266
|
+
readonly register: typeof registerUpdateAgentEvaluation;
|
|
267
|
+
};
|
|
268
|
+
readonly append_agent_evaluation_prompts: {
|
|
269
|
+
readonly register: typeof registerAppendAgentEvaluationPrompts;
|
|
270
|
+
};
|
|
271
|
+
readonly delete_agent_evaluation: {
|
|
272
|
+
readonly register: typeof registerDeleteAgentEvaluation;
|
|
273
|
+
};
|
|
274
|
+
readonly run_agent_evaluation: {
|
|
275
|
+
readonly register: typeof registerRunAgentEvaluation;
|
|
276
|
+
};
|
|
277
|
+
readonly list_agent_evaluation_runs: {
|
|
278
|
+
readonly register: typeof registerListAgentEvaluationRuns;
|
|
279
|
+
};
|
|
280
|
+
readonly get_agent_eval_run_results: {
|
|
281
|
+
readonly register: typeof registerGetAgentEvalRunResults;
|
|
282
|
+
};
|
|
220
283
|
};
|
|
221
284
|
export type ToolId = keyof typeof toolRegistry;
|
|
222
285
|
/** Register a subset of tools by id (persona allowlist). Requires catalog parity (ADR-0013). */
|
package/dist/tools/registry.js
CHANGED
|
@@ -8,6 +8,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.toolRegistry = void 0;
|
|
9
9
|
exports.registerToolsByIds = registerToolsByIds;
|
|
10
10
|
const common_1 = require("@lightdash-tools/common");
|
|
11
|
+
const agents_js_1 = require("./ai-agents/agents.js");
|
|
12
|
+
const discovery_js_1 = require("./ai-agents/discovery.js");
|
|
13
|
+
const evaluations_js_1 = require("./ai-agents/evaluations.js");
|
|
14
|
+
const threads_js_1 = require("./ai-agents/threads.js");
|
|
11
15
|
const explain_content_js_1 = require("./composition/explain-content.js");
|
|
12
16
|
const inventory_js_1 = require("./organization/inventory.js");
|
|
13
17
|
const roles_js_1 = require("./organization/roles.js");
|
|
@@ -15,12 +19,14 @@ const content_js_1 = require("./project/content.js");
|
|
|
15
19
|
const delete_chart_js_1 = require("./project/delete-chart.js");
|
|
16
20
|
const delete_dashboard_js_1 = require("./project/delete-dashboard.js");
|
|
17
21
|
const developer_content_js_1 = require("./project/developer-content.js");
|
|
22
|
+
const developer_get_chart_as_code_js_1 = require("./project/developer-get-chart-as-code.js");
|
|
18
23
|
const get_dashboard_promote_diff_js_1 = require("./project/get-dashboard-promote-diff.js");
|
|
19
24
|
const parameters_js_1 = require("./project/parameters.js");
|
|
20
25
|
const projects_js_1 = require("./project/projects.js");
|
|
21
26
|
const promote_dashboard_js_1 = require("./project/promote-dashboard.js");
|
|
22
27
|
const reader_content_js_1 = require("./project/reader-content.js");
|
|
23
28
|
const reader_execution_js_1 = require("./project/reader-execution.js");
|
|
29
|
+
const reader_export_chart_image_js_1 = require("./project/reader-export-chart-image.js");
|
|
24
30
|
const schedulers_js_1 = require("./project/schedulers.js");
|
|
25
31
|
const spaces_js_1 = require("./project/spaces.js");
|
|
26
32
|
const lifecycle_js_1 = require("./query/lifecycle.js");
|
|
@@ -68,10 +74,12 @@ exports.toolRegistry = {
|
|
|
68
74
|
get_project_parameters: { register: parameters_js_1.registerGetProjectParameters },
|
|
69
75
|
explain_content: { register: explain_content_js_1.registerExplainContent },
|
|
70
76
|
run_chart: { register: reader_execution_js_1.registerRunChart },
|
|
77
|
+
export_chart_image: { register: reader_export_chart_image_js_1.registerExportChartImage },
|
|
71
78
|
run_dashboard_tile: { register: reader_execution_js_1.registerRunDashboardTile },
|
|
72
79
|
get_query_result: { register: lifecycle_js_1.registerGetQueryResult },
|
|
73
80
|
cancel_query: { register: lifecycle_js_1.registerCancelQuery },
|
|
74
81
|
// content-developer (ADR-0014)
|
|
82
|
+
get_chart_as_code: { register: developer_get_chart_as_code_js_1.registerGetChartAsCode },
|
|
75
83
|
preview_chart_changes: { register: developer_content_js_1.registerPreviewChartChanges },
|
|
76
84
|
preview_dashboard_changes: { register: developer_content_js_1.registerPreviewDashboardChanges },
|
|
77
85
|
preview_content_move: { register: developer_content_js_1.registerPreviewContentMove },
|
|
@@ -96,6 +104,24 @@ exports.toolRegistry = {
|
|
|
96
104
|
delete_dashboard: { register: delete_dashboard_js_1.registerDeleteDashboard },
|
|
97
105
|
get_dashboard_promote_diff: { register: get_dashboard_promote_diff_js_1.registerGetDashboardPromoteDiff },
|
|
98
106
|
promote_dashboard: { register: promote_dashboard_js_1.registerPromoteDashboard },
|
|
107
|
+
// ai-agent-ops (ADR-0018)
|
|
108
|
+
list_project_agents: { register: agents_js_1.registerListProjectAgents },
|
|
109
|
+
get_project_agent: { register: agents_js_1.registerGetProjectAgent },
|
|
110
|
+
evaluate_agent_readiness: { register: discovery_js_1.registerEvaluateAgentReadiness },
|
|
111
|
+
get_agent_suggestions: { register: discovery_js_1.registerGetAgentSuggestions },
|
|
112
|
+
get_agent_models: { register: discovery_js_1.registerGetAgentModels },
|
|
113
|
+
get_explore_access_summary: { register: discovery_js_1.registerGetExploreAccessSummary },
|
|
114
|
+
list_agent_threads: { register: threads_js_1.registerListAgentThreads },
|
|
115
|
+
get_agent_thread: { register: threads_js_1.registerGetAgentThread },
|
|
116
|
+
list_agent_evaluations: { register: evaluations_js_1.registerListAgentEvaluations },
|
|
117
|
+
get_agent_evaluation: { register: evaluations_js_1.registerGetAgentEvaluation },
|
|
118
|
+
create_agent_evaluation: { register: evaluations_js_1.registerCreateAgentEvaluation },
|
|
119
|
+
update_agent_evaluation: { register: evaluations_js_1.registerUpdateAgentEvaluation },
|
|
120
|
+
append_agent_evaluation_prompts: { register: evaluations_js_1.registerAppendAgentEvaluationPrompts },
|
|
121
|
+
delete_agent_evaluation: { register: evaluations_js_1.registerDeleteAgentEvaluation },
|
|
122
|
+
run_agent_evaluation: { register: evaluations_js_1.registerRunAgentEvaluation },
|
|
123
|
+
list_agent_evaluation_runs: { register: evaluations_js_1.registerListAgentEvaluationRuns },
|
|
124
|
+
get_agent_eval_run_results: { register: evaluations_js_1.registerGetAgentEvalRunResults },
|
|
99
125
|
};
|
|
100
126
|
const BANNED_MCP_TOOL_IDS = new Set((0, common_1.listBannedMcpToolNames)());
|
|
101
127
|
/** Register a subset of tools by id (persona allowlist). Requires catalog parity (ADR-0013). */
|
package/dist/tools/shared.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Shared types and helpers for MCP tool registration.
|
|
3
3
|
*
|
|
4
4
|
* Guardrail layers applied by registerToolSafe (outer → inner):
|
|
5
|
-
* 1. Audit log wrapper
|
|
6
|
-
* 2.
|
|
7
|
-
* 3. Input validation
|
|
8
|
-
* 4. Raw handler
|
|
5
|
+
* 1. Audit log wrapper — captures timing and outcome for every call.
|
|
6
|
+
* 2. Project scope — pin mismatch + LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS membership.
|
|
7
|
+
* 3. Input validation — rejects invalid resource IDs (control chars, ?, #, %, path traversal).
|
|
8
|
+
* 4. Raw handler — the actual tool implementation.
|
|
9
9
|
*
|
|
10
10
|
* Capability surface is the persona toolIds allowlist (ADR-0006), not process safety mode.
|
|
11
11
|
*/
|
|
@@ -16,11 +16,17 @@ import type { InputRequiredResult, ServerContext } from '@modelcontextprotocol/s
|
|
|
16
16
|
import type { z } from 'zod';
|
|
17
17
|
/** Prefix for all MCP tool names (disambiguation when multiple servers are connected). */
|
|
18
18
|
export declare const TOOL_PREFIX = "lightdash_";
|
|
19
|
+
export type ImageContentBlock = {
|
|
20
|
+
type: 'image';
|
|
21
|
+
data: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
};
|
|
24
|
+
export type ToolContentBlock = ImageContentBlock | {
|
|
25
|
+
type: 'text';
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
19
28
|
export type TextContent = {
|
|
20
|
-
content:
|
|
21
|
-
type: 'text';
|
|
22
|
-
text: string;
|
|
23
|
-
}>;
|
|
29
|
+
content: ToolContentBlock[];
|
|
24
30
|
structuredContent?: Record<string, unknown>;
|
|
25
31
|
isError?: boolean;
|
|
26
32
|
};
|
|
@@ -28,6 +34,17 @@ export type TextContent = {
|
|
|
28
34
|
export type ToolResult = InputRequiredResult | TextContent;
|
|
29
35
|
/** Builds a tool result with JSON text and matching structuredContent. */
|
|
30
36
|
export declare function jsonToolResult(data: unknown): TextContent;
|
|
37
|
+
/** Tool execution error with structured `{ error: { code, message } }` (not policy-blocked). */
|
|
38
|
+
export declare function toolErrorResult(code: string, message: string): TextContent;
|
|
39
|
+
/**
|
|
40
|
+
* MCP ImageContent + metadata text. structuredContent holds meta only (no base64).
|
|
41
|
+
* Spec: https://modelcontextprotocol.io/specification/2025-11-25/server/tools
|
|
42
|
+
*/
|
|
43
|
+
export declare function imageToolResult(args: {
|
|
44
|
+
meta: Record<string, unknown>;
|
|
45
|
+
imageBase64: string;
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
}): TextContent;
|
|
31
48
|
/** Tool handler type used to avoid deep instantiation with SDK/Zod. Accepts (args, extra) for SDK compatibility. */
|
|
32
49
|
export type ToolHandler = (args: unknown, extra?: unknown) => Promise<ToolResult>;
|
|
33
50
|
/** Options for registerTool; inputSchema typed as ZodRawShapeCompat for SDK compatibility. Pass annotations explicitly (e.g. READ_ONLY_DEFAULT or WRITE_IDEMPOTENT) for visibility. */
|
|
@@ -72,6 +89,8 @@ export type ToolExecutionContext = {
|
|
|
72
89
|
/** SDK ServerContext when the transport provides it (second registerTool arg). */
|
|
73
90
|
serverContext: ServerContext | undefined;
|
|
74
91
|
sessionId: string;
|
|
92
|
+
/** Authenticated principal for signed handles (ADR-0019); anonymous when unset. */
|
|
93
|
+
subject: string;
|
|
75
94
|
};
|
|
76
95
|
/** Like wrapTool, but passes ServerContext / session / auth for elicitation-capable tools. */
|
|
77
96
|
export declare function wrapToolContextual<T>(contextProvider: McpContextProvider, fn: (ctx: ToolExecutionContext) => (args: T) => Promise<ToolResult>): ToolHandler;
|