agentlang 0.0.33 → 0.0.35

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.
@@ -19,26 +19,31 @@ export async function prepareIntegrations(
19
19
  const configPath = integConfig.get(configName);
20
20
  if (configPath) {
21
21
  const apiUrl = mkApiUrl(integManagerHost, configPath);
22
- const response = await fetch(apiUrl, {
23
- method: 'GET',
24
- headers: standardHeaders,
25
- });
22
+ try {
23
+ const response = await fetch(apiUrl, {
24
+ method: 'GET',
25
+ headers: standardHeaders,
26
+ });
26
27
 
27
- if (!response.ok) {
28
- throw new Error(
29
- `Failed to fetch integration for ${configPath}, HTTP error! status: ${response.status} ${response.text} ${response.statusText}`
30
- );
31
- }
28
+ if (!response.ok) {
29
+ console.error(
30
+ `Failed to fetch integration for ${configPath}, HTTP error! status: ${response.status} ${response.text} ${response.statusText}`
31
+ );
32
+ continue;
33
+ }
32
34
 
33
- const data = await response.json();
34
- if (data.length > 0) {
35
- const inst: any = data[0].config;
36
- if (inst.type == 'custom' && isString(inst.parameter)) {
37
- inst.parameter = new Map(Object.entries(JSON.parse(inst.parameter)));
35
+ const data = await response.json();
36
+ if (data.length > 0) {
37
+ const inst: any = data[0].config;
38
+ if (inst.type == 'custom' && isString(inst.parameter)) {
39
+ inst.parameter = new Map(Object.entries(JSON.parse(inst.parameter)));
40
+ }
41
+ Integrations.set(configName, inst);
42
+ } else {
43
+ console.error(`Integration not found for ${configPath}`);
38
44
  }
39
- Integrations.set(configName, inst);
40
- } else {
41
- throw new Error(`Integration not found for ${configPath}`);
45
+ } catch (error: any) {
46
+ console.error(`Error fetching integration for ${configPath}:`, error.message);
42
47
  }
43
48
  }
44
49
  }
@@ -302,6 +302,16 @@ export class Environment extends Instance {
302
302
  return this.returnFlag;
303
303
  }
304
304
 
305
+ resetReturnFlag(): Environment {
306
+ if (this.returnFlag) {
307
+ this.returnFlag = false;
308
+ if (this.parent) {
309
+ this.parent.resetReturnFlag();
310
+ }
311
+ }
312
+ return this;
313
+ }
314
+
305
315
  protected propagateSuspension(suspId: string) {
306
316
  this.suspensionId = suspId;
307
317
  if (this.parent) {
@@ -767,10 +777,10 @@ function maybeBindStatementResultToAlias(hints: RuntimeHint[], env: Environment)
767
777
  const resArr: Array<any> = result as Array<any>;
768
778
  for (let i = 0; i < aliases.length; ++i) {
769
779
  const k: string = aliases[i];
770
- if (k == '_') {
780
+ if (k == '__') {
771
781
  env.bind(aliases[i + 1], resArr.splice(i));
772
782
  break;
773
- } else {
783
+ } else if (k != '_') {
774
784
  env.bind(aliases[i], resArr[i]);
775
785
  }
776
786
  }
@@ -1212,7 +1222,10 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
1212
1222
  if (isAgentEventInstance(inst)) await handleAgentInvocation(inst, env);
1213
1223
  else if (isOpenApiEventInstance(inst)) await handleOpenApiEvent(inst, env);
1214
1224
  else if (isDocEventInstance(inst)) await handleDocEvent(inst, env);
1215
- else await evaluate(inst, (result: Result) => env.setLastResult(result), env);
1225
+ else {
1226
+ await evaluate(inst, (result: Result) => env.setLastResult(result), env);
1227
+ env.resetReturnFlag();
1228
+ }
1216
1229
  } else {
1217
1230
  env.setLastResult(inst);
1218
1231
  }
@@ -217,15 +217,17 @@ export class SqlDbResolver extends Resolver {
217
217
  inst.addQuery(col, '=', connectedInstance.lookup(PathAttributeName));
218
218
  return await this.queryInstances(inst, false);
219
219
  } else {
220
+ const from = relationship.getAliasFor(connectedInstance);
221
+ const to = relationship.getInverseAliasFor(connectedInstance);
220
222
  await getAllConnected(
221
223
  asTableReference(inst.moduleName, inst.name),
222
224
  inst.queryAttributesAsObject(),
223
225
  inst.queryAttributeValuesAsObject(),
224
226
  {
225
227
  connectionTable: asTableReference(inst.moduleName, relationship.name),
226
- fromColumn: relationship.node1.alias,
228
+ fromColumn: from,
227
229
  fromValue: `'${connectedInstance.lookup(PathAttributeName)}'`,
228
- toColumn: relationship.node2.alias,
230
+ toColumn: to,
229
231
  toRef: PathAttributeName,
230
232
  },
231
233
  this.getDbContext(inst.getFqName())