llmz 0.2.2 → 0.3.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/CLAUDE.md +0 -1
- package/dist/{chunk-2EZSVF5X.cjs → chunk-3UZKLXAD.cjs} +29 -23
- package/dist/{chunk-HM5H556L.js → chunk-72ZWBNZV.js} +1 -1
- package/dist/{chunk-D6PU5YAS.cjs → chunk-DDSJTR6Q.cjs} +8 -7
- package/dist/{chunk-GDWRFHM5.js → chunk-GDJTKI7J.js} +1 -1
- package/dist/{chunk-YX27XM67.js → chunk-GLXADNTR.js} +13 -1
- package/dist/{chunk-FPLSJF4S.cjs → chunk-GOWPACSK.cjs} +15 -3
- package/dist/{chunk-XVVYNOTX.js → chunk-HB2G32AK.js} +3 -2
- package/dist/{chunk-YQT5G77W.cjs → chunk-HEAQAEFZ.cjs} +2 -2
- package/dist/{chunk-MHVORH33.cjs → chunk-HMMM32RG.cjs} +14 -14
- package/dist/{chunk-5XPEVOOW.cjs → chunk-KG5E3UZZ.cjs} +20 -20
- package/dist/{chunk-C2KND2PS.cjs → chunk-OVRDJMZJ.cjs} +26 -34
- package/dist/{chunk-5ISVDYBA.js → chunk-OXEKAOVI.js} +3 -11
- package/dist/{chunk-S46T73HR.cjs → chunk-PZE6PIPG.cjs} +12 -11
- package/dist/chunk-RGUG3UMF.cjs +26 -0
- package/dist/{chunk-3OSQ4XL4.js → chunk-TDALRNGL.js} +4 -3
- package/dist/chunk-UGHFNCPD.js +26 -0
- package/dist/{chunk-2MSLOTFO.js → chunk-XMFQVARN.js} +5 -5
- package/dist/{chunk-EJIDFDQP.js → chunk-YRS7KRKP.js} +28 -22
- package/dist/context.d.ts +2 -2
- package/dist/custom-client.d.ts +4 -3
- package/dist/{dual-modes-J4RWHJ2O.js → dual-modes-BYABHBDI.js} +3 -3
- package/dist/dual-modes-HO6RRIZ5.cjs +10 -0
- package/dist/emscripten-module.wasm +0 -0
- package/dist/{execute-4IL4QPAR.cjs → execute-2H4F7GFE.cjs} +81 -69
- package/dist/{execute-6AYBMTRM.js → execute-DPCZ6PKH.js} +51 -39
- package/dist/exit-MX56VN2C.cjs +8 -0
- package/dist/{exit-VJATJTQI.js → exit-UQ3EUX5D.js} +2 -2
- package/dist/exit.d.ts +1 -1
- package/dist/index.cjs +67 -61
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -17
- package/dist/index.workerd.js +17339 -0
- package/dist/prompts/prompt.d.ts +3 -6
- package/dist/quickjs-variant.d.ts +22 -0
- package/dist/quickjs-variant.workerd.d.ts +22 -0
- package/dist/result.d.ts +3 -3
- package/dist/runtime/types.d.ts +7 -9
- package/dist/{tool-I3MAWDN2.js → tool-KD7FL45V.js} +3 -3
- package/dist/{tool-56I7OSKU.cjs → tool-VE2YHIY2.cjs} +4 -4
- package/dist/{truncator-OZOBNYON.js → truncator-73RCL52Y.js} +2 -2
- package/dist/truncator-FZNLYSDL.cjs +12 -0
- package/dist/{typings-SR3EE6LR.js → typings-E2RROCLT.js} +2 -2
- package/dist/{typings-LVI4VGE2.cjs → typings-LQOBZXSO.cjs} +3 -3
- package/dist/{utils-ZEZ66X6Q.js → utils-IATCUNKF.js} +5 -1
- package/dist/utils-ITB4NEL7.cjs +43 -0
- package/dist/utils.d.ts +18 -0
- package/dist/vm-6D3IIIU7.cjs +12 -0
- package/dist/{vm-ZLWGAYYJ.js → vm-QO5FSGPN.js} +2 -1
- package/package.json +6 -4
- package/dist/dual-modes-IZQJTXR7.cjs +0 -10
- package/dist/exit-LUJY7JIG.cjs +0 -8
- package/dist/truncator-7PGEGCHV.cjs +0 -12
- package/dist/utils-GLZVMRWO.cjs +0 -39
- package/dist/vm-ZVONLAZV.cjs +0 -11
package/CLAUDE.md
CHANGED
|
@@ -240,7 +240,6 @@ pnpm generate
|
|
|
240
240
|
- `tsup`: Fast TypeScript bundler (ESM + CJS output)
|
|
241
241
|
- `vitest`: Modern test framework with TypeScript support
|
|
242
242
|
- `prettier`: Code formatting
|
|
243
|
-
- `handlebars`: Template processing for prompts
|
|
244
243
|
|
|
245
244
|
## Code Architecture Patterns
|
|
246
245
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkRGUG3UMFcjs = require('./chunk-RGUG3UMF.cjs');
|
|
4
|
+
|
|
2
5
|
|
|
3
6
|
|
|
4
7
|
|
|
@@ -2376,23 +2379,6 @@ function compile(code) {
|
|
|
2376
2379
|
};
|
|
2377
2380
|
}
|
|
2378
2381
|
|
|
2379
|
-
// src/quickjs-variant.ts
|
|
2380
|
-
var getVariant = async () => {
|
|
2381
|
-
const module = await Promise.resolve().then(() => _interopRequireWildcard(require("@jitl/quickjs-singlefile-browser-release-sync")));
|
|
2382
|
-
return module.default;
|
|
2383
|
-
};
|
|
2384
|
-
var BundledReleaseSyncVariant = {
|
|
2385
|
-
type: "sync",
|
|
2386
|
-
importFFI: async () => {
|
|
2387
|
-
const variant = await getVariant();
|
|
2388
|
-
return variant.importFFI();
|
|
2389
|
-
},
|
|
2390
|
-
importModuleLoader: async () => {
|
|
2391
|
-
const variant = await getVariant();
|
|
2392
|
-
return variant.importModuleLoader();
|
|
2393
|
-
}
|
|
2394
|
-
};
|
|
2395
|
-
|
|
2396
2382
|
// src/vm/errors.ts
|
|
2397
2383
|
var handleErrorQuickJS = (err, code, _consumer, traces, variables, lines_executed, userCodeStartLine, currentToolCall) => {
|
|
2398
2384
|
err = _chunkPK72FAKDcjs.Signals.maybeDeserializeError(err);
|
|
@@ -2655,7 +2641,15 @@ var NodeDriver = class {
|
|
|
2655
2641
|
|
|
2656
2642
|
var _quickjsemscriptencore = require('quickjs-emscripten-core');
|
|
2657
2643
|
var _quickJSModule;
|
|
2658
|
-
var
|
|
2644
|
+
var _loadedVariant;
|
|
2645
|
+
var loadQuickJSModule = () => {
|
|
2646
|
+
const variant = _chunkRGUG3UMFcjs.getQuickJSVariant.call(void 0, );
|
|
2647
|
+
if (!_quickJSModule || _loadedVariant !== variant) {
|
|
2648
|
+
_loadedVariant = variant;
|
|
2649
|
+
_quickJSModule = _quickjsemscriptencore.newQuickJSWASMModuleFromVariant.call(void 0, variant);
|
|
2650
|
+
}
|
|
2651
|
+
return _quickJSModule;
|
|
2652
|
+
};
|
|
2659
2653
|
var QuickJSDriver = class {
|
|
2660
2654
|
async execute(ctx) {
|
|
2661
2655
|
const { transformed, consumer, context, traces, signal, timeout, code, lines_executed, variables } = ctx;
|
|
@@ -3155,6 +3149,7 @@ var useQuickJS = () => {
|
|
|
3155
3149
|
var _a;
|
|
3156
3150
|
return typeof process === "undefined" || ((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.USE_QUICKJS) !== "false";
|
|
3157
3151
|
};
|
|
3152
|
+
var isWorkerd = () => typeof navigator !== "undefined" && (navigator == null ? void 0 : navigator.userAgent) === "Cloudflare-Workers";
|
|
3158
3153
|
var warmupVM = () => {
|
|
3159
3154
|
if (useQuickJS()) {
|
|
3160
3155
|
loadQuickJSModule().catch(() => {
|
|
@@ -3206,16 +3201,27 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
3206
3201
|
currentToolCall: void 0
|
|
3207
3202
|
});
|
|
3208
3203
|
} catch (quickjsError) {
|
|
3204
|
+
const variant = _chunkRGUG3UMFcjs.getQuickJSVariant.call(void 0, );
|
|
3209
3205
|
const debugInfo = {
|
|
3210
3206
|
error: (quickjsError == null ? void 0 : quickjsError.message) || String(quickjsError),
|
|
3211
3207
|
errorStack: quickjsError == null ? void 0 : quickjsError.stack,
|
|
3212
|
-
wasmSource:
|
|
3213
|
-
wasmLoadedSuccessfully:
|
|
3214
|
-
wasmSize:
|
|
3215
|
-
wasmLoadError:
|
|
3208
|
+
wasmSource: variant._wasmSource,
|
|
3209
|
+
wasmLoadedSuccessfully: variant._wasmLoadedSuccessfully,
|
|
3210
|
+
wasmSize: variant._wasmSize,
|
|
3211
|
+
wasmLoadError: variant._wasmLoadError,
|
|
3216
3212
|
nodeVersion: typeof process !== "undefined" && process.version ? process.version : "undefined",
|
|
3217
3213
|
platform: typeof process !== "undefined" && process.platform ? process.platform : "undefined"
|
|
3218
3214
|
};
|
|
3215
|
+
if (isWorkerd()) {
|
|
3216
|
+
console.error("QuickJS failed to load and the node driver is unavailable on Cloudflare Workers.");
|
|
3217
|
+
console.error("Debug info:", JSON.stringify(debugInfo, null, 2));
|
|
3218
|
+
if (quickjsError instanceof Error) {
|
|
3219
|
+
;
|
|
3220
|
+
quickjsError.debugInfo = debugInfo;
|
|
3221
|
+
throw quickjsError;
|
|
3222
|
+
}
|
|
3223
|
+
throw new Error(`QuickJS failed to load on Cloudflare Workers: ${debugInfo.error}`);
|
|
3224
|
+
}
|
|
3219
3225
|
console.warn("QuickJS failed to load, falling back to node driver.");
|
|
3220
3226
|
console.warn("Error:", (quickjsError == null ? void 0 : quickjsError.message) || quickjsError);
|
|
3221
3227
|
console.warn("Debug info:", JSON.stringify(debugInfo, null, 2));
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
@@ -25,7 +26,7 @@ var Exit = (_class = class _Exit {
|
|
|
25
26
|
* Used internally for validation and type inference.
|
|
26
27
|
*/
|
|
27
28
|
get zSchema() {
|
|
28
|
-
return this.schema ?
|
|
29
|
+
return this.schema ? _chunkGOWPACSKcjs.fromJSONSchemaCompat.call(void 0, this.schema) : void 0;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* Renames the exit and updates aliases accordingly.
|
|
@@ -42,7 +43,7 @@ var Exit = (_class = class _Exit {
|
|
|
42
43
|
*/
|
|
43
44
|
rename(name) {
|
|
44
45
|
const before = this.name;
|
|
45
|
-
if (!
|
|
46
|
+
if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, name)) {
|
|
46
47
|
throw new Error(
|
|
47
48
|
`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.`
|
|
48
49
|
);
|
|
@@ -177,7 +178,7 @@ var Exit = (_class = class _Exit {
|
|
|
177
178
|
* ```
|
|
178
179
|
*/
|
|
179
180
|
constructor(props) {;_class.prototype.__init.call(this);
|
|
180
|
-
if (!
|
|
181
|
+
if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
181
182
|
throw new Error(
|
|
182
183
|
`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.`
|
|
183
184
|
);
|
|
@@ -197,13 +198,13 @@ var Exit = (_class = class _Exit {
|
|
|
197
198
|
`Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
198
199
|
);
|
|
199
200
|
}
|
|
200
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
201
|
+
if (props.aliases && props.aliases.some((alias) => !_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, alias))) {
|
|
201
202
|
throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
|
|
202
203
|
}
|
|
203
204
|
if (typeof props.schema !== "undefined") {
|
|
204
|
-
if (
|
|
205
|
+
if (_chunkGOWPACSKcjs.isZuiSchema.call(void 0, props.schema)) {
|
|
205
206
|
this.schema = _zui.transforms.toJSONSchemaLegacy(props.schema);
|
|
206
|
-
} else if (
|
|
207
|
+
} else if (_chunkGOWPACSKcjs.isJsonSchema.call(void 0, props.schema)) {
|
|
207
208
|
this.schema = props.schema;
|
|
208
209
|
} else {
|
|
209
210
|
throw new Error(
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
import { getWasmTokenizer } from "@bpinternal/thicktoken";
|
|
11
11
|
import { z, transforms } from "@bpinternal/zui";
|
|
12
12
|
var tokenizer = null;
|
|
13
|
+
var configureTokenizer = (customTokenizer) => {
|
|
14
|
+
tokenizer = customTokenizer;
|
|
15
|
+
};
|
|
13
16
|
var init = async () => {
|
|
14
17
|
if (tokenizer) {
|
|
15
18
|
return;
|
|
@@ -138,9 +141,16 @@ var stripInvalidIdentifiers = (object) => {
|
|
|
138
141
|
}
|
|
139
142
|
return pickBy_default(object, (__, key) => Identifier.safeParse(key).success);
|
|
140
143
|
};
|
|
144
|
+
var fromJSONSchemaCompat = (schema) => {
|
|
145
|
+
try {
|
|
146
|
+
return transforms.fromJSONSchemaLegacy(schema);
|
|
147
|
+
} catch {
|
|
148
|
+
return transforms.fromJSONSchema(schema);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
141
151
|
var isValidSchema = (schema) => {
|
|
142
152
|
try {
|
|
143
|
-
|
|
153
|
+
fromJSONSchemaCompat(schema);
|
|
144
154
|
return typeof schema.type === "string";
|
|
145
155
|
} catch {
|
|
146
156
|
return false;
|
|
@@ -167,6 +177,7 @@ function isValidMessageName(name) {
|
|
|
167
177
|
var getErrorMessage = (err) => err instanceof Error ? err.message : JSON.stringify(err);
|
|
168
178
|
|
|
169
179
|
export {
|
|
180
|
+
configureTokenizer,
|
|
170
181
|
init,
|
|
171
182
|
getTokenizer,
|
|
172
183
|
Tokens,
|
|
@@ -178,6 +189,7 @@ export {
|
|
|
178
189
|
awaitObject,
|
|
179
190
|
toValidObjectName,
|
|
180
191
|
stripInvalidIdentifiers,
|
|
192
|
+
fromJSONSchemaCompat,
|
|
181
193
|
isValidSchema,
|
|
182
194
|
isZuiSchema,
|
|
183
195
|
isJsonSchema,
|
|
@@ -10,6 +10,9 @@ var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
|
10
10
|
var _thicktoken = require('@bpinternal/thicktoken');
|
|
11
11
|
var _zui = require('@bpinternal/zui');
|
|
12
12
|
var tokenizer = null;
|
|
13
|
+
var configureTokenizer = (customTokenizer) => {
|
|
14
|
+
tokenizer = customTokenizer;
|
|
15
|
+
};
|
|
13
16
|
var init = async () => {
|
|
14
17
|
if (tokenizer) {
|
|
15
18
|
return;
|
|
@@ -138,11 +141,18 @@ var stripInvalidIdentifiers = (object) => {
|
|
|
138
141
|
}
|
|
139
142
|
return _chunkHC2QZTVTcjs.pickBy_default.call(void 0, object, (__, key) => Identifier.safeParse(key).success);
|
|
140
143
|
};
|
|
144
|
+
var fromJSONSchemaCompat = (schema) => {
|
|
145
|
+
try {
|
|
146
|
+
return _zui.transforms.fromJSONSchemaLegacy(schema);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
return _zui.transforms.fromJSONSchema(schema);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
141
151
|
var isValidSchema = (schema) => {
|
|
142
152
|
try {
|
|
143
|
-
|
|
153
|
+
fromJSONSchemaCompat(schema);
|
|
144
154
|
return typeof schema.type === "string";
|
|
145
|
-
} catch (
|
|
155
|
+
} catch (e2) {
|
|
146
156
|
return false;
|
|
147
157
|
}
|
|
148
158
|
};
|
|
@@ -184,4 +194,6 @@ var getErrorMessage = (err) => err instanceof Error ? err.message : JSON.stringi
|
|
|
184
194
|
|
|
185
195
|
|
|
186
196
|
|
|
187
|
-
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
exports.configureTokenizer = configureTokenizer; 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.fromJSONSchemaCompat = fromJSONSchemaCompat; exports.isValidSchema = isValidSchema; exports.isZuiSchema = isZuiSchema; exports.isJsonSchema = isJsonSchema; exports.isValidIdentifier = isValidIdentifier; exports.isValidMessageName = isValidMessageName; exports.getErrorMessage = getErrorMessage;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
fromJSONSchemaCompat,
|
|
2
3
|
isJsonSchema,
|
|
3
4
|
isValidIdentifier,
|
|
4
5
|
isZuiSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GLXADNTR.js";
|
|
6
7
|
import {
|
|
7
8
|
uniq_default
|
|
8
9
|
} from "./chunk-34GJUS6U.js";
|
|
@@ -25,7 +26,7 @@ var Exit = class _Exit {
|
|
|
25
26
|
* Used internally for validation and type inference.
|
|
26
27
|
*/
|
|
27
28
|
get zSchema() {
|
|
28
|
-
return this.schema ?
|
|
29
|
+
return this.schema ? fromJSONSchemaCompat(this.schema) : void 0;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* Renames the exit and updates aliases accordingly.
|
|
@@ -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(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
|
|
4
4
|
|
|
5
5
|
// src/truncator.ts
|
|
6
6
|
var DEFAULT_REMOVE_CHUNK = 250;
|
|
@@ -25,7 +25,7 @@ function truncateWrappedContent({
|
|
|
25
25
|
throwOnFailure = true
|
|
26
26
|
}) {
|
|
27
27
|
var _a, _b, _c;
|
|
28
|
-
const tokenizer =
|
|
28
|
+
const tokenizer = _chunkGOWPACSKcjs.getTokenizer.call(void 0, );
|
|
29
29
|
const parts = [];
|
|
30
30
|
for (const msg of messages) {
|
|
31
31
|
const current = [];
|
|
@@ -5,7 +5,7 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
|
|
9
9
|
|
|
10
10
|
// src/typings.ts
|
|
11
11
|
var _zui = require('@bpinternal/zui');
|
|
@@ -612,7 +612,7 @@ async function sUnwrapZod(schema, options) {
|
|
|
612
612
|
parent: schema
|
|
613
613
|
};
|
|
614
614
|
if (schema instanceof Declaration) {
|
|
615
|
-
const description =
|
|
615
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema.schema.description);
|
|
616
616
|
const withoutDesc = schema.schema.describe("");
|
|
617
617
|
const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
|
|
618
618
|
const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
|
|
@@ -633,7 +633,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
633
633
|
const optionalToken = schema.key.endsWith("?") ? "" : "?";
|
|
634
634
|
return sUnwrapZodRecursive(new KeyValue(schema.key + optionalToken, innerType), newOptions);
|
|
635
635
|
}
|
|
636
|
-
const description =
|
|
636
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema.value._def.description || schema.value.description);
|
|
637
637
|
const delimiter = (description == null ? void 0 : description.trim().length) > 0 ? "\n" : "";
|
|
638
638
|
const withoutDesc = schema.value.describe("");
|
|
639
639
|
return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
|
|
@@ -644,7 +644,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
644
644
|
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
645
645
|
const argName = _nullishCoalesce(((_b = (_a = schema.schema.items[i]) == null ? void 0 : _a.ui) == null ? void 0 : _b.title), () => ( `arg${i}`));
|
|
646
646
|
const item = schema.schema.items[i];
|
|
647
|
-
args += `${await sUnwrapZodRecursive(new KeyValue(
|
|
647
|
+
args += `${await sUnwrapZodRecursive(new KeyValue(_chunkGOWPACSKcjs.toPropertyKey.call(void 0, argName), item), newOptions)}, `;
|
|
648
648
|
}
|
|
649
649
|
return args;
|
|
650
650
|
}
|
|
@@ -683,7 +683,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
683
683
|
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
684
684
|
}
|
|
685
685
|
if (_zui.z.is.zuiFunction(schema)) {
|
|
686
|
-
const description =
|
|
686
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
687
687
|
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
688
688
|
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
689
689
|
if (options == null ? void 0 : options.declaration) {
|
|
@@ -701,7 +701,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
701
701
|
return `Array<${item}>`;
|
|
702
702
|
}
|
|
703
703
|
if (_zui.z.is.zuiEnum(schema)) {
|
|
704
|
-
const values = schema._def.values.map(
|
|
704
|
+
const values = schema._def.values.map(_chunkGOWPACSKcjs.escapeString);
|
|
705
705
|
return values.join(" | ");
|
|
706
706
|
}
|
|
707
707
|
if (_zui.z.is.zuiTuple(schema)) {
|
|
@@ -726,7 +726,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
726
726
|
const props = await Promise.all(
|
|
727
727
|
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
728
728
|
if (_zui.z.is.zuiType(value)) {
|
|
729
|
-
return sUnwrapZodRecursive(new KeyValue(
|
|
729
|
+
return sUnwrapZodRecursive(new KeyValue(_chunkGOWPACSKcjs.toPropertyKey.call(void 0, key), value), newOptions);
|
|
730
730
|
}
|
|
731
731
|
return `${key}: unknown`;
|
|
732
732
|
})
|
|
@@ -734,11 +734,11 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
734
734
|
return `{ ${props.join("; ")} }`;
|
|
735
735
|
}
|
|
736
736
|
if (_zui.z.is.zuiString(schema)) {
|
|
737
|
-
const description =
|
|
737
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
738
738
|
return `${description} string`.trim();
|
|
739
739
|
}
|
|
740
740
|
if (_zui.z.is.zuiUnion(schema)) {
|
|
741
|
-
const description =
|
|
741
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
742
742
|
const options2 = await Promise.all(
|
|
743
743
|
schema.options.map(async (option) => {
|
|
744
744
|
return sUnwrapZodRecursive(option, newOptions);
|
|
@@ -748,16 +748,16 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
748
748
|
${options2.join(" | ")}`;
|
|
749
749
|
}
|
|
750
750
|
if (_zui.z.is.zuiLiteral(schema)) {
|
|
751
|
-
const description =
|
|
751
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
752
752
|
return `${description}
|
|
753
|
-
${typeof schema.value === "string" ?
|
|
753
|
+
${typeof schema.value === "string" ? _chunkGOWPACSKcjs.escapeString.call(void 0, schema.value) : String(schema.value)}`.trim();
|
|
754
754
|
}
|
|
755
755
|
if (_zui.z.is.zuiNumber(schema)) {
|
|
756
|
-
const description =
|
|
756
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
757
757
|
return `${description} number`.trim();
|
|
758
758
|
}
|
|
759
759
|
if (_zui.z.is.zuiBoolean(schema)) {
|
|
760
|
-
const description =
|
|
760
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
761
761
|
return `${description} boolean`.trim();
|
|
762
762
|
}
|
|
763
763
|
if (_zui.z.is.zuiCatch(schema)) {
|
|
@@ -767,7 +767,7 @@ ${typeof schema.value === "string" ? _chunkFPLSJF4Scjs.escapeString.call(void 0,
|
|
|
767
767
|
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
768
768
|
}
|
|
769
769
|
if (_zui.z.is.zuiRecord(schema)) {
|
|
770
|
-
const description =
|
|
770
|
+
const description = _chunkGOWPACSKcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
771
771
|
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
772
772
|
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
773
773
|
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkOVRDJMZJcjs = require('./chunk-OVRDJMZJ.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkPZE6PIPGcjs = require('./chunk-PZE6PIPG.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkDDSJTR6Qcjs = require('./chunk-DDSJTR6Q.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
var _chunkI56MPOVGcjs = require('./chunk-I56MPOVG.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkHEAQAEFZcjs = require('./chunk-HEAQAEFZ.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
@@ -497,10 +497,10 @@ var Snapshot = class _Snapshot {
|
|
|
497
497
|
};
|
|
498
498
|
function parseVariables(variableMap) {
|
|
499
499
|
return Object.entries(variableMap).map(([name, value]) => {
|
|
500
|
-
const type =
|
|
500
|
+
const type = _chunkOVRDJMZJcjs.extractType.call(void 0, value);
|
|
501
501
|
const bytes = JSON.stringify(value || "").length;
|
|
502
502
|
const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
|
|
503
|
-
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(
|
|
503
|
+
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkOVRDJMZJcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
|
|
@@ -511,9 +511,9 @@ function getMessagePreview(message) {
|
|
|
511
511
|
return message.content;
|
|
512
512
|
}
|
|
513
513
|
if (message.role === "event") {
|
|
514
|
-
return
|
|
514
|
+
return _chunkOVRDJMZJcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
|
|
515
515
|
}
|
|
516
|
-
return
|
|
516
|
+
return _chunkOVRDJMZJcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
|
|
517
517
|
}
|
|
518
518
|
function getMessageType(message) {
|
|
519
519
|
if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
|
|
@@ -964,15 +964,15 @@ var HookedArray = class extends Array {
|
|
|
964
964
|
};
|
|
965
965
|
|
|
966
966
|
// src/context.ts
|
|
967
|
-
var ThinkExit = new (0,
|
|
967
|
+
var ThinkExit = new (0, _chunkDDSJTR6Qcjs.Exit)({
|
|
968
968
|
name: "think",
|
|
969
969
|
description: "Think about the current situation and provide a response"
|
|
970
970
|
});
|
|
971
|
-
var ListenExit = new (0,
|
|
971
|
+
var ListenExit = new (0, _chunkDDSJTR6Qcjs.Exit)({
|
|
972
972
|
name: "listen",
|
|
973
973
|
description: "Listen to the user and provide a response"
|
|
974
974
|
});
|
|
975
|
-
var DefaultExit = new (0,
|
|
975
|
+
var DefaultExit = new (0, _chunkDDSJTR6Qcjs.Exit)({
|
|
976
976
|
name: "done",
|
|
977
977
|
description: "When the execution is sucessfully completed or when error recovery is not possible",
|
|
978
978
|
schema: _zui.z.discriminatedUnion("success", [
|
|
@@ -1145,7 +1145,7 @@ var Context = (_class2 = class {
|
|
|
1145
1145
|
|
|
1146
1146
|
|
|
1147
1147
|
|
|
1148
|
-
__init3() {this.version =
|
|
1148
|
+
__init3() {this.version = _chunkOVRDJMZJcjs.DualModePrompt}
|
|
1149
1149
|
__init4() {this.timeout = 6e4}
|
|
1150
1150
|
// Default timeout of 60 seconds
|
|
1151
1151
|
|
|
@@ -1217,8 +1217,8 @@ var Context = (_class2 = class {
|
|
|
1217
1217
|
* which is prompt scaffolding.
|
|
1218
1218
|
*/
|
|
1219
1219
|
_measureContextTokens(messages, parts) {
|
|
1220
|
-
const tokenizer =
|
|
1221
|
-
const countText = (text) => (text == null ? void 0 : text.length) ? tokenizer.count(
|
|
1220
|
+
const tokenizer = _chunkGOWPACSKcjs.getTokenizer.call(void 0, );
|
|
1221
|
+
const countText = (text) => (text == null ? void 0 : text.length) ? tokenizer.count(_chunkHEAQAEFZcjs.stripTruncationTags.call(void 0, text)) : 0;
|
|
1222
1222
|
const countMessage = (message) => {
|
|
1223
1223
|
if (typeof message.content === "string") {
|
|
1224
1224
|
return countText(message.content);
|
|
@@ -1286,7 +1286,7 @@ var Context = (_class2 = class {
|
|
|
1286
1286
|
...lastIterationMessages,
|
|
1287
1287
|
{
|
|
1288
1288
|
role: "assistant",
|
|
1289
|
-
content:
|
|
1289
|
+
content: _chunkHEAQAEFZcjs.wrapContent.call(void 0, _nullishCoalesce(((_c = lastIteration.llm) == null ? void 0 : _c.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1290
1290
|
},
|
|
1291
1291
|
await this.version.getThinkingMessage({
|
|
1292
1292
|
reason: lastIteration.status.thinking_requested.reason,
|
|
@@ -1299,7 +1299,7 @@ var Context = (_class2 = class {
|
|
|
1299
1299
|
...lastIterationMessages,
|
|
1300
1300
|
{
|
|
1301
1301
|
role: "assistant",
|
|
1302
|
-
content:
|
|
1302
|
+
content: _chunkHEAQAEFZcjs.wrapContent.call(void 0, _nullishCoalesce(((_d = lastIteration.llm) == null ? void 0 : _d.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1303
1303
|
},
|
|
1304
1304
|
await this.version.getInvalidCodeMessage({
|
|
1305
1305
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -1312,7 +1312,7 @@ var Context = (_class2 = class {
|
|
|
1312
1312
|
...lastIterationMessages,
|
|
1313
1313
|
{
|
|
1314
1314
|
role: "assistant",
|
|
1315
|
-
content:
|
|
1315
|
+
content: _chunkHEAQAEFZcjs.wrapContent.call(void 0, _nullishCoalesce(((_e = lastIteration.llm) == null ? void 0 : _e.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1316
1316
|
},
|
|
1317
1317
|
await this.version.getInvalidCodeMessage({
|
|
1318
1318
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -1325,7 +1325,7 @@ var Context = (_class2 = class {
|
|
|
1325
1325
|
...lastIterationMessages,
|
|
1326
1326
|
{
|
|
1327
1327
|
role: "assistant",
|
|
1328
|
-
content:
|
|
1328
|
+
content: _chunkHEAQAEFZcjs.wrapContent.call(void 0, _nullishCoalesce(((_f = lastIteration.llm) == null ? void 0 : _f.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1329
1329
|
},
|
|
1330
1330
|
await this.version.getCodeExecutionErrorMessage({
|
|
1331
1331
|
message: lastIteration.status.execution_error.message,
|
|
@@ -1341,7 +1341,7 @@ var Context = (_class2 = class {
|
|
|
1341
1341
|
var _a, _b;
|
|
1342
1342
|
const instructions = await getValue(this.instructions, this);
|
|
1343
1343
|
const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
|
|
1344
|
-
const tools =
|
|
1344
|
+
const tools = _chunkPZE6PIPGcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
|
|
1345
1345
|
const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
|
|
1346
1346
|
const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
|
|
1347
1347
|
const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
|