@duckcodeailabs/dql-agent 1.4.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/answer-loop.d.ts +88 -1
- package/dist/answer-loop.d.ts.map +1 -1
- package/dist/answer-loop.js +459 -48
- package/dist/answer-loop.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -5
- package/dist/index.js.map +1 -1
- package/dist/kg/build.d.ts +5 -0
- package/dist/kg/build.d.ts.map +1 -1
- package/dist/kg/build.js +283 -0
- package/dist/kg/build.js.map +1 -1
- package/dist/kg/sqlite-fts.d.ts +1 -0
- package/dist/kg/sqlite-fts.d.ts.map +1 -1
- package/dist/kg/sqlite-fts.js +77 -24
- package/dist/kg/sqlite-fts.js.map +1 -1
- package/dist/kg/types.d.ts +23 -1
- package/dist/kg/types.d.ts.map +1 -1
- package/dist/memory/sqlite-memory.d.ts +62 -0
- package/dist/memory/sqlite-memory.d.ts.map +1 -0
- package/dist/memory/sqlite-memory.js +242 -0
- package/dist/memory/sqlite-memory.js.map +1 -0
- package/dist/providers/ollama.d.ts +4 -1
- package/dist/providers/ollama.d.ts.map +1 -1
- package/dist/providers/ollama.js +77 -28
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.d.ts +2 -0
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +8 -6
- package/dist/providers/openai.js.map +1 -1
- package/package.json +5 -5
package/dist/answer-loop.d.ts
CHANGED
|
@@ -18,18 +18,86 @@ import type { KGStore } from './kg/sqlite-fts.js';
|
|
|
18
18
|
import type { KGNode, KGSearchHit } from './kg/types.js';
|
|
19
19
|
import type { AgentProvider } from './providers/types.js';
|
|
20
20
|
import type { Skill } from './skills/loader.js';
|
|
21
|
+
import type { AgentMemory } from './memory/sqlite-memory.js';
|
|
21
22
|
export type AnswerKind = 'certified' | 'uncertified' | 'no_answer';
|
|
23
|
+
export type AnswerSourceTier = 'certified_artifact' | 'semantic_layer' | 'dbt_manifest' | 'no_answer';
|
|
24
|
+
export type AnswerCertification = 'certified' | 'ai_generated' | 'analyst_review_required';
|
|
25
|
+
export type AnswerReviewStatus = 'none' | 'draft_ready' | 'analyst_review_required' | 'certified';
|
|
22
26
|
export interface AgentCitation {
|
|
23
27
|
nodeId: string;
|
|
24
|
-
kind: KGNode['kind'];
|
|
28
|
+
kind: KGNode['kind'] | 'memory';
|
|
25
29
|
name: string;
|
|
26
30
|
/** Frozen-in-time SHA at the moment of indexing. */
|
|
27
31
|
gitSha?: string;
|
|
32
|
+
sourceTier?: AnswerSourceTier | 'memory';
|
|
33
|
+
provenance?: string;
|
|
34
|
+
}
|
|
35
|
+
export type AgentEvidenceRouteStatus = 'selected' | 'checked' | 'skipped' | 'failed';
|
|
36
|
+
export type AgentEvidenceLineageRole = 'question' | 'selected_asset' | 'semantic_object' | 'source_table' | 'consumer' | 'memory';
|
|
37
|
+
export interface AgentEvidenceRouteStep {
|
|
38
|
+
tool: string;
|
|
39
|
+
status: AgentEvidenceRouteStatus;
|
|
40
|
+
label: string;
|
|
41
|
+
detail?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface AgentEvidenceAsset {
|
|
44
|
+
nodeId: string;
|
|
45
|
+
kind: KGNode['kind'] | 'memory' | 'question';
|
|
46
|
+
name: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
sourceTier?: AnswerSourceTier | 'memory' | 'project';
|
|
49
|
+
certification?: AnswerCertification | 'certified' | 'uncertified';
|
|
50
|
+
provenance?: string;
|
|
51
|
+
sourcePath?: string;
|
|
52
|
+
owner?: string;
|
|
53
|
+
domain?: string;
|
|
54
|
+
status?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface AgentEvidenceLineageNode extends AgentEvidenceAsset {
|
|
57
|
+
role: AgentEvidenceLineageRole;
|
|
58
|
+
}
|
|
59
|
+
export interface AgentEvidenceContextItem {
|
|
60
|
+
label: string;
|
|
61
|
+
value: string;
|
|
62
|
+
source?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface AgentEvidenceOutcome {
|
|
65
|
+
name?: string;
|
|
66
|
+
owner?: string;
|
|
67
|
+
decisionUse?: string;
|
|
68
|
+
reviewCadence?: string;
|
|
69
|
+
caveats?: string[];
|
|
70
|
+
}
|
|
71
|
+
export interface AgentEvidence {
|
|
72
|
+
route: AgentEvidenceRouteStep[];
|
|
73
|
+
lineage: AgentEvidenceLineageNode[];
|
|
74
|
+
businessContext: AgentEvidenceContextItem[];
|
|
75
|
+
outcome?: AgentEvidenceOutcome;
|
|
76
|
+
selectedAssets: AgentEvidenceAsset[];
|
|
77
|
+
sourceTables: AgentEvidenceAsset[];
|
|
78
|
+
semanticObjects: AgentEvidenceAsset[];
|
|
79
|
+
validation?: {
|
|
80
|
+
status: 'passed' | 'warning' | 'failed' | 'not_run';
|
|
81
|
+
message: string;
|
|
82
|
+
};
|
|
83
|
+
execution?: {
|
|
84
|
+
status: 'executed' | 'failed' | 'not_requested' | 'not_applicable';
|
|
85
|
+
message: string;
|
|
86
|
+
rowCount?: number;
|
|
87
|
+
executionTime?: number;
|
|
88
|
+
};
|
|
89
|
+
citations: AgentCitation[];
|
|
28
90
|
}
|
|
29
91
|
export interface AgentAnswer {
|
|
30
92
|
kind: AnswerKind;
|
|
93
|
+
sourceTier?: AnswerSourceTier;
|
|
94
|
+
certification?: AnswerCertification;
|
|
95
|
+
reviewStatus?: AnswerReviewStatus;
|
|
96
|
+
confidence?: number;
|
|
31
97
|
/** Final answer text (NL summary). */
|
|
32
98
|
text: string;
|
|
99
|
+
/** Alias for UI envelopes. */
|
|
100
|
+
answer?: string;
|
|
33
101
|
/** Certified path: the matched block. */
|
|
34
102
|
block?: KGNode;
|
|
35
103
|
/** Certified path execution result, when a governed executor is supplied. */
|
|
@@ -38,9 +106,17 @@ export interface AgentAnswer {
|
|
|
38
106
|
executionError?: string;
|
|
39
107
|
/** Uncertified path: the LLM-proposed SQL the analyst should review. */
|
|
40
108
|
proposedSql?: string;
|
|
109
|
+
/** Alias for the structured answer envelope. */
|
|
110
|
+
sql?: string;
|
|
41
111
|
/** Suggested viz type for the proposed SQL (line/bar/single_value/...). */
|
|
42
112
|
suggestedViz?: string;
|
|
113
|
+
/** Draft block id/path once a host persists the proposal. */
|
|
114
|
+
draftBlockId?: string;
|
|
43
115
|
citations: AgentCitation[];
|
|
116
|
+
/** Relevant local memory supplied as advisory context. */
|
|
117
|
+
memoryContext?: AgentMemory[];
|
|
118
|
+
/** Evidence path connecting the question to metadata, SQL/block execution, and review state. */
|
|
119
|
+
evidence?: AgentEvidence;
|
|
44
120
|
/** Provider name used (for telemetry / UI badge). */
|
|
45
121
|
providerUsed?: string;
|
|
46
122
|
/** Top KG hits the loop considered, useful for the UI's "we considered" panel. */
|
|
@@ -52,9 +128,18 @@ export interface AgentResultPayload {
|
|
|
52
128
|
rowCount: number;
|
|
53
129
|
executionTime?: number;
|
|
54
130
|
chartConfig?: unknown;
|
|
131
|
+
sql?: string;
|
|
132
|
+
blockName?: string;
|
|
133
|
+
blockPath?: string;
|
|
55
134
|
}
|
|
56
135
|
export interface AnswerLoopInput {
|
|
57
136
|
question: string;
|
|
137
|
+
/**
|
|
138
|
+
* Current notebook/app context, such as upstream SQL or selected filters.
|
|
139
|
+
* This is prompt context only. It is intentionally excluded from KG and
|
|
140
|
+
* memory retrieval so transient SQL cannot change governed routing.
|
|
141
|
+
*/
|
|
142
|
+
extraContext?: string;
|
|
58
143
|
/** Active user — used for Skills filtering and the "asked by" record. */
|
|
59
144
|
userId?: string;
|
|
60
145
|
/** Domain to scope the search. Optional. */
|
|
@@ -67,6 +152,8 @@ export interface AnswerLoopInput {
|
|
|
67
152
|
skills?: Skill[];
|
|
68
153
|
/** Hints to prefer specific blocks first (vocabulary mappings from Skills). */
|
|
69
154
|
blockHints?: string[];
|
|
155
|
+
/** Optional advisory memory. Never outranks project metadata. */
|
|
156
|
+
memoryContext?: AgentMemory[];
|
|
70
157
|
/** Optional AbortSignal forwarded to the provider. */
|
|
71
158
|
signal?: AbortSignal;
|
|
72
159
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer-loop.d.ts","sourceRoot":"","sources":["../src/answer-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"answer-loop.d.ts","sourceRoot":"","sources":["../src/answer-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAc,WAAW,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,WAAW,CAAC;AACnE,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,cAAc,GAAG,WAAW,CAAC;AACtG,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,cAAc,GAAG,yBAAyB,CAAC;AAC3F,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,aAAa,GAAG,yBAAyB,GAAG,WAAW,CAAC;AAElG,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,gBAAgB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