llmz 0.0.6 → 0.0.8
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 +24 -3
- package/dist/chat.d.ts +2 -2
- package/dist/{chunk-P7J2WCBB.cjs → chunk-276Q6EWP.cjs} +6 -2
- package/dist/{chunk-HYVKY3W6.cjs → chunk-4L6D2A6O.cjs} +15 -15
- package/dist/{chunk-5TRUJES5.js → chunk-4MNIJGK6.js} +6 -2
- package/dist/{chunk-4QTK5ALH.cjs → chunk-C6WNNTEV.cjs} +23 -22
- package/dist/{chunk-HP7RKM25.js → chunk-GGWM6X2K.js} +32 -1
- package/dist/{chunk-4I7UPBLN.cjs → chunk-GWFYZDUR.cjs} +9 -8
- package/dist/{chunk-CH5T6SPC.cjs → chunk-HJKOSEH2.cjs} +89 -61
- package/dist/{chunk-UNMKB2DA.js → chunk-IH2WQFO5.js} +2 -2
- package/dist/{chunk-QBXIE6EY.js → chunk-JAGB2AOU.js} +16 -15
- package/dist/{chunk-FIVFS4HG.cjs → chunk-JGVAZO4X.cjs} +5 -5
- package/dist/{chunk-S6FOL2HY.js → chunk-JMSZKB4T.js} +7 -6
- package/dist/{chunk-WLUVY5QU.js → chunk-KH6JQYQA.js} +62 -21
- package/dist/{chunk-XJNRORSK.js → chunk-PRVFVXT4.js} +76 -48
- package/dist/{chunk-6WT5VZBG.cjs → chunk-SHJDRZF5.cjs} +81 -40
- package/dist/{chunk-QT4QF3YA.js → chunk-SNDVQU5A.js} +4 -4
- package/dist/{chunk-EJRCDWBA.cjs → chunk-ZRCU35UV.cjs} +32 -1
- package/dist/component-R4WTW6DZ.cjs +18 -0
- package/dist/{component-R2Y74VUI.js → component-WFVDVSDK.js} +5 -3
- package/dist/component.d.ts +6 -0
- package/dist/context.d.ts +3 -4
- package/dist/{dual-modes-ZUQKPJFH.js → dual-modes-T53P72CH.js} +4 -4
- package/dist/dual-modes-VLIGPIHX.cjs +12 -0
- package/dist/errors.d.ts +3 -3
- package/dist/exit-TRXEU4OU.cjs +8 -0
- package/dist/{exit-OIYZLBVJ.js → exit-YORW76T3.js} +2 -2
- package/dist/exit.d.ts +2 -2
- package/dist/index.cjs +40 -38
- package/dist/index.d.ts +2 -1
- package/dist/index.js +21 -19
- package/dist/{llmz-CPMVYIOJ.cjs → llmz-QLZBDG2Z.cjs} +28 -33
- package/dist/{llmz-LAN4WDFW.js → llmz-ROOX7RYI.js} +17 -22
- package/dist/llmz.d.ts +1 -1
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/prompt.d.ts +13 -8
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/{tool-LY77IWV2.js → tool-N6ODRRGH.js} +3 -3
- package/dist/{tool-SWJYOR2Z.cjs → tool-QP4MVRWI.cjs} +4 -4
- package/dist/tool.d.ts +4 -3
- package/dist/transcript.d.ts +34 -7
- package/dist/truncator-DUMWEGQO.cjs +10 -0
- package/dist/{truncator-WAL2GCUY.js → truncator-IY2MXOMC.js} +2 -2
- package/dist/truncator.d.ts +2 -3
- package/dist/{typings-XR6CYHW4.cjs → typings-2CPHOFDN.cjs} +3 -3
- package/dist/{typings-AIV2OASX.js → typings-GDMY6VY2.js} +2 -2
- package/dist/utils-A7WNEFTA.cjs +39 -0
- package/dist/{utils-L5GLCS3C.js → utils-N24IHDFA.js} +3 -1
- package/dist/utils.d.ts +5 -3
- package/package.json +5 -3
- package/dist/component-TSNW3SC7.cjs +0 -16
- package/dist/dual-modes-UHNDHNIF.cjs +0 -12
- package/dist/exit-KJ4COC5N.cjs +0 -8
- package/dist/openai.d.ts +0 -8
- package/dist/truncator-NYN7BGKJ.cjs +0 -10
- package/dist/utils-QC4I2L6R.cjs +0 -37
package/README.md
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
## Intro
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Installation
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```sh
|
|
6
|
+
# The core library
|
|
7
|
+
npm install llmz
|
|
6
8
|
|
|
9
|
+
# Dependencies
|
|
10
|
+
npm install @botpress/client
|
|
7
11
|
```
|
|
8
|
-
|
|
12
|
+
|
|
13
|
+
## Getting Started
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { execute } from 'llmz'
|
|
17
|
+
import { Client } from '@botpress/client'
|
|
18
|
+
|
|
19
|
+
const client = new Client({
|
|
20
|
+
botId: process.env.BOTPRESS_BOT_ID,
|
|
21
|
+
token: process.env.BOTPRESS_TOKEN,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const result = await execute({
|
|
25
|
+
client,
|
|
26
|
+
instructions: 'Return the value of 2 + 4.',
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
console.log(result.output) // Will print "6"
|
|
9
30
|
```
|
|
10
31
|
|
|
11
32
|
## LLMz vs Tool Calling
|
package/dist/chat.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Component, RenderedComponent } from './component.js';
|
|
|
2
2
|
import { Context } from './context.js';
|
|
3
3
|
import { ValueOrGetter } from './getter.js';
|
|
4
4
|
import { ExecutionResult } from './result.js';
|
|
5
|
-
import { TranscriptArray,
|
|
5
|
+
import { TranscriptArray, Transcript } from './transcript.js';
|
|
6
6
|
export type MessageHandler = (input: RenderedComponent) => Promise<void> | void;
|
|
7
7
|
export declare class Chat {
|
|
8
8
|
readonly handler: MessageHandler;
|
|
@@ -11,7 +11,7 @@ export declare class Chat {
|
|
|
11
11
|
constructor(props: {
|
|
12
12
|
handler: MessageHandler;
|
|
13
13
|
components: ValueOrGetter<Component[], Context>;
|
|
14
|
-
transcript?: ValueOrGetter<
|
|
14
|
+
transcript?: ValueOrGetter<Transcript.Message[], Context>;
|
|
15
15
|
});
|
|
16
16
|
onExecutionDone(_result: ExecutionResult): void;
|
|
17
17
|
}
|
|
@@ -178,12 +178,15 @@ var convertObjectToZuiLiterals = (obj, nested = false) => {
|
|
|
178
178
|
};
|
|
179
179
|
var isValidSchema = (schema) => {
|
|
180
180
|
try {
|
|
181
|
-
_zui.
|
|
181
|
+
_zui.transforms.fromJSONSchemaLegacy(schema);
|
|
182
182
|
return typeof schema.type === "string";
|
|
183
183
|
} catch (e) {
|
|
184
184
|
return false;
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
|
+
function isZuiSchema(schema) {
|
|
188
|
+
return !!schema && typeof schema === "object" && schema.__type__ === "ZuiType";
|
|
189
|
+
}
|
|
187
190
|
function isJsonSchema(schema) {
|
|
188
191
|
return !!schema && typeof schema === "object" && ("$schema" in schema || "type" in schema || "properties" in schema);
|
|
189
192
|
}
|
|
@@ -217,4 +220,5 @@ function isValidMessageName(name) {
|
|
|
217
220
|
|
|
218
221
|
|
|
219
222
|
|
|
220
|
-
|
|
223
|
+
|
|
224
|
+
exports.init = init; exports.getTokenizer = getTokenizer; exports.Tokens = Tokens; exports.Identifier = Identifier; exports.escapeString = escapeString; exports.toPropertyKey = toPropertyKey; exports.getMultilineComment = getMultilineComment; exports.toValidFunctionName = toValidFunctionName; exports.awaitObject = awaitObject; exports.toValidObjectName = toValidObjectName; exports.stripInvalidIdentifiers = stripInvalidIdentifiers; exports.convertObjectToZuiLiterals = convertObjectToZuiLiterals; exports.isValidSchema = isValidSchema; exports.isZuiSchema = isZuiSchema; exports.isJsonSchema = isJsonSchema; exports.isValidIdentifier = isValidIdentifier; exports.isValidMessageName = isValidMessageName;
|
|
@@ -5,7 +5,7 @@ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
|
|
9
9
|
|
|
10
10
|
// src/typings.ts
|
|
11
11
|
var _zui = require('@bpinternal/zui');
|
|
@@ -111,7 +111,7 @@ async function sUnwrapZod(schema, options) {
|
|
|
111
111
|
parent: schema
|
|
112
112
|
};
|
|
113
113
|
if (schema instanceof Declaration) {
|
|
114
|
-
const description =
|
|
114
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema.schema.description);
|
|
115
115
|
const withoutDesc = schema.schema.describe("");
|
|
116
116
|
const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
|
|
117
117
|
const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
|
|
@@ -132,7 +132,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
132
132
|
const optionalToken = schema.key.endsWith("?") ? "" : "?";
|
|
133
133
|
return sUnwrapZodRecursive(new KeyValue(schema.key + optionalToken, innerType), newOptions);
|
|
134
134
|
}
|
|
135
|
-
const description =
|
|
135
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema.value._def.description || schema.value.description);
|
|
136
136
|
const delimiter = (description == null ? void 0 : description.trim().length) > 0 ? "\n" : "";
|
|
137
137
|
const withoutDesc = schema.value.describe("");
|
|
138
138
|
return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
|
|
@@ -143,7 +143,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
143
143
|
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
144
144
|
const argName = _nullishCoalesce(((_b = (_a = schema.schema.items[i]) == null ? void 0 : _a.ui) == null ? void 0 : _b.title), () => ( `arg${i}`));
|
|
145
145
|
const item = schema.schema.items[i];
|
|
146
|
-
args += `${await sUnwrapZodRecursive(new KeyValue(
|
|
146
|
+
args += `${await sUnwrapZodRecursive(new KeyValue(_chunk276Q6EWPcjs.toPropertyKey.call(void 0, argName), item), newOptions)}, `;
|
|
147
147
|
}
|
|
148
148
|
return args;
|
|
149
149
|
}
|
|
@@ -178,7 +178,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
178
178
|
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
179
179
|
}
|
|
180
180
|
if (schema instanceof _zui.z.ZodFunction) {
|
|
181
|
-
const description =
|
|
181
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
182
182
|
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
183
183
|
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
184
184
|
if (options == null ? void 0 : options.declaration) {
|
|
@@ -196,7 +196,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
196
196
|
return `Array<${item}>`;
|
|
197
197
|
}
|
|
198
198
|
if (schema instanceof _zui.z.ZodEnum) {
|
|
199
|
-
const values = schema._def.values.map(
|
|
199
|
+
const values = schema._def.values.map(_chunk276Q6EWPcjs.escapeString);
|
|
200
200
|
return values.join(" | ");
|
|
201
201
|
}
|
|
202
202
|
if (schema instanceof _zui.z.ZodTuple) {
|
|
@@ -221,7 +221,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
221
221
|
const props = await Promise.all(
|
|
222
222
|
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
223
223
|
if (value instanceof _zui.z.Schema) {
|
|
224
|
-
return sUnwrapZodRecursive(new KeyValue(
|
|
224
|
+
return sUnwrapZodRecursive(new KeyValue(_chunk276Q6EWPcjs.toPropertyKey.call(void 0, key), value), newOptions);
|
|
225
225
|
}
|
|
226
226
|
return `${key}: unknown`;
|
|
227
227
|
})
|
|
@@ -229,11 +229,11 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
229
229
|
return `{ ${props.join("; ")} }`;
|
|
230
230
|
}
|
|
231
231
|
if (schema instanceof _zui.z.ZodString) {
|
|
232
|
-
const description =
|
|
232
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
233
233
|
return `${description} string`.trim();
|
|
234
234
|
}
|
|
235
235
|
if (schema instanceof _zui.z.ZodUnion) {
|
|
236
|
-
const description =
|
|
236
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
237
237
|
const options2 = await Promise.all(
|
|
238
238
|
schema.options.map(async (option) => {
|
|
239
239
|
return sUnwrapZodRecursive(option, newOptions);
|
|
@@ -243,16 +243,16 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
243
243
|
${options2.join(" | ")}`;
|
|
244
244
|
}
|
|
245
245
|
if (schema instanceof _zui.z.ZodLiteral) {
|
|
246
|
-
const description =
|
|
246
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
247
247
|
return `${description}
|
|
248
|
-
${typeof schema.value === "string" ?
|
|
248
|
+
${typeof schema.value === "string" ? _chunk276Q6EWPcjs.escapeString.call(void 0, schema.value) : schema.value}`.trim();
|
|
249
249
|
}
|
|
250
250
|
if (schema instanceof _zui.z.ZodNumber) {
|
|
251
|
-
const description =
|
|
251
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
252
252
|
return `${description} number`.trim();
|
|
253
253
|
}
|
|
254
254
|
if (schema instanceof _zui.z.ZodBoolean) {
|
|
255
|
-
const description =
|
|
255
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
256
256
|
return `${description} boolean`.trim();
|
|
257
257
|
}
|
|
258
258
|
if (schema instanceof _zui.z.ZodCatch) {
|
|
@@ -262,13 +262,13 @@ ${typeof schema.value === "string" ? _chunkP7J2WCBBcjs.escapeString.call(void 0,
|
|
|
262
262
|
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
263
263
|
}
|
|
264
264
|
if (schema instanceof _zui.z.ZodRecord) {
|
|
265
|
-
const description =
|
|
265
|
+
const description = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
266
266
|
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
267
267
|
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
268
268
|
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
269
269
|
}
|
|
270
270
|
try {
|
|
271
|
-
let typings =
|
|
271
|
+
let typings = schema == null ? void 0 : schema.toTypescriptType();
|
|
272
272
|
typings ??= "unknown";
|
|
273
273
|
return stripSpaces(typings);
|
|
274
274
|
} catch (error) {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
10
10
|
import { getWasmTokenizer } from "@bpinternal/thicktoken";
|
|
11
|
-
import { z } from "@bpinternal/zui";
|
|
11
|
+
import { z, transforms } from "@bpinternal/zui";
|
|
12
12
|
var tokenizer = null;
|
|
13
13
|
var init = async () => {
|
|
14
14
|
if (tokenizer) {
|
|
@@ -178,12 +178,15 @@ var convertObjectToZuiLiterals = (obj, nested = false) => {
|
|
|
178
178
|
};
|
|
179
179
|
var isValidSchema = (schema) => {
|
|
180
180
|
try {
|
|
181
|
-
|
|
181
|
+
transforms.fromJSONSchemaLegacy(schema);
|
|
182
182
|
return typeof schema.type === "string";
|
|
183
183
|
} catch {
|
|
184
184
|
return false;
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
|
+
function isZuiSchema(schema) {
|
|
188
|
+
return !!schema && typeof schema === "object" && schema.__type__ === "ZuiType";
|
|
189
|
+
}
|
|
187
190
|
function isJsonSchema(schema) {
|
|
188
191
|
return !!schema && typeof schema === "object" && ("$schema" in schema || "type" in schema || "properties" in schema);
|
|
189
192
|
}
|
|
@@ -214,6 +217,7 @@ export {
|
|
|
214
217
|
stripInvalidIdentifiers,
|
|
215
218
|
convertObjectToZuiLiterals,
|
|
216
219
|
isValidSchema,
|
|
220
|
+
isZuiSchema,
|
|
217
221
|
isJsonSchema,
|
|
218
222
|
isValidIdentifier,
|
|
219
223
|
isValidMessageName
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk4L6D2A6Ocjs = require('./chunk-4L6D2A6O.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
|
|
@@ -28,7 +29,7 @@ var Tool = (_class = class _Tool {
|
|
|
28
29
|
this._staticInputValues = void 0;
|
|
29
30
|
return this;
|
|
30
31
|
}
|
|
31
|
-
const input = this.input ? _zui.
|
|
32
|
+
const input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
|
|
32
33
|
if (input instanceof _zui.z.ZodObject && typeof values !== "object") {
|
|
33
34
|
throw new Error(
|
|
34
35
|
`Invalid static input values for tool ${this.name}. Expected an object, but got type "${typeof values}"`
|
|
@@ -43,9 +44,9 @@ var Tool = (_class = class _Tool {
|
|
|
43
44
|
return this;
|
|
44
45
|
}
|
|
45
46
|
get zInput() {
|
|
46
|
-
let input = this.input ? _zui.
|
|
47
|
+
let input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
|
|
47
48
|
if (!_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
48
|
-
const inputExtensions =
|
|
49
|
+
const inputExtensions = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
49
50
|
if (input instanceof _zui.z.ZodObject) {
|
|
50
51
|
input = input.extend(inputExtensions);
|
|
51
52
|
} else if (input instanceof _zui.z.ZodArray) {
|
|
@@ -57,11 +58,11 @@ var Tool = (_class = class _Tool {
|
|
|
57
58
|
return input;
|
|
58
59
|
}
|
|
59
60
|
get zOutput() {
|
|
60
|
-
return this.output ? _zui.
|
|
61
|
+
return this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : _zui.z.void();
|
|
61
62
|
}
|
|
62
63
|
rename(name) {
|
|
63
64
|
const before = this.name;
|
|
64
|
-
if (!
|
|
65
|
+
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, name)) {
|
|
65
66
|
throw new Error(
|
|
66
67
|
`Invalid name for tool ${name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
67
68
|
);
|
|
@@ -73,8 +74,8 @@ var Tool = (_class = class _Tool {
|
|
|
73
74
|
clone(props = {}) {
|
|
74
75
|
var _a, _b;
|
|
75
76
|
try {
|
|
76
|
-
const zInput = this.input ? _zui.
|
|
77
|
-
const zOutput = this.output ? _zui.
|
|
77
|
+
const zInput = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : void 0;
|
|
78
|
+
const zOutput = this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : void 0;
|
|
78
79
|
return new _Tool({
|
|
79
80
|
name: _nullishCoalesce(props.name, () => ( this.name)),
|
|
80
81
|
aliases: _nullishCoalesce(props.aliases, () => ( [...this.aliases])),
|
|
@@ -91,7 +92,7 @@ var Tool = (_class = class _Tool {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
constructor(props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
94
|
-
if (!
|
|
95
|
+
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
95
96
|
throw new Error(
|
|
96
97
|
`Invalid name for tool ${props.name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
97
98
|
);
|
|
@@ -116,13 +117,13 @@ var Tool = (_class = class _Tool {
|
|
|
116
117
|
`Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
117
118
|
);
|
|
118
119
|
}
|
|
119
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
120
|
+
if (props.aliases && props.aliases.some((alias) => !_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, alias))) {
|
|
120
121
|
throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
|
|
121
122
|
}
|
|
122
123
|
if (typeof props.input !== "undefined") {
|
|
123
|
-
if (
|
|
124
|
-
this.input = props.input
|
|
125
|
-
} else if (
|
|
124
|
+
if (_chunk276Q6EWPcjs.isZuiSchema.call(void 0, props.input)) {
|
|
125
|
+
this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
|
|
126
|
+
} else if (_chunk276Q6EWPcjs.isJsonSchema.call(void 0, props.input)) {
|
|
126
127
|
this.input = props.input;
|
|
127
128
|
} else {
|
|
128
129
|
throw new Error(
|
|
@@ -131,9 +132,9 @@ var Tool = (_class = class _Tool {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
if (typeof props.output !== "undefined") {
|
|
134
|
-
if (
|
|
135
|
-
this.output = props.output
|
|
136
|
-
} else if (
|
|
135
|
+
if (_chunk276Q6EWPcjs.isZuiSchema.call(void 0, props.output)) {
|
|
136
|
+
this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
|
|
137
|
+
} else if (_chunk276Q6EWPcjs.isJsonSchema.call(void 0, props.output)) {
|
|
137
138
|
this.output = props.output;
|
|
138
139
|
} else {
|
|
139
140
|
throw new Error(
|
|
@@ -177,16 +178,16 @@ var Tool = (_class = class _Tool {
|
|
|
177
178
|
);
|
|
178
179
|
}
|
|
179
180
|
async getTypings() {
|
|
180
|
-
let input = this.input ? _zui.
|
|
181
|
-
const output = this.output ? _zui.
|
|
181
|
+
let input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : void 0;
|
|
182
|
+
const output = this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : _zui.z.void();
|
|
182
183
|
if ((input == null ? void 0 : input.naked()) instanceof _zui.ZodObject && typeof this._staticInputValues === "object" && !_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
183
|
-
const inputExtensions =
|
|
184
|
+
const inputExtensions = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
184
185
|
input = input.extend(inputExtensions);
|
|
185
186
|
} else if (this._staticInputValues !== void 0) {
|
|
186
|
-
input =
|
|
187
|
+
input = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
187
188
|
}
|
|
188
189
|
const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
|
|
189
|
-
return
|
|
190
|
+
return _chunk4L6D2A6Ocjs.getTypings.call(void 0, fnType, {
|
|
190
191
|
declaration: true
|
|
191
192
|
});
|
|
192
193
|
}
|
|
@@ -143,11 +143,42 @@ function isComponent(rendered, component) {
|
|
|
143
143
|
function isAnyComponent(message) {
|
|
144
144
|
return isAnyJsxComponent(message);
|
|
145
145
|
}
|
|
146
|
+
function renderToTsx(component) {
|
|
147
|
+
const props = Object.entries(component.props).map(([key, value]) => {
|
|
148
|
+
if (typeof value === "string") {
|
|
149
|
+
return `${key}="${value}"`;
|
|
150
|
+
}
|
|
151
|
+
if (typeof value === "boolean") {
|
|
152
|
+
return value ? key : "";
|
|
153
|
+
}
|
|
154
|
+
if (typeof value === "number") {
|
|
155
|
+
return `${key}={${value}}`;
|
|
156
|
+
}
|
|
157
|
+
if (value === null || value === void 0) {
|
|
158
|
+
return "";
|
|
159
|
+
}
|
|
160
|
+
if (typeof value === "object") {
|
|
161
|
+
return `${key}={${JSON.stringify(value)}}`;
|
|
162
|
+
}
|
|
163
|
+
return `${key}={${String(value)}}`;
|
|
164
|
+
}).filter(Boolean).join(" ");
|
|
165
|
+
const children = component.children.map((child) => {
|
|
166
|
+
if (typeof child === "string") {
|
|
167
|
+
return child;
|
|
168
|
+
}
|
|
169
|
+
if (isAnyComponent(child)) {
|
|
170
|
+
return renderToTsx(child);
|
|
171
|
+
}
|
|
172
|
+
return String(child);
|
|
173
|
+
}).join("");
|
|
174
|
+
return `<${component.type}${props ? " " + props : ""}>${children}</${component.type}>`;
|
|
175
|
+
}
|
|
146
176
|
|
|
147
177
|
export {
|
|
148
178
|
assertValidComponent,
|
|
149
179
|
getComponentReference,
|
|
150
180
|
Component,
|
|
151
181
|
isComponent,
|
|
152
|
-
isAnyComponent
|
|
182
|
+
isAnyComponent,
|
|
183
|
+
renderToTsx
|
|
153
184
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.cjs');
|
|
@@ -15,11 +16,11 @@ var Exit = (_class = class _Exit {
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
get zSchema() {
|
|
18
|
-
return this.schema ? _zui.
|
|
19
|
+
return this.schema ? _zui.transforms.fromJSONSchemaLegacy(this.schema) : void 0;
|
|
19
20
|
}
|
|
20
21
|
rename(name) {
|
|
21
22
|
const before = this.name;
|
|
22
|
-
if (!
|
|
23
|
+
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, name)) {
|
|
23
24
|
throw new Error(
|
|
24
25
|
`Invalid name for exit ${name}. An exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
25
26
|
);
|
|
@@ -44,7 +45,7 @@ var Exit = (_class = class _Exit {
|
|
|
44
45
|
return result.exit instanceof _Exit && this.name === result.exit.name;
|
|
45
46
|
}
|
|
46
47
|
constructor(props) {;_class.prototype.__init.call(this);
|
|
47
|
-
if (!
|
|
48
|
+
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
48
49
|
throw new Error(
|
|
49
50
|
`Invalid name for exit ${props.name}. A exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
50
51
|
);
|
|
@@ -64,13 +65,13 @@ var Exit = (_class = class _Exit {
|
|
|
64
65
|
`Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
68
|
+
if (props.aliases && props.aliases.some((alias) => !_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, alias))) {
|
|
68
69
|
throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
|
|
69
70
|
}
|
|
70
71
|
if (typeof props.schema !== "undefined") {
|
|
71
|
-
if (
|
|
72
|
-
this.schema = props.schema
|
|
73
|
-
} else if (
|
|
72
|
+
if (_chunk276Q6EWPcjs.isZuiSchema.call(void 0, props.schema)) {
|
|
73
|
+
this.schema = _zui.transforms.toJSONSchemaLegacy(props.schema);
|
|
74
|
+
} else if (_chunk276Q6EWPcjs.isJsonSchema.call(void 0, props.schema)) {
|
|
74
75
|
this.schema = props.schema;
|
|
75
76
|
} else {
|
|
76
77
|
throw new Error(
|