llmz 0.2.1 → 0.2.3

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 (62) hide show
  1. package/CLAUDE.md +0 -1
  2. package/dist/{chunk-WWZ2W4WR.cjs → chunk-3UZKLXAD.cjs} +410 -514
  3. package/dist/{chunk-HM5H556L.js → chunk-72ZWBNZV.js} +1 -1
  4. package/dist/{chunk-D6PU5YAS.cjs → chunk-DDSJTR6Q.cjs} +8 -7
  5. package/dist/{chunk-665O7CAN.js → chunk-GDJTKI7J.js} +5 -1
  6. package/dist/{chunk-YX27XM67.js → chunk-GLXADNTR.js} +13 -1
  7. package/dist/{chunk-FPLSJF4S.cjs → chunk-GOWPACSK.cjs} +15 -3
  8. package/dist/{chunk-XVVYNOTX.js → chunk-HB2G32AK.js} +3 -2
  9. package/dist/{chunk-YQT5G77W.cjs → chunk-HEAQAEFZ.cjs} +2 -2
  10. package/dist/{chunk-DD4AZSP5.cjs → chunk-HMMM32RG.cjs} +19 -15
  11. package/dist/{chunk-MY26EAOP.cjs → chunk-KG5E3UZZ.cjs} +20 -20
  12. package/dist/{chunk-YGKQEVQQ.cjs → chunk-OVRDJMZJ.cjs} +29 -37
  13. package/dist/{chunk-E5NHK3FS.js → chunk-OXEKAOVI.js} +6 -14
  14. package/dist/{chunk-ETYFOCWC.cjs → chunk-PZE6PIPG.cjs} +12 -11
  15. package/dist/chunk-RGUG3UMF.cjs +26 -0
  16. package/dist/{chunk-GC5IQDGV.js → chunk-TDALRNGL.js} +4 -3
  17. package/dist/chunk-UGHFNCPD.js +26 -0
  18. package/dist/{chunk-ZWUWCRHG.js → chunk-XMFQVARN.js} +5 -5
  19. package/dist/{chunk-DH35WO5G.js → chunk-YRS7KRKP.js} +401 -505
  20. package/dist/compiler/ast.d.ts +26 -0
  21. package/dist/compiler/compiler.d.ts +13 -11
  22. package/dist/compiler/plugins/line-tracking.d.ts +6 -4
  23. package/dist/compiler/plugins/replace-comment.d.ts +8 -4
  24. package/dist/compiler/plugins/return-async.d.ts +18 -4
  25. package/dist/compiler/plugins/track-tool-calls.d.ts +21 -4
  26. package/dist/compiler/plugins/variable-extraction.d.ts +9 -4
  27. package/dist/component.default.d.ts +13 -91
  28. package/dist/{dual-modes-RMF7V7ZQ.js → dual-modes-BYABHBDI.js} +3 -3
  29. package/dist/dual-modes-HO6RRIZ5.cjs +10 -0
  30. package/dist/emscripten-module.wasm +0 -0
  31. package/dist/{execute-LNUBLVMZ.js → execute-DSGJ2UNL.js} +9 -8
  32. package/dist/{execute-2AGZ5QUN.cjs → execute-MRZZ4AYY.cjs} +41 -40
  33. package/dist/exit-MX56VN2C.cjs +8 -0
  34. package/dist/{exit-VJATJTQI.js → exit-UQ3EUX5D.js} +2 -2
  35. package/dist/exit.d.ts +1 -1
  36. package/dist/index.cjs +210 -253
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +184 -227
  39. package/dist/index.workerd.js +17328 -0
  40. package/dist/prompts/chat-mode/system.md.d.ts +1 -1
  41. package/dist/prompts/worker-mode/system.md.d.ts +1 -1
  42. package/dist/prompts/worker-mode/user.md.d.ts +1 -1
  43. package/dist/quickjs-variant.d.ts +22 -0
  44. package/dist/quickjs-variant.workerd.d.ts +22 -0
  45. package/dist/{tool-HTAYKIA2.js → tool-KD7FL45V.js} +3 -3
  46. package/dist/{tool-V55GD2FS.cjs → tool-VE2YHIY2.cjs} +4 -4
  47. package/dist/{truncator-OZOBNYON.js → truncator-73RCL52Y.js} +2 -2
  48. package/dist/truncator-FZNLYSDL.cjs +12 -0
  49. package/dist/{typings-SCKZCAPN.js → typings-E2RROCLT.js} +2 -2
  50. package/dist/{typings-S6I6IPTG.cjs → typings-LQOBZXSO.cjs} +3 -3
  51. package/dist/typings-formatter.d.ts +19 -0
  52. package/dist/{utils-ZEZ66X6Q.js → utils-IATCUNKF.js} +5 -1
  53. package/dist/utils-ITB4NEL7.cjs +43 -0
  54. package/dist/utils.d.ts +18 -0
  55. package/dist/vm-6D3IIIU7.cjs +12 -0
  56. package/dist/{vm-44H4UKI2.js → vm-QO5FSGPN.js} +2 -1
  57. package/package.json +8 -14
  58. package/dist/dual-modes-ZZY6QPYT.cjs +0 -10
  59. package/dist/exit-LUJY7JIG.cjs +0 -8
  60. package/dist/truncator-7PGEGCHV.cjs +0 -12
  61. package/dist/utils-GLZVMRWO.cjs +0 -39
  62. package/dist/vm-A3OTQVIR.cjs +0 -11
package/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ export type { ExecutionProps, ExecutionHooks } from './runtime/types.js';
22
22
  export { type ValueOrGetter, getValue } from './getter.js';
23
23
  export * from './message-stream/index.js';
24
24
  export * from './custom-client.js';
25
+ export { configureQuickJS } from './quickjs-variant.js';
26
+ export { configureTokenizer } from './utils.js';
25
27
  export declare const utils: {
26
28
  toValidObjectName: (str: string) => string;
27
29
  toValidFunctionName: (str: string) => string;
package/dist/index.js CHANGED
@@ -10,21 +10,28 @@ import {
10
10
  _CustomModelClient,
11
11
  getValue,
12
12
  parseExit
13
- } from "./chunk-ZWUWCRHG.js";
13
+ } from "./chunk-XMFQVARN.js";
14
14
  import {
15
15
  MARKER,
16
16
  NAME_REGEX,
17
17
  StreamingMessageParser,
18
18
  generateInstructions,
19
19
  tryParseJson
20
- } from "./chunk-E5NHK3FS.js";
20
+ } from "./chunk-OXEKAOVI.js";
21
+ import {
22
+ configureQuickJS
23
+ } from "./chunk-UGHFNCPD.js";
21
24
  import {
22
25
  Tool
23
- } from "./chunk-GC5IQDGV.js";
26
+ } from "./chunk-TDALRNGL.js";
24
27
  import {
25
28
  formatTypings,
26
- getTypings
27
- } from "./chunk-665O7CAN.js";
29
+ getTypings,
30
+ isGroup,
31
+ isPunct,
32
+ parse,
33
+ tokenize
34
+ } from "./chunk-GDJTKI7J.js";
28
35
  import {
29
36
  CodeFormattingError,
30
37
  LoopExceededError,
@@ -34,7 +41,7 @@ import {
34
41
  import "./chunk-YEAWWJSJ.js";
35
42
  import {
36
43
  Exit
37
- } from "./chunk-XVVYNOTX.js";
44
+ } from "./chunk-HB2G32AK.js";
38
45
  import {
39
46
  Component,
40
47
  assertValidComponent,
@@ -46,8 +53,9 @@ import {
46
53
  stripTruncationTags,
47
54
  truncateWrappedContent,
48
55
  wrapContent
49
- } from "./chunk-HM5H556L.js";
56
+ } from "./chunk-72ZWBNZV.js";
50
57
  import {
58
+ configureTokenizer,
51
59
  escapeString,
52
60
  getMultilineComment,
53
61
  isJsonSchema,
@@ -55,238 +63,193 @@ import {
55
63
  isZuiSchema,
56
64
  toValidFunctionName,
57
65
  toValidObjectName
58
- } from "./chunk-YX27XM67.js";
66
+ } from "./chunk-GLXADNTR.js";
59
67
  import {
60
- cloneDeep_default,
61
68
  upperFirst_default
62
69
  } from "./chunk-34GJUS6U.js";
63
70
 
64
71
  // package.json
65
- var version = "0.2.1";
72
+ var version = "0.2.3";
66
73
 
67
74
  // src/objects.ts
68
75
  import { z } from "@bpinternal/zui";
69
76
 
70
77
  // src/hoist.ts
71
- import { CodeGenerator } from "@babel/generator";
72
- import { parse } from "@babel/parser";
73
- import Traverse from "@babel/traverse";
74
- import * as t from "@babel/types";
75
- var traverse = Traverse;
76
- function getTypingsWithoutComments(type) {
77
- const typeClone = cloneDeep_default(type);
78
- removeBabelComments(typeClone);
79
- return new CodeGenerator(typeClone, { comments: false }).generate().code;
78
+ function printNodes(nodes) {
79
+ let out = "";
80
+ let afterLineComment = false;
81
+ const emit = (n) => {
82
+ const newlines = Math.min(n.nl ?? 0, 2);
83
+ if (newlines > 0) {
84
+ out += "\n".repeat(newlines);
85
+ } else if (afterLineComment) {
86
+ out += "\n";
87
+ } else if (out.length && !out.endsWith("\n")) {
88
+ out += " ";
89
+ }
90
+ afterLineComment = false;
91
+ if (isGroup(n)) {
92
+ out += n.open;
93
+ for (const child of n.children) {
94
+ emit(child);
95
+ }
96
+ if (afterLineComment) {
97
+ out += "\n";
98
+ afterLineComment = false;
99
+ }
100
+ out += n.close;
101
+ } else {
102
+ out += n.text;
103
+ afterLineComment = n.kind === "line-comment";
104
+ }
105
+ };
106
+ for (const n of nodes) {
107
+ emit(n);
108
+ }
109
+ return out;
80
110
  }
81
- function removeBabelComments(node) {
82
- node.leadingComments = null;
83
- node.trailingComments = null;
84
- node.innerComments = null;
85
- Object.keys(node).forEach((key) => {
86
- const val = node[key];
87
- if (Array.isArray(val)) {
88
- val.forEach((child) => child && typeof child === "object" && removeBabelComments(child));
89
- } else if (val && typeof val === "object" && val.type) {
90
- removeBabelComments(val);
111
+ function keyOf(group) {
112
+ const parts = [];
113
+ const visit = (n) => {
114
+ if (isGroup(n)) {
115
+ parts.push(n.open);
116
+ n.children.forEach(visit);
117
+ parts.push(n.close);
118
+ } else if (n.kind === "word" || n.kind === "string" || n.kind === "punct" && n.text !== ";" && n.text !== ",") {
119
+ parts.push(n.text);
91
120
  }
92
- });
121
+ };
122
+ visit(group);
123
+ return parts.join(" ");
93
124
  }
94
- function extractAndHoistTypes(ast) {
95
- const typeMap = /* @__PURE__ */ new Map();
96
- const typeCounts = /* @__PURE__ */ new Map();
97
- const hoistedTypes = [];
98
- function addTypeToMap(typeNode) {
99
- const typeString = getTypingsWithoutComments(typeNode.typeAnnotation);
100
- if (!typeMap.has(typeString)) {
101
- typeMap.set(typeString, typeNode);
125
+ var prevMeaningful = (siblings, index) => {
126
+ for (let i = index - 1; i >= 0; i--) {
127
+ const n = siblings[i];
128
+ if (isGroup(n) || n.kind !== "block-comment" && n.kind !== "line-comment") {
129
+ return n;
102
130
  }
103
131
  }
104
- function generateUniqueTypeName(baseName) {
105
- let typeName = baseName;
106
- let counter = 1;
107
- while ([...typeMap.values()].some((typeNode) => typeNode.id.name === typeName)) {
108
- typeName = `${baseName}${counter++}`;
109
- }
110
- return typeName;
111
- }
112
- function createTypeAlias(name, type) {
113
- return t.tsTypeAliasDeclaration(t.identifier(name), null, type);
114
- }
115
- function getTypePaths(path) {
116
- var _a, _b, _c;
117
- let currPath = path;
118
- const parts = /* @__PURE__ */ new Set();
119
- while (currPath) {
120
- const { node, parentPath } = currPath;
121
- if (t.isIdentifier(node) && node.name) {
122
- parts.add(node.name);
123
- }
124
- if (t.isTSMethodSignature(node) && currPath.key === "parameters") {
125
- parts.add("Input");
126
- }
127
- if (currPath.key === "returnType") {
128
- parts.add("Output");
129
- const methodName = "id" in parentPath.node && "name" in parentPath.node.id && ((_b = (_a = parentPath == null ? void 0 : parentPath.node) == null ? void 0 : _a.id) == null ? void 0 : _b.name);
130
- if (methodName) {
131
- parts.add(methodName);
132
- }
133
- }
134
- if (((_c = node == null ? void 0 : node.key) == null ? void 0 : _c.type) === "Identifier") {
135
- parts.add(node.key.name);
136
- }
137
- if (t.isTSParameterProperty(node) || t.isTSFunctionType(node)) {
138
- parts.add("Input");
139
- }
140
- if (t.isTSFunctionType(node)) {
141
- parts.add("Output");
142
- }
143
- currPath = parentPath;
132
+ return void 0;
133
+ };
134
+ var asName = (text) => upperFirst_default(text.replace(/['"]/g, "").replace(/[^A-Za-z0-9_$]/g, ""));
135
+ function segmentsAt(siblings, index) {
136
+ var _a;
137
+ const prev = prevMeaningful(siblings, index);
138
+ if (!prev || isGroup(prev)) {
139
+ return [];
140
+ }
141
+ if (isPunct(prev, "=>")) {
142
+ return ["Output"];
143
+ }
144
+ if (isPunct(prev, ":") || isPunct(prev, "<")) {
145
+ let i = siblings.indexOf(prev) - 1;
146
+ while (i >= 0 && !isGroup(siblings[i]) && ((_a = siblings[i].kind) == null ? void 0 : _a.includes("comment"))) {
147
+ i--;
144
148
  }
145
- return parts.size ? Array.from(parts).reverse().map(upperFirst_default) : ["UnnamedType"];
146
- }
147
- function generateTypeName(path) {
148
- return getTypePaths(path).join("");
149
- }
150
- function findNestedTypes(path) {
151
- const node = path.node;
152
- if (t.isTSTypeLiteral(node)) {
153
- const typeString = getTypingsWithoutComments(node);
154
- typeCounts.set(typeString, (typeCounts.get(typeString) || 0) + 1);
155
- if (typeMap.has(typeString) && (typeCounts.get(typeString) || 0) > 1) {
156
- path.replaceWith(t.tsTypeReference(typeMap.get(typeString).id));
157
- } else if (!typeMap.has(typeString) && (typeCounts.get(typeString) || 0) > 1) {
158
- const typeName = generateUniqueTypeName(generateTypeName(path));
159
- const typeAlias = createTypeAlias(typeName, node);
160
- addTypeToMap(typeAlias);
161
- path.replaceWith(t.tsTypeReference(t.identifier(typeName)));
162
- }
163
- const members = path.get("members");
164
- const memberPaths = Array.isArray(members) ? members : [members];
165
- memberPaths.forEach((memberPath) => {
166
- findNestedTypes(memberPath);
167
- });
149
+ let q = siblings[i];
150
+ if (q && !isGroup(q) && q.kind === "punct" && q.text === "?") {
151
+ q = siblings[--i];
168
152
  }
169
- if (t.isTSPropertySignature(node) && path.get("typeAnnotation")) {
170
- const annPath = path.get("typeAnnotation.typeAnnotation");
171
- if (annPath == null ? void 0 : annPath.node) {
172
- findNestedTypes(annPath);
173
- }
153
+ if (q && isGroup(q) && q.open === "(") {
154
+ const fnWord = prevMeaningful(siblings, i);
155
+ return fnWord && !isGroup(fnWord) && fnWord.kind === "word" ? [asName(fnWord.text), "Output"] : ["Output"];
174
156
  }
175
- if (t.isTSArrayType(node)) {
176
- findNestedTypes(path.get("elementType"));
157
+ if (q && !isGroup(q) && (q.kind === "word" || q.kind === "string")) {
158
+ return [asName(q.text)];
177
159
  }
178
- if (t.isTSUnionType(node) || t.isTSIntersectionType(node)) {
179
- ;
180
- path.get("types").forEach((p) => findNestedTypes(p));
160
+ }
161
+ return [];
162
+ }
163
+ function walkLiterals(siblings, path, visit) {
164
+ var _a;
165
+ for (let i = 0; i < siblings.length; i++) {
166
+ const node = siblings[i];
167
+ if (!isGroup(node)) {
168
+ continue;
181
169
  }
182
- if (t.isTSTypeReference(node) && node.typeParameters) {
183
- ;
184
- path.get("typeParameters.params").forEach((param) => findNestedTypes(param));
170
+ if (node.open === "(") {
171
+ const fnWord = prevMeaningful(siblings, i);
172
+ const fnName = fnWord && !isGroup(fnWord) && fnWord.kind === "word" ? [asName(fnWord.text)] : [];
173
+ walkLiterals(node.children, [...path, ...fnName], visit);
174
+ continue;
185
175
  }
186
- if (t.isTSFunctionType(node)) {
187
- const returnPath = path.get("typeAnnotation");
188
- if (returnPath == null ? void 0 : returnPath.node)
189
- findNestedTypes(returnPath);
190
- const params = path.get("parameters");
191
- params.forEach((paramPath) => {
192
- const ta = paramPath.get("typeAnnotation.typeAnnotation");
193
- if (ta == null ? void 0 : ta.node)
194
- findNestedTypes(ta);
195
- });
176
+ if (node.open === "<" || node.open === "[") {
177
+ walkLiterals(node.children, [...path, ...segmentsAt(siblings, i)], visit);
178
+ continue;
196
179
  }
197
- if (t.isTSMethodSignature(node)) {
198
- const returnPath = path.get("typeAnnotation");
199
- if (returnPath == null ? void 0 : returnPath.node) {
200
- findNestedTypes(returnPath);
180
+ const prev = prevMeaningful(siblings, i);
181
+ if (prev && isPunct(prev, "=")) {
182
+ const eqIdx = siblings.indexOf(prev);
183
+ const nameTok = siblings[eqIdx - 1];
184
+ const typeTok = siblings[eqIdx - 2];
185
+ const isAlias = nameTok && typeTok && !isGroup(nameTok) && !isGroup(typeTok) && nameTok.kind === "word" && typeTok.kind === "word" && typeTok.text === "type";
186
+ if (!isAlias) {
187
+ continue;
188
+ }
189
+ const aliasName = nameTok.text;
190
+ visit({ siblings, index: i, group: node, path: [aliasName], aliasName });
191
+ if (siblings[i] === node) {
192
+ walkLiterals(node.children, [aliasName], visit);
201
193
  }
202
- const params = path.get("parameters");
203
- params.forEach((paramPath) => {
204
- const ta = paramPath.get("typeAnnotation.typeAnnotation");
205
- if (ta == null ? void 0 : ta.node)
206
- findNestedTypes(ta);
207
- });
194
+ continue;
208
195
  }
209
- if (t.isTSDeclareFunction(node)) {
210
- const params = path.get("params");
211
- params.forEach((p) => {
212
- const ta = p.get("typeAnnotation.typeAnnotation");
213
- if (ta == null ? void 0 : ta.node)
214
- findNestedTypes(ta);
215
- });
216
- const returnType = path.get("returnType.typeAnnotation");
217
- if (returnType == null ? void 0 : returnType.node)
218
- findNestedTypes(returnType);
196
+ const prevIsNamespace = prev && !isGroup(prev) && prev.kind === "word" && ((_a = prevMeaningful(siblings, siblings.indexOf(prev))) == null ? void 0 : _a.kind) === "word";
197
+ const namespaceLike = prevIsNamespace && ["namespace", "module"].includes(prevMeaningful(siblings, siblings.indexOf(prev)).text);
198
+ const segments = segmentsAt(siblings, i);
199
+ const newPath = [...path, ...segments];
200
+ if (!namespaceLike) {
201
+ visit({ siblings, index: i, group: node, path: newPath });
202
+ }
203
+ if (siblings[i] === node) {
204
+ walkLiterals(node.children, namespaceLike ? [...path, asName(prev.text)] : newPath, visit);
219
205
  }
220
206
  }
221
- traverse(ast, {
222
- TSTypeAliasDeclaration(path) {
223
- const typeString = getTypingsWithoutComments(path.node.typeAnnotation);
224
- typeCounts.set(typeString, (typeCounts.get(typeString) || 0) + 1);
225
- if (typeMap.has(typeString) && (typeCounts.get(typeString) || 0) > 1) {
226
- const existing = typeMap.get(typeString);
227
- path.replaceWith(
228
- t.tsTypeAliasDeclaration(path.node.id, null, t.tsTypeReference(t.identifier(existing.id.name)))
229
- );
230
- } else {
231
- addTypeToMap(path.node);
232
- }
233
- },
234
- TSPropertySignature(path) {
235
- const annPath = path.get("typeAnnotation.typeAnnotation");
236
- if (annPath == null ? void 0 : annPath.node)
237
- findNestedTypes(annPath);
238
- },
239
- TSFunctionType(path) {
240
- const returnPath = path.get("typeAnnotation");
241
- if (returnPath.node)
242
- findNestedTypes(returnPath);
243
- const params = path.get("parameters");
244
- params.forEach((param) => {
245
- const ta = param.get("typeAnnotation.typeAnnotation");
246
- if (ta == null ? void 0 : ta.node)
247
- findNestedTypes(ta);
248
- });
249
- },
250
- TSMethodSignature(path) {
251
- const returnPath = path.get("typeAnnotation.typeAnnotation");
252
- if (returnPath == null ? void 0 : returnPath.node) {
253
- findNestedTypes(returnPath);
254
- }
255
- const params = path.get("parameters");
256
- params.forEach((param) => {
257
- const ta = param.get("typeAnnotation.typeAnnotation");
258
- if (ta == null ? void 0 : ta.node)
259
- findNestedTypes(ta);
260
- });
261
- },
262
- TSDeclareFunction(path) {
263
- const params = path.get("params");
264
- params.forEach((p) => {
265
- const ta = p.get("typeAnnotation.typeAnnotation");
266
- if (ta == null ? void 0 : ta.node)
267
- findNestedTypes(ta);
268
- });
269
- const returnPath = path.get("returnType.typeAnnotation");
270
- if (returnPath == null ? void 0 : returnPath.node)
271
- findNestedTypes(returnPath);
207
+ }
208
+ function extractAndHoistTypes(code) {
209
+ const top = parse(tokenize(code));
210
+ const counts = /* @__PURE__ */ new Map();
211
+ const aliasByKey = /* @__PURE__ */ new Map();
212
+ const usedNames = /* @__PURE__ */ new Set();
213
+ walkLiterals(top, [], ({ group, path, aliasName }) => {
214
+ const key = keyOf(group);
215
+ counts.set(key, (counts.get(key) ?? 0) + 1);
216
+ if (aliasName && !aliasByKey.has(key)) {
217
+ aliasByKey.set(key, aliasName);
218
+ }
219
+ for (const segment of path) {
220
+ usedNames.add(segment);
221
+ }
222
+ if (aliasName) {
223
+ usedNames.add(aliasName);
272
224
  }
273
225
  });
274
- typeMap.forEach((typeNode, typeString) => {
275
- if ((typeCounts.get(typeString) || 0) > 1) {
276
- if (!hoistedTypes.some((ht) => {
277
- return getTypingsWithoutComments(ht.typeAnnotation) === getTypingsWithoutComments(typeNode.typeAnnotation);
278
- })) {
279
- hoistedTypes.push(typeNode);
280
- }
226
+ const uniqueName = (base) => {
227
+ let name = base;
228
+ let counter = 1;
229
+ while (usedNames.has(name)) {
230
+ name = `${base}${counter++}`;
231
+ }
232
+ usedNames.add(name);
233
+ return name;
234
+ };
235
+ const newAliases = [];
236
+ walkLiterals(top, [], ({ siblings, index, group, aliasName, path }) => {
237
+ const key = keyOf(group);
238
+ if ((counts.get(key) ?? 0) < 2 || aliasName) {
239
+ return;
240
+ }
241
+ let name = aliasByKey.get(key);
242
+ if (!name) {
243
+ const deduped = [...new Set(path)];
244
+ name = uniqueName(deduped.length ? deduped.join("") : "UnnamedType");
245
+ aliasByKey.set(key, name);
246
+ newAliases.push(`type ${name} = ${printNodes([{ ...group, nl: 0 }])}`);
281
247
  }
248
+ siblings[index] = { kind: "word", text: name, nl: group.nl };
282
249
  });
283
- ast.program.body = [
284
- ...hoistedTypes,
285
- ...ast.program.body.filter(
286
- (node) => !hoistedTypes.some((ht) => t.isTSTypeAliasDeclaration(node) && node.id.name === ht.id.name)
287
- )
288
- ];
289
- return ast;
250
+ const body = printNodes(top);
251
+ return newAliases.length ? `${newAliases.join("\n")}
252
+ ${body}` : body;
290
253
  }
291
254
  async function hoistTypings(code, formatOptions) {
292
255
  formatOptions ??= {};
@@ -294,15 +257,7 @@ async function hoistTypings(code, formatOptions) {
294
257
  for (let i = 1; i <= 5; i++) {
295
258
  try {
296
259
  const initialCode = code;
297
- const ast = parse(code, {
298
- sourceType: "module",
299
- plugins: ["typescript"]
300
- });
301
- const transformedAst = extractAndHoistTypes(ast);
302
- code = new CodeGenerator(transformedAst, {
303
- // quotes: 'single',
304
- compact: false
305
- }).generate().code;
260
+ code = extractAndHoistTypes(code);
306
261
  if (initialCode === code) {
307
262
  break;
308
263
  }
@@ -1572,20 +1527,20 @@ var utils = {
1572
1527
  stripTruncationTags
1573
1528
  };
1574
1529
  var execute = async (props) => {
1575
- const { executeContext } = await import("./execute-LNUBLVMZ.js");
1530
+ const { executeContext } = await import("./execute-DSGJ2UNL.js");
1576
1531
  return executeContext(props);
1577
1532
  };
1578
1533
  var init = async () => {
1579
- await import("./execute-LNUBLVMZ.js");
1534
+ await import("./execute-DSGJ2UNL.js");
1580
1535
  await import("./component-ASNZHQUR.js");
1581
- await import("./tool-HTAYKIA2.js");
1582
- await import("./exit-VJATJTQI.js");
1536
+ await import("./tool-KD7FL45V.js");
1537
+ await import("./exit-UQ3EUX5D.js");
1583
1538
  await import("./jsx-DDZ63UUF.js");
1584
- await import("./vm-44H4UKI2.js");
1585
- await import("./utils-ZEZ66X6Q.js");
1586
- await import("./truncator-OZOBNYON.js");
1587
- await import("./typings-SCKZCAPN.js");
1588
- await import("./dual-modes-RMF7V7ZQ.js");
1539
+ await import("./vm-QO5FSGPN.js");
1540
+ await import("./utils-IATCUNKF.js");
1541
+ await import("./truncator-73RCL52Y.js");
1542
+ await import("./typings-E2RROCLT.js");
1543
+ await import("./dual-modes-BYABHBDI.js");
1589
1544
  };
1590
1545
  export {
1591
1546
  BaseResponse,
@@ -1618,6 +1573,8 @@ export {
1618
1573
  _CustomModelClient,
1619
1574
  assertValidComponent,
1620
1575
  collectText,
1576
+ configureQuickJS,
1577
+ configureTokenizer,
1621
1578
  execute,
1622
1579
  generateInstructions,
1623
1580
  getValue,