@axlsdk/axl 0.3.0 → 0.4.0

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
@@ -1746,6 +1746,15 @@ function zodToJsonSchema(schema) {
1746
1746
  function estimateTokens(text) {
1747
1747
  return Math.ceil(text.length / 4);
1748
1748
  }
1749
+ function stripMarkdownFences(text) {
1750
+ const trimmed = text.trim();
1751
+ if (trimmed.startsWith("```")) {
1752
+ const withoutOpening = trimmed.replace(/^```\w*\s*\n?/, "");
1753
+ const withoutClosing = withoutOpening.replace(/\n?```\s*$/, "");
1754
+ return withoutClosing.trim();
1755
+ }
1756
+ return trimmed;
1757
+ }
1749
1758
  function estimateMessagesTokens(messages) {
1750
1759
  let total = 0;
1751
1760
  for (const msg of messages) {
@@ -2439,7 +2448,7 @@ Please fix and try again.`;
2439
2448
  }
2440
2449
  if (options?.schema) {
2441
2450
  try {
2442
- const parsed = JSON.parse(content);
2451
+ const parsed = JSON.parse(stripMarkdownFences(content));
2443
2452
  const validated = options.schema.parse(parsed);
2444
2453
  return validated;
2445
2454
  } catch (err) {