agentlang 0.9.6 → 0.9.8

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 (78) hide show
  1. package/out/cli/main.d.ts.map +1 -1
  2. package/out/cli/main.js +8 -3
  3. package/out/cli/main.js.map +1 -1
  4. package/out/extension/main.cjs +250 -250
  5. package/out/extension/main.cjs.map +2 -2
  6. package/out/language/generated/ast.js +1 -0
  7. package/out/language/generated/ast.js.map +1 -1
  8. package/out/language/main.cjs +2420 -776
  9. package/out/language/main.cjs.map +4 -4
  10. package/out/runtime/docs.d.ts.map +1 -1
  11. package/out/runtime/docs.js +109 -7
  12. package/out/runtime/docs.js.map +1 -1
  13. package/out/runtime/embeddings/chunker.d.ts +9 -0
  14. package/out/runtime/embeddings/chunker.d.ts.map +1 -0
  15. package/out/runtime/embeddings/chunker.js +41 -0
  16. package/out/runtime/embeddings/chunker.js.map +1 -0
  17. package/out/runtime/embeddings/index.d.ts +6 -0
  18. package/out/runtime/embeddings/index.d.ts.map +1 -0
  19. package/out/runtime/embeddings/index.js +6 -0
  20. package/out/runtime/embeddings/index.js.map +1 -0
  21. package/out/runtime/embeddings/openai.d.ts +15 -0
  22. package/out/runtime/embeddings/openai.d.ts.map +1 -0
  23. package/out/runtime/embeddings/openai.js +34 -0
  24. package/out/runtime/embeddings/openai.js.map +1 -0
  25. package/out/runtime/embeddings/provider.d.ts +20 -0
  26. package/out/runtime/embeddings/provider.d.ts.map +1 -0
  27. package/out/runtime/embeddings/provider.js +17 -0
  28. package/out/runtime/embeddings/provider.js.map +1 -0
  29. package/out/runtime/embeddings/registry.d.ts +3 -0
  30. package/out/runtime/embeddings/registry.d.ts.map +1 -0
  31. package/out/runtime/embeddings/registry.js +16 -0
  32. package/out/runtime/embeddings/registry.js.map +1 -0
  33. package/out/runtime/interpreter.d.ts.map +1 -1
  34. package/out/runtime/interpreter.js +8 -4
  35. package/out/runtime/interpreter.js.map +1 -1
  36. package/out/runtime/module.d.ts +24 -2
  37. package/out/runtime/module.d.ts.map +1 -1
  38. package/out/runtime/module.js +94 -7
  39. package/out/runtime/module.js.map +1 -1
  40. package/out/runtime/modules/ai.d.ts +2 -0
  41. package/out/runtime/modules/ai.d.ts.map +1 -1
  42. package/out/runtime/modules/ai.js +81 -18
  43. package/out/runtime/modules/ai.js.map +1 -1
  44. package/out/runtime/resolvers/sqldb/database.d.ts +1 -1
  45. package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -1
  46. package/out/runtime/resolvers/sqldb/database.js +177 -51
  47. package/out/runtime/resolvers/sqldb/database.js.map +1 -1
  48. package/out/runtime/resolvers/sqldb/impl.d.ts +21 -1
  49. package/out/runtime/resolvers/sqldb/impl.d.ts.map +1 -1
  50. package/out/runtime/resolvers/sqldb/impl.js +176 -45
  51. package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
  52. package/package.json +188 -185
  53. package/public/pdf.worker.mjs +65152 -0
  54. package/src/cli/main.ts +7 -2
  55. package/src/language/generated/ast.ts +1 -1
  56. package/src/runtime/docs.ts +120 -9
  57. package/src/runtime/embeddings/chunker.ts +50 -0
  58. package/src/runtime/embeddings/index.ts +5 -0
  59. package/src/runtime/embeddings/openai.ts +49 -0
  60. package/src/runtime/embeddings/provider.ts +37 -0
  61. package/src/runtime/embeddings/registry.ts +17 -0
  62. package/src/runtime/interpreter.ts +16 -12
  63. package/src/runtime/module.ts +148 -40
  64. package/src/runtime/modules/ai.ts +100 -20
  65. package/src/runtime/resolvers/sqldb/database.ts +190 -59
  66. package/src/runtime/resolvers/sqldb/impl.ts +235 -58
  67. package/out/setupClassic.d.ts +0 -98
  68. package/out/setupClassic.d.ts.map +0 -1
  69. package/out/setupClassic.js +0 -38
  70. package/out/setupClassic.js.map +0 -1
  71. package/out/setupCommon.d.ts +0 -2
  72. package/out/setupCommon.d.ts.map +0 -1
  73. package/out/setupCommon.js +0 -33
  74. package/out/setupCommon.js.map +0 -1
  75. package/out/setupExtended.d.ts +0 -40
  76. package/out/setupExtended.d.ts.map +0 -1
  77. package/out/setupExtended.js +0 -67
  78. package/out/setupExtended.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import chalk from 'chalk';
2
- import { isRelNodes, isLiteral, } from '../language/generated/ast.js';
3
- import { Path, nameToPath, isString, isNumber, isBoolean, isFqName, makeFqName, DefaultModuleName, DefaultModules, joinStatements, isMinusZero, now, findMetaSchema, findAllPrePostTriggerSchema, asCrudType, isPath, findUqCompositeAttributes, escapeFqName, encryptPassword, splitFqName, splitRefs, forceAsFqName, validateIdFormat, nameContainsSepEscape, registerInitFunction, ScratchModuleName, } from './util.js';
2
+ import { isLiteral, isRelNodes, } from '../language/generated/ast.js';
3
+ import { asCrudType, DefaultModuleName, DefaultModules, encryptPassword, escapeFqName, escapeSpecialChars, findAllPrePostTriggerSchema, findMetaSchema, findUqCompositeAttributes, forceAsFqName, isBoolean, isFqName, isMinusZero, isNumber, isPath, isString, joinStatements, makeFqName, nameContainsSepEscape, nameToPath, now, Path, registerInitFunction, ScratchModuleName, splitFqName, splitRefs, validateIdFormat, } from './util.js';
4
4
  import { parseStatement } from '../language/parser.js';
5
5
  import { AdminSession } from './auth/defs.js';
6
6
  import { FetchModuleFn, getUserTenantId, PathAttributeName, TenantAttributeName, } from './defs.js';
@@ -393,7 +393,10 @@ export class Record extends ModuleEntry {
393
393
  }
394
394
  }
395
395
  getFullTextSearchAttributes() {
396
- const fts = this.getMeta('fullTextSearch');
396
+ let fts = this.getMeta('fullTextSearchAttributes');
397
+ if (!fts) {
398
+ fts = this.getMeta('fullTextSearch');
399
+ }
397
400
  if (fts) {
398
401
  if (fts instanceof Array) {
399
402
  return fts;
@@ -409,6 +412,13 @@ export class Record extends ModuleEntry {
409
412
  return undefined;
410
413
  }
411
414
  }
415
+ getEmbeddingConfig() {
416
+ const config = this.getMeta('embeddingConfig');
417
+ if (config && typeof config === 'object') {
418
+ return config;
419
+ }
420
+ return undefined;
421
+ }
412
422
  resetUserAttrs() {
413
423
  this.userAttrNames = undefined;
414
424
  this.userAttrsSchema = undefined;
@@ -954,7 +964,17 @@ export class Agent extends Record {
954
964
  if (!skip && value !== null && value !== undefined) {
955
965
  let v = value;
956
966
  const isf = key == 'flows';
957
- if (isf || key == 'tools') {
967
+ const isDocs = key == 'documents';
968
+ if (isDocs) {
969
+ const raw = isString(v) ? v : `${v}`;
970
+ const items = raw
971
+ .split(',')
972
+ .map((entry) => entry.trim())
973
+ .filter((entry) => entry.length > 0)
974
+ .map((entry) => entry.replace(/\\/g, '\\\\').replace(/"/g, '\\"'));
975
+ v = `[${items.map((entry) => `"${entry}"`).join(', ')}]`;
976
+ }
977
+ else if (isf || key == 'tools') {
958
978
  if (isf || v.indexOf(',') > 0 || v.indexOf('/') > 0)
959
979
  v = `[${v}]`;
960
980
  else
@@ -1588,6 +1608,29 @@ export class GlossaryEntry extends ModuleEntry {
1588
1608
  return `glossaryEntry ${this.name} \n{\n${ss.join(',\n')}\n}`;
1589
1609
  }
1590
1610
  }
1611
+ export class DocumentEntry extends ModuleEntry {
1612
+ constructor(title, moduleName, url) {
1613
+ super(title, moduleName);
1614
+ this.doc = { title, url };
1615
+ }
1616
+ getUrl() {
1617
+ return this.doc.url;
1618
+ }
1619
+ getTitle() {
1620
+ return this.doc.title;
1621
+ }
1622
+ toString() {
1623
+ const escapedTitle = escapeSpecialChars(this.doc.title);
1624
+ const escapedUrl = escapeSpecialChars(this.doc.url);
1625
+ return `{${DefaultModuleName}.ai/doc {\n title "${escapedTitle}",\n url "${escapedUrl}"\n}}`;
1626
+ }
1627
+ get url() {
1628
+ return this.doc.url;
1629
+ }
1630
+ set url(value) {
1631
+ this.doc.url = value;
1632
+ }
1633
+ }
1591
1634
  function statementLabel(stmt) {
1592
1635
  var _a, _b;
1593
1636
  if (stmt === undefined)
@@ -2095,6 +2138,43 @@ export class Module {
2095
2138
  }
2096
2139
  return this;
2097
2140
  }
2141
+ addDocument(title, url) {
2142
+ if (this.hasEntry(title)) {
2143
+ const existing = this.getEntry(title);
2144
+ if (existing instanceof DocumentEntry) {
2145
+ const doc = existing;
2146
+ doc.url = url;
2147
+ return this;
2148
+ }
2149
+ }
2150
+ const docEntry = new DocumentEntry(title, this.name, url);
2151
+ this.addEntry(docEntry);
2152
+ return this;
2153
+ }
2154
+ getDocument(title) {
2155
+ if (this.hasEntry(title)) {
2156
+ const entry = this.getEntry(title);
2157
+ if (entry instanceof DocumentEntry) {
2158
+ return entry.url;
2159
+ }
2160
+ }
2161
+ return undefined;
2162
+ }
2163
+ getAllDocuments() {
2164
+ return this.entries.filter((e) => {
2165
+ return e instanceof DocumentEntry;
2166
+ });
2167
+ }
2168
+ removeDocument(title) {
2169
+ for (let i = 0; i < this.entries.length; ++i) {
2170
+ const entry = this.entries[i];
2171
+ if (entry.name === title && entry instanceof DocumentEntry) {
2172
+ this.entries.splice(i, 1);
2173
+ break;
2174
+ }
2175
+ }
2176
+ return this;
2177
+ }
2098
2178
  addRetry(retry) {
2099
2179
  this.addEntry(retry);
2100
2180
  return this;
@@ -2125,7 +2205,7 @@ export class Module {
2125
2205
  }
2126
2206
  getEntryIndex(entryName) {
2127
2207
  return this.entries.findIndex((v) => {
2128
- return v.name == entryName;
2208
+ return v.name === entryName;
2129
2209
  });
2130
2210
  }
2131
2211
  hasEntry(entryName) {
@@ -2324,6 +2404,15 @@ export class Module {
2324
2404
  }
2325
2405
  }
2326
2406
  let GlobalRetries = undefined;
2407
+ const DocumentAliasMap = new Map();
2408
+ export function registerDocumentAlias(name, title) {
2409
+ if (!name || !title)
2410
+ return;
2411
+ DocumentAliasMap.set(name, title);
2412
+ }
2413
+ export function resolveDocumentAliases(names) {
2414
+ return names.map((name) => { var _a; return (_a = DocumentAliasMap.get(name)) !== null && _a !== void 0 ? _a : name; });
2415
+ }
2327
2416
  export function addGlobalRetry(r) {
2328
2417
  if (GlobalRetries === undefined) {
2329
2418
  GlobalRetries = new Array();
@@ -2372,8 +2461,6 @@ export function removeModule(name) {
2372
2461
  }
2373
2462
  return false;
2374
2463
  }
2375
- addModule(DefaultModuleName);
2376
- addRecord('env', DefaultModuleName);
2377
2464
  addModule(ScratchModuleName);
2378
2465
  export function getModuleNames() {
2379
2466
  const ks = getModuleDb().keys();