llmz 0.1.5 → 0.2.0
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 +185 -98
- package/dist/chat.d.ts +34 -0
- package/dist/{chunk-TIZWOIDF.js → chunk-33AB6SVX.js} +134 -76
- package/dist/{chunk-EFEF2AL7.js → chunk-DH35WO5G.js} +93 -556
- package/dist/chunk-E5NHK3FS.js +1637 -0
- package/dist/{chunk-L74UZONX.js → chunk-HM5H556L.js} +3 -1
- package/dist/chunk-I56MPOVG.cjs +62 -0
- package/dist/{chunk-C7T6OJB4.cjs → chunk-IKLFMVSW.cjs} +144 -86
- package/dist/chunk-KWQTYXAT.js +62 -0
- package/dist/{chunk-JXD2KJVB.cjs → chunk-WWZ2W4WR.cjs} +103 -566
- package/dist/chunk-YGKQEVQQ.cjs +1637 -0
- package/dist/{chunk-ZPHRTTQX.cjs → chunk-YQT5G77W.cjs} +3 -1
- package/dist/compiler/compiler.d.ts +7 -2
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/plugins/async-wrapper.d.ts +11 -0
- package/dist/component-2NYFY6CW.cjs +14 -0
- package/dist/{component-2Z3KLWLX.js → component-ASNZHQUR.js} +3 -7
- package/dist/component.d.ts +3 -10
- package/dist/context.d.ts +88 -2
- package/dist/{dual-modes-HEXPFVUE.js → dual-modes-RMF7V7ZQ.js} +2 -4
- package/dist/dual-modes-ZZY6QPYT.cjs +10 -0
- package/dist/{execute-22PSGL7P.cjs → execute-BXPFSEVX.cjs} +331 -87
- package/dist/{execute-ZENBZBWL.js → execute-HIRXXR6X.js} +321 -77
- package/dist/index.cjs +502 -27
- package/dist/index.d.ts +8 -5
- package/dist/index.js +491 -16
- package/dist/message-stream/index.d.ts +9 -0
- package/dist/message-stream/instructions.d.ts +22 -0
- package/dist/message-stream/normalizer.d.ts +21 -0
- package/dist/message-stream/parser.d.ts +81 -0
- package/dist/message-stream/registry.d.ts +14 -0
- package/dist/message-stream/replayable.d.ts +27 -0
- package/dist/message-stream/sanitize.d.ts +10 -0
- package/dist/message-stream/stream.d.ts +54 -0
- package/dist/message-stream/types.d.ts +96 -0
- package/dist/message-stream/validator.d.ts +23 -0
- package/dist/message-stream/validator.test.d.ts +1 -0
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/chat-mode/user.md.d.ts +1 -1
- package/dist/prompts/common.d.ts +5 -5
- package/dist/prompts/prompt.d.ts +43 -6
- package/dist/prompts/protocol.d.ts +18 -0
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/user.md.d.ts +1 -1
- package/dist/result.d.ts +31 -0
- package/dist/runtime/execute.test.d.ts +1 -0
- package/dist/runtime/generate.d.ts +24 -1
- package/dist/runtime/interpret-result.d.ts +10 -0
- package/dist/runtime/types.d.ts +29 -4
- package/dist/truncator-7PGEGCHV.cjs +12 -0
- package/dist/{truncator-3U2QUUJJ.js → truncator-OZOBNYON.js} +3 -1
- package/dist/truncator.d.ts +2 -0
- package/dist/types.d.ts +8 -1
- package/dist/vm/drivers/quickjs.d.ts +2 -0
- package/dist/vm/index.d.ts +7 -0
- package/dist/vm/instrument.d.ts +1 -1
- package/dist/{vm-PYCKS77H.js → vm-44H4UKI2.js} +5 -4
- package/dist/{vm-VHB67FVH.cjs → vm-A3OTQVIR.cjs} +4 -3
- package/package.json +5 -5
- package/dist/chunk-2O3UTPVH.js +0 -813
- package/dist/chunk-3T5IU7OU.js +0 -186
- package/dist/chunk-BBX2LDZE.cjs +0 -813
- package/dist/chunk-CQ3UJW76.cjs +0 -186
- package/dist/compiler/plugins/async-iterator.d.ts +0 -6
- package/dist/compiler/plugins/braces-tsx.d.ts +0 -3
- package/dist/compiler/plugins/html-to-markdown.d.ts +0 -21
- package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +0 -5
- package/dist/compiler/plugins/jsx-undefined-vars.d.ts +0 -14
- package/dist/component-NNHBHD72.cjs +0 -18
- package/dist/dual-modes-LLIWZCHC.cjs +0 -12
- package/dist/truncator-3ZN7W6NB.cjs +0 -10
- /package/dist/{compiler/plugins/html-to-markdown.test.d.ts → message-stream/instructions.test.d.ts} +0 -0
- /package/dist/{compiler/plugins/jsx-undefined-vars.test.d.ts → message-stream/normalizer.test.d.ts} +0 -0
- /package/dist/{component.test.d.ts → message-stream/parser.test.d.ts} +0 -0
- /package/dist/{vm/vm-jsx.test.d.ts → message-stream/stream.test.d.ts} +0 -0
package/dist/chunk-CQ3UJW76.cjs
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunk5ZF6NTYIcjs = require('./chunk-5ZF6NTYI.cjs');
|
|
6
|
-
|
|
7
|
-
// src/component.ts
|
|
8
|
-
var _zui = require('@bpinternal/zui');
|
|
9
|
-
function assertValidComponent(component) {
|
|
10
|
-
if (!component.name) {
|
|
11
|
-
throw new Error("Component must have a name");
|
|
12
|
-
}
|
|
13
|
-
const nameRegex = /^[A-Z]{3,50}$/i;
|
|
14
|
-
if (!nameRegex.test(component.name)) {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`Component name "${component.name}" must be 3-50 characters long and start with an uppercase letter`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
if (component.aliases) {
|
|
20
|
-
for (const alias of component.aliases) {
|
|
21
|
-
if (!nameRegex.test(alias)) {
|
|
22
|
-
throw new Error(`Alias "${alias}" must be 3-50 characters long and start with an uppercase letter`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (!component.description) {
|
|
27
|
-
throw new Error("Component must have a description");
|
|
28
|
-
}
|
|
29
|
-
if (!component.examples || component.examples.length === 0) {
|
|
30
|
-
throw new Error("Component must have at least one example");
|
|
31
|
-
}
|
|
32
|
-
if (component.type === "default" && !component.default) {
|
|
33
|
-
throw new Error("Default component must have default props and children");
|
|
34
|
-
}
|
|
35
|
-
if (component.type === "leaf" && !component.leaf) {
|
|
36
|
-
throw new Error("Leaf component must have leaf props");
|
|
37
|
-
}
|
|
38
|
-
if (component.type === "container" && !component.container) {
|
|
39
|
-
throw new Error("Container component must have container props and children");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
var getDefaultValue = (schema) => {
|
|
43
|
-
if (schema._def.defaultValue !== void 0) {
|
|
44
|
-
if (typeof schema._def.defaultValue === "function") {
|
|
45
|
-
return String(schema._def.defaultValue()).toString();
|
|
46
|
-
} else {
|
|
47
|
-
return String(schema._def.defaultValue);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return "";
|
|
51
|
-
};
|
|
52
|
-
function getComponentReference(component) {
|
|
53
|
-
let doc = `### <${component.name}>
|
|
54
|
-
|
|
55
|
-
`;
|
|
56
|
-
doc += `${component.description}
|
|
57
|
-
|
|
58
|
-
`;
|
|
59
|
-
const getPropsDoc = (props) => {
|
|
60
|
-
const shape = props.shape;
|
|
61
|
-
if (Object.keys(shape).length === 0)
|
|
62
|
-
return "_No props._\n\n";
|
|
63
|
-
const zodTypeToTsType = {
|
|
64
|
-
ZodString: "string",
|
|
65
|
-
ZodNumber: "number",
|
|
66
|
-
ZodBoolean: "boolean",
|
|
67
|
-
ZodEnum: "enum",
|
|
68
|
-
ZodArray: "array",
|
|
69
|
-
ZodObject: "object",
|
|
70
|
-
ZodDate: "date",
|
|
71
|
-
ZodBigInt: "bigint",
|
|
72
|
-
ZodSymbol: "symbol",
|
|
73
|
-
ZodUndefined: "undefined",
|
|
74
|
-
ZodNull: "null",
|
|
75
|
-
ZodVoid: "void",
|
|
76
|
-
ZodNever: "never",
|
|
77
|
-
ZodUnknown: "unknown",
|
|
78
|
-
ZodAny: "any"
|
|
79
|
-
};
|
|
80
|
-
return Object.entries(shape).map(([name, schema]) => {
|
|
81
|
-
const naked = schema.naked();
|
|
82
|
-
const zodType = naked._def.typeName;
|
|
83
|
-
const defValue = getDefaultValue(schema);
|
|
84
|
-
const typings = _zui.z.is.zuiEnum(naked) ? naked._def.values.map((x) => `"${x}"`).join(" | ") : zodTypeToTsType[zodType] || zodType;
|
|
85
|
-
const required = !schema.isOptional() ? "**(required)**" : "(optional)";
|
|
86
|
-
const def = defValue ? ` _Default: \`${defValue}\`_` : "";
|
|
87
|
-
const description = schema.description || schema.naked().description || (schema == null ? void 0 : schema._def.description) || "";
|
|
88
|
-
return `- \`${name}: ${typings}\` ${required} \u2014 ${description}${def}`;
|
|
89
|
-
}).join("\n") + "\n\n";
|
|
90
|
-
};
|
|
91
|
-
const getChildrenDoc = (children) => {
|
|
92
|
-
if (children.length === 0)
|
|
93
|
-
return "_None allowed._\n\n";
|
|
94
|
-
return "Can contain:\n" + children.map((child) => `- ${child.description} \u2014 \`<${child.component.name}>\``).join("\n") + "\n\n";
|
|
95
|
-
};
|
|
96
|
-
const getExamplesDoc = (examples) => {
|
|
97
|
-
if (!examples.length)
|
|
98
|
-
return "";
|
|
99
|
-
return "**Examples:**\n\n" + examples.map((example) => `**${example.name}** \u2014 ${example.description}
|
|
100
|
-
|
|
101
|
-
\`\`\`tsx
|
|
102
|
-
${example.code.trim()}
|
|
103
|
-
\`\`\`
|
|
104
|
-
`).join("\n");
|
|
105
|
-
};
|
|
106
|
-
switch (component.type) {
|
|
107
|
-
case "leaf":
|
|
108
|
-
doc += "**Props:**\n\n";
|
|
109
|
-
doc += getPropsDoc(component.leaf.props);
|
|
110
|
-
doc += "**Children:**\n\n";
|
|
111
|
-
doc += getChildrenDoc([]);
|
|
112
|
-
doc += getExamplesDoc(component.examples);
|
|
113
|
-
break;
|
|
114
|
-
case "container":
|
|
115
|
-
doc += "**Props:**\n\n";
|
|
116
|
-
doc += getPropsDoc(component.container.props);
|
|
117
|
-
doc += "**Children:**\n\n";
|
|
118
|
-
doc += getChildrenDoc(component.container.children);
|
|
119
|
-
doc += getExamplesDoc(component.examples);
|
|
120
|
-
break;
|
|
121
|
-
case "default":
|
|
122
|
-
default:
|
|
123
|
-
doc += "**Props:**\n\n";
|
|
124
|
-
doc += getPropsDoc(component.default.props);
|
|
125
|
-
doc += getExamplesDoc(component.examples);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
return doc.trim();
|
|
129
|
-
}
|
|
130
|
-
var Component = class {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// phantom type for inference
|
|
134
|
-
constructor(definition) {
|
|
135
|
-
assertValidComponent(definition);
|
|
136
|
-
this.definition = definition;
|
|
137
|
-
}
|
|
138
|
-
render(props, children = []) {
|
|
139
|
-
return _chunk5ZF6NTYIcjs.createJsxComponent.call(void 0, { type: this.definition.name, props, children });
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
function isComponent(rendered, component) {
|
|
143
|
-
return _chunk5ZF6NTYIcjs.isJsxComponent.call(void 0, component.definition.name, rendered);
|
|
144
|
-
}
|
|
145
|
-
function isAnyComponent(message) {
|
|
146
|
-
return _chunk5ZF6NTYIcjs.isAnyJsxComponent.call(void 0, message);
|
|
147
|
-
}
|
|
148
|
-
function renderToTsx(component) {
|
|
149
|
-
const props = Object.entries(component.props).map(([key, value]) => {
|
|
150
|
-
if (typeof value === "string") {
|
|
151
|
-
return `${key}="${value}"`;
|
|
152
|
-
}
|
|
153
|
-
if (typeof value === "boolean") {
|
|
154
|
-
return value ? key : "";
|
|
155
|
-
}
|
|
156
|
-
if (typeof value === "number") {
|
|
157
|
-
return `${key}={${value}}`;
|
|
158
|
-
}
|
|
159
|
-
if (value === null || value === void 0) {
|
|
160
|
-
return "";
|
|
161
|
-
}
|
|
162
|
-
if (typeof value === "object") {
|
|
163
|
-
return `${key}={${JSON.stringify(value)}}`;
|
|
164
|
-
}
|
|
165
|
-
return `${key}={${String(value)}}`;
|
|
166
|
-
}).filter(Boolean).join(" ");
|
|
167
|
-
const children = component.children.map((child) => {
|
|
168
|
-
if (typeof child === "string") {
|
|
169
|
-
return child;
|
|
170
|
-
}
|
|
171
|
-
if (isAnyComponent(child)) {
|
|
172
|
-
return renderToTsx(child);
|
|
173
|
-
}
|
|
174
|
-
return String(child);
|
|
175
|
-
}).join("");
|
|
176
|
-
return `<${component.type}${props ? " " + props : ""}>${children}</${component.type}>`;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
exports.assertValidComponent = assertValidComponent; exports.getComponentReference = getComponentReference; exports.Component = Component; exports.isComponent = isComponent; exports.isAnyComponent = isAnyComponent; exports.renderToTsx = renderToTsx;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const USER_CODE_START_MARKER = "/* __LLMZ_USER_CODE_START__ */";
|
|
2
|
-
export declare const USER_CODE_END_MARKER = "/* __LLMZ_USER_CODE_END__ */";
|
|
3
|
-
export declare const AsyncIterator: {
|
|
4
|
-
preProcessing: (code: string) => string;
|
|
5
|
-
postProcessing: (code: string) => string;
|
|
6
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type PluginObj } from '@babel/core';
|
|
2
|
-
/**
|
|
3
|
-
* This plugin converts simple HTML tags in JSX text to markdown equivalents.
|
|
4
|
-
* Only handles basic formatting tags without attributes (except href/src).
|
|
5
|
-
*
|
|
6
|
-
* Supported conversions:
|
|
7
|
-
* - <strong>text</strong> -> **text**
|
|
8
|
-
* - <b>text</b> -> **text**
|
|
9
|
-
* - <em>text</em> -> *text*
|
|
10
|
-
* - <i>text</i> -> *text*
|
|
11
|
-
* - <u>text</u> -> __text__
|
|
12
|
-
* - <a href="url">text</a> -> [text](url)
|
|
13
|
-
* - <ul><li>item</li></ul> -> - item
|
|
14
|
-
* - <ol><li>item</li></ol> -> 1. item
|
|
15
|
-
* - <br>, <br/>, <br /> -> \n
|
|
16
|
-
* - <p>text</p> -> text\n\n
|
|
17
|
-
*
|
|
18
|
-
* Only converts tags that have no attributes (except href for links).
|
|
19
|
-
* Preserves complex HTML that can't be represented in simple markdown.
|
|
20
|
-
*/
|
|
21
|
-
export declare function htmlToMarkdownPlugin(): PluginObj;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type PluginObj } from '@babel/core';
|
|
2
|
-
/**
|
|
3
|
-
* This plugin transforms JSX expressions that reference undefined variables
|
|
4
|
-
* into safe fallbacks that display the variable name as a string.
|
|
5
|
-
*
|
|
6
|
-
* For example:
|
|
7
|
-
* <div>{content}</div>
|
|
8
|
-
* becomes:
|
|
9
|
-
* <div>{(() => { try { return content } catch { return 'content' } })()}</div>
|
|
10
|
-
*
|
|
11
|
-
* This prevents "variable is not defined" errors when the LLM generates JSX
|
|
12
|
-
* with variable references that don't exist in the actual execution scope.
|
|
13
|
-
*/
|
|
14
|
-
export declare function jsxUndefinedVarsPlugin(): PluginObj;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkCQ3UJW76cjs = require('./chunk-CQ3UJW76.cjs');
|
|
9
|
-
require('./chunk-5ZF6NTYI.cjs');
|
|
10
|
-
require('./chunk-HC2QZTVT.cjs');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.Component = _chunkCQ3UJW76cjs.Component; exports.assertValidComponent = _chunkCQ3UJW76cjs.assertValidComponent; exports.getComponentReference = _chunkCQ3UJW76cjs.getComponentReference; exports.isAnyComponent = _chunkCQ3UJW76cjs.isAnyComponent; exports.isComponent = _chunkCQ3UJW76cjs.isComponent; exports.renderToTsx = _chunkCQ3UJW76cjs.renderToTsx;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkBBX2LDZEcjs = require('./chunk-BBX2LDZE.cjs');
|
|
4
|
-
require('./chunk-KIN7Y247.cjs');
|
|
5
|
-
require('./chunk-CQ3UJW76.cjs');
|
|
6
|
-
require('./chunk-5ZF6NTYI.cjs');
|
|
7
|
-
require('./chunk-ZPHRTTQX.cjs');
|
|
8
|
-
require('./chunk-FPLSJF4S.cjs');
|
|
9
|
-
require('./chunk-HC2QZTVT.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.DualModePrompt = _chunkBBX2LDZEcjs.DualModePrompt;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkZPHRTTQXcjs = require('./chunk-ZPHRTTQX.cjs');
|
|
5
|
-
require('./chunk-FPLSJF4S.cjs');
|
|
6
|
-
require('./chunk-HC2QZTVT.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.truncateWrappedContent = _chunkZPHRTTQXcjs.truncateWrappedContent; exports.wrapContent = _chunkZPHRTTQXcjs.wrapContent;
|
/package/dist/{compiler/plugins/html-to-markdown.test.d.ts → message-stream/instructions.test.d.ts}
RENAMED
|
File without changes
|
/package/dist/{compiler/plugins/jsx-undefined-vars.test.d.ts → message-stream/normalizer.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|