llmz 0.2.0 → 0.2.2
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/{chunk-WWZ2W4WR.cjs → chunk-2EZSVF5X.cjs} +382 -492
- package/dist/{chunk-33AB6SVX.js → chunk-2MSLOTFO.js} +2 -2
- package/dist/{chunk-IRCB4FRM.js → chunk-3OSQ4XL4.js} +1 -1
- package/dist/{chunk-E5NHK3FS.js → chunk-5ISVDYBA.js} +3 -3
- package/dist/{chunk-IKLFMVSW.cjs → chunk-5XPEVOOW.cjs} +8 -8
- package/dist/{chunk-YGKQEVQQ.cjs → chunk-C2KND2PS.cjs} +3 -3
- package/dist/{chunk-DH35WO5G.js → chunk-EJIDFDQP.js} +373 -483
- package/dist/chunk-GDWRFHM5.js +792 -0
- package/dist/chunk-MHVORH33.cjs +792 -0
- package/dist/{chunk-WODK7Y4J.cjs → chunk-S46T73HR.cjs} +2 -2
- 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-ZZY6QPYT.cjs → dual-modes-IZQJTXR7.cjs} +2 -2
- package/dist/{dual-modes-RMF7V7ZQ.js → dual-modes-J4RWHJ2O.js} +1 -1
- package/dist/{execute-BXPFSEVX.cjs → execute-4IL4QPAR.cjs} +23 -23
- package/dist/{execute-HIRXXR6X.js → execute-6AYBMTRM.js} +5 -5
- package/dist/formatting.d.ts +1 -2
- package/dist/index.cjs +185 -234
- package/dist/index.js +172 -221
- 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/{tool-GJ6ZXWS2.cjs → tool-56I7OSKU.cjs} +3 -3
- package/dist/{tool-DNHVW3KC.js → tool-I3MAWDN2.js} +2 -2
- package/dist/{typings-ZTFPPA5W.cjs → typings-LVI4VGE2.cjs} +2 -2
- package/dist/{typings-3YV3RDMP.js → typings-SR3EE6LR.js} +1 -1
- package/dist/typings-formatter.d.ts +34 -0
- package/dist/typings-formatter.test.d.ts +1 -0
- package/dist/{vm-44H4UKI2.js → vm-ZLWGAYYJ.js} +1 -1
- package/dist/{vm-A3OTQVIR.cjs → vm-ZVONLAZV.cjs} +2 -2
- package/package.json +5 -14
- package/dist/chunk-7LMIOS6H.cjs +0 -287
- package/dist/chunk-TOGYDN6U.js +0 -287
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,25 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk5XPEVOOWcjs = require('./chunk-5XPEVOOW.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkC2KND2PScjs = require('./chunk-C2KND2PS.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkS46T73HRcjs = require('./chunk-S46T73HR.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var _chunkMHVORH33cjs = require('./chunk-MHVORH33.cjs');
|
|
28
32
|
|
|
29
33
|
|
|
30
34
|
|
|
@@ -58,235 +62,190 @@ var _chunkYQT5G77Wcjs = require('./chunk-YQT5G77W.cjs');
|
|
|
58
62
|
var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
|
|
59
63
|
|
|
60
64
|
|
|
61
|
-
|
|
62
65
|
var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
63
66
|
|
|
64
67
|
// package.json
|
|
65
|
-
var version = "0.2.
|
|
68
|
+
var version = "0.2.2";
|
|
66
69
|
|
|
67
70
|
// src/objects.ts
|
|
68
71
|
var _zui = require('@bpinternal/zui');
|
|
69
72
|
|
|
70
73
|
// src/hoist.ts
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
function printNodes(nodes) {
|
|
75
|
+
let out = "";
|
|
76
|
+
let afterLineComment = false;
|
|
77
|
+
const emit = (n) => {
|
|
78
|
+
const newlines = Math.min(_nullishCoalesce(n.nl, () => ( 0)), 2);
|
|
79
|
+
if (newlines > 0) {
|
|
80
|
+
out += "\n".repeat(newlines);
|
|
81
|
+
} else if (afterLineComment) {
|
|
82
|
+
out += "\n";
|
|
83
|
+
} else if (out.length && !out.endsWith("\n")) {
|
|
84
|
+
out += " ";
|
|
85
|
+
}
|
|
86
|
+
afterLineComment = false;
|
|
87
|
+
if (_chunkMHVORH33cjs.isGroup.call(void 0, n)) {
|
|
88
|
+
out += n.open;
|
|
89
|
+
for (const child of n.children) {
|
|
90
|
+
emit(child);
|
|
91
|
+
}
|
|
92
|
+
if (afterLineComment) {
|
|
93
|
+
out += "\n";
|
|
94
|
+
afterLineComment = false;
|
|
95
|
+
}
|
|
96
|
+
out += n.close;
|
|
97
|
+
} else {
|
|
98
|
+
out += n.text;
|
|
99
|
+
afterLineComment = n.kind === "line-comment";
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
for (const n of nodes) {
|
|
103
|
+
emit(n);
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
80
106
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
removeBabelComments(val);
|
|
107
|
+
function keyOf(group) {
|
|
108
|
+
const parts = [];
|
|
109
|
+
const visit = (n) => {
|
|
110
|
+
if (_chunkMHVORH33cjs.isGroup.call(void 0, n)) {
|
|
111
|
+
parts.push(n.open);
|
|
112
|
+
n.children.forEach(visit);
|
|
113
|
+
parts.push(n.close);
|
|
114
|
+
} else if (n.kind === "word" || n.kind === "string" || n.kind === "punct" && n.text !== ";" && n.text !== ",") {
|
|
115
|
+
parts.push(n.text);
|
|
91
116
|
}
|
|
92
|
-
}
|
|
117
|
+
};
|
|
118
|
+
visit(group);
|
|
119
|
+
return parts.join(" ");
|
|
93
120
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const typeString = getTypingsWithoutComments(typeNode.typeAnnotation);
|
|
100
|
-
if (!typeMap.has(typeString)) {
|
|
101
|
-
typeMap.set(typeString, typeNode);
|
|
121
|
+
var prevMeaningful = (siblings, index) => {
|
|
122
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
123
|
+
const n = siblings[i];
|
|
124
|
+
if (_chunkMHVORH33cjs.isGroup.call(void 0, n) || n.kind !== "block-comment" && n.kind !== "line-comment") {
|
|
125
|
+
return n;
|
|
102
126
|
}
|
|
103
127
|
}
|
|
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;
|
|
128
|
+
return void 0;
|
|
129
|
+
};
|
|
130
|
+
var asName = (text) => _chunkHC2QZTVTcjs.upperFirst_default.call(void 0, text.replace(/['"]/g, "").replace(/[^A-Za-z0-9_$]/g, ""));
|
|
131
|
+
function segmentsAt(siblings, index) {
|
|
132
|
+
var _a;
|
|
133
|
+
const prev = prevMeaningful(siblings, index);
|
|
134
|
+
if (!prev || _chunkMHVORH33cjs.isGroup.call(void 0, prev)) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
if (_chunkMHVORH33cjs.isPunct.call(void 0, prev, "=>")) {
|
|
138
|
+
return ["Output"];
|
|
139
|
+
}
|
|
140
|
+
if (_chunkMHVORH33cjs.isPunct.call(void 0, prev, ":") || _chunkMHVORH33cjs.isPunct.call(void 0, prev, "<")) {
|
|
141
|
+
let i = siblings.indexOf(prev) - 1;
|
|
142
|
+
while (i >= 0 && !_chunkMHVORH33cjs.isGroup.call(void 0, siblings[i]) && ((_a = siblings[i].kind) == null ? void 0 : _a.includes("comment"))) {
|
|
143
|
+
i--;
|
|
144
144
|
}
|
|
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
|
-
});
|
|
145
|
+
let q = siblings[i];
|
|
146
|
+
if (q && !_chunkMHVORH33cjs.isGroup.call(void 0, q) && q.kind === "punct" && q.text === "?") {
|
|
147
|
+
q = siblings[--i];
|
|
168
148
|
}
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
findNestedTypes(annPath);
|
|
173
|
-
}
|
|
149
|
+
if (q && _chunkMHVORH33cjs.isGroup.call(void 0, q) && q.open === "(") {
|
|
150
|
+
const fnWord = prevMeaningful(siblings, i);
|
|
151
|
+
return fnWord && !_chunkMHVORH33cjs.isGroup.call(void 0, fnWord) && fnWord.kind === "word" ? [asName(fnWord.text), "Output"] : ["Output"];
|
|
174
152
|
}
|
|
175
|
-
if (
|
|
176
|
-
|
|
153
|
+
if (q && !_chunkMHVORH33cjs.isGroup.call(void 0, q) && (q.kind === "word" || q.kind === "string")) {
|
|
154
|
+
return [asName(q.text)];
|
|
177
155
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
156
|
+
}
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
function walkLiterals(siblings, path, visit) {
|
|
160
|
+
var _a;
|
|
161
|
+
for (let i = 0; i < siblings.length; i++) {
|
|
162
|
+
const node = siblings[i];
|
|
163
|
+
if (!_chunkMHVORH33cjs.isGroup.call(void 0, node)) {
|
|
164
|
+
continue;
|
|
181
165
|
}
|
|
182
|
-
if (
|
|
183
|
-
;
|
|
184
|
-
|
|
166
|
+
if (node.open === "(") {
|
|
167
|
+
const fnWord = prevMeaningful(siblings, i);
|
|
168
|
+
const fnName = fnWord && !_chunkMHVORH33cjs.isGroup.call(void 0, fnWord) && fnWord.kind === "word" ? [asName(fnWord.text)] : [];
|
|
169
|
+
walkLiterals(node.children, [...path, ...fnName], visit);
|
|
170
|
+
continue;
|
|
185
171
|
}
|
|
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
|
-
});
|
|
172
|
+
if (node.open === "<" || node.open === "[") {
|
|
173
|
+
walkLiterals(node.children, [...path, ...segmentsAt(siblings, i)], visit);
|
|
174
|
+
continue;
|
|
196
175
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
176
|
+
const prev = prevMeaningful(siblings, i);
|
|
177
|
+
if (prev && _chunkMHVORH33cjs.isPunct.call(void 0, prev, "=")) {
|
|
178
|
+
const eqIdx = siblings.indexOf(prev);
|
|
179
|
+
const nameTok = siblings[eqIdx - 1];
|
|
180
|
+
const typeTok = siblings[eqIdx - 2];
|
|
181
|
+
const isAlias = nameTok && typeTok && !_chunkMHVORH33cjs.isGroup.call(void 0, nameTok) && !_chunkMHVORH33cjs.isGroup.call(void 0, typeTok) && nameTok.kind === "word" && typeTok.kind === "word" && typeTok.text === "type";
|
|
182
|
+
if (!isAlias) {
|
|
183
|
+
continue;
|
|
201
184
|
}
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
185
|
+
const aliasName = nameTok.text;
|
|
186
|
+
visit({ siblings, index: i, group: node, path: [aliasName], aliasName });
|
|
187
|
+
if (siblings[i] === node) {
|
|
188
|
+
walkLiterals(node.children, [aliasName], visit);
|
|
189
|
+
}
|
|
190
|
+
continue;
|
|
208
191
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
findNestedTypes(returnType);
|
|
192
|
+
const prevIsNamespace = prev && !_chunkMHVORH33cjs.isGroup.call(void 0, prev) && prev.kind === "word" && ((_a = prevMeaningful(siblings, siblings.indexOf(prev))) == null ? void 0 : _a.kind) === "word";
|
|
193
|
+
const namespaceLike = prevIsNamespace && ["namespace", "module"].includes(prevMeaningful(siblings, siblings.indexOf(prev)).text);
|
|
194
|
+
const segments = segmentsAt(siblings, i);
|
|
195
|
+
const newPath = [...path, ...segments];
|
|
196
|
+
if (!namespaceLike) {
|
|
197
|
+
visit({ siblings, index: i, group: node, path: newPath });
|
|
198
|
+
}
|
|
199
|
+
if (siblings[i] === node) {
|
|
200
|
+
walkLiterals(node.children, namespaceLike ? [...path, asName(prev.text)] : newPath, visit);
|
|
219
201
|
}
|
|
220
202
|
}
|
|
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);
|
|
203
|
+
}
|
|
204
|
+
function extractAndHoistTypes(code) {
|
|
205
|
+
const top = _chunkMHVORH33cjs.parse.call(void 0, _chunkMHVORH33cjs.tokenize.call(void 0, code));
|
|
206
|
+
const counts = /* @__PURE__ */ new Map();
|
|
207
|
+
const aliasByKey = /* @__PURE__ */ new Map();
|
|
208
|
+
const usedNames = /* @__PURE__ */ new Set();
|
|
209
|
+
walkLiterals(top, [], ({ group, path, aliasName }) => {
|
|
210
|
+
const key = keyOf(group);
|
|
211
|
+
counts.set(key, (_nullishCoalesce(counts.get(key), () => ( 0))) + 1);
|
|
212
|
+
if (aliasName && !aliasByKey.has(key)) {
|
|
213
|
+
aliasByKey.set(key, aliasName);
|
|
214
|
+
}
|
|
215
|
+
for (const segment of path) {
|
|
216
|
+
usedNames.add(segment);
|
|
217
|
+
}
|
|
218
|
+
if (aliasName) {
|
|
219
|
+
usedNames.add(aliasName);
|
|
272
220
|
}
|
|
273
221
|
});
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
hoistedTypes.push(typeNode);
|
|
280
|
-
}
|
|
222
|
+
const uniqueName = (base) => {
|
|
223
|
+
let name = base;
|
|
224
|
+
let counter = 1;
|
|
225
|
+
while (usedNames.has(name)) {
|
|
226
|
+
name = `${base}${counter++}`;
|
|
281
227
|
}
|
|
228
|
+
usedNames.add(name);
|
|
229
|
+
return name;
|
|
230
|
+
};
|
|
231
|
+
const newAliases = [];
|
|
232
|
+
walkLiterals(top, [], ({ siblings, index, group, aliasName, path }) => {
|
|
233
|
+
const key = keyOf(group);
|
|
234
|
+
if ((_nullishCoalesce(counts.get(key), () => ( 0))) < 2 || aliasName) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
let name = aliasByKey.get(key);
|
|
238
|
+
if (!name) {
|
|
239
|
+
const deduped = [...new Set(path)];
|
|
240
|
+
name = uniqueName(deduped.length ? deduped.join("") : "UnnamedType");
|
|
241
|
+
aliasByKey.set(key, name);
|
|
242
|
+
newAliases.push(`type ${name} = ${printNodes([{ ...group, nl: 0 }])}`);
|
|
243
|
+
}
|
|
244
|
+
siblings[index] = { kind: "word", text: name, nl: group.nl };
|
|
282
245
|
});
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
(node) => !hoistedTypes.some((ht) => t.isTSTypeAliasDeclaration(node) && node.id.name === ht.id.name)
|
|
287
|
-
)
|
|
288
|
-
];
|
|
289
|
-
return ast;
|
|
246
|
+
const body = printNodes(top);
|
|
247
|
+
return newAliases.length ? `${newAliases.join("\n")}
|
|
248
|
+
${body}` : body;
|
|
290
249
|
}
|
|
291
250
|
async function hoistTypings(code, formatOptions) {
|
|
292
251
|
formatOptions ??= {};
|
|
@@ -294,15 +253,7 @@ async function hoistTypings(code, formatOptions) {
|
|
|
294
253
|
for (let i = 1; i <= 5; i++) {
|
|
295
254
|
try {
|
|
296
255
|
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;
|
|
256
|
+
code = extractAndHoistTypes(code);
|
|
306
257
|
if (initialCode === code) {
|
|
307
258
|
break;
|
|
308
259
|
}
|
|
@@ -314,7 +265,7 @@ async function hoistTypings(code, formatOptions) {
|
|
|
314
265
|
break;
|
|
315
266
|
}
|
|
316
267
|
}
|
|
317
|
-
return
|
|
268
|
+
return _chunkMHVORH33cjs.formatTypings.call(void 0, code, formatOptions);
|
|
318
269
|
}
|
|
319
270
|
|
|
320
271
|
// src/objects.ts
|
|
@@ -440,7 +391,7 @@ var ObjectInstance = class {
|
|
|
440
391
|
this.description = props.description;
|
|
441
392
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
442
393
|
this.properties = props.properties;
|
|
443
|
-
this.tools =
|
|
394
|
+
this.tools = _chunkS46T73HRcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
444
395
|
}
|
|
445
396
|
/**
|
|
446
397
|
* Generates TypeScript namespace declarations for this object.
|
|
@@ -521,7 +472,7 @@ function getObjectTypings(obj) {
|
|
|
521
472
|
}
|
|
522
473
|
let type = "unknown";
|
|
523
474
|
if (prop.type) {
|
|
524
|
-
type = await
|
|
475
|
+
type = await _chunkMHVORH33cjs.getTypings.call(void 0, prop.type, {});
|
|
525
476
|
} else if (prop.value !== void 0) {
|
|
526
477
|
type = typeof prop.value;
|
|
527
478
|
}
|
|
@@ -541,7 +492,7 @@ function getObjectTypings(obj) {
|
|
|
541
492
|
typings.push("");
|
|
542
493
|
for (const tool of obj.tools) {
|
|
543
494
|
const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
|
|
544
|
-
let temp = await
|
|
495
|
+
let temp = await _chunkMHVORH33cjs.getTypings.call(void 0, fnType, {
|
|
545
496
|
declaration: true
|
|
546
497
|
});
|
|
547
498
|
temp = temp.replace("declare function ", "function ");
|
|
@@ -564,7 +515,7 @@ function getObjectTypings(obj) {
|
|
|
564
515
|
if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
|
|
565
516
|
header = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, obj.description);
|
|
566
517
|
}
|
|
567
|
-
return
|
|
518
|
+
return _chunkMHVORH33cjs.formatTypings.call(void 0,
|
|
568
519
|
`${header}
|
|
569
520
|
export namespace ${obj.name} {
|
|
570
521
|
${body}
|
|
@@ -1212,7 +1163,7 @@ var SendResponse = class extends BaseResponse {
|
|
|
1212
1163
|
return this.item.props;
|
|
1213
1164
|
}
|
|
1214
1165
|
static formatToText(component, props, body) {
|
|
1215
|
-
const header = `${
|
|
1166
|
+
const header = `${_chunkC2KND2PScjs.MARKER}send=${component}${props && Object.keys(props).length ? ` ${JSON.stringify(props)}` : ""}`;
|
|
1216
1167
|
return body ? `${header}
|
|
1217
1168
|
${body}` : header;
|
|
1218
1169
|
}
|
|
@@ -1223,7 +1174,7 @@ var RunResponse = class extends BaseResponse {
|
|
|
1223
1174
|
this.code = code;
|
|
1224
1175
|
}
|
|
1225
1176
|
static formatToText(code) {
|
|
1226
|
-
return `${
|
|
1177
|
+
return `${_chunkC2KND2PScjs.MARKER}run
|
|
1227
1178
|
${code}`;
|
|
1228
1179
|
}
|
|
1229
1180
|
};
|
|
@@ -1238,7 +1189,7 @@ var NextResponse = class extends BaseResponse {
|
|
|
1238
1189
|
return this.item.props;
|
|
1239
1190
|
}
|
|
1240
1191
|
static formatToText(name, props) {
|
|
1241
|
-
return `${
|
|
1192
|
+
return `${_chunkC2KND2PScjs.MARKER}next=${name}${props && Object.keys(props).length ? ` ${JSON.stringify(props)}` : ""}`;
|
|
1242
1193
|
}
|
|
1243
1194
|
};
|
|
1244
1195
|
var EventPump = (_class3 = class {
|
|
@@ -1295,7 +1246,7 @@ function parseText(text, options) {
|
|
|
1295
1246
|
);
|
|
1296
1247
|
}
|
|
1297
1248
|
async function* parseResponses(stream, options) {
|
|
1298
|
-
const parser = new (0,
|
|
1249
|
+
const parser = new (0, _chunkC2KND2PScjs.StreamingMessageParser)(options);
|
|
1299
1250
|
const pump = new EventPump(stream, parser);
|
|
1300
1251
|
let activeBody;
|
|
1301
1252
|
while (true) {
|
|
@@ -1352,7 +1303,7 @@ var ComponentRegistry = (_class4 = class {
|
|
|
1352
1303
|
}
|
|
1353
1304
|
}
|
|
1354
1305
|
register(definition) {
|
|
1355
|
-
if (!
|
|
1306
|
+
if (!_chunkC2KND2PScjs.NAME_REGEX.test(definition.name)) {
|
|
1356
1307
|
throw new Error(
|
|
1357
1308
|
`Invalid component name "${definition.name}". Component names must be lowercase ([a-z][a-z0-9_-]*).`
|
|
1358
1309
|
);
|
|
@@ -1379,7 +1330,7 @@ var EMPTY_PROPS_SCHEMA = { type: "object", properties: {}, additionalProperties:
|
|
|
1379
1330
|
var normalizeComponentName = (name) => name.trim().toLowerCase();
|
|
1380
1331
|
function normalizeComponentDefinition(definition) {
|
|
1381
1332
|
const name = normalizeComponentName(_nullishCoalesce(definition.name, () => ( "")));
|
|
1382
|
-
if (!
|
|
1333
|
+
if (!_chunkC2KND2PScjs.NAME_REGEX.test(name)) {
|
|
1383
1334
|
throw new Error(
|
|
1384
1335
|
`Invalid component name "${definition.name}". Component names must be lowercase ([a-z][a-z0-9_-]*).`
|
|
1385
1336
|
);
|
|
@@ -1561,7 +1512,7 @@ var _checkValue = (value, schema, path, errors) => {
|
|
|
1561
1512
|
};
|
|
1562
1513
|
|
|
1563
1514
|
// src/message-stream/sanitize.ts
|
|
1564
|
-
var sanitizeMessageText = (value, options = {}) => value.replaceAll(
|
|
1515
|
+
var sanitizeMessageText = (value, options = {}) => value.replaceAll(_chunkC2KND2PScjs.MARKER, _nullishCoalesce(options.markerReplacement, () => ( "\u25AA")));
|
|
1565
1516
|
|
|
1566
1517
|
// src/index.ts
|
|
1567
1518
|
var utils = {
|
|
@@ -1572,20 +1523,20 @@ var utils = {
|
|
|
1572
1523
|
stripTruncationTags: _chunkYQT5G77Wcjs.stripTruncationTags
|
|
1573
1524
|
};
|
|
1574
1525
|
var execute = async (props) => {
|
|
1575
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-
|
|
1526
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-4IL4QPAR.cjs")));
|
|
1576
1527
|
return executeContext(props);
|
|
1577
1528
|
};
|
|
1578
1529
|
var init = async () => {
|
|
1579
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-
|
|
1530
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./execute-4IL4QPAR.cjs")));
|
|
1580
1531
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-2NYFY6CW.cjs")));
|
|
1581
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
1532
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-56I7OSKU.cjs")));
|
|
1582
1533
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-LUJY7JIG.cjs")));
|
|
1583
1534
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-ULPWX5TW.cjs")));
|
|
1584
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-
|
|
1535
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-ZVONLAZV.cjs")));
|
|
1585
1536
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-GLZVMRWO.cjs")));
|
|
1586
1537
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-7PGEGCHV.cjs")));
|
|
1587
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-
|
|
1588
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-
|
|
1538
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-LVI4VGE2.cjs")));
|
|
1539
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-IZQJTXR7.cjs")));
|
|
1589
1540
|
};
|
|
1590
1541
|
|
|
1591
1542
|
|
|
@@ -1636,4 +1587,4 @@ var init = async () => {
|
|
|
1636
1587
|
|
|
1637
1588
|
|
|
1638
1589
|
|
|
1639
|
-
exports.BaseResponse = BaseResponse; exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkI56MPOVGcjs.Component; exports.ComponentRegistry = ComponentRegistry; exports.DefaultComponents = DefaultComponents; exports.DefaultExit =
|
|
1590
|
+
exports.BaseResponse = BaseResponse; exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkI56MPOVGcjs.Component; exports.ComponentRegistry = ComponentRegistry; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunk5XPEVOOWcjs.DefaultExit; exports.ErrorExecutionResult = _chunk5XPEVOOWcjs.ErrorExecutionResult; exports.ExecutionResult = _chunk5XPEVOOWcjs.ExecutionResult; exports.Exit = _chunkD6PU5YAScjs.Exit; exports.ListenExit = _chunk5XPEVOOWcjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.MARKER = _chunkC2KND2PScjs.MARKER; exports.NAME_REGEX = _chunkC2KND2PScjs.NAME_REGEX; exports.NextResponse = NextResponse; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunk5XPEVOOWcjs.PartialExecutionResult; exports.ReplayableAsyncIterable = ReplayableAsyncIterable; exports.RunResponse = RunResponse; exports.SendResponse = SendResponse; exports.Snapshot = _chunk5XPEVOOWcjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.StreamingMessageParser = _chunkC2KND2PScjs.StreamingMessageParser; exports.SuccessExecutionResult = _chunk5XPEVOOWcjs.SuccessExecutionResult; exports.ThinkExit = _chunk5XPEVOOWcjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunkS46T73HRcjs.Tool; exports._CustomModelClient = _chunk5XPEVOOWcjs._CustomModelClient; exports.assertValidComponent = _chunkI56MPOVGcjs.assertValidComponent; exports.collectText = collectText; exports.execute = execute; exports.generateInstructions = _chunkC2KND2PScjs.generateInstructions; exports.getValue = _chunk5XPEVOOWcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkI56MPOVGcjs.isAnyComponent; exports.isComponent = _chunkI56MPOVGcjs.isComponent; exports.normalizeComponentDefinition = normalizeComponentDefinition; exports.normalizeComponentName = normalizeComponentName; exports.normalizePropsSchema = normalizePropsSchema; exports.parseExit = _chunk5XPEVOOWcjs.parseExit; exports.parseStream = parseStream; exports.parseText = parseText; exports.sanitizeMessageText = sanitizeMessageText; exports.tryParseJson = _chunkC2KND2PScjs.tryParseJson; exports.utils = utils; exports.validateComponent = validateComponent; exports.validateProps = validateProps; exports.version = version;
|