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
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkSHJDRZF5cjs = require('./chunk-SHJDRZF5.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkC6WNNTEVcjs = require('./chunk-C6WNNTEV.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkGWFYZDURcjs = require('./chunk-GWFYZDUR.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkJGVAZO4Xcjs = require('./chunk-JGVAZO4X.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -46,10 +46,10 @@ var Snapshot = class _Snapshot {
|
|
|
46
46
|
}
|
|
47
47
|
static fromSignal(signal) {
|
|
48
48
|
const variables = Object.entries(signal.variables).map(([name, value]) => {
|
|
49
|
-
const type =
|
|
49
|
+
const type = _chunkSHJDRZF5cjs.extractType.call(void 0, value);
|
|
50
50
|
const bytes = JSON.stringify(value || "").length;
|
|
51
51
|
const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
|
|
52
|
-
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(
|
|
52
|
+
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkSHJDRZF5cjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
|
|
53
53
|
});
|
|
54
54
|
return new _Snapshot({
|
|
55
55
|
id: "snapshot_" + _ulid.ulid.call(void 0, ),
|
|
@@ -107,6 +107,77 @@ var Snapshot = class _Snapshot {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
+
// src/transcript.ts
|
|
111
|
+
var MAX_MESSAGE_LENGTH = 5e3;
|
|
112
|
+
function getMessagePreview(message) {
|
|
113
|
+
if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
|
|
114
|
+
return message.content;
|
|
115
|
+
}
|
|
116
|
+
if (message.role === "event") {
|
|
117
|
+
return _chunkSHJDRZF5cjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
|
|
118
|
+
}
|
|
119
|
+
return _chunkSHJDRZF5cjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
|
|
120
|
+
}
|
|
121
|
+
function getMessageType(message) {
|
|
122
|
+
if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
|
|
123
|
+
return message.role;
|
|
124
|
+
}
|
|
125
|
+
if (message.role === "event") {
|
|
126
|
+
return `event:${message.name}`;
|
|
127
|
+
}
|
|
128
|
+
return "unknown";
|
|
129
|
+
}
|
|
130
|
+
var TranscriptArray = class extends Array {
|
|
131
|
+
constructor(items = []) {
|
|
132
|
+
items = Array.isArray(items) ? items : [];
|
|
133
|
+
super(...items);
|
|
134
|
+
items.forEach((item) => {
|
|
135
|
+
if (!["user", "assistant"].includes(item.role)) {
|
|
136
|
+
throw new Error(`Invalid role "${item.role}" in transcript message`);
|
|
137
|
+
}
|
|
138
|
+
if ("name" in item && item.name && typeof item.name !== "string") {
|
|
139
|
+
throw new Error(`Invalid name for transcript message. Expected a string, but got type "${typeof item.name}"`);
|
|
140
|
+
}
|
|
141
|
+
if ("content" in item && typeof item.content !== "string") {
|
|
142
|
+
throw new Error(
|
|
143
|
+
`Invalid content for transcript message. Expected a string, but got type "${typeof item.content}"`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
148
|
+
}
|
|
149
|
+
toString() {
|
|
150
|
+
if (!this.length) {
|
|
151
|
+
return "";
|
|
152
|
+
}
|
|
153
|
+
return this.map((item, idx) => {
|
|
154
|
+
var _a, _b;
|
|
155
|
+
const msgIdx = getMessageType(item) + "-" + String(idx + 1).padStart(3, "0");
|
|
156
|
+
let preview = getMessagePreview(item);
|
|
157
|
+
if (preview.length > MAX_MESSAGE_LENGTH) {
|
|
158
|
+
preview = preview.slice(0, MAX_MESSAGE_LENGTH) + "\n... (truncated)";
|
|
159
|
+
}
|
|
160
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
161
|
+
if ((item.role === "event" || item.role === "user") && ((_a = item.attachments) == null ? void 0 : _a.length)) {
|
|
162
|
+
for (let i = 0; i < item.attachments.length; i++) {
|
|
163
|
+
const attachmentIdx = alphabet[i % alphabet.length];
|
|
164
|
+
preview += `
|
|
165
|
+
[Attachment ${msgIdx}-${attachmentIdx}]`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const tags = [];
|
|
169
|
+
tags.push({ key: "role", value: item.role });
|
|
170
|
+
if ("name" in item && ((_b = item.name) == null ? void 0 : _b.length)) {
|
|
171
|
+
tags.push({ key: "name", value: item.name });
|
|
172
|
+
}
|
|
173
|
+
const tagsString = tags.map(({ key, value }) => `${key}="${value}"`).join(" ");
|
|
174
|
+
return `<${msgIdx} ${tagsString}>
|
|
175
|
+
${preview.trim()}
|
|
176
|
+
</${msgIdx}>`;
|
|
177
|
+
}).join("\n");
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
110
181
|
// src/result.ts
|
|
111
182
|
var ExecutionResult = class {
|
|
112
183
|
|
|
@@ -221,59 +292,16 @@ var HookedArray = class extends Array {
|
|
|
221
292
|
}
|
|
222
293
|
};
|
|
223
294
|
|
|
224
|
-
// src/transcript.ts
|
|
225
|
-
var MAX_MESSAGE_LENGTH = 5e3;
|
|
226
|
-
var TranscriptArray = class extends Array {
|
|
227
|
-
constructor(items = []) {
|
|
228
|
-
items = Array.isArray(items) ? items : [];
|
|
229
|
-
super(...items);
|
|
230
|
-
items.forEach((item) => {
|
|
231
|
-
if (!["user", "assistant"].includes(item.role)) {
|
|
232
|
-
throw new Error(`Invalid role "${item.role}" in transcript message`);
|
|
233
|
-
}
|
|
234
|
-
if (item.name && typeof item.name !== "string") {
|
|
235
|
-
throw new Error(`Invalid name for transcript message. Expected a string, but got type "${typeof item.name}"`);
|
|
236
|
-
}
|
|
237
|
-
if (typeof item.content !== "string") {
|
|
238
|
-
throw new Error(
|
|
239
|
-
`Invalid content for transcript message. Expected a string, but got type "${typeof item.content}"`
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
244
|
-
}
|
|
245
|
-
toString() {
|
|
246
|
-
if (!this.length) {
|
|
247
|
-
return "";
|
|
248
|
-
}
|
|
249
|
-
return this.map((item, idx) => {
|
|
250
|
-
var _a;
|
|
251
|
-
const msgIdx = "message-" + String(idx + 1).padStart(3, "0");
|
|
252
|
-
const shouldTruncate = item.content.length > MAX_MESSAGE_LENGTH;
|
|
253
|
-
const preview = shouldTruncate ? item.content.slice(0, MAX_MESSAGE_LENGTH) + "\n... (truncated)" : item.content;
|
|
254
|
-
const tags = [];
|
|
255
|
-
tags.push({ key: "role", value: item.role });
|
|
256
|
-
if ((_a = item.name) == null ? void 0 : _a.length) {
|
|
257
|
-
tags.push({ key: "name", value: item.name });
|
|
258
|
-
}
|
|
259
|
-
const tagsString = tags.map(({ key, value }) => `${key}="${value}"`).join(" ");
|
|
260
|
-
return `<${msgIdx} ${tagsString}>
|
|
261
|
-
${preview.trim()}
|
|
262
|
-
</${msgIdx}>`;
|
|
263
|
-
}).join("\n");
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
295
|
// src/context.ts
|
|
268
|
-
var ThinkExit = new (0,
|
|
296
|
+
var ThinkExit = new (0, _chunkGWFYZDURcjs.Exit)({
|
|
269
297
|
name: "think",
|
|
270
298
|
description: "Think about the current situation and provide a response"
|
|
271
299
|
});
|
|
272
|
-
var ListenExit = new (0,
|
|
300
|
+
var ListenExit = new (0, _chunkGWFYZDURcjs.Exit)({
|
|
273
301
|
name: "listen",
|
|
274
302
|
description: "Listen to the user and provide a response"
|
|
275
303
|
});
|
|
276
|
-
var DefaultExit = new (0,
|
|
304
|
+
var DefaultExit = new (0, _chunkGWFYZDURcjs.Exit)({
|
|
277
305
|
name: "done",
|
|
278
306
|
description: "When the execution is sucessfully completed or when error recovery is not possible",
|
|
279
307
|
schema: _zui.z.discriminatedUnion("success", [
|
|
@@ -395,7 +423,7 @@ var Context = (_class2 = class {
|
|
|
395
423
|
|
|
396
424
|
|
|
397
425
|
|
|
398
|
-
__init3() {this.version =
|
|
426
|
+
__init3() {this.version = _chunkSHJDRZF5cjs.DualModePrompt}
|
|
399
427
|
__init4() {this.timeout = 6e4}
|
|
400
428
|
// Default timeout of 60 seconds
|
|
401
429
|
|
|
@@ -510,7 +538,7 @@ var Context = (_class2 = class {
|
|
|
510
538
|
...lastIterationMessages,
|
|
511
539
|
{
|
|
512
540
|
role: "assistant",
|
|
513
|
-
content:
|
|
541
|
+
content: _chunkJGVAZO4Xcjs.wrapContent.call(void 0, _nullishCoalesce(((_c = lastIteration.llm) == null ? void 0 : _c.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
514
542
|
},
|
|
515
543
|
await this.version.getThinkingMessage({
|
|
516
544
|
reason: lastIteration.status.thinking_requested.reason,
|
|
@@ -523,7 +551,7 @@ var Context = (_class2 = class {
|
|
|
523
551
|
...lastIterationMessages,
|
|
524
552
|
{
|
|
525
553
|
role: "assistant",
|
|
526
|
-
content:
|
|
554
|
+
content: _chunkJGVAZO4Xcjs.wrapContent.call(void 0, _nullishCoalesce(((_d = lastIteration.llm) == null ? void 0 : _d.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
527
555
|
},
|
|
528
556
|
await this.version.getInvalidCodeMessage({
|
|
529
557
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -536,7 +564,7 @@ var Context = (_class2 = class {
|
|
|
536
564
|
...lastIterationMessages,
|
|
537
565
|
{
|
|
538
566
|
role: "assistant",
|
|
539
|
-
content:
|
|
567
|
+
content: _chunkJGVAZO4Xcjs.wrapContent.call(void 0, _nullishCoalesce(((_e = lastIteration.llm) == null ? void 0 : _e.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
540
568
|
},
|
|
541
569
|
await this.version.getInvalidCodeMessage({
|
|
542
570
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -549,7 +577,7 @@ var Context = (_class2 = class {
|
|
|
549
577
|
...lastIterationMessages,
|
|
550
578
|
{
|
|
551
579
|
role: "assistant",
|
|
552
|
-
content:
|
|
580
|
+
content: _chunkJGVAZO4Xcjs.wrapContent.call(void 0, _nullishCoalesce(((_f = lastIteration.llm) == null ? void 0 : _f.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
553
581
|
},
|
|
554
582
|
await this.version.getCodeExecutionErrorMessage({
|
|
555
583
|
message: lastIteration.status.execution_error.message,
|
|
@@ -565,7 +593,7 @@ var Context = (_class2 = class {
|
|
|
565
593
|
var _a, _b;
|
|
566
594
|
const instructions = await getValue(this.instructions, this);
|
|
567
595
|
const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
|
|
568
|
-
const tools =
|
|
596
|
+
const tools = _chunkC6WNNTEVcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
|
|
569
597
|
const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
|
|
570
598
|
const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
|
|
571
599
|
const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
|
|
@@ -576,7 +604,7 @@ var Context = (_class2 = class {
|
|
|
576
604
|
throw new Error("Too many tools. Expected at most 100 tools.");
|
|
577
605
|
}
|
|
578
606
|
for (const component of components) {
|
|
579
|
-
|
|
607
|
+
_chunkZRCU35UVcjs.assertValidComponent.call(void 0, component.definition);
|
|
580
608
|
}
|
|
581
609
|
const ReservedToolNames = [
|
|
582
610
|
"think",
|
|
@@ -595,7 +623,7 @@ var Context = (_class2 = class {
|
|
|
595
623
|
"boolean",
|
|
596
624
|
"array"
|
|
597
625
|
];
|
|
598
|
-
const MessageTool = this.chat && components.length ? new (0,
|
|
626
|
+
const MessageTool = this.chat && components.length ? new (0, _chunkC6WNNTEVcjs.Tool)({
|
|
599
627
|
name: "Message",
|
|
600
628
|
description: "Send a message to the user",
|
|
601
629
|
aliases: Array.from(
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
escapeString,
|
|
6
6
|
getMultilineComment,
|
|
7
7
|
toPropertyKey
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4MNIJGK6.js";
|
|
9
9
|
|
|
10
10
|
// src/typings.ts
|
|
11
11
|
import { z } from "@bpinternal/zui";
|
|
@@ -268,7 +268,7 @@ ${typeof schema.value === "string" ? escapeString(schema.value) : schema.value}`
|
|
|
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) {
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTypings
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IH2WQFO5.js";
|
|
4
4
|
import {
|
|
5
5
|
convertObjectToZuiLiterals,
|
|
6
6
|
isJsonSchema,
|
|
7
|
-
isValidIdentifier
|
|
8
|
-
|
|
7
|
+
isValidIdentifier,
|
|
8
|
+
isZuiSchema
|
|
9
|
+
} from "./chunk-4MNIJGK6.js";
|
|
9
10
|
import {
|
|
10
11
|
isEmpty_default,
|
|
11
12
|
uniq_default
|
|
12
13
|
} from "./chunk-7WRN4E42.js";
|
|
13
14
|
|
|
14
15
|
// src/tool.ts
|
|
15
|
-
import { z, ZodObject, ZodType } from "@bpinternal/zui";
|
|
16
|
+
import { z, transforms, ZodObject, ZodType } from "@bpinternal/zui";
|
|
16
17
|
var Tool = class _Tool {
|
|
17
18
|
_staticInputValues;
|
|
18
19
|
name;
|
|
@@ -28,7 +29,7 @@ var Tool = class _Tool {
|
|
|
28
29
|
this._staticInputValues = void 0;
|
|
29
30
|
return this;
|
|
30
31
|
}
|
|
31
|
-
const input = this.input ?
|
|
32
|
+
const input = this.input ? transforms.fromJSONSchemaLegacy(this.input) : z.any();
|
|
32
33
|
if (input instanceof 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,7 +44,7 @@ var Tool = class _Tool {
|
|
|
43
44
|
return this;
|
|
44
45
|
}
|
|
45
46
|
get zInput() {
|
|
46
|
-
let input = this.input ?
|
|
47
|
+
let input = this.input ? transforms.fromJSONSchemaLegacy(this.input) : z.any();
|
|
47
48
|
if (!isEmpty_default(this._staticInputValues)) {
|
|
48
49
|
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
49
50
|
if (input instanceof z.ZodObject) {
|
|
@@ -57,7 +58,7 @@ var Tool = class _Tool {
|
|
|
57
58
|
return input;
|
|
58
59
|
}
|
|
59
60
|
get zOutput() {
|
|
60
|
-
return this.output ?
|
|
61
|
+
return this.output ? transforms.fromJSONSchemaLegacy(this.output) : z.void();
|
|
61
62
|
}
|
|
62
63
|
rename(name) {
|
|
63
64
|
const before = this.name;
|
|
@@ -73,8 +74,8 @@ var Tool = class _Tool {
|
|
|
73
74
|
clone(props = {}) {
|
|
74
75
|
var _a, _b;
|
|
75
76
|
try {
|
|
76
|
-
const zInput = this.input ?
|
|
77
|
-
const zOutput = this.output ?
|
|
77
|
+
const zInput = this.input ? transforms.fromJSONSchemaLegacy(this.input) : void 0;
|
|
78
|
+
const zOutput = this.output ? transforms.fromJSONSchemaLegacy(this.output) : void 0;
|
|
78
79
|
return new _Tool({
|
|
79
80
|
name: props.name ?? this.name,
|
|
80
81
|
aliases: props.aliases ?? [...this.aliases],
|
|
@@ -120,8 +121,8 @@ var Tool = class _Tool {
|
|
|
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 (props.input
|
|
124
|
-
this.input = props.input
|
|
124
|
+
if (isZuiSchema(props.input)) {
|
|
125
|
+
this.input = transforms.toJSONSchemaLegacy(props.input);
|
|
125
126
|
} else if (isJsonSchema(props.input)) {
|
|
126
127
|
this.input = props.input;
|
|
127
128
|
} else {
|
|
@@ -131,8 +132,8 @@ var Tool = class _Tool {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
if (typeof props.output !== "undefined") {
|
|
134
|
-
if (props.output
|
|
135
|
-
this.output = props.output
|
|
135
|
+
if (isZuiSchema(props.output)) {
|
|
136
|
+
this.output = transforms.toJSONSchemaLegacy(props.output);
|
|
136
137
|
} else if (isJsonSchema(props.output)) {
|
|
137
138
|
this.output = props.output;
|
|
138
139
|
} else {
|
|
@@ -177,8 +178,8 @@ var Tool = class _Tool {
|
|
|
177
178
|
);
|
|
178
179
|
}
|
|
179
180
|
async getTypings() {
|
|
180
|
-
let input = this.input ?
|
|
181
|
-
const output = this.output ?
|
|
181
|
+
let input = this.input ? transforms.fromJSONSchemaLegacy(this.input) : void 0;
|
|
182
|
+
const output = this.output ? transforms.fromJSONSchemaLegacy(this.output) : z.void();
|
|
182
183
|
if ((input == null ? void 0 : input.naked()) instanceof ZodObject && typeof this._staticInputValues === "object" && !isEmpty_default(this._staticInputValues)) {
|
|
183
184
|
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
184
185
|
input = input.extend(inputExtensions);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
|
|
4
4
|
|
|
5
5
|
// src/truncator.ts
|
|
6
6
|
var DEFAULT_REMOVE_CHUNK = 250;
|
|
@@ -25,11 +25,11 @@ function truncateWrappedContent({
|
|
|
25
25
|
throwOnFailure = true
|
|
26
26
|
}) {
|
|
27
27
|
var _a, _b, _c;
|
|
28
|
-
const tokenizer =
|
|
28
|
+
const tokenizer = _chunk276Q6EWPcjs.getTokenizer.call(void 0, );
|
|
29
29
|
const parts = [];
|
|
30
30
|
for (const msg of messages) {
|
|
31
31
|
const current = [];
|
|
32
|
-
const content = msg.content;
|
|
32
|
+
const content = typeof msg.content === "string" ? msg.content : "";
|
|
33
33
|
let match;
|
|
34
34
|
const regex = getRegex();
|
|
35
35
|
let lastIndex = 0;
|
|
@@ -134,14 +134,14 @@ function truncateWrappedContent({
|
|
|
134
134
|
const p = parts[i];
|
|
135
135
|
return {
|
|
136
136
|
...msg,
|
|
137
|
-
content: removeRedundantWrappers(
|
|
137
|
+
content: typeof msg.content === "string" ? removeRedundantWrappers(
|
|
138
138
|
p.map((part) => {
|
|
139
139
|
if (part.truncatable) {
|
|
140
140
|
return part.content;
|
|
141
141
|
}
|
|
142
142
|
return part.content;
|
|
143
143
|
}).join("")
|
|
144
|
-
)
|
|
144
|
+
) : msg.content
|
|
145
145
|
};
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isJsonSchema,
|
|
3
|
-
isValidIdentifier
|
|
4
|
-
|
|
3
|
+
isValidIdentifier,
|
|
4
|
+
isZuiSchema
|
|
5
|
+
} from "./chunk-4MNIJGK6.js";
|
|
5
6
|
import {
|
|
6
7
|
uniq_default
|
|
7
8
|
} from "./chunk-7WRN4E42.js";
|
|
8
9
|
|
|
9
10
|
// src/exit.ts
|
|
10
|
-
import {
|
|
11
|
+
import { transforms } from "@bpinternal/zui";
|
|
11
12
|
var Exit = class _Exit {
|
|
12
13
|
name;
|
|
13
14
|
aliases = [];
|
|
@@ -15,7 +16,7 @@ var Exit = class _Exit {
|
|
|
15
16
|
metadata;
|
|
16
17
|
schema;
|
|
17
18
|
get zSchema() {
|
|
18
|
-
return this.schema ?
|
|
19
|
+
return this.schema ? transforms.fromJSONSchemaLegacy(this.schema) : void 0;
|
|
19
20
|
}
|
|
20
21
|
rename(name) {
|
|
21
22
|
const before = this.name;
|
|
@@ -68,8 +69,8 @@ var Exit = class _Exit {
|
|
|
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 (props.schema
|
|
72
|
-
this.schema = props.schema
|
|
72
|
+
if (isZuiSchema(props.schema)) {
|
|
73
|
+
this.schema = transforms.toJSONSchemaLegacy(props.schema);
|
|
73
74
|
} else if (isJsonSchema(props.schema)) {
|
|
74
75
|
this.schema = props.schema;
|
|
75
76
|
} else {
|