agency-lang 0.0.14 → 0.0.16
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.js +20 -3
- package/dist/lib/backends/agencyGenerator.test.d.ts +1 -0
- package/dist/lib/backends/agencyGenerator.test.js +205 -0
- package/dist/lib/backends/baseGenerator.js +3 -1
- package/dist/lib/backends/graphGenerator.js +7 -5
- package/dist/lib/backends/typescriptGenerator.d.ts +3 -3
- package/dist/lib/backends/typescriptGenerator.js +20 -15
- package/dist/lib/parsers/access.d.ts +3 -5
- package/dist/lib/parsers/access.js +54 -13
- package/dist/lib/parsers/access.test.js +40 -500
- package/dist/lib/parsers/assignment.js +2 -2
- package/dist/lib/parsers/assignment.test.d.ts +1 -0
- package/dist/lib/parsers/assignment.test.js +279 -0
- package/dist/lib/parsers/dataStructures.js +3 -3
- package/dist/lib/parsers/function.d.ts +3 -1
- package/dist/lib/parsers/function.js +6 -4
- package/dist/lib/parsers/function.test.js +653 -8
- package/dist/lib/parsers/functionCall.js +3 -2
- package/dist/lib/parsers/functionCall.test.js +310 -0
- package/dist/lib/parsers/literals.js +11 -2
- package/dist/lib/parsers/literals.test.js +7 -7
- package/dist/lib/parsers/matchBlock.js +2 -2
- package/dist/lib/parsers/parserUtils.test.d.ts +1 -0
- package/dist/lib/parsers/parserUtils.test.js +46 -0
- package/dist/lib/parsers/returnStatement.js +2 -2
- package/dist/lib/parsers/returnStatement.test.d.ts +1 -0
- package/dist/lib/parsers/returnStatement.test.js +268 -0
- package/dist/lib/parsers/specialVar.test.d.ts +1 -0
- package/dist/lib/parsers/specialVar.test.js +219 -0
- package/dist/lib/templates/backends/graphGenerator/builtinTools.d.ts +1 -1
- package/dist/lib/templates/backends/graphGenerator/builtinTools.js +8 -23
- package/dist/lib/templates/backends/graphGenerator/imports.d.ts +1 -1
- package/dist/lib/templates/backends/graphGenerator/imports.js +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/promptFunction.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/promptFunction.js +2 -2
- package/dist/lib/templates/backends/typescriptGenerator/tool.d.ts +2 -3
- package/dist/lib/templates/backends/typescriptGenerator/tool.js +5 -14
- package/dist/lib/templates/backends/typescriptGenerator/toolCall.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/toolCall.js +7 -8
- package/dist/lib/types/access.d.ts +5 -5
- package/dist/lib/types/access.js +6 -1
- package/dist/lib/types/dataStructures.d.ts +3 -3
- package/dist/lib/types/function.d.ts +10 -4
- package/dist/lib/types/matchBlock.d.ts +2 -2
- package/dist/lib/types/returnStatement.d.ts +2 -2
- package/dist/lib/types/whileLoop.d.ts +2 -2
- package/dist/lib/types.d.ts +3 -3
- package/package.json +4 -4
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Source: lib/templates/backends/typescriptGenerator/toolCall.mustache
|
|
3
3
|
// Any manual changes will be lost.
|
|
4
4
|
import { apply } from "typestache";
|
|
5
|
-
export const template = `if (
|
|
6
|
-
toolCall.
|
|
5
|
+
export const template = `if (
|
|
6
|
+
toolCall.name === "{{{name:string}}}"
|
|
7
7
|
) {
|
|
8
|
-
const args =
|
|
8
|
+
const args = toolCall.arguments;
|
|
9
9
|
|
|
10
10
|
toolCallStartTime = performance.now();
|
|
11
11
|
const result = await {{{name}}}(args);
|
|
@@ -23,11 +23,10 @@ statelogClient.toolCall({
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
// Add function result to messages
|
|
26
|
-
__messages.push({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
26
|
+
__messages.push(toolMessage(result, {
|
|
27
|
+
tool_call_id: toolCall.id,
|
|
28
|
+
name: toolCall.name,
|
|
29
|
+
}));
|
|
31
30
|
}`;
|
|
32
31
|
const render = (args) => {
|
|
33
32
|
return apply(template, args);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { FunctionCall } from "../types.js";
|
|
1
|
+
import { AgencyNode, FunctionCall } from "../types.js";
|
|
2
2
|
import { Literal } from "./literals.js";
|
|
3
|
-
import { AgencyArray } from "./dataStructures.js";
|
|
4
3
|
export type DotProperty = {
|
|
5
4
|
type: "dotProperty";
|
|
6
|
-
object:
|
|
5
|
+
object: AgencyNode;
|
|
7
6
|
propertyName: string;
|
|
8
7
|
};
|
|
9
8
|
export type IndexAccess = {
|
|
10
9
|
type: "indexAccess";
|
|
11
|
-
array:
|
|
10
|
+
array: AgencyNode;
|
|
12
11
|
index: Literal | FunctionCall | AccessExpression;
|
|
13
12
|
};
|
|
14
13
|
export type DotFunctionCall = {
|
|
15
14
|
type: "dotFunctionCall";
|
|
16
|
-
object:
|
|
15
|
+
object: AgencyNode;
|
|
17
16
|
functionCall: FunctionCall;
|
|
18
17
|
};
|
|
19
18
|
export type AccessExpression = {
|
|
20
19
|
type: "accessExpression";
|
|
21
20
|
expression: DotProperty | IndexAccess | DotFunctionCall;
|
|
22
21
|
};
|
|
22
|
+
export declare function accessExpression(expression: DotProperty | IndexAccess | DotFunctionCall): AccessExpression;
|
package/dist/lib/types/access.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AccessExpression, Literal } from "../types.js";
|
|
1
|
+
import { AccessExpression, IndexAccess, Literal } from "../types.js";
|
|
2
2
|
import { FunctionCall } from "./function.js";
|
|
3
3
|
export type AgencyArray = {
|
|
4
4
|
type: "agencyArray";
|
|
5
|
-
items: (AccessExpression | Literal | FunctionCall | AgencyObject | AgencyArray | AccessExpression)[];
|
|
5
|
+
items: (IndexAccess | AccessExpression | Literal | FunctionCall | AgencyObject | AgencyArray | AccessExpression)[];
|
|
6
6
|
};
|
|
7
7
|
export type AgencyObjectKV = {
|
|
8
8
|
key: string;
|
|
9
|
-
value: AccessExpression | Literal | FunctionCall | AgencyObject | AgencyArray | AccessExpression;
|
|
9
|
+
value: IndexAccess | AccessExpression | Literal | FunctionCall | AgencyObject | AgencyArray | AccessExpression;
|
|
10
10
|
};
|
|
11
11
|
export type AgencyObject = {
|
|
12
12
|
type: "agencyObject";
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { AgencyNode } from "../types.js";
|
|
2
|
-
import { AccessExpression } from "./access.js";
|
|
1
|
+
import { AgencyArray, AgencyNode, AgencyObject, VariableType } from "../types.js";
|
|
2
|
+
import { AccessExpression, IndexAccess } from "./access.js";
|
|
3
3
|
import { Literal } from "./literals.js";
|
|
4
|
+
export type FunctionParameter = {
|
|
5
|
+
type: "functionParameter";
|
|
6
|
+
name: string;
|
|
7
|
+
typeHint?: VariableType;
|
|
8
|
+
};
|
|
4
9
|
export type FunctionDefinition = {
|
|
5
10
|
type: "function";
|
|
6
11
|
functionName: string;
|
|
7
|
-
parameters:
|
|
12
|
+
parameters: FunctionParameter[];
|
|
8
13
|
body: AgencyNode[];
|
|
14
|
+
returnType?: VariableType;
|
|
9
15
|
docString?: DocString;
|
|
10
16
|
};
|
|
11
17
|
export type FunctionCall = {
|
|
12
18
|
type: "functionCall";
|
|
13
19
|
functionName: string;
|
|
14
|
-
arguments: (Literal | AccessExpression | FunctionCall)[];
|
|
20
|
+
arguments: (AgencyArray | AgencyObject | IndexAccess | Literal | AccessExpression | FunctionCall)[];
|
|
15
21
|
};
|
|
16
22
|
export type DocString = {
|
|
17
23
|
type: "docString";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Assignment, AgencyComment } from "../types.js";
|
|
2
|
-
import { AccessExpression } from "./access.js";
|
|
2
|
+
import { AccessExpression, IndexAccess } from "./access.js";
|
|
3
3
|
import { Literal } from "./literals.js";
|
|
4
4
|
import { FunctionCall } from "./function.js";
|
|
5
5
|
import { AgencyArray, AgencyObject } from "./dataStructures.js";
|
|
@@ -7,7 +7,7 @@ import { ReturnStatement } from "./returnStatement.js";
|
|
|
7
7
|
export type DefaultCase = "_";
|
|
8
8
|
export type MatchBlockCase = {
|
|
9
9
|
type: "matchBlockCase";
|
|
10
|
-
caseValue: AccessExpression | Literal | DefaultCase;
|
|
10
|
+
caseValue: AccessExpression | Literal | DefaultCase | IndexAccess;
|
|
11
11
|
body: Assignment | Literal | FunctionCall | AccessExpression | AgencyArray | AgencyObject | ReturnStatement;
|
|
12
12
|
};
|
|
13
13
|
export type MatchBlock = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AccessExpression, FunctionCall, Literal } from "../types.js";
|
|
1
|
+
import { AccessExpression, FunctionCall, IndexAccess, Literal } from "../types.js";
|
|
2
2
|
import { AgencyArray, AgencyObject } from "./dataStructures.js";
|
|
3
3
|
export type ReturnStatement = {
|
|
4
4
|
type: "returnStatement";
|
|
5
|
-
value: AccessExpression | FunctionCall | Literal | AgencyObject | AgencyArray;
|
|
5
|
+
value: AccessExpression | FunctionCall | Literal | AgencyObject | AgencyArray | IndexAccess;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AccessExpression, AgencyNode, FunctionCall, Literal } from "../types.js";
|
|
1
|
+
import { AccessExpression, AgencyNode, FunctionCall, IndexAccess, Literal } from "../types.js";
|
|
2
2
|
export type WhileLoop = {
|
|
3
3
|
type: "whileLoop";
|
|
4
|
-
condition: FunctionCall | AccessExpression | Literal;
|
|
4
|
+
condition: IndexAccess | FunctionCall | AccessExpression | Literal;
|
|
5
5
|
body: AgencyNode[];
|
|
6
6
|
};
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Literal } from "./types/literals.js";
|
|
2
2
|
import { TypeAlias, TypeHint, VariableType } from "./types/typeHints.js";
|
|
3
3
|
import { MatchBlock } from "./types/matchBlock.js";
|
|
4
|
-
import { AccessExpression } from "./types/access.js";
|
|
4
|
+
import { AccessExpression, DotProperty, IndexAccess } from "./types/access.js";
|
|
5
5
|
import { FunctionCall, FunctionDefinition } from "./types/function.js";
|
|
6
6
|
import { AgencyArray, AgencyObject } from "./types/dataStructures.js";
|
|
7
7
|
import { GraphNodeDefinition } from "./types/graphNode.js";
|
|
@@ -24,13 +24,13 @@ export * from "./types/whileLoop.js";
|
|
|
24
24
|
export type Assignment = {
|
|
25
25
|
type: "assignment";
|
|
26
26
|
variableName: string;
|
|
27
|
-
value: AccessExpression | Literal | FunctionCall | AgencyObject | AgencyArray;
|
|
27
|
+
value: AccessExpression | Literal | FunctionCall | AgencyObject | AgencyArray | IndexAccess;
|
|
28
28
|
};
|
|
29
29
|
export type AgencyComment = {
|
|
30
30
|
type: "comment";
|
|
31
31
|
content: string;
|
|
32
32
|
};
|
|
33
|
-
export type AgencyNode = TypeHint | TypeAlias | UsesTool | GraphNodeDefinition | FunctionDefinition | Assignment | Literal | FunctionCall | MatchBlock | ReturnStatement | AccessExpression | AgencyComment | AgencyObject | AgencyArray | ImportStatement | WhileLoop | SpecialVar;
|
|
33
|
+
export type AgencyNode = TypeHint | TypeAlias | UsesTool | GraphNodeDefinition | FunctionDefinition | Assignment | Literal | FunctionCall | MatchBlock | ReturnStatement | AccessExpression | AgencyComment | AgencyObject | AgencyArray | ImportStatement | WhileLoop | SpecialVar | IndexAccess | DotProperty;
|
|
34
34
|
export type AgencyProgram = {
|
|
35
35
|
type: "agencyProgram";
|
|
36
36
|
nodes: AgencyNode[];
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agency-lang",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "The Agency language",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "vitest",
|
|
8
8
|
"test:run": "vitest run",
|
|
9
9
|
"build": "rm -rf dist/ && tsc && tsc-alias",
|
|
10
|
-
"start": "node dist/
|
|
10
|
+
"start": "node dist/index.js",
|
|
11
11
|
"templates": "typestache ./lib/templates",
|
|
12
12
|
"typecheck": "tsc --noEmit",
|
|
13
13
|
"agency": "node ./dist/scripts/agency.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"homepage": "https://github.com/egonSchiele/agency-lang#readme",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"egonlog": "^0.0.2",
|
|
44
|
+
"smoltalk": "^0.0.11",
|
|
44
45
|
"tarsec": "^0.1.1",
|
|
45
46
|
"typestache": "^0.4.4",
|
|
46
47
|
"zod": "^4.3.5"
|
|
@@ -49,10 +50,9 @@
|
|
|
49
50
|
"@types/node": "^25.0.3",
|
|
50
51
|
"nanoid": "^5.1.6",
|
|
51
52
|
"piemachine": "^0.0.2",
|
|
52
|
-
"smoltalk": "^0.0.11",
|
|
53
53
|
"statelog-client": "^0.0.31",
|
|
54
54
|
"tsc-alias": "^1.8.16",
|
|
55
55
|
"typescript": "^5.9.3",
|
|
56
56
|
"vitest": "^4.0.16"
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|