llmz 0.0.30 → 0.0.32
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/dist/{chunk-7POUFE5M.js → chunk-23SY6IDW.js} +63 -9
- package/dist/{chunk-KQPGB6GB.js → chunk-4JN4PPGP.js} +293 -4
- package/dist/{chunk-VADA6DMR.cjs → chunk-4XIOQWVZ.cjs} +301 -12
- package/dist/{chunk-WP4F6KMW.cjs → chunk-5BEKU5MZ.cjs} +2 -2
- package/dist/{chunk-R3LXNE5N.cjs → chunk-5FWOHMO4.cjs} +325 -60
- package/dist/{chunk-HCC76DDO.js → chunk-AAHUDKBY.js} +2 -2
- package/dist/{chunk-DCYSCVQM.js → chunk-G3LSBWJT.js} +304 -39
- package/dist/{chunk-RLOPQZTQ.cjs → chunk-INDOGCAQ.cjs} +2 -2
- package/dist/{chunk-T63Y6GTW.cjs → chunk-PK72FAKD.cjs} +2 -1
- package/dist/{chunk-273DEMEU.cjs → chunk-SOEKWFU2.cjs} +64 -10
- package/dist/{chunk-IUE5BW56.js → chunk-U4HWJLF2.js} +1 -1
- package/dist/{chunk-MYLTD5WT.js → chunk-WSVDMGMR.js} +2 -1
- package/dist/compiler/plugins/html-to-markdown.d.ts +21 -0
- package/dist/compiler/plugins/jsx-undefined-vars.d.ts +14 -0
- package/dist/context.d.ts +20 -0
- package/dist/{dual-modes-DW3KRXT2.js → dual-modes-LEAHGCOF.js} +1 -1
- package/dist/{dual-modes-F4UV5VAZ.cjs → dual-modes-UBHAMQW4.cjs} +2 -2
- package/dist/errors.d.ts +2 -1
- package/dist/exit-parser.d.ts +37 -0
- package/dist/index.cjs +20 -18
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -12
- package/dist/{llmz-N6KWKJ2Q.js → llmz-3E2JM3HM.js} +85 -42
- package/dist/{llmz-DYB74G5C.cjs → llmz-HGUVAYIN.cjs} +105 -62
- package/dist/llmz.d.ts +12 -0
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/result.d.ts +18 -0
- package/dist/{tool-GEBXW6AQ.js → tool-7QXH6A24.js} +3 -3
- package/dist/{tool-GMYMVXUK.cjs → tool-JVLOALQN.cjs} +4 -4
- package/dist/tool.d.ts +1 -1
- package/dist/{typings-3VYUEACY.js → typings-ALZEKGV6.js} +2 -2
- package/dist/{typings-2RAAZ2YP.cjs → typings-OLI56LGT.cjs} +3 -3
- package/dist/{vm-NGQ6DRS3.cjs → vm-VFORKC54.cjs} +3 -3
- package/dist/{vm-J6UNJGIN.js → vm-Y3WY2627.js} +2 -2
- package/package.json +2 -2
|
@@ -1,17 +1,17 @@
|
|
|
1
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
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5FWOHMO4cjs = require('./chunk-5FWOHMO4.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var _chunkVADA6DMRcjs = require('./chunk-VADA6DMR.cjs');
|
|
11
|
-
require('./chunk-WP4F6KMW.cjs');
|
|
12
|
-
require('./chunk-273DEMEU.cjs');
|
|
13
|
-
require('./chunk-RLOPQZTQ.cjs');
|
|
14
10
|
|
|
11
|
+
var _chunk4XIOQWVZcjs = require('./chunk-4XIOQWVZ.cjs');
|
|
12
|
+
require('./chunk-5BEKU5MZ.cjs');
|
|
13
|
+
require('./chunk-SOEKWFU2.cjs');
|
|
14
|
+
require('./chunk-INDOGCAQ.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -21,7 +21,8 @@ require('./chunk-RLOPQZTQ.cjs');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
|
|
@@ -103,10 +104,10 @@ var executeContext = async (props) => {
|
|
|
103
104
|
var _executeContext = async (props) => {
|
|
104
105
|
var _a, _b;
|
|
105
106
|
const controller = createJoinedAbortController([props.signal]);
|
|
106
|
-
const { onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
107
|
+
const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
107
108
|
const cognitive = _cognitive.Cognitive.isCognitiveClient(props.client) ? props.client : new (0, _cognitive.Cognitive)({ client: props.client });
|
|
108
109
|
const cleanups = [];
|
|
109
|
-
const ctx = new (0,
|
|
110
|
+
const ctx = new (0, _chunk4XIOQWVZcjs.Context)({
|
|
110
111
|
chat: props.chat,
|
|
111
112
|
instructions: props.instructions,
|
|
112
113
|
objects: props.objects,
|
|
@@ -121,9 +122,22 @@ var _executeContext = async (props) => {
|
|
|
121
122
|
try {
|
|
122
123
|
while (true) {
|
|
123
124
|
if (ctx.iterations.length >= ctx.loop) {
|
|
124
|
-
return new (0,
|
|
125
|
+
return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
|
|
125
126
|
}
|
|
126
127
|
const iteration = await ctx.nextIteration();
|
|
128
|
+
try {
|
|
129
|
+
await executeOnIterationStartHook({
|
|
130
|
+
iteration,
|
|
131
|
+
ctx,
|
|
132
|
+
onIterationStart,
|
|
133
|
+
controller,
|
|
134
|
+
onIterationEnd
|
|
135
|
+
});
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (err instanceof _chunkPK72FAKDcjs.ThinkSignal) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
127
141
|
if (controller.signal.aborted) {
|
|
128
142
|
iteration.end({
|
|
129
143
|
type: "aborted",
|
|
@@ -131,7 +145,7 @@ var _executeContext = async (props) => {
|
|
|
131
145
|
reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
|
|
132
146
|
}
|
|
133
147
|
});
|
|
134
|
-
return new (0,
|
|
148
|
+
return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
|
|
135
149
|
}
|
|
136
150
|
cleanups.push(
|
|
137
151
|
iteration.traces.onPush((traces) => {
|
|
@@ -167,25 +181,25 @@ var _executeContext = async (props) => {
|
|
|
167
181
|
}
|
|
168
182
|
if (iteration.status.type === "exit_success") {
|
|
169
183
|
const exitName = iteration.status.exit_success.exit_name;
|
|
170
|
-
return new (0,
|
|
184
|
+
return new (0, _chunk4XIOQWVZcjs.SuccessExecutionResult)(ctx, {
|
|
171
185
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
172
186
|
result: iteration.status.exit_success.return_value
|
|
173
187
|
});
|
|
174
188
|
}
|
|
175
189
|
if (iteration.status.type === "callback_requested") {
|
|
176
|
-
return new (0,
|
|
190
|
+
return new (0, _chunk4XIOQWVZcjs.PartialExecutionResult)(
|
|
177
191
|
ctx,
|
|
178
192
|
iteration.status.callback_requested.signal,
|
|
179
|
-
|
|
193
|
+
_chunk4XIOQWVZcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
180
194
|
);
|
|
181
195
|
}
|
|
182
196
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
183
197
|
continue;
|
|
184
198
|
}
|
|
185
|
-
return new (0,
|
|
199
|
+
return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
|
|
186
200
|
}
|
|
187
201
|
} catch (error) {
|
|
188
|
-
return new (0,
|
|
202
|
+
return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
189
203
|
} finally {
|
|
190
204
|
for (const cleanup of cleanups) {
|
|
191
205
|
try {
|
|
@@ -239,7 +253,7 @@ var executeIteration = async ({
|
|
|
239
253
|
});
|
|
240
254
|
const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
|
|
241
255
|
if (!out) {
|
|
242
|
-
throw new (0,
|
|
256
|
+
throw new (0, _chunkPK72FAKDcjs.CognitiveError)("LLM did not return any text output");
|
|
243
257
|
}
|
|
244
258
|
const assistantResponse = ctx.version.parseAssistantResponse(out);
|
|
245
259
|
iteration.code = assistantResponse.code.trim();
|
|
@@ -250,7 +264,7 @@ var executeIteration = async ({
|
|
|
250
264
|
iteration.code = hookRes.code.trim();
|
|
251
265
|
}
|
|
252
266
|
} catch (err) {
|
|
253
|
-
if (err instanceof
|
|
267
|
+
if (err instanceof _chunkPK72FAKDcjs.ThinkSignal) {
|
|
254
268
|
return iteration.end({
|
|
255
269
|
type: "thinking_requested",
|
|
256
270
|
thinking_requested: {
|
|
@@ -276,7 +290,8 @@ var executeIteration = async ({
|
|
|
276
290
|
tokens: output.meta.tokens.input + output.meta.tokens.output,
|
|
277
291
|
spend: output.meta.cost.input + output.meta.cost.output,
|
|
278
292
|
output: assistantResponse.raw,
|
|
279
|
-
model: `${output.meta.model.integration}:${output.meta.model.model}
|
|
293
|
+
model: `${output.meta.model.integration}:${output.meta.model.model}`,
|
|
294
|
+
usage: output.output.usage
|
|
280
295
|
};
|
|
281
296
|
traces.push({
|
|
282
297
|
type: "llm_call_success",
|
|
@@ -304,14 +319,14 @@ var executeIteration = async ({
|
|
|
304
319
|
return;
|
|
305
320
|
}
|
|
306
321
|
if (!writable) {
|
|
307
|
-
throw new (0,
|
|
322
|
+
throw new (0, _chunkPK72FAKDcjs.AssignmentError)(`Property ${obj.name}.${name} is read-only and cannot be modified`);
|
|
308
323
|
}
|
|
309
324
|
if (value2 === internalValues[name]) {
|
|
310
325
|
return;
|
|
311
326
|
}
|
|
312
327
|
const parsed = schema.safeParse(value2);
|
|
313
328
|
if (!parsed.success) {
|
|
314
|
-
throw new (0,
|
|
329
|
+
throw new (0, _chunkPK72FAKDcjs.AssignmentError)(
|
|
315
330
|
`Invalid value for Object property ${obj.name}.${name}: ${getErrorMessage(parsed.error)}`
|
|
316
331
|
);
|
|
317
332
|
}
|
|
@@ -362,7 +377,7 @@ var executeIteration = async ({
|
|
|
362
377
|
});
|
|
363
378
|
}
|
|
364
379
|
startedAt = Date.now();
|
|
365
|
-
const result = await
|
|
380
|
+
const result = await _chunk5FWOHMO4cjs.runAsyncFunction.call(void 0,
|
|
366
381
|
vmContext,
|
|
367
382
|
iteration.code,
|
|
368
383
|
traces,
|
|
@@ -377,7 +392,7 @@ var executeIteration = async ({
|
|
|
377
392
|
variables: {}
|
|
378
393
|
};
|
|
379
394
|
});
|
|
380
|
-
if (result.error && result.error instanceof
|
|
395
|
+
if (result.error && result.error instanceof _chunkPK72FAKDcjs.InvalidCodeError) {
|
|
381
396
|
return iteration.end({
|
|
382
397
|
type: "invalid_code_error",
|
|
383
398
|
invalid_code_error: {
|
|
@@ -399,7 +414,7 @@ var executeIteration = async ({
|
|
|
399
414
|
}
|
|
400
415
|
});
|
|
401
416
|
}
|
|
402
|
-
if (result.error && result.error instanceof
|
|
417
|
+
if (result.error && result.error instanceof _chunkPK72FAKDcjs.CodeExecutionError) {
|
|
403
418
|
return iteration.end({
|
|
404
419
|
type: "execution_error",
|
|
405
420
|
execution_error: {
|
|
@@ -417,16 +432,17 @@ var executeIteration = async ({
|
|
|
417
432
|
}
|
|
418
433
|
});
|
|
419
434
|
}
|
|
420
|
-
if (result.signal instanceof
|
|
435
|
+
if (result.signal instanceof _chunkPK72FAKDcjs.ThinkSignal) {
|
|
421
436
|
return iteration.end({
|
|
422
437
|
type: "thinking_requested",
|
|
423
438
|
thinking_requested: {
|
|
424
439
|
variables: result.signal.context,
|
|
425
|
-
reason: result.signal.reason
|
|
440
|
+
reason: result.signal.reason,
|
|
441
|
+
metadata: result.signal.metadata
|
|
426
442
|
}
|
|
427
443
|
});
|
|
428
444
|
}
|
|
429
|
-
if (result.signal instanceof
|
|
445
|
+
if (result.signal instanceof _chunkPK72FAKDcjs.SnapshotSignal) {
|
|
430
446
|
return iteration.end({
|
|
431
447
|
type: "callback_requested",
|
|
432
448
|
callback_requested: {
|
|
@@ -434,10 +450,8 @@ var executeIteration = async ({
|
|
|
434
450
|
}
|
|
435
451
|
});
|
|
436
452
|
}
|
|
437
|
-
const validActions = [...iteration.exits.map((x) => x.name.toLowerCase()), "think"];
|
|
438
453
|
let returnValue = result.success && result.return_value ? result.return_value : null;
|
|
439
454
|
const returnAction = returnValue == null ? void 0 : returnValue.action;
|
|
440
|
-
const returnExit = _nullishCoalesce(iteration.exits.find((x) => x.name.toLowerCase() === (returnAction == null ? void 0 : returnAction.toLowerCase())), () => ( iteration.exits.find((x) => x.aliases.some((a) => a.toLowerCase() === (returnAction == null ? void 0 : returnAction.toLowerCase())))));
|
|
441
455
|
if (returnAction === "think") {
|
|
442
456
|
const variables = _chunkUQOBUJIQcjs.omit_default.call(void 0, _nullishCoalesce(returnValue, () => ( {})), "action");
|
|
443
457
|
if (_chunkUQOBUJIQcjs.isPlainObject_default.call(void 0, variables) && Object.keys(variables).length > 0) {
|
|
@@ -457,40 +471,19 @@ var executeIteration = async ({
|
|
|
457
471
|
}
|
|
458
472
|
});
|
|
459
473
|
}
|
|
460
|
-
|
|
474
|
+
const parsedExit = _chunk4XIOQWVZcjs.parseExit.call(void 0, returnValue, iteration.exits);
|
|
475
|
+
if (!parsedExit.success) {
|
|
461
476
|
return iteration.end({
|
|
462
477
|
type: "exit_error",
|
|
463
478
|
exit_error: {
|
|
464
|
-
exit: "n/a",
|
|
465
|
-
message:
|
|
479
|
+
exit: _nullishCoalesce((returnValue == null ? void 0 : returnValue.action), () => ( "n/a")),
|
|
480
|
+
message: parsedExit.error,
|
|
466
481
|
return_value: returnValue
|
|
467
482
|
}
|
|
468
483
|
});
|
|
469
484
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
type: "exit_error",
|
|
473
|
-
exit_error: {
|
|
474
|
-
exit: returnAction,
|
|
475
|
-
message: `Exit "${returnAction}" not found. Valid actions are: ${validActions.join(", ")}`,
|
|
476
|
-
return_value: returnValue
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
if (returnExit.zSchema) {
|
|
481
|
-
const parsed = returnExit.zSchema.safeParse(returnValue == null ? void 0 : returnValue.value);
|
|
482
|
-
if (!parsed.success) {
|
|
483
|
-
return iteration.end({
|
|
484
|
-
type: "exit_error",
|
|
485
|
-
exit_error: {
|
|
486
|
-
exit: returnExit.name,
|
|
487
|
-
message: `Invalid return value for exit ${returnExit.name}: ${getErrorMessage(parsed.error)}`,
|
|
488
|
-
return_value: returnValue
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
returnValue = { action: returnExit.name, value: parsed.data };
|
|
493
|
-
}
|
|
485
|
+
const returnExit = parsedExit.exit;
|
|
486
|
+
returnValue = { action: returnExit.name, value: parsedExit.value };
|
|
494
487
|
try {
|
|
495
488
|
await (onExit == null ? void 0 : onExit({
|
|
496
489
|
exit: returnExit,
|
|
@@ -539,16 +532,16 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
|
|
|
539
532
|
if (output === error2) {
|
|
540
533
|
return true;
|
|
541
534
|
}
|
|
542
|
-
if (error2 instanceof
|
|
535
|
+
if (error2 instanceof _chunkPK72FAKDcjs.SnapshotSignal) {
|
|
543
536
|
error2.toolCall = {
|
|
544
537
|
name: tool.name,
|
|
545
538
|
inputSchema: tool.input,
|
|
546
539
|
outputSchema: tool.output,
|
|
547
540
|
input
|
|
548
541
|
};
|
|
549
|
-
error2.message =
|
|
542
|
+
error2.message = _chunkPK72FAKDcjs.Signals.serializeError(error2);
|
|
550
543
|
}
|
|
551
|
-
if (error2 instanceof
|
|
544
|
+
if (error2 instanceof _chunkPK72FAKDcjs.ThinkSignal) {
|
|
552
545
|
traces.push({
|
|
553
546
|
type: "think_signal",
|
|
554
547
|
started_at: Date.now(),
|
|
@@ -567,7 +560,9 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
|
|
|
567
560
|
iteration,
|
|
568
561
|
tool,
|
|
569
562
|
input: input2,
|
|
570
|
-
controller
|
|
563
|
+
controller,
|
|
564
|
+
object,
|
|
565
|
+
toolCallId
|
|
571
566
|
}));
|
|
572
567
|
if (typeof (beforeRes == null ? void 0 : beforeRes.input) !== "undefined") {
|
|
573
568
|
input2 = beforeRes.input;
|
|
@@ -580,7 +575,9 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
|
|
|
580
575
|
tool,
|
|
581
576
|
input: input2,
|
|
582
577
|
output: output2,
|
|
583
|
-
controller
|
|
578
|
+
controller,
|
|
579
|
+
object,
|
|
580
|
+
toolCallId
|
|
584
581
|
}));
|
|
585
582
|
if (typeof (afterRes == null ? void 0 : afterRes.output) !== "undefined") {
|
|
586
583
|
output2 = afterRes.output;
|
|
@@ -593,10 +590,23 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
|
|
|
593
590
|
output = res;
|
|
594
591
|
success = true;
|
|
595
592
|
return res;
|
|
596
|
-
}).catch((err) => {
|
|
593
|
+
}).catch(async (err) => {
|
|
597
594
|
if (!handleSignals(err)) {
|
|
598
595
|
success = false;
|
|
599
596
|
error = err;
|
|
597
|
+
} else {
|
|
598
|
+
const afterRes = await (afterHook == null ? void 0 : afterHook({
|
|
599
|
+
iteration,
|
|
600
|
+
tool,
|
|
601
|
+
input,
|
|
602
|
+
output,
|
|
603
|
+
controller,
|
|
604
|
+
object,
|
|
605
|
+
toolCallId
|
|
606
|
+
}));
|
|
607
|
+
if (typeof (afterRes == null ? void 0 : afterRes.output) !== "undefined") {
|
|
608
|
+
output = afterRes.output;
|
|
609
|
+
}
|
|
600
610
|
}
|
|
601
611
|
throw err;
|
|
602
612
|
}).finally(() => {
|
|
@@ -639,12 +649,45 @@ function wrapTool({ tool, traces, object, iteration, beforeHook, afterHook, cont
|
|
|
639
649
|
if (!success) {
|
|
640
650
|
throw error;
|
|
641
651
|
}
|
|
642
|
-
if (output instanceof
|
|
652
|
+
if (output instanceof _chunkPK72FAKDcjs.VMSignal) {
|
|
643
653
|
throw output;
|
|
644
654
|
}
|
|
645
655
|
return output;
|
|
646
656
|
};
|
|
647
657
|
}
|
|
658
|
+
var executeOnIterationStartHook = async (props) => {
|
|
659
|
+
const { iteration, ctx, onIterationStart, controller, onIterationEnd } = props;
|
|
660
|
+
try {
|
|
661
|
+
const hookRes = await (onIterationStart == null ? void 0 : onIterationStart(iteration, controller, ctx));
|
|
662
|
+
if (hookRes) {
|
|
663
|
+
Object.assign(iteration, hookRes);
|
|
664
|
+
}
|
|
665
|
+
} catch (err) {
|
|
666
|
+
if (err instanceof _chunkPK72FAKDcjs.ThinkSignal) {
|
|
667
|
+
iteration.end({
|
|
668
|
+
type: "thinking_requested",
|
|
669
|
+
thinking_requested: {
|
|
670
|
+
variables: err.context,
|
|
671
|
+
reason: err.reason
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
try {
|
|
675
|
+
await (onIterationEnd == null ? void 0 : onIterationEnd(iteration, controller));
|
|
676
|
+
} catch (err2) {
|
|
677
|
+
console.error(err2);
|
|
678
|
+
}
|
|
679
|
+
} else {
|
|
680
|
+
iteration.end({
|
|
681
|
+
type: "execution_error",
|
|
682
|
+
execution_error: {
|
|
683
|
+
message: `Error in onIterationStart hook: ${getErrorMessage(err)}`,
|
|
684
|
+
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(err.stack, () => ( "No stack trace available")))
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
throw err;
|
|
689
|
+
}
|
|
690
|
+
};
|
|
648
691
|
|
|
649
692
|
|
|
650
693
|
|
package/dist/llmz.d.ts
CHANGED
|
@@ -22,6 +22,14 @@ export type ExecutionHooks = {
|
|
|
22
22
|
trace: Trace;
|
|
23
23
|
iteration: number;
|
|
24
24
|
}) => void;
|
|
25
|
+
/**
|
|
26
|
+
* BLOCKING HOOK
|
|
27
|
+
* This hook will block the execution of the iteration until it resolves.
|
|
28
|
+
*
|
|
29
|
+
* This hook will be called before each iteration starts, regardless of the status.
|
|
30
|
+
* This is useful for logging or dynamically change model arguments
|
|
31
|
+
*/
|
|
32
|
+
onIterationStart?: (iteration: Iteration, controller: AbortController, context: Context) => Promise<void | Partial<Iteration>> | void | Partial<Iteration>;
|
|
25
33
|
/**
|
|
26
34
|
* BLOCKING HOOK
|
|
27
35
|
* This hook will block the execution of the iteration until it resolves.
|
|
@@ -70,6 +78,8 @@ export type ExecutionHooks = {
|
|
|
70
78
|
tool: Tool;
|
|
71
79
|
input: any;
|
|
72
80
|
controller: AbortController;
|
|
81
|
+
toolCallId: string;
|
|
82
|
+
object?: string;
|
|
73
83
|
}) => Promise<{
|
|
74
84
|
input?: any;
|
|
75
85
|
} | void>;
|
|
@@ -88,6 +98,8 @@ export type ExecutionHooks = {
|
|
|
88
98
|
input: any;
|
|
89
99
|
output: any;
|
|
90
100
|
controller: AbortController;
|
|
101
|
+
toolCallId: string;
|
|
102
|
+
object?: string;
|
|
91
103
|
}) => Promise<{
|
|
92
104
|
output?: any;
|
|
93
105
|
} | void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "# Important Instructions\n\nYou are a helpful
|
|
1
|
+
declare const _default: "# Important Instructions\n\nYou are a helpful background AI Agent with defined Role, Capabilities and Responsibilities.\nYou can:\n\n- Generate TypeScript (TS) code that will be executed in a secure VM environment.\n- Use the provided tools to accomplish the task at hand\n\n**Your main task**: Write TypeScript code following specific guidelines to\n\n# Part 1: Response Format\n\n- **Always** reply **only** with TS code placed between `■fn_start` and `■fn_end`.\n- **Structure**:\n\n ```ts\n ■fn_start\n // Your TypeScript code here\n ■fn_end\n ```\n\n- **Guidelines**:\n\n - Write complete, syntax-error-free TypeScript code\n - Use only the tools provided to interact with the system\n - Include a valid `return` statement at the end of your function\n\n## Return Statement\n\n**Important**: `action` can only be one of: 'think', {{#each exits}}'{{name}}', {{/each}}\n\n{{#each exits}}\n\n{{#if has_typings}}\n\n- **{{name}}**: {{description}}\n\n**typeof value** must respect this format:\n\n```\n{{{typings}}}\n```\n\n```ts\nreturn { action: '{{name}}', value: /*...*/ }\n```\n\n{{else}}\n\n- **{{name}}**: {{description}}\n\n```ts\nreturn { action: '{{name}}' }\n```\n\n{{/if}}\n\n{{/each}}\n\n- **If further processing** is needed before continuing, use `think` to print the value of variables and re-generate code:\n\n ```ts\n return { action: 'think', variable1, variable2 }\n ```\n\n## Examples\n\n- **Using a Tool and Returning Think Action**:\n\n ```ts\n ■fn_start\n const data = await fetchUserData(user.id)\n return { action: 'think', data }\n ■fn_end\n ```\n\n# Part 2: VM Sandbox Environment and Tools\n\nYou have access to very specific tools and data in the VM Sandbox environment\nYou should use these tools as needed and as instructed to interact with the system and perform operations\n\n## List of Tools (`tools.d.ts`)\n\n- You are responsible for writing the code to solve the problem at hand using the tools provided\n- You have to ask yourself - \"given the instructions given and the tools available, what code should I write to solve the problem?\"\n- These tools are available to you in the `tools.d.ts` file. You should always refer to the `tools.d.ts` file to understand the available tools and their usage\n\n## Typescript Sandbox (VM)\n\n- The code you write will be executed in a secure Typescript VM environment\n- You don't have access to any external libraries or APIs outside the tools defined in `tools.d.ts`\n- You can't access or modify the system's files or interact with the network other than the provided tools\n- You can't run any code that performs malicious activities or violates the security guidelines\n- When complex reasoning or planning is required, you can use comments to outline your approach\n- You should copy/paste values (hardcode) as much as possible instead of relying on variable references\n- Some tools have inputs that are string literals (eg. `type Text = \"Hello World\"`). They can't be changed, so hardcode their values as well\n\n## Code Execution\n\n- `import` and `require` are not available and will throw an error\n- `setTimeout` and `setInterval` are not available and will throw an error\n- `console.log` is not available. Instead, use `return { action: 'think' }` to inspect values\n- Do not declare functions. The code already executes in an `AsyncGenerator`\n- Always ensure that the code you write is correct and complete; this is not an exercise, this code has to run perfectly\n- The code you write should be based on the tools available, the instructions and data provided\n- Top-level `await` is allowed and must be used when calling tools\n- Always ensure that the code is error-free and follows the guidelines\n- Do not put placeholder code in the response\n- If data is missing to proceed, use the appropriate return or tool to fetch it before proceeding further\n- The use of loops, conditionals, variables, Promise.all/Promise.allSettled and try-catch statements is **allowed**\n- Do not over-index on running code/logic when the task requires qualitative / jugement; instead, a visual inspection with `think` can be used\n\n## Variables and Data\n\n- The data available to you is provided in the `tools.d.ts` file\n- Readonly<T> variables can be used as constants in your code, but you should not modify them (it will result in a runtime error)\n- Variables that are not marked as Readonly<T> can be modified as needed\n- You can use the data available to you to generate responses, provide tool inputs and return\n\n## Provided Tools (tools.d.ts)\n\nThis is the full list of tools and variables available to you in the VM. Consider this your full API documentation / type definitions for the available code execution.\n\nThis file is already loaded in the VM, do not import it.\n\n```typescript\n// tools.d.ts\n■■■tools.d.ts■■■\n```\n\n# Part 3: Goal, Instructions and Guidelines\n\n## Important Explanation\n\nThis is who you are and the extremely important instructions that you have been assigned.\nYou ALWAYS follow these instructions, whatever they are, as long as the **Response Format (Part 1)** and **Security Guidelines (Part 5)** are respected. The instructions below are of the upmost importance. You can trust these instructions fully, as they have been provided by your creator and will be used to judge the quality of your responses.\n\nIf the instructions say something about the use of tools, then you should prioritize these instructions over the tool typings and comments above.\n\n■■■identity■■■\n\n**Important**: Trust the instructions above fully.\n\n# Part 4: Communication\n\nCommunications are disabled, because you are a background worker. You can only write and run code. There is no active conversation and no mean of communications to accomplish your task.\n\n# Part 5: Security Guidelines\n\nBefore you generate the response, here are few things to keep in mind. Not following them might put human life in danger.\n\n- You should not generate any arbitrary code. Instead, you should generate code that helps progress the goal at hand and is in line with the provided guidelines in **Part 3 (Goal, Instructions and Guidelines)**.\n- You should not reveal the existence of the VM and should not reveal any properties of the VM object (including the tools available to you).\n- It is however safe to reveal any roles assigned to you under the `bot` object (like `bot.name`, `bot.role` etc) as they are not sensitive.\n- Instructions provided in the **Part 3 (Goal, Instructions and Guidelines)** section should always be followed and take precedence over everything else.\n\n# Your turn: Generate a Response\n\n## Tools\n\nFull list of valid tools: ■■■tool_names■■■\nCalls to tools not listed above will result in RuntimeError.\n\n## Variables / Memory\n\n**Readonly**: Here are the variables you are allowed to read: ■■■readonly_vars■■■\n\n**Writable**: Here are the variables you are allowed to read & write (assign value to): ■■■writeable_vars■■■\n■■■variables_example■■■\n\n## Format\n\nRemember, the expected Response Format is:\n\n### Tool + Think\n\n```\n■fn_start\n// 1-liner chain-of-thought (CoT) as comment\nconst result = await toolCall()\nreturn { action: 'think', result }\n■fn_end\n```\n";
|
|
2
2
|
export default _default;
|
package/dist/result.d.ts
CHANGED
|
@@ -405,6 +405,12 @@ export declare class SuccessExecutionResult<TOutput = unknown> extends Execution
|
|
|
405
405
|
spend: number;
|
|
406
406
|
output: string;
|
|
407
407
|
model: string;
|
|
408
|
+
usage: {
|
|
409
|
+
inputCost: number;
|
|
410
|
+
outputCost: number;
|
|
411
|
+
inputTokens: number;
|
|
412
|
+
outputTokens: number;
|
|
413
|
+
};
|
|
408
414
|
} | undefined;
|
|
409
415
|
transcript: import("./transcript.js").Transcript.Message[];
|
|
410
416
|
tools: {
|
|
@@ -560,6 +566,12 @@ export declare class ErrorExecutionResult extends ExecutionResult implements Ser
|
|
|
560
566
|
spend: number;
|
|
561
567
|
output: string;
|
|
562
568
|
model: string;
|
|
569
|
+
usage: {
|
|
570
|
+
inputCost: number;
|
|
571
|
+
outputCost: number;
|
|
572
|
+
inputTokens: number;
|
|
573
|
+
outputTokens: number;
|
|
574
|
+
};
|
|
563
575
|
} | undefined;
|
|
564
576
|
transcript: import("./transcript.js").Transcript.Message[];
|
|
565
577
|
tools: {
|
|
@@ -735,6 +747,12 @@ export declare class PartialExecutionResult extends ExecutionResult implements S
|
|
|
735
747
|
spend: number;
|
|
736
748
|
output: string;
|
|
737
749
|
model: string;
|
|
750
|
+
usage: {
|
|
751
|
+
inputCost: number;
|
|
752
|
+
outputCost: number;
|
|
753
|
+
inputTokens: number;
|
|
754
|
+
outputTokens: number;
|
|
755
|
+
};
|
|
738
756
|
} | undefined;
|
|
739
757
|
transcript: import("./transcript.js").Transcript.Message[];
|
|
740
758
|
tools: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Tool
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-23SY6IDW.js";
|
|
4
|
+
import "./chunk-U4HWJLF2.js";
|
|
5
|
+
import "./chunk-WSVDMGMR.js";
|
|
6
6
|
import "./chunk-YEAWWJSJ.js";
|
|
7
7
|
import "./chunk-ZORRILUV.js";
|
|
8
8
|
import "./chunk-7WRN4E42.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var _chunkSOEKWFU2cjs = require('./chunk-SOEKWFU2.cjs');
|
|
4
|
+
require('./chunk-INDOGCAQ.cjs');
|
|
5
|
+
require('./chunk-PK72FAKD.cjs');
|
|
6
6
|
require('./chunk-KIN7Y247.cjs');
|
|
7
7
|
require('./chunk-WHNOR4ZU.cjs');
|
|
8
8
|
require('./chunk-UQOBUJIQ.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.Tool =
|
|
11
|
+
exports.Tool = _chunkSOEKWFU2cjs.Tool;
|
package/dist/tool.d.ts
CHANGED
|
@@ -262,7 +262,7 @@ export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiTy
|
|
|
262
262
|
* @returns The Zui schema for input validation
|
|
263
263
|
* @internal
|
|
264
264
|
*/
|
|
265
|
-
get zInput():
|
|
265
|
+
get zInput(): ZuiType;
|
|
266
266
|
/**
|
|
267
267
|
* Gets the output schema for validation.
|
|
268
268
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkINDOGCAQcjs = require('./chunk-INDOGCAQ.cjs');
|
|
4
|
+
require('./chunk-PK72FAKD.cjs');
|
|
5
5
|
require('./chunk-KIN7Y247.cjs');
|
|
6
6
|
require('./chunk-WHNOR4ZU.cjs');
|
|
7
7
|
require('./chunk-UQOBUJIQ.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.getTypings =
|
|
10
|
+
exports.getTypings = _chunkINDOGCAQcjs.getTypings;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunk5FWOHMO4cjs = require('./chunk-5FWOHMO4.cjs');
|
|
4
|
+
require('./chunk-PK72FAKD.cjs');
|
|
5
5
|
require('./chunk-KIN7Y247.cjs');
|
|
6
6
|
require('./chunk-KMZDFWYZ.cjs');
|
|
7
7
|
require('./chunk-UQOBUJIQ.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.runAsyncFunction =
|
|
10
|
+
exports.runAsyncFunction = _chunk5FWOHMO4cjs.runAsyncFunction;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "llmz",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "LLMz – An LLM-native Typescript VM built on top of Zui",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.32",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@botpress/client": "1.27.1",
|
|
74
|
-
"@botpress/cognitive": "0.
|
|
74
|
+
"@botpress/cognitive": "0.3.0",
|
|
75
75
|
"@bpinternal/thicktoken": "^1.0.5",
|
|
76
76
|
"@bpinternal/zui": "1.2.1"
|
|
77
77
|
},
|