llmz 0.0.30 → 0.0.32

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.
Files changed (35) hide show
  1. package/dist/{chunk-7POUFE5M.js → chunk-23SY6IDW.js} +63 -9
  2. package/dist/{chunk-KQPGB6GB.js → chunk-4JN4PPGP.js} +293 -4
  3. package/dist/{chunk-VADA6DMR.cjs → chunk-4XIOQWVZ.cjs} +301 -12
  4. package/dist/{chunk-WP4F6KMW.cjs → chunk-5BEKU5MZ.cjs} +2 -2
  5. package/dist/{chunk-R3LXNE5N.cjs → chunk-5FWOHMO4.cjs} +325 -60
  6. package/dist/{chunk-HCC76DDO.js → chunk-AAHUDKBY.js} +2 -2
  7. package/dist/{chunk-DCYSCVQM.js → chunk-G3LSBWJT.js} +304 -39
  8. package/dist/{chunk-RLOPQZTQ.cjs → chunk-INDOGCAQ.cjs} +2 -2
  9. package/dist/{chunk-T63Y6GTW.cjs → chunk-PK72FAKD.cjs} +2 -1
  10. package/dist/{chunk-273DEMEU.cjs → chunk-SOEKWFU2.cjs} +64 -10
  11. package/dist/{chunk-IUE5BW56.js → chunk-U4HWJLF2.js} +1 -1
  12. package/dist/{chunk-MYLTD5WT.js → chunk-WSVDMGMR.js} +2 -1
  13. package/dist/compiler/plugins/html-to-markdown.d.ts +21 -0
  14. package/dist/compiler/plugins/jsx-undefined-vars.d.ts +14 -0
  15. package/dist/context.d.ts +20 -0
  16. package/dist/{dual-modes-DW3KRXT2.js → dual-modes-LEAHGCOF.js} +1 -1
  17. package/dist/{dual-modes-F4UV5VAZ.cjs → dual-modes-UBHAMQW4.cjs} +2 -2
  18. package/dist/errors.d.ts +2 -1
  19. package/dist/exit-parser.d.ts +37 -0
  20. package/dist/index.cjs +20 -18
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +14 -12
  23. package/dist/{llmz-N6KWKJ2Q.js → llmz-3E2JM3HM.js} +85 -42
  24. package/dist/{llmz-DYB74G5C.cjs → llmz-HGUVAYIN.cjs} +105 -62
  25. package/dist/llmz.d.ts +12 -0
  26. package/dist/prompts/worker-mode/system.md.d.ts +1 -1
  27. package/dist/result.d.ts +18 -0
  28. package/dist/{tool-GEBXW6AQ.js → tool-7QXH6A24.js} +3 -3
  29. package/dist/{tool-GMYMVXUK.cjs → tool-JVLOALQN.cjs} +4 -4
  30. package/dist/tool.d.ts +1 -1
  31. package/dist/{typings-3VYUEACY.js → typings-ALZEKGV6.js} +2 -2
  32. package/dist/{typings-2RAAZ2YP.cjs → typings-OLI56LGT.cjs} +3 -3
  33. package/dist/{vm-NGQ6DRS3.cjs → vm-VFORKC54.cjs} +3 -3
  34. package/dist/{vm-J6UNJGIN.js → vm-Y3WY2627.js} +2 -2
  35. package/package.json +2 -2
@@ -4,7 +4,7 @@ import {
4
4
  Signals,
5
5
  SnapshotSignal,
6
6
  VMSignal
7
- } from "./chunk-MYLTD5WT.js";
7
+ } from "./chunk-WSVDMGMR.js";
8
8
  import {
9
9
  cleanStackTrace
10
10
  } from "./chunk-YEAWWJSJ.js";
@@ -2101,6 +2101,207 @@ var JSXMarkdown = {
2101
2101
  }
2102
2102
  };
2103
2103
 
2104
+ // src/compiler/plugins/html-to-markdown.ts
2105
+ import { types as t } from "@babel/core";
2106
+ function htmlToMarkdownPlugin() {
2107
+ return {
2108
+ name: "html-to-markdown",
2109
+ visitor: {
2110
+ JSXElement(path) {
2111
+ const { openingElement } = path.node;
2112
+ const tagName = t.isJSXIdentifier(openingElement.name) ? openingElement.name.name : null;
2113
+ if (!tagName)
2114
+ return;
2115
+ const lowerTagName = tagName.toLowerCase();
2116
+ if (lowerTagName === "strong" || lowerTagName === "b") {
2117
+ convertToMarkdown(path, "**", "**");
2118
+ } else if (lowerTagName === "em" || lowerTagName === "i") {
2119
+ convertToMarkdown(path, "*", "*");
2120
+ } else if (lowerTagName === "u") {
2121
+ convertToMarkdown(path, "__", "__");
2122
+ } else if (lowerTagName === "a") {
2123
+ convertLinkToMarkdown(path);
2124
+ } else if (lowerTagName === "br") {
2125
+ convertBrToNewline(path);
2126
+ } else if (lowerTagName === "p") {
2127
+ convertParagraphToMarkdown(path);
2128
+ } else if (lowerTagName === "ul") {
2129
+ convertUnorderedListToMarkdown(path);
2130
+ } else if (lowerTagName === "ol") {
2131
+ convertOrderedListToMarkdown(path);
2132
+ }
2133
+ }
2134
+ }
2135
+ };
2136
+ }
2137
+ function hasOnlyTextChildren(children) {
2138
+ return children.every(
2139
+ (child) => t.isJSXText(child) || t.isJSXExpressionContainer(child) && !t.isJSXElement(child.expression) || t.isJSXElement(child) && canConvertToMarkdown(child)
2140
+ );
2141
+ }
2142
+ function canConvertToMarkdown(element) {
2143
+ const { openingElement } = element;
2144
+ const tagName = t.isJSXIdentifier(openingElement.name) ? openingElement.name.name.toLowerCase() : null;
2145
+ if (!tagName)
2146
+ return false;
2147
+ const allowedTags = ["strong", "b", "em", "i", "u", "br", "p", "a", "li", "ul", "ol"];
2148
+ if (!allowedTags.includes(tagName))
2149
+ return false;
2150
+ if (tagName === "a") {
2151
+ return openingElement.attributes.length === 1 && t.isJSXAttribute(openingElement.attributes[0]) && t.isJSXIdentifier(openingElement.attributes[0].name) && openingElement.attributes[0].name.name === "href";
2152
+ }
2153
+ if (tagName === "br") {
2154
+ return openingElement.attributes.length === 0;
2155
+ }
2156
+ return openingElement.attributes.length === 0;
2157
+ }
2158
+ function convertToMarkdown(path, prefix, suffix) {
2159
+ const element = path.node;
2160
+ if (!canConvertToMarkdown(element))
2161
+ return;
2162
+ const children = element.children;
2163
+ if (!hasOnlyTextChildren(children))
2164
+ return;
2165
+ const textContent = extractTextContent(children);
2166
+ if (!textContent)
2167
+ return;
2168
+ const markdownText = `${prefix}${textContent}${suffix}`;
2169
+ path.replaceWith(t.jsxText(markdownText));
2170
+ }
2171
+ function convertLinkToMarkdown(path) {
2172
+ const element = path.node;
2173
+ if (!canConvertToMarkdown(element))
2174
+ return;
2175
+ const children = element.children;
2176
+ if (!hasOnlyTextChildren(children))
2177
+ return;
2178
+ const hrefAttr = element.openingElement.attributes.find(
2179
+ (attr) => t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name) && attr.name.name === "href"
2180
+ );
2181
+ if (!hrefAttr || !t.isJSXAttribute(hrefAttr))
2182
+ return;
2183
+ let href = "";
2184
+ if (t.isStringLiteral(hrefAttr.value)) {
2185
+ href = hrefAttr.value.value;
2186
+ } else if (t.isJSXExpressionContainer(hrefAttr.value) && t.isStringLiteral(hrefAttr.value.expression)) {
2187
+ href = hrefAttr.value.expression.value;
2188
+ } else {
2189
+ return;
2190
+ }
2191
+ const textContent = extractTextContent(children);
2192
+ if (!textContent)
2193
+ return;
2194
+ const markdownText = `[${textContent}](${href})`;
2195
+ path.replaceWith(t.jsxText(markdownText));
2196
+ }
2197
+ function convertBrToNewline(path) {
2198
+ const element = path.node;
2199
+ if (!canConvertToMarkdown(element))
2200
+ return;
2201
+ path.replaceWith(t.jsxText("\n"));
2202
+ }
2203
+ function convertParagraphToMarkdown(path) {
2204
+ const element = path.node;
2205
+ if (!canConvertToMarkdown(element))
2206
+ return;
2207
+ const children = element.children;
2208
+ if (!hasOnlyTextChildren(children))
2209
+ return;
2210
+ const textContent = extractTextContent(children);
2211
+ if (!textContent)
2212
+ return;
2213
+ const markdownText = `${textContent}
2214
+
2215
+ `;
2216
+ path.replaceWith(t.jsxText(markdownText));
2217
+ }
2218
+ function convertUnorderedListToMarkdown(path) {
2219
+ const element = path.node;
2220
+ if (element.openingElement.attributes.length > 0)
2221
+ return;
2222
+ const children = element.children;
2223
+ const listItems = [];
2224
+ for (const child of children) {
2225
+ if (t.isJSXElement(child)) {
2226
+ const tagName = t.isJSXIdentifier(child.openingElement.name) ? child.openingElement.name.name : null;
2227
+ if ((tagName == null ? void 0 : tagName.toLowerCase()) === "li" && canConvertToMarkdown(child)) {
2228
+ const itemText = extractTextContent(child.children);
2229
+ if (itemText) {
2230
+ listItems.push(`- ${itemText}`);
2231
+ }
2232
+ } else {
2233
+ return;
2234
+ }
2235
+ } else if (t.isJSXText(child) && child.value.trim()) {
2236
+ return;
2237
+ }
2238
+ }
2239
+ if (listItems.length === 0)
2240
+ return;
2241
+ const markdownText = listItems.join("\n") + "\n";
2242
+ path.replaceWith(t.jsxText(markdownText));
2243
+ }
2244
+ function convertOrderedListToMarkdown(path) {
2245
+ const element = path.node;
2246
+ if (element.openingElement.attributes.length > 0)
2247
+ return;
2248
+ const children = element.children;
2249
+ const listItems = [];
2250
+ for (const child of children) {
2251
+ if (t.isJSXElement(child)) {
2252
+ const tagName = t.isJSXIdentifier(child.openingElement.name) ? child.openingElement.name.name : null;
2253
+ if ((tagName == null ? void 0 : tagName.toLowerCase()) === "li" && canConvertToMarkdown(child)) {
2254
+ const itemText = extractTextContent(child.children);
2255
+ if (itemText) {
2256
+ listItems.push(`${listItems.length + 1}. ${itemText}`);
2257
+ }
2258
+ } else {
2259
+ return;
2260
+ }
2261
+ } else if (t.isJSXText(child) && child.value.trim()) {
2262
+ return;
2263
+ }
2264
+ }
2265
+ if (listItems.length === 0)
2266
+ return;
2267
+ const markdownText = listItems.join("\n") + "\n";
2268
+ path.replaceWith(t.jsxText(markdownText));
2269
+ }
2270
+ function extractTextContent(children) {
2271
+ let text = "";
2272
+ for (const child of children) {
2273
+ if (t.isJSXText(child)) {
2274
+ text += child.value;
2275
+ } else if (t.isJSXExpressionContainer(child)) {
2276
+ return "";
2277
+ } else if (t.isJSXElement(child)) {
2278
+ const nestedText = extractTextContent(child.children);
2279
+ if (!nestedText)
2280
+ return "";
2281
+ const tagName = t.isJSXIdentifier(child.openingElement.name) ? child.openingElement.name.name.toLowerCase() : null;
2282
+ switch (tagName) {
2283
+ case "strong":
2284
+ case "b":
2285
+ text += `**${nestedText}**`;
2286
+ break;
2287
+ case "em":
2288
+ case "i":
2289
+ text += `*${nestedText}*`;
2290
+ break;
2291
+ case "u":
2292
+ text += `__${nestedText}__`;
2293
+ break;
2294
+ case "br":
2295
+ text += "\n";
2296
+ break;
2297
+ default:
2298
+ return "";
2299
+ }
2300
+ }
2301
+ }
2302
+ return text;
2303
+ }
2304
+
2104
2305
  // src/compiler/plugins/jsx-preserve-newlines.ts
2105
2306
  import {
2106
2307
  isJSXIdentifier,
@@ -2137,10 +2338,71 @@ var JSXNewLines = {
2137
2338
  postProcessing
2138
2339
  };
2139
2340
 
2341
+ // src/compiler/plugins/jsx-undefined-vars.ts
2342
+ import { types as t2 } from "@babel/core";
2343
+ function jsxUndefinedVarsPlugin() {
2344
+ return {
2345
+ name: "jsx-undefined-vars",
2346
+ visitor: {
2347
+ JSXExpressionContainer(path) {
2348
+ const expression = path.node.expression;
2349
+ if (t2.isJSXEmptyExpression(expression)) {
2350
+ return;
2351
+ }
2352
+ if (!t2.isIdentifier(expression)) {
2353
+ return;
2354
+ }
2355
+ const varName = expression.name;
2356
+ const knownGlobals = /* @__PURE__ */ new Set([
2357
+ "undefined",
2358
+ "null",
2359
+ "true",
2360
+ "false",
2361
+ "NaN",
2362
+ "Infinity",
2363
+ "console",
2364
+ "Math",
2365
+ "JSON",
2366
+ "Object",
2367
+ "Array",
2368
+ "String",
2369
+ "Number",
2370
+ "Boolean",
2371
+ "Date",
2372
+ "RegExp",
2373
+ "Error",
2374
+ "Promise",
2375
+ "Symbol"
2376
+ ]);
2377
+ if (knownGlobals.has(varName)) {
2378
+ return;
2379
+ }
2380
+ const iife = t2.callExpression(
2381
+ t2.arrowFunctionExpression(
2382
+ [],
2383
+ t2.blockStatement([
2384
+ t2.tryStatement(
2385
+ t2.blockStatement([t2.returnStatement(t2.identifier(varName))]),
2386
+ t2.catchClause(
2387
+ null,
2388
+ // no error binding needed
2389
+ t2.blockStatement([t2.returnStatement(t2.stringLiteral(varName))])
2390
+ )
2391
+ )
2392
+ ])
2393
+ ),
2394
+ []
2395
+ );
2396
+ path.node.expression = iife;
2397
+ }
2398
+ }
2399
+ };
2400
+ }
2401
+
2140
2402
  // src/compiler/plugins/line-tracking.ts
2141
2403
  import { callExpression, expressionStatement, identifier, numericLiteral } from "@babel/types";
2142
2404
  var LineTrackingFnIdentifier = "__track__";
2143
- var lineTrackingBabelPlugin = function({ types: t }) {
2405
+ var lineTrackingBabelPlugin = function({ types: t3 }) {
2144
2406
  return {
2145
2407
  visitor: {
2146
2408
  Program(path) {
@@ -2161,8 +2423,8 @@ var lineTrackingBabelPlugin = function({ types: t }) {
2161
2423
  console.error(e);
2162
2424
  }
2163
2425
  };
2164
- if (t.isFunctionDeclaration(node) || t.isClassMethod(node) || t.isReturnStatement(node) || t.isAwaitExpression(node) || t.isForOfStatement(node) || t.isCallExpression(node) || t.isUnaryExpression(node) || t.isVariableDeclaration(node) || t.isBlockStatement(path2.parent) || t.isAssignmentExpression(node)) {
2165
- if (!trackedLines.has(startLine) && !t.isArrowFunctionExpression(path2.parent) && !t.isObjectProperty(path2.parent) && !t.isAwaitExpression(path2.parent) && !t.isUnaryExpression(path2.parent) && !t.isReturnStatement(path2.parent) && !t.isForOfStatement(path2.parent) && !t.isForStatement(path2.parent) && !t.isForInStatement(path2.parent) && !t.isVariableDeclaration(path2.parent) && !t.isBinaryExpression(path2.parent) && !t.isLogicalExpression(path2.parent)) {
2426
+ if (t3.isFunctionDeclaration(node) || t3.isClassMethod(node) || t3.isReturnStatement(node) || t3.isAwaitExpression(node) || t3.isForOfStatement(node) || t3.isCallExpression(node) || t3.isUnaryExpression(node) || t3.isVariableDeclaration(node) || t3.isBlockStatement(path2.parent) || t3.isAssignmentExpression(node)) {
2427
+ if (!trackedLines.has(startLine) && !t3.isArrowFunctionExpression(path2.parent) && !t3.isObjectProperty(path2.parent) && !t3.isAwaitExpression(path2.parent) && !t3.isUnaryExpression(path2.parent) && !t3.isReturnStatement(path2.parent) && !t3.isForOfStatement(path2.parent) && !t3.isForStatement(path2.parent) && !t3.isForInStatement(path2.parent) && !t3.isVariableDeclaration(path2.parent) && !t3.isBinaryExpression(path2.parent) && !t3.isLogicalExpression(path2.parent)) {
2166
2428
  track();
2167
2429
  }
2168
2430
  }
@@ -2177,7 +2439,7 @@ var lineTrackingBabelPlugin = function({ types: t }) {
2177
2439
  // src/compiler/plugins/replace-comment.ts
2178
2440
  var CommentFnIdentifier = "__comment__";
2179
2441
  var replaceCommentBabelPlugin = function({
2180
- types: t
2442
+ types: t3
2181
2443
  }) {
2182
2444
  return {
2183
2445
  visitor: {
@@ -2196,13 +2458,13 @@ var replaceCommentBabelPlugin = function({
2196
2458
  return;
2197
2459
  }
2198
2460
  processed.add(comment.loc);
2199
- const commentCall = t.expressionStatement(
2200
- t.callExpression(t.identifier(CommentFnIdentifier), [
2201
- t.stringLiteral(comment.value.trim()),
2202
- t.numericLiteral(((_a = comment.loc) == null ? void 0 : _a.start.line) ?? 0)
2461
+ const commentCall = t3.expressionStatement(
2462
+ t3.callExpression(t3.identifier(CommentFnIdentifier), [
2463
+ t3.stringLiteral(comment.value.trim()),
2464
+ t3.numericLiteral(((_a = comment.loc) == null ? void 0 : _a.start.line) ?? 0)
2203
2465
  ])
2204
2466
  );
2205
- const isInsideObjectProperty = t.isObjectProperty(node) || path2.findParent((path3) => t.isObjectProperty(path3.node));
2467
+ const isInsideObjectProperty = t3.isObjectProperty(node) || path2.findParent((path3) => t3.isObjectProperty(path3.node));
2206
2468
  if (!isInsideObjectProperty) {
2207
2469
  insertMethod(commentCall);
2208
2470
  }
@@ -2221,7 +2483,7 @@ var replaceCommentBabelPlugin = function({
2221
2483
 
2222
2484
  // src/compiler/plugins/return-async.ts
2223
2485
  var instrumentLastLinePlugin = function({
2224
- types: t
2486
+ types: t3
2225
2487
  }) {
2226
2488
  return {
2227
2489
  visitor: {
@@ -2235,14 +2497,14 @@ var instrumentLastLinePlugin = function({
2235
2497
  return;
2236
2498
  }
2237
2499
  const lastStatement = statements[statements.length - 1];
2238
- if (t.isReturnStatement(lastStatement)) {
2239
- if (t.isExpression(lastStatement.argument)) {
2240
- lastStatement.argument = t.awaitExpression(lastStatement.argument);
2500
+ if (t3.isReturnStatement(lastStatement)) {
2501
+ if (t3.isExpression(lastStatement.argument)) {
2502
+ lastStatement.argument = t3.awaitExpression(lastStatement.argument);
2241
2503
  }
2242
2504
  return;
2243
2505
  }
2244
- if (t.isExpressionStatement(lastStatement) && (t.isCallExpression(lastStatement.expression) || t.isAwaitExpression(lastStatement.expression))) {
2245
- const returnStatement3 = t.returnStatement(t.awaitExpression(lastStatement.expression));
2506
+ if (t3.isExpressionStatement(lastStatement) && (t3.isCallExpression(lastStatement.expression) || t3.isAwaitExpression(lastStatement.expression))) {
2507
+ const returnStatement3 = t3.returnStatement(t3.awaitExpression(lastStatement.expression));
2246
2508
  (_b = path.get("body").get("body")[statements.length - 1]) == null ? void 0 : _b.replaceWith(returnStatement3);
2247
2509
  }
2248
2510
  }
@@ -2460,7 +2722,7 @@ import {
2460
2722
  returnStatement as returnStatement2
2461
2723
  } from "@babel/types";
2462
2724
  var VariableTrackingFnIdentifier = "__var__";
2463
- var variableTrackingPlugin = (variables = /* @__PURE__ */ new Set()) => function({ types: t }) {
2725
+ var variableTrackingPlugin = (variables = /* @__PURE__ */ new Set()) => function({ types: t3 }) {
2464
2726
  let trackingStatements = [];
2465
2727
  const trackVariable = (variableName) => {
2466
2728
  if (variableName.startsWith("__")) {
@@ -2480,19 +2742,19 @@ var variableTrackingPlugin = (variables = /* @__PURE__ */ new Set()) => function
2480
2742
  visitor: {
2481
2743
  FunctionDeclaration(path) {
2482
2744
  path.node.params.forEach((param) => {
2483
- if (t.isIdentifier(param)) {
2745
+ if (t3.isIdentifier(param)) {
2484
2746
  trackVariable(param.name);
2485
- } else if (t.isAssignmentPattern(param) && t.isIdentifier(param.left)) {
2747
+ } else if (t3.isAssignmentPattern(param) && t3.isIdentifier(param.left)) {
2486
2748
  trackVariable(param.left.name);
2487
- } else if (t.isObjectPattern(param)) {
2749
+ } else if (t3.isObjectPattern(param)) {
2488
2750
  param.properties.forEach((prop) => {
2489
- if (t.isObjectProperty(prop) && t.isIdentifier(prop.value)) {
2751
+ if (t3.isObjectProperty(prop) && t3.isIdentifier(prop.value)) {
2490
2752
  trackVariable(prop.value.name);
2491
2753
  }
2492
2754
  });
2493
- } else if (t.isArrayPattern(param)) {
2755
+ } else if (t3.isArrayPattern(param)) {
2494
2756
  param.elements.forEach((element) => {
2495
- if (t.isIdentifier(element)) {
2757
+ if (t3.isIdentifier(element)) {
2496
2758
  trackVariable(element.name);
2497
2759
  }
2498
2760
  });
@@ -2505,19 +2767,19 @@ var variableTrackingPlugin = (variables = /* @__PURE__ */ new Set()) => function
2505
2767
  },
2506
2768
  ArrowFunctionExpression(path) {
2507
2769
  path.node.params.forEach((param) => {
2508
- if (t.isIdentifier(param)) {
2770
+ if (t3.isIdentifier(param)) {
2509
2771
  trackVariable(param.name);
2510
- } else if (t.isAssignmentPattern(param) && t.isIdentifier(param.left)) {
2772
+ } else if (t3.isAssignmentPattern(param) && t3.isIdentifier(param.left)) {
2511
2773
  trackVariable(param.left.name);
2512
- } else if (t.isObjectPattern(param)) {
2774
+ } else if (t3.isObjectPattern(param)) {
2513
2775
  param.properties.forEach((prop) => {
2514
- if (t.isObjectProperty(prop) && t.isIdentifier(prop.value)) {
2776
+ if (t3.isObjectProperty(prop) && t3.isIdentifier(prop.value)) {
2515
2777
  trackVariable(prop.value.name);
2516
2778
  }
2517
2779
  });
2518
- } else if (t.isArrayPattern(param)) {
2780
+ } else if (t3.isArrayPattern(param)) {
2519
2781
  param.elements.forEach((element) => {
2520
- if (t.isIdentifier(element)) {
2782
+ if (t3.isIdentifier(element)) {
2521
2783
  trackVariable(element.name);
2522
2784
  }
2523
2785
  });
@@ -2538,11 +2800,11 @@ var variableTrackingPlugin = (variables = /* @__PURE__ */ new Set()) => function
2538
2800
  const parent = path.parentPath;
2539
2801
  const handleObjectPattern = (pattern) => {
2540
2802
  pattern.properties.forEach((prop) => {
2541
- if (t.isObjectProperty(prop) && t.isIdentifier(prop.value)) {
2803
+ if (t3.isObjectProperty(prop) && t3.isIdentifier(prop.value)) {
2542
2804
  trackVariable(prop.value.name);
2543
- } else if (t.isObjectProperty(prop) && t.isObjectPattern(prop.value)) {
2805
+ } else if (t3.isObjectProperty(prop) && t3.isObjectPattern(prop.value)) {
2544
2806
  handleObjectPattern(prop.value);
2545
- } else if (t.isObjectProperty(prop) && t.isAssignmentPattern(prop.value) && t.isIdentifier(prop.value.left)) {
2807
+ } else if (t3.isObjectProperty(prop) && t3.isAssignmentPattern(prop.value) && t3.isIdentifier(prop.value.left)) {
2546
2808
  trackVariable(prop.value.left.name);
2547
2809
  }
2548
2810
  });
@@ -2551,19 +2813,19 @@ var variableTrackingPlugin = (variables = /* @__PURE__ */ new Set()) => function
2551
2813
  if (parent.isForXStatement() || parent.isForStatement()) {
2552
2814
  return;
2553
2815
  }
2554
- if (t.isIdentifier(declarator.id)) {
2816
+ if (t3.isIdentifier(declarator.id)) {
2555
2817
  trackVariable(declarator.id.name);
2556
2818
  }
2557
- if (t.isObjectPattern(declarator.id)) {
2819
+ if (t3.isObjectPattern(declarator.id)) {
2558
2820
  handleObjectPattern(declarator.id);
2559
2821
  }
2560
- if (t.isArrayPattern(declarator.id)) {
2822
+ if (t3.isArrayPattern(declarator.id)) {
2561
2823
  declarator.id.elements.forEach((element) => {
2562
- if (t.isIdentifier(element)) {
2824
+ if (t3.isIdentifier(element)) {
2563
2825
  trackVariable(element.name);
2564
- } else if (t.isRestElement(element) && t.isIdentifier(element.argument)) {
2826
+ } else if (t3.isRestElement(element) && t3.isIdentifier(element.argument)) {
2565
2827
  trackVariable(element.argument.name);
2566
- } else if (t.isAssignmentPattern(element) && t.isIdentifier(element.left)) {
2828
+ } else if (t3.isAssignmentPattern(element) && t3.isIdentifier(element.left)) {
2567
2829
  trackVariable(element.left.name);
2568
2830
  }
2569
2831
  });
@@ -2612,6 +2874,10 @@ function compile(code) {
2612
2874
  presets: ["typescript"],
2613
2875
  plugins: [
2614
2876
  JSXNewLines.babelPlugin,
2877
+ htmlToMarkdownPlugin,
2878
+ // Convert simple HTML to markdown first
2879
+ jsxUndefinedVarsPlugin,
2880
+ // Must run BEFORE JSX transform
2615
2881
  [
2616
2882
  jsxPlugin,
2617
2883
  {
@@ -2801,7 +3067,6 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
2801
3067
  };
2802
3068
  const QuickJS = await newQuickJSWASMModuleFromVariant(BundledReleaseSyncVariant);
2803
3069
  const runtime = QuickJS.newRuntime();
2804
- runtime.setDebugMode(true);
2805
3070
  runtime.setMemoryLimit(128 * 1024 * 1024);
2806
3071
  const startTime = Date.now();
2807
3072
  const timeoutHandler = shouldInterruptAfterDeadline(startTime + timeout);
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
3
+ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
4
4
 
5
5
 
6
6
 
@@ -38,7 +38,7 @@ async function formatTypings(typings, options) {
38
38
  return result;
39
39
  } catch (err) {
40
40
  if (options == null ? void 0 : options.throwOnError) {
41
- throw new (0, _chunkT63Y6GTWcjs.CodeFormattingError)(err instanceof Error ? err.message : _nullishCoalesce((err == null ? void 0 : err.toString()), () => ( "Unknown Error")), typings);
41
+ throw new (0, _chunkPK72FAKDcjs.CodeFormattingError)(err instanceof Error ? err.message : _nullishCoalesce((err == null ? void 0 : err.toString()), () => ( "Unknown Error")), typings);
42
42
  }
43
43
  return typings;
44
44
  }
@@ -96,10 +96,11 @@ var VMLoopSignal = class extends VMSignal {
96
96
  }
97
97
  };
98
98
  var ThinkSignal = class extends VMLoopSignal {
99
- constructor(reason, context) {
99
+ constructor(reason, context, metadata) {
100
100
  super("Think signal received: " + reason);
101
101
  this.reason = reason;
102
102
  this.context = context;
103
+ this.metadata = metadata;
103
104
  this.message = Signals.serializeError(this);
104
105
  this.stack = "";
105
106
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
2
 
3
- var _chunkRLOPQZTQcjs = require('./chunk-RLOPQZTQ.cjs');
3
+ var _chunkINDOGCAQcjs = require('./chunk-INDOGCAQ.cjs');
4
4
 
5
5
 
6
6
 
@@ -94,7 +94,16 @@ var Tool = (_class = class _Tool {
94
94
  * @internal
95
95
  */
96
96
  get zInput() {
97
- let input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
97
+ let input;
98
+ if (this.input) {
99
+ try {
100
+ input = _zui.transforms.fromJSONSchema(this.input);
101
+ } catch (e2) {
102
+ input = _zui.transforms.fromJSONSchemaLegacy(this.input);
103
+ }
104
+ } else {
105
+ input = _zui.z.any();
106
+ }
98
107
  if (!_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
99
108
  const inputExtensions = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
100
109
  if (input instanceof _zui.z.ZodObject) {
@@ -114,7 +123,14 @@ var Tool = (_class = class _Tool {
114
123
  * @internal
115
124
  */
116
125
  get zOutput() {
117
- return this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : _zui.z.void();
126
+ if (!this.output) {
127
+ return _zui.z.void();
128
+ }
129
+ try {
130
+ return _zui.transforms.fromJSONSchema(this.output);
131
+ } catch (e3) {
132
+ return _zui.transforms.fromJSONSchemaLegacy(this.output);
133
+ }
118
134
  }
119
135
  /**
120
136
  * Renames the tool and updates its aliases.
@@ -200,8 +216,22 @@ var Tool = (_class = class _Tool {
200
216
  clone(props = {}) {
201
217
  var _a, _b;
202
218
  try {
203
- const zInput = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : void 0;
204
- const zOutput = this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : void 0;
219
+ let zInput;
220
+ if (this.input) {
221
+ try {
222
+ zInput = _zui.transforms.fromJSONSchema(this.input);
223
+ } catch (e4) {
224
+ zInput = _zui.transforms.fromJSONSchemaLegacy(this.input);
225
+ }
226
+ }
227
+ let zOutput;
228
+ if (this.output) {
229
+ try {
230
+ zOutput = _zui.transforms.fromJSONSchema(this.output);
231
+ } catch (e5) {
232
+ zOutput = _zui.transforms.fromJSONSchemaLegacy(this.output);
233
+ }
234
+ }
205
235
  return new _Tool({
206
236
  name: _nullishCoalesce(props.name, () => ( this.name)),
207
237
  aliases: _nullishCoalesce(props.aliases, () => ( [...this.aliases])),
@@ -324,7 +354,11 @@ var Tool = (_class = class _Tool {
324
354
  }
325
355
  if (typeof props.input !== "undefined") {
326
356
  if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.input)) {
327
- this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
357
+ try {
358
+ this.input = _zui.transforms.toJSONSchema(props.input);
359
+ } catch (e6) {
360
+ this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
361
+ }
328
362
  } else if (_chunkWHNOR4ZUcjs.isJsonSchema.call(void 0, props.input)) {
329
363
  this.input = props.input;
330
364
  } else {
@@ -335,7 +369,11 @@ var Tool = (_class = class _Tool {
335
369
  }
336
370
  if (typeof props.output !== "undefined") {
337
371
  if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.output)) {
338
- this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
372
+ try {
373
+ this.output = _zui.transforms.toJSONSchema(props.output);
374
+ } catch (e7) {
375
+ this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
376
+ }
339
377
  } else if (_chunkWHNOR4ZUcjs.isJsonSchema.call(void 0, props.output)) {
340
378
  this.output = props.output;
341
379
  } else {
@@ -413,8 +451,24 @@ var Tool = (_class = class _Tool {
413
451
  * @returns Promise resolving to TypeScript declaration string
414
452
  */
415
453
  async getTypings() {
416
- let input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : void 0;
417
- const output = this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : _zui.z.void();
454
+ let input;
455
+ if (this.input) {
456
+ try {
457
+ input = _zui.transforms.fromJSONSchema(this.input);
458
+ } catch (e8) {
459
+ input = _zui.transforms.fromJSONSchemaLegacy(this.input);
460
+ }
461
+ }
462
+ let output;
463
+ if (!this.output || Object.keys(this.output).length === 0) {
464
+ output = _zui.z.void();
465
+ } else {
466
+ try {
467
+ output = _zui.transforms.fromJSONSchema(this.output);
468
+ } catch (e9) {
469
+ output = _zui.transforms.fromJSONSchemaLegacy(this.output);
470
+ }
471
+ }
418
472
  if ((input == null ? void 0 : input.naked()) instanceof _zui.ZodObject && typeof this._staticInputValues === "object" && !_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
419
473
  const inputExtensions = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
420
474
  input = input.extend(inputExtensions);
@@ -422,7 +476,7 @@ var Tool = (_class = class _Tool {
422
476
  input = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
423
477
  }
424
478
  const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
425
- return _chunkRLOPQZTQcjs.getTypings.call(void 0, fnType, {
479
+ return _chunkINDOGCAQcjs.getTypings.call(void 0, fnType, {
426
480
  declaration: true
427
481
  });
428
482
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CodeFormattingError
3
- } from "./chunk-MYLTD5WT.js";
3
+ } from "./chunk-WSVDMGMR.js";
4
4
  import {
5
5
  escapeString,
6
6
  getMultilineComment,
@@ -96,10 +96,11 @@ var VMLoopSignal = class extends VMSignal {
96
96
  }
97
97
  };
98
98
  var ThinkSignal = class extends VMLoopSignal {
99
- constructor(reason, context) {
99
+ constructor(reason, context, metadata) {
100
100
  super("Think signal received: " + reason);
101
101
  this.reason = reason;
102
102
  this.context = context;
103
+ this.metadata = metadata;
103
104
  this.message = Signals.serializeError(this);
104
105
  this.stack = "";
105
106
  }
@@ -0,0 +1,21 @@
1
+ import { type PluginObj } from '@babel/core';
2
+ /**
3
+ * This plugin converts simple HTML tags in JSX text to markdown equivalents.
4
+ * Only handles basic formatting tags without attributes (except href/src).
5
+ *
6
+ * Supported conversions:
7
+ * - <strong>text</strong> -> **text**
8
+ * - <b>text</b> -> **text**
9
+ * - <em>text</em> -> *text*
10
+ * - <i>text</i> -> *text*
11
+ * - <u>text</u> -> __text__
12
+ * - <a href="url">text</a> -> [text](url)
13
+ * - <ul><li>item</li></ul> -> - item
14
+ * - <ol><li>item</li></ol> -> 1. item
15
+ * - <br>, <br/>, <br /> -> \n
16
+ * - <p>text</p> -> text\n\n
17
+ *
18
+ * Only converts tags that have no attributes (except href for links).
19
+ * Preserves complex HTML that can't be represented in simple markdown.
20
+ */
21
+ export declare function htmlToMarkdownPlugin(): PluginObj;