llmz 0.0.84 → 0.0.85
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-NK2NCYSY.js → chunk-2XSXXGXJ.js} +4 -4
- package/dist/{chunk-2O3UTPVH.js → chunk-EADBCAE7.js} +2 -2
- package/dist/{chunk-D6PU5YAS.cjs → chunk-EC2I4U4G.cjs} +6 -6
- package/dist/{chunk-L74UZONX.js → chunk-GEN6TAXY.js} +8 -16
- package/dist/{chunk-ZPHRTTQX.cjs → chunk-GFSUTNRM.cjs} +9 -17
- package/dist/{chunk-WODK7Y4J.cjs → chunk-H3PZFBJL.cjs} +10 -10
- package/dist/{chunk-7LMIOS6H.cjs → chunk-KY27DGTG.cjs} +14 -14
- package/dist/{chunk-PQGZQQA6.cjs → chunk-N3XPJTPE.cjs} +18 -18
- package/dist/{chunk-FPLSJF4S.cjs → chunk-NFZXJRXS.cjs} +2 -5
- package/dist/{chunk-TOGYDN6U.js → chunk-PASYUKW4.js} +1 -1
- package/dist/{chunk-XVVYNOTX.js → chunk-TRWUQSEK.js} +1 -1
- package/dist/{chunk-IRCB4FRM.js → chunk-YTFNFSDT.js} +2 -2
- package/dist/{chunk-YX27XM67.js → chunk-ZHHB3FT4.js} +1 -4
- package/dist/{chunk-BBX2LDZE.cjs → chunk-ZVSO527D.cjs} +25 -25
- package/dist/{dual-modes-HEXPFVUE.js → dual-modes-5NJMZJTA.js} +3 -3
- package/dist/{dual-modes-LLIWZCHC.cjs → dual-modes-WA5TPGJR.cjs} +4 -4
- package/dist/{execute-EZXXBWB6.js → execute-2T75URIX.js} +7 -7
- package/dist/{execute-2BVFYTJT.cjs → execute-I53OOORH.cjs} +30 -30
- package/dist/{exit-VJATJTQI.js → exit-7NHSUR3V.js} +2 -2
- package/dist/exit-V3ORIN65.cjs +8 -0
- package/dist/index.cjs +33 -33
- package/dist/index.js +16 -16
- package/dist/{tool-GJ6ZXWS2.cjs → tool-4OPM7QRM.cjs} +4 -4
- package/dist/{tool-DNHVW3KC.js → tool-HXXQMDA3.js} +3 -3
- package/dist/truncator-ZN7X6OMF.cjs +10 -0
- package/dist/{truncator-3U2QUUJJ.js → truncator-ZQYBTVCJ.js} +2 -2
- package/dist/{typings-ZTFPPA5W.cjs → typings-QW4427V7.cjs} +3 -3
- package/dist/{typings-3YV3RDMP.js → typings-YD2WAQ4A.js} +2 -2
- package/dist/utils-NQSM5FBL.cjs +39 -0
- package/dist/{utils-ZEZ66X6Q.js → utils-RKUVYFTJ.js} +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +2 -2
- package/dist/exit-LUJY7JIG.cjs +0 -8
- package/dist/truncator-3ZN7W6NB.cjs +0 -10
- package/dist/utils-GLZVMRWO.cjs +0 -39
|
@@ -6,11 +6,11 @@ var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
|
|
|
6
6
|
var _chunkCQ3UJW76cjs = require('./chunk-CQ3UJW76.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkGFSUTNRMcjs = require('./chunk-GFSUTNRM.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkNFZXJRXScjs = require('./chunk-NFZXJRXS.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -57,7 +57,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
57
57
|
}
|
|
58
58
|
if (typeof currentObj !== "object" || currentObj === null) {
|
|
59
59
|
const value = JSON.stringify(currentObj);
|
|
60
|
-
currentLength +=
|
|
60
|
+
currentLength += _chunkNFZXJRXScjs.getTokenizer.call(void 0, ).count(value);
|
|
61
61
|
return value;
|
|
62
62
|
}
|
|
63
63
|
const indentation = " ".repeat(currentIndent);
|
|
@@ -70,7 +70,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
70
70
|
result += indentation + " ".repeat(indent) + recurse(currentObj[i], depth + 1, currentIndent + indent);
|
|
71
71
|
}
|
|
72
72
|
result += "\n" + indentation + "]";
|
|
73
|
-
currentLength +=
|
|
73
|
+
currentLength += _chunkNFZXJRXScjs.getTokenizer.call(void 0, ).count(result);
|
|
74
74
|
return result;
|
|
75
75
|
} else {
|
|
76
76
|
let result = "{\n";
|
|
@@ -89,11 +89,11 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
89
89
|
result += ",\n" + indentation + `... (${numKeys - maxKeys} more keys)`;
|
|
90
90
|
}
|
|
91
91
|
result += "\n" + indentation + "}";
|
|
92
|
-
currentLength +=
|
|
92
|
+
currentLength += _chunkNFZXJRXScjs.getTokenizer.call(void 0, ).count(result);
|
|
93
93
|
return result;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const output =
|
|
96
|
+
const output = _chunkNFZXJRXScjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
|
|
97
97
|
return { output, truncated: wasTruncated };
|
|
98
98
|
}
|
|
99
99
|
function extractType(value, generic = true) {
|
|
@@ -158,9 +158,9 @@ function previewValue(value, length = LONG_TEXT_LENGTH) {
|
|
|
158
158
|
}
|
|
159
159
|
const previewStr = (str) => {
|
|
160
160
|
if (str.length > length) {
|
|
161
|
-
return
|
|
161
|
+
return _chunkNFZXJRXScjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
|
|
162
162
|
}
|
|
163
|
-
return
|
|
163
|
+
return _chunkNFZXJRXScjs.escapeString.call(void 0, str);
|
|
164
164
|
};
|
|
165
165
|
const previewObj = (obj) => {
|
|
166
166
|
const mapped = _chunkHC2QZTVTcjs.mapKeys_default.call(void 0, obj, (_value, key) => previewStr(key));
|
|
@@ -353,7 +353,7 @@ var inspect = (value, name, options = DEFAULT_OPTIONS) => {
|
|
|
353
353
|
} else if (genericType === "boolean") {
|
|
354
354
|
return header + previewValue(value);
|
|
355
355
|
} else if (typeof value === "string") {
|
|
356
|
-
if (
|
|
356
|
+
if (_chunkNFZXJRXScjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
|
|
357
357
|
return header + previewValue(value);
|
|
358
358
|
} else {
|
|
359
359
|
return header + previewLongText(value);
|
|
@@ -508,15 +508,15 @@ ${variables_example}
|
|
|
508
508
|
role: "system",
|
|
509
509
|
content: replacePlaceholders(canTalk ? system_md_default : system_md_default2, {
|
|
510
510
|
is_message_enabled: canTalk,
|
|
511
|
-
"tools.d.ts":
|
|
511
|
+
"tools.d.ts": _chunkGFSUTNRMcjs.wrapContent.call(void 0, dts, {
|
|
512
512
|
preserve: "both",
|
|
513
513
|
minTokens: 500
|
|
514
514
|
}),
|
|
515
|
-
identity:
|
|
515
|
+
identity: _chunkGFSUTNRMcjs.wrapContent.call(void 0, ((_a = props.instructions) == null ? void 0 : _a.length) ? props.instructions : "No specific instructions provided", {
|
|
516
516
|
preserve: "both",
|
|
517
517
|
minTokens: 1e3
|
|
518
518
|
}),
|
|
519
|
-
transcript:
|
|
519
|
+
transcript: _chunkGFSUTNRMcjs.wrapContent.call(void 0, props.transcript.toString(), {
|
|
520
520
|
preserve: "bottom",
|
|
521
521
|
minTokens: 500
|
|
522
522
|
}),
|
|
@@ -525,7 +525,7 @@ ${variables_example}
|
|
|
525
525
|
writeable_vars: writeable_vars.join(", "),
|
|
526
526
|
variables_example,
|
|
527
527
|
exits,
|
|
528
|
-
components:
|
|
528
|
+
components: _chunkGFSUTNRMcjs.wrapContent.call(void 0,
|
|
529
529
|
props.components.map((component) => _chunkCQ3UJW76cjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
|
|
530
530
|
{
|
|
531
531
|
preserve: "top",
|
|
@@ -603,13 +603,13 @@ Code:
|
|
|
603
603
|
|
|
604
604
|
\`\`\`tsx
|
|
605
605
|
\u25A0fn_start
|
|
606
|
-
${
|
|
606
|
+
${_chunkGFSUTNRMcjs.wrapContent.call(void 0, props.code)}
|
|
607
607
|
\u25A0fn_end
|
|
608
608
|
\`\`\`
|
|
609
609
|
|
|
610
610
|
Error:
|
|
611
611
|
\`\`\`
|
|
612
|
-
${
|
|
612
|
+
${_chunkGFSUTNRMcjs.wrapContent.call(void 0, props.message, { flex: 4 })}
|
|
613
613
|
\`\`\`
|
|
614
614
|
|
|
615
615
|
Please fix the error and try again.
|
|
@@ -632,11 +632,11 @@ var getCodeExecutionErrorMessage = async (props) => {
|
|
|
632
632
|
|
|
633
633
|
An error occurred while executing the code.
|
|
634
634
|
|
|
635
|
-
${
|
|
635
|
+
${_chunkGFSUTNRMcjs.wrapContent.call(void 0, props.message, { preserve: "top", flex: 4 })}
|
|
636
636
|
|
|
637
637
|
Stack Trace:
|
|
638
638
|
\`\`\`
|
|
639
|
-
${
|
|
639
|
+
${_chunkGFSUTNRMcjs.wrapContent.call(void 0, _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
|
|
640
640
|
\`\`\`
|
|
641
641
|
|
|
642
642
|
Let the user know that an error occurred, and if possible, try something else. Do not repeat yourself in the message.
|
|
@@ -659,7 +659,7 @@ var getThinkingMessage = async (props) => {
|
|
|
659
659
|
if (inspected) {
|
|
660
660
|
acc.push(inspected);
|
|
661
661
|
} else {
|
|
662
|
-
acc.push(`Value of ${key} is ${
|
|
662
|
+
acc.push(`Value of ${key} is ${_chunkGFSUTNRMcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`);
|
|
663
663
|
}
|
|
664
664
|
return acc;
|
|
665
665
|
}, []);
|
|
@@ -670,7 +670,7 @@ var getThinkingMessage = async (props) => {
|
|
|
670
670
|
if (inspected) {
|
|
671
671
|
return inspected;
|
|
672
672
|
} else {
|
|
673
|
-
return `Value at index ${index} is ${
|
|
673
|
+
return `Value at index ${index} is ${_chunkGFSUTNRMcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`;
|
|
674
674
|
}
|
|
675
675
|
});
|
|
676
676
|
context = mapped.join("\n\n");
|
|
@@ -688,7 +688,7 @@ The assistant requested to think. Here's the context:
|
|
|
688
688
|
-------------------
|
|
689
689
|
Reason: ${props.reason || "Thinking requested"}
|
|
690
690
|
Context:
|
|
691
|
-
${
|
|
691
|
+
${_chunkGFSUTNRMcjs.wrapContent.call(void 0, context, { preserve: "top" })}
|
|
692
692
|
-------------------
|
|
693
693
|
|
|
694
694
|
Please continue with the conversation (\u25A0fn_start).
|
|
@@ -707,19 +707,19 @@ var getSnapshotResolvedMessage = (props) => {
|
|
|
707
707
|
injectedVariables[variable.name] = variable.value;
|
|
708
708
|
variablesMessage += `
|
|
709
709
|
// Variable "${variable.name}" restored with its full value:
|
|
710
|
-
// ${
|
|
710
|
+
// ${_chunkGFSUTNRMcjs.wrapContent.call(void 0, _nullishCoalesce(((_a = inspect(variable.value)) == null ? void 0 : _a.split("\n").join("\n// ")), () => ( "")))}
|
|
711
711
|
declare const ${variable.name}: ${variable.type}
|
|
712
712
|
`;
|
|
713
713
|
} else {
|
|
714
714
|
variablesMessage += `
|
|
715
715
|
// The variable "${variable.name}" was too large to be restored with its full value, here's a preview of its last known value:
|
|
716
|
-
// ${
|
|
716
|
+
// ${_chunkGFSUTNRMcjs.wrapContent.call(void 0, variable.preview.split("\n").join("\n// "))}
|
|
717
717
|
// Important: To restore the full value, please re-run the code that generated this variable in the first place.
|
|
718
718
|
let ${variable.name}: undefined | ${variable.type} = undefined;
|
|
719
719
|
`;
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
|
-
const output =
|
|
722
|
+
const output = _chunkGFSUTNRMcjs.wrapContent.call(void 0, _nullishCoalesce(((_b = inspect(props.snapshot.status.value)) == null ? void 0 : _b.split("\n").join("\n * ")), () => ( "")), {
|
|
723
723
|
preserve: "top",
|
|
724
724
|
flex: 4
|
|
725
725
|
});
|
|
@@ -741,7 +741,7 @@ ${_chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.snapshot.stack).split("\n
|
|
|
741
741
|
Continue the conversation from here, without repeating the above code, as it has already been executed. Here's the variables you can rely on:
|
|
742
742
|
|
|
743
743
|
\`\`\`tsx
|
|
744
|
-
${
|
|
744
|
+
${_chunkGFSUTNRMcjs.wrapContent.call(void 0, variablesMessage)}
|
|
745
745
|
\`\`\`
|
|
746
746
|
|
|
747
747
|
You can now assume that the code you about to generate can rely on the variables "${Object.keys(injectedVariables).join('", "')}" being available.
|
|
@@ -764,7 +764,7 @@ var getSnapshotRejectedMessage = (props) => {
|
|
|
764
764
|
throw new Error("Snapshot is not resolved");
|
|
765
765
|
}
|
|
766
766
|
const errorMessage = _nullishCoalesce(inspect(props.snapshot.status.error), () => ( "Unknown Error"));
|
|
767
|
-
const output =
|
|
767
|
+
const output = _chunkGFSUTNRMcjs.wrapContent.call(void 0, _nullishCoalesce(errorMessage.split("\n").join("\n * "), () => ( "Unknown Error")), {
|
|
768
768
|
preserve: "both",
|
|
769
769
|
minTokens: 100
|
|
770
770
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DualModePrompt
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EADBCAE7.js";
|
|
4
4
|
import "./chunk-YEAWWJSJ.js";
|
|
5
5
|
import "./chunk-3T5IU7OU.js";
|
|
6
6
|
import "./chunk-XTEHT2TK.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-GEN6TAXY.js";
|
|
8
|
+
import "./chunk-ZHHB3FT4.js";
|
|
9
9
|
import "./chunk-34GJUS6U.js";
|
|
10
10
|
export {
|
|
11
11
|
DualModePrompt
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZVSO527Dcjs = require('./chunk-ZVSO527D.cjs');
|
|
4
4
|
require('./chunk-KIN7Y247.cjs');
|
|
5
5
|
require('./chunk-CQ3UJW76.cjs');
|
|
6
6
|
require('./chunk-5ZF6NTYI.cjs');
|
|
7
|
-
require('./chunk-
|
|
8
|
-
require('./chunk-
|
|
7
|
+
require('./chunk-GFSUTNRM.cjs');
|
|
8
|
+
require('./chunk-NFZXJRXS.cjs');
|
|
9
9
|
require('./chunk-HC2QZTVT.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.DualModePrompt =
|
|
12
|
+
exports.DualModePrompt = _chunkZVSO527Dcjs.DualModePrompt;
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
Snapshot,
|
|
9
9
|
SuccessExecutionResult,
|
|
10
10
|
parseExit
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-2XSXXGXJ.js";
|
|
12
|
+
import "./chunk-EADBCAE7.js";
|
|
13
|
+
import "./chunk-YTFNFSDT.js";
|
|
14
|
+
import "./chunk-PASYUKW4.js";
|
|
15
15
|
import {
|
|
16
16
|
AssignmentError,
|
|
17
17
|
CodeExecutionError,
|
|
@@ -25,17 +25,17 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
cleanStackTrace
|
|
27
27
|
} from "./chunk-YEAWWJSJ.js";
|
|
28
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-TRWUQSEK.js";
|
|
29
29
|
import "./chunk-3T5IU7OU.js";
|
|
30
30
|
import "./chunk-XTEHT2TK.js";
|
|
31
31
|
import {
|
|
32
32
|
truncateWrappedContent
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-GEN6TAXY.js";
|
|
34
34
|
import {
|
|
35
35
|
getErrorMessage,
|
|
36
36
|
init,
|
|
37
37
|
stripInvalidIdentifiers
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-ZHHB3FT4.js";
|
|
39
39
|
import {
|
|
40
40
|
clamp_default,
|
|
41
41
|
isEqual_default,
|
|
@@ -8,10 +8,10 @@ var _chunkJXD2KJVBcjs = require('./chunk-JXD2KJVB.cjs');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
require('./chunk-
|
|
13
|
-
require('./chunk-
|
|
14
|
-
require('./chunk-
|
|
11
|
+
var _chunkN3XPJTPEcjs = require('./chunk-N3XPJTPE.cjs');
|
|
12
|
+
require('./chunk-ZVSO527D.cjs');
|
|
13
|
+
require('./chunk-H3PZFBJL.cjs');
|
|
14
|
+
require('./chunk-KY27DGTG.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -25,17 +25,17 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
|
|
28
|
-
require('./chunk-
|
|
28
|
+
require('./chunk-EC2I4U4G.cjs');
|
|
29
29
|
require('./chunk-CQ3UJW76.cjs');
|
|
30
30
|
require('./chunk-5ZF6NTYI.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _chunkGFSUTNRMcjs = require('./chunk-GFSUTNRM.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _chunkNFZXJRXScjs = require('./chunk-NFZXJRXS.cjs');
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
@@ -93,11 +93,11 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
|
|
|
93
93
|
const traces = iteration.traces;
|
|
94
94
|
const modelRef = Array.isArray(iteration.model) ? iteration.model[0] : iteration.model;
|
|
95
95
|
const model = await cognitive.getModelDetails(modelRef).catch((thrown) => {
|
|
96
|
-
throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`Failed to fetch model details for model "${modelRef}": ${
|
|
96
|
+
throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`Failed to fetch model details for model "${modelRef}": ${_chunkNFZXJRXScjs.getErrorMessage.call(void 0, thrown)}`);
|
|
97
97
|
});
|
|
98
98
|
const modelLimit = Math.max(model.input.maxTokens, 8e3);
|
|
99
99
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
100
|
-
const messages =
|
|
100
|
+
const messages = _chunkGFSUTNRMcjs.truncateWrappedContent.call(void 0, {
|
|
101
101
|
messages: iteration.messages,
|
|
102
102
|
tokenLimit: modelLimit - responseLengthBuffer,
|
|
103
103
|
throwOnFailure: true
|
|
@@ -119,7 +119,7 @@ var generateCode = async ({ iteration, ctx, cognitive, controller }) => {
|
|
|
119
119
|
messages: messages.filter((x) => x.role !== "system"),
|
|
120
120
|
stopSequences: ctx.version.getStopTokens()
|
|
121
121
|
}).catch((thrown) => {
|
|
122
|
-
throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`LLM generation failed: ${
|
|
122
|
+
throw new (0, _chunkPK72FAKDcjs.CognitiveError)(`LLM generation failed: ${_chunkNFZXJRXScjs.getErrorMessage.call(void 0, thrown)}`);
|
|
123
123
|
});
|
|
124
124
|
const out = typeof ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.content) === "string" ? output.output.choices[0].content : null;
|
|
125
125
|
if (!out) {
|
|
@@ -243,7 +243,7 @@ var interpretVMResult = async ({
|
|
|
243
243
|
});
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
|
-
const parsedExit =
|
|
246
|
+
const parsedExit = _chunkN3XPJTPEcjs.parseExit.call(void 0, returnValue, iteration.exits);
|
|
247
247
|
if (!parsedExit.success) {
|
|
248
248
|
iteration.end({
|
|
249
249
|
type: "exit_error",
|
|
@@ -267,7 +267,7 @@ var interpretVMResult = async ({
|
|
|
267
267
|
type: "exit_error",
|
|
268
268
|
exit_error: {
|
|
269
269
|
exit: returnExit.name,
|
|
270
|
-
message: `Error executing exit ${returnExit.name}: ${
|
|
270
|
+
message: `Error executing exit ${returnExit.name}: ${_chunkNFZXJRXScjs.getErrorMessage.call(void 0, err)}`,
|
|
271
271
|
return_value: returnValue
|
|
272
272
|
}
|
|
273
273
|
});
|
|
@@ -449,7 +449,7 @@ var buildVMContext = ({
|
|
|
449
449
|
onAfterTool
|
|
450
450
|
}) => {
|
|
451
451
|
const traces = iteration.traces;
|
|
452
|
-
const vmContext = { ...
|
|
452
|
+
const vmContext = { ..._chunkNFZXJRXScjs.stripInvalidIdentifiers.call(void 0, iteration.variables) };
|
|
453
453
|
for (const obj of iteration.objects) {
|
|
454
454
|
const internalValues = {};
|
|
455
455
|
const instance = {};
|
|
@@ -473,7 +473,7 @@ var buildVMContext = ({
|
|
|
473
473
|
const parsed = schema.safeParse(value2);
|
|
474
474
|
if (!parsed.success) {
|
|
475
475
|
throw new (0, _chunkPK72FAKDcjs.AssignmentError)(
|
|
476
|
-
`Invalid value for Object property ${obj.name}.${name}: ${
|
|
476
|
+
`Invalid value for Object property ${obj.name}.${name}: ${_chunkNFZXJRXScjs.getErrorMessage.call(void 0, parsed.error)}`
|
|
477
477
|
);
|
|
478
478
|
}
|
|
479
479
|
internalValues[name] = parsed.data;
|
|
@@ -524,7 +524,7 @@ var buildVMContext = ({
|
|
|
524
524
|
// src/runtime/execute.ts
|
|
525
525
|
var executeContext = async (props) => {
|
|
526
526
|
var _a, _b;
|
|
527
|
-
await
|
|
527
|
+
await _chunkNFZXJRXScjs.init.call(void 0, );
|
|
528
528
|
const result = await executeContextInternal(props);
|
|
529
529
|
try {
|
|
530
530
|
(_b = (_a = result.context.chat) == null ? void 0 : _a.onExecutionDone) == null ? void 0 : _b.call(_a, result);
|
|
@@ -538,7 +538,7 @@ var executeContextInternal = async (props) => {
|
|
|
538
538
|
const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
539
539
|
const client = _nullishCoalesce(props.client, () => ( new (0, _client.Client)()));
|
|
540
540
|
const cognitive = _cognitive.Cognitive.isCognitiveClient(client) ? client : _cognitive.CognitiveBeta.isBetaClient(client) ? _cognitive.cognitiveFromBeta.call(void 0, client) : new (0, _cognitive.Cognitive)({ client, __experimental_beta: true });
|
|
541
|
-
const ctx = new (0,
|
|
541
|
+
const ctx = new (0, _chunkN3XPJTPEcjs.Context)({
|
|
542
542
|
chat: props.chat,
|
|
543
543
|
instructions: props.instructions,
|
|
544
544
|
objects: props.objects,
|
|
@@ -554,7 +554,7 @@ var executeContextInternal = async (props) => {
|
|
|
554
554
|
try {
|
|
555
555
|
while (true) {
|
|
556
556
|
if (ctx.iterations.length >= ctx.loop) {
|
|
557
|
-
return new (0,
|
|
557
|
+
return new (0, _chunkN3XPJTPEcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
|
|
558
558
|
}
|
|
559
559
|
const iteration = await ctx.nextIteration();
|
|
560
560
|
const unsubscribeTrace = iteration.traces.onPush((traces) => {
|
|
@@ -585,7 +585,7 @@ var executeContextInternal = async (props) => {
|
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
});
|
|
588
|
-
return new (0,
|
|
588
|
+
return new (0, _chunkN3XPJTPEcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
|
|
589
589
|
}
|
|
590
590
|
const iterationResult = await executeIterationWithErrorHandling({
|
|
591
591
|
iteration,
|
|
@@ -614,7 +614,7 @@ var executeContextInternal = async (props) => {
|
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
} catch (error) {
|
|
617
|
-
return new (0,
|
|
617
|
+
return new (0, _chunkN3XPJTPEcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
618
618
|
}
|
|
619
619
|
};
|
|
620
620
|
var executeIterationStartHook = async ({
|
|
@@ -644,7 +644,7 @@ var executeIterationStartHook = async ({
|
|
|
644
644
|
} : {
|
|
645
645
|
type: "execution_error",
|
|
646
646
|
execution_error: {
|
|
647
|
-
message: `Error in onIterationStart hook: ${
|
|
647
|
+
message: `Error in onIterationStart hook: ${_chunkNFZXJRXScjs.getErrorMessage.call(void 0, err)}`,
|
|
648
648
|
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0,
|
|
649
649
|
err instanceof Error ? _nullishCoalesce(err.stack, () => ( "No stack trace available")) : "No stack trace available"
|
|
650
650
|
)
|
|
@@ -687,7 +687,7 @@ var executeIterationWithErrorHandling = async ({
|
|
|
687
687
|
status: iteration.status.type === "pending" ? {
|
|
688
688
|
type: "execution_error",
|
|
689
689
|
execution_error: {
|
|
690
|
-
message: "An unexpected error occurred: " +
|
|
690
|
+
message: "An unexpected error occurred: " + _chunkNFZXJRXScjs.getErrorMessage.call(void 0, err),
|
|
691
691
|
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0,
|
|
692
692
|
err instanceof Error ? _nullishCoalesce(err.stack, () => ( "No stack trace available")) : "No stack trace available"
|
|
693
693
|
)
|
|
@@ -699,7 +699,7 @@ var executeIterationWithErrorHandling = async ({
|
|
|
699
699
|
if (!controller.signal.aborted) {
|
|
700
700
|
return {
|
|
701
701
|
type: "return",
|
|
702
|
-
result: new (0,
|
|
702
|
+
result: new (0, _chunkN3XPJTPEcjs.ErrorExecutionResult)(ctx, err)
|
|
703
703
|
};
|
|
704
704
|
}
|
|
705
705
|
await finalizeIteration({
|
|
@@ -715,7 +715,7 @@ var executeIterationWithErrorHandling = async ({
|
|
|
715
715
|
});
|
|
716
716
|
return {
|
|
717
717
|
type: "return",
|
|
718
|
-
result: new (0,
|
|
718
|
+
result: new (0, _chunkN3XPJTPEcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")))
|
|
719
719
|
};
|
|
720
720
|
}
|
|
721
721
|
};
|
|
@@ -727,7 +727,7 @@ var transformIterationResult = ({
|
|
|
727
727
|
const exitName = iteration.status.exit_success.exit_name;
|
|
728
728
|
return {
|
|
729
729
|
type: "return",
|
|
730
|
-
result: new (0,
|
|
730
|
+
result: new (0, _chunkN3XPJTPEcjs.SuccessExecutionResult)(ctx, {
|
|
731
731
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
732
732
|
result: iteration.status.exit_success.return_value
|
|
733
733
|
})
|
|
@@ -736,17 +736,17 @@ var transformIterationResult = ({
|
|
|
736
736
|
if (iteration.status.type === "callback_requested") {
|
|
737
737
|
return {
|
|
738
738
|
type: "return",
|
|
739
|
-
result: new (0,
|
|
739
|
+
result: new (0, _chunkN3XPJTPEcjs.PartialExecutionResult)(
|
|
740
740
|
ctx,
|
|
741
741
|
iteration.status.callback_requested.signal,
|
|
742
|
-
|
|
742
|
+
_chunkN3XPJTPEcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
743
743
|
)
|
|
744
744
|
};
|
|
745
745
|
}
|
|
746
746
|
if (iteration.status.type === "aborted") {
|
|
747
747
|
return {
|
|
748
748
|
type: "return",
|
|
749
|
-
result: new (0,
|
|
749
|
+
result: new (0, _chunkN3XPJTPEcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( "The operation was aborted")))
|
|
750
750
|
};
|
|
751
751
|
}
|
|
752
752
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
@@ -754,7 +754,7 @@ var transformIterationResult = ({
|
|
|
754
754
|
}
|
|
755
755
|
return {
|
|
756
756
|
type: "return",
|
|
757
|
-
result: new (0,
|
|
757
|
+
result: new (0, _chunkN3XPJTPEcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)))
|
|
758
758
|
};
|
|
759
759
|
};
|
|
760
760
|
var executeIteration = async ({
|
|
@@ -788,7 +788,7 @@ var executeIteration = async ({
|
|
|
788
788
|
iteration.end({
|
|
789
789
|
type: "execution_error",
|
|
790
790
|
execution_error: {
|
|
791
|
-
message: `Error in onBeforeExecution hook: ${
|
|
791
|
+
message: `Error in onBeforeExecution hook: ${_chunkNFZXJRXScjs.getErrorMessage.call(void 0, err)}`,
|
|
792
792
|
stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0,
|
|
793
793
|
err instanceof Error ? _nullishCoalesce(err.stack, () => ( "No stack trace available")) : "No stack trace available"
|
|
794
794
|
)
|
|
@@ -823,7 +823,7 @@ var executeIteration = async ({
|
|
|
823
823
|
).catch((err) => {
|
|
824
824
|
return {
|
|
825
825
|
success: false,
|
|
826
|
-
error: err instanceof Error ? err : new Error(
|
|
826
|
+
error: err instanceof Error ? err : new Error(_chunkNFZXJRXScjs.getErrorMessage.call(void 0, err)),
|
|
827
827
|
lines_executed: [],
|
|
828
828
|
traces: [],
|
|
829
829
|
variables: {}
|