llmz 0.0.4 → 0.0.6
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 +4 -0
- package/dist/chat.d.ts +17 -0
- package/dist/{chunk-LVKZYKTP.cjs → chunk-4I7UPBLN.cjs} +2 -2
- package/dist/{chunk-W6U2VXSF.cjs → chunk-6WT5VZBG.cjs} +348 -12
- package/dist/{chunk-5NVNEEYW.cjs → chunk-BEPRLBPK.cjs} +60 -16
- package/dist/chunk-CH5T6SPC.cjs +694 -0
- package/dist/{chunk-4EWY34YA.js → chunk-D3ESDRLH.js} +60 -16
- package/dist/{chunk-JK2LZW2G.cjs → chunk-EJRCDWBA.cjs} +45 -6
- package/dist/{chunk-ZCPQ3QOW.js → chunk-HP7RKM25.js} +45 -6
- package/dist/{chunk-S6WICIDW.js → chunk-S6FOL2HY.js} +2 -2
- package/dist/{chunk-TJQVC4CE.js → chunk-WLUVY5QU.js} +341 -5
- package/dist/chunk-XJNRORSK.js +694 -0
- package/dist/{component-LQDU72LX.js → component-R2Y74VUI.js} +3 -1
- package/dist/component-TSNW3SC7.cjs +16 -0
- package/dist/component.d.ts +6 -19
- package/dist/component.default.d.ts +131 -151
- package/dist/context.d.ts +13 -5
- package/dist/{dual-modes-YE4S2AIL.cjs → dual-modes-UHNDHNIF.cjs} +3 -4
- package/dist/{dual-modes-QHBOFWHM.js → dual-modes-ZUQKPJFH.js} +2 -3
- package/dist/{exit-IDKGZD7M.cjs → exit-KJ4COC5N.cjs} +2 -2
- package/dist/{exit-F6ZUL2NV.js → exit-OIYZLBVJ.js} +1 -1
- package/dist/exit.d.ts +5 -1
- package/dist/getter.d.ts +1 -1
- package/dist/index.cjs +85 -128
- package/dist/index.d.ts +11 -8
- package/dist/index.js +80 -123
- package/dist/llmz-CPMVYIOJ.cjs +581 -0
- package/dist/llmz-LAN4WDFW.js +581 -0
- package/dist/llmz.d.ts +8 -10
- package/dist/result.d.ts +33 -0
- package/dist/types.d.ts +1 -33
- package/dist/{vm-GJ5R72AP.cjs → vm-2DLG7V4G.cjs} +2 -2
- package/dist/{vm-ZUQOSRRM.js → vm-FLBMZUA2.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-4KB5WXHR.js +0 -92
- package/dist/chunk-6YWYCVAB.cjs +0 -92
- package/dist/chunk-EFGXTO64.js +0 -344
- package/dist/chunk-VAF2H6UD.cjs +0 -344
- package/dist/component-HQ5YQNRX.cjs +0 -14
- package/dist/llmz-AS5TGCQS.js +0 -1108
- package/dist/llmz-R6XZG3JQ.cjs +0 -1108
|
@@ -2649,6 +2649,7 @@ function getCompiledCode(code, traces = []) {
|
|
|
2649
2649
|
}
|
|
2650
2650
|
}
|
|
2651
2651
|
async function runAsyncFunction(context, code, traces = [], signal = null, timeout = MAX_VM_EXECUTION_TIME) {
|
|
2652
|
+
var _a3;
|
|
2652
2653
|
const transformed = getCompiledCode(code, traces);
|
|
2653
2654
|
const lines_executed = /* @__PURE__ */ new Map();
|
|
2654
2655
|
const variables = {};
|
|
@@ -2692,12 +2693,12 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2692
2693
|
};
|
|
2693
2694
|
let currentToolCall;
|
|
2694
2695
|
context[Identifiers.ToolCallTrackerFnIdentifier] = (callId, type, outputOrError) => {
|
|
2695
|
-
var
|
|
2696
|
+
var _a4;
|
|
2696
2697
|
const temp = Signals.maybeDeserializeError(outputOrError == null ? void 0 : outputOrError.message);
|
|
2697
2698
|
if (type === "end" && temp instanceof SnapshotSignal && (temp == null ? void 0 : temp.toolCall)) {
|
|
2698
2699
|
currentToolCall = {
|
|
2699
2700
|
...temp.toolCall,
|
|
2700
|
-
assignment: (
|
|
2701
|
+
assignment: (_a4 = transformed.toolCalls.get(callId)) == null ? void 0 : _a4.assignment
|
|
2701
2702
|
};
|
|
2702
2703
|
}
|
|
2703
2704
|
};
|
|
@@ -2726,15 +2727,19 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2726
2727
|
const AsyncFunction = async function* () {
|
|
2727
2728
|
}.constructor;
|
|
2728
2729
|
return await (async () => {
|
|
2729
|
-
const
|
|
2730
|
-
|
|
2730
|
+
const descriptors = Object.getOwnPropertyDescriptors(context);
|
|
2731
|
+
const topLevelProperties = Object.keys(descriptors).filter(
|
|
2732
|
+
(x) => !NO_TRACKING.includes(x) && descriptors[x] && typeof descriptors[x].value !== "function" && typeof descriptors[x].value !== "object"
|
|
2731
2733
|
);
|
|
2732
2734
|
const __report = (name, value) => {
|
|
2733
|
-
context[name]
|
|
2735
|
+
if (context[name] !== void 0 && context[name] !== value) {
|
|
2736
|
+
context[name] = value;
|
|
2737
|
+
}
|
|
2734
2738
|
};
|
|
2735
2739
|
context.__report = __report;
|
|
2736
2740
|
const reportAll = topLevelProperties.map((x) => `__report("${x}", ${x})`).join(";");
|
|
2737
|
-
const
|
|
2741
|
+
const assigner = `let __${Identifiers.LineTrackingFnIdentifier} = ${Identifiers.LineTrackingFnIdentifier}; ${Identifiers.LineTrackingFnIdentifier} = function(line) { ${reportAll}; __${Identifiers.LineTrackingFnIdentifier}(line);}`;
|
|
2742
|
+
const wrapper = `"use strict"; try { ${assigner};${transformed.code} } finally { ${reportAll} };`;
|
|
2738
2743
|
const fn = AsyncFunction(...Object.keys(context), wrapper);
|
|
2739
2744
|
const res = fn(...Object.values(context));
|
|
2740
2745
|
do {
|
|
@@ -2760,6 +2765,7 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2760
2765
|
const isolatedContext = await isolate.createContext();
|
|
2761
2766
|
const jail = isolatedContext.global;
|
|
2762
2767
|
const trackedProperties = /* @__PURE__ */ new Set();
|
|
2768
|
+
const referenceProperties = /* @__PURE__ */ new Set();
|
|
2763
2769
|
const abort = () => {
|
|
2764
2770
|
if (USE_ISOLATED_VM) {
|
|
2765
2771
|
isolate.dispose();
|
|
@@ -2779,7 +2785,7 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2779
2785
|
arguments: { reference: true }
|
|
2780
2786
|
}
|
|
2781
2787
|
);
|
|
2782
|
-
} else if (typeof context[key] === "object") {
|
|
2788
|
+
} else if (typeof context[key] === "object" && !((_a3 = Object.getOwnPropertyDescriptor(context, key)) == null ? void 0 : _a3.get)) {
|
|
2783
2789
|
try {
|
|
2784
2790
|
trackedProperties.add(key);
|
|
2785
2791
|
const initial = Array.isArray(context[key]) ? new Array(context[key].length) : {};
|
|
@@ -2796,9 +2802,28 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2796
2802
|
}
|
|
2797
2803
|
);
|
|
2798
2804
|
} else {
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2805
|
+
const descriptor = Object.getOwnPropertyDescriptor(context[key], prop);
|
|
2806
|
+
if (descriptor && (descriptor.get || descriptor.set)) {
|
|
2807
|
+
referenceProperties.add(`${key}.${prop}`);
|
|
2808
|
+
await isolatedContext.evalClosure(
|
|
2809
|
+
`Object.defineProperty(global['${key}'], '${prop}', {
|
|
2810
|
+
get: () => $0.applySync(null, [], {arguments: {copy: true}}),
|
|
2811
|
+
set: (value) => $1.applySync(null, [value], {arguments: {copy: true}})
|
|
2812
|
+
});`,
|
|
2813
|
+
[
|
|
2814
|
+
() => context[key][prop],
|
|
2815
|
+
(value) => {
|
|
2816
|
+
context[key][prop] = value;
|
|
2817
|
+
return value;
|
|
2818
|
+
}
|
|
2819
|
+
],
|
|
2820
|
+
{ arguments: { reference: true } }
|
|
2821
|
+
);
|
|
2822
|
+
} else {
|
|
2823
|
+
await isolatedContext.evalClosure(`global['${key}']['${prop}'] = $0;`, [context[key][prop]], {
|
|
2824
|
+
arguments: { copy: true }
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2802
2827
|
}
|
|
2803
2828
|
} catch (err) {
|
|
2804
2829
|
console.error(`Could not copy "${key}.${prop}" (typeof = ${typeof context[key][prop]}) to the sandbox`, err);
|
|
@@ -2809,7 +2834,26 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2809
2834
|
}
|
|
2810
2835
|
} else {
|
|
2811
2836
|
try {
|
|
2812
|
-
|
|
2837
|
+
const descriptor = Object.getOwnPropertyDescriptor(context, key);
|
|
2838
|
+
if (descriptor && (descriptor.get || descriptor.set)) {
|
|
2839
|
+
referenceProperties.add(key);
|
|
2840
|
+
await isolatedContext.evalClosure(
|
|
2841
|
+
`Object.defineProperty(global, '${key}', {
|
|
2842
|
+
get: () => $0.applySync(null, [], {arguments: {copy: true}}),
|
|
2843
|
+
set: (value) => $1.applySync(null, [value], {arguments: {copy: true}})
|
|
2844
|
+
});`,
|
|
2845
|
+
[
|
|
2846
|
+
() => context[key],
|
|
2847
|
+
(value) => {
|
|
2848
|
+
context[key] = value;
|
|
2849
|
+
return value;
|
|
2850
|
+
}
|
|
2851
|
+
],
|
|
2852
|
+
{ arguments: { reference: true } }
|
|
2853
|
+
);
|
|
2854
|
+
} else {
|
|
2855
|
+
await jail.set(key, context[key], { copy: true });
|
|
2856
|
+
}
|
|
2813
2857
|
trackedProperties.add(key);
|
|
2814
2858
|
} catch (err) {
|
|
2815
2859
|
console.error(`Could not copy "${key}" to the sandbox (typeof = ${typeof context[key]})`, err);
|
|
@@ -2875,7 +2919,7 @@ do {
|
|
|
2875
2919
|
}
|
|
2876
2920
|
copied = true;
|
|
2877
2921
|
for (const key of trackedProperties) {
|
|
2878
|
-
if (typeof context[key] === "object") {
|
|
2922
|
+
if (typeof context[key] === "object" && !referenceProperties.has(key)) {
|
|
2879
2923
|
try {
|
|
2880
2924
|
let properties = [];
|
|
2881
2925
|
try {
|
|
@@ -2890,7 +2934,7 @@ do {
|
|
|
2890
2934
|
delete context[key][prop];
|
|
2891
2935
|
}
|
|
2892
2936
|
for (const prop of properties) {
|
|
2893
|
-
if (typeof context[key][prop] === "function") {
|
|
2937
|
+
if (typeof context[key][prop] === "function" || referenceProperties.has(`${key}.${prop}`)) {
|
|
2894
2938
|
continue;
|
|
2895
2939
|
}
|
|
2896
2940
|
try {
|
|
@@ -2921,6 +2965,9 @@ do {
|
|
|
2921
2965
|
}
|
|
2922
2966
|
} else {
|
|
2923
2967
|
try {
|
|
2968
|
+
if (referenceProperties.has(key)) {
|
|
2969
|
+
continue;
|
|
2970
|
+
}
|
|
2924
2971
|
const value = jail.getSync(key, { copy: true });
|
|
2925
2972
|
try {
|
|
2926
2973
|
Object.assign(context, { [key]: value });
|
|
@@ -2944,9 +2991,6 @@ do {
|
|
|
2944
2991
|
}
|
|
2945
2992
|
};
|
|
2946
2993
|
const final = await script.run(isolatedContext, {
|
|
2947
|
-
// TODO: fix getRemainingTimeInMillis ...
|
|
2948
|
-
// TODO: probably expose a "timeout" option instead
|
|
2949
|
-
// timeout: clamp(Runtime.getRemainingTimeInMillis() - 10_000, 5_000, MAX_VM_EXECUTION_TIME),
|
|
2950
2994
|
timeout,
|
|
2951
2995
|
copy: true,
|
|
2952
2996
|
promise: true
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var _chunkKMZDFWYZcjs = require('./chunk-KMZDFWYZ.cjs');
|
|
4
5
|
|
|
5
6
|
// src/component.ts
|
|
7
|
+
var _zui = require('@bpinternal/zui');
|
|
6
8
|
function assertValidComponent(component) {
|
|
7
9
|
if (!component.name) {
|
|
8
10
|
throw new Error("Component must have a name");
|
|
@@ -36,6 +38,16 @@ function assertValidComponent(component) {
|
|
|
36
38
|
throw new Error("Container component must have container props and children");
|
|
37
39
|
}
|
|
38
40
|
}
|
|
41
|
+
var getDefaultValue = (schema) => {
|
|
42
|
+
if (schema._def.defaultValue !== void 0) {
|
|
43
|
+
if (typeof schema._def.defaultValue === "function") {
|
|
44
|
+
return String(schema._def.defaultValue()).toString();
|
|
45
|
+
} else {
|
|
46
|
+
return String(schema._def.defaultValue);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return "";
|
|
50
|
+
};
|
|
39
51
|
function getComponentReference(component) {
|
|
40
52
|
let doc = `### <${component.name}>
|
|
41
53
|
|
|
@@ -44,12 +56,35 @@ function getComponentReference(component) {
|
|
|
44
56
|
|
|
45
57
|
`;
|
|
46
58
|
const getPropsDoc = (props) => {
|
|
47
|
-
|
|
59
|
+
const shape = props.shape;
|
|
60
|
+
if (Object.keys(shape).length === 0)
|
|
48
61
|
return "_No props._\n\n";
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
const zodTypeToTsType = {
|
|
63
|
+
ZodString: "string",
|
|
64
|
+
ZodNumber: "number",
|
|
65
|
+
ZodBoolean: "boolean",
|
|
66
|
+
ZodEnum: "enum",
|
|
67
|
+
ZodArray: "array",
|
|
68
|
+
ZodObject: "object",
|
|
69
|
+
ZodDate: "date",
|
|
70
|
+
ZodBigInt: "bigint",
|
|
71
|
+
ZodSymbol: "symbol",
|
|
72
|
+
ZodUndefined: "undefined",
|
|
73
|
+
ZodNull: "null",
|
|
74
|
+
ZodVoid: "void",
|
|
75
|
+
ZodNever: "never",
|
|
76
|
+
ZodUnknown: "unknown",
|
|
77
|
+
ZodAny: "any"
|
|
78
|
+
};
|
|
79
|
+
return Object.entries(shape).map(([name, schema]) => {
|
|
80
|
+
const naked = schema.naked();
|
|
81
|
+
const zodType = naked._def.typeName;
|
|
82
|
+
const defValue = getDefaultValue(schema);
|
|
83
|
+
const typings = naked instanceof _zui.z.ZodEnum ? naked._def.values.map((x) => `"${x}"`).join(" | ") : zodTypeToTsType[zodType] || zodType;
|
|
84
|
+
const required = !schema.isOptional() ? "**(required)**" : "(optional)";
|
|
85
|
+
const def = defValue ? ` _Default: \`${defValue}\`_` : "";
|
|
86
|
+
const description = schema.description || schema.naked().description || (schema == null ? void 0 : schema._def.description) || "";
|
|
87
|
+
return `- \`${name}: ${typings}\` ${required} \u2014 ${description}${def}`;
|
|
53
88
|
}).join("\n") + "\n\n";
|
|
54
89
|
};
|
|
55
90
|
const getChildrenDoc = (children) => {
|
|
@@ -105,10 +140,14 @@ var Component = class {
|
|
|
105
140
|
function isComponent(rendered, component) {
|
|
106
141
|
return _chunkKMZDFWYZcjs.isJsxComponent.call(void 0, component.definition.name, rendered);
|
|
107
142
|
}
|
|
143
|
+
function isAnyComponent(message) {
|
|
144
|
+
return _chunkKMZDFWYZcjs.isAnyJsxComponent.call(void 0, message);
|
|
145
|
+
}
|
|
146
|
+
|
|
108
147
|
|
|
109
148
|
|
|
110
149
|
|
|
111
150
|
|
|
112
151
|
|
|
113
152
|
|
|
114
|
-
exports.assertValidComponent = assertValidComponent; exports.getComponentReference = getComponentReference; exports.Component = Component; exports.isComponent = isComponent;
|
|
153
|
+
exports.assertValidComponent = assertValidComponent; exports.getComponentReference = getComponentReference; exports.Component = Component; exports.isComponent = isComponent; exports.isAnyComponent = isAnyComponent;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
isAnyJsxComponent,
|
|
2
3
|
isJsxComponent
|
|
3
4
|
} from "./chunk-ORQP26SZ.js";
|
|
4
5
|
|
|
5
6
|
// src/component.ts
|
|
7
|
+
import { z } from "@bpinternal/zui";
|
|
6
8
|
function assertValidComponent(component) {
|
|
7
9
|
if (!component.name) {
|
|
8
10
|
throw new Error("Component must have a name");
|
|
@@ -36,6 +38,16 @@ function assertValidComponent(component) {
|
|
|
36
38
|
throw new Error("Container component must have container props and children");
|
|
37
39
|
}
|
|
38
40
|
}
|
|
41
|
+
var getDefaultValue = (schema) => {
|
|
42
|
+
if (schema._def.defaultValue !== void 0) {
|
|
43
|
+
if (typeof schema._def.defaultValue === "function") {
|
|
44
|
+
return String(schema._def.defaultValue()).toString();
|
|
45
|
+
} else {
|
|
46
|
+
return String(schema._def.defaultValue);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return "";
|
|
50
|
+
};
|
|
39
51
|
function getComponentReference(component) {
|
|
40
52
|
let doc = `### <${component.name}>
|
|
41
53
|
|
|
@@ -44,12 +56,35 @@ function getComponentReference(component) {
|
|
|
44
56
|
|
|
45
57
|
`;
|
|
46
58
|
const getPropsDoc = (props) => {
|
|
47
|
-
|
|
59
|
+
const shape = props.shape;
|
|
60
|
+
if (Object.keys(shape).length === 0)
|
|
48
61
|
return "_No props._\n\n";
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
const zodTypeToTsType = {
|
|
63
|
+
ZodString: "string",
|
|
64
|
+
ZodNumber: "number",
|
|
65
|
+
ZodBoolean: "boolean",
|
|
66
|
+
ZodEnum: "enum",
|
|
67
|
+
ZodArray: "array",
|
|
68
|
+
ZodObject: "object",
|
|
69
|
+
ZodDate: "date",
|
|
70
|
+
ZodBigInt: "bigint",
|
|
71
|
+
ZodSymbol: "symbol",
|
|
72
|
+
ZodUndefined: "undefined",
|
|
73
|
+
ZodNull: "null",
|
|
74
|
+
ZodVoid: "void",
|
|
75
|
+
ZodNever: "never",
|
|
76
|
+
ZodUnknown: "unknown",
|
|
77
|
+
ZodAny: "any"
|
|
78
|
+
};
|
|
79
|
+
return Object.entries(shape).map(([name, schema]) => {
|
|
80
|
+
const naked = schema.naked();
|
|
81
|
+
const zodType = naked._def.typeName;
|
|
82
|
+
const defValue = getDefaultValue(schema);
|
|
83
|
+
const typings = naked instanceof z.ZodEnum ? naked._def.values.map((x) => `"${x}"`).join(" | ") : zodTypeToTsType[zodType] || zodType;
|
|
84
|
+
const required = !schema.isOptional() ? "**(required)**" : "(optional)";
|
|
85
|
+
const def = defValue ? ` _Default: \`${defValue}\`_` : "";
|
|
86
|
+
const description = schema.description || schema.naked().description || (schema == null ? void 0 : schema._def.description) || "";
|
|
87
|
+
return `- \`${name}: ${typings}\` ${required} \u2014 ${description}${def}`;
|
|
53
88
|
}).join("\n") + "\n\n";
|
|
54
89
|
};
|
|
55
90
|
const getChildrenDoc = (children) => {
|
|
@@ -105,10 +140,14 @@ var Component = class {
|
|
|
105
140
|
function isComponent(rendered, component) {
|
|
106
141
|
return isJsxComponent(component.definition.name, rendered);
|
|
107
142
|
}
|
|
143
|
+
function isAnyComponent(message) {
|
|
144
|
+
return isAnyJsxComponent(message);
|
|
145
|
+
}
|
|
108
146
|
|
|
109
147
|
export {
|
|
110
148
|
assertValidComponent,
|
|
111
149
|
getComponentReference,
|
|
112
150
|
Component,
|
|
113
|
-
isComponent
|
|
151
|
+
isComponent,
|
|
152
|
+
isAnyComponent
|
|
114
153
|
};
|
|
@@ -40,8 +40,8 @@ var Exit = class _Exit {
|
|
|
40
40
|
is(exit) {
|
|
41
41
|
return this.name === exit.name;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
return
|
|
43
|
+
match(result) {
|
|
44
|
+
return result.exit instanceof _Exit && this.name === result.exit.name;
|
|
45
45
|
}
|
|
46
46
|
constructor(props) {
|
|
47
47
|
if (!isValidIdentifier(props.name)) {
|