@duckcodeailabs/dql-mcp 1.6.30 → 1.6.32
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/context.d.ts.map +1 -1
- package/dist/context.js +4 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +32 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +184 -90
- package/dist/server.js.map +1 -1
- package/dist/tool-schema.d.ts +5 -0
- package/dist/tool-schema.d.ts.map +1 -0
- package/dist/tool-schema.js +105 -0
- package/dist/tool-schema.js.map +1 -0
- package/dist/tools/certify.d.ts +1 -4
- package/dist/tools/certify.d.ts.map +1 -1
- package/dist/tools/certify.js +2 -4
- package/dist/tools/certify.js.map +1 -1
- package/dist/tools/expand-context.d.ts +62 -0
- package/dist/tools/expand-context.d.ts.map +1 -0
- package/dist/tools/expand-context.js +130 -0
- package/dist/tools/expand-context.js.map +1 -0
- package/dist/tools/get-block.d.ts +1 -5
- package/dist/tools/get-block.d.ts.map +1 -1
- package/dist/tools/get-block.js +2 -8
- package/dist/tools/get-block.js.map +1 -1
- package/dist/tools/governed.d.ts +94 -0
- package/dist/tools/governed.d.ts.map +1 -0
- package/dist/tools/governed.js +139 -0
- package/dist/tools/governed.js.map +1 -0
- package/dist/tools/hints.d.ts +3 -46
- package/dist/tools/hints.d.ts.map +1 -1
- package/dist/tools/hints.js +4 -33
- package/dist/tools/hints.js.map +1 -1
- package/dist/tools/kg.d.ts +5 -22
- package/dist/tools/kg.d.ts.map +1 -1
- package/dist/tools/kg.js +6 -29
- package/dist/tools/kg.js.map +1 -1
- package/dist/tools/lineage-impact.d.ts +4 -9
- package/dist/tools/lineage-impact.d.ts.map +1 -1
- package/dist/tools/lineage-impact.js +91 -36
- package/dist/tools/lineage-impact.js.map +1 -1
- package/dist/tools/list-proposals.d.ts +13 -5
- package/dist/tools/list-proposals.d.ts.map +1 -1
- package/dist/tools/list-proposals.js +152 -16
- package/dist/tools/list-proposals.js.map +1 -1
- package/dist/tools/metadata.d.ts +3 -12
- package/dist/tools/metadata.d.ts.map +1 -1
- package/dist/tools/metadata.js +4 -15
- package/dist/tools/metadata.js.map +1 -1
- package/dist/tools/query-semantic-model.d.ts +374 -0
- package/dist/tools/query-semantic-model.d.ts.map +1 -0
- package/dist/tools/query-semantic-model.js +404 -0
- package/dist/tools/query-semantic-model.js.map +1 -0
- package/dist/tools/query-via-block.d.ts +5 -8
- package/dist/tools/query-via-block.d.ts.map +1 -1
- package/dist/tools/query-via-block.js +9 -14
- package/dist/tools/query-via-block.js.map +1 -1
- package/dist/tools/query-via-metadata.d.ts +198 -130
- package/dist/tools/query-via-metadata.d.ts.map +1 -1
- package/dist/tools/query-via-metadata.js +197 -101
- package/dist/tools/query-via-metadata.js.map +1 -1
- package/dist/tools/search-blocks.d.ts +1 -7
- package/dist/tools/search-blocks.d.ts.map +1 -1
- package/dist/tools/search-blocks.js +2 -10
- package/dist/tools/search-blocks.js.map +1 -1
- package/dist/tools/semantic.d.ts +3 -8
- package/dist/tools/semantic.d.ts.map +1 -1
- package/dist/tools/semantic.js +3 -7
- package/dist/tools/semantic.js.map +1 -1
- package/dist/tools/suggest-block.d.ts +1 -10
- package/dist/tools/suggest-block.d.ts.map +1 -1
- package/dist/tools/suggest-block.js +2 -10
- package/dist/tools/suggest-block.js.map +1 -1
- package/dist/tools/workflows.d.ts +7 -33
- package/dist/tools/workflows.d.ts.map +1 -1
- package/dist/tools/workflows.js +6 -19
- package/dist/tools/workflows.js.map +1 -1
- package/package.json +5 -5
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,uBAAuB,EAGvB,aAAa,EAEb,YAAY,EACZ,KAAK,WAAW,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AC7C,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,gBAAgB,CAAwC;gBAEpD,OAAO,EAAE,iBAAiB;IAOtC,IAAI,QAAQ,IAAI,WAAW,CAG1B;IAED,IAAI,aAAa,IAAI,aAAa,CAGjC;IAED,IAAI,YAAY,IAAI,YAAY,CAG/B;IAED;;;;;;OAMG;IACH,IAAI,eAAe,IAAI,uBAAuB,CAO7C;IAED,OAAO,IAAI,IAAI;CA6BhB;AAgCD,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQxD"}
|
package/dist/context.js
CHANGED
|
@@ -92,7 +92,10 @@ function buildGraphFromManifest(manifest) {
|
|
|
92
92
|
domain: node.domain,
|
|
93
93
|
owner: node.owner,
|
|
94
94
|
status: node.status,
|
|
95
|
-
metadata:
|
|
95
|
+
metadata: {
|
|
96
|
+
...(node.metadata ?? {}),
|
|
97
|
+
...(node.filePath ? { filePath: node.filePath } : {}),
|
|
98
|
+
},
|
|
96
99
|
columns: node.columns,
|
|
97
100
|
});
|
|
98
101
|
}
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,mCAAmC,EACnC,YAAY,GAKb,MAAM,0BAA0B,CAAC;AAalC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACZ,WAAW,CAAS;IACZ,UAAU,CAAS;IACnB,mBAAmB,CAAS;IACrC,SAAS,GAAuB,IAAI,CAAC;IACrC,cAAc,GAAyB,IAAI,CA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D;YACD,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC1C,KAAK,CAAC,OAAO,CAAC;YACZ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAuB;YAClC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;YAAE,OAAO,OAAO,CAAC;QACjE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export { listMetrics, listMetricsInput, listDimensions, listDimensionsInput, } f
|
|
|
14
14
|
export { lineageImpact, lineageImpactInput } from './tools/lineage-impact.js';
|
|
15
15
|
export { certify, certifyInput } from './tools/certify.js';
|
|
16
16
|
export { suggestBlock, suggestBlockInput } from './tools/suggest-block.js';
|
|
17
|
+
export { querySemanticModel, querySemanticModelInput } from './tools/query-semantic-model.js';
|
|
18
|
+
export { expandContext, expandContextInput } from './tools/expand-context.js';
|
|
17
19
|
export { kgSearch, kgSearchInput, feedbackRecord, feedbackRecordInput } from './tools/kg.js';
|
|
20
|
+
export { inspectMetadataContext, inspectMetadataContextInput } from './tools/kg.js';
|
|
21
|
+
export { queryViaMetadata, queryViaMetadataInput } from './tools/query-via-metadata.js';
|
|
18
22
|
export { askDql, askDqlInput, buildDqlApp, buildDqlAppInput, buildDqlBlock, buildDqlBlockInput, inspectDqlProject, inspectDqlProjectInput, } from './tools/workflows.js';
|
|
19
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC7F,O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,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,10 @@ export { listMetrics, listMetricsInput, listDimensions, listDimensionsInput, } f
|
|
|
13
13
|
export { lineageImpact, lineageImpactInput } from './tools/lineage-impact.js';
|
|
14
14
|
export { certify, certifyInput } from './tools/certify.js';
|
|
15
15
|
export { suggestBlock, suggestBlockInput } from './tools/suggest-block.js';
|
|
16
|
+
export { querySemanticModel, querySemanticModelInput } from './tools/query-semantic-model.js';
|
|
17
|
+
export { expandContext, expandContextInput } from './tools/expand-context.js';
|
|
16
18
|
export { kgSearch, kgSearchInput, feedbackRecord, feedbackRecordInput } from './tools/kg.js';
|
|
19
|
+
export { inspectMetadataContext, inspectMetadataContextInput } from './tools/kg.js';
|
|
20
|
+
export { queryViaMetadata, queryViaMetadataInput } from './tools/query-via-metadata.js';
|
|
17
21
|
export { askDql, askDqlInput, buildDqlApp, buildDqlAppInput, buildDqlBlock, buildDqlBlockInput, inspectDqlProject, inspectDqlProjectInput, } from './tools/workflows.js';
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,O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AgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type DqlToolName } from '@duckcodeailabs/dql-agent';
|
|
4
|
+
import { DQLContext } from './context.js';
|
|
5
|
+
import { zodRawShapeFromJsonSchema } from './tool-schema.js';
|
|
2
6
|
export interface CreateServerOptions {
|
|
3
7
|
projectRoot?: string;
|
|
4
8
|
version?: string;
|
|
9
|
+
/**
|
|
10
|
+
* `agentic` is the default bounded surface for LLM clients. `full` exposes
|
|
11
|
+
* the historical expert/admin MCP surface for explicit maintenance sessions.
|
|
12
|
+
*/
|
|
13
|
+
toolProfile?: McpToolProfile;
|
|
14
|
+
}
|
|
15
|
+
export type McpToolProfile = 'agentic' | 'full';
|
|
16
|
+
interface McpToolRegistration {
|
|
17
|
+
name: DqlToolName;
|
|
18
|
+
inputSchema: Record<string, z.ZodTypeAny>;
|
|
19
|
+
run(args: any): unknown | Promise<unknown>;
|
|
5
20
|
}
|
|
6
21
|
export declare const DQL_MCP_INSTRUCTIONS: string;
|
|
22
|
+
export declare function dqlMcpInstructionsForProfile(profile: McpToolProfile): string;
|
|
7
23
|
export declare function createDQLMCPServer(options?: CreateServerOptions): McpServer;
|
|
24
|
+
declare function buildMcpToolRegistrations(ctx: DQLContext, profile?: McpToolProfile): McpToolRegistration[];
|
|
25
|
+
declare function resolveMcpToolProfile(explicit?: McpToolProfile): McpToolProfile;
|
|
26
|
+
declare function wrap(result: unknown): {
|
|
27
|
+
content: {
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
export declare const __test__: {
|
|
33
|
+
buildMcpToolRegistrations: typeof buildMcpToolRegistrations;
|
|
34
|
+
dqlMcpInstructionsForProfile: typeof dqlMcpInstructionsForProfile;
|
|
35
|
+
resolveMcpToolProfile: typeof resolveMcpToolProfile;
|
|
36
|
+
wrap: typeof wrap;
|
|
37
|
+
zodRawShapeFromJsonSchema: typeof zodRawShapeFromJsonSchema;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
8
40
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAmC7D,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAC1C,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5C;AAiED,eAAO,MAAM,oBAAoB,QAA+B,CAAC;AAEjE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAI5E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,SAAS,CAsB/E;AAED,iBAAS,yBAAyB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,cAA0B,GAAG,mBAAmB,EAAE,CAY9G;AAED,iBAAS,qBAAqB,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,cAAc,CAIxE;AA4FD,iBAAS,IAAI,CAAC,MAAM,EAAE,OAAO;;;;;EAO5B;AAED,eAAO,MAAM,QAAQ;;;;;;CAMpB,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { dqlToolDefinitionsForSurface, getDqlToolDefinition, } from '@duckcodeailabs/dql-agent';
|
|
2
3
|
import { DQLContext, findProjectRoot } from './context.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
4
|
+
import { zodRawShapeFromJsonSchema } from './tool-schema.js';
|
|
5
|
+
import { searchBlocks } from './tools/search-blocks.js';
|
|
6
|
+
import { getBlock } from './tools/get-block.js';
|
|
7
|
+
import { queryViaBlock } from './tools/query-via-block.js';
|
|
8
|
+
import { listMetrics, listDimensions } from './tools/semantic.js';
|
|
9
|
+
import { lineageImpact } from './tools/lineage-impact.js';
|
|
10
|
+
import { certify } from './tools/certify.js';
|
|
11
|
+
import { suggestBlock } from './tools/suggest-block.js';
|
|
12
|
+
import { expandContext } from './tools/expand-context.js';
|
|
13
|
+
import { querySemanticModel } from './tools/query-semantic-model.js';
|
|
14
|
+
import { queryViaMetadata } from './tools/query-via-metadata.js';
|
|
15
|
+
import { answerQuestion, buildBlockFromPrompt } from './tools/governed.js';
|
|
16
|
+
import { listProposals } from './tools/list-proposals.js';
|
|
17
|
+
import { feedbackRecord, inspectMetadataContext, kgSearch, } from './tools/kg.js';
|
|
18
|
+
import { askDql, buildDqlApp, buildDqlBlock, inspectDqlProject, } from './tools/workflows.js';
|
|
19
|
+
import { approveHint, listHints, recordCorrection, } from './tools/hints.js';
|
|
20
|
+
import { getTableSchema, searchMetadata, validateSql, } from './tools/metadata.js';
|
|
21
|
+
const DQL_MCP_AGENTIC_INSTRUCTIONS = 'DQL is a governed analytics MCP server. Start each session with ' +
|
|
17
22
|
'`inspect_dql_project`; route every analytics question through `ask_dql` ' +
|
|
18
23
|
'before writing SQL. It returns the safe route, trust label, certified ' +
|
|
19
24
|
'candidate when available, allowed SQL context, and next tool.\n' +
|
|
25
|
+
'Two ways to answer: `answer_question` runs DQL\'s FULL governed cascade and ' +
|
|
26
|
+
'returns the executed answer + rows + canonical trust label + a reviewable ' +
|
|
27
|
+
'draft — use it when you want DQL to generate for you (same engine + trust ' +
|
|
28
|
+
'guards as the DQL UI). The BYOSQL path (`ask_dql` → inspect → ' +
|
|
29
|
+
'`query_via_metadata` with your own SELECT) is for when you want to author the ' +
|
|
30
|
+
'SQL yourself. To create a reusable block from a description, use ' +
|
|
31
|
+
'`build_block_from_prompt` (governed, no SQL authoring); it returns a ' +
|
|
32
|
+
'review-required draft + Certifier verdict and never auto-certifies.\n' +
|
|
33
|
+
'Semantic compile: when the semantic layer contains the requested metric, ' +
|
|
34
|
+
'dimension, or time grain, use `query_semantic_model` before deep dbt or ' +
|
|
35
|
+
'warehouse search. Return the DQL semantic artifact, draft path when present, and generated SQL as ' +
|
|
36
|
+
'reviewable context unless it is backed by a certified block.\n' +
|
|
20
37
|
'Tier 1 certified: for an exact saved block or direct KPI, use ' +
|
|
21
38
|
'`search_blocks`/`get_block` for discovery and `query_via_block` only when ' +
|
|
22
39
|
'a certified block grain exactly answers the question.\n' +
|
|
@@ -24,7 +41,18 @@ export const DQL_MCP_INSTRUCTIONS = 'DQL is a governed analytics MCP server. Sta
|
|
|
24
41
|
'rankings, breakdowns, comparisons, drill-throughs, or different grain, use ' +
|
|
25
42
|
'certified assets only as context. Call `inspect_metadata_context`, then `query_via_metadata` with ' +
|
|
26
43
|
'one read-only SELECT/WITH query from the inspected context. Surface ' +
|
|
27
|
-
'`uncertified: true`, the trust status,
|
|
44
|
+
'`uncertified: true`, the trust status, the returned `dqlArtifact.source`, ' +
|
|
45
|
+
'and draft path verbatim; treat SQL as compiled/preview evidence, not the default artifact.\n' +
|
|
46
|
+
'Follow-ups: when the user refers to prior/previous results, pass `followUp.priorResultRef` ' +
|
|
47
|
+
'(id, question, columns, rowCount, sourceSql if known) and `followUp.priorDqlArtifact` ' +
|
|
48
|
+
'(the previous `dqlArtifact.source` plus metrics/dimensions/filters) into `query_via_metadata`; ' +
|
|
49
|
+
'do not answer a drilldown from vague follow-up prose alone.\n' +
|
|
50
|
+
'Deep research: call `inspect_metadata_context` with `strictness: "exploratory"` ' +
|
|
51
|
+
'before writing SQL when the user asks for broad investigation, many entities, or full context.\n' +
|
|
52
|
+
'Repair loop: if `query_via_metadata` reports an unknown relation that exists ' +
|
|
53
|
+
'in the metadata catalog/runtime schema, call `expand_context` with the prior ' +
|
|
54
|
+
'contextPackId and relation, then retry `query_via_metadata` once with the new contextPackId ' +
|
|
55
|
+
'and `regroundAttemptsUsed: 1`.\n' +
|
|
28
56
|
'Tier 3 missing context: if metadata does not identify a safe table, metric, ' +
|
|
29
57
|
'dimension, or grain, refuse and ask for what is missing.\n' +
|
|
30
58
|
'Trust labels are one canonical vocabulary: Certified, Reviewed, ' +
|
|
@@ -35,94 +63,160 @@ export const DQL_MCP_INSTRUCTIONS = 'DQL is a governed analytics MCP server. Sta
|
|
|
35
63
|
'but disagree, `ask_dql` returns route `conflict` with BOTH definitions and ' +
|
|
36
64
|
'owners. Present both sides and ask the user which is authoritative — never ' +
|
|
37
65
|
'silently pick one.\n' +
|
|
38
|
-
'Use `
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
|
|
42
|
-
'
|
|
66
|
+
'Use `suggest_block` for reusable draft blocks, `certify` for governance, ' +
|
|
67
|
+
'`lineage_impact` for dependencies, and `kg_search` for the knowledge graph. ' +
|
|
68
|
+
'Never present generated SQL or draft output as certified.';
|
|
69
|
+
const DQL_MCP_FULL_PROFILE_INSTRUCTIONS = '\nFull expert profile only: `build_dql_block`, `build_dql_app`, ' +
|
|
70
|
+
'`list_proposals`, `feedback_record`, `record_correction`, `approve_hint`, ' +
|
|
71
|
+
'`list_hints`, `search_metadata`, `get_table_schema`, `validate_sql`, ' +
|
|
72
|
+
'`list_metrics`, and `list_dimensions` are available for maintenance, legacy, ' +
|
|
73
|
+
'and governance-admin workflows. Prefer the bounded governed cascade tools for normal analytics questions.\n' +
|
|
43
74
|
'Correction memory: when an analyst corrects a Tier-2 answer, call ' +
|
|
44
75
|
'`record_correction` with the scope (metric/dbt model/domain/dialect). It ' +
|
|
45
76
|
'creates a scoped CANDIDATE hint that is NOT used until a human runs ' +
|
|
46
77
|
'`approve_hint`. Approved hints are folded into matching future Tier-2 drafts ' +
|
|
47
78
|
'AFTER certified routing (never overriding certified answers) and are cited. ' +
|
|
48
79
|
'Use `list_hints` to review pending corrections.';
|
|
80
|
+
export const DQL_MCP_INSTRUCTIONS = DQL_MCP_AGENTIC_INSTRUCTIONS;
|
|
81
|
+
export function dqlMcpInstructionsForProfile(profile) {
|
|
82
|
+
return profile === 'full'
|
|
83
|
+
? `${DQL_MCP_AGENTIC_INSTRUCTIONS}${DQL_MCP_FULL_PROFILE_INSTRUCTIONS}`
|
|
84
|
+
: DQL_MCP_AGENTIC_INSTRUCTIONS;
|
|
85
|
+
}
|
|
49
86
|
export function createDQLMCPServer(options = {}) {
|
|
50
87
|
const projectRoot = options.projectRoot ?? findProjectRoot(process.cwd());
|
|
51
88
|
const ctx = new DQLContext({ projectRoot, dqlVersion: options.version });
|
|
52
|
-
const
|
|
53
|
-
server
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, async (args) => wrap(await askDql(ctx, args)));
|
|
61
|
-
server.registerTool('build_dql_block', {
|
|
62
|
-
description: 'High-level draft-block tool. Writes a proposed block to the local draft queue (domains/<domain>/blocks/_drafts/ when available, otherwise blocks/_drafts/) with governance results. Does not certify automatically.',
|
|
63
|
-
inputSchema: buildDqlBlockInput,
|
|
64
|
-
}, async (args) => wrap(await buildDqlBlock(ctx, args)));
|
|
65
|
-
server.registerTool('build_dql_app', {
|
|
66
|
-
description: 'High-level app builder. Creates or plans a governed DQL app draft from a prompt using certified tiles first and review-only placeholders for missing evidence.',
|
|
67
|
-
inputSchema: buildDqlAppInput,
|
|
68
|
-
}, async (args) => wrap(await buildDqlApp(ctx, args)));
|
|
69
|
-
server.registerTool('search_blocks', { description: 'Find certified DQL blocks by keyword, domain, or status.', inputSchema: searchBlocksInput }, async (args) => wrap(await searchBlocks(ctx, args)));
|
|
70
|
-
server.registerTool('get_block', { description: 'Return full metadata, dependencies, and SQL for a block.', inputSchema: getBlockInput }, async (args) => wrap(await getBlock(ctx, args)));
|
|
71
|
-
server.registerTool('query_via_block', {
|
|
72
|
-
description: 'Tier-1 of graduated trust. Execute a certified block against the local DQL runtime when the block grain exactly answers the user question. Refuses non-certified blocks and refuses unresolved datalex_contract references when a DataLex manifest is loaded. For named-entity filters, custom rankings, breakdowns, comparisons, or drill-throughs, use the block as context and call query_via_metadata instead.',
|
|
73
|
-
inputSchema: queryViaBlockInput,
|
|
74
|
-
}, async (args) => wrap(await queryViaBlock(ctx, args)));
|
|
75
|
-
server.registerTool('query_via_metadata', {
|
|
76
|
-
description: 'Tier-2 of graduated trust. Use when no certified block exactly answers the requested grain, including why-changed diagnostics, named customer/user/account filters, rankings, breakdowns, comparisons, anomalies, and drill-throughs. Call inspect_metadata_context first; pass its contextPackId when available. If proposedSql is omitted, this returns the catalog route plan, allowed SQL context, and missing context. When the question spans entities, the response also includes `datalexJoinGuidance` from the DataLex model: the canonical key to join each business concept on, and which joins fan out — follow it so generated SQL stays grain-safe (don\'t double-count). If proposedSql is supplied, it must be one read-only SELECT/WITH query using only inspected relations/columns. The runtime executes a bounded preview, returns `uncertified: true` plus trustStatus/evidence, and saves a draft block under the local draft queue. Surface the `uncertified` flag and review path verbatim.',
|
|
77
|
-
inputSchema: queryViaMetadataInput,
|
|
78
|
-
}, async (args) => wrap(await queryViaMetadata(ctx, args)));
|
|
79
|
-
server.registerTool('list_proposals', {
|
|
80
|
-
description: 'List Tier-2 draft proposals from blocks/_drafts/ and domains/<domain>/blocks/_drafts/ ordered by askedTimes DESC. Filter with askedAtLeastTimes / since. Use this to surface "questions that get asked repeatedly are good certify candidates" — the prioritization signal for the human review queue.',
|
|
81
|
-
inputSchema: listProposalsInput,
|
|
82
|
-
}, async (args) => wrap(listProposals(ctx, args)));
|
|
83
|
-
server.registerTool('list_metrics', { description: 'List semantic-layer metrics, optionally filtered by domain.', inputSchema: listMetricsInput }, async (args) => wrap(await listMetrics(ctx, args)));
|
|
84
|
-
server.registerTool('list_dimensions', { description: 'List semantic-layer dimensions, optionally filtered by domain.', inputSchema: listDimensionsInput }, async (args) => wrap(await listDimensions(ctx, args)));
|
|
85
|
-
server.registerTool('lineage_impact', { description: 'Return upstream/downstream lineage for a block, metric, or model.', inputSchema: lineageImpactInput }, async (args) => wrap(await lineageImpact(ctx, args)));
|
|
86
|
-
server.registerTool('certify', { description: 'Run governance rules against a block and report pass/fail.', inputSchema: certifyInput }, async (args) => wrap(await certify(ctx, args)));
|
|
87
|
-
server.registerTool('suggest_block', {
|
|
88
|
-
description: 'Write a curated proposed block to the local draft queue with a hand-shaped name + structure, plus the governance gate result. Use when proposing a SHARED building block on top of multiple Tier-2 proposals. For one-shot ad-hoc Tier-2 captures, use `query_via_metadata` instead — it auto-saves the draft.',
|
|
89
|
-
inputSchema: suggestBlockInput,
|
|
90
|
-
}, async (args) => wrap(await suggestBlock(ctx, args)));
|
|
91
|
-
server.registerTool('kg_search', { description: 'Search the agent knowledge graph (FTS5) over terms, business views, blocks, metrics, dimensions, dashboards, apps, notebooks, and dbt/source metadata.', inputSchema: kgSearchInput }, async (args) => wrap(await kgSearch(ctx, args)));
|
|
92
|
-
server.registerTool('search_metadata', {
|
|
93
|
-
description: 'Grounded-SQL retrieval: rank dbt tables relevant to a request and return each table\'s fully-qualified warehouse relation (database.schema.table) and {{ ref() }} form. Use before writing SQL so you reference the REAL relation, never a bare model name.',
|
|
94
|
-
inputSchema: searchMetadataInput,
|
|
95
|
-
}, async (args) => wrap(await searchMetadata(ctx, args)));
|
|
96
|
-
server.registerTool('get_table_schema', {
|
|
97
|
-
description: 'Return the qualified relation, {{ ref() }} form, real columns + types, and inferred join keys for a dbt table (by model name, alias, or qualified relation).',
|
|
98
|
-
inputSchema: getTableSchemaInput,
|
|
99
|
-
}, async (args) => wrap(getTableSchema(ctx, args)));
|
|
100
|
-
server.registerTool('validate_sql', {
|
|
101
|
-
description: 'Validate that a read-only SELECT/WITH query references ONLY relations and columns that exist in the dbt schema. Returns the precise offending table/column on a miss so you can correct it.',
|
|
102
|
-
inputSchema: validateSqlInput,
|
|
103
|
-
}, async (args) => wrap(await validateSql(ctx, args)));
|
|
104
|
-
server.registerTool('inspect_metadata_context', {
|
|
105
|
-
description: 'Build the local SQLite metadata context pack for a question. Use before Tier-2 SQL generation to inspect certified blocks, semantic metrics, DQL terms/views, dbt/warehouse objects, lineage edges, diagnostics, selected evidence, rejected candidates, and trust labels.',
|
|
106
|
-
inputSchema: inspectMetadataContextInput,
|
|
107
|
-
}, async (args) => wrap(await inspectMetadataContext(ctx, args)));
|
|
108
|
-
server.registerTool('feedback_record', { description: 'Record thumbs-up/down feedback on an answer; feeds self-learning + promotion suggestions.', inputSchema: feedbackRecordInput }, async (args) => wrap(feedbackRecord(ctx, args)));
|
|
109
|
-
server.registerTool('record_correction', {
|
|
110
|
-
description: 'Capture an analyst correction of a Tier-2 generated answer as a scoped, Git-versioned CANDIDATE hint (not used until approved). Writes a trace + hint under .dql/ and reindexes the local cache.',
|
|
111
|
-
inputSchema: recordCorrectionInput,
|
|
112
|
-
}, async (args) => wrap(recordCorrection(ctx, args)));
|
|
113
|
-
server.registerTool('approve_hint', {
|
|
114
|
-
description: 'Human review of a candidate correction hint. Approving makes the scoped hint usable in future Tier-2 drafts (after certified routing, never overriding it). Updates .dql/ and the local index.',
|
|
115
|
-
inputSchema: approveHintInput,
|
|
116
|
-
}, async (args) => wrap(approveHint(ctx, args)));
|
|
117
|
-
server.registerTool('list_hints', {
|
|
118
|
-
description: 'List scoped correction hints (optionally filtered by status/domain/metric) for review. Approved hints are the ones folded into future answers.',
|
|
119
|
-
inputSchema: listHintsInput,
|
|
120
|
-
}, async (args) => wrap(listHints(ctx, args)));
|
|
89
|
+
const toolProfile = resolveMcpToolProfile(options.toolProfile);
|
|
90
|
+
const server = new McpServer({ name: 'dql-mcp', version: options.version ?? '0.1.0' }, { instructions: dqlMcpInstructionsForProfile(toolProfile) });
|
|
91
|
+
for (const tool of buildMcpToolRegistrations(ctx, toolProfile)) {
|
|
92
|
+
server.registerTool(tool.name, {
|
|
93
|
+
description: toolDescription(tool.name),
|
|
94
|
+
inputSchema: tool.inputSchema,
|
|
95
|
+
}, async (args) => wrap(await tool.run(args)));
|
|
96
|
+
}
|
|
121
97
|
return server;
|
|
122
98
|
}
|
|
99
|
+
function buildMcpToolRegistrations(ctx, profile = 'agentic') {
|
|
100
|
+
const handlers = mcpToolHandlers(ctx);
|
|
101
|
+
const surface = profile === 'full' ? 'mcp' : 'mcp_agentic';
|
|
102
|
+
return dqlToolDefinitionsForSurface(surface).map((definition) => {
|
|
103
|
+
const handler = handlers[definition.name];
|
|
104
|
+
if (!handler)
|
|
105
|
+
throw new Error(`MCP DQL tool handler is missing for ${definition.name}`);
|
|
106
|
+
return {
|
|
107
|
+
name: definition.name,
|
|
108
|
+
inputSchema: zodRawShapeFromJsonSchema(definition.inputSchema),
|
|
109
|
+
run: handler.run,
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function resolveMcpToolProfile(explicit) {
|
|
114
|
+
if (explicit)
|
|
115
|
+
return explicit;
|
|
116
|
+
const raw = process.env.DQL_MCP_TOOL_PROFILE?.trim().toLowerCase();
|
|
117
|
+
return raw === 'full' || raw === 'expert' || raw === 'admin' ? 'full' : 'agentic';
|
|
118
|
+
}
|
|
119
|
+
function mcpToolHandlers(ctx) {
|
|
120
|
+
return {
|
|
121
|
+
ask_dql: {
|
|
122
|
+
run: (args) => askDql(ctx, args),
|
|
123
|
+
},
|
|
124
|
+
query_semantic_model: {
|
|
125
|
+
run: (args) => querySemanticModel(ctx, args),
|
|
126
|
+
},
|
|
127
|
+
kg_search: {
|
|
128
|
+
run: (args) => kgSearch(ctx, args),
|
|
129
|
+
},
|
|
130
|
+
search_blocks: {
|
|
131
|
+
run: (args) => searchBlocks(ctx, args),
|
|
132
|
+
},
|
|
133
|
+
get_block: {
|
|
134
|
+
run: (args) => getBlock(ctx, args),
|
|
135
|
+
},
|
|
136
|
+
query_via_block: {
|
|
137
|
+
run: (args) => queryViaBlock(ctx, args),
|
|
138
|
+
},
|
|
139
|
+
inspect_metadata_context: {
|
|
140
|
+
run: (args) => inspectMetadataContext(ctx, args),
|
|
141
|
+
},
|
|
142
|
+
expand_context: {
|
|
143
|
+
run: (args) => expandContext(ctx, args),
|
|
144
|
+
},
|
|
145
|
+
query_via_metadata: {
|
|
146
|
+
run: (args) => queryViaMetadata(ctx, args),
|
|
147
|
+
},
|
|
148
|
+
answer_question: {
|
|
149
|
+
run: (args) => answerQuestion(ctx, args),
|
|
150
|
+
},
|
|
151
|
+
build_block_from_prompt: {
|
|
152
|
+
run: (args) => buildBlockFromPrompt(ctx, args),
|
|
153
|
+
},
|
|
154
|
+
list_metrics: {
|
|
155
|
+
run: (args) => listMetrics(ctx, args),
|
|
156
|
+
},
|
|
157
|
+
list_dimensions: {
|
|
158
|
+
run: (args) => listDimensions(ctx, args),
|
|
159
|
+
},
|
|
160
|
+
lineage_impact: {
|
|
161
|
+
run: (args) => lineageImpact(ctx, args),
|
|
162
|
+
},
|
|
163
|
+
certify: {
|
|
164
|
+
run: (args) => certify(ctx, args),
|
|
165
|
+
},
|
|
166
|
+
suggest_block: {
|
|
167
|
+
run: (args) => suggestBlock(ctx, args),
|
|
168
|
+
},
|
|
169
|
+
search_metadata: {
|
|
170
|
+
run: (args) => searchMetadata(ctx, args),
|
|
171
|
+
},
|
|
172
|
+
get_table_schema: {
|
|
173
|
+
run: (args) => getTableSchema(ctx, args),
|
|
174
|
+
},
|
|
175
|
+
validate_sql: {
|
|
176
|
+
run: (args) => validateSql(ctx, args),
|
|
177
|
+
},
|
|
178
|
+
inspect_dql_project: {
|
|
179
|
+
run: (args) => inspectDqlProject(ctx, args),
|
|
180
|
+
},
|
|
181
|
+
build_dql_block: {
|
|
182
|
+
run: (args) => buildDqlBlock(ctx, args),
|
|
183
|
+
},
|
|
184
|
+
build_dql_app: {
|
|
185
|
+
run: (args) => buildDqlApp(ctx, args),
|
|
186
|
+
},
|
|
187
|
+
list_proposals: {
|
|
188
|
+
run: (args) => listProposals(ctx, args),
|
|
189
|
+
},
|
|
190
|
+
feedback_record: {
|
|
191
|
+
run: (args) => feedbackRecord(ctx, args),
|
|
192
|
+
},
|
|
193
|
+
record_correction: {
|
|
194
|
+
run: (args) => recordCorrection(ctx, args),
|
|
195
|
+
},
|
|
196
|
+
approve_hint: {
|
|
197
|
+
run: (args) => approveHint(ctx, args),
|
|
198
|
+
},
|
|
199
|
+
list_hints: {
|
|
200
|
+
run: (args) => listHints(ctx, args),
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function toolDescription(name) {
|
|
205
|
+
return getDqlToolDefinition(name).description;
|
|
206
|
+
}
|
|
123
207
|
function wrap(result) {
|
|
208
|
+
const text = process.env.DQL_MCP_PRETTY_JSON === '1'
|
|
209
|
+
? JSON.stringify(result, null, 2)
|
|
210
|
+
: JSON.stringify(result);
|
|
124
211
|
return {
|
|
125
|
-
content: [{ type: 'text', text
|
|
212
|
+
content: [{ type: 'text', text }],
|
|
126
213
|
};
|
|
127
214
|
}
|
|
215
|
+
export const __test__ = {
|
|
216
|
+
buildMcpToolRegistrations,
|
|
217
|
+
dqlMcpInstructionsForProfile,
|
|
218
|
+
resolveMcpToolProfile,
|
|
219
|
+
wrap,
|
|
220
|
+
zodRawShapeFromJsonSchema,
|
|
221
|
+
};
|
|
128
222
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
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ChD,CAAC;AAED,SAAS,IAAI,CAAC,MAAe;IAC3B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,GAAG;QAClD,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,yBAAyB;IACzB,4BAA4B;IAC5B,qBAAqB;IACrB,IAAI;IACJ,yBAAyB;CAC1B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type DqlToolName, type JsonSchema } from '@duckcodeailabs/dql-agent';
|
|
3
|
+
export declare function zodInputShapeForTool(name: DqlToolName): Record<string, z.ZodTypeAny>;
|
|
4
|
+
export declare function zodRawShapeFromJsonSchema(schema: JsonSchema): Record<string, z.ZodTypeAny>;
|
|
5
|
+
//# sourceMappingURL=tool-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-schema.d.ts","sourceRoot":"","sources":["../src/tool-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAwB,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEpG,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAEpF;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAS1F"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getDqlToolDefinition } from '@duckcodeailabs/dql-agent';
|
|
3
|
+
export function zodInputShapeForTool(name) {
|
|
4
|
+
return zodRawShapeFromJsonSchema(getDqlToolDefinition(name).inputSchema);
|
|
5
|
+
}
|
|
6
|
+
export function zodRawShapeFromJsonSchema(schema) {
|
|
7
|
+
const properties = jsonObject(schema.properties);
|
|
8
|
+
const required = new Set(jsonStringList(schema.required));
|
|
9
|
+
const shape = {};
|
|
10
|
+
for (const [key, propertySchema] of Object.entries(properties)) {
|
|
11
|
+
const field = zodTypeFromJsonSchema(propertySchema);
|
|
12
|
+
shape[key] = required.has(key) ? field : field.optional();
|
|
13
|
+
}
|
|
14
|
+
return shape;
|
|
15
|
+
}
|
|
16
|
+
function zodTypeFromJsonSchema(schema) {
|
|
17
|
+
const record = jsonObject(schema);
|
|
18
|
+
const enumValues = jsonStringList(record.enum);
|
|
19
|
+
let type;
|
|
20
|
+
if (enumValues.length > 0) {
|
|
21
|
+
type = z.enum(enumValues);
|
|
22
|
+
}
|
|
23
|
+
else if (record.type === 'string') {
|
|
24
|
+
type = applyStringBounds(z.string(), record);
|
|
25
|
+
}
|
|
26
|
+
else if (record.type === 'number' || record.type === 'integer') {
|
|
27
|
+
type = applyNumberBounds(record.type === 'integer' ? z.number().int() : z.number(), record);
|
|
28
|
+
}
|
|
29
|
+
else if (record.type === 'boolean') {
|
|
30
|
+
type = z.boolean();
|
|
31
|
+
}
|
|
32
|
+
else if (record.type === 'array') {
|
|
33
|
+
type = applyArrayBounds(z.array(zodTypeFromJsonSchema(record.items)), record);
|
|
34
|
+
}
|
|
35
|
+
else if (record.type === 'object') {
|
|
36
|
+
const properties = jsonObject(record.properties);
|
|
37
|
+
if (Object.keys(properties).length > 0) {
|
|
38
|
+
const required = new Set(jsonStringList(record.required));
|
|
39
|
+
const shape = {};
|
|
40
|
+
for (const [key, propertySchema] of Object.entries(properties)) {
|
|
41
|
+
const field = zodTypeFromJsonSchema(propertySchema);
|
|
42
|
+
shape[key] = required.has(key) ? field : field.optional();
|
|
43
|
+
}
|
|
44
|
+
type = record.additionalProperties === false ? z.object(shape).strict() : z.object(shape);
|
|
45
|
+
}
|
|
46
|
+
else if (record.additionalProperties && typeof record.additionalProperties === 'object') {
|
|
47
|
+
type = z.record(zodTypeFromJsonSchema(record.additionalProperties));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
type = z.record(z.unknown());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
type = z.unknown();
|
|
55
|
+
}
|
|
56
|
+
const description = typeof record.description === 'string' ? record.description.trim() : '';
|
|
57
|
+
return description ? type.describe(description) : type;
|
|
58
|
+
}
|
|
59
|
+
function applyArrayBounds(type, record) {
|
|
60
|
+
const minItems = finiteInteger(record.minItems);
|
|
61
|
+
const maxItems = finiteInteger(record.maxItems);
|
|
62
|
+
let bounded = type;
|
|
63
|
+
if (minItems !== undefined)
|
|
64
|
+
bounded = bounded.min(minItems);
|
|
65
|
+
if (maxItems !== undefined)
|
|
66
|
+
bounded = bounded.max(maxItems);
|
|
67
|
+
return bounded;
|
|
68
|
+
}
|
|
69
|
+
function applyNumberBounds(type, record) {
|
|
70
|
+
const minimum = finiteNumber(record.minimum);
|
|
71
|
+
const maximum = finiteNumber(record.maximum);
|
|
72
|
+
let bounded = type;
|
|
73
|
+
if (minimum !== undefined)
|
|
74
|
+
bounded = bounded.min(minimum);
|
|
75
|
+
if (maximum !== undefined)
|
|
76
|
+
bounded = bounded.max(maximum);
|
|
77
|
+
return bounded;
|
|
78
|
+
}
|
|
79
|
+
function applyStringBounds(type, record) {
|
|
80
|
+
const minLength = finiteInteger(record.minLength);
|
|
81
|
+
const maxLength = finiteInteger(record.maxLength);
|
|
82
|
+
let bounded = type;
|
|
83
|
+
if (minLength !== undefined)
|
|
84
|
+
bounded = bounded.min(minLength);
|
|
85
|
+
if (maxLength !== undefined)
|
|
86
|
+
bounded = bounded.max(maxLength);
|
|
87
|
+
return bounded;
|
|
88
|
+
}
|
|
89
|
+
function jsonObject(value) {
|
|
90
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
91
|
+
? value
|
|
92
|
+
: {};
|
|
93
|
+
}
|
|
94
|
+
function jsonStringList(value) {
|
|
95
|
+
return Array.isArray(value)
|
|
96
|
+
? value.filter((item) => typeof item === 'string' && item.length > 0)
|
|
97
|
+
: [];
|
|
98
|
+
}
|
|
99
|
+
function finiteNumber(value) {
|
|
100
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
101
|
+
}
|
|
102
|
+
function finiteInteger(value) {
|
|
103
|
+
return typeof value === 'number' && Number.isInteger(value) ? value : undefined;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=tool-schema.js.map
|