llmz 0.0.5 → 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/package.json +5 -3
- package/dist/chat.d.ts +0 -17
- package/dist/chunk-3U57H7GT.js +0 -608
- package/dist/chunk-4EWY34YA.js +0 -3079
- package/dist/chunk-4I7UPBLN.cjs +0 -104
- package/dist/chunk-4QTK5ALH.cjs +0 -211
- package/dist/chunk-5NVNEEYW.cjs +0 -3079
- package/dist/chunk-5TRUJES5.js +0 -220
- package/dist/chunk-6WT5VZBG.cjs +0 -755
- package/dist/chunk-7WRN4E42.js +0 -3087
- 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-MU4LFVY7.cjs +0 -608
- 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/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 -170
- 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 -907
- package/dist/index.d.ts +0 -21
- package/dist/index.js +0 -907
- 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-VDA4M42R.cjs +0 -604
- package/dist/llmz-YE5N54IU.js +0 -604
- package/dist/llmz.d.ts +0 -39
- 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/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 -139
- 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-GJ5R72AP.cjs +0 -12
- package/dist/vm-ZUQOSRRM.js +0 -12
- package/dist/vm.d.ts +0 -3
package/dist/chunk-UNMKB2DA.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CodeFormattingError
|
|
3
|
-
} from "./chunk-JKVVQN2P.js";
|
|
4
|
-
import {
|
|
5
|
-
escapeString,
|
|
6
|
-
getMultilineComment,
|
|
7
|
-
toPropertyKey
|
|
8
|
-
} from "./chunk-5TRUJES5.js";
|
|
9
|
-
|
|
10
|
-
// src/typings.ts
|
|
11
|
-
import { z } from "@bpinternal/zui";
|
|
12
|
-
|
|
13
|
-
// src/formatting.ts
|
|
14
|
-
import { LRUCache } from "lru-cache";
|
|
15
|
-
import babel from "prettier/plugins/babel";
|
|
16
|
-
import estree from "prettier/plugins/estree";
|
|
17
|
-
import typescript from "prettier/plugins/typescript";
|
|
18
|
-
import { format } from "prettier/standalone";
|
|
19
|
-
var cache = new 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 format(typings, {
|
|
28
|
-
singleAttributePerLine: true,
|
|
29
|
-
bracketSameLine: true,
|
|
30
|
-
semi: false,
|
|
31
|
-
...options,
|
|
32
|
-
embeddedLanguageFormatting: "off",
|
|
33
|
-
plugins: [estree, babel, typescript],
|
|
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 CodeFormattingError(err instanceof Error ? err.message : (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 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 = getMultilineComment(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 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 z.ZodOptional) {
|
|
128
|
-
let innerType = schema.value._def.innerType;
|
|
129
|
-
if (innerType instanceof 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 = getMultilineComment(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 z.ZodTuple) {
|
|
142
|
-
let args = "";
|
|
143
|
-
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
144
|
-
const argName = ((_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(toPropertyKey(argName), item), newOptions)}, `;
|
|
147
|
-
}
|
|
148
|
-
return args;
|
|
149
|
-
}
|
|
150
|
-
const isLiteral = schema.schema.naked() instanceof 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 z.ZodOptional) {
|
|
161
|
-
return `${await sUnwrapZodRecursive(schema.schema.unwrap(), newOptions)} | undefined`;
|
|
162
|
-
}
|
|
163
|
-
return sUnwrapZodRecursive(schema.schema, newOptions);
|
|
164
|
-
}
|
|
165
|
-
if (schema instanceof z.ZodDefault) {
|
|
166
|
-
return sUnwrapZodRecursive(schema._def.innerType, options);
|
|
167
|
-
}
|
|
168
|
-
if (schema instanceof z.ZodVoid) {
|
|
169
|
-
return "void";
|
|
170
|
-
}
|
|
171
|
-
if (schema instanceof z.ZodUnknown) {
|
|
172
|
-
return "unknown";
|
|
173
|
-
}
|
|
174
|
-
if (schema instanceof z.ZodAny) {
|
|
175
|
-
return "any";
|
|
176
|
-
}
|
|
177
|
-
if (schema instanceof z.ZodPromise) {
|
|
178
|
-
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
179
|
-
}
|
|
180
|
-
if (schema instanceof z.ZodFunction) {
|
|
181
|
-
const description = getMultilineComment(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 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 z.ZodEnum) {
|
|
199
|
-
const values = schema._def.values.map(escapeString);
|
|
200
|
-
return values.join(" | ");
|
|
201
|
-
}
|
|
202
|
-
if (schema instanceof 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 z.ZodNullable) {
|
|
210
|
-
return `${await sUnwrapZodRecursive(schema.unwrap(), options)} | null`;
|
|
211
|
-
}
|
|
212
|
-
if (schema instanceof z.ZodOptional) {
|
|
213
|
-
if ((options == null ? void 0 : options.declaration) || (options == null ? void 0 : options.parent) instanceof 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 z.ZodObject) {
|
|
221
|
-
const props = await Promise.all(
|
|
222
|
-
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
223
|
-
if (value instanceof z.Schema) {
|
|
224
|
-
return sUnwrapZodRecursive(new KeyValue(toPropertyKey(key), value), newOptions);
|
|
225
|
-
}
|
|
226
|
-
return `${key}: unknown`;
|
|
227
|
-
})
|
|
228
|
-
);
|
|
229
|
-
return `{ ${props.join("; ")} }`;
|
|
230
|
-
}
|
|
231
|
-
if (schema instanceof z.ZodString) {
|
|
232
|
-
const description = getMultilineComment(schema._def.description);
|
|
233
|
-
return `${description} string`.trim();
|
|
234
|
-
}
|
|
235
|
-
if (schema instanceof z.ZodUnion) {
|
|
236
|
-
const description = getMultilineComment(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 z.ZodLiteral) {
|
|
246
|
-
const description = getMultilineComment(schema._def.description);
|
|
247
|
-
return `${description}
|
|
248
|
-
${typeof schema.value === "string" ? escapeString(schema.value) : schema.value}`.trim();
|
|
249
|
-
}
|
|
250
|
-
if (schema instanceof z.ZodNumber) {
|
|
251
|
-
const description = getMultilineComment(schema._def.description);
|
|
252
|
-
return `${description} number`.trim();
|
|
253
|
-
}
|
|
254
|
-
if (schema instanceof z.ZodBoolean) {
|
|
255
|
-
const description = getMultilineComment(schema._def.description);
|
|
256
|
-
return `${description} boolean`.trim();
|
|
257
|
-
}
|
|
258
|
-
if (schema instanceof z.ZodCatch) {
|
|
259
|
-
return sUnwrapZodRecursive(schema.removeCatch(), newOptions);
|
|
260
|
-
}
|
|
261
|
-
if (schema instanceof z.ZodLazy) {
|
|
262
|
-
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
263
|
-
}
|
|
264
|
-
if (schema instanceof z.ZodRecord) {
|
|
265
|
-
const description = getMultilineComment(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
|
-
export {
|
|
281
|
-
formatTypings,
|
|
282
|
-
getTypings
|
|
283
|
-
};
|