agency-lang 0.0.21 → 0.0.23
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.
- package/dist/lib/backends/agencyGenerator.d.ts +10 -2
- package/dist/lib/backends/agencyGenerator.js +87 -20
- package/dist/lib/backends/agencyGenerator.test.js +0 -48
- package/dist/lib/backends/baseGenerator.d.ts +11 -4
- package/dist/lib/backends/baseGenerator.js +35 -11
- package/dist/lib/backends/graphGenerator.js +19 -186
- package/dist/lib/backends/typescriptGenerator/builtins.js +6 -0
- package/dist/lib/backends/typescriptGenerator.d.ts +11 -3
- package/dist/lib/backends/typescriptGenerator.js +98 -26
- package/dist/lib/backends/utils.d.ts +1 -1
- package/dist/lib/parser.js +5 -5
- package/dist/lib/parser.test.js +15 -38
- package/dist/lib/parsers/access.test.js +14 -3
- package/dist/lib/parsers/assignment.test.js +159 -4
- package/dist/lib/parsers/await.d.ts +3 -0
- package/dist/lib/parsers/await.js +18 -0
- package/dist/lib/parsers/body.test.js +10 -1
- package/dist/lib/parsers/dataStructures.js +2 -2
- package/dist/lib/parsers/dataStructures.test.js +11 -11
- package/dist/lib/parsers/function.d.ts +8 -3
- package/dist/lib/parsers/function.js +64 -12
- package/dist/lib/parsers/function.test.js +284 -52
- package/dist/lib/parsers/functionCall.test.js +6 -6
- package/dist/lib/parsers/ifElse.test.d.ts +1 -0
- package/dist/lib/parsers/ifElse.test.js +376 -0
- package/dist/lib/parsers/importStatement.js +2 -2
- package/dist/lib/parsers/literals.d.ts +1 -0
- package/dist/lib/parsers/literals.js +6 -2
- package/dist/lib/parsers/literals.test.js +110 -21
- package/dist/lib/parsers/matchBlock.js +7 -4
- package/dist/lib/parsers/matchBlock.test.js +16 -16
- package/dist/lib/parsers/newline.d.ts +3 -0
- package/dist/lib/parsers/newline.js +2 -0
- package/dist/lib/parsers/parserUtils.d.ts +3 -1
- package/dist/lib/parsers/parserUtils.js +4 -1
- package/dist/lib/parsers/returnStatement.js +2 -1
- package/dist/lib/parsers/returnStatement.test.js +2 -2
- package/dist/lib/parsers/specialVar.test.js +7 -7
- package/dist/lib/parsers/typeHints.d.ts +1 -1
- package/dist/lib/parsers/typeHints.js +4 -4
- package/dist/lib/parsers/typeHints.test.js +0 -8
- package/dist/lib/parsers/utils.d.ts +1 -0
- package/dist/lib/parsers/utils.js +2 -1
- package/dist/lib/parsers/whileLoop.test.js +46 -1
- package/dist/lib/templates/backends/graphGenerator/goToNode.d.ts +2 -1
- package/dist/lib/templates/backends/graphGenerator/goToNode.js +11 -1
- package/dist/lib/templates/backends/graphGenerator/graphNode.d.ts +2 -2
- package/dist/lib/templates/backends/graphGenerator/graphNode.js +2 -1
- package/dist/lib/templates/backends/graphGenerator/imports.d.ts +1 -1
- package/dist/lib/templates/backends/graphGenerator/imports.js +14 -1
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/sleep.d.ts +4 -0
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/sleep.js +13 -0
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/time.d.ts +7 -0
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/time.js +12 -0
- package/dist/lib/templates/backends/typescriptGenerator/functionDefinition.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/functionDefinition.js +1 -0
- package/dist/lib/templates/backends/typescriptGenerator/promptFunction.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/promptFunction.js +3 -2
- package/dist/lib/templates/backends/typescriptGenerator/tool.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/tool.js +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/toolCall.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/toolCall.js +2 -2
- package/dist/lib/types/await.d.ts +7 -0
- package/dist/lib/types/await.js +1 -0
- package/dist/lib/types/graphNode.d.ts +2 -1
- package/dist/lib/types/ifElse.d.ts +7 -0
- package/dist/lib/types/ifElse.js +1 -0
- package/dist/lib/types/literals.d.ts +1 -1
- package/dist/lib/types/returnStatement.d.ts +2 -1
- package/dist/lib/types/timeBlock.d.ts +5 -0
- package/dist/lib/types/timeBlock.js +1 -0
- package/dist/lib/types.d.ts +16 -8
- package/dist/lib/types.js +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +3 -0
- package/package.json +2 -1
- package/dist/lib/parsers/assignment.d.ts +0 -3
- package/dist/lib/parsers/assignment.js +0 -8
- package/dist/lib/templates/backends/graphGenerator/node.d.ts +0 -7
- package/dist/lib/templates/backends/graphGenerator/node.js +0 -18
- package/dist/lib/templates/backends/graphGenerator/promptNode.d.ts +0 -8
- package/dist/lib/templates/backends/graphGenerator/promptNode.js +0 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const template = "if (\n toolCall.name === \"{{{name:string}}}\"\n) {\n const args = toolCall.arguments;\n\n toolCallStartTime = performance.now();\n const result = await {{{name}}}(args);\n toolCallEndTime = performance.now();\n\n console.log(\"Tool '{{{name:string}}}' called with arguments:\", args);\n console.log(\"Tool '{{{name:string}}}' returned result:\", result);\n\nstatelogClient.toolCall({\n toolName: \"{{{name:string}}}\",\n args,\n output: result,\n model: __client.getModel(),\n timeTaken: toolCallEndTime - toolCallStartTime,\n });\n\n // Add function result to messages\n __messages.push(toolMessage(result, {\n tool_call_id: toolCall.id,\n name: toolCall.name,\n }));\n}";
|
|
1
|
+
export declare const template = "if (\n toolCall.name === \"{{{name:string}}}\"\n) {\n const args = toolCall.arguments;\n\n toolCallStartTime = performance.now();\n const result = await {{{name}}}(args);\n toolCallEndTime = performance.now();\n\n // console.log(\"Tool '{{{name:string}}}' called with arguments:\", args);\n // console.log(\"Tool '{{{name:string}}}' returned result:\", result);\n\nstatelogClient.toolCall({\n toolName: \"{{{name:string}}}\",\n args,\n output: result,\n model: __client.getModel(),\n timeTaken: toolCallEndTime - toolCallStartTime,\n });\n\n // Add function result to messages\n __messages.push(toolMessage(result, {\n tool_call_id: toolCall.id,\n name: toolCall.name,\n }));\n}";
|
|
2
2
|
export type TemplateType = {
|
|
3
3
|
name: string;
|
|
4
4
|
};
|
|
@@ -11,8 +11,8 @@ export const template = `if (
|
|
|
11
11
|
const result = await {{{name}}}(args);
|
|
12
12
|
toolCallEndTime = performance.now();
|
|
13
13
|
|
|
14
|
-
console.log("Tool '{{{name:string}}}' called with arguments:", args);
|
|
15
|
-
console.log("Tool '{{{name:string}}}' returned result:", result);
|
|
14
|
+
// console.log("Tool '{{{name:string}}}' called with arguments:", args);
|
|
15
|
+
// console.log("Tool '{{{name:string}}}' returned result:", result);
|
|
16
16
|
|
|
17
17
|
statelogClient.toolCall({
|
|
18
18
|
toolName: "{{{name:string}}}",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AgencyNode, FunctionCall, VariableType } from "../types.js";
|
|
2
2
|
import { AccessExpression } from "./access.js";
|
|
3
|
+
import { FunctionParameter } from "./function.js";
|
|
3
4
|
import { Literal } from "./literals.js";
|
|
4
5
|
export type GraphNodeDefinition = {
|
|
5
6
|
type: "graphNode";
|
|
6
7
|
nodeName: string;
|
|
7
|
-
parameters:
|
|
8
|
+
parameters: FunctionParameter[];
|
|
8
9
|
body: AgencyNode[];
|
|
9
10
|
returnType?: VariableType | null;
|
|
10
11
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AccessExpression, FunctionCall, IndexAccess, Literal } from "../types.js";
|
|
2
|
+
import { AwaitStatement } from "./await.js";
|
|
2
3
|
import { AgencyArray, AgencyObject } from "./dataStructures.js";
|
|
3
4
|
export type ReturnStatement = {
|
|
4
5
|
type: "returnStatement";
|
|
5
|
-
value: AccessExpression | FunctionCall | Literal | AgencyObject | AgencyArray | IndexAccess;
|
|
6
|
+
value: AccessExpression | FunctionCall | Literal | AgencyObject | AgencyArray | IndexAccess | AwaitStatement;
|
|
6
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { Literal } from "./types/literals.js";
|
|
2
|
-
import { TypeAlias, TypeHint, VariableType } from "./types/typeHints.js";
|
|
3
|
-
import { MatchBlock } from "./types/matchBlock.js";
|
|
4
1
|
import { AccessExpression, DotProperty, IndexAccess } from "./types/access.js";
|
|
5
|
-
import {
|
|
2
|
+
import { AwaitStatement } from "./types/await.js";
|
|
6
3
|
import { AgencyArray, AgencyObject } from "./types/dataStructures.js";
|
|
4
|
+
import { FunctionCall, FunctionDefinition } from "./types/function.js";
|
|
7
5
|
import { GraphNodeDefinition } from "./types/graphNode.js";
|
|
6
|
+
import { ImportStatement } from "./types/importStatement.js";
|
|
7
|
+
import { Literal } from "./types/literals.js";
|
|
8
|
+
import { MatchBlock } from "./types/matchBlock.js";
|
|
8
9
|
import { ReturnStatement } from "./types/returnStatement.js";
|
|
10
|
+
import { SpecialVar } from "./types/specialVar.js";
|
|
11
|
+
import { TimeBlock } from "./types/timeBlock.js";
|
|
9
12
|
import { UsesTool } from "./types/tools.js";
|
|
10
|
-
import {
|
|
13
|
+
import { TypeAlias, TypeHint, VariableType } from "./types/typeHints.js";
|
|
11
14
|
import { WhileLoop } from "./types/whileLoop.js";
|
|
12
|
-
import {
|
|
15
|
+
import { IfElse } from "./types/ifElse.js";
|
|
13
16
|
export * from "./types/access.js";
|
|
14
17
|
export * from "./types/dataStructures.js";
|
|
15
18
|
export * from "./types/function.js";
|
|
16
19
|
export * from "./types/graphNode.js";
|
|
20
|
+
export * from "./types/ifElse.js";
|
|
17
21
|
export * from "./types/importStatement.js";
|
|
18
22
|
export * from "./types/literals.js";
|
|
19
23
|
export * from "./types/matchBlock.js";
|
|
@@ -24,13 +28,17 @@ export * from "./types/whileLoop.js";
|
|
|
24
28
|
export type Assignment = {
|
|
25
29
|
type: "assignment";
|
|
26
30
|
variableName: string;
|
|
27
|
-
|
|
31
|
+
typeHint?: VariableType;
|
|
32
|
+
value: AccessExpression | Literal | FunctionCall | AgencyObject | AgencyArray | IndexAccess | TimeBlock | AwaitStatement;
|
|
28
33
|
};
|
|
29
34
|
export type AgencyComment = {
|
|
30
35
|
type: "comment";
|
|
31
36
|
content: string;
|
|
32
37
|
};
|
|
33
|
-
export type
|
|
38
|
+
export type NewLine = {
|
|
39
|
+
type: "newLine";
|
|
40
|
+
};
|
|
41
|
+
export type AgencyNode = TypeHint | TypeAlias | UsesTool | GraphNodeDefinition | FunctionDefinition | Assignment | Literal | FunctionCall | MatchBlock | ReturnStatement | AccessExpression | AgencyComment | AgencyObject | AgencyArray | ImportStatement | WhileLoop | IfElse | SpecialVar | IndexAccess | DotProperty | TimeBlock | AwaitStatement | NewLine;
|
|
34
42
|
export type AgencyProgram = {
|
|
35
43
|
type: "agencyProgram";
|
|
36
44
|
nodes: AgencyNode[];
|
package/dist/lib/types.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./types/access.js";
|
|
|
2
2
|
export * from "./types/dataStructures.js";
|
|
3
3
|
export * from "./types/function.js";
|
|
4
4
|
export * from "./types/graphNode.js";
|
|
5
|
+
export * from "./types/ifElse.js";
|
|
5
6
|
export * from "./types/importStatement.js";
|
|
6
7
|
export * from "./types/literals.js";
|
|
7
8
|
export * from "./types/matchBlock.js";
|
package/dist/lib/utils.d.ts
CHANGED
package/dist/lib/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agency-lang",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "The Agency language",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^25.0.3",
|
|
51
|
+
"cli-highlight": "^2.1.11",
|
|
51
52
|
"nanoid": "^5.1.6",
|
|
52
53
|
"piemachine": "^0.0.3",
|
|
53
54
|
"statelog-client": "^0.0.31",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { capture, char, many1WithJoin, or, seqC, set, trace, } from "tarsec";
|
|
2
|
-
import { accessExpressionParser, indexAccessParser } from "./access.js";
|
|
3
|
-
import { agencyArrayParser, agencyObjectParser } from "./dataStructures.js";
|
|
4
|
-
import { functionCallParser } from "./functionCall.js";
|
|
5
|
-
import { literalParser } from "./literals.js";
|
|
6
|
-
import { optionalSemicolon } from "./parserUtils.js";
|
|
7
|
-
import { optionalSpaces, varNameChar } from "./utils.js";
|
|
8
|
-
export const assignmentParser = trace("assignmentParser", seqC(set("type", "assignment"), optionalSpaces, capture(many1WithJoin(varNameChar), "variableName"), optionalSpaces, char("="), optionalSpaces, capture(or(functionCallParser, indexAccessParser, accessExpressionParser, agencyArrayParser, agencyObjectParser, literalParser), "value"), optionalSemicolon));
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const template = "let {{{name:string}}}:any;\n\ngraph.node(\"{{{name}}}\", async (state) => {\n const innerFunc = async () => {\n {{{body}}}\n };\n {{{name}}} = await innerFunc();\n return {{{name}}};\n});\n";
|
|
2
|
-
export type TemplateType = {
|
|
3
|
-
name: string;
|
|
4
|
-
body: string | boolean | number;
|
|
5
|
-
};
|
|
6
|
-
declare const render: (args: TemplateType) => string;
|
|
7
|
-
export default render;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// THIS FILE WAS AUTO-GENERATED
|
|
2
|
-
// Source: lib/templates/backends/graphGenerator/node.mustache
|
|
3
|
-
// Any manual changes will be lost.
|
|
4
|
-
import { apply } from "typestache";
|
|
5
|
-
export const template = `let {{{name:string}}}:any;
|
|
6
|
-
|
|
7
|
-
graph.node("{{{name}}}", async (state) => {
|
|
8
|
-
const innerFunc = async () => {
|
|
9
|
-
{{{body}}}
|
|
10
|
-
};
|
|
11
|
-
{{{name}}} = await innerFunc();
|
|
12
|
-
return {{{name}}};
|
|
13
|
-
});
|
|
14
|
-
`;
|
|
15
|
-
const render = (args) => {
|
|
16
|
-
return apply(template, args);
|
|
17
|
-
};
|
|
18
|
-
export default render;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const template = "let {{{name:string}}}:any;\n\ngraph.node(\"{{{name}}}\", async (state) => {\n const innerFunc = {{{promptFunction:string}}};\n {{{name}}} = await innerFunc({{{argsStr:string}}});\n return {{{name}}};\n});\n";
|
|
2
|
-
export type TemplateType = {
|
|
3
|
-
name: string;
|
|
4
|
-
promptFunction: string;
|
|
5
|
-
argsStr: string;
|
|
6
|
-
};
|
|
7
|
-
declare const render: (args: TemplateType) => string;
|
|
8
|
-
export default render;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// THIS FILE WAS AUTO-GENERATED
|
|
2
|
-
// Source: lib/templates/backends/graphGenerator/promptNode.mustache
|
|
3
|
-
// Any manual changes will be lost.
|
|
4
|
-
import { apply } from "typestache";
|
|
5
|
-
export const template = `let {{{name:string}}}:any;
|
|
6
|
-
|
|
7
|
-
graph.node("{{{name}}}", async (state) => {
|
|
8
|
-
const innerFunc = {{{promptFunction:string}}};
|
|
9
|
-
{{{name}}} = await innerFunc({{{argsStr:string}}});
|
|
10
|
-
return {{{name}}};
|
|
11
|
-
});
|
|
12
|
-
`;
|
|
13
|
-
const render = (args) => {
|
|
14
|
-
return apply(template, args);
|
|
15
|
-
};
|
|
16
|
-
export default render;
|