agency-lang 0.0.22 → 0.0.24

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.
@@ -48,7 +48,7 @@ export class AgencyGenerator extends BaseGenerator {
48
48
  processTypeAlias(node) {
49
49
  this.typeAliases[node.aliasName] = node.aliasedType;
50
50
  const aliasedTypeStr = this.aliasedTypeToString(node.aliasedType);
51
- return this.indentStr(`type ${node.aliasName} = ${aliasedTypeStr}\n`);
51
+ return this.indentStr(`type ${node.aliasName} = ${aliasedTypeStr}`);
52
52
  }
53
53
  processTypeHint(node) {
54
54
  this.typeHints[node.variableName] = node.variableType;
@@ -57,8 +57,8 @@ export class AgencyGenerator extends BaseGenerator {
57
57
  }
58
58
  // Assignment and literals
59
59
  processAssignment(node) {
60
- const varName = node.typeHint ?
61
- `${node.variableName}: ${variableTypeToString(node.typeHint, this.typeAliases)}`
60
+ const varName = node.typeHint
61
+ ? `${node.variableName}: ${variableTypeToString(node.typeHint, this.typeAliases)}`
62
62
  : node.variableName;
63
63
  if (node.value.type === "timeBlock") {
64
64
  const code = this.processTimeBlock(node.value);
@@ -239,7 +239,7 @@ export class AgencyGenerator extends BaseGenerator {
239
239
  result += this.indentStr(`${pattern} => ${bodyCode}\n`);
240
240
  }
241
241
  this.decreaseIndent();
242
- result += this.indentStr(`}\n`);
242
+ result += this.indentStr(`}`);
243
243
  return result;
244
244
  }
245
245
  processWhileLoop(node) {
@@ -332,7 +332,7 @@ export class AgencyGenerator extends BaseGenerator {
332
332
  }
333
333
  processAwaitStatement(node) {
334
334
  const code = this.processNode(node.expression);
335
- return this.indentStr(`await ${code.trim()}\n`);
335
+ return this.indentStr(`await ${code.trim()}`);
336
336
  }
337
337
  processNewLine(_node) {
338
338
  return "\n";
@@ -145,8 +145,11 @@ export class GraphGenerator extends TypeScriptGenerator {
145
145
  }));
146
146
  }
147
147
  for (const node of this.graphNodes) {
148
+ const args = node.parameters;
149
+ const argsStr = args.map((arg) => arg.name).join(", ");
148
150
  lines.push(renderRunNodeFunction.default({
149
151
  nodeName: node.nodeName,
152
+ argsStr,
150
153
  returnType: node.returnType
151
154
  ? variableTypeToString(node.returnType, this.typeAliases)
152
155
  : "any",
@@ -1,6 +1,7 @@
1
- export declare const template = "export async function {{{nodeName:string}}}(data:any): Promise<{{{returnType:string}}}> {\n const result = await graph.run(\"{{{nodeName:string}}}\", { messages: [], data });\n return result.data;\n}\n";
1
+ export declare const template = "export async function {{{nodeName:string}}}({{{argsStr:string}}}): Promise<{{{returnType:string}}}> {\n const data = { {{{argsStr}}} };\n const result = await graph.run(\"{{{nodeName:string}}}\", { messages: [], data });\n return result.data;\n}\n";
2
2
  export type TemplateType = {
3
3
  nodeName: string;
4
+ argsStr: string;
4
5
  returnType: string;
5
6
  };
6
7
  declare const render: (args: TemplateType) => string;
@@ -2,7 +2,8 @@
2
2
  // Source: lib/templates/backends/graphGenerator/runNodeFunction.mustache
3
3
  // Any manual changes will be lost.
4
4
  import { apply } from "typestache";
5
- export const template = `export async function {{{nodeName:string}}}(data:any): Promise<{{{returnType:string}}}> {
5
+ export const template = `export async function {{{nodeName:string}}}({{{argsStr:string}}}): Promise<{{{returnType:string}}}> {
6
+ const data = { {{{argsStr}}} };
6
7
  const result = await graph.run("{{{nodeName:string}}}", { messages: [], data });
7
8
  return result.data;
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agency-lang",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "The Agency language",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -56,4 +56,4 @@
56
56
  "typescript": "^5.9.3",
57
57
  "vitest": "^4.0.16"
58
58
  }
59
- }
59
+ }