@mondaydotcomorg/atp-compiler 0.19.12 → 0.19.13

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/index.js CHANGED
@@ -60,6 +60,10 @@ var PAUSABLE_CALL_PATTERNS = [
60
60
  {
61
61
  namespace: "atp.embedding",
62
62
  method: "encode"
63
+ },
64
+ {
65
+ namespace: "api.client",
66
+ method: "*"
63
67
  }
64
68
  ];
65
69
  var DEFAULT_COMPILER_CONFIG = {
@@ -86,7 +90,7 @@ function isPausableCallExpression(node) {
86
90
  return false;
87
91
  }
88
92
  const fullPath = getMemberExpressionPath(callee);
89
- return PAUSABLE_CALL_PATTERNS.some((pattern) => fullPath === `${pattern.namespace}.${pattern.method}`);
93
+ return PAUSABLE_CALL_PATTERNS.some((pattern) => pattern.method === "*" ? fullPath.startsWith(`${pattern.namespace}.`) : fullPath === `${pattern.namespace}.${pattern.method}`);
90
94
  }
91
95
  __name(isPausableCallExpression, "isPausableCallExpression");
92
96
  function getMemberExpressionPath(node) {
@@ -729,10 +733,24 @@ var BatchParallelDetector = class {
729
733
  return null;
730
734
  }
731
735
  const [namespace, service, method] = parts;
732
- if (namespace !== "atp" || !method) {
736
+ if (!service || !method) {
737
+ return null;
738
+ }
739
+ let type;
740
+ if (namespace === "atp") {
741
+ if (![
742
+ "llm",
743
+ "approval",
744
+ "embedding"
745
+ ].includes(service)) {
746
+ return null;
747
+ }
748
+ type = service;
749
+ } else if (namespace === "api" && service === "client") {
750
+ type = "tool";
751
+ } else {
733
752
  return null;
734
753
  }
735
- const type = service;
736
754
  const payload = this.extractPayload(callNode.arguments);
737
755
  return {
738
756
  type,
@@ -1293,6 +1311,7 @@ function isInIsolateRuntimeFunction(name) {
1293
1311
  __name(isInIsolateRuntimeFunction, "isInIsolateRuntimeFunction");
1294
1312
 
1295
1313
  // src/transformer/promise-transformer.ts
1314
+ var TOOL_OPERATION_CALL = "call";
1296
1315
  var PromiseTransformer = class {
1297
1316
  static {
1298
1317
  __name(this, "PromiseTransformer");
@@ -1358,11 +1377,7 @@ var PromiseTransformer = class {
1358
1377
  return t7.nullLiteral();
1359
1378
  }
1360
1379
  const payloadArg = callNode.arguments[0];
1361
- return t7.objectExpression([
1362
- t7.objectProperty(t7.identifier("type"), t7.stringLiteral(callInfo.type)),
1363
- t7.objectProperty(t7.identifier("operation"), t7.stringLiteral(callInfo.operation)),
1364
- t7.objectProperty(t7.identifier("payload"), payloadArg && t7.isExpression(payloadArg) ? payloadArg : t7.objectExpression([]))
1365
- ]);
1380
+ return this.buildBatchCallObject(callInfo, payloadArg);
1366
1381
  }));
1367
1382
  const runtimeCall = t7.awaitExpression(t7.callExpression(t7.memberExpression(t7.identifier("__runtime"), t7.identifier(RuntimeFunction.BATCH_PARALLEL)), [
1368
1383
  batchCallsArray,
@@ -1372,6 +1387,28 @@ var PromiseTransformer = class {
1372
1387
  this.transformCount++;
1373
1388
  return true;
1374
1389
  }
1390
+ /**
1391
+ * Builds the AST for a batch call object.
1392
+ * For client tools, wraps payload with toolName and input structure.
1393
+ */
1394
+ buildBatchCallObject(callInfo, payloadArg) {
1395
+ const payloadExpr = payloadArg && t7.isExpression(payloadArg) ? payloadArg : t7.objectExpression([]);
1396
+ if (callInfo.type === "tool") {
1397
+ return t7.objectExpression([
1398
+ t7.objectProperty(t7.identifier("type"), t7.stringLiteral(callInfo.type)),
1399
+ t7.objectProperty(t7.identifier("operation"), t7.stringLiteral(TOOL_OPERATION_CALL)),
1400
+ t7.objectProperty(t7.identifier("payload"), t7.objectExpression([
1401
+ t7.objectProperty(t7.identifier("toolName"), t7.stringLiteral(callInfo.operation)),
1402
+ t7.objectProperty(t7.identifier("input"), payloadExpr)
1403
+ ]))
1404
+ ]);
1405
+ }
1406
+ return t7.objectExpression([
1407
+ t7.objectProperty(t7.identifier("type"), t7.stringLiteral(callInfo.type)),
1408
+ t7.objectProperty(t7.identifier("operation"), t7.stringLiteral(callInfo.operation)),
1409
+ t7.objectProperty(t7.identifier("payload"), payloadExpr)
1410
+ ]);
1411
+ }
1375
1412
  transformToSequential(path, node) {
1376
1413
  const arrayArg = node.arguments[0];
1377
1414
  if (!t7.isArrayExpression(arrayArg)) {