@finos/legend-lego 2.0.188 → 2.0.189

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.
Files changed (44) hide show
  1. package/lib/index.css +2 -2
  2. package/lib/index.css.map +1 -1
  3. package/lib/legend-ai/LegendAITypes.d.ts +196 -0
  4. package/lib/legend-ai/LegendAITypes.d.ts.map +1 -0
  5. package/lib/legend-ai/LegendAITypes.js +281 -0
  6. package/lib/legend-ai/LegendAITypes.js.map +1 -0
  7. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.d.ts +127 -0
  8. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.d.ts.map +1 -0
  9. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.js +63 -0
  10. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.js.map +1 -0
  11. package/lib/legend-ai/__test-utils__/LegendAITestUtils.d.ts +29 -0
  12. package/lib/legend-ai/__test-utils__/LegendAITestUtils.d.ts.map +1 -0
  13. package/lib/legend-ai/__test-utils__/LegendAITestUtils.js +98 -0
  14. package/lib/legend-ai/__test-utils__/LegendAITestUtils.js.map +1 -0
  15. package/lib/legend-ai/components/LegendAIChat.d.ts +23 -0
  16. package/lib/legend-ai/components/LegendAIChat.d.ts.map +1 -0
  17. package/lib/legend-ai/components/LegendAIChat.js +179 -0
  18. package/lib/legend-ai/components/LegendAIChat.js.map +1 -0
  19. package/lib/legend-ai/components/LegendAIErrorBoundary.d.ts +31 -0
  20. package/lib/legend-ai/components/LegendAIErrorBoundary.d.ts.map +1 -0
  21. package/lib/legend-ai/components/LegendAIErrorBoundary.js +35 -0
  22. package/lib/legend-ai/components/LegendAIErrorBoundary.js.map +1 -0
  23. package/lib/legend-ai/components/LegendAIResultGrid.d.ts +20 -0
  24. package/lib/legend-ai/components/LegendAIResultGrid.d.ts.map +1 -0
  25. package/lib/legend-ai/components/LegendAIResultGrid.js +90 -0
  26. package/lib/legend-ai/components/LegendAIResultGrid.js.map +1 -0
  27. package/lib/legend-ai/index.d.ts +22 -0
  28. package/lib/legend-ai/index.d.ts.map +1 -0
  29. package/lib/legend-ai/index.js +22 -0
  30. package/lib/legend-ai/index.js.map +1 -0
  31. package/lib/legend-ai/stores/LegendAIChatState.d.ts +46 -0
  32. package/lib/legend-ai/stores/LegendAIChatState.d.ts.map +1 -0
  33. package/lib/legend-ai/stores/LegendAIChatState.js +559 -0
  34. package/lib/legend-ai/stores/LegendAIChatState.js.map +1 -0
  35. package/package.json +5 -1
  36. package/src/legend-ai/LegendAITypes.ts +386 -0
  37. package/src/legend-ai/LegendAI_LegendApplicationPlugin_Extension.ts +208 -0
  38. package/src/legend-ai/__test-utils__/LegendAITestUtils.ts +139 -0
  39. package/src/legend-ai/components/LegendAIChat.tsx +502 -0
  40. package/src/legend-ai/components/LegendAIErrorBoundary.tsx +42 -0
  41. package/src/legend-ai/components/LegendAIResultGrid.tsx +132 -0
  42. package/src/legend-ai/index.ts +46 -0
  43. package/src/legend-ai/stores/LegendAIChatState.ts +1004 -0
  44. package/tsconfig.json +8 -0
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Copyright (c) 2026-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { LegendAI_LegendApplicationPlugin_Extension, } from './LegendAI_LegendApplicationPlugin_Extension.js';
17
+ export class TDSColumnSchema {
18
+ name;
19
+ type;
20
+ documentation;
21
+ sampleValues;
22
+ }
23
+ export var TDSServiceSourceType;
24
+ (function (TDSServiceSourceType) {
25
+ TDSServiceSourceType["SERVICE"] = "service";
26
+ TDSServiceSourceType["ACCESS_POINT"] = "accessPoint";
27
+ })(TDSServiceSourceType || (TDSServiceSourceType = {}));
28
+ export class TDSServiceSchema {
29
+ title;
30
+ description;
31
+ pattern;
32
+ columns;
33
+ parameters;
34
+ /**
35
+ * Indicates the source of this service schema.
36
+ * - SERVICE: traditional DataSpace service executable (uses `FROM service(...)` SQL syntax)
37
+ * - ACCESS_POINT: data product access point (uses `FROM p(...)` SQL syntax with lakehouse runtime)
38
+ */
39
+ sourceType;
40
+ /** Full data product path (e.g. 'my::package::DataProduct'), used with `p()` syntax for access points. */
41
+ dataProductPath;
42
+ }
43
+ export class LegendAIConfig {
44
+ enabled;
45
+ llmServiceUrl;
46
+ llmModelName;
47
+ sqlExecutionUrl;
48
+ orchestratorUrl;
49
+ marketplaceSearchUrl;
50
+ engineUrl;
51
+ orchestratorAuthToken;
52
+ maxJudgeAttempts;
53
+ /** Lakehouse runtime environment name (e.g. 'prod', 'uat'). Defaults to 'prod' when not set. */
54
+ lakehouseEnvironment;
55
+ }
56
+ export const DEFAULT_LEGEND_AI_CONFIG = Object.freeze({
57
+ enabled: false,
58
+ llmServiceUrl: undefined,
59
+ llmModelName: undefined,
60
+ sqlExecutionUrl: undefined,
61
+ orchestratorUrl: undefined,
62
+ marketplaceSearchUrl: undefined,
63
+ engineUrl: undefined,
64
+ });
65
+ export function findLegendAIPlugin(plugins) {
66
+ return plugins.find((p) => p instanceof LegendAI_LegendApplicationPlugin_Extension);
67
+ }
68
+ export class LegendAIGridData {
69
+ columnDefs;
70
+ rowData;
71
+ }
72
+ export function buildColumnDefsFromNames(columns) {
73
+ return columns.map((col) => ({
74
+ colId: col,
75
+ headerName: col,
76
+ field: col,
77
+ }));
78
+ }
79
+ export var LegendAIThinkingStepStatus;
80
+ (function (LegendAIThinkingStepStatus) {
81
+ LegendAIThinkingStepStatus["ACTIVE"] = "active";
82
+ LegendAIThinkingStepStatus["DONE"] = "done";
83
+ LegendAIThinkingStepStatus["ERROR"] = "error";
84
+ })(LegendAIThinkingStepStatus || (LegendAIThinkingStepStatus = {}));
85
+ export class LegendAIThinkingStep {
86
+ label;
87
+ status;
88
+ }
89
+ export var LegendAIMessageRole;
90
+ (function (LegendAIMessageRole) {
91
+ LegendAIMessageRole["USER"] = "user";
92
+ LegendAIMessageRole["ASSISTANT"] = "assistant";
93
+ })(LegendAIMessageRole || (LegendAIMessageRole = {}));
94
+ export class LegendAIUserMessage {
95
+ id;
96
+ role;
97
+ text;
98
+ }
99
+ export class LegendAIAssistantMessage {
100
+ id;
101
+ role;
102
+ thinkingSteps;
103
+ sql;
104
+ textAnswer;
105
+ gridData;
106
+ error;
107
+ sqlGenTime;
108
+ execTime;
109
+ thinkingDuration;
110
+ isProcessing;
111
+ isExecuting;
112
+ suggestedQueries;
113
+ }
114
+ export class LegendAIConversationTurn {
115
+ question;
116
+ sql;
117
+ /**
118
+ * The intent classification of this turn, allowing downstream prompts
119
+ * to differentiate prior metadata answers from SQL query results.
120
+ */
121
+ intent;
122
+ }
123
+ export class LegendAIAccessPointGroupInfo {
124
+ title;
125
+ description;
126
+ accessPoints;
127
+ }
128
+ export class LegendAIProductMetadata {
129
+ name;
130
+ description;
131
+ coordinates;
132
+ serviceSummaries;
133
+ accessPointGroups;
134
+ tags;
135
+ supportInfo;
136
+ }
137
+ export var LegendAIQuestionIntent;
138
+ (function (LegendAIQuestionIntent) {
139
+ LegendAIQuestionIntent["DATA_QUERY"] = "data_query";
140
+ LegendAIQuestionIntent["METADATA"] = "metadata";
141
+ LegendAIQuestionIntent["ORCHESTRATOR"] = "orchestrator";
142
+ })(LegendAIQuestionIntent || (LegendAIQuestionIntent = {}));
143
+ export const METADATA_SIGNAL_PATTERNS = Object.freeze([
144
+ /\b(?:what\s+does\s+this\s+(?:data\s*product|dataspace|data\s*space|product)\s+(?:do|provide|contain|offer|have))\b/,
145
+ /\b(?:describe|explain|summarize|summary|overview)\s+(?:this\s+)?(?:data\s*product|dataspace|data\s*space|product)\b/,
146
+ /\b(?:tell\s+me\s+about)\s+(?:this\s+)?(?:data\s*product|dataspace|data\s*space|product)\b/,
147
+ /\b(?:what\s+(?:services?|endpoints?|access\s*points?|columns?|fields?)\s+(?:are|is|does))\b/,
148
+ /\b(?:list|what\s+are)\s+(?:the\s+)?(?:available\s+)?(?:services?|endpoints?|capabilities)\b/,
149
+ /\b(?:list|what\s+are)\s+(?:the\s+)?(?:available\s+)?access\s*points?\b/,
150
+ /\b(?:who\s+(?:owns?|maintains?|created?|manages?|supports?))\b/,
151
+ /\b(?:owner(?:ship)?|maintainer|contact\s+(?:info|email|team|details)|support\s+(?:info|email|team))\b/,
152
+ /\b(?:classifications?|tags?|stereotypes?)\s+(?:of|for|on)\s+(?:this|the)\b/,
153
+ /\bsummarize\s+what\s+(?:you|this|it)\s+(?:have|has|provide|offers?|contains?)\b/,
154
+ /\bwhat\s+(?:do\s+you|does\s+it|does\s+this)\s+(?:have|provide|offer|contain)\b/,
155
+ /\b(?:how\s+many)\s+(?:services?|endpoints?|access\s*points?|columns?|fields?)\b/,
156
+ /\b(?:what\s+(?:type|kind|format))\s+(?:of|is)\b/,
157
+ /^(?:summarize|describe|explain|overview)\b/,
158
+ /\b(?:summary|overview|description)\s+(?:of|about)\b/,
159
+ /\bwhat\s+(?:is|are)\s+(?:this|the|it)\b/,
160
+ /\btell\s+me\s+(?:about|more)\b/,
161
+ /\bwhat\s+(?:\S+\s+)*(?:provides?|offers?|contains?|includes?)\s*$/,
162
+ /\bhow\s+does\s+(?:\S+\s+)*(?:work|function|operate)\b/,
163
+ /\bwhat\s+can\s+(?:i|we|you)\b/,
164
+ /\b(?:used\s+for|meant\s+for|designed\s+for|purpose\s+of)\b/,
165
+ /\b(?:help\s+me\s+(?:understand|with))\b/,
166
+ /\bwhat\s+(?:information|data|content|datasets?)\s+(?:is|are|does)\b/,
167
+ /\b(?:what\s+does)\s+\S+(?:\s+\S+)*\s+(?:do|provide|offer|contain|include|cover)\b/,
168
+ ]);
169
+ export const DATA_QUERY_SIGNAL_PATTERNS = Object.freeze([
170
+ /\b(?:select|query|sql|rows?|records?|count|sum|avg|average|min|max|total)\b/,
171
+ /\b(?:top\s+\d+|first\s+\d+|last\s+\d+|limit\s+\d+)\b/,
172
+ /\b(?:filter|where|group\s+by|order\s+by|sort|join|aggregate)\b/,
173
+ /\b(?:distinct|unique)\s+(?:values?|entries?|items?)/,
174
+ /\bfrom\s+(?:\S+\s+)*service\b/,
175
+ /\b(?:show|give|get|fetch|retrieve|pull|find|provide|display|return)\s+(?:me\s+)?/,
176
+ /\b(?:compare|comparison|versus|vs\.?)\b/,
177
+ /\b(?:what\s+percentage|what\s+%|what\s+proportion|what\s+fraction)\b/,
178
+ /\b(?:which\s+\w+s?\s+(?:does|do|did|has|have|is|are|generate|earn|produce))\b/,
179
+ /\b(?:how\s+(?:much|many|often))\b/,
180
+ /\b\d{4}[-/]\d{2}[-/]\d{2}\b/,
181
+ /\b(?:as\s+of|since|before|after|between|from|until|latest|recent|yesterday|today)\b/,
182
+ /\blast\s+(?:year|month|week|quarter|fiscal)\b/,
183
+ /\b(?:fiscal\s+(?:year|quarter)|fy\s*\d|q[1-4]\s*\d{4})\b/,
184
+ /\b(?:sedol|isin|cusip|ticker|symbol)[\s:=]*\w+/,
185
+ /\b(?:revenue|sales|income|profit|earnings|margin|growth|volume|price|rate|exposure)\b/,
186
+ /\b(?:breakdown|distribution|composition|split|allocation|attribution|ranking|trend)\b/,
187
+ /\b(?:per\s+(?:country|region|year|month|quarter|segment|category))\b/,
188
+ /\b(?:grouped?\s+by|broken?\s+down\s+by|split\s+by|segmented?\s+by)\b/,
189
+ ]);
190
+ const PRODUCT_REFERENCE_PATTERN = /\b(?:this|the)\s+(?:data\s*product|dataspace|data\s*space|product)\b/;
191
+ const STRUCTURAL_KEYWORD_PATTERN = /\b(?:services?|endpoints?|access\s*points?|capabilities|owner|maintainer|support)\b/;
192
+ function countPatternMatches(question, patterns) {
193
+ let count = 0;
194
+ for (const pattern of patterns) {
195
+ if (pattern.test(question)) {
196
+ count++;
197
+ }
198
+ }
199
+ return count;
200
+ }
201
+ /**
202
+ * Result of the fast deterministic regex-based classifier.
203
+ * Includes the scores and resolved intent so callers can decide
204
+ * whether the classification is confident or needs LLM arbitration.
205
+ */
206
+ export class QuestionIntentClassification {
207
+ intent;
208
+ metaScore;
209
+ dataScore;
210
+ ambiguous;
211
+ }
212
+ /**
213
+ * Fast deterministic regex classifier (sync, < 1ms).
214
+ * Returns both the resolved intent AND whether the result is ambiguous,
215
+ * so callers can decide to escalate to an LLM for ambiguous cases.
216
+ */
217
+ export function classifyQuestionIntentFast(question, hasServices) {
218
+ const q = question.toLowerCase().trim();
219
+ const metaScore = countPatternMatches(q, METADATA_SIGNAL_PATTERNS);
220
+ const dataScore = countPatternMatches(q, DATA_QUERY_SIGNAL_PATTERNS);
221
+ if (metaScore > 0 && dataScore === 0) {
222
+ return {
223
+ intent: LegendAIQuestionIntent.METADATA,
224
+ metaScore,
225
+ dataScore,
226
+ ambiguous: false,
227
+ };
228
+ }
229
+ if (dataScore > 0 && metaScore === 0) {
230
+ return {
231
+ intent: LegendAIQuestionIntent.DATA_QUERY,
232
+ metaScore,
233
+ dataScore,
234
+ ambiguous: false,
235
+ };
236
+ }
237
+ if (metaScore > 0 && dataScore > 0) {
238
+ if (dataScore >= metaScore * 2) {
239
+ return {
240
+ intent: LegendAIQuestionIntent.DATA_QUERY,
241
+ metaScore,
242
+ dataScore,
243
+ ambiguous: false,
244
+ };
245
+ }
246
+ if (PRODUCT_REFERENCE_PATTERN.test(q) ||
247
+ STRUCTURAL_KEYWORD_PATTERN.test(q)) {
248
+ return {
249
+ intent: LegendAIQuestionIntent.METADATA,
250
+ metaScore,
251
+ dataScore,
252
+ ambiguous: false,
253
+ };
254
+ }
255
+ const tentative = metaScore > dataScore
256
+ ? LegendAIQuestionIntent.METADATA
257
+ : LegendAIQuestionIntent.DATA_QUERY;
258
+ return {
259
+ intent: tentative,
260
+ metaScore,
261
+ dataScore,
262
+ ambiguous: true,
263
+ };
264
+ }
265
+ return {
266
+ intent: hasServices
267
+ ? LegendAIQuestionIntent.DATA_QUERY
268
+ : LegendAIQuestionIntent.METADATA,
269
+ metaScore,
270
+ dataScore,
271
+ ambiguous: true,
272
+ };
273
+ }
274
+ /**
275
+ * Legacy synchronous classifier for backward compatibility.
276
+ * Returns just the intent, discarding ambiguity info.
277
+ */
278
+ export function classifyQuestionIntent(question, hasServices) {
279
+ return classifyQuestionIntentFast(question, hasServices).intent;
280
+ }
281
+ //# sourceMappingURL=LegendAITypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendAITypes.js","sourceRoot":"","sources":["../../src/legend-ai/LegendAITypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EACL,0CAA0C,GAE3C,MAAM,iDAAiD,CAAC;AAEzD,MAAM,OAAO,eAAe;IAC1B,IAAI,CAAU;IACd,IAAI,CAAU;IACd,aAAa,CAAU;IACvB,YAAY,CAAU;CACvB;AAED,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,2CAAmB,CAAA;IACnB,oDAA4B,CAAA;AAC9B,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B;AAED,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAU;IACf,WAAW,CAAU;IACrB,OAAO,CAAU;IACjB,OAAO,CAAqB;IAC5B,UAAU,CAAY;IACtB;;;;OAIG;IACH,UAAU,CAAwB;IAClC,0GAA0G;IAC1G,eAAe,CAAU;CAC1B;AAED,MAAM,OAAO,cAAc;IACzB,OAAO,CAAW;IAClB,aAAa,CAAsB;IACnC,YAAY,CAAsB;IAClC,eAAe,CAAsB;IACrC,eAAe,CAAsB;IACrC,oBAAoB,CAAsB;IAC1C,SAAS,CAAsB;IAC/B,qBAAqB,CAAU;IAC/B,gBAAgB,CAAU;IAC1B,gGAAgG;IAChG,oBAAoB,CAAU;CAC/B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0 +1,127 @@
1
+ /**
2
+ * Copyright (c) 2026-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { LegendApplicationPlugin, type LegendApplicationPluginManager } from '@finos/legend-application';
17
+ import type { QueryExplicitExecutionContextInfo, TDSRowDataType } from '@finos/legend-graph';
18
+ import type { TDSServiceSchema, LegendAIConfig, LegendAIConversationTurn, LegendAIProductMetadata, LegendAIQuestionIntent } from './LegendAITypes.js';
19
+ export declare class LegendAISqlExtractionResult {
20
+ sql: string | null;
21
+ failure: string | null;
22
+ suggestion?: string;
23
+ }
24
+ export declare enum LegendAIJudgeVerdict {
25
+ PASS = "PASS",
26
+ FAIL = "FAIL"
27
+ }
28
+ export declare class LegendAIJudgeResult {
29
+ verdict: LegendAIJudgeVerdict;
30
+ issues?: string;
31
+ correctedSql?: string;
32
+ }
33
+ export declare class LegendAISqlExecutionResultData {
34
+ columns: string[];
35
+ rows: TDSRowDataType[];
36
+ }
37
+ export declare class LegendAIOrchestratorDataProductCoordinates {
38
+ data_product: string;
39
+ group_id: string;
40
+ artifact_id: string;
41
+ version: string;
42
+ }
43
+ export interface LegendAISemanticSearchResolutionDetails {
44
+ data_product_coordinates: LegendAIOrchestratorDataProductCoordinates;
45
+ root_entity: string;
46
+ related_entities: string[];
47
+ }
48
+ export declare class LegendAIOrchestratorRequest {
49
+ user_question: string;
50
+ semantic_search_resolution_details: LegendAISemanticSearchResolutionDetails;
51
+ }
52
+ export declare class LegendAIOrchestratorResponse {
53
+ legend_query: string;
54
+ }
55
+ export declare class LegendAIResolvedEntities {
56
+ rootEntity: string;
57
+ relatedEntities: string[];
58
+ }
59
+ /**
60
+ * @deprecated Use {@link QueryExplicitExecutionContextInfo} from `@finos/legend-graph` directly.
61
+ */
62
+ export type LegendAIPureExecutionContext = QueryExplicitExecutionContextInfo;
63
+ export declare abstract class LegendAI_LegendApplicationPlugin_Extension extends LegendApplicationPlugin {
64
+ /**
65
+ * This helps to better type-check for this empty abstract type
66
+ * See https://github.com/finos/legend-studio/blob/master/docs/technical/typescript-usage.md#understand-typescript-structual-type-system
67
+ */
68
+ private readonly _$nominalTypeBrand;
69
+ install(pluginManager: LegendApplicationPluginManager<LegendApplicationPlugin>): void;
70
+ /**
71
+ * Classify the user question as either a data query or a metadata question.
72
+ *
73
+ * This is async to allow implementations to use an LLM micro-classifier
74
+ * for ambiguous questions while falling back to fast regex for clear-cut cases.
75
+ */
76
+ abstract classifyQuestionIntent(question: string, hasServices: boolean, config: LegendAIConfig, serviceNames?: string[]): Promise<LegendAIQuestionIntent>;
77
+ /**
78
+ * Build the LLM prompt for answering a metadata question about the product.
79
+ */
80
+ abstract buildMetadataPrompt(question: string, metadata: LegendAIProductMetadata, history?: LegendAIConversationTurn[]): string;
81
+ /**
82
+ * Build the LLM prompt for generating a SQL query from the user question.
83
+ */
84
+ abstract buildGeneratorPrompt(question: string, services: TDSServiceSchema[], coordinates: string, history?: LegendAIConversationTurn[]): string;
85
+ /**
86
+ * Build the LLM prompt for verifying and correcting a generated SQL query.
87
+ */
88
+ abstract buildJudgePrompt(sql: string, question: string, services: TDSServiceSchema[], coordinates: string, history?: LegendAIConversationTurn[]): string;
89
+ /**
90
+ * Send a prompt to the LLM service and return the raw response text.
91
+ */
92
+ abstract callLLM(prompt: string, config: LegendAIConfig): Promise<string>;
93
+ /**
94
+ * Execute a SQL query against the data platform and return tabular results.
95
+ */
96
+ abstract executeSql(sql: string, config: LegendAIConfig): Promise<LegendAISqlExecutionResultData>;
97
+ /**
98
+ * Parse the LLM generator response to extract the SQL query or failure reason.
99
+ */
100
+ abstract extractSqlFromResponse(answerText: string): LegendAISqlExtractionResult;
101
+ /**
102
+ * Parse the LLM judge response to extract the verdict and optional corrections.
103
+ */
104
+ abstract extractJudgeResult(answerText: string): LegendAIJudgeResult;
105
+ /**
106
+ * Call the Legend AI Orchestrator to generate a Legend/PURE query from
107
+ * natural language using resolved entity information.
108
+ */
109
+ abstract generateQueryViaOrchestrator(request: LegendAIOrchestratorRequest, config: LegendAIConfig): Promise<LegendAIOrchestratorResponse>;
110
+ /**
111
+ * Resolve root and related entities for a given user query within a data product.
112
+ * Uses the dataset search API to determine which entities are most relevant.
113
+ */
114
+ abstract resolveEntitiesForQuery(query: string, dataProductCoordinates: LegendAIOrchestratorDataProductCoordinates, config: LegendAIConfig): Promise<LegendAIResolvedEntities>;
115
+ /**
116
+ * Execute a Pure/Legend query against the engine and return tabular results.
117
+ * Converts the Pure expression text to a lambda, then executes it using
118
+ * the engine's execution endpoint with the provided execution context.
119
+ */
120
+ abstract executePureQuery(pureQuery: string, executionContext: QueryExplicitExecutionContextInfo, dataProductCoordinates: LegendAIOrchestratorDataProductCoordinates, config: LegendAIConfig): Promise<LegendAISqlExecutionResultData>;
121
+ /**
122
+ * Execute a SQL query that uses `p()` syntax against data product access points.
123
+ * Wraps the SQL in `#SQL{...}#`, builds a lakehouse runtime, and executes via the engine.
124
+ */
125
+ abstract executeLakehouseSql(sql: string, dataProductCoordinates: LegendAIOrchestratorDataProductCoordinates, config: LegendAIConfig): Promise<LegendAISqlExecutionResultData>;
126
+ }
127
+ //# sourceMappingURL=LegendAI_LegendApplicationPlugin_Extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendAI_LegendApplicationPlugin_Extension.d.ts","sourceRoot":"","sources":["../../src/legend-ai/LegendAI_LegendApplicationPlugin_Extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,uBAAuB,EACvB,KAAK,8BAA8B,EACpC,MAAM,2BA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,MAAM,GAAG,mBAAmB;IAEpE;;;OAGG;IACH,QAAQ,CAAC,4BAA4B,CACnC,OAAO,EAAE,2BAA2B,EACpC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,4BAA4B,CAAC;IAExC;;;OAGG;IACH,QAAQ,CAAC,uBAAuB,CAC9B,KAAK,EAAE,MAAM,EACb,sBAAsB,EAAE,0CAA0C,EAClE,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,wBAAwB,CAAC;IAEpC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CACvB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,iCAAiC,EACnD,sBAAsB,EAAE,0CAA0C,EAClE,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,8BAA8B,CAAC;IAE1C;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,CAC1B,GAAG,EAAE,MAAM,EACX,sBAAsB,EAAE,0CAA0C,EAClE,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,8BAA8B,CAAC;CAC3C"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) 2026-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { LegendApplicationPlugin, } from '@finos/legend-application';
17
+ export class LegendAISqlExtractionResult {
18
+ sql;
19
+ failure;
20
+ suggestion;
21
+ }
22
+ export var LegendAIJudgeVerdict;
23
+ (function (LegendAIJudgeVerdict) {
24
+ LegendAIJudgeVerdict["PASS"] = "PASS";
25
+ LegendAIJudgeVerdict["FAIL"] = "FAIL";
26
+ })(LegendAIJudgeVerdict || (LegendAIJudgeVerdict = {}));
27
+ export class LegendAIJudgeResult {
28
+ verdict;
29
+ issues;
30
+ correctedSql;
31
+ }
32
+ export class LegendAISqlExecutionResultData {
33
+ columns;
34
+ rows;
35
+ }
36
+ export class LegendAIOrchestratorDataProductCoordinates {
37
+ data_product;
38
+ group_id;
39
+ artifact_id;
40
+ version;
41
+ }
42
+ export class LegendAIOrchestratorRequest {
43
+ user_question;
44
+ semantic_search_resolution_details;
45
+ }
46
+ export class LegendAIOrchestratorResponse {
47
+ legend_query;
48
+ }
49
+ export class LegendAIResolvedEntities {
50
+ rootEntity;
51
+ relatedEntities;
52
+ }
53
+ export class LegendAI_LegendApplicationPlugin_Extension extends LegendApplicationPlugin {
54
+ /**
55
+ * This helps to better type-check for this empty abstract type
56
+ * See https://github.com/finos/legend-studio/blob/master/docs/technical/typescript-usage.md#understand-typescript-structual-type-system
57
+ */
58
+ _$nominalTypeBrand;
59
+ install(pluginManager) {
60
+ pluginManager.registerApplicationPlugin(this);
61
+ }
62
+ }
63
+ //# sourceMappingURL=LegendAI_LegendApplicationPlugin_Extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendAI_LegendApplicationPlugin_Extension.js","sourceRoot":"","sources":["../../src/legend-ai/LegendAI_LegendApplicationPlugin_Extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,uBAAuB,GAExB,MAAM,2BAA2B,CAAC;AAanC,MAAM,OAAO,2BAA2B;IACtC,GAAG,CAAiB;IACpB,OAAO,CAAiB;IACxB,UAAU,CAAU;CACrB;AAED,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B;AAED,MAAM,OAAO,mBAAmB;IAC9B,OAAO,CAAwB;IAC/B,MAAM,CAAU;IAChB,YAAY,CAAU;CACvB;AAED,MAAM,OAAO,8BAA8B;IACzC,OAAO,CAAY;IACnB,IAAI,CAAoB;CACzB;AAED,MAAM,OAAO,0CAA0C;IACrD,YAAY,CAAU;IACtB,QAAQ,CAAU;IAClB,WAAW,CAAU;IACrB,OAAO,CAAU;CAClB;AAQD,MAAM,OAAO,2BAA2B;IACtC,aAAa,CAAU;IACvB,kCAAkC,CAA2C;CAC9E;AAED,MAAM,OAAO,4BAA4B;IACvC,YAAY,CAAU;CACvB;AAED,MAAM,OAAO,wBAAwB;IACnC,UAAU,CAAU;IACpB,eAAe,CAAY;CAC5B;AAOD,MAAM,OAAgB,0CAA2C,SAAQ,uBAAuB;IAC9F;;;OAGG;IACc,kBAAkB,CAAgD;IAEnF,OAAO,CACL,aAAsE;QAEtE,aAAa,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;CA8GF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) 2026-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { MessageSetter } from '../stores/LegendAIChatState.js';
17
+ import { type LegendAIMessage, type LegendAIAssistantMessage, type LegendAIConfig, type LegendAIProductMetadata, type TDSServiceSchema } from '../LegendAITypes.js';
18
+ import { type LegendAI_LegendApplicationPlugin_Extension } from '../LegendAI_LegendApplicationPlugin_Extension.js';
19
+ export declare const TEST__createMockSetter: () => {
20
+ setter: MessageSetter;
21
+ getMessages: () => LegendAIMessage[];
22
+ };
23
+ export declare const TEST__makeAssistantMessage: (overrides?: Partial<LegendAIAssistantMessage>) => LegendAIAssistantMessage;
24
+ export declare const TEST__seedAssistant: (setter: MessageSetter) => void;
25
+ export declare const TEST_DATA__legendAIConfig: LegendAIConfig;
26
+ export declare const TEST_DATA__legendAIMetadata: LegendAIProductMetadata;
27
+ export declare const TEST_DATA__legendAIServices: TDSServiceSchema[];
28
+ export declare const TEST__createMockLegendAIPlugin: (overrides?: Partial<LegendAI_LegendApplicationPlugin_Extension>) => LegendAI_LegendApplicationPlugin_Extension;
29
+ //# sourceMappingURL=LegendAITestUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendAITestUtils.d.ts","sourceRoot":"","sources":["../../../src/legend-ai/__test-utils__/LegendAITestUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAItB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,0CAA0C,EAIhD,MAAM,kDAAkD,CAAC;AAE1D,eAAO,MAAM,sBAAsB,QAAO;IACxC,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,MAAM,eAAe,EAAE,CAAC;CAWtC,CAAC;AACF,eAAO,MAAM,0BAA0B,GACrC,YAAY,OAAO,CAAC,wBAAwB,CAAC,KAC5C,wBAeD,CAAC;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,aAAa,KAAG,IAK3D,CAAC;AACF,eAAO,MAAM,yBAAyB,EAAE,cASvC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,uBAIzC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,gBAAgB,EAUzD,CAAC;AACF,eAAO,MAAM,8BAA8B,GACzC,YAAY,OAAO,CAAC,0CAA0C,CAAC,KAC9D,0CAmC+C,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Copyright (c) 2026-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { createMock } from '@finos/legend-shared/test';
17
+ import { LegendAIMessageRole, LegendAIQuestionIntent, } from '../LegendAITypes.js';
18
+ import { LegendAIJudgeVerdict, } from '../LegendAI_LegendApplicationPlugin_Extension.js';
19
+ export const TEST__createMockSetter = () => {
20
+ let messages = [];
21
+ const setter = (action) => {
22
+ if (typeof action === 'function') {
23
+ messages = action(messages);
24
+ }
25
+ else {
26
+ messages = action;
27
+ }
28
+ };
29
+ return { setter, getMessages: () => messages };
30
+ };
31
+ export const TEST__makeAssistantMessage = (overrides) => ({
32
+ id: 'test-assistant-msg',
33
+ role: LegendAIMessageRole.ASSISTANT,
34
+ thinkingSteps: [],
35
+ sql: null,
36
+ textAnswer: null,
37
+ gridData: null,
38
+ error: null,
39
+ sqlGenTime: null,
40
+ execTime: null,
41
+ thinkingDuration: null,
42
+ isProcessing: true,
43
+ isExecuting: false,
44
+ suggestedQueries: [],
45
+ ...overrides,
46
+ });
47
+ export const TEST__seedAssistant = (setter) => {
48
+ setter([
49
+ { id: 'test-user-msg', role: LegendAIMessageRole.USER, text: 'test' },
50
+ TEST__makeAssistantMessage(),
51
+ ]);
52
+ };
53
+ export const TEST_DATA__legendAIConfig = {
54
+ enabled: true,
55
+ llmServiceUrl: 'http://localhost/llm',
56
+ llmModelName: 'test-model',
57
+ sqlExecutionUrl: 'http://localhost/sql',
58
+ orchestratorUrl: undefined,
59
+ marketplaceSearchUrl: undefined,
60
+ engineUrl: undefined,
61
+ maxJudgeAttempts: 2,
62
+ };
63
+ export const TEST_DATA__legendAIMetadata = {
64
+ name: 'TestProduct',
65
+ coordinates: 'com.test:prod:1.0.0',
66
+ serviceSummaries: [{ title: 'Svc', description: 'desc' }],
67
+ };
68
+ export const TEST_DATA__legendAIServices = [
69
+ {
70
+ title: 'TradeService',
71
+ pattern: '/trades',
72
+ columns: [
73
+ { name: 'tradeId', type: 'String' },
74
+ { name: 'amount', type: 'Number' },
75
+ ],
76
+ parameters: [],
77
+ },
78
+ ];
79
+ export const TEST__createMockLegendAIPlugin = (overrides) => ({
80
+ getName: () => 'test-plugin',
81
+ getVersion: () => '1.0.0',
82
+ install: () => { },
83
+ classifyQuestionIntent: (_q, _h) => LegendAIQuestionIntent.DATA_QUERY,
84
+ buildMetadataPrompt: (_q, _m, _h) => 'metadata prompt',
85
+ buildGeneratorPrompt: (_q, _s, _c, _h) => 'generator prompt',
86
+ buildJudgePrompt: (_sql, _q, _s, _c, _h) => 'judge prompt',
87
+ callLLM: createMock(),
88
+ executeSql: createMock(),
89
+ extractSqlFromResponse: (_a) => ({
90
+ sql: 'SELECT * FROM t',
91
+ failure: null,
92
+ }),
93
+ extractJudgeResult: (_a) => ({
94
+ verdict: LegendAIJudgeVerdict.PASS,
95
+ }),
96
+ ...overrides,
97
+ });
98
+ //# sourceMappingURL=LegendAITestUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendAITestUtils.js","sourceRoot":"","sources":["../../../src/legend-ai/__test-utils__/LegendAITestUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAOL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,oBAAoB,GACrB,MAAM,kDAAkD,CAAC;AAE1D,MAAM,CAAC,MAAM,sBAAsB,GAAG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E,CAAC,CAAC;QACpE,GAAG,EAAE,iBAAiB;QACtB,OAAO,EAAE,IAAI;KACd,CAAC;IACF,kBAAkB,EAAE,CAAC,EAAU,EAAuB,EAAE,CAAC,CAAC;QACxD,OAAO,EAAE,oBAAoB,CAAC,IAAI;KACnC,CAAC;IACF,GAAG,SAAS;CACb,CAA+C,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) 2026-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { type LegendAIChatProps, type LegendAIProductMetadata, type TDSServiceSchema, type TDSColumnSchema } from '../LegendAITypes.js';
17
+ export declare const LEGEND_AI_ANCHOR_ID = "legend-ai-anchor";
18
+ export declare function isStringColumn(c: TDSColumnSchema): boolean;
19
+ export declare function isNumericColumn(c: TDSColumnSchema): boolean;
20
+ export declare function isDateColumn(c: TDSColumnSchema): boolean;
21
+ export declare function buildSuggestedQueries(services: TDSServiceSchema[], metadata: LegendAIProductMetadata): string[];
22
+ export declare const LegendAIChat: (props: LegendAIChatProps) => React.ReactNode;
23
+ //# sourceMappingURL=LegendAIChat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendAIChat.d.ts","sourceRoot":"","sources":["../../../src/legend-ai/components/LegendAIChat.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAeH,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAIrB,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAoBtD,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAE1D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAE3D;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAMxD;AAwDD,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,QAAQ,EAAE,uBAAuB,GAChC,MAAM,EAAE,CAqCV;AAmLD,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,KAAG,KAAK,CAAC,SAsJ7D,CAAC"}