agentlang 0.9.0 → 0.9.2

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 (70) hide show
  1. package/out/language/generated/ast.d.ts +26 -14
  2. package/out/language/generated/ast.d.ts.map +1 -1
  3. package/out/language/generated/ast.js +23 -6
  4. package/out/language/generated/ast.js.map +1 -1
  5. package/out/language/generated/grammar.d.ts.map +1 -1
  6. package/out/language/generated/grammar.js +400 -214
  7. package/out/language/generated/grammar.js.map +1 -1
  8. package/out/language/main.cjs +414 -218
  9. package/out/language/main.cjs.map +2 -2
  10. package/out/language/syntax.d.ts +6 -2
  11. package/out/language/syntax.d.ts.map +1 -1
  12. package/out/language/syntax.js +19 -6
  13. package/out/language/syntax.js.map +1 -1
  14. package/out/runtime/agents/common.d.ts +1 -1
  15. package/out/runtime/agents/common.d.ts.map +1 -1
  16. package/out/runtime/agents/common.js +6 -2
  17. package/out/runtime/agents/common.js.map +1 -1
  18. package/out/runtime/defs.d.ts +9 -7
  19. package/out/runtime/defs.d.ts.map +1 -1
  20. package/out/runtime/defs.js +11 -7
  21. package/out/runtime/defs.js.map +1 -1
  22. package/out/runtime/exec-graph.d.ts.map +1 -1
  23. package/out/runtime/exec-graph.js +32 -2
  24. package/out/runtime/exec-graph.js.map +1 -1
  25. package/out/runtime/interpreter.d.ts +4 -1
  26. package/out/runtime/interpreter.d.ts.map +1 -1
  27. package/out/runtime/interpreter.js +54 -8
  28. package/out/runtime/interpreter.js.map +1 -1
  29. package/out/runtime/mcpclient.d.ts +46 -0
  30. package/out/runtime/mcpclient.d.ts.map +1 -0
  31. package/out/runtime/mcpclient.js +457 -0
  32. package/out/runtime/mcpclient.js.map +1 -0
  33. package/out/runtime/module.d.ts +8 -1
  34. package/out/runtime/module.d.ts.map +1 -1
  35. package/out/runtime/module.js +66 -6
  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 +6 -20
  39. package/out/runtime/modules/ai.js.map +1 -1
  40. package/out/runtime/modules/auth.js +2 -2
  41. package/out/runtime/modules/core.d.ts.map +1 -1
  42. package/out/runtime/modules/core.js +6 -1
  43. package/out/runtime/modules/core.js.map +1 -1
  44. package/out/runtime/modules/mcp.d.ts +6 -0
  45. package/out/runtime/modules/mcp.d.ts.map +1 -0
  46. package/out/runtime/modules/mcp.js +43 -0
  47. package/out/runtime/modules/mcp.js.map +1 -0
  48. package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -1
  49. package/out/runtime/resolvers/sqldb/database.js +3 -2
  50. package/out/runtime/resolvers/sqldb/database.js.map +1 -1
  51. package/out/syntaxes/agentlang.monarch.d.ts.map +1 -1
  52. package/out/syntaxes/agentlang.monarch.js +1 -0
  53. package/out/syntaxes/agentlang.monarch.js.map +1 -1
  54. package/package.json +3 -2
  55. package/src/language/agentlang.langium +10 -4
  56. package/src/language/generated/ast.ts +49 -19
  57. package/src/language/generated/grammar.ts +400 -214
  58. package/src/language/syntax.ts +24 -7
  59. package/src/runtime/agents/common.ts +6 -2
  60. package/src/runtime/defs.ts +5 -0
  61. package/src/runtime/exec-graph.ts +36 -1
  62. package/src/runtime/interpreter.ts +68 -7
  63. package/src/runtime/mcpclient.ts +542 -0
  64. package/src/runtime/module.ts +70 -7
  65. package/src/runtime/modules/ai.ts +6 -22
  66. package/src/runtime/modules/auth.ts +2 -2
  67. package/src/runtime/modules/core.ts +5 -1
  68. package/src/runtime/modules/mcp.ts +45 -0
  69. package/src/runtime/resolvers/sqldb/database.ts +3 -2
  70. package/src/syntaxes/agentlang.monarch.ts +1 -0
@@ -5,10 +5,11 @@ import {
5
5
  isDecisionDefinition,
6
6
  isFlowDefinition,
7
7
  ModuleDefinition,
8
+ Statement,
8
9
  } from './generated/ast.js';
9
10
  import { createAgentlangServices } from './agentlang-module.js';
10
11
  import { EmptyFileSystem } from 'langium';
11
- import { introspect, parseModule } from './parser.js';
12
+ import { introspect, parseModule, parseStatement } from './parser.js';
12
13
 
13
14
  export class BasePattern {
14
15
  alias: string | undefined;
@@ -806,16 +807,31 @@ function patternsToString(body: BasePattern[], sep = ';\n'): string {
806
807
 
807
808
  export class FlowStepPattern extends BasePattern {
808
809
  first: string;
809
- next: string;
810
+ next: Statement | undefined;
810
811
  condition?: string;
811
812
 
812
- constructor(first: string, next: string, condition?: string) {
813
+ constructor(first: string, next?: Statement, condition?: string) {
813
814
  super();
814
815
  this.first = first;
815
816
  this.next = next;
816
817
  this.condition = condition ? trimQuotes(condition) : undefined;
817
818
  }
818
819
 
820
+ async setNextFromString(pattern: string): Promise<FlowStepPattern> {
821
+ this.next = await parseStatement(pattern);
822
+ return this;
823
+ }
824
+
825
+ setNext(next: Statement): FlowStepPattern {
826
+ this.next = next;
827
+ return this;
828
+ }
829
+
830
+ setCondition(condition: string): FlowStepPattern {
831
+ this.condition = condition;
832
+ return this;
833
+ }
834
+
819
835
  static async Parse(s: string): Promise<FlowStepPattern> {
820
836
  const p = await parseModule(`module Temp
821
837
  flow tempFlow {
@@ -826,9 +842,9 @@ export class FlowStepPattern extends BasePattern {
826
842
  if (isFlowDefinition(d)) {
827
843
  d.body?.entries.forEach((fe: FlowEntry) => {
828
844
  if (fe.cond) {
829
- result = new FlowStepPattern(fe.root, fe.cond.next.$cstNode?.text || '', fe.cond.expr);
845
+ result = new FlowStepPattern(fe.root, fe.cond.next, fe.cond.expr);
830
846
  } else {
831
- result = new FlowStepPattern(fe.root, fe.next?.$cstNode?.text || '');
847
+ result = new FlowStepPattern(fe.root, fe.next);
832
848
  }
833
849
  });
834
850
  }
@@ -839,10 +855,11 @@ export class FlowStepPattern extends BasePattern {
839
855
  }
840
856
 
841
857
  override toString(): string {
858
+ const nxt = this.next === undefined ? '' : this.next.$cstNode?.text;
842
859
  if (this.condition) {
843
- return `${this.first} --> "${this.condition}" ${this.next}`;
860
+ return `${this.first} --> "${this.condition}" ${nxt}`;
844
861
  } else {
845
- return `${this.first} --> ${this.next}`;
862
+ return `${this.first} --> ${nxt}`;
846
863
  }
847
864
  }
848
865
  }
@@ -275,8 +275,7 @@ acceptOrder --> sendPaymentLinkToCustomer
275
275
  rejectOrder --> sendRejectionEmailToCustomer
276
276
 
277
277
  Along with this flowchart, you'll be passed a "context", which contain the steps in the flowchart that was executed so far, along with
278
- their results. Based on the context, you need to return the name of the step that needs to execute next. If you have reached the end
279
- of the chart, return 'DONE'.
278
+ their results. Based on the context, you need to return the step that needs to execute next. If you have reached the end of the chart, return 'DONE'.
280
279
 
281
280
  At the beginning of the execution, the context will contain only the order information, say something like:
282
281
 
@@ -311,6 +310,11 @@ The 'sendPaymentLinkToCustomer' has returned the customer email. You look at the
311
310
  Generally a flowchart has the following two types of entries:
312
311
  1. a --> b, meaning after step 'a' do step 'b'.
313
312
  2. a --> "x" b - this means if 'a' returns the string "x", then do step 'b'.
313
+ The node 'b' can be a simple name of the next step or a complex pattern like: \`{acme.core/createProduct {productNo 19089, name "X200"}}\` or
314
+ \`{acme.core/createProduct {productNo 19089, name "X200"}} @as NewProductCreated\`. In all cases, you must return the complete step-specification
315
+ when you are required to produce the next step to execute. That is, return the spec -- complete with the enclosing \`{\` and \`}\` and the \`@as <alias>\` specification,
316
+ if that's provided.
317
+
314
318
  If you detect that you have reached the end of the chart, return 'DONE'. Otherwise, return only the name of the next step. Never return
315
319
  any additional description, direction or comments.
316
320
 
@@ -121,6 +121,7 @@ export const FlowSuspensionTag = `--`;
121
121
  export enum SubGraphType {
122
122
  EVENT,
123
123
  IF,
124
+ IF_WITH_ALIAS,
124
125
  FOR_EACH,
125
126
  DELETE,
126
127
  PURGE,
@@ -206,6 +207,10 @@ export class ExecGraph {
206
207
  return this.fetchSubGraphAt(this.subGraphs.length - 1);
207
208
  }
208
209
 
210
+ fetchIfWithAliasSubGraph(): ExecGraph {
211
+ return this.fetchSubGraphAt(this.subGraphs.length - 1);
212
+ }
213
+
209
214
  fetchIfConsequentSubGraph(): ExecGraph {
210
215
  if (this.subGraphs.length >= 2) {
211
216
  return this.fetchSubGraphAt(this.subGraphs.length - 2);
@@ -5,6 +5,7 @@ import {
5
5
  ForEach,
6
6
  FullTextSearch,
7
7
  If,
8
+ IfWithAlias,
8
9
  isPattern,
9
10
  isStatement,
10
11
  isWorkflowDefinition,
@@ -12,6 +13,7 @@ import {
12
13
  Pattern,
13
14
  Purge,
14
15
  Return,
16
+ RuntimeHint,
15
17
  Statement,
16
18
  ThrowError,
17
19
  } from '../language/generated/ast.js';
@@ -24,7 +26,9 @@ import {
24
26
  evaluatePattern,
25
27
  evaluateStatement,
26
28
  handleAgentInvocation,
29
+ handleMcpEvent,
27
30
  handleOpenApiEvent,
31
+ isMcpEventInstance,
28
32
  maybeBindStatementResultToAlias,
29
33
  maybeDeleteQueriedInstances,
30
34
  PatternHandler,
@@ -135,6 +139,12 @@ class GraphGenerator extends PatternHandler {
135
139
  this.addSubGraph(SubGraphType.IF, cond, env);
136
140
  }
137
141
 
142
+ override async handleIfWithAlias(ifWithAlias: IfWithAlias, env: Environment) {
143
+ const handler = new GraphGenerator();
144
+ await handler.handleIf(ifWithAlias.if, env);
145
+ this.addSubGraph(SubGraphType.IF_WITH_ALIAS, handler.getGraph(), env);
146
+ }
147
+
138
148
  private async handleSubPattern(subGraphType: SubGraphType, pat: Pattern, env: Environment) {
139
149
  const newEnv = Environment.from(env).setActiveUserData(pat);
140
150
  const handler = new GraphGenerator();
@@ -256,6 +266,12 @@ export async function executeGraph(execGraph: ExecGraph, env: Environment): Prom
256
266
  env.setLastResult(newEnv.getLastResult());
257
267
  break;
258
268
  }
269
+ case SubGraphType.IF_WITH_ALIAS: {
270
+ const newEnv = new Environment(`${env.name}-if`, env);
271
+ await executeIfSubGraph(subg.fetchIfWithAliasSubGraph(), newEnv);
272
+ env.setLastResult(newEnv.getLastResult());
273
+ break;
274
+ }
259
275
  case SubGraphType.FOR_EACH: {
260
276
  const newEnv = new Environment(`${env.name}-forEach`, env);
261
277
  await executeForEachSubGraph(subg, node, newEnv);
@@ -278,7 +294,10 @@ export async function executeGraph(execGraph: ExecGraph, env: Environment): Prom
278
294
  throw new Error(`Invalid sub-graph type: ${node.subGraphType}`);
279
295
  }
280
296
  }
281
- maybeSetAlias(node, env);
297
+ const aliasHints = fetchAliasHints(node);
298
+ if (aliasHints) {
299
+ maybeBindStatementResultToAlias(aliasHints, env);
300
+ }
282
301
  }
283
302
  } catch (reason: any) {
284
303
  if (monitoringEnabled) env.setMonitorEntryError(reason);
@@ -437,6 +456,10 @@ export async function executeEventHelper(eventInstance: Instance, env?: Environm
437
456
  env = env || new Environment();
438
457
  await handleOpenApiEvent(eventInstance, env);
439
458
  return env.getLastResult();
459
+ } else if (isMcpEventInstance(eventInstance)) {
460
+ env = env || new Environment();
461
+ await handleMcpEvent(eventInstance, env);
462
+ return env.getLastResult();
440
463
  }
441
464
  const fqn = eventInstance.getFqName();
442
465
  let isLocalEnv = false;
@@ -453,6 +476,7 @@ export async function executeEventHelper(eventInstance: Instance, env?: Environm
453
476
  }
454
477
  const oldModuleName = env.switchActiveModuleName(eventInstance.moduleName);
455
478
  env.bind(eventInstance.name, eventInstance);
479
+ env.bind(eventInstance.getFqName(), eventInstance);
456
480
  try {
457
481
  if (g) {
458
482
  await executeGraph(g, env);
@@ -570,6 +594,17 @@ export async function parseAndExecuteStatement(
570
594
  }
571
595
  }
572
596
 
597
+ function fetchAliasHints(node: ExecGraphNode): RuntimeHint[] | undefined {
598
+ const stmt = node.code as Statement;
599
+ const hints = stmt.hints;
600
+ if (hints && hints.length > 0) {
601
+ return hints.filter((rh: RuntimeHint) => {
602
+ return rh.aliasSpec;
603
+ });
604
+ }
605
+ return undefined;
606
+ }
607
+
573
608
  function maybeSetAlias(node: ExecGraphNode, env: Environment) {
574
609
  const stmt = node.code as Statement;
575
610
  const hints = stmt.hints;
@@ -8,6 +8,7 @@ import {
8
8
  FullTextSearch,
9
9
  Handler,
10
10
  If,
11
+ IfWithAlias,
11
12
  isBinExpr,
12
13
  isGroup,
13
14
  isLiteral,
@@ -52,6 +53,8 @@ import {
52
53
  Relationship,
53
54
  Workflow,
54
55
  setMetaAttributes,
56
+ Event,
57
+ isOneToOneBetweenRelationship,
55
58
  } from './module.js';
56
59
  import { JoinInfo, Resolver, WhereClause } from './resolvers/interface.js';
57
60
  import { ResolverAuthInfo } from './resolvers/authinfo.js';
@@ -107,6 +110,7 @@ import { FlowSpec, FlowStep, getAgentFlow } from './agents/flows.js';
107
110
  import { isMonitoringEnabled } from './state.js';
108
111
  import { Monitor, MonitorEntry } from './monitor.js';
109
112
  import { detailedDiff } from 'deep-object-diff';
113
+ import { callMcpTool, mcpClientNameFromToolEvent } from './mcpclient.js';
110
114
 
111
115
  export type Result = any;
112
116
 
@@ -1215,6 +1219,10 @@ export class PatternHandler {
1215
1219
  await evaluateIf(_if, env);
1216
1220
  }
1217
1221
 
1222
+ async handleIfWithAlias(ifWithAlias: IfWithAlias, env: Environment) {
1223
+ await evaluateIfWithAlias(ifWithAlias, env);
1224
+ }
1225
+
1218
1226
  async handleDelete(del: Delete, env: Environment) {
1219
1227
  await evaluateDelete(del, env);
1220
1228
  }
@@ -1251,6 +1259,8 @@ export async function evaluatePattern(
1251
1259
  await handler.handleForEach(pat.forEach, env);
1252
1260
  } else if (pat.if) {
1253
1261
  await handler.handleIf(pat.if, env);
1262
+ } else if (pat.ifWithAlias) {
1263
+ await handler.handleIfWithAlias(pat.ifWithAlias, env);
1254
1264
  } else if (pat.delete) {
1255
1265
  await handler.handleDelete(pat.delete, env);
1256
1266
  } else if (pat.purge) {
@@ -1414,7 +1424,9 @@ async function instanceFromSource(crud: CrudMap, env: Environment): Promise<Inst
1414
1424
  await evaluateLiteral(crud.source, env);
1415
1425
  const attrsSrc = env.getLastResult();
1416
1426
  if (attrsSrc && attrsSrc instanceof Object) {
1417
- const attrs: InstanceAttributes = new Map(Object.entries(attrsSrc));
1427
+ const obj =
1428
+ attrsSrc instanceof Instance ? (attrsSrc as Instance).userAttributesAsObject() : attrsSrc;
1429
+ const attrs: InstanceAttributes = new Map(Object.entries(obj));
1418
1430
  const nparts = nameToPath(crud.name);
1419
1431
  const n = nparts.getEntryName();
1420
1432
  const m = nparts.hasModule() ? nparts.getModuleName() : env.getActiveModuleName();
@@ -1606,8 +1618,25 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1606
1618
  isReadForUpdate,
1607
1619
  env.isInDeleteMode()
1608
1620
  );
1609
- const insts: Instance[] = await res.queryInstances(inst, isQueryAll, distinct);
1610
- env.setLastResult(insts);
1621
+ let oneToOne = false;
1622
+ let rel: Relationship | undefined;
1623
+ if (isBetRel && env.isInDeleteMode()) {
1624
+ rel = getRelationship(inst.name, inst.moduleName);
1625
+ oneToOne = rel.isOneToOne();
1626
+ }
1627
+ if (oneToOne && rel !== undefined) {
1628
+ await res.handleInstancesLink(
1629
+ inst.lookupQueryVal(rel.node1.alias),
1630
+ inst.lookupQueryVal(rel.node2.alias),
1631
+ rel,
1632
+ false,
1633
+ true
1634
+ );
1635
+ env.setLastResult(inst);
1636
+ } else {
1637
+ const insts: Instance[] = await res.queryInstances(inst, isQueryAll, distinct);
1638
+ env.setLastResult(insts);
1639
+ }
1611
1640
  }
1612
1641
  if (crud.relationships !== undefined) {
1613
1642
  const lastRes: Instance[] = env.getLastResult();
@@ -1674,6 +1703,7 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1674
1703
  if (isAgentEventInstance(inst)) await handleAgentInvocation(inst, env);
1675
1704
  else if (isOpenApiEventInstance(inst)) await handleOpenApiEvent(inst, env);
1676
1705
  else if (isDocEventInstance(inst)) await handleDocEvent(inst, env);
1706
+ else if (isMcpEventInstance(inst)) await handleMcpEvent(inst, env);
1677
1707
  else {
1678
1708
  const eventExec = env.getEventExecutor();
1679
1709
  const newEnv = new Environment(`${inst.name}.env`, env);
@@ -1697,6 +1727,11 @@ function isDocEventInstance(inst: Instance): boolean {
1697
1727
  return isInstanceOfType(inst, DocEventName);
1698
1728
  }
1699
1729
 
1730
+ export function isMcpEventInstance(inst: Instance): boolean {
1731
+ const event: Event = inst.record as Event;
1732
+ return event.isMcpTool();
1733
+ }
1734
+
1700
1735
  async function handleDocEvent(inst: Instance, env: Environment): Promise<void> {
1701
1736
  const s = await fetchDoc(inst.lookup('url'));
1702
1737
  if (s) {
@@ -1709,6 +1744,17 @@ async function handleDocEvent(inst: Instance, env: Environment): Promise<void> {
1709
1744
  }
1710
1745
  }
1711
1746
 
1747
+ export async function handleMcpEvent(inst: Instance, env: Environment): Promise<void> {
1748
+ const mcpClientName = mcpClientNameFromToolEvent(inst);
1749
+ const clientInsts: Instance[] = await parseAndEvaluateStatement(
1750
+ `{agentlang.mcp/Client {name? "${mcpClientName}"}}`,
1751
+ undefined,
1752
+ env
1753
+ );
1754
+ const result = await callMcpTool(clientInsts[0], inst);
1755
+ env.setLastResult(result);
1756
+ }
1757
+
1712
1758
  async function computeExprAttributes(
1713
1759
  inst: Instance,
1714
1760
  origAttrs: SetAttribute[] | undefined,
@@ -2093,7 +2139,7 @@ async function iterateOnFlow(
2093
2139
  env.setFlowContext(initContext);
2094
2140
  await agentInvoke(rootAgent, s, env);
2095
2141
  const rootModuleName = rootAgent.moduleName;
2096
- let preprocResult = await preprocessStep(env.getLastResult().trim(), rootModuleName, env);
2142
+ let preprocResult = await preprocessStep(env.getLastResult(), rootModuleName, env);
2097
2143
  let step = preprocResult.step;
2098
2144
  let needAgentProcessing = preprocResult.needAgentProcessing;
2099
2145
  let context = initContext;
@@ -2147,11 +2193,11 @@ async function iterateOnFlow(
2147
2193
  );
2148
2194
  context = `${context}\n${step} --> ${rs}\n`;
2149
2195
  if (isfxc) {
2150
- preprocResult = await preprocessStep(rs.trim(), rootModuleName, env);
2196
+ preprocResult = await preprocessStep(rs, rootModuleName, env);
2151
2197
  } else {
2152
2198
  env.setFlowContext(context);
2153
2199
  await agentInvoke(rootAgent, `${s}\n${context}`, env);
2154
- preprocResult = await preprocessStep(env.getLastResult().trim(), rootModuleName, env);
2200
+ preprocResult = await preprocessStep(env.getLastResult(), rootModuleName, env);
2155
2201
  }
2156
2202
  step = preprocResult.step;
2157
2203
  needAgentProcessing = preprocResult.needAgentProcessing;
@@ -2173,7 +2219,8 @@ async function preprocessStep(
2173
2219
  env: Environment
2174
2220
  ): Promise<PreprocStepResult> {
2175
2221
  let needAgentProcessing = true;
2176
- if (spec.startsWith('{')) {
2222
+ spec = trimGeneratedCode(spec);
2223
+ if (spec.startsWith('{') || spec.indexOf(' ') > 0) {
2177
2224
  const newEnv = Environment.from(env, env.name + '_flow_eval', false, true).setActiveModuleName(
2178
2225
  activeModuleName
2179
2226
  );
@@ -2229,6 +2276,10 @@ async function evaluateIf(ifStmt: If, env: Environment): Promise<void> {
2229
2276
  }
2230
2277
  }
2231
2278
 
2279
+ async function evaluateIfWithAlias(ifWithAlias: IfWithAlias, env: Environment): Promise<void> {
2280
+ await evaluateIf(ifWithAlias.if, env);
2281
+ }
2282
+
2232
2283
  async function evaluateDeleteHelper(
2233
2284
  pattern: Pattern,
2234
2285
  purge: boolean,
@@ -2248,6 +2299,11 @@ export async function maybeDeleteQueriedInstances(
2248
2299
  let resolver: Resolver = Resolver.Default;
2249
2300
  if (inst instanceof Array) {
2250
2301
  if (inst.length > 0) {
2302
+ if (isOneToOneBetweenRelationship(inst[0].name, inst[0].moduleName)) {
2303
+ // delete already handled in evaluateCrudMap
2304
+ env.setLastResult(inst);
2305
+ return;
2306
+ }
2251
2307
  resolver = await getResolverForPath(inst[0].name, inst[0].moduleName, queryEnv);
2252
2308
  const finalResult: Array<any> = new Array<any>();
2253
2309
  for (let i = 0; i < inst.length; ++i) {
@@ -2261,6 +2317,11 @@ export async function maybeDeleteQueriedInstances(
2261
2317
  queryEnv.setLastResult(inst);
2262
2318
  }
2263
2319
  } else {
2320
+ if (isOneToOneBetweenRelationship(inst.name, inst.moduleName)) {
2321
+ // delete already handled in evaluateCrudMap
2322
+ env.setLastResult([inst]);
2323
+ return;
2324
+ }
2264
2325
  resolver = await getResolverForPath(inst.name, inst.moduleName, queryEnv);
2265
2326
  await runPreDeleteEvents(inst, env);
2266
2327
  const r: Instance | null = await resolver.deleteInstance(inst, purge);