agentlang 0.9.5 → 0.9.7
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/out/cli/main.d.ts.map +1 -1
- package/out/cli/main.js +8 -3
- package/out/cli/main.js.map +1 -1
- package/out/language/generated/ast.d.ts +80 -3
- package/out/language/generated/ast.d.ts.map +1 -1
- package/out/language/generated/ast.js +62 -0
- package/out/language/generated/ast.js.map +1 -1
- package/out/language/generated/grammar.d.ts.map +1 -1
- package/out/language/generated/grammar.js +432 -218
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/main.cjs +485 -218
- package/out/language/main.cjs.map +2 -2
- package/out/language/parser.js +8 -8
- package/out/language/parser.js.map +1 -1
- package/out/runtime/agents/common.d.ts +7 -1
- package/out/runtime/agents/common.d.ts.map +1 -1
- package/out/runtime/agents/common.js +101 -0
- package/out/runtime/agents/common.js.map +1 -1
- package/out/runtime/agents/impl/anthropic.js +4 -4
- package/out/runtime/agents/impl/anthropic.js.map +1 -1
- package/out/runtime/agents/impl/openai.js +4 -4
- package/out/runtime/agents/impl/openai.js.map +1 -1
- package/out/runtime/docs.d.ts.map +1 -1
- package/out/runtime/docs.js +109 -7
- package/out/runtime/docs.js.map +1 -1
- package/out/runtime/embeddings/chunker.d.ts +9 -0
- package/out/runtime/embeddings/chunker.d.ts.map +1 -0
- package/out/runtime/embeddings/chunker.js +41 -0
- package/out/runtime/embeddings/chunker.js.map +1 -0
- package/out/runtime/embeddings/index.d.ts +6 -0
- package/out/runtime/embeddings/index.d.ts.map +1 -0
- package/out/runtime/embeddings/index.js +6 -0
- package/out/runtime/embeddings/index.js.map +1 -0
- package/out/runtime/embeddings/openai.d.ts +15 -0
- package/out/runtime/embeddings/openai.d.ts.map +1 -0
- package/out/runtime/embeddings/openai.js +34 -0
- package/out/runtime/embeddings/openai.js.map +1 -0
- package/out/runtime/embeddings/provider.d.ts +20 -0
- package/out/runtime/embeddings/provider.d.ts.map +1 -0
- package/out/runtime/embeddings/provider.js +17 -0
- package/out/runtime/embeddings/provider.js.map +1 -0
- package/out/runtime/embeddings/registry.d.ts +3 -0
- package/out/runtime/embeddings/registry.d.ts.map +1 -0
- package/out/runtime/embeddings/registry.js +16 -0
- package/out/runtime/embeddings/registry.js.map +1 -0
- package/out/runtime/exec-graph.d.ts.map +1 -1
- package/out/runtime/exec-graph.js +5 -0
- package/out/runtime/exec-graph.js.map +1 -1
- package/out/runtime/interpreter.d.ts +4 -0
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +27 -7
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/loader.d.ts.map +1 -1
- package/out/runtime/loader.js +42 -5
- package/out/runtime/loader.js.map +1 -1
- package/out/runtime/module.d.ts +22 -4
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +76 -10
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.d.ts +20 -2
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +333 -37
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/auth.d.ts.map +1 -1
- package/out/runtime/modules/auth.js +11 -5
- package/out/runtime/modules/auth.js.map +1 -1
- package/out/runtime/resolvers/interface.d.ts +1 -1
- package/out/runtime/resolvers/interface.d.ts.map +1 -1
- package/out/runtime/resolvers/interface.js.map +1 -1
- package/out/runtime/resolvers/sqldb/database.d.ts +1 -1
- package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -1
- package/out/runtime/resolvers/sqldb/database.js +139 -50
- package/out/runtime/resolvers/sqldb/database.js.map +1 -1
- package/out/runtime/resolvers/sqldb/impl.d.ts +22 -2
- package/out/runtime/resolvers/sqldb/impl.d.ts.map +1 -1
- package/out/runtime/resolvers/sqldb/impl.js +178 -47
- package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
- package/out/runtime/state.d.ts +1 -0
- package/out/runtime/state.d.ts.map +1 -1
- package/out/runtime/state.js +3 -0
- package/out/runtime/state.js.map +1 -1
- package/out/syntaxes/agentlang.monarch.js +1 -1
- package/out/syntaxes/agentlang.monarch.js.map +1 -1
- package/package.json +188 -185
- package/public/pdf.worker.mjs +65152 -0
- package/src/cli/main.ts +7 -2
- package/src/language/agentlang.langium +8 -2
- package/src/language/generated/ast.ts +96 -2
- package/src/language/generated/grammar.ts +432 -218
- package/src/language/parser.ts +8 -8
- package/src/runtime/agents/common.ts +107 -0
- package/src/runtime/agents/impl/anthropic.ts +4 -4
- package/src/runtime/agents/impl/openai.ts +4 -4
- package/src/runtime/docs.ts +120 -9
- package/src/runtime/embeddings/chunker.ts +50 -0
- package/src/runtime/embeddings/index.ts +5 -0
- package/src/runtime/embeddings/openai.ts +49 -0
- package/src/runtime/embeddings/provider.ts +37 -0
- package/src/runtime/embeddings/registry.ts +17 -0
- package/src/runtime/exec-graph.ts +4 -0
- package/src/runtime/interpreter.ts +39 -16
- package/src/runtime/loader.ts +42 -3
- package/src/runtime/module.ts +127 -41
- package/src/runtime/modules/ai.ts +467 -38
- package/src/runtime/modules/auth.ts +11 -5
- package/src/runtime/resolvers/interface.ts +1 -1
- package/src/runtime/resolvers/sqldb/database.ts +146 -56
- package/src/runtime/resolvers/sqldb/impl.ts +238 -61
- package/src/runtime/state.ts +4 -0
- package/src/syntaxes/agentlang.monarch.ts +1 -1
- package/out/setupClassic.d.ts +0 -98
- package/out/setupClassic.d.ts.map +0 -1
- package/out/setupClassic.js +0 -38
- package/out/setupClassic.js.map +0 -1
- package/out/setupCommon.d.ts +0 -2
- package/out/setupCommon.d.ts.map +0 -1
- package/out/setupCommon.js +0 -33
- package/out/setupCommon.js.map +0 -1
- package/out/setupExtended.d.ts +0 -40
- package/out/setupExtended.d.ts.map +0 -1
- package/out/setupExtended.js +0 -67
- package/out/setupExtended.js.map +0 -1
|
@@ -25,32 +25,96 @@ import {
|
|
|
25
25
|
import { JoinInfo, Resolver, WhereClause } from '../interface.js';
|
|
26
26
|
import { asColumnReference, asTableReference } from './dbutil.js';
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
insertRow,
|
|
30
|
-
updateRow,
|
|
31
|
-
getAllConnected,
|
|
32
|
-
startDbTransaction,
|
|
28
|
+
addRowForFullTextSearch,
|
|
33
29
|
commitDbTransaction,
|
|
34
|
-
rollbackDbTransaction,
|
|
35
|
-
hardDeleteRow,
|
|
36
30
|
DbContext,
|
|
37
|
-
insertBetweenRow,
|
|
38
|
-
addRowForFullTextSearch,
|
|
39
|
-
vectorStoreSearch,
|
|
40
|
-
vectorStoreSearchEntryExists,
|
|
41
31
|
deleteFullTextSearchEntry,
|
|
32
|
+
getAllConnected,
|
|
33
|
+
getMany,
|
|
34
|
+
getManyByJoin,
|
|
35
|
+
hardDeleteRow,
|
|
36
|
+
insertBetweenRow,
|
|
37
|
+
insertRow,
|
|
38
|
+
isVectorStoreSupported,
|
|
42
39
|
JoinClause,
|
|
43
40
|
JoinOn,
|
|
44
41
|
makeJoinOn,
|
|
45
|
-
getManyByJoin,
|
|
46
42
|
QuerySpec,
|
|
43
|
+
rollbackDbTransaction,
|
|
44
|
+
startDbTransaction,
|
|
45
|
+
updateRow,
|
|
46
|
+
vectorStoreSearch,
|
|
47
|
+
vectorStoreSearchEntryExists,
|
|
47
48
|
} from './database.js';
|
|
48
49
|
import { AggregateFunctionCall, Environment } from '../../interpreter.js';
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
import {
|
|
51
|
+
DeletedFlagAttributeName,
|
|
52
|
+
ParentAttributeName,
|
|
53
|
+
PathAttributeName,
|
|
54
|
+
TenantAttributeName,
|
|
55
|
+
} from '../../defs.js';
|
|
52
56
|
import { logger } from '../../logger.js';
|
|
53
57
|
import { JoinSpec } from '../../../language/generated/ast.js';
|
|
58
|
+
import { EmbeddingProvider, EmbeddingProviderConfig } from '../../embeddings/provider.js';
|
|
59
|
+
import { embeddingProvider } from '../../embeddings/registry.js';
|
|
60
|
+
import { TextChunker } from '../../embeddings/chunker.js';
|
|
61
|
+
|
|
62
|
+
interface EmbeddingServiceConfig extends EmbeddingProviderConfig {
|
|
63
|
+
provider?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class EmbeddingService {
|
|
67
|
+
private provider: EmbeddingProvider;
|
|
68
|
+
private config: EmbeddingServiceConfig;
|
|
69
|
+
private chunker: TextChunker;
|
|
70
|
+
|
|
71
|
+
constructor(config?: EmbeddingServiceConfig) {
|
|
72
|
+
this.config = config || {};
|
|
73
|
+
const providerClass = embeddingProvider(this.config.provider || 'openai');
|
|
74
|
+
this.provider = new providerClass(this.config);
|
|
75
|
+
this.chunker = new TextChunker(this.getChunkSize(), this.getChunkOverlap());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private getChunkSize(): number {
|
|
79
|
+
return this.config.chunkSize || 1000;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private getChunkOverlap(): number {
|
|
83
|
+
return this.config.chunkOverlap || 200;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async embedText(text: string): Promise<number[]> {
|
|
87
|
+
const chunks = this.chunker.splitText(text);
|
|
88
|
+
|
|
89
|
+
if (chunks.length === 1) {
|
|
90
|
+
return await this.provider.embedText(chunks[0]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const chunkEmbeddings = await Promise.all(
|
|
94
|
+
chunks.map((chunk: string) => this.provider.embedText(chunk))
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return this.averageEmbeddings(chunkEmbeddings);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async embedQuery(query: string): Promise<number[]> {
|
|
101
|
+
return await this.provider.embedText(query);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private averageEmbeddings(embeddings: number[][]): number[] {
|
|
105
|
+
if (embeddings.length === 0) return [];
|
|
106
|
+
const dimension = embeddings[0].length;
|
|
107
|
+
const averaged = new Array(dimension).fill(0);
|
|
108
|
+
|
|
109
|
+
for (const embedding of embeddings) {
|
|
110
|
+
for (let i = 0; i < dimension; i++) {
|
|
111
|
+
averaged[i] += embedding[i];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return averaged.map((v: number) => v / embeddings.length);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
54
118
|
|
|
55
119
|
function maybeFindIdAttributeName(inst: Instance): string | undefined {
|
|
56
120
|
const attrEntry: AttributeEntry | undefined = findIdAttribute(inst);
|
|
@@ -62,12 +126,18 @@ function maybeFindIdAttributeName(inst: Instance): string | undefined {
|
|
|
62
126
|
|
|
63
127
|
export class SqlDbResolver extends Resolver {
|
|
64
128
|
private txnId: string | undefined;
|
|
65
|
-
private
|
|
129
|
+
private _embeddingService: EmbeddingService | undefined;
|
|
66
130
|
|
|
67
131
|
constructor(name: string) {
|
|
68
132
|
super();
|
|
69
133
|
this.name = name;
|
|
70
|
-
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private get embeddingService(): EmbeddingService {
|
|
137
|
+
if (!this._embeddingService) {
|
|
138
|
+
this._embeddingService = new EmbeddingService();
|
|
139
|
+
}
|
|
140
|
+
return this._embeddingService;
|
|
71
141
|
}
|
|
72
142
|
|
|
73
143
|
public override getName(): string {
|
|
@@ -93,6 +163,45 @@ export class SqlDbResolver extends Resolver {
|
|
|
93
163
|
return entryName;
|
|
94
164
|
}
|
|
95
165
|
|
|
166
|
+
private extractTextForEmbedding(rowObj: object, searchAttributes: string[] | undefined): string {
|
|
167
|
+
const obj = rowObj as Record<string, any>;
|
|
168
|
+
const ftsAttrs =
|
|
169
|
+
!searchAttributes || searchAttributes.length === 0 || searchAttributes[0] === '*'
|
|
170
|
+
? Object.keys(obj).filter(k => this.shouldIncludeAttribute(k))
|
|
171
|
+
: searchAttributes;
|
|
172
|
+
|
|
173
|
+
const parts: string[] = [];
|
|
174
|
+
for (const attr of ftsAttrs) {
|
|
175
|
+
const value = obj[attr];
|
|
176
|
+
if (value !== undefined && value !== null) {
|
|
177
|
+
parts.push(this.valueToString(value));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return parts.join(' ');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private shouldIncludeAttribute(key: string): boolean {
|
|
185
|
+
const excludedAttrs = [
|
|
186
|
+
PathAttributeName,
|
|
187
|
+
DeletedFlagAttributeName,
|
|
188
|
+
TenantAttributeName,
|
|
189
|
+
'__tenant__',
|
|
190
|
+
'__is_deleted__',
|
|
191
|
+
];
|
|
192
|
+
return !excludedAttrs.includes(key);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private valueToString(value: any): string {
|
|
196
|
+
if (Array.isArray(value)) {
|
|
197
|
+
return value.join(' ');
|
|
198
|
+
}
|
|
199
|
+
if (typeof value === 'object' && value !== null) {
|
|
200
|
+
return JSON.stringify(value);
|
|
201
|
+
}
|
|
202
|
+
return String(value);
|
|
203
|
+
}
|
|
204
|
+
|
|
96
205
|
private async insertInstance(inst: Instance, orUpdate = false): Promise<Instance> {
|
|
97
206
|
const ctx = this.getDbContext(inst.getFqName());
|
|
98
207
|
if (isBetweenRelationship(inst.name, inst.moduleName)) {
|
|
@@ -107,35 +216,43 @@ export class SqlDbResolver extends Resolver {
|
|
|
107
216
|
ctx.activeEnv.isInDeleteMode()
|
|
108
217
|
);
|
|
109
218
|
return inst;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
219
|
+
}
|
|
220
|
+
const idAttrName: string | undefined = maybeFindIdAttributeName(inst);
|
|
221
|
+
ensureOneToOneAttributes(inst);
|
|
222
|
+
const attrs: InstanceAttributes = inst.attributes;
|
|
223
|
+
const idAttrVal: any = idAttrName ? attrs.get(idAttrName) : crypto.randomUUID();
|
|
224
|
+
if (idAttrVal !== undefined) {
|
|
225
|
+
const pp: string | undefined = attrs.get(PathAttributeName);
|
|
226
|
+
const n: string = `${inst.moduleName}/${inst.name}`;
|
|
227
|
+
let p: string = '';
|
|
228
|
+
if (pp !== undefined) p = `${pp}/${escapeFqName(n)}/${idAttrVal}`;
|
|
229
|
+
else p = `${n.replace('/', '$')}/${idAttrVal}`;
|
|
230
|
+
attrs.set(PathAttributeName, p);
|
|
231
|
+
}
|
|
232
|
+
const n: string = asTableReference(inst.moduleName, inst.name);
|
|
233
|
+
const rowObj: object = inst.attributesWithStringifiedObjects();
|
|
234
|
+
await insertRow(n, rowObj, ctx, orUpdate);
|
|
235
|
+
if (inst.record.getEmbeddingConfig() || inst.record.getFullTextSearchAttributes()) {
|
|
236
|
+
const path = attrs.get(PathAttributeName);
|
|
237
|
+
try {
|
|
238
|
+
if (
|
|
239
|
+
(await isVectorStoreSupported()) &&
|
|
240
|
+
!(await vectorStoreSearchEntryExists(n, path, ctx))
|
|
241
|
+
) {
|
|
242
|
+
const ftsAttrs = inst.record.getFullTextSearchAttributes() || ['*'];
|
|
243
|
+
const textToEmbed = this.extractTextForEmbedding(rowObj, ftsAttrs);
|
|
244
|
+
const embeddingConfig = inst.record.getEmbeddingConfig();
|
|
245
|
+
const embeddingService = embeddingConfig
|
|
246
|
+
? new EmbeddingService(embeddingConfig)
|
|
247
|
+
: this.embeddingService;
|
|
248
|
+
const res = await embeddingService.embedText(textToEmbed);
|
|
249
|
+
await addRowForFullTextSearch(n, path, res, ctx);
|
|
135
250
|
}
|
|
251
|
+
} catch (reason: any) {
|
|
252
|
+
logger.warn(`Full text indexing failed for ${path} - ${reason}`);
|
|
136
253
|
}
|
|
137
|
-
return inst;
|
|
138
254
|
}
|
|
255
|
+
return inst;
|
|
139
256
|
}
|
|
140
257
|
|
|
141
258
|
public override async createInstance(inst: Instance): Promise<Instance> {
|
|
@@ -211,9 +328,42 @@ export class SqlDbResolver extends Resolver {
|
|
|
211
328
|
: undefined;
|
|
212
329
|
const orderByDesc = inst.orderByDesc ? 'DESC' : 'ASC';
|
|
213
330
|
const aggregates = SqlDbResolver.normalizedAggregates(inst, tableName);
|
|
331
|
+
|
|
332
|
+
let vectorResult: Instance[] | undefined;
|
|
333
|
+
const embeddingConfig = inst.record.getEmbeddingConfig();
|
|
334
|
+
const ftsAttrs = inst.record.getFullTextSearchAttributes();
|
|
335
|
+
if (
|
|
336
|
+
(await isVectorStoreSupported()) &&
|
|
337
|
+
embeddingConfig &&
|
|
338
|
+
qattrs &&
|
|
339
|
+
(ftsAttrs || Object.keys(qattrs).some(k => k.endsWith('?')))
|
|
340
|
+
) {
|
|
341
|
+
const vectorSearchAttr = Object.keys(qattrs).find(k => k.endsWith('?'));
|
|
342
|
+
if (vectorSearchAttr) {
|
|
343
|
+
const queryVal = qvals[vectorSearchAttr];
|
|
344
|
+
const searchString = this.valueToString(queryVal);
|
|
345
|
+
const embeddingService = new EmbeddingService(embeddingConfig);
|
|
346
|
+
const queryVec = await embeddingService.embedQuery(searchString);
|
|
347
|
+
const rslt: any = await vectorStoreSearch(tableName, queryVec, 10, ctx);
|
|
348
|
+
if (rslt instanceof Array) {
|
|
349
|
+
vectorResult = new Array<Instance>();
|
|
350
|
+
rslt.forEach((r: any) => {
|
|
351
|
+
const attrs: InstanceAttributes = maybeNormalizeAttributeNames(
|
|
352
|
+
tableName,
|
|
353
|
+
new Map(Object.entries(r))
|
|
354
|
+
);
|
|
355
|
+
attrs.delete(DeletedFlagAttributeName);
|
|
356
|
+
vectorResult!.push(Instance.newWithAttributes(inst, attrs));
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
delete qattrs[vectorSearchAttr];
|
|
360
|
+
delete qvals[vectorSearchAttr];
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
214
364
|
const qspec: QuerySpec = {
|
|
215
|
-
queryObj: qattrs,
|
|
216
|
-
queryVals: qvals,
|
|
365
|
+
queryObj: Object.keys(qattrs || {}).length > 0 ? qattrs : undefined,
|
|
366
|
+
queryVals: Object.keys(qvals || {}).length > 0 ? qvals : undefined,
|
|
217
367
|
distinct,
|
|
218
368
|
groupBy,
|
|
219
369
|
orderBy,
|
|
@@ -224,20 +374,47 @@ export class SqlDbResolver extends Resolver {
|
|
|
224
374
|
whereClauses: undefined,
|
|
225
375
|
};
|
|
226
376
|
const readOnlyAttrs = inst.record.getWriteOnlyAttributes();
|
|
227
|
-
const rslt: any =
|
|
377
|
+
const rslt: any =
|
|
378
|
+
vectorResult !== undefined && qspec.queryObj === undefined
|
|
379
|
+
? vectorResult
|
|
380
|
+
: await getMany(tableName, qspec, ctx);
|
|
228
381
|
if (rslt instanceof Array) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
382
|
+
if (vectorResult !== undefined && qspec.queryObj !== undefined) {
|
|
383
|
+
// Merge results if both vector and standard queries were performed
|
|
384
|
+
const vectorPaths = new Set(vectorResult.map(i => i.lookup(PathAttributeName)));
|
|
385
|
+
result = new Array<Instance>();
|
|
386
|
+
rslt.forEach((r: any) => {
|
|
387
|
+
const attrs: InstanceAttributes = maybeNormalizeAttributeNames(
|
|
388
|
+
tableName,
|
|
389
|
+
new Map(Object.entries(r))
|
|
390
|
+
);
|
|
391
|
+
if (vectorPaths.has(attrs.get(PathAttributeName))) {
|
|
392
|
+
attrs.delete(DeletedFlagAttributeName);
|
|
393
|
+
readOnlyAttrs?.forEach((n: string) => {
|
|
394
|
+
attrs.delete(n);
|
|
395
|
+
});
|
|
396
|
+
result.push(Instance.newWithAttributes(inst, attrs));
|
|
397
|
+
}
|
|
238
398
|
});
|
|
239
|
-
|
|
240
|
-
|
|
399
|
+
} else {
|
|
400
|
+
result =
|
|
401
|
+
vectorResult !== undefined && qspec.queryObj === undefined
|
|
402
|
+
? vectorResult
|
|
403
|
+
: new Array<Instance>();
|
|
404
|
+
if (vectorResult === undefined || qspec.queryObj !== undefined) {
|
|
405
|
+
rslt.forEach((r: any) => {
|
|
406
|
+
const attrs: InstanceAttributes = maybeNormalizeAttributeNames(
|
|
407
|
+
tableName,
|
|
408
|
+
new Map(Object.entries(r))
|
|
409
|
+
);
|
|
410
|
+
attrs.delete(DeletedFlagAttributeName);
|
|
411
|
+
readOnlyAttrs?.forEach((n: string) => {
|
|
412
|
+
attrs.delete(n);
|
|
413
|
+
});
|
|
414
|
+
result.push(Instance.newWithAttributes(inst, attrs));
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
241
418
|
}
|
|
242
419
|
return result;
|
|
243
420
|
}
|
|
@@ -553,13 +730,13 @@ export class SqlDbResolver extends Resolver {
|
|
|
553
730
|
entryName: string,
|
|
554
731
|
moduleName: string,
|
|
555
732
|
query: string,
|
|
556
|
-
options?:
|
|
733
|
+
options?: any
|
|
557
734
|
): Promise<any> {
|
|
558
|
-
const queryVec = await this.
|
|
735
|
+
const queryVec = await this.embeddingService.embedQuery(query);
|
|
559
736
|
const ctx = this.getDbContext(makeFqName(moduleName, entryName));
|
|
560
737
|
let limit = 5;
|
|
561
|
-
if (options && options.
|
|
562
|
-
limit = options.
|
|
738
|
+
if (options && options.limit) {
|
|
739
|
+
limit = options.limit as number;
|
|
563
740
|
}
|
|
564
741
|
return await vectorStoreSearch(asTableReference(moduleName, entryName), queryVec, limit, ctx);
|
|
565
742
|
}
|
package/src/runtime/state.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Monarch syntax highlighting for the agentlang language.
|
|
2
2
|
export default {
|
|
3
3
|
keywords: [
|
|
4
|
-
'@actions','@after','@as','@asc','@async','@before','@catch','@desc','@distinct','@enum','@expr','@from','@full_join','@groupBy','@inner_join','@into','@join','@left_join','@meta','@oneof','@orderBy','@public','@rbac','@ref','@right_join','@then','@upsert','@where','@with_unique','agent','agentlang/retry','allow','and','attempts','await','backoff','between','case','commitTransaction','contains','create','decision','delete','directive','else','entity','error','event','extends','false','flow','for','glossaryEntry','if','import','in','like','module','not','not_found','onSubscription','or','purge','query','read','record','relationship','resolver','return','roles','rollbackTransaction','scenario','startTransaction','subscribe','throw','true','update','upsert','where','workflow'
|
|
4
|
+
'@actions','@after','@as','@asc','@async','@before','@catch','@desc','@distinct','@enum','@expr','@from','@full_join','@groupBy','@inner_join','@into','@join','@left_join','@meta','@oneof','@orderBy','@public','@rbac','@ref','@right_join','@then','@upsert','@where','@withRole','@with_unique','agent','agentlang/retry','allow','and','attempts','await','backoff','between','case','commitTransaction','contains','create','decision','delete','directive','else','entity','error','eval','event','extends','false','flow','for','glossaryEntry','if','import','in','like','module','not','not_found','onSubscription','or','purge','query','read','record','relationship','resolver','return','roles','rollbackTransaction','scenario','startTransaction','subscribe','throw','true','update','upsert','where','workflow'
|
|
5
5
|
],
|
|
6
6
|
operators: [
|
|
7
7
|
'!=','*','+',',','-','-->','.','/',':',';','<','<=','<>','=','==','>','>=','?','@'
|
package/out/setupClassic.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
export declare const setupConfigClassic: () => {
|
|
2
|
-
$type: string;
|
|
3
|
-
editorAppConfig: {
|
|
4
|
-
codeResources: {
|
|
5
|
-
modified: {
|
|
6
|
-
uri: string;
|
|
7
|
-
text: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
useDiffEditor: boolean;
|
|
11
|
-
languageDef: {
|
|
12
|
-
languageExtensionConfig: {
|
|
13
|
-
id: string;
|
|
14
|
-
};
|
|
15
|
-
monarchLanguage: {
|
|
16
|
-
keywords: string[];
|
|
17
|
-
operators: string[];
|
|
18
|
-
symbols: RegExp;
|
|
19
|
-
tokenizer: {
|
|
20
|
-
initial: ({
|
|
21
|
-
regex: RegExp;
|
|
22
|
-
action: {
|
|
23
|
-
cases: {
|
|
24
|
-
'@keywords': {
|
|
25
|
-
token: string;
|
|
26
|
-
};
|
|
27
|
-
'@default': {
|
|
28
|
-
token: string;
|
|
29
|
-
};
|
|
30
|
-
'@operators'?: undefined;
|
|
31
|
-
};
|
|
32
|
-
token?: undefined;
|
|
33
|
-
};
|
|
34
|
-
include?: undefined;
|
|
35
|
-
} | {
|
|
36
|
-
regex: RegExp;
|
|
37
|
-
action: {
|
|
38
|
-
token: string;
|
|
39
|
-
cases?: undefined;
|
|
40
|
-
};
|
|
41
|
-
include?: undefined;
|
|
42
|
-
} | {
|
|
43
|
-
include: string;
|
|
44
|
-
regex?: undefined;
|
|
45
|
-
action?: undefined;
|
|
46
|
-
} | {
|
|
47
|
-
regex: RegExp;
|
|
48
|
-
action: {
|
|
49
|
-
cases: {
|
|
50
|
-
'@operators': {
|
|
51
|
-
token: string;
|
|
52
|
-
};
|
|
53
|
-
'@default': {
|
|
54
|
-
token: string;
|
|
55
|
-
};
|
|
56
|
-
'@keywords'?: undefined;
|
|
57
|
-
};
|
|
58
|
-
token?: undefined;
|
|
59
|
-
};
|
|
60
|
-
include?: undefined;
|
|
61
|
-
})[];
|
|
62
|
-
whitespace: ({
|
|
63
|
-
regex: RegExp;
|
|
64
|
-
action: {
|
|
65
|
-
token: string;
|
|
66
|
-
next?: undefined;
|
|
67
|
-
};
|
|
68
|
-
} | {
|
|
69
|
-
regex: RegExp;
|
|
70
|
-
action: {
|
|
71
|
-
token: string;
|
|
72
|
-
next: string;
|
|
73
|
-
};
|
|
74
|
-
})[];
|
|
75
|
-
comment: ({
|
|
76
|
-
regex: RegExp;
|
|
77
|
-
action: {
|
|
78
|
-
token: string;
|
|
79
|
-
next?: undefined;
|
|
80
|
-
};
|
|
81
|
-
} | {
|
|
82
|
-
regex: RegExp;
|
|
83
|
-
action: {
|
|
84
|
-
token: string;
|
|
85
|
-
next: string;
|
|
86
|
-
};
|
|
87
|
-
})[];
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
editorOptions: {
|
|
92
|
-
'semanticHighlighting.enabled': boolean;
|
|
93
|
-
theme: string;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
export declare const executeClassic: (htmlElement: HTMLElement) => Promise<void>;
|
|
98
|
-
//# sourceMappingURL=setupClassic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupClassic.d.ts","sourceRoot":"","sources":["../src/setupClassic.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqB9B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,aAAa,WAAW,kBAgB5D,CAAC"}
|
package/out/setupClassic.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { MonacoEditorLanguageClientWrapper } from 'monaco-editor-wrapper';
|
|
2
|
-
import monarchSyntax from './syntaxes/agentlang.monarch.js';
|
|
3
|
-
export const setupConfigClassic = () => {
|
|
4
|
-
return {
|
|
5
|
-
$type: 'classic',
|
|
6
|
-
editorAppConfig: {
|
|
7
|
-
codeResources: {
|
|
8
|
-
modified: {
|
|
9
|
-
uri: '/workspace/example.al',
|
|
10
|
-
text: `// Agentlang is running in the web!`,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
useDiffEditor: false,
|
|
14
|
-
languageDef: {
|
|
15
|
-
languageExtensionConfig: { id: 'agentlang' },
|
|
16
|
-
monarchLanguage: monarchSyntax,
|
|
17
|
-
},
|
|
18
|
-
editorOptions: {
|
|
19
|
-
'semanticHighlighting.enabled': true,
|
|
20
|
-
theme: 'vs-dark',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export const executeClassic = async (htmlElement) => {
|
|
26
|
-
try {
|
|
27
|
-
const config = setupConfigClassic();
|
|
28
|
-
const wrapper = new MonacoEditorLanguageClientWrapper();
|
|
29
|
-
// Add the HTML container to the config
|
|
30
|
-
const wrapperConfig = Object.assign(Object.assign({}, config), { htmlContainer: htmlElement });
|
|
31
|
-
// Initialize and start the wrapper
|
|
32
|
-
await wrapper.initAndStart(wrapperConfig);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.error('Error initializing monaco editor:', error);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=setupClassic.js.map
|
package/out/setupClassic.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupClassic.js","sourceRoot":"","sources":["../src/setupClassic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAsB,MAAM,uBAAuB,CAAC;AAC9F,OAAO,aAAa,MAAM,iCAAiC,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO;QACL,KAAK,EAAE,SAAS;QAChB,eAAe,EAAE;YACf,aAAa,EAAE;gBACb,QAAQ,EAAE;oBACR,GAAG,EAAE,uBAAuB;oBAC5B,IAAI,EAAE,qCAAqC;iBAC5C;aACF;YACD,aAAa,EAAE,KAAK;YACpB,WAAW,EAAE;gBACX,uBAAuB,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE;gBAC5C,eAAe,EAAE,aAAa;aAC/B;YACD,aAAa,EAAE;gBACb,8BAA8B,EAAE,IAAI;gBACpC,KAAK,EAAE,SAAS;aACjB;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,WAAwB,EAAE,EAAE;IAC/D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,iCAAiC,EAAE,CAAC;QAExD,uCAAuC;QACvC,MAAM,aAAa,GAAG,gCACjB,MAAM,KACT,aAAa,EAAE,WAAW,GACV,CAAC;QAEnB,mCAAmC;QACnC,MAAM,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC"}
|
package/out/setupCommon.d.ts
DELETED
package/out/setupCommon.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupCommon.d.ts","sourceRoot":"","sources":["../src/setupCommon.ts"],"names":[],"mappings":""}
|
package/out/setupCommon.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// This file is kept for reference but is not used directly anymore
|
|
2
|
-
// The monaco-editor-wrapper API has changed significantly in v6+
|
|
3
|
-
export {};
|
|
4
|
-
// These functions are kept for reference but not used directly anymore
|
|
5
|
-
/*
|
|
6
|
-
export const defineUserServices = () => {
|
|
7
|
-
return {
|
|
8
|
-
userServices: {
|
|
9
|
-
// This API has changed in the latest version
|
|
10
|
-
},
|
|
11
|
-
debugLogging: true,
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const configureMonacoWorkers = () => {
|
|
16
|
-
// This function is kept for compatibility, but implementation has changed
|
|
17
|
-
// Use configureDefaultWorkerFactory from monaco-editor-wrapper/workers/workerLoaders in newer code
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const configureWorker = () => {
|
|
21
|
-
// vite does not extract the worker properly if it is URL is a variable
|
|
22
|
-
const lsWorker = new Worker(new URL('./language/main-browser', import.meta.url), {
|
|
23
|
-
type: 'module',
|
|
24
|
-
name: 'Agentlang Language Server',
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
type: 'WorkerDirect',
|
|
29
|
-
worker: lsWorker,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
*/
|
|
33
|
-
//# sourceMappingURL=setupCommon.js.map
|
package/out/setupCommon.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupCommon.js","sourceRoot":"","sources":["../src/setupCommon.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,iEAAiE;;AAEjE,uEAAuE;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BE"}
|
package/out/setupExtended.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export declare const setupConfigExtended: () => {
|
|
2
|
-
$type: string;
|
|
3
|
-
editorAppConfig: {
|
|
4
|
-
codeResources: {
|
|
5
|
-
modified: {
|
|
6
|
-
uri: string;
|
|
7
|
-
text: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
useDiffEditor: boolean;
|
|
11
|
-
extensions: {
|
|
12
|
-
config: {
|
|
13
|
-
name: string;
|
|
14
|
-
publisher: string;
|
|
15
|
-
version: string;
|
|
16
|
-
engines: {
|
|
17
|
-
vscode: string;
|
|
18
|
-
};
|
|
19
|
-
contributes: {
|
|
20
|
-
languages: {
|
|
21
|
-
id: string;
|
|
22
|
-
extensions: string[];
|
|
23
|
-
configuration: string;
|
|
24
|
-
}[];
|
|
25
|
-
grammars: {
|
|
26
|
-
language: string;
|
|
27
|
-
scopeName: string;
|
|
28
|
-
path: string;
|
|
29
|
-
}[];
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
filesOrContents: Map<any, any>;
|
|
33
|
-
}[];
|
|
34
|
-
userConfiguration: {
|
|
35
|
-
json: string;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export declare const executeExtended: (htmlElement: HTMLElement) => Promise<void>;
|
|
40
|
-
//# sourceMappingURL=setupExtended.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupExtended.d.ts","sourceRoot":"","sources":["../src/setupExtended.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0D/B,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,aAAa,WAAW,kBAgB7D,CAAC"}
|