@duckcodeailabs/dql-mcp 1.6.21 → 1.6.22
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/server.d.ts.map +1 -1
- package/dist/server.js +42 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/hints.d.ts +150 -0
- package/dist/tools/hints.d.ts.map +1 -0
- package/dist/tools/hints.js +128 -0
- package/dist/tools/hints.js.map +1 -0
- package/dist/tools/lineage-impact.d.ts +4 -0
- package/dist/tools/lineage-impact.d.ts.map +1 -1
- package/dist/tools/lineage-impact.js +36 -1
- package/dist/tools/lineage-impact.js.map +1 -1
- package/dist/tools/metadata.d.ts +109 -0
- package/dist/tools/metadata.d.ts.map +1 -0
- package/dist/tools/metadata.js +122 -0
- package/dist/tools/metadata.js.map +1 -0
- package/dist/tools/query-via-block.d.ts +23 -8
- package/dist/tools/query-via-block.d.ts.map +1 -1
- package/dist/tools/query-via-block.js +76 -0
- package/dist/tools/query-via-block.js.map +1 -1
- package/dist/tools/query-via-metadata.d.ts +54 -0
- package/dist/tools/query-via-metadata.d.ts.map +1 -1
- package/dist/tools/query-via-metadata.js +112 -0
- package/dist/tools/query-via-metadata.js.map +1 -1
- package/dist/tools/workflows.d.ts +8 -1
- package/dist/tools/workflows.d.ts.map +1 -1
- package/dist/tools/workflows.js +19 -1
- package/dist/tools/workflows.js.map +1 -1
- package/package.json +5 -5
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;AA8CpE,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,QAiCkB,CAAC;AAEpD,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,SAAS,CA0L/E"}
|
package/dist/server.js
CHANGED
|
@@ -11,6 +11,8 @@ import { queryViaMetadata, queryViaMetadataInput } from './tools/query-via-metad
|
|
|
11
11
|
import { listProposals, listProposalsInput } from './tools/list-proposals.js';
|
|
12
12
|
import { feedbackRecord, feedbackRecordInput, inspectMetadataContext, inspectMetadataContextInput, kgSearch, kgSearchInput, } from './tools/kg.js';
|
|
13
13
|
import { askDql, askDqlInput, buildDqlApp, buildDqlAppInput, buildDqlBlock, buildDqlBlockInput, inspectDqlProject, inspectDqlProjectInput, } from './tools/workflows.js';
|
|
14
|
+
import { approveHint, approveHintInput, listHints, listHintsInput, recordCorrection, recordCorrectionInput, } from './tools/hints.js';
|
|
15
|
+
import { getTableSchema, getTableSchemaInput, searchMetadata, searchMetadataInput, validateSql, validateSqlInput, } from './tools/metadata.js';
|
|
14
16
|
export const DQL_MCP_INSTRUCTIONS = 'DQL is a governed analytics MCP server. Start each session with ' +
|
|
15
17
|
'`inspect_dql_project`; route every analytics question through `ask_dql` ' +
|
|
16
18
|
'before writing SQL. It returns the safe route, trust label, certified ' +
|
|
@@ -25,11 +27,25 @@ export const DQL_MCP_INSTRUCTIONS = 'DQL is a governed analytics MCP server. Sta
|
|
|
25
27
|
'`uncertified: true`, the trust status, and draft path verbatim.\n' +
|
|
26
28
|
'Tier 3 missing context: if metadata does not identify a safe table, metric, ' +
|
|
27
29
|
'dimension, or grain, refuse and ask for what is missing.\n' +
|
|
30
|
+
'Trust labels are one canonical vocabulary: Certified, Reviewed, ' +
|
|
31
|
+
'AI-Generated, Insufficient-Context, Conflict (a base label plus an optional ' +
|
|
32
|
+
'qualifier, e.g. "Certified · invariant violated"). Report the trust label ' +
|
|
33
|
+
'verbatim and never upgrade it.\n' +
|
|
34
|
+
'Conflict route: when two certified terms or blocks claim the same concept ' +
|
|
35
|
+
'but disagree, `ask_dql` returns route `conflict` with BOTH definitions and ' +
|
|
36
|
+
'owners. Present both sides and ask the user which is authoritative — never ' +
|
|
37
|
+
'silently pick one.\n' +
|
|
28
38
|
'Use `build_dql_block` for reusable draft blocks, `build_dql_app` for app ' +
|
|
29
39
|
'drafts with certified tiles plus review-only gaps, `certify` for governance, ' +
|
|
30
40
|
'`lineage_impact` for dependencies, `kg_search` for the knowledge graph, and ' +
|
|
31
41
|
'`feedback_record` for answer quality. Never present generated SQL or draft ' +
|
|
32
|
-
'output as certified
|
|
42
|
+
'output as certified.\n' +
|
|
43
|
+
'Correction memory: when an analyst corrects a Tier-2 answer, call ' +
|
|
44
|
+
'`record_correction` with the scope (metric/dbt model/domain/dialect). It ' +
|
|
45
|
+
'creates a scoped CANDIDATE hint that is NOT used until a human runs ' +
|
|
46
|
+
'`approve_hint`. Approved hints are folded into matching future Tier-2 drafts ' +
|
|
47
|
+
'AFTER certified routing (never overriding certified answers) and are cited. ' +
|
|
48
|
+
'Use `list_hints` to review pending corrections.';
|
|
33
49
|
export function createDQLMCPServer(options = {}) {
|
|
34
50
|
const projectRoot = options.projectRoot ?? findProjectRoot(process.cwd());
|
|
35
51
|
const ctx = new DQLContext({ projectRoot, dqlVersion: options.version });
|
|
@@ -57,7 +73,7 @@ export function createDQLMCPServer(options = {}) {
|
|
|
57
73
|
inputSchema: queryViaBlockInput,
|
|
58
74
|
}, async (args) => wrap(await queryViaBlock(ctx, args)));
|
|
59
75
|
server.registerTool('query_via_metadata', {
|
|
60
|
-
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. 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.',
|
|
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.',
|
|
61
77
|
inputSchema: queryViaMetadataInput,
|
|
62
78
|
}, async (args) => wrap(await queryViaMetadata(ctx, args)));
|
|
63
79
|
server.registerTool('list_proposals', {
|
|
@@ -73,11 +89,35 @@ export function createDQLMCPServer(options = {}) {
|
|
|
73
89
|
inputSchema: suggestBlockInput,
|
|
74
90
|
}, async (args) => wrap(await suggestBlock(ctx, args)));
|
|
75
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)));
|
|
76
104
|
server.registerTool('inspect_metadata_context', {
|
|
77
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.',
|
|
78
106
|
inputSchema: inspectMetadataContextInput,
|
|
79
107
|
}, async (args) => wrap(await inspectMetadataContext(ctx, args)));
|
|
80
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)));
|
|
81
121
|
return server;
|
|
82
122
|
}
|
|
83
123
|
function wrap(result) {
|
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;AACpE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,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,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACzG,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,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,QAAQ,EACR,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE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`record_correction` — capture a Tier-2 correction as a Git trace + candidate
|
|
5
|
+
* hint (NOT used until approved).
|
|
6
|
+
* `approve_hint` — human review: approve/reject a candidate hint. Approval
|
|
7
|
+
* is the only path that makes a hint usable in retrieval.
|
|
8
|
+
* `list_hints` — list hints (optionally filtered by status) for review.
|
|
9
|
+
*
|
|
10
|
+
* Source of truth is Git (`.dql/hints`, `.dql/traces`, `.dql/reviews`); SQLite
|
|
11
|
+
* (`.dql/cache/agent-kg.sqlite`) is reindexed automatically on every write.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import type { DQLContext } from '../context.js';
|
|
15
|
+
export declare const recordCorrectionInput: {
|
|
16
|
+
question: z.ZodString;
|
|
17
|
+
wrongAnswer: z.ZodString;
|
|
18
|
+
correction: z.ZodString;
|
|
19
|
+
scope: z.ZodObject<{
|
|
20
|
+
metric: z.ZodOptional<z.ZodString>;
|
|
21
|
+
dbtModel: z.ZodOptional<z.ZodString>;
|
|
22
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
23
|
+
dialect: z.ZodOptional<z.ZodString>;
|
|
24
|
+
term: z.ZodOptional<z.ZodString>;
|
|
25
|
+
block: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
term?: string | undefined;
|
|
28
|
+
block?: string | undefined;
|
|
29
|
+
metric?: string | undefined;
|
|
30
|
+
domain?: string | undefined;
|
|
31
|
+
dbtModel?: string | undefined;
|
|
32
|
+
dialect?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
term?: string | undefined;
|
|
35
|
+
block?: string | undefined;
|
|
36
|
+
metric?: string | undefined;
|
|
37
|
+
domain?: string | undefined;
|
|
38
|
+
dbtModel?: string | undefined;
|
|
39
|
+
dialect?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
rationale: z.ZodOptional<z.ZodString>;
|
|
42
|
+
author: z.ZodOptional<z.ZodString>;
|
|
43
|
+
correctedSql: z.ZodOptional<z.ZodString>;
|
|
44
|
+
hintTitle: z.ZodOptional<z.ZodString>;
|
|
45
|
+
hintGuidance: z.ZodOptional<z.ZodString>;
|
|
46
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
47
|
+
anchorObjectKey: z.ZodOptional<z.ZodString>;
|
|
48
|
+
};
|
|
49
|
+
export declare function recordCorrection(ctx: DQLContext, args: {
|
|
50
|
+
question: string;
|
|
51
|
+
wrongAnswer: string;
|
|
52
|
+
correction: string;
|
|
53
|
+
scope: {
|
|
54
|
+
metric?: string;
|
|
55
|
+
dbtModel?: string;
|
|
56
|
+
domain?: string;
|
|
57
|
+
dialect?: string;
|
|
58
|
+
term?: string;
|
|
59
|
+
block?: string;
|
|
60
|
+
};
|
|
61
|
+
rationale?: string;
|
|
62
|
+
author?: string;
|
|
63
|
+
correctedSql?: string;
|
|
64
|
+
hintTitle?: string;
|
|
65
|
+
hintGuidance?: string;
|
|
66
|
+
tags?: string[];
|
|
67
|
+
anchorObjectKey?: string;
|
|
68
|
+
}): {
|
|
69
|
+
ok: boolean;
|
|
70
|
+
traceId: string;
|
|
71
|
+
hintId: string;
|
|
72
|
+
status: import("@duckcodeailabs/dql-agent").HintStatus;
|
|
73
|
+
note: string;
|
|
74
|
+
hint: {
|
|
75
|
+
id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
status: import("@duckcodeailabs/dql-agent").HintStatus;
|
|
78
|
+
guidance: string;
|
|
79
|
+
scope: import("@duckcodeailabs/dql-agent").HintScope;
|
|
80
|
+
correctedSql: string | undefined;
|
|
81
|
+
traceId: string | undefined;
|
|
82
|
+
author: string | undefined;
|
|
83
|
+
reviewer: string | undefined;
|
|
84
|
+
updatedAt: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export declare const approveHintInput: {
|
|
88
|
+
hintId: z.ZodString;
|
|
89
|
+
decision: z.ZodEnum<["approved", "rejected"]>;
|
|
90
|
+
reviewer: z.ZodString;
|
|
91
|
+
note: z.ZodOptional<z.ZodString>;
|
|
92
|
+
};
|
|
93
|
+
export declare function approveHint(ctx: DQLContext, args: {
|
|
94
|
+
hintId: string;
|
|
95
|
+
decision: 'approved' | 'rejected';
|
|
96
|
+
reviewer: string;
|
|
97
|
+
note?: string;
|
|
98
|
+
}): {
|
|
99
|
+
ok: boolean;
|
|
100
|
+
error: string;
|
|
101
|
+
hintId?: undefined;
|
|
102
|
+
status?: undefined;
|
|
103
|
+
reviewId?: undefined;
|
|
104
|
+
note?: undefined;
|
|
105
|
+
hint?: undefined;
|
|
106
|
+
} | {
|
|
107
|
+
ok: boolean;
|
|
108
|
+
hintId: string;
|
|
109
|
+
status: import("@duckcodeailabs/dql-agent").HintStatus;
|
|
110
|
+
reviewId: string;
|
|
111
|
+
note: string;
|
|
112
|
+
hint: {
|
|
113
|
+
id: string;
|
|
114
|
+
title: string;
|
|
115
|
+
status: import("@duckcodeailabs/dql-agent").HintStatus;
|
|
116
|
+
guidance: string;
|
|
117
|
+
scope: import("@duckcodeailabs/dql-agent").HintScope;
|
|
118
|
+
correctedSql: string | undefined;
|
|
119
|
+
traceId: string | undefined;
|
|
120
|
+
author: string | undefined;
|
|
121
|
+
reviewer: string | undefined;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
};
|
|
124
|
+
error?: undefined;
|
|
125
|
+
};
|
|
126
|
+
export declare const listHintsInput: {
|
|
127
|
+
status: z.ZodOptional<z.ZodEnum<["candidate", "approved", "rejected"]>>;
|
|
128
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
129
|
+
metric: z.ZodOptional<z.ZodString>;
|
|
130
|
+
};
|
|
131
|
+
export declare function listHints(ctx: DQLContext, args: {
|
|
132
|
+
status?: 'candidate' | 'approved' | 'rejected';
|
|
133
|
+
domain?: string;
|
|
134
|
+
metric?: string;
|
|
135
|
+
}): {
|
|
136
|
+
count: number;
|
|
137
|
+
hints: {
|
|
138
|
+
id: string;
|
|
139
|
+
title: string;
|
|
140
|
+
status: import("@duckcodeailabs/dql-agent").HintStatus;
|
|
141
|
+
guidance: string;
|
|
142
|
+
scope: import("@duckcodeailabs/dql-agent").HintScope;
|
|
143
|
+
correctedSql: string | undefined;
|
|
144
|
+
traceId: string | undefined;
|
|
145
|
+
author: string | undefined;
|
|
146
|
+
reviewer: string | undefined;
|
|
147
|
+
updatedAt: string;
|
|
148
|
+
}[];
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=hints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hints.d.ts","sourceRoot":"","sources":["../../src/tools/hints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAkBhD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYjC,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;;;;;;;;;;;;;;;;;;EAyBF;AAED,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC;AAEF,wBAAgB,WAAW,CACzB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B7F;AAED,eAAO,MAAM,cAAc;;;;CAI1B,CAAC;AAEF,wBAAgB,SAAS,CACvB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;EAU3F"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tools for scoped correction memory ("mini Hint Graph").
|
|
3
|
+
*
|
|
4
|
+
* `record_correction` — capture a Tier-2 correction as a Git trace + candidate
|
|
5
|
+
* hint (NOT used until approved).
|
|
6
|
+
* `approve_hint` — human review: approve/reject a candidate hint. Approval
|
|
7
|
+
* is the only path that makes a hint usable in retrieval.
|
|
8
|
+
* `list_hints` — list hints (optionally filtered by status) for review.
|
|
9
|
+
*
|
|
10
|
+
* Source of truth is Git (`.dql/hints`, `.dql/traces`, `.dql/reviews`); SQLite
|
|
11
|
+
* (`.dql/cache/agent-kg.sqlite`) is reindexed automatically on every write.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { getHintFromGit, listHintsFromGit, recordCorrectionTrace, reviewHint, } from '@duckcodeailabs/dql-agent';
|
|
15
|
+
const scopeSchema = {
|
|
16
|
+
metric: z.string().optional().describe('Metric / KPI the hint is about, e.g. "revenue".'),
|
|
17
|
+
dbtModel: z.string().optional().describe('dbt model the hint is about, e.g. "fct_orders".'),
|
|
18
|
+
domain: z.string().optional().describe('Business domain, e.g. "growth".'),
|
|
19
|
+
dialect: z.string().optional().describe('Warehouse SQL dialect, e.g. "duckdb", "snowflake".'),
|
|
20
|
+
term: z.string().optional().describe('Business term the hint refines.'),
|
|
21
|
+
block: z.string().optional().describe('Certified block the hint relates to.'),
|
|
22
|
+
};
|
|
23
|
+
export const recordCorrectionInput = {
|
|
24
|
+
question: z.string().describe('The analyst question the Tier-2 answer was for.'),
|
|
25
|
+
wrongAnswer: z.string().describe('The generated answer/SQL that was wrong.'),
|
|
26
|
+
correction: z.string().describe('The analyst correction: corrected SQL, rule, or guidance.'),
|
|
27
|
+
scope: z.object(scopeSchema).describe('Scope the correction applies within. A hint only applies inside its scope.'),
|
|
28
|
+
rationale: z.string().optional().describe('Why the original answer was wrong.'),
|
|
29
|
+
author: z.string().optional().describe('Who recorded the correction.'),
|
|
30
|
+
correctedSql: z.string().optional().describe('Optional canonical corrected SQL to endorse.'),
|
|
31
|
+
hintTitle: z.string().optional().describe('Override the derived hint title.'),
|
|
32
|
+
hintGuidance: z.string().optional().describe('Override the hint guidance (defaults to the correction).'),
|
|
33
|
+
tags: z.array(z.string()).optional().describe('Searchable keywords.'),
|
|
34
|
+
anchorObjectKey: z.string().optional().describe('contextPackId / blockId the correction anchored to.'),
|
|
35
|
+
};
|
|
36
|
+
export function recordCorrection(ctx, args) {
|
|
37
|
+
const { trace, hint } = recordCorrectionTrace(ctx.projectRoot, {
|
|
38
|
+
question: args.question,
|
|
39
|
+
scope: args.scope,
|
|
40
|
+
wrongAnswer: args.wrongAnswer,
|
|
41
|
+
correction: args.correction,
|
|
42
|
+
rationale: args.rationale,
|
|
43
|
+
author: args.author,
|
|
44
|
+
correctedSql: args.correctedSql,
|
|
45
|
+
hintTitle: args.hintTitle,
|
|
46
|
+
hintGuidance: args.hintGuidance,
|
|
47
|
+
tags: args.tags,
|
|
48
|
+
anchorObjectKey: args.anchorObjectKey,
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
ok: true,
|
|
52
|
+
traceId: trace.id,
|
|
53
|
+
hintId: hint.id,
|
|
54
|
+
status: hint.status,
|
|
55
|
+
note: 'Recorded as a CANDIDATE hint. It is NOT used in answers until approved via `approve_hint`. ' +
|
|
56
|
+
'Both the trace and hint are written under .dql/ and should be committed to Git.',
|
|
57
|
+
hint: summarizeHint(hint),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export const approveHintInput = {
|
|
61
|
+
hintId: z.string().describe('Id of the candidate hint to review.'),
|
|
62
|
+
decision: z.enum(['approved', 'rejected']).describe('Approve (usable in retrieval) or reject.'),
|
|
63
|
+
reviewer: z.string().describe('Who is reviewing.'),
|
|
64
|
+
note: z.string().optional().describe('Optional review note.'),
|
|
65
|
+
};
|
|
66
|
+
export function approveHint(ctx, args) {
|
|
67
|
+
const existing = getHintFromGit(ctx.projectRoot, args.hintId);
|
|
68
|
+
if (!existing) {
|
|
69
|
+
return { ok: false, error: `Hint ${args.hintId} not found under .dql/hints/.` };
|
|
70
|
+
}
|
|
71
|
+
const result = reviewHint(ctx.projectRoot, {
|
|
72
|
+
hintId: args.hintId,
|
|
73
|
+
decision: args.decision,
|
|
74
|
+
reviewer: args.reviewer,
|
|
75
|
+
note: args.note,
|
|
76
|
+
});
|
|
77
|
+
if (!result) {
|
|
78
|
+
return { ok: false, error: `Could not review hint ${args.hintId}.` };
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
ok: true,
|
|
82
|
+
hintId: result.hint.id,
|
|
83
|
+
status: result.hint.status,
|
|
84
|
+
reviewId: result.review.id,
|
|
85
|
+
note: result.hint.status === 'approved'
|
|
86
|
+
? 'Approved. This scoped hint will now be folded into matching Tier-2 drafts (after certified routing). Commit the updated .dql/ files to Git.'
|
|
87
|
+
: 'Rejected. This hint will not be used. Commit the updated .dql/ files to Git.',
|
|
88
|
+
hint: summarizeHint(result.hint),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export const listHintsInput = {
|
|
92
|
+
status: z.enum(['candidate', 'approved', 'rejected']).optional().describe('Filter by lifecycle status.'),
|
|
93
|
+
domain: z.string().optional().describe('Filter to a single domain scope.'),
|
|
94
|
+
metric: z.string().optional().describe('Filter to a single metric scope.'),
|
|
95
|
+
};
|
|
96
|
+
export function listHints(ctx, args) {
|
|
97
|
+
let hints = listHintsFromGit(ctx.projectRoot);
|
|
98
|
+
if (args.status)
|
|
99
|
+
hints = hints.filter((hint) => hint.status === args.status);
|
|
100
|
+
if (args.domain)
|
|
101
|
+
hints = hints.filter((hint) => eq(hint.scope.domain, args.domain));
|
|
102
|
+
if (args.metric)
|
|
103
|
+
hints = hints.filter((hint) => eq(hint.scope.metric, args.metric));
|
|
104
|
+
return {
|
|
105
|
+
count: hints.length,
|
|
106
|
+
hints: hints.map(summarizeHint),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function summarizeHint(hint) {
|
|
110
|
+
return {
|
|
111
|
+
id: hint.id,
|
|
112
|
+
title: hint.title,
|
|
113
|
+
status: hint.status,
|
|
114
|
+
guidance: hint.guidance,
|
|
115
|
+
scope: hint.scope,
|
|
116
|
+
correctedSql: hint.correctedSql,
|
|
117
|
+
traceId: hint.traceId,
|
|
118
|
+
author: hint.author,
|
|
119
|
+
reviewer: hint.reviewer,
|
|
120
|
+
updatedAt: hint.updatedAt,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function eq(a, b) {
|
|
124
|
+
if (a === undefined || b === undefined)
|
|
125
|
+
return false;
|
|
126
|
+
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=hints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hints.js","sourceRoot":"","sources":["../../src/tools/hints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAE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,IAAI,CAAC,MAAM;QAAE,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,IAAU;IAC/B,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,EAAE,CAAC,CAAqB,EAAE,CAAqB;IACtD,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACrD,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -5,11 +5,15 @@ export declare const lineageImpactInput: {
|
|
|
5
5
|
upstreamDepth: z.ZodOptional<z.ZodNumber>;
|
|
6
6
|
downstreamDepth: z.ZodOptional<z.ZodNumber>;
|
|
7
7
|
paths: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
recert: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
nonSemantic: z.ZodOptional<z.ZodBoolean>;
|
|
8
10
|
};
|
|
9
11
|
export declare function lineageImpact(ctx: DQLContext, args: {
|
|
10
12
|
focus: string;
|
|
11
13
|
upstreamDepth?: number;
|
|
12
14
|
downstreamDepth?: number;
|
|
13
15
|
paths?: boolean;
|
|
16
|
+
recert?: boolean;
|
|
17
|
+
nonSemantic?: boolean;
|
|
14
18
|
}): Record<string, unknown>;
|
|
15
19
|
//# sourceMappingURL=lineage-impact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineage-impact.d.ts","sourceRoot":"","sources":["../../src/tools/lineage-impact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"lineage-impact.d.ts","sourceRoot":"","sources":["../../src/tools/lineage-impact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,kBAAkB;;;;;;;CAuB9B,CAAC;AAEF,wBAAgB,aAAa,CAC3B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,2BAyDF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { queryLineage, queryCompleteLineagePaths } from '@duckcodeailabs/dql-core';
|
|
2
|
+
import { queryLineage, queryCompleteLineagePaths, computeImpact, } from '@duckcodeailabs/dql-core';
|
|
3
3
|
export const lineageImpactInput = {
|
|
4
4
|
focus: z.string().describe('Node id ("block:revenue") or bare name — resolved against the lineage graph.'),
|
|
5
5
|
upstreamDepth: z.number().int().min(0).max(20).optional(),
|
|
@@ -8,6 +8,17 @@ export const lineageImpactInput = {
|
|
|
8
8
|
.boolean()
|
|
9
9
|
.optional()
|
|
10
10
|
.describe('When true, include full source→leaf paths (slower on large graphs).'),
|
|
11
|
+
recert: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('When true, treat `focus` as a changed block and return the re-cert impact: ' +
|
|
15
|
+
'full transitive downstream, invalidated cross-domain edges, domainTrust delta, ' +
|
|
16
|
+
'and the certified artifacts that require re-certification.'),
|
|
17
|
+
nonSemantic: z
|
|
18
|
+
.boolean()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('When true with `recert`, treats the change as non-semantic (description/comment/tag only) ' +
|
|
21
|
+
'so no re-cert is required. Default false (conservative: assume semantic).'),
|
|
11
22
|
};
|
|
12
23
|
export function lineageImpact(ctx, args) {
|
|
13
24
|
const graph = ctx.lineageGraph;
|
|
@@ -34,6 +45,30 @@ export function lineageImpact(ctx, args) {
|
|
|
34
45
|
response.layerSummary = paths.layerSummary;
|
|
35
46
|
}
|
|
36
47
|
}
|
|
48
|
+
// Re-cert impact: treat the focal block as changed and compute the
|
|
49
|
+
// downstream invalidation + required re-cert list. Mirrors the
|
|
50
|
+
// `dql diff --impact` CLI gate, surfaced structurally for agents.
|
|
51
|
+
if (args.recert) {
|
|
52
|
+
const blockName = result.focalNode.type === 'block'
|
|
53
|
+
? result.focalNode.name
|
|
54
|
+
: result.focalNode.id.replace(/^block:/, '');
|
|
55
|
+
const changed = {
|
|
56
|
+
name: blockName,
|
|
57
|
+
verdict: args.nonSemantic ? 'non-semantic' : 'semantic',
|
|
58
|
+
changedFields: [],
|
|
59
|
+
structural: false,
|
|
60
|
+
};
|
|
61
|
+
const impact = computeImpact(graph, [changed]);
|
|
62
|
+
response.impact = {
|
|
63
|
+
changedBlocks: impact.changedBlocks,
|
|
64
|
+
semanticChanges: impact.semanticChanges,
|
|
65
|
+
downstream: impact.downstream,
|
|
66
|
+
crossDomainImpacts: impact.crossDomainImpacts,
|
|
67
|
+
requiresRecert: impact.requiresRecert,
|
|
68
|
+
domainTrustDelta: impact.domainTrustDelta,
|
|
69
|
+
hasCertifiedInvalidation: impact.hasCertifiedInvalidation,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
37
72
|
return response;
|
|
38
73
|
}
|
|
39
74
|
function formatPath(path) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineage-impact.js","sourceRoot":"","sources":["../../src/tools/lineage-impact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"lineage-impact.js","sourceRoot":"","sources":["../../src/tools/lineage-impact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,aAAa,GAEd,MAAM,0BAA0B,CAAC;AAGlC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8EAA8E,CAAC;IAC1G,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACzD,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC3D,KAAK,EAAE,CAAC;SACL,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CAAC,qEAAqE,CAAC;IAClF,MAAM,EAAE,CAAC;SACN,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CACP,6EAA6E;QAC3E,iFAAiF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|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grounded-SQL metadata tools (spec 15.5) — thin wrappers over the dbt catalog
|
|
3
|
+
* + the shared sql-grounding so EXTERNAL agents look up the same context the
|
|
4
|
+
* notebook build path uses:
|
|
5
|
+
*
|
|
6
|
+
* - `search_metadata` — rank dbt tables relevant to a request, with their
|
|
7
|
+
* qualified relation + {{ ref() }} form.
|
|
8
|
+
* - `get_table_schema` — the qualified relation, {{ ref() }} form, real
|
|
9
|
+
* columns + types, and join keys for a table.
|
|
10
|
+
* - `validate_sql` — validate a SQL string references ONLY known
|
|
11
|
+
* relations/columns, returning the precise miss.
|
|
12
|
+
*
|
|
13
|
+
* All three load dbt artifacts read-only and never write. They degrade
|
|
14
|
+
* gracefully (a clear hint) when no dbt manifest is present.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import type { DQLContext } from '../context.js';
|
|
18
|
+
export declare const searchMetadataInput: {
|
|
19
|
+
query: z.ZodString;
|
|
20
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
};
|
|
22
|
+
export declare function searchMetadata(ctx: DQLContext, args: {
|
|
23
|
+
query: string;
|
|
24
|
+
limit?: number;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
tables: never[];
|
|
27
|
+
hint: string;
|
|
28
|
+
total?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
total: number;
|
|
31
|
+
tables: {
|
|
32
|
+
name: string;
|
|
33
|
+
qualifiedRelation: string;
|
|
34
|
+
refForm: string | null;
|
|
35
|
+
kind: "source" | "model";
|
|
36
|
+
columnCount: number;
|
|
37
|
+
certifiedBlock: boolean;
|
|
38
|
+
}[];
|
|
39
|
+
hint?: undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const getTableSchemaInput: {
|
|
42
|
+
table: z.ZodString;
|
|
43
|
+
};
|
|
44
|
+
export declare function getTableSchema(ctx: DQLContext, args: {
|
|
45
|
+
table: string;
|
|
46
|
+
}): {
|
|
47
|
+
found: boolean;
|
|
48
|
+
hint: string;
|
|
49
|
+
name?: undefined;
|
|
50
|
+
qualifiedRelation?: undefined;
|
|
51
|
+
refForm?: undefined;
|
|
52
|
+
kind?: undefined;
|
|
53
|
+
certifiedBlock?: undefined;
|
|
54
|
+
columns?: undefined;
|
|
55
|
+
joinKeys?: undefined;
|
|
56
|
+
} | {
|
|
57
|
+
found: boolean;
|
|
58
|
+
name: string;
|
|
59
|
+
qualifiedRelation: string;
|
|
60
|
+
refForm: string | null;
|
|
61
|
+
kind: "source" | "model";
|
|
62
|
+
certifiedBlock: boolean;
|
|
63
|
+
columns: {
|
|
64
|
+
name: string;
|
|
65
|
+
type: string | null;
|
|
66
|
+
description: string | null;
|
|
67
|
+
}[];
|
|
68
|
+
joinKeys: {
|
|
69
|
+
leftRelation: string;
|
|
70
|
+
leftColumn: string;
|
|
71
|
+
rightRelation: string;
|
|
72
|
+
rightColumn: string;
|
|
73
|
+
reason: string;
|
|
74
|
+
}[];
|
|
75
|
+
hint?: undefined;
|
|
76
|
+
};
|
|
77
|
+
export declare const validateSqlInput: {
|
|
78
|
+
sql: z.ZodString;
|
|
79
|
+
query: z.ZodOptional<z.ZodString>;
|
|
80
|
+
};
|
|
81
|
+
export declare function validateSql(ctx: DQLContext, args: {
|
|
82
|
+
sql: string;
|
|
83
|
+
query?: string;
|
|
84
|
+
}): Promise<{
|
|
85
|
+
ok: boolean;
|
|
86
|
+
code: string;
|
|
87
|
+
error: string;
|
|
88
|
+
warnings: never[];
|
|
89
|
+
referencedRelations?: undefined;
|
|
90
|
+
offending?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
ok: boolean;
|
|
93
|
+
warnings: string[];
|
|
94
|
+
referencedRelations: string[];
|
|
95
|
+
code?: undefined;
|
|
96
|
+
error?: undefined;
|
|
97
|
+
offending?: undefined;
|
|
98
|
+
} | {
|
|
99
|
+
ok: boolean;
|
|
100
|
+
code: import("@duckcodeailabs/dql-agent").GroundingValidationCode;
|
|
101
|
+
error: string;
|
|
102
|
+
warnings: string[];
|
|
103
|
+
referencedRelations: string[];
|
|
104
|
+
offending: {
|
|
105
|
+
relation?: string;
|
|
106
|
+
column?: string;
|
|
107
|
+
} | null;
|
|
108
|
+
}>;
|
|
109
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/tools/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAkBhD,eAAO,MAAM,mBAAmB;;;CAG/B,CAAC;AAEF,wBAAsB,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;GAiB5F;AAID,eAAO,MAAM,mBAAmB;;CAE/B,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCtE;AAID,eAAO,MAAM,gBAAgB;;;CAM5B,CAAC;AAEF,wBAAsB,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;GAqBvF"}
|