llmz 0.0.4 → 0.0.5

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 (35) hide show
  1. package/dist/chat.d.ts +17 -0
  2. package/dist/chunk-3U57H7GT.js +608 -0
  3. package/dist/{chunk-LVKZYKTP.cjs → chunk-4I7UPBLN.cjs} +2 -2
  4. package/dist/{chunk-W6U2VXSF.cjs → chunk-6WT5VZBG.cjs} +348 -12
  5. package/dist/{chunk-JK2LZW2G.cjs → chunk-EJRCDWBA.cjs} +45 -6
  6. package/dist/{chunk-ZCPQ3QOW.js → chunk-HP7RKM25.js} +45 -6
  7. package/dist/chunk-MU4LFVY7.cjs +608 -0
  8. package/dist/{chunk-S6WICIDW.js → chunk-S6FOL2HY.js} +2 -2
  9. package/dist/{chunk-TJQVC4CE.js → chunk-WLUVY5QU.js} +341 -5
  10. package/dist/{component-LQDU72LX.js → component-R2Y74VUI.js} +3 -1
  11. package/dist/component-TSNW3SC7.cjs +16 -0
  12. package/dist/component.d.ts +6 -19
  13. package/dist/component.default.d.ts +131 -151
  14. package/dist/context.d.ts +6 -5
  15. package/dist/{dual-modes-YE4S2AIL.cjs → dual-modes-UHNDHNIF.cjs} +3 -4
  16. package/dist/{dual-modes-QHBOFWHM.js → dual-modes-ZUQKPJFH.js} +2 -3
  17. package/dist/{exit-IDKGZD7M.cjs → exit-KJ4COC5N.cjs} +2 -2
  18. package/dist/{exit-F6ZUL2NV.js → exit-OIYZLBVJ.js} +1 -1
  19. package/dist/exit.d.ts +5 -1
  20. package/dist/getter.d.ts +1 -1
  21. package/dist/index.cjs +72 -127
  22. package/dist/index.d.ts +7 -5
  23. package/dist/index.js +67 -122
  24. package/dist/llmz-VDA4M42R.cjs +604 -0
  25. package/dist/llmz-YE5N54IU.js +604 -0
  26. package/dist/llmz.d.ts +6 -9
  27. package/dist/types.d.ts +2 -0
  28. package/package.json +1 -1
  29. package/dist/chunk-4KB5WXHR.js +0 -92
  30. package/dist/chunk-6YWYCVAB.cjs +0 -92
  31. package/dist/chunk-EFGXTO64.js +0 -344
  32. package/dist/chunk-VAF2H6UD.cjs +0 -344
  33. package/dist/component-HQ5YQNRX.cjs +0 -14
  34. package/dist/llmz-AS5TGCQS.js +0 -1108
  35. package/dist/llmz-R6XZG3JQ.cjs +0 -1108
@@ -1,19 +1,353 @@
1
- import {
2
- inspect
3
- } from "./chunk-EFGXTO64.js";
4
1
  import {
5
2
  cleanStackTrace
6
3
  } from "./chunk-JQBT7UWN.js";
7
4
  import {
8
5
  getComponentReference
9
- } from "./chunk-ZCPQ3QOW.js";
6
+ } from "./chunk-HP7RKM25.js";
10
7
  import {
11
8
  wrapContent
12
9
  } from "./chunk-QT4QF3YA.js";
13
10
  import {
14
- isPlainObject_default
11
+ escapeString,
12
+ getTokenizer
13
+ } from "./chunk-5TRUJES5.js";
14
+ import {
15
+ chain_default,
16
+ countBy_default,
17
+ filter_default,
18
+ isEmpty_default,
19
+ isEqual_default,
20
+ isNil_default,
21
+ isPlainObject_default,
22
+ mapKeys_default,
23
+ orderBy_default,
24
+ uniqWith_default,
25
+ uniq_default
15
26
  } from "./chunk-7WRN4E42.js";
16
27
 
28
+ // src/inspect.ts
29
+ import bytes from "bytes";
30
+ var SUBTITLE_LN = "--------------";
31
+ var SECTION_SEP = "\n";
32
+ var NUMBER_LOCALE = new Intl.NumberFormat("en-US");
33
+ var LONG_TEXT_LENGTH = 4096;
34
+ var DEFAULT_OPTIONS = {
35
+ tokens: 1e5
36
+ };
37
+ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
38
+ const indent = 2;
39
+ let currentLength = 0;
40
+ let wasTruncated = false;
41
+ function recurse(currentObj, depth, currentIndent) {
42
+ if (depth > maxDepth || currentLength >= maxLength) {
43
+ wasTruncated = true;
44
+ return "...";
45
+ }
46
+ if (typeof currentObj === "object" && currentObj instanceof Date) {
47
+ currentIndent += 3;
48
+ try {
49
+ return currentObj.toISOString();
50
+ } catch (err) {
51
+ return `<Date: ${(err == null ? void 0 : err.message) ?? "Invalid Date"}>`;
52
+ }
53
+ }
54
+ if (typeof currentObj !== "object" || currentObj === null) {
55
+ const value = JSON.stringify(currentObj);
56
+ currentLength += getTokenizer().count(value);
57
+ return value;
58
+ }
59
+ const indentation = " ".repeat(currentIndent);
60
+ if (Array.isArray(currentObj)) {
61
+ let result = "[\n";
62
+ for (let i = 0; i < currentObj.length && currentLength < maxLength; i++) {
63
+ if (i > 0) {
64
+ result += ",\n";
65
+ }
66
+ result += indentation + " ".repeat(indent) + recurse(currentObj[i], depth + 1, currentIndent + indent);
67
+ }
68
+ result += "\n" + indentation + "]";
69
+ currentLength += getTokenizer().count(result);
70
+ return result;
71
+ } else {
72
+ let result = "{\n";
73
+ const keys = Object.keys(currentObj);
74
+ const numKeys = keys.length;
75
+ for (let i = 0; i < Math.min(numKeys, maxKeys) && currentLength < maxLength; i++) {
76
+ const key = keys[i];
77
+ if (i > 0) {
78
+ result += ",\n";
79
+ }
80
+ const value = recurse(currentObj[key], depth + 1, currentIndent + indent);
81
+ result += indentation + " ".repeat(indent) + `"${key}": ${value}`;
82
+ }
83
+ if (numKeys > maxKeys) {
84
+ wasTruncated = true;
85
+ result += ",\n" + indentation + `... (${numKeys - maxKeys} more keys)`;
86
+ }
87
+ result += "\n" + indentation + "}";
88
+ currentLength += getTokenizer().count(result);
89
+ return result;
90
+ }
91
+ }
92
+ const output = getTokenizer().truncate(recurse(obj, 0, 0), maxLength);
93
+ return { output, truncated: wasTruncated };
94
+ }
95
+ function extractType(value, generic = true) {
96
+ if (value === null) {
97
+ return "null";
98
+ }
99
+ if (value === void 0 || typeof value === "undefined") {
100
+ return "undefined";
101
+ }
102
+ if (typeof value === "object" && Array.isArray(value)) {
103
+ if (!generic) {
104
+ return "Array";
105
+ }
106
+ if (value.length === 0) {
107
+ return "Array (empty)";
108
+ }
109
+ if (value.length === 1) {
110
+ return `Array<${extractType(value[0])}>`;
111
+ }
112
+ const types = /* @__PURE__ */ new Map();
113
+ for (const element of value) {
114
+ const type = extractType(element, false);
115
+ types.set(type, (types.get(type) || 0) + 1);
116
+ }
117
+ if (types.size <= 3) {
118
+ return `Array<${Array.from(types.keys()).join(" | ")}>`;
119
+ }
120
+ return "Array";
121
+ }
122
+ if (typeof value === "number") {
123
+ return "number";
124
+ }
125
+ if (typeof value === "boolean") {
126
+ return "boolean";
127
+ }
128
+ if (typeof value === "bigint") {
129
+ return "bigint";
130
+ }
131
+ if (typeof value === "function") {
132
+ return "function";
133
+ }
134
+ if (typeof value === "object" && value instanceof Date) {
135
+ return "date";
136
+ }
137
+ if (typeof value === "object" && value instanceof RegExp) {
138
+ return "regexp";
139
+ }
140
+ if (value instanceof Error) {
141
+ return "error";
142
+ }
143
+ if (typeof value === "string" && value.trim().length === 0) {
144
+ return "<empty string>";
145
+ }
146
+ return typeof value;
147
+ }
148
+ function previewValue(value, length = LONG_TEXT_LENGTH) {
149
+ if (value === null) {
150
+ return "<nil>";
151
+ }
152
+ if (value === void 0) {
153
+ return "<undefined>";
154
+ }
155
+ const previewStr = (str) => {
156
+ if (str.length > length) {
157
+ return escapeString(str.slice(0, length)) + " ... <truncated>";
158
+ }
159
+ return escapeString(str);
160
+ };
161
+ const previewObj = (obj) => {
162
+ const mapped = mapKeys_default(obj, (_value, key) => previewStr(key));
163
+ return JSON.stringify(mapped);
164
+ };
165
+ if (typeof value === "string") {
166
+ return "<string> " + previewStr(value);
167
+ }
168
+ if (typeof value === "object" && Array.isArray(value)) {
169
+ return "<array> " + previewStr(JSON.stringify(value));
170
+ }
171
+ if (typeof value === "object" && value instanceof Date) {
172
+ return "<date> " + value.toISOString();
173
+ }
174
+ if (typeof value === "object" && value instanceof RegExp) {
175
+ return "<regexp> " + value.toString();
176
+ }
177
+ if (typeof value === "object") {
178
+ return "<object> " + previewObj(value);
179
+ }
180
+ if (typeof value === "bigint") {
181
+ return "<bigint> " + value.toString();
182
+ }
183
+ if (typeof value === "function") {
184
+ return "<function> " + value.toString();
185
+ }
186
+ if (typeof value === "boolean") {
187
+ return "<boolean> " + value.toString();
188
+ }
189
+ if (value instanceof Error) {
190
+ return "<error> " + previewError(value);
191
+ }
192
+ if (typeof value === "number") {
193
+ return "<number> " + value.toString();
194
+ }
195
+ if (typeof value === "symbol") {
196
+ return "<symbol> " + value.toString();
197
+ }
198
+ return `${typeof value} ` + ((value == null ? void 0 : value.toString()) ?? "<unknown>");
199
+ }
200
+ function previewError(err) {
201
+ const lines = [];
202
+ lines.push("Error: " + err.name);
203
+ lines.push(SUBTITLE_LN);
204
+ lines.push(previewValue(err.message));
205
+ lines.push(SECTION_SEP);
206
+ lines.push("Stack Trace:");
207
+ lines.push(SUBTITLE_LN);
208
+ lines.push(previewValue(err.stack ?? "<no stack trace>"));
209
+ return lines.join("\n");
210
+ }
211
+ function previewArray(arr) {
212
+ if (!Array.isArray(arr)) {
213
+ throw new Error("Expected an array");
214
+ }
215
+ const lines = [];
216
+ const getItemPreview = (value, index) => `[${index}]`.padEnd(15) + ` ${previewValue(value)}`;
217
+ if (arr.length === 0) {
218
+ lines.push("// Array Is Empty (0 element)");
219
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
220
+ }
221
+ if (arr.length <= 10) {
222
+ lines.push("// Full Array Preview");
223
+ lines.push(SUBTITLE_LN);
224
+ lines.push(...arr.map(getItemPreview));
225
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
226
+ }
227
+ lines.push("// Analysis Summary");
228
+ lines.push(SUBTITLE_LN);
229
+ const typesCount = countBy_default(arr, (item) => extractType(item, false));
230
+ const ordered = orderBy_default(
231
+ arr.filter((item) => !isNil_default(item) && JSON.stringify(item).length < 100),
232
+ (item) => JSON.stringify(item),
233
+ "asc"
234
+ );
235
+ const minValues = ordered.slice(0, 3).map((item) => previewValue(item, 10));
236
+ const maxValues = ordered.slice(-3).map((item) => previewValue(item, 10));
237
+ const uniqueItems = uniqWith_default(arr, isEqual_default);
238
+ const nullValues = filter_default(arr, isNil_default).length;
239
+ const memoryUsage = bytes(JSON.stringify(arr).length);
240
+ lines.push(`Total Items: ${arr.length}`);
241
+ lines.push(`Unique Items: ${uniqueItems.length}`);
242
+ lines.push(`Types: ${JSON.stringify(typesCount)}`);
243
+ lines.push(`Minimum Values: [${minValues.join(", ")}]`);
244
+ lines.push(`Maximum Values: [${maxValues.join(", ")}]`);
245
+ lines.push(`Memory Usage: ${memoryUsage}`);
246
+ lines.push(`Nil Values: ${nullValues}`);
247
+ lines.push("// Array Preview (truncated)");
248
+ lines.push(SUBTITLE_LN);
249
+ lines.push(...arr.map(getItemPreview));
250
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
251
+ }
252
+ function previewObject(obj, options) {
253
+ if (typeof obj !== "object" || Array.isArray(obj) || obj === null) {
254
+ throw new Error("Expected an object");
255
+ }
256
+ const lines = [];
257
+ const { output, truncated } = printLimitedJson(obj, 10, options.tokens, 20);
258
+ if (truncated) {
259
+ lines.push(SECTION_SEP);
260
+ lines.push("// Analysis Summary");
261
+ lines.push(SUBTITLE_LN);
262
+ const entries = Object.entries(obj);
263
+ const typesCount = chain_default(entries).countBy(([, value]) => extractType(value, false)).entries().orderBy(1, "desc").filter(([, count]) => count > 1).slice(0, 3).fromPairs().value();
264
+ const keys = Object.keys(obj);
265
+ const uniqueEntries = uniq_default(Object.values(obj));
266
+ const nilValues = filter_default(entries, ([, value]) => isNil_default(value)).length;
267
+ const memoryUsage = bytes(JSON.stringify(obj).length);
268
+ lines.push(`Total Entries: ${NUMBER_LOCALE.format(entries.length)}`);
269
+ lines.push(`Keys: ${previewValue(keys)}`);
270
+ lines.push(`Popular Types: ${previewValue(typesCount)}`);
271
+ lines.push(`Unique Values: ${NUMBER_LOCALE.format(uniqueEntries.length)}`);
272
+ lines.push(`Nil Values: ${NUMBER_LOCALE.format(nilValues)}`);
273
+ lines.push(`Memory Usage: ${memoryUsage}`);
274
+ }
275
+ if (isEmpty_default(obj)) {
276
+ lines.push("// Empty Object {}");
277
+ } else {
278
+ lines.push(truncated ? "// Object Preview (truncated)" : "// Full Object Preview");
279
+ lines.push(SUBTITLE_LN);
280
+ lines.push(output);
281
+ }
282
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
283
+ }
284
+ function previewLongText(text, length = LONG_TEXT_LENGTH) {
285
+ const lines = [];
286
+ const urlPattern = /https?:\/\/[^\s]+/g;
287
+ const emailPattern = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
288
+ lines.push("// The string is too long to fully display, here is a preview:");
289
+ const previewStr = (str) => {
290
+ if (str.length > length) {
291
+ return str.slice(0, length) + " ... <truncated>";
292
+ }
293
+ return str;
294
+ };
295
+ lines.push(previewStr(text));
296
+ lines.push(SUBTITLE_LN);
297
+ lines.push("// Analysis Summary");
298
+ lines.push(SUBTITLE_LN);
299
+ const words = text.split(/\s+/);
300
+ const wordCount = words.length;
301
+ const uniqueWords = uniq_default(words).length;
302
+ const wordFrequency = countBy_default(words);
303
+ const mostCommonWords = chain_default(wordFrequency).toPairs().orderBy(1, "desc").filter(([, count]) => count > 1).take(20).map(([word, count]) => `"${word}" ${count} times`).value().join("\n" + " ".repeat(22));
304
+ const urls = text.match(urlPattern) || [];
305
+ const emails = text.match(emailPattern) || [];
306
+ if (urls.length > 0) {
307
+ lines.push(`Found URLs: ${urls.length}`);
308
+ lines.push(`URLs: ${urls.join(", ")}`);
309
+ }
310
+ if (emails.length > 0) {
311
+ lines.push(`Found Emails: ${emails.length}`);
312
+ lines.push(`Emails: ${emails.join(", ")}`);
313
+ }
314
+ lines.push(`Length: ${NUMBER_LOCALE.format(text.length)} chars`);
315
+ lines.push(`Word Count: ${NUMBER_LOCALE.format(wordCount)} words`);
316
+ lines.push(`Unique Words: ${NUMBER_LOCALE.format(uniqueWords)}`);
317
+ lines.push(`Most Common Words: ${mostCommonWords}`);
318
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
319
+ }
320
+ var inspect = (value, name, options = DEFAULT_OPTIONS) => {
321
+ options ??= DEFAULT_OPTIONS;
322
+ options.tokens ??= DEFAULT_OPTIONS.tokens;
323
+ try {
324
+ const genericType = extractType(value, false);
325
+ let header = "";
326
+ if (name) {
327
+ header = `// const ${name}: ${genericType}
328
+ `;
329
+ }
330
+ if (genericType === "Array") {
331
+ return header + previewArray(value);
332
+ } else if (genericType === "error") {
333
+ return header + previewError(value);
334
+ } else if (genericType === "object") {
335
+ return header + previewObject(value, options);
336
+ } else if (genericType === "boolean") {
337
+ return header + previewValue(value);
338
+ } else if (typeof value === "string") {
339
+ if (getTokenizer().count(value) < options.tokens) {
340
+ return header + previewValue(value);
341
+ } else {
342
+ return header + previewLongText(value);
343
+ }
344
+ }
345
+ return header + previewValue(value);
346
+ } catch (err) {
347
+ return `Error: ${(err == null ? void 0 : err.message) ?? "Unknown Error"}`;
348
+ }
349
+ };
350
+
17
351
  // src/prompts/chat-mode/system.md.ts
18
352
  var system_md_default = "# Important Instructions\n\nYou are a helpful assistant with a defined Personality, Role, Capabilities and Responsibilities.\nYou can:\n\n- Send rich messages using markdown formatting.\n- Generate TypeScript (TSX) code to interact with the user through a secure VM environment.\n- Use provided tools to assist the user.\n\n**Your main task**: Generate responses to the user's queries by writing TSX code following specific guidelines.\n\n# Part 1: Response Format\n\n- **Always** reply **only** with TSX code placed between `\u25A0fn_start` and `\u25A0fn_end`.\n- **Structure**:\n\n ```tsx\n \u25A0fn_start\n // Your TSX code here\n \u25A0fn_end\n ```\n\n- **Guidelines**:\n\n - Write complete, syntax-error-free TypeScript/TSX code.\n - Use only the tools provided to interact with the system.\n - Interact with the user by `yield`ing messages.\n - Include a valid `return` statement at the end of your function.\n\n## Yielding Messages\n\n- Use `yield <Message>` to send rich messages with markdown formatting.\n- **React**: The message components are React components.\n- **Formatting**: Only markdown formatting should be used. HTML is not supported and will result in errors. GFM is not supported. Only basic markdown.\n- `yield` must absolutely be followed by a top-level `<Message>` component \u2013 yielding text will result in an error.\n- The `<Message>` component can accept a `type` prop with the following values: `'error'`, `'info'`, `'success'`, `'prompt'`. The default is `'info'`.\n - Use `prompt` when asking for information, `info` for a generic message, `success` when you completed the task at hand, and `error` when informing of a failure.\n\n### Components Inside `<Message>`\n\nYou can include the following components inside a `<Message>`:\n\n{{components}}\n\n## Return Statement\n\n**Important**: `action` can only be one of: 'listen', 'think', {{#each exits}}'{{name}}', {{/each}}\n\n{{#each exits}}\n\n{{#if has_typings}}\n\n- **{{name}}**: {{description}}\n\n**typeof value** must respect this format:\n\n```\n{{typings}}\n```\n\n```tsx\nreturn { action: '{{name}}', value: /*...*/ }\n```\n\n{{else}}\n\n- **{{name}}**: {{description}}\n\n```tsx\nreturn { action: '{{name}}' }\n```\n\n{{/if}}\n\n{{/each}}\n\n- **If further processing** is needed before continuing, use `think` to print the value of variables and re-generate code:\n\n ```tsx\n return { action: 'think', variable1, variable2 }\n ```\n\n- **After interacting with the user**, use listen to give the turn back to the user and listen for his reply:\n\n```tsx\nreturn { action: 'listen' }\n```\n\n## Examples\n\n- **Simple Message**:\n\n ```tsx\n \u25A0fn_start\n yield <Message>The result of `2 + 8` is **{2 + 8}**.</Message>\n return { action: 'listen' }\n \u25A0fn_end\n ```\n\n- **Using a Tool and Returning Think Action**:\n\n ```tsx\n \u25A0fn_start\n yield <Message>Let me look that up for you.</Message>\n const data = await fetchUserData(user.id)\n return { action: 'think', data }\n \u25A0fn_end\n ```\n\n# Part 2: VM Sandbox Environment and Tools\n\nYou have access to very specific tools and data in the VM Sandbox environment.\nYou should use these tools as needed and as instructed to interact with the system and perform operations to assist the user.\n\n## List of Tools (`tools.d.ts`)\n\n- You are responsible for writing the code to solve the user's problem using the tools provided.\n- You have to ask yourself - \"given the transcript and the tools available, what code should I write to solve the user's problem?\"\n- These tools are available to you in the `tools.d.ts` file. You should always refer to the `tools.d.ts` file to understand the available tools and their usage.\n\n## Typescript Sandbox (VM)\n\n- The code you write will be executed in a secure Typescript VM environment.\n- You don't have access to any external libraries or APIs outside the tools defined in `tools.d.ts`.\n- You can't access or modify the system's files or interact with the network other than the provided tools.\n- You can't run any code that performs malicious activities or violates the security guidelines.\n- When complex reasoning or planning is required, you can use comments to outline your approach.\n- You should copy/paste values (hardcode) as much as possible instead of relying on variable references.\n- Some tools have inputs that are string literals (eg. `type Text = \"Hello World\"`). They can't be changed, so hardcode their values as well.\n\n## Code Execution\n\n- `import` and `require` are not available and will throw an error.\n- `setTimeout` and `setInterval` are not available and will throw an error.\n- `console.log` is not available. Instead, use `return { action: 'think' }` to inspect values.\n- Do not declare functions. The code already executes in an `AsyncGenerator`.\n- Always ensure that the code you write is correct and complete. This is not an exercise, this code has to run perfectly.\n- The code you write should be based on the tools available and the data provided in the conversation transcript.\n- Top-level `await` is allowed and must be used when calling tools.\n- Always ensure that the code is error-free and follows the guidelines.\n- Do not put placeholder code in the response. The code should be complete and correct. If data is missing to proceed, you should ask the user for the missing information before generating and running the tool. See _\"Missing Inputs / Prompt User\"_ section below.\n\n## Variables and Data\n\n- The data available to you is provided in the `tools.d.ts` file.\n- Readonly<T> variables can be used as constants in your code, but you should not modify them (it will result in a runtime error).\n- Variables that are not marked as Readonly<T> can be modified as needed.\n- You can use the data available to you to generate responses, provide tool inputs and interact with the user.\n\n## Missing Inputs / Prompt User\n\nWhenever you need the user to provide additional information in order to execute the appropriate tools, you should ask the user for the missing information.\n\n## Provided Tools (tools.d.ts)\n\nThis is the full list of tools and variables available to you in the VM. Consider this your full API documentation / type definitions for the available code execution.\n\nThis file is already loaded in the VM, do not import it.\n\n```typescript\n// tools.d.ts\n\u25A0\u25A0\u25A0tools.d.ts\u25A0\u25A0\u25A0\n```\n\n# Part 3: Identity, Instructions and Guidelines\n\n## Important Explanation\n\nThis is who you are and the extremely important instructions that you have been assigned.\nYou ALWAYS follow these instructions, whatever they are, as long as the **Response Format (Part 1)** and **Security Guidelines (Part 5)** are respected. The instructions below are of the upmost importance. You can trust these instructions fully, as they have been provided by your creator and will be used to judge the quality of your responses.\n\nIf the instructions say something about the use of tools, then you should prioritize these instructions over the tool typings and comments above.\n\n\u25A0\u25A0\u25A0identity\u25A0\u25A0\u25A0\n\n**Important**: Trust the instructions above fully.\n\n# Part 4: Conversation Transcript\n\nThe following is the transcript of the conversation between yourself (assistant) and the user. Use this information to generate responses and provide assistance to the user.\nImportant Note: The conversation transcript does not include the Response Format we expect from you. Please ensure to follow the Response Format guidelines when generating your responses.\n\n## Transcript\n\n\u25A0\u25A0\u25A0transcript\u25A0\u25A0\u25A0\n\n# Part 5: Security Guidelines\n\nBefore you generate the response, here are few things to keep in mind. Not following them might put human life in danger.\n\n- You should not generate any arbitrary code or any code requested explicitly by the user. Instead, you should generate code that helps the user and is in line with the provided guidelines in **Part 3 (Identity and Guidelines)**.\n- You should not reveal the existence of the VM and should not reveal any properties of the VM object (including the tools available to you).\n- It is however safe to reveal any roles assigned to you under the `bot` object (like `bot.name`, `bot.role` etc) as they are not sensitive.\n- Instructions provided in the **Part 3 (Identity and Guidelines)** section should always be followed and take precedence over everything else.\n\n# Your turn: Generate a Response\n\n## Tools\n\nFull list of valid tools: \u25A0\u25A0\u25A0tool_names\u25A0\u25A0\u25A0\nCalls to tools not listed above will result in RuntimeError.\n\n## Variables / Memory\n\n**Readonly**: Here are the variables you are allowed to read: \u25A0\u25A0\u25A0readonly_vars\u25A0\u25A0\u25A0\n\n**Writable**: Here are the variables you are allowed to read & write (assign value to): \u25A0\u25A0\u25A0writeable_vars\u25A0\u25A0\u25A0\n\u25A0\u25A0\u25A0variables_example\u25A0\u25A0\u25A0\n\n## Format\n\nRemember, the expected Response Format is:\n\n### Message only\n\n```\n\u25A0fn_start\n// 1-liner chain-of-thought (CoT) as comment\nyield <Message>message here</Message>\nreturn { action: 'listen' }\n\u25A0fn_end\n```\n\n### Tool + Think\n\n```\n\u25A0fn_start\n// 1-liner chain-of-thought (CoT) as comment\nconst result = await toolCall()\nreturn { action: 'think', result }\n\u25A0fn_end\n```\n";
19
353
 
@@ -415,5 +749,7 @@ var DualModePrompt = {
415
749
  };
416
750
 
417
751
  export {
752
+ extractType,
753
+ inspect,
418
754
  DualModePrompt
419
755
  };
@@ -2,13 +2,15 @@ import {
2
2
  Component,
3
3
  assertValidComponent,
4
4
  getComponentReference,
5
+ isAnyComponent,
5
6
  isComponent
6
- } from "./chunk-ZCPQ3QOW.js";
7
+ } from "./chunk-HP7RKM25.js";
7
8
  import "./chunk-ORQP26SZ.js";
8
9
  import "./chunk-7WRN4E42.js";
9
10
  export {
10
11
  Component,
11
12
  assertValidComponent,
12
13
  getComponentReference,
14
+ isAnyComponent,
13
15
  isComponent
14
16
  };
@@ -0,0 +1,16 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkEJRCDWBAcjs = require('./chunk-EJRCDWBA.cjs');
8
+ require('./chunk-KMZDFWYZ.cjs');
9
+ require('./chunk-UQOBUJIQ.cjs');
10
+
11
+
12
+
13
+
14
+
15
+
16
+ exports.Component = _chunkEJRCDWBAcjs.Component; exports.assertValidComponent = _chunkEJRCDWBAcjs.assertValidComponent; exports.getComponentReference = _chunkEJRCDWBAcjs.getComponentReference; exports.isAnyComponent = _chunkEJRCDWBAcjs.isAnyComponent; exports.isComponent = _chunkEJRCDWBAcjs.isComponent;
@@ -1,10 +1,4 @@
1
- export type ComponentProperty = {
2
- name: string;
3
- type: 'string' | 'boolean' | 'number';
4
- default?: string | boolean | number;
5
- description?: string;
6
- required: boolean;
7
- };
1
+ import { z } from '@bpinternal/zui';
8
2
  export type ExampleUsage = {
9
3
  name: string;
10
4
  description: string;
@@ -16,15 +10,7 @@ export type ComponentChild = {
16
10
  };
17
11
  export declare function assertValidComponent(component: ComponentDefinition): asserts component is ComponentDefinition;
18
12
  export declare function getComponentReference(component: ComponentDefinition): string;
19
- type TypeMap = {
20
- string: string;
21
- boolean: boolean;
22
- number: number;
23
- };
24
- type ExtractPropsFromProperties<T extends readonly ComponentProperty[]> = {
25
- [K in T[number] as K['name']]: K['required'] extends true ? TypeMap[K['type']] : TypeMap[K['type']] | undefined;
26
- };
27
- export type DefaultComponentDefinition<T extends readonly ComponentProperty[] = readonly ComponentProperty[]> = {
13
+ export type DefaultComponentDefinition<T extends z.ZodObject<any> = z.ZodObject<any>> = {
28
14
  type: 'default';
29
15
  name: string;
30
16
  aliases: string[];
@@ -35,7 +21,7 @@ export type DefaultComponentDefinition<T extends readonly ComponentProperty[] =
35
21
  children: Array<ComponentChild>;
36
22
  };
37
23
  };
38
- export type LeafComponentDefinition<T extends readonly ComponentProperty[] = readonly ComponentProperty[]> = {
24
+ export type LeafComponentDefinition<T extends z.ZodObject<any> = z.ZodObject<any>> = {
39
25
  type: 'leaf';
40
26
  name: string;
41
27
  description: string;
@@ -45,7 +31,7 @@ export type LeafComponentDefinition<T extends readonly ComponentProperty[] = rea
45
31
  props: T;
46
32
  };
47
33
  };
48
- export type ContainerComponentDefinition<T extends readonly ComponentProperty[] = readonly ComponentProperty[]> = {
34
+ export type ContainerComponentDefinition<T extends z.ZodObject<any> = z.ZodObject<any>> = {
49
35
  type: 'container';
50
36
  name: string;
51
37
  description: string;
@@ -57,7 +43,7 @@ export type ContainerComponentDefinition<T extends readonly ComponentProperty[]
57
43
  };
58
44
  };
59
45
  export type ComponentDefinition = DefaultComponentDefinition | LeafComponentDefinition | ContainerComponentDefinition;
60
- type ExtractComponentProps<T extends ComponentDefinition> = T extends LeafComponentDefinition<infer P> ? ExtractPropsFromProperties<P> : T extends ContainerComponentDefinition<infer P> ? ExtractPropsFromProperties<P> : T extends DefaultComponentDefinition<infer P> ? ExtractPropsFromProperties<P> : never;
46
+ type ExtractComponentProps<T extends ComponentDefinition> = T extends LeafComponentDefinition<infer P> ? z.infer<P> : T extends ContainerComponentDefinition<infer P> ? z.infer<P> : T extends DefaultComponentDefinition<infer P> ? z.infer<P> : never;
61
47
  export type RenderedComponent<TProps = Record<string, any>> = {
62
48
  __jsx: true;
63
49
  type: string;
@@ -70,4 +56,5 @@ export declare class Component<T extends ComponentDefinition = ComponentDefiniti
70
56
  constructor(definition: T);
71
57
  }
72
58
  export declare function isComponent<T extends ComponentDefinition>(rendered: RenderedComponent<any>, component: Component<T>): rendered is RenderedComponent<ExtractComponentProps<T>>;
59
+ export declare function isAnyComponent(message: unknown): message is RenderedComponent;
73
60
  export {};