@mondaydotcomorg/atp-compiler 0.17.14 → 0.18.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.
- package/dist/atp-compiler/src/transformer/array-transformer-utils.d.ts +2 -2
- package/dist/atp-compiler/src/transformer/array-transformer-utils.d.ts.map +1 -1
- package/dist/atp-compiler/src/transformer/array-transformer-utils.js +2 -2
- package/dist/atp-compiler/src/transformer/array-transformer-utils.js.map +1 -1
- package/dist/atp-compiler/src/transformer/loop-transformer.d.ts +0 -4
- package/dist/atp-compiler/src/transformer/loop-transformer.d.ts.map +1 -1
- package/dist/atp-compiler/src/transformer/loop-transformer.js +5 -60
- package/dist/atp-compiler/src/transformer/loop-transformer.js.map +1 -1
- package/dist/atp-compiler/src/transformer/utils.d.ts +4 -0
- package/dist/atp-compiler/src/transformer/utils.d.ts.map +1 -1
- package/dist/atp-compiler/src/transformer/utils.js +15 -0
- package/dist/atp-compiler/src/transformer/utils.js.map +1 -1
- package/dist/protocol/src/types.d.ts +25 -0
- package/dist/protocol/src/types.d.ts.map +1 -1
- package/dist/runtime/src/metadata/generated.d.ts +4 -0
- package/dist/runtime/src/metadata/generated.d.ts.map +1 -1
- package/dist/runtime/src/metadata/generated.js +189 -189
- package/dist/runtime/src/metadata/generated.js.map +1 -1
- package/dist/runtime/src/metadata/index.d.ts +14 -1
- package/dist/runtime/src/metadata/index.d.ts.map +1 -1
- package/dist/runtime/src/metadata/index.js +45 -3
- package/dist/runtime/src/metadata/index.js.map +1 -1
- package/dist/runtime/src/metadata/types.d.ts +2 -1
- package/dist/runtime/src/metadata/types.d.ts.map +1 -1
- package/package.json +16 -5
- package/project.json +1 -3
- package/src/transformer/array-transformer-utils.ts +3 -7
- package/src/transformer/loop-transformer.ts +5 -66
- package/src/transformer/utils.ts +14 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Common metadata interface for runtime APIs
|
|
3
3
|
* Each runtime module exports its metadata for the type generator
|
|
4
4
|
*/
|
|
5
|
+
import { RuntimeAPIName } from './generated';
|
|
5
6
|
export interface RuntimeAPIParam {
|
|
6
7
|
name: string;
|
|
7
8
|
type: string;
|
|
@@ -15,7 +16,7 @@ export interface RuntimeAPIMethod {
|
|
|
15
16
|
returns: string;
|
|
16
17
|
}
|
|
17
18
|
export interface RuntimeAPIMetadata {
|
|
18
|
-
name:
|
|
19
|
+
name: RuntimeAPIName;
|
|
19
20
|
description: string;
|
|
20
21
|
methods: RuntimeAPIMethod[];
|
|
21
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../runtime/src/metadata/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../runtime/src/metadata/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mondaydotcomorg/atp-compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Production-ready compiler for transforming async iteration patterns into resumable operations with checkpoint-based state management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/atp-compiler/src/index.js",
|
|
@@ -15,6 +15,14 @@
|
|
|
15
15
|
"import": "./dist/atp-compiler/src/*.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/mondaycom/agent-tool-protocol",
|
|
24
|
+
"directory": "packages/atp-compiler"
|
|
25
|
+
},
|
|
18
26
|
"scripts": {
|
|
19
27
|
"build": "tsc",
|
|
20
28
|
"test": "jest",
|
|
@@ -26,6 +34,7 @@
|
|
|
26
34
|
},
|
|
27
35
|
"keywords": [
|
|
28
36
|
"agent-tool-protocol",
|
|
37
|
+
"atp",
|
|
29
38
|
"compiler",
|
|
30
39
|
"resumable",
|
|
31
40
|
"async",
|
|
@@ -38,16 +47,18 @@
|
|
|
38
47
|
"@babel/parser": "^7.26.0",
|
|
39
48
|
"@babel/traverse": "^7.26.0",
|
|
40
49
|
"@babel/types": "^7.26.0",
|
|
50
|
+
"@mondaydotcomorg/atp-protocol": "0.18.2",
|
|
51
|
+
"@mondaydotcomorg/atp-runtime": "0.18.2",
|
|
52
|
+
"@types/babel__generator": "^7.6.0",
|
|
53
|
+
"@types/babel__traverse": "^7.20.0",
|
|
41
54
|
"nanoid": "^5.0.0"
|
|
42
55
|
},
|
|
43
56
|
"peerDependencies": {
|
|
44
|
-
"@mondaydotcomorg/atp-protocol": "0.
|
|
45
|
-
"@mondaydotcomorg/atp-runtime": "0.
|
|
57
|
+
"@mondaydotcomorg/atp-protocol": "0.18.2",
|
|
58
|
+
"@mondaydotcomorg/atp-runtime": "0.18.2"
|
|
46
59
|
},
|
|
47
60
|
"devDependencies": {
|
|
48
61
|
"@stryker-mutator/core": "^8.0.0",
|
|
49
|
-
"@types/babel__generator": "^7.6.0",
|
|
50
|
-
"@types/babel__traverse": "^7.20.0",
|
|
51
62
|
"@types/jest": "^29.5.0",
|
|
52
63
|
"fast-check": "^3.15.0",
|
|
53
64
|
"jest": "^29.7.0",
|
package/project.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
|
+
import { isArrayMethod } from './utils.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
* Find LLM call expression in
|
|
5
|
+
* Find LLM call expression in AST node
|
|
5
6
|
*/
|
|
6
|
-
export function findLLMCallExpression(
|
|
7
|
-
body: t.BlockStatement | t.Expression
|
|
8
|
-
): t.CallExpression | null {
|
|
7
|
+
export function findLLMCallExpression(body: t.Node): t.CallExpression | null {
|
|
9
8
|
let found: t.CallExpression | null = null;
|
|
10
9
|
|
|
11
10
|
const visit = (node: t.Node) => {
|
|
@@ -42,9 +41,6 @@ export function findLLMCallExpression(
|
|
|
42
41
|
*/
|
|
43
42
|
export function getArrayMethodName(node: t.CallExpression): string | null {
|
|
44
43
|
const arrayMethods = ['map', 'forEach', 'filter', 'reduce', 'find', 'some', 'every', 'flatMap'];
|
|
45
|
-
|
|
46
|
-
const { isArrayMethod } = require('./utils.js');
|
|
47
|
-
|
|
48
44
|
for (const method of arrayMethods) {
|
|
49
45
|
if (isArrayMethod(node, method)) {
|
|
50
46
|
return method;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
2
|
import { generateUniqueId } from '../runtime/context.js';
|
|
3
|
-
import { containsAwait } from './utils.js';
|
|
3
|
+
import { containsAwait, extractForOfParamName } from './utils.js';
|
|
4
4
|
import { BatchOptimizer } from './batch-optimizer.js';
|
|
5
5
|
import { BatchParallelDetector } from './batch-detector.js';
|
|
6
|
+
import { findLLMCallExpression } from './array-transformer-utils.js';
|
|
6
7
|
|
|
7
8
|
export class LoopTransformer {
|
|
8
9
|
private transformCount = 0;
|
|
@@ -46,27 +47,10 @@ export class LoopTransformer {
|
|
|
46
47
|
*/
|
|
47
48
|
private transformForOfToBatch(path: any, node: t.ForOfStatement): boolean {
|
|
48
49
|
const loopId = generateUniqueId('for_of_batch');
|
|
49
|
-
const left = node.left;
|
|
50
50
|
const right = node.right;
|
|
51
|
+
const paramName = extractForOfParamName(node.left);
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
if (t.isVariableDeclaration(left)) {
|
|
54
|
-
const id = left.declarations[0]?.id;
|
|
55
|
-
paramName = t.isIdentifier(id) ? id.name : 'item';
|
|
56
|
-
} else if (t.isIdentifier(left)) {
|
|
57
|
-
paramName = left.name;
|
|
58
|
-
} else {
|
|
59
|
-
paramName = 'item';
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const bodyStatements = t.isBlockStatement(node.body) ? node.body.body : [node.body];
|
|
63
|
-
const callback = t.arrowFunctionExpression(
|
|
64
|
-
[t.identifier(paramName)],
|
|
65
|
-
t.blockStatement(bodyStatements),
|
|
66
|
-
true
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const llmCall = this.findLLMCallInBody(node.body);
|
|
53
|
+
const llmCall = findLLMCallExpression(node.body);
|
|
70
54
|
if (!llmCall) {
|
|
71
55
|
return this.transformForOfToSequential(path, node);
|
|
72
56
|
}
|
|
@@ -109,18 +93,8 @@ export class LoopTransformer {
|
|
|
109
93
|
*/
|
|
110
94
|
private transformForOfToSequential(path: any, node: t.ForOfStatement): boolean {
|
|
111
95
|
const loopId = generateUniqueId('for_of');
|
|
112
|
-
const left = node.left;
|
|
113
96
|
const right = node.right;
|
|
114
|
-
|
|
115
|
-
let paramName: string;
|
|
116
|
-
if (t.isVariableDeclaration(left)) {
|
|
117
|
-
const id = left.declarations[0]?.id;
|
|
118
|
-
paramName = t.isIdentifier(id) ? id.name : 'item';
|
|
119
|
-
} else if (t.isIdentifier(left)) {
|
|
120
|
-
paramName = left.name;
|
|
121
|
-
} else {
|
|
122
|
-
paramName = 'item';
|
|
123
|
-
}
|
|
97
|
+
const paramName = extractForOfParamName(node.left);
|
|
124
98
|
|
|
125
99
|
const bodyStatements = t.isBlockStatement(node.body) ? node.body.body : [node.body];
|
|
126
100
|
|
|
@@ -142,41 +116,6 @@ export class LoopTransformer {
|
|
|
142
116
|
return true;
|
|
143
117
|
}
|
|
144
118
|
|
|
145
|
-
/**
|
|
146
|
-
* Find LLM call in loop body
|
|
147
|
-
*/
|
|
148
|
-
private findLLMCallInBody(body: t.Statement | t.BlockStatement): t.CallExpression | null {
|
|
149
|
-
let found: t.CallExpression | null = null;
|
|
150
|
-
|
|
151
|
-
const visit = (node: t.Node) => {
|
|
152
|
-
if (found) return;
|
|
153
|
-
|
|
154
|
-
if (t.isAwaitExpression(node) && t.isCallExpression(node.argument)) {
|
|
155
|
-
const call = node.argument;
|
|
156
|
-
if (t.isMemberExpression(call.callee)) {
|
|
157
|
-
found = call;
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
Object.keys(node).forEach((key) => {
|
|
163
|
-
const value = (node as any)[key];
|
|
164
|
-
if (Array.isArray(value)) {
|
|
165
|
-
value.forEach((item) => {
|
|
166
|
-
if (item && typeof item === 'object' && item.type) {
|
|
167
|
-
visit(item);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
} else if (value && typeof value === 'object' && value.type) {
|
|
171
|
-
visit(value);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
visit(body);
|
|
177
|
-
return found;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
119
|
transformWhileLoop(path: any): boolean {
|
|
181
120
|
const node = path.node as t.WhileStatement;
|
|
182
121
|
|
package/src/transformer/utils.ts
CHANGED
|
@@ -145,3 +145,17 @@ export function isArrayMethod(node: t.Node, methodName: string): boolean {
|
|
|
145
145
|
|
|
146
146
|
return t.isIdentifier(callee.property) && callee.property.name === methodName;
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Extract parameter name from ForOfStatement left side
|
|
151
|
+
*/
|
|
152
|
+
export function extractForOfParamName(left: t.VariableDeclaration | t.LVal): string {
|
|
153
|
+
if (t.isVariableDeclaration(left)) {
|
|
154
|
+
const id = left.declarations[0]?.id;
|
|
155
|
+
return t.isIdentifier(id) ? id.name : 'item';
|
|
156
|
+
} else if (t.isIdentifier(left)) {
|
|
157
|
+
return left.name;
|
|
158
|
+
} else {
|
|
159
|
+
return 'item';
|
|
160
|
+
}
|
|
161
|
+
}
|