@stackfactor/agent-utils 1.0.6 → 1.0.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAoaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAiqBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCAphBO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAy0BF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAz4B8B,GAAG,KAAG,MAAM;;AAo8BzD,wBAOE"}
1
+ {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAwaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAyqBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCA5hBO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAi1BF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAj5B8B,GAAG,KAAG,MAAM;;AA48BzD,wBAOE"}
@@ -269,7 +269,9 @@ const getAIProgressTool = (onProgress, minPercent = 0, maxPercent = 100) => lang
269
269
  // Clamp percent to be within minPercent and maxPercent bounds
270
270
  const rawPct = typeof percent === "number" ? percent : 0;
271
271
  const clampedPct = Math.max(minPercent, Math.min(maxPercent, rawPct));
272
- if (onProgress) {
272
+ if (onProgress &&
273
+ minPercent <= clampedPct &&
274
+ clampedPct <= maxPercent) {
273
275
  await onProgress({
274
276
  progress: clampedPct,
275
277
  message: message,
@@ -603,7 +605,12 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
603
605
  throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, "Agent returned no messages");
604
606
  }
605
607
  const lastMessage = messages[messages.length - 1];
606
- const rawContent = lastMessage?.content || "";
608
+ let rawContent = lastMessage?.content || "";
609
+ // Handle array content blocks (e.g., from Gemini/Claude agent responses)
610
+ if (Array.isArray(rawContent)) {
611
+ const textBlock = rawContent.find((block) => typeof block === "object" && block.type === "text");
612
+ rawContent = textBlock?.text || "";
613
+ }
607
614
  // If not expecting JSON, return raw content directly
608
615
  if (!expectsJsonResponse) {
609
616
  return rawContent;
@@ -1 +1 @@
1
- {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAoaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAiqBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCAphBO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAy0BF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAz4B8B,GAAG,KAAG,MAAM;;AAo8BzD,wBAOE"}
1
+ {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAwaQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,qBACO,QAAQ,GAAG,IAAI,eACrB,MAAM,eACN,MAAM,KACjB,GAAG;sBAyCG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAyqBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCA5hBO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAi1BF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAj5B8B,GAAG,KAAG,MAAM;;AA48BzD,wBAOE"}
@@ -264,7 +264,9 @@ const getAIProgressTool = (onProgress, minPercent = 0, maxPercent = 100) => lang
264
264
  // Clamp percent to be within minPercent and maxPercent bounds
265
265
  const rawPct = typeof percent === "number" ? percent : 0;
266
266
  const clampedPct = Math.max(minPercent, Math.min(maxPercent, rawPct));
267
- if (onProgress) {
267
+ if (onProgress &&
268
+ minPercent <= clampedPct &&
269
+ clampedPct <= maxPercent) {
268
270
  await onProgress({
269
271
  progress: clampedPct,
270
272
  message: message,
@@ -598,7 +600,12 @@ const runPromptWithModel = async (modelName, config, prompt, onProgressReport, m
598
600
  throw errorHandlingHelper.create(constants.HTTP_CODES.INTERNAL_SERVER_ERROR, "Agent returned no messages");
599
601
  }
600
602
  const lastMessage = messages[messages.length - 1];
601
- const rawContent = lastMessage?.content || "";
603
+ let rawContent = lastMessage?.content || "";
604
+ // Handle array content blocks (e.g., from Gemini/Claude agent responses)
605
+ if (Array.isArray(rawContent)) {
606
+ const textBlock = rawContent.find((block) => typeof block === "object" && block.type === "text");
607
+ rawContent = textBlock?.text || "";
608
+ }
602
609
  // If not expecting JSON, return raw content directly
603
610
  if (!expectsJsonResponse) {
604
611
  return rawContent;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "restricted"
5
5
  },
6
- "version": "1.0.6",
6
+ "version": "1.0.8",
7
7
  "description": "",
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/esm/index.js",