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.
- package/CLAUDE.md +0 -1
- package/dist/{chunk-WWZ2W4WR.cjs → chunk-3UZKLXAD.cjs} +410 -514
- package/dist/{chunk-HM5H556L.js → chunk-72ZWBNZV.js} +1 -1
- package/dist/{chunk-D6PU5YAS.cjs → chunk-DDSJTR6Q.cjs} +8 -7
- package/dist/{chunk-665O7CAN.js → chunk-GDJTKI7J.js} +5 -1
- package/dist/{chunk-YX27XM67.js → chunk-GLXADNTR.js} +13 -1
- package/dist/{chunk-FPLSJF4S.cjs → chunk-GOWPACSK.cjs} +15 -3
- package/dist/{chunk-XVVYNOTX.js → chunk-HB2G32AK.js} +3 -2
- package/dist/{chunk-YQT5G77W.cjs → chunk-HEAQAEFZ.cjs} +2 -2
- package/dist/{chunk-DD4AZSP5.cjs → chunk-HMMM32RG.cjs} +19 -15
- package/dist/{chunk-MY26EAOP.cjs → chunk-KG5E3UZZ.cjs} +20 -20
- package/dist/{chunk-YGKQEVQQ.cjs → chunk-OVRDJMZJ.cjs} +29 -37
- package/dist/{chunk-E5NHK3FS.js → chunk-OXEKAOVI.js} +6 -14
- package/dist/{chunk-ETYFOCWC.cjs → chunk-PZE6PIPG.cjs} +12 -11
- package/dist/chunk-RGUG3UMF.cjs +26 -0
- package/dist/{chunk-GC5IQDGV.js → chunk-TDALRNGL.js} +4 -3
- package/dist/chunk-UGHFNCPD.js +26 -0
- package/dist/{chunk-ZWUWCRHG.js → chunk-XMFQVARN.js} +5 -5
- package/dist/{chunk-DH35WO5G.js → chunk-YRS7KRKP.js} +401 -505
- package/dist/compiler/ast.d.ts +26 -0
- package/dist/compiler/compiler.d.ts +13 -11
- package/dist/compiler/plugins/line-tracking.d.ts +6 -4
- package/dist/compiler/plugins/replace-comment.d.ts +8 -4
- package/dist/compiler/plugins/return-async.d.ts +18 -4
- package/dist/compiler/plugins/track-tool-calls.d.ts +21 -4
- package/dist/compiler/plugins/variable-extraction.d.ts +9 -4
- package/dist/component.default.d.ts +13 -91
- package/dist/{dual-modes-RMF7V7ZQ.js → dual-modes-BYABHBDI.js} +3 -3
- package/dist/dual-modes-HO6RRIZ5.cjs +10 -0
- package/dist/emscripten-module.wasm +0 -0
- package/dist/{execute-LNUBLVMZ.js → execute-DSGJ2UNL.js} +9 -8
- package/dist/{execute-2AGZ5QUN.cjs → execute-MRZZ4AYY.cjs} +41 -40
- package/dist/exit-MX56VN2C.cjs +8 -0
- package/dist/{exit-VJATJTQI.js → exit-UQ3EUX5D.js} +2 -2
- package/dist/exit.d.ts +1 -1
- package/dist/index.cjs +210 -253
- package/dist/index.d.ts +2 -0
- package/dist/index.js +184 -227
- package/dist/index.workerd.js +17328 -0
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/user.md.d.ts +1 -1
- package/dist/quickjs-variant.d.ts +22 -0
- package/dist/quickjs-variant.workerd.d.ts +22 -0
- package/dist/{tool-HTAYKIA2.js → tool-KD7FL45V.js} +3 -3
- package/dist/{tool-V55GD2FS.cjs → tool-VE2YHIY2.cjs} +4 -4
- package/dist/{truncator-OZOBNYON.js → truncator-73RCL52Y.js} +2 -2
- package/dist/truncator-FZNLYSDL.cjs +12 -0
- package/dist/{typings-SCKZCAPN.js → typings-E2RROCLT.js} +2 -2
- package/dist/{typings-S6I6IPTG.cjs → typings-LQOBZXSO.cjs} +3 -3
- package/dist/typings-formatter.d.ts +19 -0
- package/dist/{utils-ZEZ66X6Q.js → utils-IATCUNKF.js} +5 -1
- package/dist/utils-ITB4NEL7.cjs +43 -0
- package/dist/utils.d.ts +18 -0
- package/dist/vm-6D3IIIU7.cjs +12 -0
- package/dist/{vm-44H4UKI2.js → vm-QO5FSGPN.js} +2 -1
- package/package.json +8 -14
- package/dist/dual-modes-ZZY6QPYT.cjs +0 -10
- package/dist/exit-LUJY7JIG.cjs +0 -8
- package/dist/truncator-7PGEGCHV.cjs +0 -12
- package/dist/utils-GLZVMRWO.cjs +0 -39
- package/dist/vm-A3OTQVIR.cjs +0 -11
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class; var _class2; var _class3; var _class4;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -10,21 +10,28 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkKG5E3UZZcjs = require('./chunk-KG5E3UZZ.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkOVRDJMZJcjs = require('./chunk-OVRDJMZJ.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkRGUG3UMFcjs = require('./chunk-RGUG3UMF.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
var _chunkPZE6PIPGcjs = require('./chunk-PZE6PIPG.cjs');
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var _chunkHMMM32RGcjs = require('./chunk-HMMM32RG.cjs');
|
|
28
35
|
|
|
29
36
|
|
|
30
37
|
|
|
@@ -34,7 +41,7 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
|
34
41
|
require('./chunk-KIN7Y247.cjs');
|
|
35
42
|
|
|
36
43
|
|
|
37
|
-
var
|
|
44
|
+
var _chunkDDSJTR6Qcjs = require('./chunk-DDSJTR6Q.cjs');
|
|
38
45
|
|
|
39
46
|
|
|
40
47
|
|
|
@@ -46,7 +53,7 @@ require('./chunk-5ZF6NTYI.cjs');
|
|
|
46
53
|
|
|
47
54
|
|
|
48
55
|
|
|
49
|
-
var
|
|
56
|
+
var _chunkHEAQAEFZcjs = require('./chunk-HEAQAEFZ.cjs');
|
|
50
57
|
|
|
51
58
|
|
|
52
59
|
|
|
@@ -55,238 +62,194 @@ var _chunkYQT5G77Wcjs = require('./chunk-YQT5G77W.cjs');
|
|
|
55
62
|
|
|
56
63
|
|
|
57
64
|
|
|
58
|
-
var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
|
|
59
65
|
|
|
66
|
+
var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
|
|
60
67
|
|
|
61
68
|
|
|
62
69
|
var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
63
70
|
|
|
64
71
|
// package.json
|
|
65
|
-
var version = "0.2.
|
|
72
|
+
var version = "0.2.3";
|
|
66
73
|
|
|
67
74
|
// src/objects.ts
|
|
68
75
|
var _zui = require('@bpinternal/zui');
|
|
69
76
|
|
|
70
77
|
// src/hoist.ts
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
function printNodes(nodes) {
|
|
79
|
+
let out = "";
|
|
80
|
+
let afterLineComment = false;
|
|
81
|
+
const emit = (n) => {
|
|
82
|
+
const newlines = Math.min(_nullishCoalesce(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 (_chunkHMMM32RGcjs.isGroup.call(void 0, 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
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
removeBabelComments(val);
|
|
111
|
+
function keyOf(group) {
|
|
112
|
+
const parts = [];
|
|
113
|
+
const visit = (n) => {
|
|
114
|
+
if (_chunkHMMM32RGcjs.isGroup.call(void 0, 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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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 (_chunkHMMM32RGcjs.isGroup.call(void 0, n) || n.kind !== "block-comment" && n.kind !== "line-comment") {
|
|
129
|
+
return n;
|
|
102
130
|
}
|
|
103
131
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
|
|
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) => _chunkHC2QZTVTcjs.upperFirst_default.call(void 0, 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 || _chunkHMMM32RGcjs.isGroup.call(void 0, prev)) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
if (_chunkHMMM32RGcjs.isPunct.call(void 0, prev, "=>")) {
|
|
142
|
+
return ["Output"];
|
|
143
|
+
}
|
|
144
|
+
if (_chunkHMMM32RGcjs.isPunct.call(void 0, prev, ":") || _chunkHMMM32RGcjs.isPunct.call(void 0, prev, "<")) {
|
|
145
|
+
let i = siblings.indexOf(prev) - 1;
|
|
146
|
+
while (i >= 0 && !_chunkHMMM32RGcjs.isGroup.call(void 0, siblings[i]) && ((_a = siblings[i].kind) == null ? void 0 : _a.includes("comment"))) {
|
|
147
|
+
i--;
|
|
144
148
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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 && !_chunkHMMM32RGcjs.isGroup.call(void 0, q) && q.kind === "punct" && q.text === "?") {
|
|
151
|
+
q = siblings[--i];
|
|
168
152
|
}
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
findNestedTypes(annPath);
|
|
173
|
-
}
|
|
153
|
+
if (q && _chunkHMMM32RGcjs.isGroup.call(void 0, q) && q.open === "(") {
|
|
154
|
+
const fnWord = prevMeaningful(siblings, i);
|
|
155
|
+
return fnWord && !_chunkHMMM32RGcjs.isGroup.call(void 0, fnWord) && fnWord.kind === "word" ? [asName(fnWord.text), "Output"] : ["Output"];
|
|
174
156
|
}
|
|
175
|
-
if (
|
|
176
|
-
|
|
157
|
+
if (q && !_chunkHMMM32RGcjs.isGroup.call(void 0, q) && (q.kind === "word" || q.kind === "string")) {
|
|
158
|
+
return [asName(q.text)];
|
|
177
159
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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 (!_chunkHMMM32RGcjs.isGroup.call(void 0, node)) {
|
|
168
|
+
continue;
|
|
181
169
|
}
|
|
182
|
-
if (
|
|
183
|
-
;
|
|
184
|
-
|
|
170
|
+
if (node.open === "(") {
|
|
171
|
+
const fnWord = prevMeaningful(siblings, i);
|
|
172
|
+
const fnName = fnWord && !_chunkHMMM32RGcjs.isGroup.call(void 0, fnWord) && fnWord.kind === "word" ? [asName(fnWord.text)] : [];
|
|
173
|
+
walkLiterals(node.children, [...path, ...fnName], visit);
|
|
174
|
+
continue;
|
|
185
175
|
}
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
180
|
+
const prev = prevMeaningful(siblings, i);
|
|
181
|
+
if (prev && _chunkHMMM32RGcjs.isPunct.call(void 0, prev, "=")) {
|
|
182
|
+
const eqIdx = siblings.indexOf(prev);
|
|
183
|
+
const nameTok = siblings[eqIdx - 1];
|
|
184
|
+
const typeTok = siblings[eqIdx - 2];
|
|
185
|
+
const isAlias = nameTok && typeTok && !_chunkHMMM32RGcjs.isGroup.call(void 0, nameTok) && !_chunkHMMM32RGcjs.isGroup.call(void 0, 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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const prevIsNamespace = prev && !_chunkHMMM32RGcjs.isGroup.call(void 0, 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 });
|
|
208
202
|
}
|
|
209
|
-
if (
|
|
210
|
-
|
|
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);
|
|
203
|
+
if (siblings[i] === node) {
|
|
204
|
+
walkLiterals(node.children, namespaceLike ? [...path, asName(prev.text)] : newPath, visit);
|
|
219
205
|
}
|
|
220
206
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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 = _chunkHMMM32RGcjs.parse.call(void 0, _chunkHMMM32RGcjs.tokenize.call(void 0, 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, (_nullishCoalesce(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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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++}`;
|
|
281
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 ((_nullishCoalesce(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 }])}`);
|
|
247
|
+
}
|
|
248
|
+
siblings[index] = { kind: "word", text: name, nl: group.nl };
|
|
282
249
|
});
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
298
|
-
sourceType: "module",
|
|
299
|
-
plugins: ["typescript"]
|
|
300
|
-
});
|
|
301
|
-
const transformedAst = extractAndHoistTypes(ast);
|
|
302
|
-
code = new (0, _generator.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
|
}
|
|
@@ -314,7 +269,7 @@ async function hoistTypings(code, formatOptions) {
|
|
|
314
269
|
break;
|
|
315
270
|
}
|
|
316
271
|
}
|
|
317
|
-
return
|
|
272
|
+
return _chunkHMMM32RGcjs.formatTypings.call(void 0, code, formatOptions);
|
|
318
273
|
}
|
|
319
274
|
|
|
320
275
|
// src/objects.ts
|
|
@@ -383,7 +338,7 @@ var ObjectInstance = class {
|
|
|
383
338
|
*/
|
|
384
339
|
constructor(props) {
|
|
385
340
|
var _a;
|
|
386
|
-
if (!
|
|
341
|
+
if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
387
342
|
throw new Error(
|
|
388
343
|
`Invalid name for tool ${props.name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
389
344
|
);
|
|
@@ -416,7 +371,7 @@ var ObjectInstance = class {
|
|
|
416
371
|
if (props.properties.filter((p) => p.name === prop.name).length > 1) {
|
|
417
372
|
throw new Error(`Duplicate property name "${prop.name}" in tool ${props.name}`);
|
|
418
373
|
}
|
|
419
|
-
if (!
|
|
374
|
+
if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, prop.name)) {
|
|
420
375
|
throw new Error(
|
|
421
376
|
`Invalid name for property ${prop.name}. A property name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
422
377
|
);
|
|
@@ -440,7 +395,7 @@ var ObjectInstance = class {
|
|
|
440
395
|
this.description = props.description;
|
|
441
396
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
442
397
|
this.properties = props.properties;
|
|
443
|
-
this.tools =
|
|
398
|
+
this.tools = _chunkPZE6PIPGcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
444
399
|
}
|
|
445
400
|
/**
|
|
446
401
|
* Generates TypeScript namespace declarations for this object.
|
|
@@ -517,11 +472,11 @@ function getObjectTypings(obj) {
|
|
|
517
472
|
for (const prop of _nullishCoalesce(obj.properties, () => ( []))) {
|
|
518
473
|
const description = _nullishCoalesce(prop.description, () => ( ""));
|
|
519
474
|
if (description == null ? void 0 : description.trim().length) {
|
|
520
|
-
typings.push(
|
|
475
|
+
typings.push(_chunkGOWPACSKcjs.getMultilineComment.call(void 0, description));
|
|
521
476
|
}
|
|
522
477
|
let type = "unknown";
|
|
523
478
|
if (prop.type) {
|
|
524
|
-
type = await
|
|
479
|
+
type = await _chunkHMMM32RGcjs.getTypings.call(void 0, prop.type, {});
|
|
525
480
|
} else if (prop.value !== void 0) {
|
|
526
481
|
type = typeof prop.value;
|
|
527
482
|
}
|
|
@@ -541,7 +496,7 @@ function getObjectTypings(obj) {
|
|
|
541
496
|
typings.push("");
|
|
542
497
|
for (const tool of obj.tools) {
|
|
543
498
|
const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
|
|
544
|
-
let temp = await
|
|
499
|
+
let temp = await _chunkHMMM32RGcjs.getTypings.call(void 0, fnType, {
|
|
545
500
|
declaration: true
|
|
546
501
|
});
|
|
547
502
|
temp = temp.replace("declare function ", "function ");
|
|
@@ -562,9 +517,9 @@ function getObjectTypings(obj) {
|
|
|
562
517
|
typings.push("}" + closingBracket);
|
|
563
518
|
let header = "";
|
|
564
519
|
if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
|
|
565
|
-
header =
|
|
520
|
+
header = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, obj.description);
|
|
566
521
|
}
|
|
567
|
-
return
|
|
522
|
+
return _chunkHMMM32RGcjs.formatTypings.call(void 0,
|
|
568
523
|
`${header}
|
|
569
524
|
export namespace ${obj.name} {
|
|
570
525
|
${body}
|
|
@@ -595,7 +550,7 @@ function getObjectTypings(obj) {
|
|
|
595
550
|
}
|
|
596
551
|
function embedPropertyValue(property) {
|
|
597
552
|
if (typeof property.value === "string") {
|
|
598
|
-
return
|
|
553
|
+
return _chunkGOWPACSKcjs.escapeString.call(void 0, property.value);
|
|
599
554
|
}
|
|
600
555
|
if (Number.isNaN(property.value)) {
|
|
601
556
|
return "NaN";
|
|
@@ -613,7 +568,7 @@ function embedPropertyValue(property) {
|
|
|
613
568
|
return `new Date('${property.value.toISOString()}')`;
|
|
614
569
|
}
|
|
615
570
|
if (property.value instanceof RegExp) {
|
|
616
|
-
return `new RegExp(${
|
|
571
|
+
return `new RegExp(${_chunkGOWPACSKcjs.escapeString.call(void 0, property.value.source)}, ${_chunkGOWPACSKcjs.escapeString.call(void 0, property.value.flags)})`;
|
|
617
572
|
}
|
|
618
573
|
if (property.value === null) {
|
|
619
574
|
return "null";
|
|
@@ -631,7 +586,7 @@ function embedPropertyValue(property) {
|
|
|
631
586
|
return `${property.value}n`;
|
|
632
587
|
}
|
|
633
588
|
if (property.value instanceof Error) {
|
|
634
|
-
return `Error(${
|
|
589
|
+
return `Error(${_chunkGOWPACSKcjs.escapeString.call(void 0, property.value.message)})`;
|
|
635
590
|
}
|
|
636
591
|
if (property.value instanceof Map) {
|
|
637
592
|
return `new Map(${JSON.stringify(Array.from(property.value.entries()))})`;
|
|
@@ -1212,7 +1167,7 @@ var SendResponse = class extends BaseResponse {
|
|
|
1212
1167
|
return this.item.props;
|
|
1213
1168
|
}
|
|
1214
1169
|
static formatToText(component, props, body) {
|
|
1215
|
-
const header = `${
|
|
1170
|
+
const header = `${_chunkOVRDJMZJcjs.MARKER}send=${component}${props && Object.keys(props).length ? ` ${JSON.stringify(props)}` : ""}`;
|
|
1216
1171
|
return body ? `${header}
|
|
1217
1172
|
${body}` : header;
|
|
1218
1173
|
}
|
|
@@ -1223,7 +1178,7 @@ var RunResponse = class extends BaseResponse {
|
|
|
1223
1178
|
this.code = code;
|
|
1224
1179
|
}
|
|
1225
1180
|
static formatToText(code) {
|
|
1226
|
-
return `${
|
|
1181
|
+
return `${_chunkOVRDJMZJcjs.MARKER}run
|
|
1227
1182
|
${code}`;
|
|
1228
1183
|
}
|
|
1229
1184
|
};
|
|
@@ -1238,7 +1193,7 @@ var NextResponse = class extends BaseResponse {
|
|
|
1238
1193
|
return this.item.props;
|
|
1239
1194
|
}
|
|
1240
1195
|
static formatToText(name, props) {
|
|
1241
|
-
return `${
|
|
1196
|
+
return `${_chunkOVRDJMZJcjs.MARKER}next=${name}${props && Object.keys(props).length ? ` ${JSON.stringify(props)}` : ""}`;
|
|
1242
1197
|
}
|
|
1243
1198
|
};
|
|
1244
1199
|
var EventPump = (_class3 = class {
|
|
@@ -1295,7 +1250,7 @@ function parseText(text, options) {
|
|
|
1295
1250
|
);
|
|
1296
1251
|
}
|
|
1297
1252
|
async function* parseResponses(stream, options) {
|
|
1298
|
-
const parser = new (0,
|
|
1253
|
+
const parser = new (0, _chunkOVRDJMZJcjs.StreamingMessageParser)(options);
|
|
1299
1254
|
const pump = new EventPump(stream, parser);
|
|
1300
1255
|
let activeBody;
|
|
1301
1256
|
while (true) {
|
|
@@ -1352,7 +1307,7 @@ var ComponentRegistry = (_class4 = class {
|
|
|
1352
1307
|
}
|
|
1353
1308
|
}
|
|
1354
1309
|
register(definition) {
|
|
1355
|
-
if (!
|
|
1310
|
+
if (!_chunkOVRDJMZJcjs.NAME_REGEX.test(definition.name)) {
|
|
1356
1311
|
throw new Error(
|
|
1357
1312
|
`Invalid component name "${definition.name}". Component names must be lowercase ([a-z][a-z0-9_-]*).`
|
|
1358
1313
|
);
|
|
@@ -1379,7 +1334,7 @@ var EMPTY_PROPS_SCHEMA = { type: "object", properties: {}, additionalProperties:
|
|
|
1379
1334
|
var normalizeComponentName = (name) => name.trim().toLowerCase();
|
|
1380
1335
|
function normalizeComponentDefinition(definition) {
|
|
1381
1336
|
const name = normalizeComponentName(_nullishCoalesce(definition.name, () => ( "")));
|
|
1382
|
-
if (!
|
|
1337
|
+
if (!_chunkOVRDJMZJcjs.NAME_REGEX.test(name)) {
|
|
1383
1338
|
throw new Error(
|
|
1384
1339
|
`Invalid component name "${definition.name}". Component names must be lowercase ([a-z][a-z0-9_-]*).`
|
|
1385
1340
|
);
|
|
@@ -1400,14 +1355,14 @@ function normalizePropsSchema(props, name) {
|
|
|
1400
1355
|
if (props === void 0) {
|
|
1401
1356
|
return EMPTY_PROPS_SCHEMA;
|
|
1402
1357
|
}
|
|
1403
|
-
if (
|
|
1358
|
+
if (_chunkGOWPACSKcjs.isZuiSchema.call(void 0, props)) {
|
|
1404
1359
|
try {
|
|
1405
1360
|
return _zui.transforms.toJSONSchema(props);
|
|
1406
1361
|
} catch (e2) {
|
|
1407
1362
|
return _zui.transforms.toJSONSchemaLegacy(props);
|
|
1408
1363
|
}
|
|
1409
1364
|
}
|
|
1410
|
-
if (
|
|
1365
|
+
if (_chunkGOWPACSKcjs.isJsonSchema.call(void 0, props)) {
|
|
1411
1366
|
return props;
|
|
1412
1367
|
}
|
|
1413
1368
|
throw new Error(
|
|
@@ -1561,31 +1516,31 @@ var _checkValue = (value, schema, path, errors) => {
|
|
|
1561
1516
|
};
|
|
1562
1517
|
|
|
1563
1518
|
// src/message-stream/sanitize.ts
|
|
1564
|
-
var sanitizeMessageText = (value, options = {}) => value.replaceAll(
|
|
1519
|
+
var sanitizeMessageText = (value, options = {}) => value.replaceAll(_chunkOVRDJMZJcjs.MARKER, _nullishCoalesce(options.markerReplacement, () => ( "\u25AA")));
|
|
1565
1520
|
|
|
1566
1521
|
// src/index.ts
|
|
1567
1522
|
var utils = {
|
|
1568
|
-
toValidObjectName:
|
|
1569
|
-
toValidFunctionName:
|
|
1570
|
-
wrapContent:
|
|
1571
|
-
truncateWrappedContent:
|
|
1572
|
-
stripTruncationTags:
|
|
1523
|
+
toValidObjectName: _chunkGOWPACSKcjs.toValidObjectName,
|
|
1524
|
+
toValidFunctionName: _chunkGOWPACSKcjs.toValidFunctionName,
|
|
1525
|
+
wrapContent: _chunkHEAQAEFZcjs.wrapContent,
|
|
1526
|
+
truncateWrappedContent: _chunkHEAQAEFZcjs.truncateWrappedContent,
|
|
1527
|
+
stripTruncationTags: _chunkHEAQAEFZcjs.stripTruncationTags
|
|
1573
1528
|
};
|
|
1574
1529
|
var execute = async (props) => {
|
|
1575
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-
|
|
1530
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-MRZZ4AYY.cjs")));
|
|
1576
1531
|
return executeContext(props);
|
|
1577
1532
|
};
|
|
1578
1533
|
var init = async () => {
|
|
1579
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-
|
|
1534
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-MRZZ4AYY.cjs")));
|
|
1580
1535
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-2NYFY6CW.cjs")));
|
|
1581
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
1582
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-
|
|
1536
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-VE2YHIY2.cjs")));
|
|
1537
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-MX56VN2C.cjs")));
|
|
1583
1538
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-ULPWX5TW.cjs")));
|
|
1584
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-
|
|
1585
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-
|
|
1586
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-
|
|
1587
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-
|
|
1588
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-
|
|
1539
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-6D3IIIU7.cjs")));
|
|
1540
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-ITB4NEL7.cjs")));
|
|
1541
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-FZNLYSDL.cjs")));
|
|
1542
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-LQOBZXSO.cjs")));
|
|
1543
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-HO6RRIZ5.cjs")));
|
|
1589
1544
|
};
|
|
1590
1545
|
|
|
1591
1546
|
|
|
@@ -1636,4 +1591,6 @@ var init = async () => {
|
|
|
1636
1591
|
|
|
1637
1592
|
|
|
1638
1593
|
|
|
1639
|
-
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
exports.BaseResponse = BaseResponse; exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkI56MPOVGcjs.Component; exports.ComponentRegistry = ComponentRegistry; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkKG5E3UZZcjs.DefaultExit; exports.ErrorExecutionResult = _chunkKG5E3UZZcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkKG5E3UZZcjs.ExecutionResult; exports.Exit = _chunkDDSJTR6Qcjs.Exit; exports.ListenExit = _chunkKG5E3UZZcjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.MARKER = _chunkOVRDJMZJcjs.MARKER; exports.NAME_REGEX = _chunkOVRDJMZJcjs.NAME_REGEX; exports.NextResponse = NextResponse; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkKG5E3UZZcjs.PartialExecutionResult; exports.ReplayableAsyncIterable = ReplayableAsyncIterable; exports.RunResponse = RunResponse; exports.SendResponse = SendResponse; exports.Snapshot = _chunkKG5E3UZZcjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.StreamingMessageParser = _chunkOVRDJMZJcjs.StreamingMessageParser; exports.SuccessExecutionResult = _chunkKG5E3UZZcjs.SuccessExecutionResult; exports.ThinkExit = _chunkKG5E3UZZcjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunkPZE6PIPGcjs.Tool; exports._CustomModelClient = _chunkKG5E3UZZcjs._CustomModelClient; exports.assertValidComponent = _chunkI56MPOVGcjs.assertValidComponent; exports.collectText = collectText; exports.configureQuickJS = _chunkRGUG3UMFcjs.configureQuickJS; exports.configureTokenizer = _chunkGOWPACSKcjs.configureTokenizer; exports.execute = execute; exports.generateInstructions = _chunkOVRDJMZJcjs.generateInstructions; exports.getValue = _chunkKG5E3UZZcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkI56MPOVGcjs.isAnyComponent; exports.isComponent = _chunkI56MPOVGcjs.isComponent; exports.normalizeComponentDefinition = normalizeComponentDefinition; exports.normalizeComponentName = normalizeComponentName; exports.normalizePropsSchema = normalizePropsSchema; exports.parseExit = _chunkKG5E3UZZcjs.parseExit; exports.parseStream = parseStream; exports.parseText = parseText; exports.sanitizeMessageText = sanitizeMessageText; exports.tryParseJson = _chunkOVRDJMZJcjs.tryParseJson; exports.utils = utils; exports.validateComponent = validateComponent; exports.validateProps = validateProps; exports.version = version;
|