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.
Files changed (92) hide show
  1. package/package.json +5 -3
  2. package/dist/chat.d.ts +0 -17
  3. package/dist/chunk-3U57H7GT.js +0 -608
  4. package/dist/chunk-4EWY34YA.js +0 -3079
  5. package/dist/chunk-4I7UPBLN.cjs +0 -104
  6. package/dist/chunk-4QTK5ALH.cjs +0 -211
  7. package/dist/chunk-5NVNEEYW.cjs +0 -3079
  8. package/dist/chunk-5TRUJES5.js +0 -220
  9. package/dist/chunk-6WT5VZBG.cjs +0 -755
  10. package/dist/chunk-7WRN4E42.js +0 -3087
  11. package/dist/chunk-EJRCDWBA.cjs +0 -153
  12. package/dist/chunk-FIVFS4HG.cjs +0 -152
  13. package/dist/chunk-HP7RKM25.js +0 -153
  14. package/dist/chunk-HYVKY3W6.cjs +0 -283
  15. package/dist/chunk-IKSIOIIP.cjs +0 -28
  16. package/dist/chunk-JDABP4SD.cjs +0 -161
  17. package/dist/chunk-JKVVQN2P.js +0 -161
  18. package/dist/chunk-JQBT7UWN.js +0 -28
  19. package/dist/chunk-KMZDFWYZ.cjs +0 -33
  20. package/dist/chunk-MU4LFVY7.cjs +0 -608
  21. package/dist/chunk-ORQP26SZ.js +0 -33
  22. package/dist/chunk-P7J2WCBB.cjs +0 -220
  23. package/dist/chunk-QBXIE6EY.js +0 -211
  24. package/dist/chunk-QT4QF3YA.js +0 -152
  25. package/dist/chunk-S6FOL2HY.js +0 -104
  26. package/dist/chunk-UNMKB2DA.js +0 -283
  27. package/dist/chunk-UQOBUJIQ.cjs +0 -3087
  28. package/dist/chunk-WLUVY5QU.js +0 -755
  29. package/dist/citations.d.ts +0 -63
  30. package/dist/compiler/compiler.d.ts +0 -28
  31. package/dist/compiler/index.d.ts +0 -2
  32. package/dist/compiler/plugins/async-iterator.d.ts +0 -4
  33. package/dist/compiler/plugins/braces-tsx.d.ts +0 -3
  34. package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +0 -5
  35. package/dist/compiler/plugins/line-tracking.d.ts +0 -5
  36. package/dist/compiler/plugins/replace-comment.d.ts +0 -5
  37. package/dist/compiler/plugins/return-async.d.ts +0 -4
  38. package/dist/compiler/plugins/track-tool-calls.d.ts +0 -16
  39. package/dist/compiler/plugins/variable-extraction.d.ts +0 -5
  40. package/dist/component-R2Y74VUI.js +0 -16
  41. package/dist/component-TSNW3SC7.cjs +0 -16
  42. package/dist/component.d.ts +0 -60
  43. package/dist/component.default.d.ts +0 -316
  44. package/dist/context.d.ts +0 -170
  45. package/dist/dual-modes-UHNDHNIF.cjs +0 -12
  46. package/dist/dual-modes-ZUQKPJFH.js +0 -12
  47. package/dist/errors.d.ts +0 -64
  48. package/dist/exit-KJ4COC5N.cjs +0 -8
  49. package/dist/exit-OIYZLBVJ.js +0 -8
  50. package/dist/exit.d.ts +0 -26
  51. package/dist/formatting.d.ts +0 -5
  52. package/dist/getter.d.ts +0 -2
  53. package/dist/handlers.d.ts +0 -10
  54. package/dist/hoist.d.ts +0 -2
  55. package/dist/index.cjs +0 -907
  56. package/dist/index.d.ts +0 -21
  57. package/dist/index.js +0 -907
  58. package/dist/inspect.d.ts +0 -6
  59. package/dist/jsx-AEHVFB3L.js +0 -13
  60. package/dist/jsx-AJAXBWFE.cjs +0 -13
  61. package/dist/jsx.d.ts +0 -11
  62. package/dist/llmz-VDA4M42R.cjs +0 -604
  63. package/dist/llmz-YE5N54IU.js +0 -604
  64. package/dist/llmz.d.ts +0 -39
  65. package/dist/objects.d.ts +0 -24
  66. package/dist/openai.d.ts +0 -8
  67. package/dist/prompts/chat-mode/system.md.d.ts +0 -2
  68. package/dist/prompts/chat-mode/user.md.d.ts +0 -2
  69. package/dist/prompts/common.d.ts +0 -6
  70. package/dist/prompts/dual-modes.d.ts +0 -2
  71. package/dist/prompts/prompt.d.ts +0 -50
  72. package/dist/prompts/worker-mode/system.md.d.ts +0 -2
  73. package/dist/prompts/worker-mode/user.md.d.ts +0 -2
  74. package/dist/snapshots.d.ts +0 -69
  75. package/dist/stack-traces.d.ts +0 -1
  76. package/dist/tool-LY77IWV2.js +0 -11
  77. package/dist/tool-SWJYOR2Z.cjs +0 -11
  78. package/dist/tool.d.ts +0 -55
  79. package/dist/transcript.d.ts +0 -9
  80. package/dist/truncator-NYN7BGKJ.cjs +0 -10
  81. package/dist/truncator-WAL2GCUY.js +0 -10
  82. package/dist/truncator.d.ts +0 -21
  83. package/dist/types.d.ts +0 -139
  84. package/dist/typings-AIV2OASX.js +0 -10
  85. package/dist/typings-XR6CYHW4.cjs +0 -10
  86. package/dist/typings.d.ts +0 -5
  87. package/dist/utils-L5GLCS3C.js +0 -37
  88. package/dist/utils-QC4I2L6R.cjs +0 -37
  89. package/dist/utils.d.ts +0 -21
  90. package/dist/vm-GJ5R72AP.cjs +0 -12
  91. package/dist/vm-ZUQOSRRM.js +0 -12
  92. package/dist/vm.d.ts +0 -3
@@ -1,220 +0,0 @@
1
- import {
2
- camelCase_default,
3
- deburr_default,
4
- isPlainObject_default,
5
- pickBy_default,
6
- startCase_default
7
- } from "./chunk-7WRN4E42.js";
8
-
9
- // src/utils.ts
10
- import { getWasmTokenizer } from "@bpinternal/thicktoken";
11
- import { z } from "@bpinternal/zui";
12
- var tokenizer = null;
13
- var init = async () => {
14
- if (tokenizer) {
15
- return;
16
- }
17
- while (typeof getWasmTokenizer !== "function") {
18
- await new Promise((resolve) => setTimeout(resolve, 50));
19
- }
20
- tokenizer = await getWasmTokenizer();
21
- };
22
- var getTokenizer = () => {
23
- if (!tokenizer) {
24
- throw new Error("Tokenizer not initialized, make sure to call init() first and await it");
25
- }
26
- return tokenizer;
27
- };
28
- var Tokens = (min, max) => {
29
- return z.string().superRefine((value, ctx) => {
30
- const tokens = tokenizer.count(value);
31
- if (value.length < min) {
32
- ctx.addIssue({
33
- code: "too_small",
34
- minimum: min,
35
- type: "string",
36
- message: `Text is ${tokens} but expected at least ${min} tokens`,
37
- inclusive: true
38
- });
39
- }
40
- if (value.length > max) {
41
- ctx.addIssue({
42
- code: "too_big",
43
- maximum: max,
44
- type: "string",
45
- message: `Text is ${tokens} tokens but expected at most ${max} tokens`,
46
- inclusive: true
47
- });
48
- }
49
- return value;
50
- });
51
- };
52
- var Identifier = z.string().min(1).max(100).regex(
53
- /^([a-zA-Z_][a-zA-Z0-9_]*)$/,
54
- "Identifiers must start with a letter and can only contain letters, numbers and underscores"
55
- );
56
- function escapeString(str) {
57
- if (typeof str !== "string") {
58
- return "";
59
- }
60
- const rawStr = String.raw`${str}`;
61
- const escapedStr = rawStr.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/"/g, '\\"').replace(/'/g, "\\'");
62
- if (escapedStr.includes("`")) {
63
- return `"${escapedStr}"`;
64
- } else if (escapedStr.includes("'")) {
65
- return `"${escapedStr}"`;
66
- } else {
67
- return `'${escapedStr}'`;
68
- }
69
- }
70
- var toPropertyKey = (key) => {
71
- if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)) {
72
- return key;
73
- }
74
- return escapeString(key);
75
- };
76
- var trimEmptyLines = (lines) => {
77
- var _a;
78
- while (lines.length && !((_a = lines[0]) == null ? void 0 : _a.trim())) {
79
- lines.shift();
80
- }
81
- while (lines.length && !lines[lines.length - 1].trim()) {
82
- lines.pop();
83
- }
84
- };
85
- var getMultilineComment = (description) => {
86
- description = description == null ? void 0 : description.replace(/(\n(\s*)?){3,}/g, "\n\n");
87
- const ensureLineStartsWithAsterisk = (line) => line.startsWith("* ") ? ` ${line}` : ` * ${line}`;
88
- const escapeCommentEnd = (line) => line.replace(/\*\//g, "*\\/");
89
- const descLines = (description ?? "").split("\n").map((line) => line.trim());
90
- trimEmptyLines(descLines);
91
- if (descLines.length) {
92
- descLines[0] = descLines[0].replace(/^\/\*\*?/, "");
93
- descLines[descLines.length - 1] = descLines[descLines.length - 1].replace(/\*\/$/, "");
94
- }
95
- trimEmptyLines(descLines);
96
- return descLines.length === 0 ? "" : descLines.length === 1 ? `/** ${escapeCommentEnd(descLines[0])} */` : `/**
97
- ${descLines.map(ensureLineStartsWithAsterisk).map(escapeCommentEnd).join("\n")}
98
- */`;
99
- };
100
- var toValidFunctionName = (str) => {
101
- let name = deburr_default(str);
102
- name = name.replace(/[^a-zA-Z0-9_$]/g, "");
103
- if (!/^[a-zA-Z_$]/.test(name)) {
104
- name = `_${name}`;
105
- }
106
- return camelCase_default(name);
107
- };
108
- var awaitObject = async (obj) => {
109
- const newObj = { ...obj };
110
- const promises = [];
111
- const setProp = async (key, value) => {
112
- newObj[key] = await value;
113
- };
114
- for (const [key, value] of Object.entries(obj)) {
115
- if (value instanceof Promise) {
116
- promises.push(setProp(key, value));
117
- } else if (isPlainObject_default(value)) {
118
- promises.push(setProp(key, await awaitObject(value)));
119
- }
120
- }
121
- await Promise.all(promises);
122
- return newObj;
123
- };
124
- var toValidObjectName = (str) => {
125
- let name = deburr_default(str);
126
- name = name.split(/[^a-zA-Z0-9_$]/g).map(startCase_default).join("");
127
- if (!/^[a-zA-Z_$]/.test(name)) {
128
- name = `_${name}`;
129
- }
130
- return name.replaceAll(" ", "");
131
- };
132
- var stripInvalidIdentifiers = (object) => {
133
- if (typeof object !== "object") {
134
- return object;
135
- }
136
- if (Array.isArray(object)) {
137
- return object.map(stripInvalidIdentifiers);
138
- }
139
- return pickBy_default(object, (__, key) => Identifier.safeParse(key).success);
140
- };
141
- var convertObjectToZuiLiterals = (obj, nested = false) => {
142
- if (typeof obj === "string") {
143
- return z.literal(obj).catch(() => obj);
144
- }
145
- if (typeof obj === "number") {
146
- return z.literal(obj).catch(() => obj);
147
- }
148
- if (typeof obj === "boolean") {
149
- return z.literal(obj).catch(() => obj);
150
- }
151
- if (Array.isArray(obj)) {
152
- if (obj.length === 0) {
153
- return z.tuple([]).catch(() => obj);
154
- }
155
- return z.tuple([
156
- // the tuple needs to have at least one element
157
- convertObjectToZuiLiterals(obj[0]),
158
- ...obj.slice(1).map((child) => convertObjectToZuiLiterals(child))
159
- ]).catch(() => obj);
160
- }
161
- if (obj !== null && typeof obj === "object") {
162
- const shape = {};
163
- for (const key in obj) {
164
- shape[key] = convertObjectToZuiLiterals(obj[key], true);
165
- }
166
- if (nested) {
167
- return z.object(shape).catch(() => shape);
168
- }
169
- return shape;
170
- }
171
- if (obj === void 0) {
172
- return z.undefined().catch(() => void 0);
173
- }
174
- if (obj === null) {
175
- return z.null().catch(() => null);
176
- }
177
- throw new Error(`Unsupported object type ${typeof obj}, ${obj})`);
178
- };
179
- var isValidSchema = (schema) => {
180
- try {
181
- z.fromJsonSchema(schema);
182
- return typeof schema.type === "string";
183
- } catch {
184
- return false;
185
- }
186
- };
187
- function isJsonSchema(schema) {
188
- return !!schema && typeof schema === "object" && ("$schema" in schema || "type" in schema || "properties" in schema);
189
- }
190
- function isValidIdentifier(name) {
191
- if (typeof name !== "string") {
192
- return false;
193
- }
194
- return /^[A-Z]{1,}[A-Z0-9_]{0,50}$/i.test(name);
195
- }
196
- function isValidMessageName(name) {
197
- if (typeof name !== "string") {
198
- return false;
199
- }
200
- return /^[A-Z]{1,50}$/i.test(name);
201
- }
202
-
203
- export {
204
- init,
205
- getTokenizer,
206
- Tokens,
207
- Identifier,
208
- escapeString,
209
- toPropertyKey,
210
- getMultilineComment,
211
- toValidFunctionName,
212
- awaitObject,
213
- toValidObjectName,
214
- stripInvalidIdentifiers,
215
- convertObjectToZuiLiterals,
216
- isValidSchema,
217
- isJsonSchema,
218
- isValidIdentifier,
219
- isValidMessageName
220
- };