agentlang 0.2.6 → 0.3.1

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 (72) hide show
  1. package/README.md +315 -39
  2. package/out/api/http.d.ts.map +1 -1
  3. package/out/api/http.js +5 -3
  4. package/out/api/http.js.map +1 -1
  5. package/out/extension/main.cjs +85 -63
  6. package/out/extension/main.cjs.map +3 -3
  7. package/out/language/agentlang-validator.d.ts.map +1 -1
  8. package/out/language/agentlang-validator.js +24 -4
  9. package/out/language/agentlang-validator.js.map +1 -1
  10. package/out/language/generated/ast.d.ts +58 -7
  11. package/out/language/generated/ast.d.ts.map +1 -1
  12. package/out/language/generated/ast.js +83 -1
  13. package/out/language/generated/ast.js.map +1 -1
  14. package/out/language/generated/grammar.d.ts.map +1 -1
  15. package/out/language/generated/grammar.js +537 -216
  16. package/out/language/generated/grammar.js.map +1 -1
  17. package/out/language/main.cjs +657 -264
  18. package/out/language/main.cjs.map +2 -2
  19. package/out/runtime/agents/common.d.ts +11 -0
  20. package/out/runtime/agents/common.d.ts.map +1 -1
  21. package/out/runtime/agents/common.js +61 -1
  22. package/out/runtime/agents/common.js.map +1 -1
  23. package/out/runtime/exec-graph.d.ts.map +1 -1
  24. package/out/runtime/exec-graph.js +1 -7
  25. package/out/runtime/exec-graph.js.map +1 -1
  26. package/out/runtime/interpreter.d.ts.map +1 -1
  27. package/out/runtime/interpreter.js +45 -17
  28. package/out/runtime/interpreter.js.map +1 -1
  29. package/out/runtime/loader.d.ts +3 -4
  30. package/out/runtime/loader.d.ts.map +1 -1
  31. package/out/runtime/loader.js +91 -12
  32. package/out/runtime/loader.js.map +1 -1
  33. package/out/runtime/module.d.ts +34 -5
  34. package/out/runtime/module.d.ts.map +1 -1
  35. package/out/runtime/module.js +190 -18
  36. package/out/runtime/module.js.map +1 -1
  37. package/out/runtime/modules/ai.d.ts.map +1 -1
  38. package/out/runtime/modules/ai.js +15 -6
  39. package/out/runtime/modules/ai.js.map +1 -1
  40. package/out/runtime/modules/auth.d.ts.map +1 -1
  41. package/out/runtime/modules/auth.js +42 -43
  42. package/out/runtime/modules/auth.js.map +1 -1
  43. package/out/runtime/modules/core.js +1 -1
  44. package/out/runtime/modules/files.d.ts +18 -0
  45. package/out/runtime/modules/files.d.ts.map +1 -0
  46. package/out/runtime/modules/files.js +116 -0
  47. package/out/runtime/modules/files.js.map +1 -0
  48. package/out/runtime/util.d.ts +3 -1
  49. package/out/runtime/util.d.ts.map +1 -1
  50. package/out/runtime/util.js +16 -0
  51. package/out/runtime/util.js.map +1 -1
  52. package/out/syntaxes/agentlang.monarch.js +1 -1
  53. package/out/syntaxes/agentlang.monarch.js.map +1 -1
  54. package/package.json +182 -201
  55. package/src/api/http.ts +5 -3
  56. package/src/language/agentlang-validator.ts +29 -4
  57. package/src/language/agentlang.langium +15 -3
  58. package/src/language/generated/ast.ts +149 -7
  59. package/src/language/generated/grammar.ts +537 -216
  60. package/src/runtime/agents/common.ts +69 -1
  61. package/src/runtime/exec-graph.ts +1 -8
  62. package/src/runtime/interpreter.ts +47 -16
  63. package/src/runtime/loader.ts +105 -9
  64. package/src/runtime/module.ts +213 -24
  65. package/src/runtime/modules/ai.ts +12 -5
  66. package/src/runtime/modules/auth.ts +42 -43
  67. package/src/runtime/modules/core.ts +1 -1
  68. package/src/runtime/util.ts +19 -0
  69. package/src/syntaxes/agentlang.monarch.ts +1 -1
  70. package/src/setupClassic.ts +0 -43
  71. package/src/setupCommon.ts +0 -33
  72. package/src/setupExtended.ts +0 -79
@@ -356,6 +356,7 @@ Now apply the same analysis to the following context and cases provided by the u
356
356
  export type AgentCondition = {
357
357
  cond: string;
358
358
  then: string;
359
+ internal: boolean;
359
360
  };
360
361
 
361
362
  const AgentDirectives = new Map<string, AgentCondition[]>();
@@ -368,8 +369,14 @@ export function getAgentDirectives(agentFqName: string): AgentCondition[] | unde
368
369
  return AgentDirectives.get(agentFqName);
369
370
  }
370
371
 
372
+ export function getAgentDirectivesInternal(agentFqName: string): AgentCondition[] | undefined {
373
+ return AgentDirectives.get(agentFqName)?.filter((ac: AgentCondition) => {
374
+ return ac.internal;
375
+ });
376
+ }
377
+
371
378
  export function getAgentDirectivesJson(agentFqName: string): string | undefined {
372
- const conds = AgentDirectives.get(agentFqName);
379
+ const conds = getAgentDirectivesInternal(agentFqName);
373
380
  if (conds) {
374
381
  const fmted = conds.map((c: AgentCondition) => {
375
382
  return { if: c.cond, then: c.then };
@@ -383,9 +390,16 @@ export function removeAgentDirectives(agentFqName: string) {
383
390
  AgentDirectives.delete(agentFqName);
384
391
  }
385
392
 
393
+ export function addAgentDirective(agentFqName: string, newDirective: AgentCondition) {
394
+ const dirs = getAgentDirectives(agentFqName) || new Array<AgentCondition>();
395
+ dirs.push(newDirective);
396
+ registerAgentDirectives(agentFqName, dirs);
397
+ }
398
+
386
399
  export type AgentScenario = {
387
400
  user: string;
388
401
  ai: string;
402
+ internal: boolean;
389
403
  };
390
404
 
391
405
  const AgentScenarios = new Map<string, AgentScenario[]>();
@@ -398,14 +412,41 @@ export function getAgentScenarios(agentFqName: string): AgentScenario[] | undefi
398
412
  return AgentScenarios.get(agentFqName);
399
413
  }
400
414
 
415
+ export function getAgentScenariosJson(agentFqName: string): string | undefined {
416
+ const scns = getAgentScenariosInternal(agentFqName);
417
+ if (scns) {
418
+ const fmtd = scns.map((scn: AgentScenario) => {
419
+ return {
420
+ user: scn.user,
421
+ ai: scn.ai,
422
+ };
423
+ });
424
+ return JSON.stringify(fmtd);
425
+ }
426
+ return undefined;
427
+ }
428
+
429
+ export function getAgentScenariosInternal(agentFqName: string): AgentScenario[] | undefined {
430
+ return AgentScenarios.get(agentFqName)?.filter((asc: AgentScenario) => {
431
+ return asc.internal;
432
+ });
433
+ }
434
+
401
435
  export function removeAgentScenarios(agentFqName: string) {
402
436
  AgentScenarios.delete(agentFqName);
403
437
  }
404
438
 
439
+ export function addAgentScenario(agentFqName: string, newScn: AgentScenario) {
440
+ const scns = getAgentScenarios(agentFqName) || new Array<AgentScenario>();
441
+ scns.push(newScn);
442
+ registerAgentScenarios(agentFqName, scns);
443
+ }
444
+
405
445
  export type AgentGlossaryEntry = {
406
446
  name: string;
407
447
  meaning: string;
408
448
  synonyms: string | undefined;
449
+ internal: boolean;
409
450
  };
410
451
 
411
452
  const AgentGlossary = new Map<string, AgentGlossaryEntry[]>();
@@ -418,10 +459,37 @@ export function getAgentGlossary(agentFqName: string): AgentGlossaryEntry[] | un
418
459
  return AgentGlossary.get(agentFqName);
419
460
  }
420
461
 
462
+ export function getAgentGlossaryInternal(agentFqName: string): AgentGlossaryEntry[] | undefined {
463
+ return AgentGlossary.get(agentFqName)?.filter((age: AgentGlossaryEntry) => {
464
+ return age.internal;
465
+ });
466
+ }
467
+
468
+ export function getAgentGlossaryJson(agentFqName: string): string | undefined {
469
+ const gls = getAgentGlossaryInternal(agentFqName);
470
+ if (gls) {
471
+ const fmtd = gls.map((ge: AgentGlossaryEntry) => {
472
+ return {
473
+ name: ge.name,
474
+ meaning: ge.meaning,
475
+ synonyms: ge.synonyms,
476
+ };
477
+ });
478
+ return JSON.stringify(fmtd);
479
+ }
480
+ return undefined;
481
+ }
482
+
421
483
  export function removeAgentGlossary(agentFqName: string) {
422
484
  AgentGlossary.delete(agentFqName);
423
485
  }
424
486
 
487
+ export function addAgentGlossaryEntry(agentFqName: string, newEntry: AgentGlossaryEntry) {
488
+ const entries = getAgentGlossary(agentFqName) || new Array<AgentGlossaryEntry>();
489
+ entries.push(newEntry);
490
+ registerAgentGlossary(agentFqName, entries);
491
+ }
492
+
425
493
  const AgentResponseSchema = new Map<string, string>();
426
494
 
427
495
  export function registerAgentResponseSchema(agentFqName: string, responseSchema: string) {
@@ -175,12 +175,6 @@ async function graphFromStatements(
175
175
  return handler.getGraph().setActiveModuleName(activeModuleName);
176
176
  }
177
177
 
178
- async function eventExecutor(eventInst: Instance, env: Environment) {
179
- const newEnv = new Environment(`${eventInst.name}-env`, env);
180
- await executeEventHelper(eventInst, newEnv);
181
- env.setLastResult(newEnv.getLastResult());
182
- }
183
-
184
178
  function makeStatementsExecutor(execGraph: ExecGraph, triggeringNode: ExecGraphNode): Function {
185
179
  return async (stmts: Statement[], env: Environment): Promise<any> => {
186
180
  const g = await graphFromStatements(stmts, env.getActiveModuleName());
@@ -195,7 +189,7 @@ function makeStatementsExecutor(execGraph: ExecGraph, triggeringNode: ExecGraphN
195
189
 
196
190
  export async function executeGraph(execGraph: ExecGraph, env: Environment): Promise<any> {
197
191
  const activeModuleName = execGraph.getActiveModuleName();
198
- env.setEventExecutor(eventExecutor);
192
+ env.setEventExecutor(executeEventHelper);
199
193
  let oldModule: string | undefined = undefined;
200
194
  if (activeModuleName) {
201
195
  oldModule = env.switchActiveModuleName(activeModuleName);
@@ -339,7 +333,6 @@ export async function executeEvent(
339
333
  let txnRolledBack: boolean = false;
340
334
  try {
341
335
  if (isEventInstance(eventInstance)) {
342
- env.setActiveEvent(eventInstance);
343
336
  if (kernelCall) {
344
337
  env.setInKernelMode(true);
345
338
  }
@@ -1268,7 +1268,7 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1268
1268
  }
1269
1269
  const res: Resolver = await getResolverForPath(entryName, moduleName, env);
1270
1270
  let r: Instance | undefined;
1271
- await computeExprAttributes(inst, env);
1271
+ await computeExprAttributes(inst, undefined, undefined, env);
1272
1272
  if (env.isInUpsertMode()) {
1273
1273
  await runPreUpdateEvents(inst, env);
1274
1274
  r = await res.upsertInstance(inst);
@@ -1279,7 +1279,7 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1279
1279
  r = await res.createInstance(inst);
1280
1280
  await runPostCreateEvents(inst, env);
1281
1281
  }
1282
- if (r && entryName == AgentEntityName) {
1282
+ if (r && entryName == AgentEntityName && inst.moduleName == CoreAIModuleName) {
1283
1283
  defineAgentEvent(env.getActiveModuleName(), r.lookup('name'), r.lookup('instruction'));
1284
1284
  }
1285
1285
  env.setLastResult(r);
@@ -1385,7 +1385,7 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1385
1385
  );
1386
1386
  const res: Array<Instance> = new Array<Instance>();
1387
1387
  for (let i = 0; i < lastRes.length; ++i) {
1388
- await computeExprAttributes(lastRes[i], env);
1388
+ await computeExprAttributes(lastRes[i], crud.body?.attributes, attrs, env);
1389
1389
  await runPreUpdateEvents(lastRes[i], env);
1390
1390
  const finalInst: Instance = await resolver.updateInstance(lastRes[i], attrs);
1391
1391
  await runPostUpdateEvents(finalInst, lastRes[i], env);
@@ -1397,7 +1397,7 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1397
1397
  }
1398
1398
  } else {
1399
1399
  const res: Resolver = await getResolverForPath(lastRes.name, lastRes.moduleName, env);
1400
- await computeExprAttributes(lastRes, env);
1400
+ await computeExprAttributes(lastRes, crud.body?.attributes, attrs, env);
1401
1401
  await runPreUpdateEvents(lastRes, env);
1402
1402
  const finalInst: Instance = await res.updateInstance(lastRes, attrs);
1403
1403
  await runPostUpdateEvents(finalInst, lastRes, env);
@@ -1489,22 +1489,45 @@ function triggerTimer(timerInst: Instance): Instance {
1489
1489
  return timerInst;
1490
1490
  }
1491
1491
 
1492
- async function computeExprAttributes(inst: Instance, env: Environment) {
1492
+ async function computeExprAttributes(
1493
+ inst: Instance,
1494
+ origAttrs: SetAttribute[] | undefined,
1495
+ updatedAttrs: InstanceAttributes | undefined,
1496
+ env: Environment
1497
+ ) {
1493
1498
  const exprAttrs = inst.getExprAttributes();
1494
- if (exprAttrs) {
1499
+ if (exprAttrs || origAttrs) {
1495
1500
  const newEnv = new Environment('expr-env', env);
1496
1501
  inst.attributes.forEach((v: any, k: string) => {
1497
- newEnv.bind(k, v);
1502
+ if (v != undefined) newEnv.bind(k, v);
1498
1503
  });
1499
- const ks = [...exprAttrs.keys()];
1500
- for (let i = 0; i < ks.length; ++i) {
1501
- const n = ks[i];
1502
- const expr: Expr | undefined = exprAttrs.get(n);
1503
- if (expr) {
1504
- await evaluateExpression(expr, newEnv);
1505
- const v: Result = newEnv.getLastResult();
1506
- newEnv.bind(n, v);
1507
- inst.attributes.set(n, v);
1504
+ updatedAttrs?.forEach((v: any, k: string) => {
1505
+ if (v != undefined) newEnv.bind(k, v);
1506
+ });
1507
+ if (exprAttrs) {
1508
+ const ks = [...exprAttrs.keys()];
1509
+ for (let i = 0; i < ks.length; ++i) {
1510
+ const n = ks[i];
1511
+ const expr: Expr | undefined = exprAttrs.get(n);
1512
+ if (expr) {
1513
+ await evaluateExpression(expr, newEnv);
1514
+ const v: Result = newEnv.getLastResult();
1515
+ newEnv.bind(n, v);
1516
+ inst.attributes.set(n, v);
1517
+ updatedAttrs?.set(n, v);
1518
+ }
1519
+ }
1520
+ }
1521
+ if (origAttrs && updatedAttrs) {
1522
+ for (let i = 0; i < origAttrs.length; ++i) {
1523
+ const a: SetAttribute = origAttrs[i];
1524
+ const n = a.name;
1525
+ if (!n.endsWith(QuerySuffix) && updatedAttrs.has(n)) {
1526
+ await evaluateExpression(a.value, newEnv);
1527
+ const v: Result = newEnv.getLastResult();
1528
+ updatedAttrs.set(n, v);
1529
+ newEnv.bind(n, v);
1530
+ }
1508
1531
  }
1509
1532
  }
1510
1533
  }
@@ -1929,8 +1952,16 @@ export async function evaluateExpression(expr: Expr, env: Environment): Promise<
1929
1952
  await evaluateExpression(expr.e2, env);
1930
1953
  return;
1931
1954
  }
1955
+ if (v1 == null || v1 == undefined) {
1956
+ env.setLastResult(undefined);
1957
+ return;
1958
+ }
1932
1959
  await evaluateExpression(expr.e2, env);
1933
1960
  const v2 = env.getLastResult();
1961
+ if (v2 == null || v2 == undefined) {
1962
+ env.setLastResult(undefined);
1963
+ return;
1964
+ }
1934
1965
  switch (expr.op) {
1935
1966
  // arithmetic operators
1936
1967
  case '+':
@@ -33,6 +33,15 @@ import {
33
33
  isDecisionDefinition,
34
34
  DecisionDefinition,
35
35
  CaseEntry,
36
+ isScenarioDefinition,
37
+ ScenarioDefinition,
38
+ DirectiveDefinition,
39
+ GlossaryEntryDefinition,
40
+ isDirectiveDefinition,
41
+ isGlossaryEntryDefinition,
42
+ isPublicWorkflowDefinition,
43
+ isPublicAgentDefinition,
44
+ isPublicEventDefinition,
36
45
  } from '../language/generated/ast.js';
37
46
  import {
38
47
  addEntity,
@@ -55,6 +64,7 @@ import {
55
64
  fetchModule,
56
65
  } from './module.js';
57
66
  import {
67
+ asStringLiteralsMap,
58
68
  escapeSpecialChars,
59
69
  findRbacSchema,
60
70
  isFqName,
@@ -62,6 +72,7 @@ import {
62
72
  makeFqName,
63
73
  maybeExtends,
64
74
  registerInitFunction,
75
+ rootRef,
65
76
  } from './util.js';
66
77
  import { getFileSystem, toFsPath, readFile, readdir, exists } from '../utils/fs-utils.js';
67
78
  import { URI } from 'vscode-uri';
@@ -89,6 +100,9 @@ import { ExtendedFileSystem } from '../utils/fs/interfaces.js';
89
100
  import z from 'zod';
90
101
  import { registerAgentFlow, registerFlow } from './agents/flows.js';
91
102
  import {
103
+ addAgentDirective,
104
+ addAgentGlossaryEntry,
105
+ addAgentScenario,
92
106
  AgentCondition,
93
107
  AgentGlossaryEntry,
94
108
  AgentScenario,
@@ -423,14 +437,23 @@ function addEntityFromDef(def: EntityDefinition, moduleName: string): Entity {
423
437
  return entity;
424
438
  }
425
439
 
426
- export function addSchemaFromDef(def: SchemaDefinition, moduleName: string): Record {
440
+ function addSchemaFromDef(
441
+ def: SchemaDefinition,
442
+ moduleName: string,
443
+ ispub: boolean = false
444
+ ): Record {
427
445
  let result: Record | undefined;
428
446
  if (isEntityDefinition(def)) {
429
447
  result = addEntityFromDef(def, moduleName);
430
448
  } else if (isEventDefinition(def)) {
431
449
  result = addEvent(def.name, moduleName, def.schema, maybeExtends(def.extends));
432
- } else {
450
+ } else if (isRecordDefinition(def)) {
433
451
  result = addRecord(def.name, moduleName, def.schema, maybeExtends(def.extends));
452
+ } else {
453
+ throw new Error(`Cannot add schema defintiion in module ${moduleName} for ${def}`);
454
+ }
455
+ if (ispub) {
456
+ result.setPublic(true);
434
457
  }
435
458
  return result;
436
459
  }
@@ -442,8 +465,12 @@ export function addRelationshipFromDef(
442
465
  return addRelationship(def.name, def.type, def.nodes, moduleName, def.schema, def.properties);
443
466
  }
444
467
 
445
- export function addWorkflowFromDef(def: WorkflowDefinition, moduleName: string): Workflow {
446
- return addWorkflow(def.name || '', moduleName, def.statements, def.header);
468
+ export function addWorkflowFromDef(
469
+ def: WorkflowDefinition,
470
+ moduleName: string,
471
+ ispub: boolean = false
472
+ ): Workflow {
473
+ return addWorkflow(def.name || '', moduleName, def.statements, def.header, ispub);
447
474
  }
448
475
 
449
476
  const StandaloneStatements = new Map<string, Statement[]>();
@@ -501,7 +528,8 @@ function processAgentDirectives(agentName: string, value: Literal): AgentConditi
501
528
  }
502
529
  });
503
530
  if (cond && then) {
504
- conds?.push({ cond, then });
531
+ const internal = true;
532
+ conds?.push({ cond, then, internal });
505
533
  } else {
506
534
  throw new Error(`Invalid condition spec in agent ${agentName}`);
507
535
  }
@@ -531,7 +559,8 @@ function processAgentScenarios(agentName: string, value: Literal): AgentScenario
531
559
  }
532
560
  });
533
561
  if (user && ai) {
534
- scenarios.push({ user, ai });
562
+ const internal = true;
563
+ scenarios.push({ user, ai, internal });
535
564
  } else {
536
565
  throw new Error(`Invalid glossary spec in agent ${agentName}`);
537
566
  }
@@ -564,7 +593,8 @@ function processAgentGlossary(agentName: string, value: Literal): AgentGlossaryE
564
593
  }
565
594
  });
566
595
  if (name && meaning) {
567
- gls.push({ name, meaning, synonyms });
596
+ const internal = true;
597
+ gls.push({ name, meaning, synonyms, internal });
568
598
  } else {
569
599
  throw new Error(`Invalid glossary spec in agent ${agentName}`);
570
600
  }
@@ -589,7 +619,11 @@ function processAgentScratchNames(agentName: string, value: Literal): string[] |
589
619
  return undefined;
590
620
  }
591
621
 
592
- async function addAgentDefinition(def: AgentDefinition, moduleName: string) {
622
+ async function addAgentDefinition(
623
+ def: AgentDefinition,
624
+ moduleName: string,
625
+ ispub: boolean = false
626
+ ) {
593
627
  let llmName: string | undefined = undefined;
594
628
  const name = def.name;
595
629
  const attrsStrs = new Array<string>();
@@ -712,7 +746,11 @@ async function addAgentDefinition(def: AgentDefinition, moduleName: string) {
712
746
  registerAgentScratchNames(agentFqName, scratchNames);
713
747
  }
714
748
  // Don't add llm to module attrs if it wasn't originally specified
715
- addAgent(def.name, attrs, moduleName);
749
+ const agent = addAgent(def.name, attrs, moduleName);
750
+ if (ispub) {
751
+ agent.setPublic(true);
752
+ }
753
+ return agent;
716
754
  }
717
755
 
718
756
  function processAgentArray(array: ArrayLiteral, attrName: string): string {
@@ -774,6 +812,58 @@ function addDecisionDefinition(def: DecisionDefinition, moduleName: string) {
774
812
  }
775
813
  }
776
814
 
815
+ function addScenarioDefintion(def: ScenarioDefinition, moduleName: string) {
816
+ if (def.body) {
817
+ let n = rootRef(def.name);
818
+ if (!isFqName(n)) {
819
+ n = makeFqName(moduleName, n);
820
+ }
821
+ const m = asStringLiteralsMap(def.body);
822
+ const user = m.get('user');
823
+ const ai = m.get('ai');
824
+ if (user && ai) addAgentScenario(n, { user: user, ai: ai, internal: false });
825
+ else throw new Error(`scenario ${def.name} requires both user and ai entries`);
826
+ fetchModule(moduleName).addScenario(def);
827
+ }
828
+ }
829
+
830
+ function addDirectiveDefintion(def: DirectiveDefinition, moduleName: string) {
831
+ if (def.body) {
832
+ let n = rootRef(def.name);
833
+ if (!isFqName(n)) {
834
+ n = makeFqName(moduleName, n);
835
+ }
836
+ const m = asStringLiteralsMap(def.body);
837
+ const cond = m.get('if');
838
+ const then = m.get('then');
839
+ if (cond && then) addAgentDirective(n, { cond: cond, then: then, internal: false });
840
+ else throw new Error(`directive ${def.name} requires both if and then entries`);
841
+ fetchModule(moduleName).addDirective(def);
842
+ }
843
+ }
844
+
845
+ function addGlossaryEntryDefintion(def: GlossaryEntryDefinition, moduleName: string) {
846
+ if (def.body) {
847
+ let n = rootRef(def.name);
848
+ if (!isFqName(n)) {
849
+ n = makeFqName(moduleName, n);
850
+ }
851
+ const m = asStringLiteralsMap(def.body);
852
+ const name = m.get('name');
853
+ const meaning = m.get('meaning');
854
+ const syn = m.get('synonyms');
855
+ if (name && meaning)
856
+ addAgentGlossaryEntry(n, {
857
+ name: name,
858
+ meaning: meaning,
859
+ synonyms: syn,
860
+ internal: false,
861
+ });
862
+ else throw new Error(`glossaryEntry ${def.name} requires both name and meaning keys`);
863
+ fetchModule(moduleName).addGlossaryEntry(def);
864
+ }
865
+ }
866
+
777
867
  function addResolverDefinition(def: ResolverDefinition, moduleName: string) {
778
868
  const resolverName = `${moduleName}/${def.name}`;
779
869
  const paths = def.paths;
@@ -826,14 +916,20 @@ function asResolverFn(fname: string): Function {
826
916
  export async function addFromDef(def: Definition, moduleName: string) {
827
917
  if (isEntityDefinition(def)) addSchemaFromDef(def, moduleName);
828
918
  else if (isEventDefinition(def)) addSchemaFromDef(def, moduleName);
919
+ else if (isPublicEventDefinition(def)) addSchemaFromDef(def.def, moduleName, true);
829
920
  else if (isRecordDefinition(def)) addSchemaFromDef(def, moduleName);
830
921
  else if (isRelationshipDefinition(def)) addRelationshipFromDef(def, moduleName);
831
922
  else if (isWorkflowDefinition(def)) addWorkflowFromDef(def, moduleName);
923
+ else if (isPublicWorkflowDefinition(def)) addWorkflowFromDef(def.def, moduleName, true);
832
924
  else if (isAgentDefinition(def)) await addAgentDefinition(def, moduleName);
925
+ else if (isPublicAgentDefinition(def)) await addAgentDefinition(def.def, moduleName, true);
833
926
  else if (isStandaloneStatement(def)) addStandaloneStatement(def.stmt, moduleName);
834
927
  else if (isResolverDefinition(def)) addResolverDefinition(def, moduleName);
835
928
  else if (isFlowDefinition(def)) addFlowDefinition(def, moduleName);
836
929
  else if (isDecisionDefinition(def)) addDecisionDefinition(def, moduleName);
930
+ else if (isScenarioDefinition(def)) addScenarioDefintion(def, moduleName);
931
+ else if (isDirectiveDefinition(def)) addDirectiveDefintion(def, moduleName);
932
+ else if (isGlossaryEntryDefinition(def)) addGlossaryEntryDefintion(def, moduleName);
837
933
  }
838
934
 
839
935
  export async function parseAndIntern(code: string, moduleName?: string) {