llmz 0.0.8 → 0.0.10
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/package.json +3 -3
- package/dist/chat.d.ts +0 -17
- package/dist/chunk-276Q6EWP.cjs +0 -224
- package/dist/chunk-4L6D2A6O.cjs +0 -283
- package/dist/chunk-4MNIJGK6.js +0 -224
- package/dist/chunk-7WRN4E42.js +0 -3087
- package/dist/chunk-BEPRLBPK.cjs +0 -3123
- package/dist/chunk-C6WNNTEV.cjs +0 -212
- package/dist/chunk-D3ESDRLH.js +0 -3123
- package/dist/chunk-GGWM6X2K.js +0 -184
- package/dist/chunk-GWFYZDUR.cjs +0 -105
- package/dist/chunk-HJKOSEH2.cjs +0 -722
- package/dist/chunk-IH2WQFO5.js +0 -283
- package/dist/chunk-IKSIOIIP.cjs +0 -28
- package/dist/chunk-JAGB2AOU.js +0 -212
- package/dist/chunk-JDABP4SD.cjs +0 -161
- package/dist/chunk-JGVAZO4X.cjs +0 -152
- package/dist/chunk-JKVVQN2P.js +0 -161
- package/dist/chunk-JMSZKB4T.js +0 -105
- package/dist/chunk-JQBT7UWN.js +0 -28
- package/dist/chunk-KH6JQYQA.js +0 -796
- package/dist/chunk-KMZDFWYZ.cjs +0 -33
- package/dist/chunk-ORQP26SZ.js +0 -33
- package/dist/chunk-PRVFVXT4.js +0 -722
- package/dist/chunk-SHJDRZF5.cjs +0 -796
- package/dist/chunk-SNDVQU5A.js +0 -152
- package/dist/chunk-UQOBUJIQ.cjs +0 -3087
- package/dist/chunk-ZRCU35UV.cjs +0 -184
- package/dist/citations.d.ts +0 -63
- package/dist/compiler/compiler.d.ts +0 -28
- package/dist/compiler/index.d.ts +0 -2
- package/dist/compiler/plugins/async-iterator.d.ts +0 -4
- package/dist/compiler/plugins/braces-tsx.d.ts +0 -3
- package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +0 -5
- package/dist/compiler/plugins/line-tracking.d.ts +0 -5
- package/dist/compiler/plugins/replace-comment.d.ts +0 -5
- package/dist/compiler/plugins/return-async.d.ts +0 -4
- package/dist/compiler/plugins/track-tool-calls.d.ts +0 -16
- package/dist/compiler/plugins/variable-extraction.d.ts +0 -5
- package/dist/component-R4WTW6DZ.cjs +0 -18
- package/dist/component-WFVDVSDK.js +0 -18
- package/dist/component.d.ts +0 -66
- package/dist/component.default.d.ts +0 -316
- package/dist/context.d.ts +0 -176
- package/dist/dual-modes-T53P72CH.js +0 -12
- package/dist/dual-modes-VLIGPIHX.cjs +0 -12
- package/dist/errors.d.ts +0 -64
- package/dist/exit-TRXEU4OU.cjs +0 -8
- package/dist/exit-YORW76T3.js +0 -8
- package/dist/exit.d.ts +0 -26
- package/dist/formatting.d.ts +0 -5
- package/dist/getter.d.ts +0 -2
- package/dist/handlers.d.ts +0 -10
- package/dist/hoist.d.ts +0 -2
- package/dist/index.cjs +0 -921
- package/dist/index.d.ts +0 -23
- package/dist/index.js +0 -921
- package/dist/inspect.d.ts +0 -6
- package/dist/jsx-AEHVFB3L.js +0 -13
- package/dist/jsx-AJAXBWFE.cjs +0 -13
- package/dist/jsx.d.ts +0 -11
- package/dist/llmz-QLZBDG2Z.cjs +0 -576
- package/dist/llmz-ROOX7RYI.js +0 -576
- package/dist/llmz.d.ts +0 -40
- package/dist/objects.d.ts +0 -24
- package/dist/prompts/chat-mode/system.md.d.ts +0 -2
- package/dist/prompts/chat-mode/user.md.d.ts +0 -2
- package/dist/prompts/common.d.ts +0 -6
- package/dist/prompts/dual-modes.d.ts +0 -2
- package/dist/prompts/prompt.d.ts +0 -55
- package/dist/prompts/worker-mode/system.md.d.ts +0 -2
- package/dist/prompts/worker-mode/user.md.d.ts +0 -2
- package/dist/result.d.ts +0 -33
- package/dist/snapshots.d.ts +0 -69
- package/dist/stack-traces.d.ts +0 -1
- package/dist/tool-N6ODRRGH.js +0 -11
- package/dist/tool-QP4MVRWI.cjs +0 -11
- package/dist/tool.d.ts +0 -56
- package/dist/transcript.d.ts +0 -36
- package/dist/truncator-DUMWEGQO.cjs +0 -10
- package/dist/truncator-IY2MXOMC.js +0 -10
- package/dist/truncator.d.ts +0 -20
- package/dist/types.d.ts +0 -105
- package/dist/typings-2CPHOFDN.cjs +0 -10
- package/dist/typings-GDMY6VY2.js +0 -10
- package/dist/typings.d.ts +0 -5
- package/dist/utils-A7WNEFTA.cjs +0 -39
- package/dist/utils-N24IHDFA.js +0 -39
- package/dist/utils.d.ts +0 -23
- package/dist/vm-2DLG7V4G.cjs +0 -12
- package/dist/vm-FLBMZUA2.js +0 -12
- package/dist/vm.d.ts +0 -3
package/dist/chunk-C6WNNTEV.cjs
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
|
-
|
|
3
|
-
var _chunk4L6D2A6Ocjs = require('./chunk-4L6D2A6O.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.cjs');
|
|
14
|
-
|
|
15
|
-
// src/tool.ts
|
|
16
|
-
var _zui = require('@bpinternal/zui');
|
|
17
|
-
var Tool = (_class = class _Tool {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__init() {this.aliases = []}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__init2() {this.MAX_RETRIES = 1e3}
|
|
27
|
-
setStaticInputValues(values) {
|
|
28
|
-
if (values === null || values === void 0) {
|
|
29
|
-
this._staticInputValues = void 0;
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
const input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
|
|
33
|
-
if (input instanceof _zui.z.ZodObject && typeof values !== "object") {
|
|
34
|
-
throw new Error(
|
|
35
|
-
`Invalid static input values for tool ${this.name}. Expected an object, but got type "${typeof values}"`
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
if (input instanceof _zui.z.ZodArray && !Array.isArray(values)) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`Invalid static input values for tool ${this.name}. Expected an array, but got type "${typeof values}"`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
this._staticInputValues = values;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
get zInput() {
|
|
47
|
-
let input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
|
|
48
|
-
if (!_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
49
|
-
const inputExtensions = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
50
|
-
if (input instanceof _zui.z.ZodObject) {
|
|
51
|
-
input = input.extend(inputExtensions);
|
|
52
|
-
} else if (input instanceof _zui.z.ZodArray) {
|
|
53
|
-
input = _zui.z.array(input.element.extend(inputExtensions));
|
|
54
|
-
} else {
|
|
55
|
-
input = inputExtensions;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return input;
|
|
59
|
-
}
|
|
60
|
-
get zOutput() {
|
|
61
|
-
return this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : _zui.z.void();
|
|
62
|
-
}
|
|
63
|
-
rename(name) {
|
|
64
|
-
const before = this.name;
|
|
65
|
-
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, name)) {
|
|
66
|
-
throw new Error(
|
|
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.`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
this.name = name;
|
|
71
|
-
this.aliases = _chunkUQOBUJIQcjs.uniq_default.call(void 0, [name, ...this.aliases.map((alias) => alias === before ? name : alias)]);
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
clone(props = {}) {
|
|
75
|
-
var _a, _b;
|
|
76
|
-
try {
|
|
77
|
-
const zInput = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : void 0;
|
|
78
|
-
const zOutput = this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : void 0;
|
|
79
|
-
return new _Tool({
|
|
80
|
-
name: _nullishCoalesce(props.name, () => ( this.name)),
|
|
81
|
-
aliases: _nullishCoalesce(props.aliases, () => ( [...this.aliases])),
|
|
82
|
-
description: _nullishCoalesce(props.description, () => ( this.description)),
|
|
83
|
-
metadata: JSON.parse(JSON.stringify(_nullishCoalesce(props.metadata, () => ( this.metadata)))),
|
|
84
|
-
input: typeof props.input === "function" ? (_a = props.input) == null ? void 0 : _a.call(props, zInput) : props.input instanceof _zui.ZodType ? props.input : zInput,
|
|
85
|
-
output: typeof props.output === "function" ? (_b = props.output) == null ? void 0 : _b.call(props, zOutput) : props.output instanceof _zui.ZodType ? props.output : zOutput,
|
|
86
|
-
handler: _nullishCoalesce(props.handler, () => ( this._handler)),
|
|
87
|
-
retry: _nullishCoalesce(props.retry, () => ( this.retry))
|
|
88
|
-
}).setStaticInputValues(_nullishCoalesce(props.staticInputValues, () => ( this._staticInputValues)));
|
|
89
|
-
} catch (e) {
|
|
90
|
-
throw new Error(`Failed to clone tool "${this.name}": ${e}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
constructor(props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
95
|
-
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
96
|
-
throw new Error(
|
|
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.`
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
if (props.description !== void 0 && typeof props.description !== "string") {
|
|
101
|
-
throw new Error(
|
|
102
|
-
`Invalid description for tool ${props.name}. Expected a string, but got type "${typeof props.description}"`
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
if (props.metadata !== void 0 && typeof props.metadata !== "object") {
|
|
106
|
-
throw new Error(
|
|
107
|
-
`Invalid metadata for tool ${props.name}. Expected an object, but got type "${typeof props.metadata}"`
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
if (typeof props.handler !== "function") {
|
|
111
|
-
throw new Error(
|
|
112
|
-
`Invalid handler for tool ${props.name}. Expected a function, but got type "${typeof props.handler}"`
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
if (props.aliases !== void 0 && !Array.isArray(props.aliases)) {
|
|
116
|
-
throw new Error(
|
|
117
|
-
`Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
if (props.aliases && props.aliases.some((alias) => !_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, alias))) {
|
|
121
|
-
throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
|
|
122
|
-
}
|
|
123
|
-
if (typeof props.input !== "undefined") {
|
|
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)) {
|
|
127
|
-
this.input = props.input;
|
|
128
|
-
} else {
|
|
129
|
-
throw new Error(
|
|
130
|
-
`Invalid input schema for tool ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.input}"`
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (typeof props.output !== "undefined") {
|
|
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)) {
|
|
138
|
-
this.output = props.output;
|
|
139
|
-
} else {
|
|
140
|
-
throw new Error(
|
|
141
|
-
`Invalid output schema for tool ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.output}"`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
this.name = props.name;
|
|
146
|
-
this.aliases = _chunkUQOBUJIQcjs.uniq_default.call(void 0, [props.name, ..._nullishCoalesce(props.aliases, () => ( []))]);
|
|
147
|
-
this.description = props.description;
|
|
148
|
-
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
149
|
-
this._handler = props.handler;
|
|
150
|
-
this.setStaticInputValues(props.staticInputValues);
|
|
151
|
-
this.retry = props.retry;
|
|
152
|
-
}
|
|
153
|
-
async execute(input, ctx) {
|
|
154
|
-
var _a;
|
|
155
|
-
const pInput = this.zInput.safeParse(input);
|
|
156
|
-
if (!pInput.success) {
|
|
157
|
-
throw new Error(`Tool "${this.name}" received invalid input: ${pInput.error.message}`);
|
|
158
|
-
}
|
|
159
|
-
let attempt = 0;
|
|
160
|
-
while (attempt < this.MAX_RETRIES) {
|
|
161
|
-
try {
|
|
162
|
-
const result = await this._handler(pInput.data, ctx);
|
|
163
|
-
const pOutput = this.zOutput.safeParse(result);
|
|
164
|
-
return pOutput.success ? pOutput.data : result;
|
|
165
|
-
} catch (err) {
|
|
166
|
-
const shouldRetry = await ((_a = this.retry) == null ? void 0 : _a.call(this, {
|
|
167
|
-
input: pInput.data,
|
|
168
|
-
attempt: ++attempt,
|
|
169
|
-
error: err
|
|
170
|
-
}));
|
|
171
|
-
if (!shouldRetry) {
|
|
172
|
-
throw err;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
throw new Error(
|
|
177
|
-
`Tool "${this.name}" failed after ${this.MAX_RETRIES} attempts. Last error: ${JSON.stringify(input)}`
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
async getTypings() {
|
|
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();
|
|
183
|
-
if ((input == null ? void 0 : input.naked()) instanceof _zui.ZodObject && typeof this._staticInputValues === "object" && !_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
184
|
-
const inputExtensions = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
185
|
-
input = input.extend(inputExtensions);
|
|
186
|
-
} else if (this._staticInputValues !== void 0) {
|
|
187
|
-
input = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
188
|
-
}
|
|
189
|
-
const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
|
|
190
|
-
return _chunk4L6D2A6Ocjs.getTypings.call(void 0, fnType, {
|
|
191
|
-
declaration: true
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
static __initStatic() {this.withUniqueNames = (tools) => {
|
|
195
|
-
const names = /* @__PURE__ */ new Set();
|
|
196
|
-
return tools.map((tool) => {
|
|
197
|
-
if (tools.filter((t) => t.name === tool.name).length === 1) {
|
|
198
|
-
return tool;
|
|
199
|
-
}
|
|
200
|
-
let counter = 1;
|
|
201
|
-
let toolName = tool.name + counter;
|
|
202
|
-
while (names.has(toolName)) {
|
|
203
|
-
toolName = `${tool.name}${++counter}`;
|
|
204
|
-
}
|
|
205
|
-
return tool.rename(toolName);
|
|
206
|
-
});
|
|
207
|
-
}}
|
|
208
|
-
}, _class.__initStatic(), _class);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
exports.Tool = Tool;
|