llmz 0.0.6 → 0.0.7
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/README.md +0 -4
- package/package.json +5 -3
- package/dist/chat.d.ts +0 -17
- package/dist/chunk-4I7UPBLN.cjs +0 -104
- package/dist/chunk-4QTK5ALH.cjs +0 -211
- package/dist/chunk-5TRUJES5.js +0 -220
- package/dist/chunk-6WT5VZBG.cjs +0 -755
- package/dist/chunk-7WRN4E42.js +0 -3087
- package/dist/chunk-BEPRLBPK.cjs +0 -3123
- package/dist/chunk-CH5T6SPC.cjs +0 -694
- package/dist/chunk-D3ESDRLH.js +0 -3123
- package/dist/chunk-EJRCDWBA.cjs +0 -153
- package/dist/chunk-FIVFS4HG.cjs +0 -152
- package/dist/chunk-HP7RKM25.js +0 -153
- package/dist/chunk-HYVKY3W6.cjs +0 -283
- package/dist/chunk-IKSIOIIP.cjs +0 -28
- package/dist/chunk-JDABP4SD.cjs +0 -161
- package/dist/chunk-JKVVQN2P.js +0 -161
- package/dist/chunk-JQBT7UWN.js +0 -28
- package/dist/chunk-KMZDFWYZ.cjs +0 -33
- package/dist/chunk-ORQP26SZ.js +0 -33
- package/dist/chunk-P7J2WCBB.cjs +0 -220
- package/dist/chunk-QBXIE6EY.js +0 -211
- package/dist/chunk-QT4QF3YA.js +0 -152
- package/dist/chunk-S6FOL2HY.js +0 -104
- package/dist/chunk-UNMKB2DA.js +0 -283
- package/dist/chunk-UQOBUJIQ.cjs +0 -3087
- package/dist/chunk-WLUVY5QU.js +0 -755
- package/dist/chunk-XJNRORSK.js +0 -694
- package/dist/citations.d.ts +0 -63
- package/dist/compiler/compiler.d.ts +0 -28
- package/dist/compiler/index.d.ts +0 -2
- package/dist/compiler/plugins/async-iterator.d.ts +0 -4
- package/dist/compiler/plugins/braces-tsx.d.ts +0 -3
- package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +0 -5
- package/dist/compiler/plugins/line-tracking.d.ts +0 -5
- package/dist/compiler/plugins/replace-comment.d.ts +0 -5
- package/dist/compiler/plugins/return-async.d.ts +0 -4
- package/dist/compiler/plugins/track-tool-calls.d.ts +0 -16
- package/dist/compiler/plugins/variable-extraction.d.ts +0 -5
- package/dist/component-R2Y74VUI.js +0 -16
- package/dist/component-TSNW3SC7.cjs +0 -16
- package/dist/component.d.ts +0 -60
- package/dist/component.default.d.ts +0 -316
- package/dist/context.d.ts +0 -177
- package/dist/dual-modes-UHNDHNIF.cjs +0 -12
- package/dist/dual-modes-ZUQKPJFH.js +0 -12
- package/dist/errors.d.ts +0 -64
- package/dist/exit-KJ4COC5N.cjs +0 -8
- package/dist/exit-OIYZLBVJ.js +0 -8
- package/dist/exit.d.ts +0 -26
- package/dist/formatting.d.ts +0 -5
- package/dist/getter.d.ts +0 -2
- package/dist/handlers.d.ts +0 -10
- package/dist/hoist.d.ts +0 -2
- package/dist/index.cjs +0 -919
- package/dist/index.d.ts +0 -22
- package/dist/index.js +0 -919
- package/dist/inspect.d.ts +0 -6
- package/dist/jsx-AEHVFB3L.js +0 -13
- package/dist/jsx-AJAXBWFE.cjs +0 -13
- package/dist/jsx.d.ts +0 -11
- package/dist/llmz-CPMVYIOJ.cjs +0 -581
- package/dist/llmz-LAN4WDFW.js +0 -581
- package/dist/llmz.d.ts +0 -40
- package/dist/objects.d.ts +0 -24
- package/dist/openai.d.ts +0 -8
- package/dist/prompts/chat-mode/system.md.d.ts +0 -2
- package/dist/prompts/chat-mode/user.md.d.ts +0 -2
- package/dist/prompts/common.d.ts +0 -6
- package/dist/prompts/dual-modes.d.ts +0 -2
- package/dist/prompts/prompt.d.ts +0 -50
- package/dist/prompts/worker-mode/system.md.d.ts +0 -2
- package/dist/prompts/worker-mode/user.md.d.ts +0 -2
- package/dist/result.d.ts +0 -33
- package/dist/snapshots.d.ts +0 -69
- package/dist/stack-traces.d.ts +0 -1
- package/dist/tool-LY77IWV2.js +0 -11
- package/dist/tool-SWJYOR2Z.cjs +0 -11
- package/dist/tool.d.ts +0 -55
- package/dist/transcript.d.ts +0 -9
- package/dist/truncator-NYN7BGKJ.cjs +0 -10
- package/dist/truncator-WAL2GCUY.js +0 -10
- package/dist/truncator.d.ts +0 -21
- package/dist/types.d.ts +0 -105
- package/dist/typings-AIV2OASX.js +0 -10
- package/dist/typings-XR6CYHW4.cjs +0 -10
- package/dist/typings.d.ts +0 -5
- package/dist/utils-L5GLCS3C.js +0 -37
- package/dist/utils-QC4I2L6R.cjs +0 -37
- package/dist/utils.d.ts +0 -21
- package/dist/vm-2DLG7V4G.cjs +0 -12
- package/dist/vm-FLBMZUA2.js +0 -12
- package/dist/vm.d.ts +0 -3
package/dist/chunk-HYVKY3W6.cjs
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
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
|
-
|
|
3
|
-
var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkP7J2WCBBcjs = require('./chunk-P7J2WCBB.cjs');
|
|
9
|
-
|
|
10
|
-
// src/typings.ts
|
|
11
|
-
var _zui = require('@bpinternal/zui');
|
|
12
|
-
|
|
13
|
-
// src/formatting.ts
|
|
14
|
-
var _lrucache = require('lru-cache');
|
|
15
|
-
var _babel = require('prettier/plugins/babel'); var _babel2 = _interopRequireDefault(_babel);
|
|
16
|
-
var _estree = require('prettier/plugins/estree'); var _estree2 = _interopRequireDefault(_estree);
|
|
17
|
-
var _typescript = require('prettier/plugins/typescript'); var _typescript2 = _interopRequireDefault(_typescript);
|
|
18
|
-
var _standalone = require('prettier/standalone');
|
|
19
|
-
var cache = new (0, _lrucache.LRUCache)({ max: 1e3 });
|
|
20
|
-
async function formatTypings(typings, options) {
|
|
21
|
-
if (cache.has(typings)) {
|
|
22
|
-
return cache.get(typings);
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
options ??= {};
|
|
26
|
-
options.throwOnError ??= true;
|
|
27
|
-
const result = (await _standalone.format.call(void 0, typings, {
|
|
28
|
-
singleAttributePerLine: true,
|
|
29
|
-
bracketSameLine: true,
|
|
30
|
-
semi: false,
|
|
31
|
-
...options,
|
|
32
|
-
embeddedLanguageFormatting: "off",
|
|
33
|
-
plugins: [_estree2.default, _babel2.default, _typescript2.default],
|
|
34
|
-
parser: "typescript",
|
|
35
|
-
filepath: "tools.d.ts"
|
|
36
|
-
})).trim();
|
|
37
|
-
cache.set(typings, result);
|
|
38
|
-
return result;
|
|
39
|
-
} catch (err) {
|
|
40
|
-
if (options == null ? void 0 : options.throwOnError) {
|
|
41
|
-
throw new (0, _chunkJDABP4SDcjs.CodeFormattingError)(err instanceof Error ? err.message : _nullishCoalesce((err == null ? void 0 : err.toString()), () => ( "Unknown Error")), typings);
|
|
42
|
-
}
|
|
43
|
-
return typings;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/typings.ts
|
|
48
|
-
var Primitives = [
|
|
49
|
-
"string",
|
|
50
|
-
"number",
|
|
51
|
-
"boolean",
|
|
52
|
-
"unknown",
|
|
53
|
-
"void",
|
|
54
|
-
"any",
|
|
55
|
-
"null",
|
|
56
|
-
"undefined",
|
|
57
|
-
"never",
|
|
58
|
-
"bigint",
|
|
59
|
-
"symbol",
|
|
60
|
-
"object"
|
|
61
|
-
];
|
|
62
|
-
var LARGE_DECLARATION_LINES = 5;
|
|
63
|
-
var isPrimitive = (type) => Primitives.includes(type);
|
|
64
|
-
var isArrayOfPrimitives = (type) => Primitives.map((p) => `${p}[]`).includes(type);
|
|
65
|
-
var stripSpaces = (typings) => typings.replace(/ +/g, " ").trim();
|
|
66
|
-
var KeyValue = class {
|
|
67
|
-
constructor(key, value) {
|
|
68
|
-
this.key = key;
|
|
69
|
-
this.value = value;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var FnParameters = class {
|
|
73
|
-
constructor(schema) {
|
|
74
|
-
this.schema = schema;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var FnReturn = class {
|
|
78
|
-
constructor(schema) {
|
|
79
|
-
this.schema = schema;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var Declaration = class {
|
|
83
|
-
constructor(schema, identifier) {
|
|
84
|
-
this.schema = schema;
|
|
85
|
-
this.identifier = identifier;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
async function getTypings(schema, options) {
|
|
89
|
-
options ??= {};
|
|
90
|
-
options.declaration ??= false;
|
|
91
|
-
let wrappedSchema = schema;
|
|
92
|
-
if ((options == null ? void 0 : options.declaration) && schema instanceof _zui.z.Schema) {
|
|
93
|
-
const title = "title" in schema.ui ? schema.ui.title : null;
|
|
94
|
-
if (!title) {
|
|
95
|
-
throw new Error('Only schemas with "title" Zui property can be declared.');
|
|
96
|
-
}
|
|
97
|
-
wrappedSchema = new Declaration(schema, title);
|
|
98
|
-
}
|
|
99
|
-
let dts = await sUnwrapZodRecursive(wrappedSchema, { ...options });
|
|
100
|
-
dts = await formatTypings(dts, { throwOnError: false });
|
|
101
|
-
return dts;
|
|
102
|
-
}
|
|
103
|
-
async function sUnwrapZodRecursive(schema, options) {
|
|
104
|
-
return sUnwrapZod(schema, options);
|
|
105
|
-
}
|
|
106
|
-
async function sUnwrapZod(schema, options) {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
const newOptions = {
|
|
109
|
-
...options,
|
|
110
|
-
declaration: false,
|
|
111
|
-
parent: schema
|
|
112
|
-
};
|
|
113
|
-
if (schema instanceof Declaration) {
|
|
114
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema.schema.description);
|
|
115
|
-
const withoutDesc = schema.schema.describe("");
|
|
116
|
-
const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
|
|
117
|
-
const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
|
|
118
|
-
const closingTag = isLargeDeclaration ? `// end of ${schema.identifier}` : "";
|
|
119
|
-
if (schema.schema instanceof _zui.z.ZodFunction) {
|
|
120
|
-
return stripSpaces(`${description}
|
|
121
|
-
declare function ${schema.identifier}${typings};${closingTag}`);
|
|
122
|
-
}
|
|
123
|
-
return stripSpaces(`${description}
|
|
124
|
-
declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
125
|
-
}
|
|
126
|
-
if (schema instanceof KeyValue) {
|
|
127
|
-
if (schema.value instanceof _zui.z.ZodOptional) {
|
|
128
|
-
let innerType = schema.value._def.innerType;
|
|
129
|
-
if (innerType instanceof _zui.z.Schema && !innerType.description && schema.value.description) {
|
|
130
|
-
innerType = innerType == null ? void 0 : innerType.describe(schema.value.description);
|
|
131
|
-
}
|
|
132
|
-
const optionalToken = schema.key.endsWith("?") ? "" : "?";
|
|
133
|
-
return sUnwrapZodRecursive(new KeyValue(schema.key + optionalToken, innerType), newOptions);
|
|
134
|
-
}
|
|
135
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema.value._def.description || schema.value.description);
|
|
136
|
-
const delimiter = (description == null ? void 0 : description.trim().length) > 0 ? "\n" : "";
|
|
137
|
-
const withoutDesc = schema.value.describe("");
|
|
138
|
-
return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
|
|
139
|
-
}
|
|
140
|
-
if (schema instanceof FnParameters) {
|
|
141
|
-
if (schema.schema instanceof _zui.z.ZodTuple) {
|
|
142
|
-
let args = "";
|
|
143
|
-
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
144
|
-
const argName = _nullishCoalesce(((_b = (_a = schema.schema.items[i]) == null ? void 0 : _a.ui) == null ? void 0 : _b.title), () => ( `arg${i}`));
|
|
145
|
-
const item = schema.schema.items[i];
|
|
146
|
-
args += `${await sUnwrapZodRecursive(new KeyValue(_chunkP7J2WCBBcjs.toPropertyKey.call(void 0, argName), item), newOptions)}, `;
|
|
147
|
-
}
|
|
148
|
-
return args;
|
|
149
|
-
}
|
|
150
|
-
const isLiteral = schema.schema.naked() instanceof _zui.z.ZodLiteral;
|
|
151
|
-
const typings = (await sUnwrapZodRecursive(schema.schema, newOptions)).trim();
|
|
152
|
-
const startsWithPairs = typings.startsWith("{") && typings.endsWith("}") || typings.startsWith("[") && typings.endsWith("]") || typings.startsWith("(") && typings.endsWith(")") || typings.startsWith("Array<") && typings.endsWith(">") || typings.startsWith("Record<") && typings.endsWith(">") || isArrayOfPrimitives(typings);
|
|
153
|
-
if (startsWithPairs || isLiteral) {
|
|
154
|
-
return `args: ${typings}`;
|
|
155
|
-
} else {
|
|
156
|
-
return typings;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (schema instanceof FnReturn) {
|
|
160
|
-
if (schema.schema instanceof _zui.z.ZodOptional) {
|
|
161
|
-
return `${await sUnwrapZodRecursive(schema.schema.unwrap(), newOptions)} | undefined`;
|
|
162
|
-
}
|
|
163
|
-
return sUnwrapZodRecursive(schema.schema, newOptions);
|
|
164
|
-
}
|
|
165
|
-
if (schema instanceof _zui.z.ZodDefault) {
|
|
166
|
-
return sUnwrapZodRecursive(schema._def.innerType, options);
|
|
167
|
-
}
|
|
168
|
-
if (schema instanceof _zui.z.ZodVoid) {
|
|
169
|
-
return "void";
|
|
170
|
-
}
|
|
171
|
-
if (schema instanceof _zui.z.ZodUnknown) {
|
|
172
|
-
return "unknown";
|
|
173
|
-
}
|
|
174
|
-
if (schema instanceof _zui.z.ZodAny) {
|
|
175
|
-
return "any";
|
|
176
|
-
}
|
|
177
|
-
if (schema instanceof _zui.z.ZodPromise) {
|
|
178
|
-
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
179
|
-
}
|
|
180
|
-
if (schema instanceof _zui.z.ZodFunction) {
|
|
181
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
182
|
-
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
183
|
-
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
184
|
-
if (options == null ? void 0 : options.declaration) {
|
|
185
|
-
return `${description}
|
|
186
|
-
(${input}): ${output}`;
|
|
187
|
-
}
|
|
188
|
-
return `${description}
|
|
189
|
-
(${input}) => ${output}`;
|
|
190
|
-
}
|
|
191
|
-
if (schema instanceof _zui.z.ZodArray) {
|
|
192
|
-
const item = await sUnwrapZodRecursive(schema._def.type, newOptions);
|
|
193
|
-
if (isPrimitive(item)) {
|
|
194
|
-
return `${item}[]`;
|
|
195
|
-
}
|
|
196
|
-
return `Array<${item}>`;
|
|
197
|
-
}
|
|
198
|
-
if (schema instanceof _zui.z.ZodEnum) {
|
|
199
|
-
const values = schema._def.values.map(_chunkP7J2WCBBcjs.escapeString);
|
|
200
|
-
return values.join(" | ");
|
|
201
|
-
}
|
|
202
|
-
if (schema instanceof _zui.z.ZodTuple) {
|
|
203
|
-
if (schema.items.length === 0) {
|
|
204
|
-
return "[]";
|
|
205
|
-
}
|
|
206
|
-
const items = await Promise.all(schema.items.map((i) => sUnwrapZodRecursive(i, newOptions)));
|
|
207
|
-
return `[${items.join(", ")}]`;
|
|
208
|
-
}
|
|
209
|
-
if (schema instanceof _zui.z.ZodNullable) {
|
|
210
|
-
return `${await sUnwrapZodRecursive(schema.unwrap(), options)} | null`;
|
|
211
|
-
}
|
|
212
|
-
if (schema instanceof _zui.z.ZodOptional) {
|
|
213
|
-
if ((options == null ? void 0 : options.declaration) || (options == null ? void 0 : options.parent) instanceof _zui.z.ZodRecord) {
|
|
214
|
-
return `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)} | undefined`;
|
|
215
|
-
}
|
|
216
|
-
const optionalToken = options.parent instanceof KeyValue ? "| undefined" : "";
|
|
217
|
-
const val = `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)}${optionalToken}`;
|
|
218
|
-
return val;
|
|
219
|
-
}
|
|
220
|
-
if (schema instanceof _zui.z.ZodObject) {
|
|
221
|
-
const props = await Promise.all(
|
|
222
|
-
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
223
|
-
if (value instanceof _zui.z.Schema) {
|
|
224
|
-
return sUnwrapZodRecursive(new KeyValue(_chunkP7J2WCBBcjs.toPropertyKey.call(void 0, key), value), newOptions);
|
|
225
|
-
}
|
|
226
|
-
return `${key}: unknown`;
|
|
227
|
-
})
|
|
228
|
-
);
|
|
229
|
-
return `{ ${props.join("; ")} }`;
|
|
230
|
-
}
|
|
231
|
-
if (schema instanceof _zui.z.ZodString) {
|
|
232
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
233
|
-
return `${description} string`.trim();
|
|
234
|
-
}
|
|
235
|
-
if (schema instanceof _zui.z.ZodUnion) {
|
|
236
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
237
|
-
const options2 = await Promise.all(
|
|
238
|
-
schema.options.map(async (option) => {
|
|
239
|
-
return sUnwrapZodRecursive(option, newOptions);
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
return `${description}
|
|
243
|
-
${options2.join(" | ")}`;
|
|
244
|
-
}
|
|
245
|
-
if (schema instanceof _zui.z.ZodLiteral) {
|
|
246
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
247
|
-
return `${description}
|
|
248
|
-
${typeof schema.value === "string" ? _chunkP7J2WCBBcjs.escapeString.call(void 0, schema.value) : schema.value}`.trim();
|
|
249
|
-
}
|
|
250
|
-
if (schema instanceof _zui.z.ZodNumber) {
|
|
251
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
252
|
-
return `${description} number`.trim();
|
|
253
|
-
}
|
|
254
|
-
if (schema instanceof _zui.z.ZodBoolean) {
|
|
255
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
256
|
-
return `${description} boolean`.trim();
|
|
257
|
-
}
|
|
258
|
-
if (schema instanceof _zui.z.ZodCatch) {
|
|
259
|
-
return sUnwrapZodRecursive(schema.removeCatch(), newOptions);
|
|
260
|
-
}
|
|
261
|
-
if (schema instanceof _zui.z.ZodLazy) {
|
|
262
|
-
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
263
|
-
}
|
|
264
|
-
if (schema instanceof _zui.z.ZodRecord) {
|
|
265
|
-
const description = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
266
|
-
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
267
|
-
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
268
|
-
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
269
|
-
}
|
|
270
|
-
try {
|
|
271
|
-
let typings = await (schema == null ? void 0 : schema.toTypescriptAsync());
|
|
272
|
-
typings ??= "unknown";
|
|
273
|
-
return stripSpaces(typings);
|
|
274
|
-
} catch (error) {
|
|
275
|
-
console.error("Error in sUnwrapZod", { error, schema, parent: options == null ? void 0 : options.parent });
|
|
276
|
-
return "unknown";
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
exports.formatTypings = formatTypings; exports.getTypings = getTypings;
|
package/dist/chunk-IKSIOIIP.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/stack-traces.ts
|
|
2
|
-
var isInternalLine = (line) => {
|
|
3
|
-
return line.includes("/llmz/") || line.includes("\\llmz\\src\\") || line.includes("node_modules");
|
|
4
|
-
};
|
|
5
|
-
function cleanStackTrace(stack, cleanInternal = true) {
|
|
6
|
-
const lines = stack.split("\n");
|
|
7
|
-
for (let i = 0; i < lines.length; i++) {
|
|
8
|
-
const line = lines[i];
|
|
9
|
-
let llmzIndex = line.indexOf("/llmz/");
|
|
10
|
-
if (llmzIndex === -1) {
|
|
11
|
-
llmzIndex = line.indexOf("\\llmz\\");
|
|
12
|
-
}
|
|
13
|
-
if (llmzIndex === -1) {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
let lastSpaceIndex = line.lastIndexOf(" ", llmzIndex);
|
|
17
|
-
if (lastSpaceIndex === -1) {
|
|
18
|
-
lastSpaceIndex = 0;
|
|
19
|
-
}
|
|
20
|
-
const maybeParen = line[lastSpaceIndex + 1] === "(" ? "(" : "";
|
|
21
|
-
lines[i] = line.slice(0, lastSpaceIndex + 1) + maybeParen + line.slice(llmzIndex);
|
|
22
|
-
}
|
|
23
|
-
return lines.filter((x) => !cleanInternal || !isInternalLine(x)).join("\n");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.cleanStackTrace = cleanStackTrace;
|
package/dist/chunk-JDABP4SD.cjs
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkIKSIOIIPcjs = require('./chunk-IKSIOIIP.cjs');
|
|
4
|
-
|
|
5
|
-
// src/errors.ts
|
|
6
|
-
var errorClasses = {};
|
|
7
|
-
function registerErrorClass(name, errorClass) {
|
|
8
|
-
errorClasses[name] = errorClass;
|
|
9
|
-
}
|
|
10
|
-
var tryParseMessage = (str) => {
|
|
11
|
-
try {
|
|
12
|
-
return JSON.parse(str);
|
|
13
|
-
} catch (e) {
|
|
14
|
-
return str;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var Signals;
|
|
18
|
-
((Signals2) => {
|
|
19
|
-
function isWrappedError(error) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const isAlreadyWrapped = error.name === "Error" && ((_a = error == null ? void 0 : error.message) == null ? void 0 : _a.startsWith("{")) && ((_b = error == null ? void 0 : error.message) == null ? void 0 : _b.endsWith("}"));
|
|
22
|
-
return isAlreadyWrapped;
|
|
23
|
-
}
|
|
24
|
-
Signals2.isWrappedError = isWrappedError;
|
|
25
|
-
function serializeError(error) {
|
|
26
|
-
if (isWrappedError(error)) {
|
|
27
|
-
const msg = tryParseMessage(error.message);
|
|
28
|
-
return JSON.stringify({
|
|
29
|
-
...typeof msg === "object" ? msg : { message: msg },
|
|
30
|
-
properties: { ...error }
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return JSON.stringify({
|
|
34
|
-
name: error.constructor.name,
|
|
35
|
-
message: error.message,
|
|
36
|
-
stack: _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, _nullishCoalesce(error.stack, () => ( ""))),
|
|
37
|
-
properties: { ...error }
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
Signals2.serializeError = serializeError;
|
|
41
|
-
function maybeDeserializeError(error) {
|
|
42
|
-
const errorIsAlreadyDeserialized = error instanceof Error && error.name in errorClasses;
|
|
43
|
-
if (errorIsAlreadyDeserialized) {
|
|
44
|
-
return error;
|
|
45
|
-
}
|
|
46
|
-
const serializedError = error instanceof Error ? error.message : typeof error === "string" ? error : _nullishCoalesce((error == null ? void 0 : error.toString()), () => ( ""));
|
|
47
|
-
try {
|
|
48
|
-
const parsed = JSON.parse(serializedError);
|
|
49
|
-
if (parsed && parsed.name && parsed.message) {
|
|
50
|
-
const { name, message, properties = {} } = parsed;
|
|
51
|
-
const ErrorClass = errorClasses[name] || Error;
|
|
52
|
-
const errorInstance = new ErrorClass(message);
|
|
53
|
-
errorInstance.message = message;
|
|
54
|
-
errorInstance.name = name;
|
|
55
|
-
errorInstance.stack = _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, _nullishCoalesce((error == null ? void 0 : error.stack), () => ( "")));
|
|
56
|
-
Object.assign(errorInstance, properties);
|
|
57
|
-
if (isWrappedError(errorInstance)) {
|
|
58
|
-
return maybeDeserializeError(errorInstance);
|
|
59
|
-
}
|
|
60
|
-
return errorInstance;
|
|
61
|
-
}
|
|
62
|
-
} catch (e2) {
|
|
63
|
-
}
|
|
64
|
-
return error;
|
|
65
|
-
}
|
|
66
|
-
Signals2.maybeDeserializeError = maybeDeserializeError;
|
|
67
|
-
})(Signals || (Signals = exports.Signals = {}));
|
|
68
|
-
var VMSignal = (_class = class extends Error {
|
|
69
|
-
constructor(message) {
|
|
70
|
-
super(message);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);;
|
|
71
|
-
this.message = message;
|
|
72
|
-
this.message = Signals.serializeError(this);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The code that was executed by the VM up to the point of the signal
|
|
76
|
-
*/
|
|
77
|
-
__init() {this.truncatedCode = ""}
|
|
78
|
-
/** The current tool call, if any */
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Contains all the declared and executed variables during the VM execution
|
|
82
|
-
* See file plugins/variable-extraction.ts for more details
|
|
83
|
-
*/
|
|
84
|
-
__init2() {this.variables = {}}
|
|
85
|
-
}, _class);
|
|
86
|
-
var SnapshotSignal = class extends VMSignal {
|
|
87
|
-
constructor(message) {
|
|
88
|
-
super(message);
|
|
89
|
-
this.message = Signals.serializeError(this);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var VMLoopSignal = class extends VMSignal {
|
|
93
|
-
constructor(message) {
|
|
94
|
-
super(message);
|
|
95
|
-
this.message = Signals.serializeError(this);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var ThinkSignal = class extends VMLoopSignal {
|
|
99
|
-
constructor(reason, context) {
|
|
100
|
-
super("Think signal received: " + reason);
|
|
101
|
-
this.reason = reason;
|
|
102
|
-
this.context = context;
|
|
103
|
-
this.message = Signals.serializeError(this);
|
|
104
|
-
}
|
|
105
|
-
toString() {
|
|
106
|
-
return Signals.serializeError(this);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var CodeExecutionError = class extends Error {
|
|
110
|
-
constructor(message, code, stacktrace) {
|
|
111
|
-
super(message);
|
|
112
|
-
this.code = code;
|
|
113
|
-
this.stacktrace = stacktrace;
|
|
114
|
-
this.message = Signals.serializeError(this);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
var InvalidCodeError = class extends Error {
|
|
118
|
-
constructor(message, code) {
|
|
119
|
-
super(message);
|
|
120
|
-
this.code = code;
|
|
121
|
-
this.message = Signals.serializeError(this);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var LoopExceededError = class extends Error {
|
|
125
|
-
constructor() {
|
|
126
|
-
super("Loop exceeded error");
|
|
127
|
-
this.message = Signals.serializeError(this);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
var CodeFormattingError = class extends Error {
|
|
131
|
-
constructor(message, code) {
|
|
132
|
-
super(message, {
|
|
133
|
-
cause: "Code formatting error"
|
|
134
|
-
});
|
|
135
|
-
this.code = code;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
var AssignmentError = class extends Error {
|
|
139
|
-
constructor(message) {
|
|
140
|
-
super(message);
|
|
141
|
-
this.message = Signals.serializeError(this);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
registerErrorClass("VMSignal", VMSignal);
|
|
145
|
-
registerErrorClass("SnapshotSignal", SnapshotSignal);
|
|
146
|
-
registerErrorClass("VMLoopSignal", VMLoopSignal);
|
|
147
|
-
registerErrorClass("ThinkSignal", ThinkSignal);
|
|
148
|
-
registerErrorClass("CodeExecutionError", CodeExecutionError);
|
|
149
|
-
registerErrorClass("AssignmentError", AssignmentError);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
exports.Signals = Signals; exports.VMSignal = VMSignal; exports.SnapshotSignal = SnapshotSignal; exports.ThinkSignal = ThinkSignal; exports.CodeExecutionError = CodeExecutionError; exports.InvalidCodeError = InvalidCodeError; exports.LoopExceededError = LoopExceededError; exports.CodeFormattingError = CodeFormattingError; exports.AssignmentError = AssignmentError;
|
package/dist/chunk-JKVVQN2P.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cleanStackTrace
|
|
3
|
-
} from "./chunk-JQBT7UWN.js";
|
|
4
|
-
|
|
5
|
-
// src/errors.ts
|
|
6
|
-
var errorClasses = {};
|
|
7
|
-
function registerErrorClass(name, errorClass) {
|
|
8
|
-
errorClasses[name] = errorClass;
|
|
9
|
-
}
|
|
10
|
-
var tryParseMessage = (str) => {
|
|
11
|
-
try {
|
|
12
|
-
return JSON.parse(str);
|
|
13
|
-
} catch {
|
|
14
|
-
return str;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var Signals;
|
|
18
|
-
((Signals2) => {
|
|
19
|
-
function isWrappedError(error) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const isAlreadyWrapped = error.name === "Error" && ((_a = error == null ? void 0 : error.message) == null ? void 0 : _a.startsWith("{")) && ((_b = error == null ? void 0 : error.message) == null ? void 0 : _b.endsWith("}"));
|
|
22
|
-
return isAlreadyWrapped;
|
|
23
|
-
}
|
|
24
|
-
Signals2.isWrappedError = isWrappedError;
|
|
25
|
-
function serializeError(error) {
|
|
26
|
-
if (isWrappedError(error)) {
|
|
27
|
-
const msg = tryParseMessage(error.message);
|
|
28
|
-
return JSON.stringify({
|
|
29
|
-
...typeof msg === "object" ? msg : { message: msg },
|
|
30
|
-
properties: { ...error }
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return JSON.stringify({
|
|
34
|
-
name: error.constructor.name,
|
|
35
|
-
message: error.message,
|
|
36
|
-
stack: cleanStackTrace(error.stack ?? ""),
|
|
37
|
-
properties: { ...error }
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
Signals2.serializeError = serializeError;
|
|
41
|
-
function maybeDeserializeError(error) {
|
|
42
|
-
const errorIsAlreadyDeserialized = error instanceof Error && error.name in errorClasses;
|
|
43
|
-
if (errorIsAlreadyDeserialized) {
|
|
44
|
-
return error;
|
|
45
|
-
}
|
|
46
|
-
const serializedError = error instanceof Error ? error.message : typeof error === "string" ? error : (error == null ? void 0 : error.toString()) ?? "";
|
|
47
|
-
try {
|
|
48
|
-
const parsed = JSON.parse(serializedError);
|
|
49
|
-
if (parsed && parsed.name && parsed.message) {
|
|
50
|
-
const { name, message, properties = {} } = parsed;
|
|
51
|
-
const ErrorClass = errorClasses[name] || Error;
|
|
52
|
-
const errorInstance = new ErrorClass(message);
|
|
53
|
-
errorInstance.message = message;
|
|
54
|
-
errorInstance.name = name;
|
|
55
|
-
errorInstance.stack = cleanStackTrace((error == null ? void 0 : error.stack) ?? "");
|
|
56
|
-
Object.assign(errorInstance, properties);
|
|
57
|
-
if (isWrappedError(errorInstance)) {
|
|
58
|
-
return maybeDeserializeError(errorInstance);
|
|
59
|
-
}
|
|
60
|
-
return errorInstance;
|
|
61
|
-
}
|
|
62
|
-
} catch {
|
|
63
|
-
}
|
|
64
|
-
return error;
|
|
65
|
-
}
|
|
66
|
-
Signals2.maybeDeserializeError = maybeDeserializeError;
|
|
67
|
-
})(Signals || (Signals = {}));
|
|
68
|
-
var VMSignal = class extends Error {
|
|
69
|
-
constructor(message) {
|
|
70
|
-
super(message);
|
|
71
|
-
this.message = message;
|
|
72
|
-
this.message = Signals.serializeError(this);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The code that was executed by the VM up to the point of the signal
|
|
76
|
-
*/
|
|
77
|
-
truncatedCode = "";
|
|
78
|
-
/** The current tool call, if any */
|
|
79
|
-
toolCall;
|
|
80
|
-
/**
|
|
81
|
-
* Contains all the declared and executed variables during the VM execution
|
|
82
|
-
* See file plugins/variable-extraction.ts for more details
|
|
83
|
-
*/
|
|
84
|
-
variables = {};
|
|
85
|
-
};
|
|
86
|
-
var SnapshotSignal = class extends VMSignal {
|
|
87
|
-
constructor(message) {
|
|
88
|
-
super(message);
|
|
89
|
-
this.message = Signals.serializeError(this);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var VMLoopSignal = class extends VMSignal {
|
|
93
|
-
constructor(message) {
|
|
94
|
-
super(message);
|
|
95
|
-
this.message = Signals.serializeError(this);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var ThinkSignal = class extends VMLoopSignal {
|
|
99
|
-
constructor(reason, context) {
|
|
100
|
-
super("Think signal received: " + reason);
|
|
101
|
-
this.reason = reason;
|
|
102
|
-
this.context = context;
|
|
103
|
-
this.message = Signals.serializeError(this);
|
|
104
|
-
}
|
|
105
|
-
toString() {
|
|
106
|
-
return Signals.serializeError(this);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var CodeExecutionError = class extends Error {
|
|
110
|
-
constructor(message, code, stacktrace) {
|
|
111
|
-
super(message);
|
|
112
|
-
this.code = code;
|
|
113
|
-
this.stacktrace = stacktrace;
|
|
114
|
-
this.message = Signals.serializeError(this);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
var InvalidCodeError = class extends Error {
|
|
118
|
-
constructor(message, code) {
|
|
119
|
-
super(message);
|
|
120
|
-
this.code = code;
|
|
121
|
-
this.message = Signals.serializeError(this);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var LoopExceededError = class extends Error {
|
|
125
|
-
constructor() {
|
|
126
|
-
super("Loop exceeded error");
|
|
127
|
-
this.message = Signals.serializeError(this);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
var CodeFormattingError = class extends Error {
|
|
131
|
-
constructor(message, code) {
|
|
132
|
-
super(message, {
|
|
133
|
-
cause: "Code formatting error"
|
|
134
|
-
});
|
|
135
|
-
this.code = code;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
var AssignmentError = class extends Error {
|
|
139
|
-
constructor(message) {
|
|
140
|
-
super(message);
|
|
141
|
-
this.message = Signals.serializeError(this);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
registerErrorClass("VMSignal", VMSignal);
|
|
145
|
-
registerErrorClass("SnapshotSignal", SnapshotSignal);
|
|
146
|
-
registerErrorClass("VMLoopSignal", VMLoopSignal);
|
|
147
|
-
registerErrorClass("ThinkSignal", ThinkSignal);
|
|
148
|
-
registerErrorClass("CodeExecutionError", CodeExecutionError);
|
|
149
|
-
registerErrorClass("AssignmentError", AssignmentError);
|
|
150
|
-
|
|
151
|
-
export {
|
|
152
|
-
Signals,
|
|
153
|
-
VMSignal,
|
|
154
|
-
SnapshotSignal,
|
|
155
|
-
ThinkSignal,
|
|
156
|
-
CodeExecutionError,
|
|
157
|
-
InvalidCodeError,
|
|
158
|
-
LoopExceededError,
|
|
159
|
-
CodeFormattingError,
|
|
160
|
-
AssignmentError
|
|
161
|
-
};
|
package/dist/chunk-JQBT7UWN.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// src/stack-traces.ts
|
|
2
|
-
var isInternalLine = (line) => {
|
|
3
|
-
return line.includes("/llmz/") || line.includes("\\llmz\\src\\") || line.includes("node_modules");
|
|
4
|
-
};
|
|
5
|
-
function cleanStackTrace(stack, cleanInternal = true) {
|
|
6
|
-
const lines = stack.split("\n");
|
|
7
|
-
for (let i = 0; i < lines.length; i++) {
|
|
8
|
-
const line = lines[i];
|
|
9
|
-
let llmzIndex = line.indexOf("/llmz/");
|
|
10
|
-
if (llmzIndex === -1) {
|
|
11
|
-
llmzIndex = line.indexOf("\\llmz\\");
|
|
12
|
-
}
|
|
13
|
-
if (llmzIndex === -1) {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
let lastSpaceIndex = line.lastIndexOf(" ", llmzIndex);
|
|
17
|
-
if (lastSpaceIndex === -1) {
|
|
18
|
-
lastSpaceIndex = 0;
|
|
19
|
-
}
|
|
20
|
-
const maybeParen = line[lastSpaceIndex + 1] === "(" ? "(" : "";
|
|
21
|
-
lines[i] = line.slice(0, lastSpaceIndex + 1) + maybeParen + line.slice(llmzIndex);
|
|
22
|
-
}
|
|
23
|
-
return lines.filter((x) => !cleanInternal || !isInternalLine(x)).join("\n");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
cleanStackTrace
|
|
28
|
-
};
|
package/dist/chunk-KMZDFWYZ.cjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.cjs');
|
|
5
|
-
|
|
6
|
-
// src/jsx.ts
|
|
7
|
-
var _zui = require('@bpinternal/zui');
|
|
8
|
-
function isAnyJsxComponent(component) {
|
|
9
|
-
return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string";
|
|
10
|
-
}
|
|
11
|
-
function isJsxComponent(type, component) {
|
|
12
|
-
return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string" && typeof type === "string" && component.type.toUpperCase().trim() === type.toUpperCase().trim();
|
|
13
|
-
}
|
|
14
|
-
var createJsxComponent = (props) => ({
|
|
15
|
-
__jsx: true,
|
|
16
|
-
type: _chunkUQOBUJIQcjs.isString_default.call(void 0, props.type) ? props.type.toUpperCase() : "__unknown__",
|
|
17
|
-
children: Array.isArray(props.children) ? props.children : props.children ? [props.children] : [],
|
|
18
|
-
props: _chunkUQOBUJIQcjs.isPlainObject_default.call(void 0, props.props) ? props.props : {}
|
|
19
|
-
});
|
|
20
|
-
var Jsx = _zui.z.custom(
|
|
21
|
-
(value) => isAnyJsxComponent(value),
|
|
22
|
-
(value) => ({
|
|
23
|
-
params: { value },
|
|
24
|
-
message: `Invalid JSX component: ${value}`
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
exports.isAnyJsxComponent = isAnyJsxComponent; exports.isJsxComponent = isJsxComponent; exports.createJsxComponent = createJsxComponent; exports.Jsx = Jsx;
|