agentlang 0.3.5 → 0.3.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.
Files changed (74) hide show
  1. package/README.md +82 -29
  2. package/out/api/http.js +2 -2
  3. package/out/api/http.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 +0 -1
  7. package/out/language/generated/ast.js.map +1 -1
  8. package/out/language/main.cjs +502 -502
  9. package/out/language/main.cjs.map +3 -3
  10. package/out/language/syntax.js +8 -8
  11. package/out/language/syntax.js.map +1 -1
  12. package/out/runtime/auth/cognito.js +2 -2
  13. package/out/runtime/auth/cognito.js.map +1 -1
  14. package/out/runtime/exec-graph.d.ts.map +1 -1
  15. package/out/runtime/exec-graph.js +6 -5
  16. package/out/runtime/exec-graph.js.map +1 -1
  17. package/out/runtime/interpreter.js +49 -49
  18. package/out/runtime/interpreter.js.map +1 -1
  19. package/out/runtime/jsmodules.js +6 -6
  20. package/out/runtime/jsmodules.js.map +1 -1
  21. package/out/runtime/loader.js +6 -6
  22. package/out/runtime/loader.js.map +1 -1
  23. package/out/runtime/module.d.ts.map +1 -1
  24. package/out/runtime/module.js +72 -66
  25. package/out/runtime/module.js.map +1 -1
  26. package/out/runtime/modules/ai.js +5 -5
  27. package/out/runtime/modules/ai.js.map +1 -1
  28. package/out/runtime/modules/auth.d.ts.map +1 -1
  29. package/out/runtime/modules/auth.js +21 -18
  30. package/out/runtime/modules/auth.js.map +1 -1
  31. package/out/runtime/modules/core.js +1 -1
  32. package/out/runtime/modules/core.js.map +1 -1
  33. package/out/runtime/openapi.js +2 -2
  34. package/out/runtime/openapi.js.map +1 -1
  35. package/out/runtime/relgraph.js +1 -1
  36. package/out/runtime/relgraph.js.map +1 -1
  37. package/out/runtime/resolvers/authinfo.js +2 -2
  38. package/out/runtime/resolvers/authinfo.js.map +1 -1
  39. package/out/runtime/resolvers/interface.js +1 -1
  40. package/out/runtime/resolvers/interface.js.map +1 -1
  41. package/out/runtime/resolvers/registry.js +1 -1
  42. package/out/runtime/resolvers/registry.js.map +1 -1
  43. package/out/runtime/resolvers/sqldb/database.js +11 -11
  44. package/out/runtime/resolvers/sqldb/database.js.map +1 -1
  45. package/out/runtime/resolvers/sqldb/impl.js +4 -4
  46. package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
  47. package/out/runtime/util.js +5 -5
  48. package/out/runtime/util.js.map +1 -1
  49. package/out/utils/runtime.d.ts.map +1 -1
  50. package/out/utils/runtime.js +4 -2
  51. package/out/utils/runtime.js.map +1 -1
  52. package/package.json +184 -182
  53. package/src/api/http.ts +2 -2
  54. package/src/language/generated/ast.ts +1 -1
  55. package/src/language/syntax.ts +8 -8
  56. package/src/runtime/auth/cognito.ts +107 -2
  57. package/src/runtime/auth/interface.ts +1 -0
  58. package/src/runtime/exec-graph.ts +6 -5
  59. package/src/runtime/interpreter.ts +49 -49
  60. package/src/runtime/jsmodules.ts +6 -6
  61. package/src/runtime/loader.ts +6 -6
  62. package/src/runtime/module.ts +71 -66
  63. package/src/runtime/modules/ai.ts +5 -5
  64. package/src/runtime/modules/auth.ts +54 -20
  65. package/src/runtime/modules/core.ts +1 -1
  66. package/src/runtime/openapi.ts +2 -2
  67. package/src/runtime/relgraph.ts +1 -1
  68. package/src/runtime/resolvers/authinfo.ts +2 -2
  69. package/src/runtime/resolvers/interface.ts +1 -1
  70. package/src/runtime/resolvers/registry.ts +1 -1
  71. package/src/runtime/resolvers/sqldb/database.ts +11 -11
  72. package/src/runtime/resolvers/sqldb/impl.ts +4 -4
  73. package/src/runtime/util.ts +5 -5
  74. package/src/utils/runtime.ts +3 -3
@@ -114,7 +114,7 @@ class GraphGenerator extends PatternHandler {
114
114
  const cond = handler.getGraph();
115
115
  const conseq = await graphFromStatements(ifStmt.statements, env.getActiveModuleName());
116
116
  cond.pushSubGraph(conseq);
117
- if (ifStmt.else != undefined) {
117
+ if (ifStmt.else !== undefined) {
118
118
  const alter = await graphFromStatements(ifStmt.else.statements, env.getActiveModuleName());
119
119
  cond.pushSubGraph(alter);
120
120
  } else {
@@ -336,6 +336,7 @@ export async function executeEvent(
336
336
  if (kernelCall) {
337
337
  env.setInKernelMode(true);
338
338
  }
339
+ env.setActiveEvent(eventInstance);
339
340
  await executeEventHelper(eventInstance, env);
340
341
  } else if (isAgentEventInstance(eventInstance)) {
341
342
  env.setStatementsExecutor(executeStatements);
@@ -348,7 +349,7 @@ export async function executeEvent(
348
349
  if (env && env.hasHandlers()) {
349
350
  throw err;
350
351
  } else {
351
- if (env != undefined && activeEnv == undefined) {
352
+ if (env !== undefined && activeEnv === undefined) {
352
353
  await env.rollbackAllTransactions().then(() => {
353
354
  txnRolledBack = true;
354
355
  });
@@ -356,7 +357,7 @@ export async function executeEvent(
356
357
  throw err;
357
358
  }
358
359
  } finally {
359
- if (!txnRolledBack && env != undefined && activeEnv == undefined) {
360
+ if (!txnRolledBack && env !== undefined && activeEnv === undefined) {
360
361
  await env.commitAllTransactions();
361
362
  }
362
363
  }
@@ -370,7 +371,7 @@ export async function executeEventHelper(eventInstance: Instance, env?: Environm
370
371
  }
371
372
  const fqn = eventInstance.getFqName();
372
373
  let isLocalEnv = false;
373
- if (env == undefined) {
374
+ if (env === undefined) {
374
375
  env = new Environment(`${fqn}-env`);
375
376
  isLocalEnv = true;
376
377
  }
@@ -433,7 +434,7 @@ async function executeStatementsHelper(
433
434
  ): Promise<any> {
434
435
  const g = await graphFromStatements(stmts);
435
436
  let isLocalEnv = false;
436
- if (env == undefined) {
437
+ if (env === undefined) {
437
438
  env = new Environment(`stmt-exec-env`);
438
439
  isLocalEnv = true;
439
440
  }
@@ -152,7 +152,7 @@ export class Environment extends Instance {
152
152
  mkEnvName(name, parent),
153
153
  newInstanceAttributes()
154
154
  );
155
- if (parent != undefined) {
155
+ if (parent !== undefined) {
156
156
  this.parent = parent;
157
157
  this.activeModule = parent.activeModule;
158
158
  this.activeUser = parent.activeUser;
@@ -234,8 +234,8 @@ export class Environment extends Instance {
234
234
 
235
235
  override lookup(k: string): Result {
236
236
  const v = this.attributes.get(k);
237
- if (v == undefined) {
238
- if (this.parent != undefined) {
237
+ if (v === undefined) {
238
+ if (this.parent !== undefined) {
239
239
  return this.parent.lookup(k);
240
240
  } else if (this == GlobalEnvironment) {
241
241
  return EmptyResult;
@@ -273,7 +273,7 @@ export class Environment extends Instance {
273
273
  }
274
274
 
275
275
  addToScratchPad(k: string, data: any): Environment {
276
- if (this.scratchPad == undefined) {
276
+ if (this.scratchPad === undefined) {
277
277
  this.scratchPad = {};
278
278
  }
279
279
  if (isFqName(k)) {
@@ -352,11 +352,11 @@ export class Environment extends Instance {
352
352
  }
353
353
 
354
354
  isSuspended(): boolean {
355
- return this.suspensionId != undefined;
355
+ return this.suspensionId !== undefined;
356
356
  }
357
357
 
358
358
  suspend(): string {
359
- if (this.suspensionId == undefined) {
359
+ if (this.suspensionId === undefined) {
360
360
  const id = this.preGeneratedSuspensionId;
361
361
  this.propagateSuspension(id);
362
362
  return id;
@@ -634,7 +634,7 @@ export class Environment extends Instance {
634
634
 
635
635
  popHandlers(): CatchHandlers {
636
636
  const r = this.activeCatchHandlers.pop();
637
- if (r == undefined) {
637
+ if (r === undefined) {
638
638
  throw new Error(`No more handlers to pop`);
639
639
  }
640
640
  return r;
@@ -725,7 +725,7 @@ export let evaluate = async function (
725
725
  if (env && env.hasHandlers()) {
726
726
  throw err;
727
727
  } else {
728
- if (env != undefined && activeEnv == undefined) {
728
+ if (env !== undefined && activeEnv === undefined) {
729
729
  await env.rollbackAllTransactions().then(() => {
730
730
  txnRolledBack = true;
731
731
  });
@@ -733,7 +733,7 @@ export let evaluate = async function (
733
733
  throw err;
734
734
  }
735
735
  } finally {
736
- if (!txnRolledBack && env != undefined && activeEnv == undefined) {
736
+ if (!txnRolledBack && env !== undefined && activeEnv === undefined) {
737
737
  await env.commitAllTransactions();
738
738
  }
739
739
  }
@@ -790,7 +790,7 @@ export async function evaluateStatements(
790
790
  break;
791
791
  }
792
792
  }
793
- if (continuation != undefined) {
793
+ if (continuation !== undefined) {
794
794
  continuation(env.getLastResult());
795
795
  }
796
796
  }
@@ -872,8 +872,8 @@ export async function evaluateStatement(stmt: Statement, env: Environment): Prom
872
872
  async function maybeHandleNotFound(handlers: CatchHandlers | undefined, env: Environment) {
873
873
  const lastResult: Result = env.getLastResult();
874
874
  if (
875
- lastResult == null ||
876
- lastResult == undefined ||
875
+ lastResult === null ||
876
+ lastResult === undefined ||
877
877
  (lastResult instanceof Array && lastResult.length == 0)
878
878
  ) {
879
879
  const onNotFound = handlers ? handlers.get('not_found') : undefined;
@@ -904,10 +904,10 @@ export function maybeBindStatementResultToAlias(hints: RuntimeHint[], env: Envir
904
904
  for (let i = 0; i < hints.length; ++i) {
905
905
  const rh = hints[i];
906
906
  if (rh.aliasSpec) {
907
- if (rh.aliasSpec.alias != undefined || rh.aliasSpec.aliases.length > 0) {
907
+ if (rh.aliasSpec.alias !== undefined || rh.aliasSpec.aliases.length > 0) {
908
908
  const result: Result = env.getLastResult();
909
909
  const alias: string | undefined = rh.aliasSpec.alias;
910
- if (alias != undefined) {
910
+ if (alias !== undefined) {
911
911
  env.bind(alias, result);
912
912
  } else {
913
913
  const aliases: string[] = rh.aliasSpec.aliases;
@@ -1087,21 +1087,21 @@ async function evaluateFullTextSearch(fts: FullTextSearch, env: Environment): Pr
1087
1087
  }
1088
1088
 
1089
1089
  async function evaluateLiteral(lit: Literal, env: Environment): Promise<void> {
1090
- if (lit.id != undefined) env.setLastResult(env.lookup(lit.id));
1091
- else if (lit.ref != undefined) env.setLastResult(await followReference(env, lit.ref));
1092
- else if (lit.fnCall != undefined) await applyFn(lit.fnCall, env, false);
1093
- else if (lit.asyncFnCall != undefined) await applyFn(lit.asyncFnCall.fnCall, env, true);
1094
- else if (lit.array != undefined) await realizeArray(lit.array, env);
1095
- else if (lit.map != undefined) await realizeMap(lit.map, env);
1096
- else if (lit.num != undefined) env.setLastResult(lit.num);
1097
- else if (lit.str != undefined) env.setLastResult(restoreSpecialChars(lit.str));
1098
- else if (lit.bool != undefined) env.setLastResult(lit.bool == 'true' ? true : false);
1090
+ if (lit.id !== undefined) env.setLastResult(env.lookup(lit.id));
1091
+ else if (lit.ref !== undefined) env.setLastResult(await followReference(env, lit.ref));
1092
+ else if (lit.fnCall !== undefined) await applyFn(lit.fnCall, env, false);
1093
+ else if (lit.asyncFnCall !== undefined) await applyFn(lit.asyncFnCall.fnCall, env, true);
1094
+ else if (lit.array !== undefined) await realizeArray(lit.array, env);
1095
+ else if (lit.map !== undefined) await realizeMap(lit.map, env);
1096
+ else if (lit.num !== undefined) env.setLastResult(lit.num);
1097
+ else if (lit.str !== undefined) env.setLastResult(restoreSpecialChars(lit.str));
1098
+ else if (lit.bool !== undefined) env.setLastResult(lit.bool == 'true' ? true : false);
1099
1099
  }
1100
1100
 
1101
1101
  function getMapKey(k: MapKey): Result {
1102
- if (k.str != undefined) return k.str;
1103
- else if (k.num != undefined) return k.num;
1104
- else if (k.bool != undefined) return k.bool == 'true' ? true : false;
1102
+ if (k.str !== undefined) return k.str;
1103
+ else if (k.num !== undefined) return k.num;
1104
+ else if (k.bool !== undefined) return k.bool == 'true' ? true : false;
1105
1105
  }
1106
1106
 
1107
1107
  const DefaultResolverName: string = '-';
@@ -1116,15 +1116,15 @@ async function getResolverForPath(
1116
1116
  const fqEntryName: string = isFqName(entryName) ? entryName : makeFqName(moduleName, entryName);
1117
1117
  const resN: string | undefined = getResolverNameForPath(fqEntryName);
1118
1118
  let res: Resolver | undefined;
1119
- if (resN == undefined) {
1119
+ if (resN === undefined) {
1120
1120
  res = env.getResolver(DefaultResolverName);
1121
- if (res == undefined) {
1121
+ if (res === undefined) {
1122
1122
  res = new SqlDbResolver(DefaultResolverName);
1123
1123
  await env.addResolver(res);
1124
1124
  }
1125
1125
  } else {
1126
1126
  res = env.getResolver(resN);
1127
- if (res == undefined) {
1127
+ if (res === undefined) {
1128
1128
  res = getResolver(fqEntryName);
1129
1129
  await env.addResolver(res);
1130
1130
  }
@@ -1164,10 +1164,10 @@ async function patternToInstance(
1164
1164
  if (isQueryAll) {
1165
1165
  throw new Error(`Cannot specifiy query attribute ${aname} here`);
1166
1166
  }
1167
- if (qattrs == undefined) qattrs = newInstanceAttributes();
1168
- if (qattrVals == undefined) qattrVals = newInstanceAttributes();
1167
+ if (qattrs === undefined) qattrs = newInstanceAttributes();
1168
+ if (qattrVals === undefined) qattrVals = newInstanceAttributes();
1169
1169
  aname = aname.slice(0, aname.length - 1);
1170
- qattrs.set(aname, a.op == undefined ? '=' : a.op);
1170
+ qattrs.set(aname, a.op === undefined ? '=' : a.op);
1171
1171
  qattrVals.set(aname, v);
1172
1172
  } else {
1173
1173
  attrs.set(aname, v);
@@ -1209,7 +1209,7 @@ async function maybeValidateOneOfRefs(inst: Instance, env: Environment) {
1209
1209
  for (let i = 0; i < attrs.length; ++i) {
1210
1210
  const n = attrs[i];
1211
1211
  const v = inst.lookup(n);
1212
- if (v == undefined) continue;
1212
+ if (v === undefined) continue;
1213
1213
  const attrSpec = inst.record.schema.get(n);
1214
1214
  if (!attrSpec) continue;
1215
1215
  const r = getOneOfRef(attrSpec);
@@ -1254,14 +1254,14 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1254
1254
  `Query pattern for ${entryName} with 'into' clause cannot be used to update attributes`
1255
1255
  );
1256
1256
  }
1257
- if (qattrs == undefined && !isQueryAll) {
1257
+ if (qattrs === undefined && !isQueryAll) {
1258
1258
  throw new Error(`Pattern for ${entryName} with 'into' clause must be a query`);
1259
1259
  }
1260
1260
  await evaluateJoinQuery(crud.into, inst, crud.relationships, distinct, env);
1261
1261
  return;
1262
1262
  }
1263
1263
  if (isEntityInstance(inst) || isBetweenRelationship(inst.name, inst.moduleName)) {
1264
- if (qattrs == undefined && !isQueryAll) {
1264
+ if (qattrs === undefined && !isQueryAll) {
1265
1265
  const parentPath: string | undefined = env.getParentPath();
1266
1266
  if (parentPath) {
1267
1267
  inst.attributes.set(PathAttributeName, parentPath);
@@ -1293,7 +1293,7 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1293
1293
  env.isInUpsertMode()
1294
1294
  );
1295
1295
  }
1296
- if (crud.relationships != undefined) {
1296
+ if (crud.relationships !== undefined) {
1297
1297
  for (let i = 0; i < crud.relationships.length; ++i) {
1298
1298
  const rel: RelationshipPattern = crud.relationships[i];
1299
1299
  const relEntry: Relationship = getRelationship(rel.name, moduleName);
@@ -1320,11 +1320,11 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1320
1320
  const betRelInfo: BetweenRelInfo | undefined = env.getBetweenRelInfo();
1321
1321
  const isReadForUpdate = attrs.size > 0;
1322
1322
  let res: Resolver = Resolver.Default;
1323
- if (parentPath != undefined) {
1323
+ if (parentPath !== undefined) {
1324
1324
  res = await getResolverForPath(inst.name, inst.moduleName, env);
1325
1325
  const insts: Instance[] = await res.queryChildInstances(parentPath, inst);
1326
1326
  env.setLastResult(insts);
1327
- } else if (betRelInfo != undefined) {
1327
+ } else if (betRelInfo !== undefined) {
1328
1328
  res = await getResolverForPath(
1329
1329
  betRelInfo.relationship.name,
1330
1330
  betRelInfo.relationship.moduleName,
@@ -1347,7 +1347,7 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1347
1347
  const insts: Instance[] = await res.queryInstances(inst, isQueryAll, distinct);
1348
1348
  env.setLastResult(insts);
1349
1349
  }
1350
- if (crud.relationships != undefined) {
1350
+ if (crud.relationships !== undefined) {
1351
1351
  const lastRes: Instance[] = env.getLastResult();
1352
1352
  for (let i = 0; i < crud.relationships.length; ++i) {
1353
1353
  const rel: RelationshipPattern = crud.relationships[i];
@@ -1500,10 +1500,10 @@ async function computeExprAttributes(
1500
1500
  if (exprAttrs || origAttrs) {
1501
1501
  const newEnv = new Environment('expr-env', env);
1502
1502
  inst.attributes.forEach((v: any, k: string) => {
1503
- if (v != undefined) newEnv.bind(k, v);
1503
+ if (v !== undefined) newEnv.bind(k, v);
1504
1504
  });
1505
1505
  updatedAttrs?.forEach((v: any, k: string) => {
1506
- if (v != undefined) newEnv.bind(k, v);
1506
+ if (v !== undefined) newEnv.bind(k, v);
1507
1507
  });
1508
1508
  if (exprAttrs) {
1509
1509
  const ks = [...exprAttrs.keys()];
@@ -1685,7 +1685,7 @@ async function agentInvoke(agent: AgentInstance, msg: string, env: Environment):
1685
1685
  while (true) {
1686
1686
  try {
1687
1687
  const obj = agent.maybeValidateJsonResponse(result);
1688
- if (obj != undefined) {
1688
+ if (obj !== undefined) {
1689
1689
  env.setLastResult(obj);
1690
1690
  env.addToScratchPad(agent.getFqName(), obj);
1691
1691
  }
@@ -1867,7 +1867,7 @@ async function evaluateIf(ifStmt: If, env: Environment): Promise<void> {
1867
1867
  await evaluateExpression(ifStmt.cond, env);
1868
1868
  if (env.getLastResult()) {
1869
1869
  await evaluateStatements(ifStmt.statements, env);
1870
- } else if (ifStmt.else != undefined) {
1870
+ } else if (ifStmt.else !== undefined) {
1871
1871
  await evaluateStatements(ifStmt.else.statements, env);
1872
1872
  }
1873
1873
  }
@@ -1935,13 +1935,13 @@ export async function evaluateExpression(expr: Expr, env: Environment): Promise<
1935
1935
  await evaluateExpression(expr.e2, env);
1936
1936
  return;
1937
1937
  }
1938
- if (v1 == null || v1 == undefined) {
1938
+ if (v1 === null || v1 === undefined) {
1939
1939
  env.setLastResult(undefined);
1940
1940
  return;
1941
1941
  }
1942
1942
  await evaluateExpression(expr.e2, env);
1943
1943
  const v2 = env.getLastResult();
1944
- if (v2 == null || v2 == undefined) {
1944
+ if (v2 === null || v2 === undefined) {
1945
1945
  env.setLastResult(undefined);
1946
1946
  return;
1947
1947
  }
@@ -2021,7 +2021,7 @@ async function followReference(env: Environment, s: string): Promise<Result> {
2021
2021
  for (let i = 0; i < refs.length; ++i) {
2022
2022
  const r: string = refs[i];
2023
2023
  const v: Result | undefined = await getRef(r, src, env);
2024
- if (v == undefined) return EmptyResult;
2024
+ if (v === undefined) return EmptyResult;
2025
2025
  result = v;
2026
2026
  src = result;
2027
2027
  }
@@ -2030,7 +2030,7 @@ async function followReference(env: Environment, s: string): Promise<Result> {
2030
2030
 
2031
2031
  async function dereferencePath(path: string, env: Environment): Promise<Result> {
2032
2032
  const fqName = fqNameFromPath(path);
2033
- if (fqName == undefined) {
2033
+ if (fqName === undefined) {
2034
2034
  throw new Error(`Failed to deduce entry-name from path - ${path}`);
2035
2035
  }
2036
2036
  const newEnv = new Environment('path-deref', env);
@@ -2048,9 +2048,9 @@ async function dereferencePath(path: string, env: Environment): Promise<Result>
2048
2048
 
2049
2049
  async function applyFn(fnCall: FnCall, env: Environment, isAsync: boolean): Promise<void> {
2050
2050
  const fnName: string | undefined = fnCall.name;
2051
- if (fnName != undefined) {
2051
+ if (fnName !== undefined) {
2052
2052
  let args: Array<Result> | null = null;
2053
- if (fnCall.args != undefined) {
2053
+ if (fnCall.args !== undefined) {
2054
2054
  args = new Array<Result>();
2055
2055
  for (let i = 0; i < fnCall.args.length; ++i) {
2056
2056
  const arg = fnCall.args[i];
@@ -74,7 +74,7 @@ async function invokeBuiltInFn(fnName: string, args: Array<any> | null, isAsync:
74
74
  } else {
75
75
  const pf: Function | undefined = maybeEvalFunction(fnName);
76
76
  if (pf instanceof Function) {
77
- if (args == null) {
77
+ if (args === null) {
78
78
  if (isAsync) return await pf();
79
79
  else return pf();
80
80
  } else {
@@ -103,10 +103,10 @@ export async function invokeModuleFn(
103
103
  }
104
104
  const mname = refs[0];
105
105
  const m = importedModules.get(mname);
106
- if (m != undefined) {
106
+ if (m !== undefined) {
107
107
  const f = m[refs[1]];
108
- if (f != undefined) {
109
- if (args == null)
108
+ if (f !== undefined) {
109
+ if (args === null)
110
110
  if (isAsync) {
111
111
  return await f();
112
112
  } else return f();
@@ -118,7 +118,7 @@ export async function invokeModuleFn(
118
118
  } catch (reason: any) {
119
119
  const pf: Function | undefined = maybeEvalFunction(fqFnName);
120
120
  if (pf instanceof Function) {
121
- if (args == null) {
121
+ if (args === null) {
122
122
  if (isAsync) return await pf();
123
123
  else return pf();
124
124
  } else {
@@ -134,7 +134,7 @@ export async function invokeModuleFn(
134
134
  export function getModuleFn(fqFnName: string): Function | undefined {
135
135
  const refs: string[] = splitRefs(fqFnName);
136
136
  const m = importedModules.get(refs[0]);
137
- if (m != undefined) {
137
+ if (m !== undefined) {
138
138
  return m[refs[1]];
139
139
  } else return undefined;
140
140
  }
@@ -227,7 +227,7 @@ async function loadApp(appDir: string, fsOptions?: any, callback?: Function): Pr
227
227
  }
228
228
  if (callback) await callback(appSpec);
229
229
  }
230
- if (appSpec.dependencies != undefined) {
230
+ if (appSpec.dependencies !== undefined) {
231
231
  for (const [depName, _] of Object.entries(appSpec.dependencies)) {
232
232
  try {
233
233
  const depDirName = `./node_modules/${depName}`;
@@ -355,7 +355,7 @@ async function loadModule(fileName: string, fsOptions?: any, callback?: Function
355
355
  let cachedFsAdapter: any = null;
356
356
 
357
357
  function getFsAdapter(fs: any) {
358
- if (cachedFsAdapter == null) {
358
+ if (cachedFsAdapter === null) {
359
359
  // Create an adapter to make our filesystem compatible with Langium
360
360
  cachedFsAdapter = {
361
361
  // Read file contents as text
@@ -477,7 +477,7 @@ const StandaloneStatements = new Map<string, Statement[]>();
477
477
 
478
478
  function addStandaloneStatement(stmt: Statement, moduleName: string, userDefined = true) {
479
479
  let stmts: Array<Statement> | undefined = StandaloneStatements.get(moduleName);
480
- if (stmts == undefined) {
480
+ if (stmts === undefined) {
481
481
  stmts = new Array<Statement>();
482
482
  }
483
483
  stmts.push(stmt);
@@ -682,11 +682,11 @@ async function addAgentDefinition(
682
682
  v = processAgentArray(apdef.value.array, name);
683
683
  } else {
684
684
  v = apdef.value.str || apdef.value.id || apdef.value.ref || apdef.value.num;
685
- if (v == undefined) {
685
+ if (v === undefined) {
686
686
  v = apdef.value.bool;
687
687
  }
688
688
  }
689
- if (v == undefined) {
689
+ if (v === undefined) {
690
690
  throw new Error(`Cannot initialize agent ${name}, only literals can be set for attributes`);
691
691
  }
692
692
  if (apdef.name == 'llm') {
@@ -765,7 +765,7 @@ function processAgentArray(array: ArrayLiteral, attrName: string): string {
765
765
  function processAgentArrayValue(expr: Expr | undefined, attrName: string): string {
766
766
  if (expr && isLiteral(expr)) {
767
767
  const s = expr.str || expr.id || expr.ref || expr.bool;
768
- if (s != undefined) {
768
+ if (s !== undefined) {
769
769
  return s;
770
770
  }
771
771
  if (expr.array) {