llmz 0.0.24 → 0.0.26
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-FZJHYLM2.cjs → chunk-45GKLDDR.cjs} +2 -2
- package/dist/{chunk-LUX4X7XO.js → chunk-7G5QAIUX.js} +2 -2
- package/dist/{chunk-XGJOEQMW.cjs → chunk-A63TROZX.cjs} +2 -2
- package/dist/{chunk-A7QHWVD7.js → chunk-CARJB3HP.js} +1 -1
- package/dist/{chunk-2D2DE7CD.js → chunk-EDVD6GWH.js} +1 -1
- package/dist/chunk-KIN7Y247.cjs +32 -0
- package/dist/{chunk-BNDY7RGX.cjs → chunk-M3LCKL55.cjs} +20 -20
- package/dist/{chunk-JKVVQN2P.js → chunk-MYLTD5WT.js} +15 -2
- package/dist/{chunk-EE6NVDID.js → chunk-PBTEQAZK.js} +1 -1
- package/dist/{chunk-2NU62OI4.cjs → chunk-PQILLTEM.cjs} +33 -20
- package/dist/{chunk-PIDLNYIP.cjs → chunk-Q2O6MYES.cjs} +4 -4
- package/dist/{chunk-QIZBF7A5.js → chunk-SHC22IAH.js} +25 -12
- package/dist/{chunk-JDABP4SD.cjs → chunk-T63Y6GTW.cjs} +17 -4
- package/dist/chunk-YEAWWJSJ.js +32 -0
- package/dist/context.d.ts +15 -11
- package/dist/{dual-modes-7FI4T35O.js → dual-modes-7FEESYXQ.js} +2 -2
- package/dist/{dual-modes-OFHV2C3X.cjs → dual-modes-F2HJJY2Z.cjs} +3 -3
- package/dist/errors.d.ts +3 -0
- package/dist/index.cjs +19 -19
- package/dist/index.d.ts +6 -2
- package/dist/index.js +12 -12
- package/dist/{llmz-IUGXC4SH.js → llmz-VGZUUM3U.js} +17 -16
- package/dist/{llmz-UUZTBIF3.cjs → llmz-Z5ULKYGZ.cjs} +41 -40
- package/dist/llmz.d.ts +15 -2
- package/dist/result.d.ts +6 -6
- package/dist/tool-4J4JNDNV.cjs +11 -0
- package/dist/tool-SFRUHH7M.js +11 -0
- package/dist/typings-2WTRKHEH.cjs +10 -0
- package/dist/{typings-WYHEFCYB.js → typings-AYAZ5YA3.js} +3 -3
- package/dist/{vm-CYC5RLKU.js → vm-I4G4IH7T.js} +3 -3
- package/dist/vm-YJX6M4NJ.cjs +12 -0
- package/package.json +6 -3
- package/dist/chunk-IKSIOIIP.cjs +0 -28
- package/dist/chunk-JQBT7UWN.js +0 -28
- package/dist/tool-O4SFRIE4.cjs +0 -11
- package/dist/tool-PCOYOCRH.js +0 -11
- package/dist/typings-Y45GMPZT.cjs +0 -10
- package/dist/vm-PRZ5GEM2.cjs +0 -12
|
@@ -1,6 +1,6 @@
|
|
|
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 _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -38,7 +38,7 @@ async function formatTypings(typings, options) {
|
|
|
38
38
|
return result;
|
|
39
39
|
} catch (err) {
|
|
40
40
|
if (options == null ? void 0 : options.throwOnError) {
|
|
41
|
-
throw new (0,
|
|
41
|
+
throw new (0, _chunkT63Y6GTWcjs.CodeFormattingError)(err instanceof Error ? err.message : _nullishCoalesce((err == null ? void 0 : err.toString()), () => ( "Unknown Error")), typings);
|
|
42
42
|
}
|
|
43
43
|
return typings;
|
|
44
44
|
}
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
Signals,
|
|
6
6
|
SnapshotSignal,
|
|
7
7
|
VMSignal
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MYLTD5WT.js";
|
|
9
9
|
import {
|
|
10
10
|
cleanStackTrace
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-YEAWWJSJ.js";
|
|
12
12
|
import {
|
|
13
13
|
createJsxComponent
|
|
14
14
|
} from "./chunk-ORQP26SZ.js";
|
|
@@ -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 _chunk45GKLDDRcjs = require('./chunk-45GKLDDR.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -422,7 +422,7 @@ var Tool = (_class = class _Tool {
|
|
|
422
422
|
input = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
423
423
|
}
|
|
424
424
|
const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
|
|
425
|
-
return
|
|
425
|
+
return _chunk45GKLDDRcjs.getTypings.call(void 0, fnType, {
|
|
426
426
|
declaration: true
|
|
427
427
|
});
|
|
428
428
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/stack-traces.ts
|
|
2
|
+
var isInternalLine = (line) => {
|
|
3
|
+
return line.includes("/llmz/") || line.includes("\\llmz\\src\\") || line.includes("node_modules");
|
|
4
|
+
};
|
|
5
|
+
function cleanStackTrace(stack, cleanInternal = true) {
|
|
6
|
+
let lines = stack.split("\n");
|
|
7
|
+
const until = lines.findIndex((line) => isInternalLine(line));
|
|
8
|
+
if (cleanInternal && until >= 0) {
|
|
9
|
+
lines = lines.slice(0, until);
|
|
10
|
+
} else {
|
|
11
|
+
lines = lines.map((line) => {
|
|
12
|
+
let llmzIndex = line.indexOf("/llmz/");
|
|
13
|
+
if (llmzIndex === -1) {
|
|
14
|
+
llmzIndex = line.indexOf("\\llmz\\");
|
|
15
|
+
}
|
|
16
|
+
if (llmzIndex === -1) {
|
|
17
|
+
return line;
|
|
18
|
+
}
|
|
19
|
+
let lastSpaceIndex = line.lastIndexOf(" ", llmzIndex);
|
|
20
|
+
if (lastSpaceIndex === -1) {
|
|
21
|
+
lastSpaceIndex = 0;
|
|
22
|
+
}
|
|
23
|
+
const maybeParen = line[lastSpaceIndex + 1] === "(" ? "(" : "";
|
|
24
|
+
return line.slice(0, lastSpaceIndex + 1) + maybeParen + line.slice(llmzIndex);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return lines.join("\n");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.cleanStackTrace = cleanStackTrace;
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkKMZDFWYZcjs = require('./chunk-KMZDFWYZ.cjs');
|
|
@@ -2644,7 +2644,7 @@ function getCompiledCode(code, traces = []) {
|
|
|
2644
2644
|
code,
|
|
2645
2645
|
started_at: Date.now()
|
|
2646
2646
|
});
|
|
2647
|
-
throw new (0,
|
|
2647
|
+
throw new (0, _chunkT63Y6GTWcjs.InvalidCodeError)(err.message, code);
|
|
2648
2648
|
}
|
|
2649
2649
|
}
|
|
2650
2650
|
async function runAsyncFunction(context, code, traces = [], signal = null, timeout = MAX_VM_EXECUTION_TIME) {
|
|
@@ -2693,8 +2693,8 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2693
2693
|
let currentToolCall;
|
|
2694
2694
|
context[Identifiers.ToolCallTrackerFnIdentifier] = (callId, type, outputOrError) => {
|
|
2695
2695
|
var _a4;
|
|
2696
|
-
const temp =
|
|
2697
|
-
if (type === "end" && temp instanceof
|
|
2696
|
+
const temp = _chunkT63Y6GTWcjs.Signals.maybeDeserializeError(outputOrError == null ? void 0 : outputOrError.message);
|
|
2697
|
+
if (type === "end" && temp instanceof _chunkT63Y6GTWcjs.SnapshotSignal && (temp == null ? void 0 : temp.toolCall)) {
|
|
2698
2698
|
currentToolCall = {
|
|
2699
2699
|
...temp.toolCall,
|
|
2700
2700
|
assignment: (_a4 = transformed.toolCalls.get(callId)) == null ? void 0 : _a4.assignment
|
|
@@ -2758,11 +2758,11 @@ async function runAsyncFunction(context, code, traces = [], signal = null, timeo
|
|
|
2758
2758
|
await context[Identifiers.AsyncIterYieldFnIdentifier](value);
|
|
2759
2759
|
} while (true);
|
|
2760
2760
|
})().then((res) => {
|
|
2761
|
-
res =
|
|
2761
|
+
res = _chunkT63Y6GTWcjs.Signals.maybeDeserializeError(res);
|
|
2762
2762
|
return {
|
|
2763
2763
|
success: true,
|
|
2764
2764
|
variables: _chunkUQOBUJIQcjs.mapValues_default.call(void 0, variables, (getter) => _chunkUQOBUJIQcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
|
|
2765
|
-
signal: res instanceof
|
|
2765
|
+
signal: res instanceof _chunkT63Y6GTWcjs.VMSignal ? res : void 0,
|
|
2766
2766
|
lines_executed: Array.from(lines_executed),
|
|
2767
2767
|
return_value: res
|
|
2768
2768
|
};
|
|
@@ -2954,7 +2954,7 @@ do {
|
|
|
2954
2954
|
try {
|
|
2955
2955
|
Object.assign(context[key], { [prop]: obj });
|
|
2956
2956
|
} catch (err) {
|
|
2957
|
-
if (err instanceof
|
|
2957
|
+
if (err instanceof _chunkT63Y6GTWcjs.AssignmentError) {
|
|
2958
2958
|
traces.push({
|
|
2959
2959
|
type: "code_execution_exception",
|
|
2960
2960
|
position: [0, 0],
|
|
@@ -2982,7 +2982,7 @@ do {
|
|
|
2982
2982
|
try {
|
|
2983
2983
|
Object.assign(context, { [key]: value });
|
|
2984
2984
|
} catch (err) {
|
|
2985
|
-
if (err instanceof
|
|
2985
|
+
if (err instanceof _chunkT63Y6GTWcjs.AssignmentError) {
|
|
2986
2986
|
traces.push({
|
|
2987
2987
|
type: "code_execution_exception",
|
|
2988
2988
|
position: [0, 0],
|
|
@@ -3007,16 +3007,16 @@ do {
|
|
|
3007
3007
|
}).then((res) => {
|
|
3008
3008
|
copyBackContextFromJail();
|
|
3009
3009
|
if (copyErrors.length) {
|
|
3010
|
-
throw new (0,
|
|
3010
|
+
throw new (0, _chunkT63Y6GTWcjs.CodeExecutionError)(copyErrors.map((x) => x.message).join(", "), code, "");
|
|
3011
3011
|
}
|
|
3012
3012
|
return res;
|
|
3013
3013
|
}).then(
|
|
3014
3014
|
(res) => {
|
|
3015
|
-
res =
|
|
3015
|
+
res = _chunkT63Y6GTWcjs.Signals.maybeDeserializeError(res);
|
|
3016
3016
|
return {
|
|
3017
3017
|
success: true,
|
|
3018
3018
|
variables: _chunkUQOBUJIQcjs.mapValues_default.call(void 0, variables, (getter) => _chunkUQOBUJIQcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
|
|
3019
|
-
signal: res instanceof
|
|
3019
|
+
signal: res instanceof _chunkT63Y6GTWcjs.VMSignal ? res : void 0,
|
|
3020
3020
|
lines_executed: Array.from(lines_executed),
|
|
3021
3021
|
return_value: res
|
|
3022
3022
|
};
|
|
@@ -3045,7 +3045,7 @@ do {
|
|
|
3045
3045
|
}
|
|
3046
3046
|
var handleError = (err, code, consumer, traces, variables, lines_executed, currentToolCall, driver = "isolated-vm") => {
|
|
3047
3047
|
var _a3, _b, _c;
|
|
3048
|
-
err =
|
|
3048
|
+
err = _chunkT63Y6GTWcjs.Signals.maybeDeserializeError(err);
|
|
3049
3049
|
const lines = code.split("\n");
|
|
3050
3050
|
const stackTrace = err.stack || "";
|
|
3051
3051
|
const LINE_OFFSET = driver === "isolated-vm" ? 3 : 1;
|
|
@@ -3097,9 +3097,9 @@ var handleError = (err, code, consumer, traces, variables, lines_executed, curre
|
|
|
3097
3097
|
`);
|
|
3098
3098
|
}
|
|
3099
3099
|
}
|
|
3100
|
-
debugUserCode =
|
|
3101
|
-
truncatedCode =
|
|
3102
|
-
if (err instanceof
|
|
3100
|
+
debugUserCode = _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, debugUserCode).trim();
|
|
3101
|
+
truncatedCode = _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, truncatedCode).trim();
|
|
3102
|
+
if (err instanceof _chunkT63Y6GTWcjs.VMSignal) {
|
|
3103
3103
|
err.stack = debugUserCode;
|
|
3104
3104
|
err.truncatedCode = truncatedCode;
|
|
3105
3105
|
err.variables = _chunkUQOBUJIQcjs.mapValues_default.call(void 0, variables, (getter) => _chunkUQOBUJIQcjs.isFunction_default.call(void 0, getter) ? getter() : getter);
|
|
@@ -3113,16 +3113,16 @@ var handleError = (err, code, consumer, traces, variables, lines_executed, curre
|
|
|
3113
3113
|
stackTrace: debugUserCode,
|
|
3114
3114
|
started_at: Date.now()
|
|
3115
3115
|
});
|
|
3116
|
-
throw new (0,
|
|
3116
|
+
throw new (0, _chunkT63Y6GTWcjs.CodeExecutionError)(err.message, code, debugUserCode);
|
|
3117
3117
|
}
|
|
3118
3118
|
};
|
|
3119
3119
|
var handleCatch = (err, traces, variables, lines_executed) => {
|
|
3120
|
-
err =
|
|
3120
|
+
err = _chunkT63Y6GTWcjs.Signals.maybeDeserializeError(err);
|
|
3121
3121
|
return {
|
|
3122
|
-
success: err instanceof
|
|
3122
|
+
success: err instanceof _chunkT63Y6GTWcjs.VMSignal ? true : false,
|
|
3123
3123
|
variables: _chunkUQOBUJIQcjs.mapValues_default.call(void 0, variables, (getter) => _chunkUQOBUJIQcjs.isFunction_default.call(void 0, getter) ? getter() : getter),
|
|
3124
3124
|
error: err,
|
|
3125
|
-
signal: err instanceof
|
|
3125
|
+
signal: err instanceof _chunkT63Y6GTWcjs.VMSignal ? err : void 0,
|
|
3126
3126
|
traces,
|
|
3127
3127
|
lines_executed: Array.from(lines_executed)
|
|
3128
3128
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cleanStackTrace
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YEAWWJSJ.js";
|
|
4
4
|
|
|
5
5
|
// src/errors.ts
|
|
6
6
|
var errorClasses = {};
|
|
@@ -101,6 +101,7 @@ var ThinkSignal = class extends VMLoopSignal {
|
|
|
101
101
|
this.reason = reason;
|
|
102
102
|
this.context = context;
|
|
103
103
|
this.message = Signals.serializeError(this);
|
|
104
|
+
this.stack = "";
|
|
104
105
|
}
|
|
105
106
|
toString() {
|
|
106
107
|
return Signals.serializeError(this);
|
|
@@ -119,12 +120,14 @@ var InvalidCodeError = class extends Error {
|
|
|
119
120
|
super(message);
|
|
120
121
|
this.code = code;
|
|
121
122
|
this.message = Signals.serializeError(this);
|
|
123
|
+
this.stack = "";
|
|
122
124
|
}
|
|
123
125
|
};
|
|
124
126
|
var LoopExceededError = class extends Error {
|
|
125
127
|
constructor() {
|
|
126
128
|
super("Loop exceeded error");
|
|
127
129
|
this.message = Signals.serializeError(this);
|
|
130
|
+
this.stack = "";
|
|
128
131
|
}
|
|
129
132
|
};
|
|
130
133
|
var CodeFormattingError = class extends Error {
|
|
@@ -133,6 +136,7 @@ var CodeFormattingError = class extends Error {
|
|
|
133
136
|
cause: "Code formatting error"
|
|
134
137
|
});
|
|
135
138
|
this.code = code;
|
|
139
|
+
this.stack = "";
|
|
136
140
|
}
|
|
137
141
|
};
|
|
138
142
|
var AssignmentError = class extends Error {
|
|
@@ -141,12 +145,20 @@ var AssignmentError = class extends Error {
|
|
|
141
145
|
this.message = Signals.serializeError(this);
|
|
142
146
|
}
|
|
143
147
|
};
|
|
148
|
+
var CognitiveError = class extends Error {
|
|
149
|
+
constructor(message) {
|
|
150
|
+
super(message);
|
|
151
|
+
this.message = Signals.serializeError(this);
|
|
152
|
+
this.stack = "";
|
|
153
|
+
}
|
|
154
|
+
};
|
|
144
155
|
registerErrorClass("VMSignal", VMSignal);
|
|
145
156
|
registerErrorClass("SnapshotSignal", SnapshotSignal);
|
|
146
157
|
registerErrorClass("VMLoopSignal", VMLoopSignal);
|
|
147
158
|
registerErrorClass("ThinkSignal", ThinkSignal);
|
|
148
159
|
registerErrorClass("CodeExecutionError", CodeExecutionError);
|
|
149
160
|
registerErrorClass("AssignmentError", AssignmentError);
|
|
161
|
+
registerErrorClass("CognitiveError", CognitiveError);
|
|
150
162
|
|
|
151
163
|
export {
|
|
152
164
|
Signals,
|
|
@@ -157,5 +169,6 @@ export {
|
|
|
157
169
|
InvalidCodeError,
|
|
158
170
|
LoopExceededError,
|
|
159
171
|
CodeFormattingError,
|
|
160
|
-
AssignmentError
|
|
172
|
+
AssignmentError,
|
|
173
|
+
CognitiveError
|
|
161
174
|
};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkQ2O6MYEScjs = require('./chunk-Q2O6MYES.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkA63TROZXcjs = require('./chunk-A63TROZX.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkT63Y6GTWcjs = require('./chunk-T63Y6GTW.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunk3G3BS5IAcjs = require('./chunk-3G3BS5IA.cjs');
|
|
@@ -62,10 +62,10 @@ var Snapshot = class _Snapshot {
|
|
|
62
62
|
*/
|
|
63
63
|
static fromSignal(signal) {
|
|
64
64
|
const variables = Object.entries(signal.variables).map(([name, value]) => {
|
|
65
|
-
const type =
|
|
65
|
+
const type = _chunkQ2O6MYEScjs.extractType.call(void 0, value);
|
|
66
66
|
const bytes = JSON.stringify(value || "").length;
|
|
67
67
|
const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
|
|
68
|
-
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(
|
|
68
|
+
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkQ2O6MYEScjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
|
|
69
69
|
});
|
|
70
70
|
return new _Snapshot({
|
|
71
71
|
id: "snapshot_" + _ulid.ulid.call(void 0, ),
|
|
@@ -210,9 +210,9 @@ function getMessagePreview(message) {
|
|
|
210
210
|
return message.content;
|
|
211
211
|
}
|
|
212
212
|
if (message.role === "event") {
|
|
213
|
-
return
|
|
213
|
+
return _chunkQ2O6MYEScjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
|
|
214
214
|
}
|
|
215
|
-
return
|
|
215
|
+
return _chunkQ2O6MYEScjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
|
|
216
216
|
}
|
|
217
217
|
function getMessageType(message) {
|
|
218
218
|
if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
|
|
@@ -684,6 +684,12 @@ var Iteration = class {
|
|
|
684
684
|
get objects() {
|
|
685
685
|
return this._parameters.objects;
|
|
686
686
|
}
|
|
687
|
+
get model() {
|
|
688
|
+
return this._parameters.model;
|
|
689
|
+
}
|
|
690
|
+
get temperature() {
|
|
691
|
+
return this._parameters.temperature;
|
|
692
|
+
}
|
|
687
693
|
get exits() {
|
|
688
694
|
const exits = [...this._parameters.exits, ThinkExit];
|
|
689
695
|
if (this.isChatEnabled) {
|
|
@@ -763,6 +769,8 @@ var Iteration = class {
|
|
|
763
769
|
id: this.id,
|
|
764
770
|
messages: [...this.messages],
|
|
765
771
|
code: this.code,
|
|
772
|
+
model: this.model,
|
|
773
|
+
temperature: this.temperature,
|
|
766
774
|
traces: [...this.traces],
|
|
767
775
|
variables: this.variables,
|
|
768
776
|
started_ts: this.started_ts,
|
|
@@ -788,11 +796,11 @@ var Context = (_class2 = class {
|
|
|
788
796
|
|
|
789
797
|
|
|
790
798
|
|
|
791
|
-
__init3() {this.version = _chunkPIDLNYIPcjs.DualModePrompt}
|
|
792
|
-
__init4() {this.timeout = 6e4}
|
|
793
|
-
// Default timeout of 60 seconds
|
|
794
799
|
|
|
795
800
|
|
|
801
|
+
__init3() {this.version = _chunkQ2O6MYEScjs.DualModePrompt}
|
|
802
|
+
__init4() {this.timeout = 6e4}
|
|
803
|
+
// Default timeout of 60 seconds
|
|
796
804
|
|
|
797
805
|
|
|
798
806
|
|
|
@@ -800,7 +808,7 @@ var Context = (_class2 = class {
|
|
|
800
808
|
|
|
801
809
|
async nextIteration() {
|
|
802
810
|
if (this.iterations.length >= this.loop) {
|
|
803
|
-
throw new (0,
|
|
811
|
+
throw new (0, _chunkT63Y6GTWcjs.LoopExceededError)();
|
|
804
812
|
}
|
|
805
813
|
if (this.snapshot && this.snapshot.status.type === "pending") {
|
|
806
814
|
throw new Error(
|
|
@@ -958,10 +966,12 @@ var Context = (_class2 = class {
|
|
|
958
966
|
var _a, _b;
|
|
959
967
|
const instructions = await getValue(this.instructions, this);
|
|
960
968
|
const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
|
|
961
|
-
const tools =
|
|
969
|
+
const tools = _chunkA63TROZXcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
|
|
962
970
|
const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
|
|
963
971
|
const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
|
|
964
972
|
const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
|
|
973
|
+
const model = await _asyncNullishCoalesce(await getValue(this.model, this), async () => ( "best"));
|
|
974
|
+
const temperature = await getValue(this.temperature, this);
|
|
965
975
|
if (objects && objects.length > 100) {
|
|
966
976
|
throw new Error("Too many objects. Expected at most 100 objects.");
|
|
967
977
|
}
|
|
@@ -988,7 +998,7 @@ var Context = (_class2 = class {
|
|
|
988
998
|
"boolean",
|
|
989
999
|
"array"
|
|
990
1000
|
];
|
|
991
|
-
const MessageTool = this.chat && components.length ? new (0,
|
|
1001
|
+
const MessageTool = this.chat && components.length ? new (0, _chunkA63TROZXcjs.Tool)({
|
|
992
1002
|
name: "Message",
|
|
993
1003
|
description: "Send a message to the user",
|
|
994
1004
|
aliases: Array.from(
|
|
@@ -1041,13 +1051,21 @@ var Context = (_class2 = class {
|
|
|
1041
1051
|
if (!components.length && !exits.length) {
|
|
1042
1052
|
exits.push(DefaultExit);
|
|
1043
1053
|
}
|
|
1054
|
+
if (typeof temperature !== "number" || isNaN(temperature) || temperature < 0 || temperature > 2) {
|
|
1055
|
+
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1056
|
+
}
|
|
1057
|
+
if (typeof model !== "string" || model.length === 0) {
|
|
1058
|
+
throw new Error("Invalid model. Expected a non-empty string.");
|
|
1059
|
+
}
|
|
1044
1060
|
return {
|
|
1045
1061
|
transcript,
|
|
1046
1062
|
tools: allTools,
|
|
1047
1063
|
objects,
|
|
1048
1064
|
exits,
|
|
1049
1065
|
instructions,
|
|
1050
|
-
components
|
|
1066
|
+
components,
|
|
1067
|
+
model,
|
|
1068
|
+
temperature
|
|
1051
1069
|
};
|
|
1052
1070
|
}
|
|
1053
1071
|
constructor(props) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
|
|
@@ -1060,16 +1078,13 @@ var Context = (_class2 = class {
|
|
|
1060
1078
|
this.timeout = Math.min(999999999, Math.max(0, _nullishCoalesce(props.timeout, () => ( 6e4))));
|
|
1061
1079
|
this.loop = _nullishCoalesce(props.loop, () => ( 3));
|
|
1062
1080
|
this.temperature = _nullishCoalesce(props.temperature, () => ( 0.7));
|
|
1063
|
-
this.model = props.model;
|
|
1081
|
+
this.model = _nullishCoalesce(props.model, () => ( "best"));
|
|
1064
1082
|
this.iterations = [];
|
|
1065
1083
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
1066
1084
|
this.snapshot = props.snapshot;
|
|
1067
1085
|
if (this.loop < 1 || this.loop > 100) {
|
|
1068
1086
|
throw new Error("Invalid loop. Expected a number between 1 and 100.");
|
|
1069
1087
|
}
|
|
1070
|
-
if (this.temperature < 0 || this.temperature > 2) {
|
|
1071
|
-
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1072
|
-
}
|
|
1073
1088
|
}
|
|
1074
1089
|
toJSON() {
|
|
1075
1090
|
var _a;
|
|
@@ -1079,8 +1094,6 @@ var Context = (_class2 = class {
|
|
|
1079
1094
|
iteration: this.iteration,
|
|
1080
1095
|
timeout: this.timeout,
|
|
1081
1096
|
loop: this.loop,
|
|
1082
|
-
temperature: this.temperature,
|
|
1083
|
-
model: this.model,
|
|
1084
1097
|
metadata: this.metadata,
|
|
1085
1098
|
snapshot: (_a = this.snapshot) == null ? void 0 : _a.toJSON()
|
|
1086
1099
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
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 _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
|
|
@@ -619,7 +619,7 @@ ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, props.message, { preserve: "top", f
|
|
|
619
619
|
|
|
620
620
|
Stack Trace:
|
|
621
621
|
\`\`\`
|
|
622
|
-
${_chunkGZPN7RGHcjs.wrapContent.call(void 0,
|
|
622
|
+
${_chunkGZPN7RGHcjs.wrapContent.call(void 0, _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
|
|
623
623
|
\`\`\`
|
|
624
624
|
|
|
625
625
|
Let the user know that an error occurred, and if possible, try something else. Do not repeat yourself in the message.
|
|
@@ -712,7 +712,7 @@ let ${variable.name}: undefined | ${variable.type} = undefined;
|
|
|
712
712
|
## Important message from the VM
|
|
713
713
|
|
|
714
714
|
The execution of an asynchronous code block has been completed. Here's the code that was executed:
|
|
715
|
-
${
|
|
715
|
+
${_chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.snapshot.stack).split("\n").slice(0, -1).join("\n")}
|
|
716
716
|
// Reason: ${props.snapshot.reason}
|
|
717
717
|
\`\`\`tsx
|
|
718
718
|
/**
|
|
@@ -758,7 +758,7 @@ var getSnapshotRejectedMessage = (props) => {
|
|
|
758
758
|
|
|
759
759
|
An error occurred while executing the code. Here is the code that was executed so far:
|
|
760
760
|
|
|
761
|
-
${
|
|
761
|
+
${_chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.snapshot.stack).split("\n").slice(0, -1).join("\n")}
|
|
762
762
|
// Reason: ${props.snapshot.reason}
|
|
763
763
|
|
|
764
764
|
Here's the error:
|
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
DualModePrompt,
|
|
3
3
|
extractType,
|
|
4
4
|
inspect
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EDVD6GWH.js";
|
|
6
6
|
import {
|
|
7
7
|
Tool
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CARJB3HP.js";
|
|
9
9
|
import {
|
|
10
10
|
LoopExceededError
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MYLTD5WT.js";
|
|
12
12
|
import {
|
|
13
13
|
Exit
|
|
14
14
|
} from "./chunk-VPTFUOIK.js";
|
|
@@ -684,6 +684,12 @@ var Iteration = class {
|
|
|
684
684
|
get objects() {
|
|
685
685
|
return this._parameters.objects;
|
|
686
686
|
}
|
|
687
|
+
get model() {
|
|
688
|
+
return this._parameters.model;
|
|
689
|
+
}
|
|
690
|
+
get temperature() {
|
|
691
|
+
return this._parameters.temperature;
|
|
692
|
+
}
|
|
687
693
|
get exits() {
|
|
688
694
|
const exits = [...this._parameters.exits, ThinkExit];
|
|
689
695
|
if (this.isChatEnabled) {
|
|
@@ -763,6 +769,8 @@ var Iteration = class {
|
|
|
763
769
|
id: this.id,
|
|
764
770
|
messages: [...this.messages],
|
|
765
771
|
code: this.code,
|
|
772
|
+
model: this.model,
|
|
773
|
+
temperature: this.temperature,
|
|
766
774
|
traces: [...this.traces],
|
|
767
775
|
variables: this.variables,
|
|
768
776
|
started_ts: this.started_ts,
|
|
@@ -788,12 +796,12 @@ var Context = class {
|
|
|
788
796
|
objects;
|
|
789
797
|
tools;
|
|
790
798
|
exits;
|
|
799
|
+
model;
|
|
800
|
+
temperature;
|
|
791
801
|
version = DualModePrompt;
|
|
792
802
|
timeout = 6e4;
|
|
793
803
|
// Default timeout of 60 seconds
|
|
794
804
|
loop;
|
|
795
|
-
temperature;
|
|
796
|
-
model;
|
|
797
805
|
metadata;
|
|
798
806
|
snapshot;
|
|
799
807
|
iteration = 0;
|
|
@@ -962,6 +970,8 @@ var Context = class {
|
|
|
962
970
|
const objects = await getValue(this.objects, this) ?? [];
|
|
963
971
|
const exits = await getValue(this.exits, this) ?? [];
|
|
964
972
|
const components = await getValue(((_b = this.chat) == null ? void 0 : _b.components) ?? [], this);
|
|
973
|
+
const model = await getValue(this.model, this) ?? "best";
|
|
974
|
+
const temperature = await getValue(this.temperature, this);
|
|
965
975
|
if (objects && objects.length > 100) {
|
|
966
976
|
throw new Error("Too many objects. Expected at most 100 objects.");
|
|
967
977
|
}
|
|
@@ -1041,13 +1051,21 @@ var Context = class {
|
|
|
1041
1051
|
if (!components.length && !exits.length) {
|
|
1042
1052
|
exits.push(DefaultExit);
|
|
1043
1053
|
}
|
|
1054
|
+
if (typeof temperature !== "number" || isNaN(temperature) || temperature < 0 || temperature > 2) {
|
|
1055
|
+
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1056
|
+
}
|
|
1057
|
+
if (typeof model !== "string" || model.length === 0) {
|
|
1058
|
+
throw new Error("Invalid model. Expected a non-empty string.");
|
|
1059
|
+
}
|
|
1044
1060
|
return {
|
|
1045
1061
|
transcript,
|
|
1046
1062
|
tools: allTools,
|
|
1047
1063
|
objects,
|
|
1048
1064
|
exits,
|
|
1049
1065
|
instructions,
|
|
1050
|
-
components
|
|
1066
|
+
components,
|
|
1067
|
+
model,
|
|
1068
|
+
temperature
|
|
1051
1069
|
};
|
|
1052
1070
|
}
|
|
1053
1071
|
constructor(props) {
|
|
@@ -1060,16 +1078,13 @@ var Context = class {
|
|
|
1060
1078
|
this.timeout = Math.min(999999999, Math.max(0, props.timeout ?? 6e4));
|
|
1061
1079
|
this.loop = props.loop ?? 3;
|
|
1062
1080
|
this.temperature = props.temperature ?? 0.7;
|
|
1063
|
-
this.model = props.model;
|
|
1081
|
+
this.model = props.model ?? "best";
|
|
1064
1082
|
this.iterations = [];
|
|
1065
1083
|
this.metadata = props.metadata ?? {};
|
|
1066
1084
|
this.snapshot = props.snapshot;
|
|
1067
1085
|
if (this.loop < 1 || this.loop > 100) {
|
|
1068
1086
|
throw new Error("Invalid loop. Expected a number between 1 and 100.");
|
|
1069
1087
|
}
|
|
1070
|
-
if (this.temperature < 0 || this.temperature > 2) {
|
|
1071
|
-
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1072
|
-
}
|
|
1073
1088
|
}
|
|
1074
1089
|
toJSON() {
|
|
1075
1090
|
var _a;
|
|
@@ -1079,8 +1094,6 @@ var Context = class {
|
|
|
1079
1094
|
iteration: this.iteration,
|
|
1080
1095
|
timeout: this.timeout,
|
|
1081
1096
|
loop: this.loop,
|
|
1082
|
-
temperature: this.temperature,
|
|
1083
|
-
model: this.model,
|
|
1084
1097
|
metadata: this.metadata,
|
|
1085
1098
|
snapshot: (_a = this.snapshot) == null ? void 0 : _a.toJSON()
|
|
1086
1099
|
};
|