@elizaos/core 1.7.1-alpha.2 → 1.7.1-alpha.3
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/browser/index.browser.js +92 -92
- package/dist/browser/index.browser.js.map +15 -14
- package/dist/node/index.node.js +516 -196
- package/dist/node/index.node.js.map +9 -8
- package/dist/runtime.d.ts +4 -0
- package/dist/runtime.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/node/index.node.js
CHANGED
|
@@ -5053,11 +5053,11 @@ var require_ast = __commonJS((exports, module) => {
|
|
|
5053
5053
|
helperExpression: function helperExpression(node) {
|
|
5054
5054
|
return node.type === "SubExpression" || (node.type === "MustacheStatement" || node.type === "BlockStatement") && !!(node.params && node.params.length || node.hash);
|
|
5055
5055
|
},
|
|
5056
|
-
scopedId: function scopedId(
|
|
5057
|
-
return /^\.|this\b/.test(
|
|
5056
|
+
scopedId: function scopedId(path2) {
|
|
5057
|
+
return /^\.|this\b/.test(path2.original);
|
|
5058
5058
|
},
|
|
5059
|
-
simpleId: function simpleId(
|
|
5060
|
-
return
|
|
5059
|
+
simpleId: function simpleId(path2) {
|
|
5060
|
+
return path2.parts.length === 1 && !AST.helpers.scopedId(path2) && !path2.depth;
|
|
5061
5061
|
}
|
|
5062
5062
|
}
|
|
5063
5063
|
};
|
|
@@ -6117,12 +6117,12 @@ var require_helpers2 = __commonJS((exports) => {
|
|
|
6117
6117
|
loc
|
|
6118
6118
|
};
|
|
6119
6119
|
}
|
|
6120
|
-
function prepareMustache(
|
|
6120
|
+
function prepareMustache(path2, params, hash, open, strip, locInfo) {
|
|
6121
6121
|
var escapeFlag = open.charAt(3) || open.charAt(2), escaped = escapeFlag !== "{" && escapeFlag !== "&";
|
|
6122
6122
|
var decorator = /\*/.test(open);
|
|
6123
6123
|
return {
|
|
6124
6124
|
type: decorator ? "Decorator" : "MustacheStatement",
|
|
6125
|
-
path,
|
|
6125
|
+
path: path2,
|
|
6126
6126
|
params,
|
|
6127
6127
|
hash,
|
|
6128
6128
|
escaped,
|
|
@@ -6386,9 +6386,9 @@ var require_compiler = __commonJS((exports) => {
|
|
|
6386
6386
|
},
|
|
6387
6387
|
DecoratorBlock: function DecoratorBlock(decorator) {
|
|
6388
6388
|
var program = decorator.program && this.compileProgram(decorator.program);
|
|
6389
|
-
var params = this.setupFullMustacheParams(decorator, program, undefined),
|
|
6389
|
+
var params = this.setupFullMustacheParams(decorator, program, undefined), path2 = decorator.path;
|
|
6390
6390
|
this.useDecorators = true;
|
|
6391
|
-
this.opcode("registerDecorator", params.length,
|
|
6391
|
+
this.opcode("registerDecorator", params.length, path2.original);
|
|
6392
6392
|
},
|
|
6393
6393
|
PartialStatement: function PartialStatement(partial) {
|
|
6394
6394
|
this.usePartial = true;
|
|
@@ -6451,46 +6451,46 @@ var require_compiler = __commonJS((exports) => {
|
|
|
6451
6451
|
}
|
|
6452
6452
|
},
|
|
6453
6453
|
ambiguousSexpr: function ambiguousSexpr(sexpr, program, inverse) {
|
|
6454
|
-
var
|
|
6455
|
-
this.opcode("getContext",
|
|
6454
|
+
var path2 = sexpr.path, name = path2.parts[0], isBlock = program != null || inverse != null;
|
|
6455
|
+
this.opcode("getContext", path2.depth);
|
|
6456
6456
|
this.opcode("pushProgram", program);
|
|
6457
6457
|
this.opcode("pushProgram", inverse);
|
|
6458
|
-
|
|
6459
|
-
this.accept(
|
|
6458
|
+
path2.strict = true;
|
|
6459
|
+
this.accept(path2);
|
|
6460
6460
|
this.opcode("invokeAmbiguous", name, isBlock);
|
|
6461
6461
|
},
|
|
6462
6462
|
simpleSexpr: function simpleSexpr(sexpr) {
|
|
6463
|
-
var
|
|
6464
|
-
|
|
6465
|
-
this.accept(
|
|
6463
|
+
var path2 = sexpr.path;
|
|
6464
|
+
path2.strict = true;
|
|
6465
|
+
this.accept(path2);
|
|
6466
6466
|
this.opcode("resolvePossibleLambda");
|
|
6467
6467
|
},
|
|
6468
6468
|
helperSexpr: function helperSexpr(sexpr, program, inverse) {
|
|
6469
|
-
var params = this.setupFullMustacheParams(sexpr, program, inverse),
|
|
6469
|
+
var params = this.setupFullMustacheParams(sexpr, program, inverse), path2 = sexpr.path, name = path2.parts[0];
|
|
6470
6470
|
if (this.options.knownHelpers[name]) {
|
|
6471
6471
|
this.opcode("invokeKnownHelper", params.length, name);
|
|
6472
6472
|
} else if (this.options.knownHelpersOnly) {
|
|
6473
6473
|
throw new _exception2["default"]("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
|
|
6474
6474
|
} else {
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
this.accept(
|
|
6478
|
-
this.opcode("invokeHelper", params.length,
|
|
6475
|
+
path2.strict = true;
|
|
6476
|
+
path2.falsy = true;
|
|
6477
|
+
this.accept(path2);
|
|
6478
|
+
this.opcode("invokeHelper", params.length, path2.original, _ast2["default"].helpers.simpleId(path2));
|
|
6479
6479
|
}
|
|
6480
6480
|
},
|
|
6481
|
-
PathExpression: function PathExpression(
|
|
6482
|
-
this.addDepth(
|
|
6483
|
-
this.opcode("getContext",
|
|
6484
|
-
var name =
|
|
6481
|
+
PathExpression: function PathExpression(path2) {
|
|
6482
|
+
this.addDepth(path2.depth);
|
|
6483
|
+
this.opcode("getContext", path2.depth);
|
|
6484
|
+
var name = path2.parts[0], scoped = _ast2["default"].helpers.scopedId(path2), blockParamId = !path2.depth && !scoped && this.blockParamIndex(name);
|
|
6485
6485
|
if (blockParamId) {
|
|
6486
|
-
this.opcode("lookupBlockParam", blockParamId,
|
|
6486
|
+
this.opcode("lookupBlockParam", blockParamId, path2.parts);
|
|
6487
6487
|
} else if (!name) {
|
|
6488
6488
|
this.opcode("pushContext");
|
|
6489
|
-
} else if (
|
|
6489
|
+
} else if (path2.data) {
|
|
6490
6490
|
this.options.data = true;
|
|
6491
|
-
this.opcode("lookupData",
|
|
6491
|
+
this.opcode("lookupData", path2.depth, path2.parts, path2.strict);
|
|
6492
6492
|
} else {
|
|
6493
|
-
this.opcode("lookupOnContext",
|
|
6493
|
+
this.opcode("lookupOnContext", path2.parts, path2.falsy, path2.strict, scoped);
|
|
6494
6494
|
}
|
|
6495
6495
|
},
|
|
6496
6496
|
StringLiteral: function StringLiteral(string) {
|
|
@@ -6834,16 +6834,16 @@ var require_util = __commonJS((exports) => {
|
|
|
6834
6834
|
}
|
|
6835
6835
|
exports.urlGenerate = urlGenerate;
|
|
6836
6836
|
function normalize(aPath) {
|
|
6837
|
-
var
|
|
6837
|
+
var path2 = aPath;
|
|
6838
6838
|
var url = urlParse(aPath);
|
|
6839
6839
|
if (url) {
|
|
6840
6840
|
if (!url.path) {
|
|
6841
6841
|
return aPath;
|
|
6842
6842
|
}
|
|
6843
|
-
|
|
6843
|
+
path2 = url.path;
|
|
6844
6844
|
}
|
|
6845
|
-
var isAbsolute = exports.isAbsolute(
|
|
6846
|
-
var parts =
|
|
6845
|
+
var isAbsolute = exports.isAbsolute(path2);
|
|
6846
|
+
var parts = path2.split(/\/+/);
|
|
6847
6847
|
for (var part, up = 0, i = parts.length - 1;i >= 0; i--) {
|
|
6848
6848
|
part = parts[i];
|
|
6849
6849
|
if (part === ".") {
|
|
@@ -6860,15 +6860,15 @@ var require_util = __commonJS((exports) => {
|
|
|
6860
6860
|
}
|
|
6861
6861
|
}
|
|
6862
6862
|
}
|
|
6863
|
-
|
|
6864
|
-
if (
|
|
6865
|
-
|
|
6863
|
+
path2 = parts.join("/");
|
|
6864
|
+
if (path2 === "") {
|
|
6865
|
+
path2 = isAbsolute ? "/" : ".";
|
|
6866
6866
|
}
|
|
6867
6867
|
if (url) {
|
|
6868
|
-
url.path =
|
|
6868
|
+
url.path = path2;
|
|
6869
6869
|
return urlGenerate(url);
|
|
6870
6870
|
}
|
|
6871
|
-
return
|
|
6871
|
+
return path2;
|
|
6872
6872
|
}
|
|
6873
6873
|
exports.normalize = normalize;
|
|
6874
6874
|
function join(aRoot, aPath) {
|
|
@@ -9425,8 +9425,8 @@ var require_printer = __commonJS((exports) => {
|
|
|
9425
9425
|
return this.accept(sexpr.path) + " " + params + hash;
|
|
9426
9426
|
};
|
|
9427
9427
|
PrintVisitor.prototype.PathExpression = function(id) {
|
|
9428
|
-
var
|
|
9429
|
-
return (id.data ? "@" : "") + "PATH:" +
|
|
9428
|
+
var path2 = id.parts.join("/");
|
|
9429
|
+
return (id.data ? "@" : "") + "PATH:" + path2;
|
|
9430
9430
|
};
|
|
9431
9431
|
PrintVisitor.prototype.StringLiteral = function(string) {
|
|
9432
9432
|
return '"' + string.value + '"';
|
|
@@ -9463,8 +9463,8 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
9463
9463
|
handlebars.print = printer.print;
|
|
9464
9464
|
module.exports = handlebars;
|
|
9465
9465
|
function extension(module2, filename) {
|
|
9466
|
-
var
|
|
9467
|
-
var templateString =
|
|
9466
|
+
var fs2 = __require("fs");
|
|
9467
|
+
var templateString = fs2.readFileSync(filename, "utf8");
|
|
9468
9468
|
module2.exports = handlebars.compile(templateString);
|
|
9469
9469
|
}
|
|
9470
9470
|
if (__require.extensions) {
|
|
@@ -9653,19 +9653,19 @@ var require_parse4 = __commonJS((exports, module) => {
|
|
|
9653
9653
|
const wildcards = [];
|
|
9654
9654
|
var wcLen = 0;
|
|
9655
9655
|
const secret = paths.reduce(function(o, strPath, ix) {
|
|
9656
|
-
var
|
|
9656
|
+
var path2 = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
|
|
9657
9657
|
const leadingBracket = strPath[0] === "[";
|
|
9658
|
-
|
|
9658
|
+
path2 = path2.map((p) => {
|
|
9659
9659
|
if (p[0] === "[")
|
|
9660
9660
|
return p.substr(1, p.length - 2);
|
|
9661
9661
|
else
|
|
9662
9662
|
return p;
|
|
9663
9663
|
});
|
|
9664
|
-
const star =
|
|
9664
|
+
const star = path2.indexOf("*");
|
|
9665
9665
|
if (star > -1) {
|
|
9666
|
-
const before =
|
|
9666
|
+
const before = path2.slice(0, star);
|
|
9667
9667
|
const beforeStr = before.join(".");
|
|
9668
|
-
const after =
|
|
9668
|
+
const after = path2.slice(star + 1, path2.length);
|
|
9669
9669
|
const nested = after.length > 0;
|
|
9670
9670
|
wcLen++;
|
|
9671
9671
|
wildcards.push({
|
|
@@ -9676,7 +9676,7 @@ var require_parse4 = __commonJS((exports, module) => {
|
|
|
9676
9676
|
});
|
|
9677
9677
|
} else {
|
|
9678
9678
|
o[strPath] = {
|
|
9679
|
-
path,
|
|
9679
|
+
path: path2,
|
|
9680
9680
|
val: undefined,
|
|
9681
9681
|
precensored: false,
|
|
9682
9682
|
circle: "",
|
|
@@ -9719,13 +9719,13 @@ var require_redactor = __commonJS((exports, module) => {
|
|
|
9719
9719
|
return redact;
|
|
9720
9720
|
}
|
|
9721
9721
|
function redactTmpl(secret, isCensorFct, censorFctTakesPath) {
|
|
9722
|
-
return Object.keys(secret).map((
|
|
9723
|
-
const { escPath, leadingBracket, path: arrPath } = secret[
|
|
9722
|
+
return Object.keys(secret).map((path2) => {
|
|
9723
|
+
const { escPath, leadingBracket, path: arrPath } = secret[path2];
|
|
9724
9724
|
const skip = leadingBracket ? 1 : 0;
|
|
9725
9725
|
const delim = leadingBracket ? "" : ".";
|
|
9726
9726
|
const hops = [];
|
|
9727
9727
|
var match;
|
|
9728
|
-
while ((match = rx.exec(
|
|
9728
|
+
while ((match = rx.exec(path2)) !== null) {
|
|
9729
9729
|
const [, ix] = match;
|
|
9730
9730
|
const { index, input } = match;
|
|
9731
9731
|
if (index > skip)
|
|
@@ -9733,9 +9733,9 @@ var require_redactor = __commonJS((exports, module) => {
|
|
|
9733
9733
|
}
|
|
9734
9734
|
var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
|
|
9735
9735
|
if (existence.length === 0)
|
|
9736
|
-
existence += `o${delim}${
|
|
9736
|
+
existence += `o${delim}${path2} != null`;
|
|
9737
9737
|
else
|
|
9738
|
-
existence += ` && o${delim}${
|
|
9738
|
+
existence += ` && o${delim}${path2} != null`;
|
|
9739
9739
|
const circularDetection = `
|
|
9740
9740
|
switch (true) {
|
|
9741
9741
|
${hops.reverse().map((p) => `
|
|
@@ -9749,12 +9749,12 @@ var require_redactor = __commonJS((exports, module) => {
|
|
|
9749
9749
|
const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`;
|
|
9750
9750
|
return `
|
|
9751
9751
|
if (${existence}) {
|
|
9752
|
-
const val = o${delim}${
|
|
9752
|
+
const val = o${delim}${path2}
|
|
9753
9753
|
if (val === censor) {
|
|
9754
9754
|
secret[${escPath}].precensored = true
|
|
9755
9755
|
} else {
|
|
9756
9756
|
secret[${escPath}].val = val
|
|
9757
|
-
o${delim}${
|
|
9757
|
+
o${delim}${path2} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
|
|
9758
9758
|
${circularDetection}
|
|
9759
9759
|
}
|
|
9760
9760
|
}
|
|
@@ -9805,14 +9805,14 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9805
9805
|
target[k] = values[i];
|
|
9806
9806
|
}
|
|
9807
9807
|
}
|
|
9808
|
-
function groupRedact(o,
|
|
9809
|
-
const target = get(o,
|
|
9808
|
+
function groupRedact(o, path2, censor, isCensorFct, censorFctTakesPath) {
|
|
9809
|
+
const target = get(o, path2);
|
|
9810
9810
|
if (target == null || typeof target === "string")
|
|
9811
9811
|
return { keys: null, values: null, target, flat: true };
|
|
9812
9812
|
const keys2 = Object.keys(target);
|
|
9813
9813
|
const keysLength = keys2.length;
|
|
9814
|
-
const pathLength =
|
|
9815
|
-
const pathWithKey = censorFctTakesPath ? [...
|
|
9814
|
+
const pathLength = path2.length;
|
|
9815
|
+
const pathWithKey = censorFctTakesPath ? [...path2] : undefined;
|
|
9816
9816
|
const values = new Array(keysLength);
|
|
9817
9817
|
for (var i = 0;i < keysLength; i++) {
|
|
9818
9818
|
const key = keys2[i];
|
|
@@ -9830,30 +9830,30 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9830
9830
|
}
|
|
9831
9831
|
function nestedRestore(instructions) {
|
|
9832
9832
|
for (let i = 0;i < instructions.length; i++) {
|
|
9833
|
-
const { target, path, value } = instructions[i];
|
|
9833
|
+
const { target, path: path2, value } = instructions[i];
|
|
9834
9834
|
let current = target;
|
|
9835
|
-
for (let i2 =
|
|
9836
|
-
current = current[
|
|
9835
|
+
for (let i2 = path2.length - 1;i2 > 0; i2--) {
|
|
9836
|
+
current = current[path2[i2]];
|
|
9837
9837
|
}
|
|
9838
|
-
current[
|
|
9838
|
+
current[path2[0]] = value;
|
|
9839
9839
|
}
|
|
9840
9840
|
}
|
|
9841
|
-
function nestedRedact(store, o,
|
|
9842
|
-
const target = get(o,
|
|
9841
|
+
function nestedRedact(store, o, path2, ns, censor, isCensorFct, censorFctTakesPath) {
|
|
9842
|
+
const target = get(o, path2);
|
|
9843
9843
|
if (target == null)
|
|
9844
9844
|
return;
|
|
9845
9845
|
const keys2 = Object.keys(target);
|
|
9846
9846
|
const keysLength = keys2.length;
|
|
9847
9847
|
for (var i = 0;i < keysLength; i++) {
|
|
9848
9848
|
const key = keys2[i];
|
|
9849
|
-
specialSet(store, target, key,
|
|
9849
|
+
specialSet(store, target, key, path2, ns, censor, isCensorFct, censorFctTakesPath);
|
|
9850
9850
|
}
|
|
9851
9851
|
return store;
|
|
9852
9852
|
}
|
|
9853
9853
|
function has(obj, prop) {
|
|
9854
9854
|
return obj !== undefined && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
|
|
9855
9855
|
}
|
|
9856
|
-
function specialSet(store, o, k,
|
|
9856
|
+
function specialSet(store, o, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath) {
|
|
9857
9857
|
const afterPathLen = afterPath.length;
|
|
9858
9858
|
const lastPathIndex = afterPathLen - 1;
|
|
9859
9859
|
const originalKey = k;
|
|
@@ -9897,7 +9897,7 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9897
9897
|
if (consecutive) {
|
|
9898
9898
|
redactPathCurrent = node(redactPathCurrent, wck, depth);
|
|
9899
9899
|
level = i;
|
|
9900
|
-
ov = iterateNthLevel(wcov, level - 1, k,
|
|
9900
|
+
ov = iterateNthLevel(wcov, level - 1, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1);
|
|
9901
9901
|
} else {
|
|
9902
9902
|
if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
|
|
9903
9903
|
if (kIsWc) {
|
|
@@ -9905,7 +9905,7 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9905
9905
|
} else {
|
|
9906
9906
|
ov = wcov[k];
|
|
9907
9907
|
}
|
|
9908
|
-
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...
|
|
9908
|
+
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path2, originalKey, ...afterPath]) : censor(ov) : censor;
|
|
9909
9909
|
if (kIsWc) {
|
|
9910
9910
|
const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
|
|
9911
9911
|
store.push(rv);
|
|
@@ -9927,7 +9927,7 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9927
9927
|
} else {
|
|
9928
9928
|
ov = n[k];
|
|
9929
9929
|
redactPathCurrent = node(redactPathCurrent, k, depth);
|
|
9930
|
-
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...
|
|
9930
|
+
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path2, originalKey, ...afterPath]) : censor(ov) : censor;
|
|
9931
9931
|
if (has(n, k) && nv === ov || nv === undefined && censor !== undefined) {} else {
|
|
9932
9932
|
const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
|
|
9933
9933
|
store.push(rv);
|
|
@@ -9949,7 +9949,7 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9949
9949
|
}
|
|
9950
9950
|
return n;
|
|
9951
9951
|
}
|
|
9952
|
-
function iterateNthLevel(wcov, level, k,
|
|
9952
|
+
function iterateNthLevel(wcov, level, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
|
|
9953
9953
|
if (level === 0) {
|
|
9954
9954
|
if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
|
|
9955
9955
|
if (kIsWc) {
|
|
@@ -9957,7 +9957,7 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9957
9957
|
} else {
|
|
9958
9958
|
ov = wcov[k];
|
|
9959
9959
|
}
|
|
9960
|
-
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...
|
|
9960
|
+
nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path2, originalKey, ...afterPath]) : censor(ov) : censor;
|
|
9961
9961
|
if (kIsWc) {
|
|
9962
9962
|
const rv = restoreInstr(redactPathCurrent, ov, parent);
|
|
9963
9963
|
store.push(rv);
|
|
@@ -9974,7 +9974,7 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9974
9974
|
for (const key in wcov) {
|
|
9975
9975
|
if (typeof wcov[key] === "object") {
|
|
9976
9976
|
redactPathCurrent = node(redactPathCurrent, key, depth);
|
|
9977
|
-
iterateNthLevel(wcov[key], level - 1, k,
|
|
9977
|
+
iterateNthLevel(wcov[key], level - 1, k, path2, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
|
|
9978
9978
|
}
|
|
9979
9979
|
}
|
|
9980
9980
|
}
|
|
@@ -9996,12 +9996,12 @@ var require_modifiers = __commonJS((exports, module) => {
|
|
|
9996
9996
|
}
|
|
9997
9997
|
function restoreInstr(node2, value, target) {
|
|
9998
9998
|
let current = node2;
|
|
9999
|
-
const
|
|
9999
|
+
const path2 = [];
|
|
10000
10000
|
do {
|
|
10001
|
-
|
|
10001
|
+
path2.push(current.key);
|
|
10002
10002
|
current = current.parent;
|
|
10003
10003
|
} while (current.parent != null);
|
|
10004
|
-
return { path, value, target };
|
|
10004
|
+
return { path: path2, value, target };
|
|
10005
10005
|
}
|
|
10006
10006
|
});
|
|
10007
10007
|
|
|
@@ -10025,10 +10025,10 @@ var require_restorer = __commonJS((exports, module) => {
|
|
|
10025
10025
|
};
|
|
10026
10026
|
}
|
|
10027
10027
|
function resetTmpl(secret, paths) {
|
|
10028
|
-
return paths.map((
|
|
10029
|
-
const { circle, escPath, leadingBracket } = secret[
|
|
10028
|
+
return paths.map((path2) => {
|
|
10029
|
+
const { circle, escPath, leadingBracket } = secret[path2];
|
|
10030
10030
|
const delim = leadingBracket ? "" : ".";
|
|
10031
|
-
const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${
|
|
10031
|
+
const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path2} = secret[${escPath}].val`;
|
|
10032
10032
|
const clear = `secret[${escPath}].val = undefined`;
|
|
10033
10033
|
return `
|
|
10034
10034
|
if (secret[${escPath}].val !== undefined) {
|
|
@@ -19932,8 +19932,8 @@ var require_reporter = __commonJS((exports) => {
|
|
|
19932
19932
|
errors: state.errors
|
|
19933
19933
|
};
|
|
19934
19934
|
};
|
|
19935
|
-
function ReporterError(
|
|
19936
|
-
this.path =
|
|
19935
|
+
function ReporterError(path2, msg) {
|
|
19936
|
+
this.path = path2;
|
|
19937
19937
|
this.rethrow(msg);
|
|
19938
19938
|
}
|
|
19939
19939
|
inherits(ReporterError, Error);
|
|
@@ -21746,7 +21746,7 @@ var require_parse_asn1 = __commonJS((exports, module) => {
|
|
|
21746
21746
|
|
|
21747
21747
|
// ../../node_modules/public-encrypt/mgf.js
|
|
21748
21748
|
var require_mgf = __commonJS((exports, module) => {
|
|
21749
|
-
var
|
|
21749
|
+
var createHash2 = require_create_hash();
|
|
21750
21750
|
var Buffer2 = require_safe_buffer().Buffer;
|
|
21751
21751
|
module.exports = function(seed, len) {
|
|
21752
21752
|
var t = Buffer2.alloc(0);
|
|
@@ -21754,7 +21754,7 @@ var require_mgf = __commonJS((exports, module) => {
|
|
|
21754
21754
|
var c;
|
|
21755
21755
|
while (t.length < len) {
|
|
21756
21756
|
c = i2ops(i++);
|
|
21757
|
-
t = Buffer2.concat([t,
|
|
21757
|
+
t = Buffer2.concat([t, createHash2("sha1").update(seed).update(c).digest()]);
|
|
21758
21758
|
}
|
|
21759
21759
|
return t.slice(0, len);
|
|
21760
21760
|
};
|
|
@@ -24739,7 +24739,7 @@ var require_browserify_rsa = __commonJS((exports, module) => {
|
|
|
24739
24739
|
var require_publicEncrypt = __commonJS((exports, module) => {
|
|
24740
24740
|
var parseKeys = require_parse_asn1();
|
|
24741
24741
|
var randomBytes2 = require_randombytes();
|
|
24742
|
-
var
|
|
24742
|
+
var createHash2 = require_create_hash();
|
|
24743
24743
|
var mgf = require_mgf();
|
|
24744
24744
|
var xor = require_xor();
|
|
24745
24745
|
var BN = require_bn();
|
|
@@ -24778,7 +24778,7 @@ var require_publicEncrypt = __commonJS((exports, module) => {
|
|
|
24778
24778
|
function oaep(key, msg) {
|
|
24779
24779
|
var k = key.modulus.byteLength();
|
|
24780
24780
|
var mLen = msg.length;
|
|
24781
|
-
var iHash =
|
|
24781
|
+
var iHash = createHash2("sha1").update(Buffer2.alloc(0)).digest();
|
|
24782
24782
|
var hLen = iHash.length;
|
|
24783
24783
|
var hLen2 = 2 * hLen;
|
|
24784
24784
|
if (mLen > k - hLen2 - 2) {
|
|
@@ -24832,7 +24832,7 @@ var require_privateDecrypt = __commonJS((exports, module) => {
|
|
|
24832
24832
|
var xor = require_xor();
|
|
24833
24833
|
var BN = require_bn();
|
|
24834
24834
|
var crt = require_browserify_rsa();
|
|
24835
|
-
var
|
|
24835
|
+
var createHash2 = require_create_hash();
|
|
24836
24836
|
var withPublic = require_withPublic();
|
|
24837
24837
|
var Buffer2 = require_safe_buffer().Buffer;
|
|
24838
24838
|
module.exports = function privateDecrypt(privateKey, enc, reverse) {
|
|
@@ -24869,7 +24869,7 @@ var require_privateDecrypt = __commonJS((exports, module) => {
|
|
|
24869
24869
|
};
|
|
24870
24870
|
function oaep(key, msg) {
|
|
24871
24871
|
var k = key.modulus.byteLength();
|
|
24872
|
-
var iHash =
|
|
24872
|
+
var iHash = createHash2("sha1").update(Buffer2.alloc(0)).digest();
|
|
24873
24873
|
var hLen = iHash.length;
|
|
24874
24874
|
if (msg[0] !== 0) {
|
|
24875
24875
|
throw new Error("decryption error");
|
|
@@ -27980,6 +27980,9 @@ var _getFetchImplementation = (debug) => {
|
|
|
27980
27980
|
var getDefaultProjectName = () => {
|
|
27981
27981
|
return getLangSmithEnvironmentVariable("PROJECT") ?? getEnvironmentVariable2("LANGCHAIN_SESSION") ?? "default";
|
|
27982
27982
|
};
|
|
27983
|
+
// ../../node_modules/langsmith/dist/utils/_uuid.js
|
|
27984
|
+
import { createHash } from "crypto";
|
|
27985
|
+
|
|
27983
27986
|
// ../../node_modules/langsmith/dist/utils/warn.js
|
|
27984
27987
|
var warnedMessages = {};
|
|
27985
27988
|
function warnOnce(message) {
|
|
@@ -28002,8 +28005,46 @@ function uuid7FromTime(timestamp) {
|
|
|
28002
28005
|
const msecs = typeof timestamp === "string" ? Date.parse(timestamp) : timestamp;
|
|
28003
28006
|
return v72({ msecs, seq: 0 });
|
|
28004
28007
|
}
|
|
28008
|
+
function getUuidVersion(uuidStr) {
|
|
28009
|
+
if (!UUID_REGEX.test(uuidStr)) {
|
|
28010
|
+
return null;
|
|
28011
|
+
}
|
|
28012
|
+
const versionChar = uuidStr[14];
|
|
28013
|
+
return parseInt(versionChar, 16);
|
|
28014
|
+
}
|
|
28015
|
+
function uuidToBytes(uuidStr) {
|
|
28016
|
+
const hex = uuidStr.replace(/-/g, "");
|
|
28017
|
+
return Buffer.from(hex, "hex");
|
|
28018
|
+
}
|
|
28019
|
+
function bytesToUuid(bytes) {
|
|
28020
|
+
const hex = bytes.toString("hex");
|
|
28021
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
28022
|
+
}
|
|
28023
|
+
function uuid7Deterministic(originalId, key) {
|
|
28024
|
+
const hashInput = `${originalId}:${key}`;
|
|
28025
|
+
const h = createHash("sha256").update(hashInput).digest();
|
|
28026
|
+
const b = Buffer.alloc(16);
|
|
28027
|
+
const version3 = getUuidVersion(originalId);
|
|
28028
|
+
if (version3 === 7) {
|
|
28029
|
+
const originalBytes = uuidToBytes(originalId);
|
|
28030
|
+
originalBytes.copy(b, 0, 0, 6);
|
|
28031
|
+
} else {
|
|
28032
|
+
const msecs = Date.now();
|
|
28033
|
+
b[0] = msecs / 1099511627776 & 255;
|
|
28034
|
+
b[1] = msecs / 4294967296 & 255;
|
|
28035
|
+
b[2] = msecs / 16777216 & 255;
|
|
28036
|
+
b[3] = msecs / 65536 & 255;
|
|
28037
|
+
b[4] = msecs / 256 & 255;
|
|
28038
|
+
b[5] = msecs & 255;
|
|
28039
|
+
}
|
|
28040
|
+
b[6] = 112 | h[0] & 15;
|
|
28041
|
+
b[7] = h[1];
|
|
28042
|
+
b[8] = 128 | h[2] & 63;
|
|
28043
|
+
h.copy(b, 9, 3, 10);
|
|
28044
|
+
return bytesToUuid(b);
|
|
28045
|
+
}
|
|
28005
28046
|
// ../../node_modules/langsmith/dist/index.js
|
|
28006
|
-
var __version__ = "0.4.
|
|
28047
|
+
var __version__ = "0.4.3";
|
|
28007
28048
|
|
|
28008
28049
|
// ../../node_modules/langsmith/dist/utils/env.js
|
|
28009
28050
|
var globalEnv;
|
|
@@ -29041,6 +29082,220 @@ function isConflictingEndpointsError(err) {
|
|
|
29041
29082
|
return typeof err === "object" && err !== null && err.code === ERR_CONFLICTING_ENDPOINTS;
|
|
29042
29083
|
}
|
|
29043
29084
|
|
|
29085
|
+
// ../../node_modules/langsmith/dist/utils/prompts_cache.js
|
|
29086
|
+
import * as fs from "node:fs";
|
|
29087
|
+
import * as path from "node:path";
|
|
29088
|
+
function isStale(entry, ttlSeconds) {
|
|
29089
|
+
if (ttlSeconds === null) {
|
|
29090
|
+
return false;
|
|
29091
|
+
}
|
|
29092
|
+
const ageMs = Date.now() - entry.createdAt;
|
|
29093
|
+
return ageMs > ttlSeconds * 1000;
|
|
29094
|
+
}
|
|
29095
|
+
|
|
29096
|
+
class PromptCache {
|
|
29097
|
+
constructor(config = {}) {
|
|
29098
|
+
Object.defineProperty(this, "cache", {
|
|
29099
|
+
enumerable: true,
|
|
29100
|
+
configurable: true,
|
|
29101
|
+
writable: true,
|
|
29102
|
+
value: new Map
|
|
29103
|
+
});
|
|
29104
|
+
Object.defineProperty(this, "maxSize", {
|
|
29105
|
+
enumerable: true,
|
|
29106
|
+
configurable: true,
|
|
29107
|
+
writable: true,
|
|
29108
|
+
value: undefined
|
|
29109
|
+
});
|
|
29110
|
+
Object.defineProperty(this, "ttlSeconds", {
|
|
29111
|
+
enumerable: true,
|
|
29112
|
+
configurable: true,
|
|
29113
|
+
writable: true,
|
|
29114
|
+
value: undefined
|
|
29115
|
+
});
|
|
29116
|
+
Object.defineProperty(this, "refreshIntervalSeconds", {
|
|
29117
|
+
enumerable: true,
|
|
29118
|
+
configurable: true,
|
|
29119
|
+
writable: true,
|
|
29120
|
+
value: undefined
|
|
29121
|
+
});
|
|
29122
|
+
Object.defineProperty(this, "fetchFunc", {
|
|
29123
|
+
enumerable: true,
|
|
29124
|
+
configurable: true,
|
|
29125
|
+
writable: true,
|
|
29126
|
+
value: undefined
|
|
29127
|
+
});
|
|
29128
|
+
Object.defineProperty(this, "refreshTimer", {
|
|
29129
|
+
enumerable: true,
|
|
29130
|
+
configurable: true,
|
|
29131
|
+
writable: true,
|
|
29132
|
+
value: undefined
|
|
29133
|
+
});
|
|
29134
|
+
Object.defineProperty(this, "_metrics", {
|
|
29135
|
+
enumerable: true,
|
|
29136
|
+
configurable: true,
|
|
29137
|
+
writable: true,
|
|
29138
|
+
value: {
|
|
29139
|
+
hits: 0,
|
|
29140
|
+
misses: 0,
|
|
29141
|
+
refreshes: 0,
|
|
29142
|
+
refreshErrors: 0
|
|
29143
|
+
}
|
|
29144
|
+
});
|
|
29145
|
+
this.maxSize = config.maxSize ?? 100;
|
|
29146
|
+
this.ttlSeconds = config.ttlSeconds ?? 3600;
|
|
29147
|
+
this.refreshIntervalSeconds = config.refreshIntervalSeconds ?? 60;
|
|
29148
|
+
this.fetchFunc = config.fetchFunc;
|
|
29149
|
+
if (this.fetchFunc && this.ttlSeconds !== null) {
|
|
29150
|
+
this.startRefreshLoop();
|
|
29151
|
+
}
|
|
29152
|
+
}
|
|
29153
|
+
get metrics() {
|
|
29154
|
+
return { ...this._metrics };
|
|
29155
|
+
}
|
|
29156
|
+
get totalRequests() {
|
|
29157
|
+
return this._metrics.hits + this._metrics.misses;
|
|
29158
|
+
}
|
|
29159
|
+
get hitRate() {
|
|
29160
|
+
const total = this.totalRequests;
|
|
29161
|
+
return total > 0 ? this._metrics.hits / total : 0;
|
|
29162
|
+
}
|
|
29163
|
+
resetMetrics() {
|
|
29164
|
+
this._metrics = {
|
|
29165
|
+
hits: 0,
|
|
29166
|
+
misses: 0,
|
|
29167
|
+
refreshes: 0,
|
|
29168
|
+
refreshErrors: 0
|
|
29169
|
+
};
|
|
29170
|
+
}
|
|
29171
|
+
get(key) {
|
|
29172
|
+
const entry = this.cache.get(key);
|
|
29173
|
+
if (!entry) {
|
|
29174
|
+
this._metrics.misses += 1;
|
|
29175
|
+
return;
|
|
29176
|
+
}
|
|
29177
|
+
this.cache.delete(key);
|
|
29178
|
+
this.cache.set(key, entry);
|
|
29179
|
+
this._metrics.hits += 1;
|
|
29180
|
+
return entry.value;
|
|
29181
|
+
}
|
|
29182
|
+
set(key, value) {
|
|
29183
|
+
if (!this.cache.has(key) && this.cache.size >= this.maxSize) {
|
|
29184
|
+
const oldestKey = this.cache.keys().next().value;
|
|
29185
|
+
if (oldestKey !== undefined) {
|
|
29186
|
+
this.cache.delete(oldestKey);
|
|
29187
|
+
}
|
|
29188
|
+
}
|
|
29189
|
+
const entry = {
|
|
29190
|
+
value,
|
|
29191
|
+
createdAt: Date.now()
|
|
29192
|
+
};
|
|
29193
|
+
this.cache.delete(key);
|
|
29194
|
+
this.cache.set(key, entry);
|
|
29195
|
+
}
|
|
29196
|
+
invalidate(key) {
|
|
29197
|
+
this.cache.delete(key);
|
|
29198
|
+
}
|
|
29199
|
+
clear() {
|
|
29200
|
+
this.cache.clear();
|
|
29201
|
+
}
|
|
29202
|
+
get size() {
|
|
29203
|
+
return this.cache.size;
|
|
29204
|
+
}
|
|
29205
|
+
stop() {
|
|
29206
|
+
if (this.refreshTimer) {
|
|
29207
|
+
clearInterval(this.refreshTimer);
|
|
29208
|
+
this.refreshTimer = undefined;
|
|
29209
|
+
}
|
|
29210
|
+
}
|
|
29211
|
+
dump(filePath) {
|
|
29212
|
+
const dir = path.dirname(filePath);
|
|
29213
|
+
if (!fs.existsSync(dir)) {
|
|
29214
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
29215
|
+
}
|
|
29216
|
+
const entries = {};
|
|
29217
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
29218
|
+
entries[key] = entry.value;
|
|
29219
|
+
}
|
|
29220
|
+
const data = { entries };
|
|
29221
|
+
const tempPath = `${filePath}.tmp`;
|
|
29222
|
+
try {
|
|
29223
|
+
fs.writeFileSync(tempPath, JSON.stringify(data, null, 2));
|
|
29224
|
+
fs.renameSync(tempPath, filePath);
|
|
29225
|
+
} catch (e) {
|
|
29226
|
+
if (fs.existsSync(tempPath)) {
|
|
29227
|
+
fs.unlinkSync(tempPath);
|
|
29228
|
+
}
|
|
29229
|
+
throw e;
|
|
29230
|
+
}
|
|
29231
|
+
}
|
|
29232
|
+
load(filePath) {
|
|
29233
|
+
if (!fs.existsSync(filePath)) {
|
|
29234
|
+
return 0;
|
|
29235
|
+
}
|
|
29236
|
+
let data;
|
|
29237
|
+
try {
|
|
29238
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
29239
|
+
data = JSON.parse(content);
|
|
29240
|
+
} catch {
|
|
29241
|
+
return 0;
|
|
29242
|
+
}
|
|
29243
|
+
const entries = data.entries ?? {};
|
|
29244
|
+
let loaded = 0;
|
|
29245
|
+
const now = Date.now();
|
|
29246
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
29247
|
+
if (this.cache.size >= this.maxSize) {
|
|
29248
|
+
break;
|
|
29249
|
+
}
|
|
29250
|
+
const entry = {
|
|
29251
|
+
value,
|
|
29252
|
+
createdAt: now
|
|
29253
|
+
};
|
|
29254
|
+
this.cache.set(key, entry);
|
|
29255
|
+
loaded += 1;
|
|
29256
|
+
}
|
|
29257
|
+
return loaded;
|
|
29258
|
+
}
|
|
29259
|
+
startRefreshLoop() {
|
|
29260
|
+
this.refreshTimer = setInterval(() => {
|
|
29261
|
+
this.refreshStaleEntries().catch((e) => {
|
|
29262
|
+
console.warn("Unexpected error in cache refresh loop:", e);
|
|
29263
|
+
});
|
|
29264
|
+
}, this.refreshIntervalSeconds * 1000);
|
|
29265
|
+
if (this.refreshTimer.unref) {
|
|
29266
|
+
this.refreshTimer.unref();
|
|
29267
|
+
}
|
|
29268
|
+
}
|
|
29269
|
+
getStaleKeys() {
|
|
29270
|
+
const staleKeys = [];
|
|
29271
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
29272
|
+
if (isStale(entry, this.ttlSeconds)) {
|
|
29273
|
+
staleKeys.push(key);
|
|
29274
|
+
}
|
|
29275
|
+
}
|
|
29276
|
+
return staleKeys;
|
|
29277
|
+
}
|
|
29278
|
+
async refreshStaleEntries() {
|
|
29279
|
+
if (!this.fetchFunc) {
|
|
29280
|
+
return;
|
|
29281
|
+
}
|
|
29282
|
+
const staleKeys = this.getStaleKeys();
|
|
29283
|
+
if (staleKeys.length === 0) {
|
|
29284
|
+
return;
|
|
29285
|
+
}
|
|
29286
|
+
for (const key of staleKeys) {
|
|
29287
|
+
try {
|
|
29288
|
+
const newValue = await this.fetchFunc(key);
|
|
29289
|
+
this.set(key, newValue);
|
|
29290
|
+
this._metrics.refreshes += 1;
|
|
29291
|
+
} catch (e) {
|
|
29292
|
+
this._metrics.refreshErrors += 1;
|
|
29293
|
+
console.warn(`Failed to refresh cache entry ${key}:`, e);
|
|
29294
|
+
}
|
|
29295
|
+
}
|
|
29296
|
+
}
|
|
29297
|
+
}
|
|
29298
|
+
|
|
29044
29299
|
// ../../node_modules/langsmith/dist/utils/fast-safe-stringify/index.js
|
|
29045
29300
|
var LIMIT_REPLACE_NODE = "[...]";
|
|
29046
29301
|
var CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
|
|
@@ -29531,6 +29786,12 @@ class Client {
|
|
|
29531
29786
|
writable: true,
|
|
29532
29787
|
value: undefined
|
|
29533
29788
|
});
|
|
29789
|
+
Object.defineProperty(this, "_promptCache", {
|
|
29790
|
+
enumerable: true,
|
|
29791
|
+
configurable: true,
|
|
29792
|
+
writable: true,
|
|
29793
|
+
value: undefined
|
|
29794
|
+
});
|
|
29534
29795
|
Object.defineProperty(this, "multipartStreamingDisabled", {
|
|
29535
29796
|
enumerable: true,
|
|
29536
29797
|
configurable: true,
|
|
@@ -29596,6 +29857,19 @@ class Client {
|
|
|
29596
29857
|
this.langSmithToOTELTranslator = new LangSmithToOTELTranslator;
|
|
29597
29858
|
}
|
|
29598
29859
|
this.cachedLSEnvVarsForMetadata = getLangSmithEnvVarsMetadata();
|
|
29860
|
+
const cacheEnabled = config.promptCacheEnabled ?? getLangSmithEnvironmentVariable("PROMPT_CACHE_ENABLED") === "true";
|
|
29861
|
+
if (cacheEnabled) {
|
|
29862
|
+
this._promptCache = new PromptCache({
|
|
29863
|
+
maxSize: config.promptCacheMaxSize ?? parseInt(getLangSmithEnvironmentVariable("PROMPT_CACHE_MAX_SIZE") ?? "100", 10),
|
|
29864
|
+
ttlSeconds: config.promptCacheTtlSeconds ?? parseFloat(getLangSmithEnvironmentVariable("PROMPT_CACHE_TTL_SECONDS") ?? "3600"),
|
|
29865
|
+
refreshIntervalSeconds: config.promptCacheRefreshIntervalSeconds ?? parseFloat(getLangSmithEnvironmentVariable("PROMPT_CACHE_REFRESH_INTERVAL_SECONDS") ?? "60"),
|
|
29866
|
+
fetchFunc: this._makeFetchPromptFunc()
|
|
29867
|
+
});
|
|
29868
|
+
const cachePath = config.promptCachePath ?? getLangSmithEnvironmentVariable("PROMPT_CACHE_PATH");
|
|
29869
|
+
if (cachePath) {
|
|
29870
|
+
this._promptCache.load(cachePath);
|
|
29871
|
+
}
|
|
29872
|
+
}
|
|
29599
29873
|
}
|
|
29600
29874
|
static getDefaultClientConfig() {
|
|
29601
29875
|
const apiKey = getLangSmithEnvironmentVariable("API_KEY");
|
|
@@ -29648,9 +29922,9 @@ class Client {
|
|
|
29648
29922
|
}
|
|
29649
29923
|
return headers;
|
|
29650
29924
|
}
|
|
29651
|
-
_getPlatformEndpointPath(
|
|
29925
|
+
_getPlatformEndpointPath(path2) {
|
|
29652
29926
|
const needsV1Prefix = this.apiUrl.slice(-3) !== "/v1" && this.apiUrl.slice(-4) !== "/v1/";
|
|
29653
|
-
return needsV1Prefix ? `/v1/platform/${
|
|
29927
|
+
return needsV1Prefix ? `/v1/platform/${path2}` : `/platform/${path2}`;
|
|
29654
29928
|
}
|
|
29655
29929
|
async processInputs(inputs) {
|
|
29656
29930
|
if (this.hideInputs === false) {
|
|
@@ -29686,9 +29960,9 @@ class Client {
|
|
|
29686
29960
|
}
|
|
29687
29961
|
return runParams;
|
|
29688
29962
|
}
|
|
29689
|
-
async _getResponse(
|
|
29963
|
+
async _getResponse(path2, queryParams) {
|
|
29690
29964
|
const paramsString = queryParams?.toString() ?? "";
|
|
29691
|
-
const url = `${this.apiUrl}${
|
|
29965
|
+
const url = `${this.apiUrl}${path2}?${paramsString}`;
|
|
29692
29966
|
const response = await this.caller.call(async () => {
|
|
29693
29967
|
const res = await this._fetch(url, {
|
|
29694
29968
|
method: "GET",
|
|
@@ -29696,22 +29970,22 @@ class Client {
|
|
|
29696
29970
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
29697
29971
|
...this.fetchOptions
|
|
29698
29972
|
});
|
|
29699
|
-
await raiseForStatus(res, `fetch ${
|
|
29973
|
+
await raiseForStatus(res, `fetch ${path2}`);
|
|
29700
29974
|
return res;
|
|
29701
29975
|
});
|
|
29702
29976
|
return response;
|
|
29703
29977
|
}
|
|
29704
|
-
async _get(
|
|
29705
|
-
const response = await this._getResponse(
|
|
29978
|
+
async _get(path2, queryParams) {
|
|
29979
|
+
const response = await this._getResponse(path2, queryParams);
|
|
29706
29980
|
return response.json();
|
|
29707
29981
|
}
|
|
29708
|
-
async* _getPaginated(
|
|
29982
|
+
async* _getPaginated(path2, queryParams = new URLSearchParams, transform) {
|
|
29709
29983
|
let offset = Number(queryParams.get("offset")) || 0;
|
|
29710
29984
|
const limit = Number(queryParams.get("limit")) || 100;
|
|
29711
29985
|
while (true) {
|
|
29712
29986
|
queryParams.set("offset", String(offset));
|
|
29713
29987
|
queryParams.set("limit", String(limit));
|
|
29714
|
-
const url = `${this.apiUrl}${
|
|
29988
|
+
const url = `${this.apiUrl}${path2}?${queryParams}`;
|
|
29715
29989
|
const response = await this.caller.call(async () => {
|
|
29716
29990
|
const res = await this._fetch(url, {
|
|
29717
29991
|
method: "GET",
|
|
@@ -29719,7 +29993,7 @@ class Client {
|
|
|
29719
29993
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
29720
29994
|
...this.fetchOptions
|
|
29721
29995
|
});
|
|
29722
|
-
await raiseForStatus(res, `fetch ${
|
|
29996
|
+
await raiseForStatus(res, `fetch ${path2}`);
|
|
29723
29997
|
return res;
|
|
29724
29998
|
});
|
|
29725
29999
|
const items = transform ? transform(await response.json()) : await response.json();
|
|
@@ -29733,19 +30007,19 @@ class Client {
|
|
|
29733
30007
|
offset += items.length;
|
|
29734
30008
|
}
|
|
29735
30009
|
}
|
|
29736
|
-
async* _getCursorPaginatedList(
|
|
30010
|
+
async* _getCursorPaginatedList(path2, body = null, requestMethod = "POST", dataKey = "runs") {
|
|
29737
30011
|
const bodyParams = body ? { ...body } : {};
|
|
29738
30012
|
while (true) {
|
|
29739
30013
|
const body2 = JSON.stringify(bodyParams);
|
|
29740
30014
|
const response = await this.caller.call(async () => {
|
|
29741
|
-
const res = await this._fetch(`${this.apiUrl}${
|
|
30015
|
+
const res = await this._fetch(`${this.apiUrl}${path2}`, {
|
|
29742
30016
|
method: requestMethod,
|
|
29743
30017
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
29744
30018
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
29745
30019
|
...this.fetchOptions,
|
|
29746
30020
|
body: body2
|
|
29747
30021
|
});
|
|
29748
|
-
await raiseForStatus(res, `fetch ${
|
|
30022
|
+
await raiseForStatus(res, `fetch ${path2}`);
|
|
29749
30023
|
return res;
|
|
29750
30024
|
});
|
|
29751
30025
|
const responseBody = await response.json();
|
|
@@ -30581,8 +30855,8 @@ Context: ${context}`);
|
|
|
30581
30855
|
limit: Number(limit) || 100
|
|
30582
30856
|
};
|
|
30583
30857
|
let currentOffset = Number(offset) || 0;
|
|
30584
|
-
const
|
|
30585
|
-
const url = `${this.apiUrl}${
|
|
30858
|
+
const path2 = "/runs/group";
|
|
30859
|
+
const url = `${this.apiUrl}${path2}`;
|
|
30586
30860
|
while (true) {
|
|
30587
30861
|
const currentBody = {
|
|
30588
30862
|
...baseBody,
|
|
@@ -30598,7 +30872,7 @@ Context: ${context}`);
|
|
|
30598
30872
|
...this.fetchOptions,
|
|
30599
30873
|
body
|
|
30600
30874
|
});
|
|
30601
|
-
await raiseForStatus(res, `Failed to fetch ${
|
|
30875
|
+
await raiseForStatus(res, `Failed to fetch ${path2}`);
|
|
30602
30876
|
return res;
|
|
30603
30877
|
});
|
|
30604
30878
|
const items = await response.json();
|
|
@@ -30908,20 +31182,20 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
30908
31182
|
return result;
|
|
30909
31183
|
}
|
|
30910
31184
|
async hasProject({ projectId, projectName }) {
|
|
30911
|
-
let
|
|
31185
|
+
let path2 = "/sessions";
|
|
30912
31186
|
const params = new URLSearchParams;
|
|
30913
31187
|
if (projectId !== undefined && projectName !== undefined) {
|
|
30914
31188
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
30915
31189
|
} else if (projectId !== undefined) {
|
|
30916
31190
|
assertUuid(projectId);
|
|
30917
|
-
|
|
31191
|
+
path2 += `/${projectId}`;
|
|
30918
31192
|
} else if (projectName !== undefined) {
|
|
30919
31193
|
params.append("name", projectName);
|
|
30920
31194
|
} else {
|
|
30921
31195
|
throw new Error("Must provide projectName or projectId");
|
|
30922
31196
|
}
|
|
30923
31197
|
const response = await this.caller.call(async () => {
|
|
30924
|
-
const res = await this._fetch(`${this.apiUrl}${
|
|
31198
|
+
const res = await this._fetch(`${this.apiUrl}${path2}?${params}`, {
|
|
30925
31199
|
method: "GET",
|
|
30926
31200
|
headers: this.headers,
|
|
30927
31201
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
@@ -30944,13 +31218,13 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
30944
31218
|
}
|
|
30945
31219
|
}
|
|
30946
31220
|
async readProject({ projectId, projectName, includeStats }) {
|
|
30947
|
-
let
|
|
31221
|
+
let path2 = "/sessions";
|
|
30948
31222
|
const params = new URLSearchParams;
|
|
30949
31223
|
if (projectId !== undefined && projectName !== undefined) {
|
|
30950
31224
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
30951
31225
|
} else if (projectId !== undefined) {
|
|
30952
31226
|
assertUuid(projectId);
|
|
30953
|
-
|
|
31227
|
+
path2 += `/${projectId}`;
|
|
30954
31228
|
} else if (projectName !== undefined) {
|
|
30955
31229
|
params.append("name", projectName);
|
|
30956
31230
|
} else {
|
|
@@ -30959,7 +31233,7 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
30959
31233
|
if (includeStats !== undefined) {
|
|
30960
31234
|
params.append("include_stats", includeStats.toString());
|
|
30961
31235
|
}
|
|
30962
|
-
const response = await this._get(
|
|
31236
|
+
const response = await this._get(path2, params);
|
|
30963
31237
|
let result;
|
|
30964
31238
|
if (Array.isArray(response)) {
|
|
30965
31239
|
if (response.length === 0) {
|
|
@@ -31122,19 +31396,19 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31122
31396
|
return result;
|
|
31123
31397
|
}
|
|
31124
31398
|
async readDataset({ datasetId, datasetName }) {
|
|
31125
|
-
let
|
|
31399
|
+
let path2 = "/datasets";
|
|
31126
31400
|
const params = new URLSearchParams({ limit: "1" });
|
|
31127
31401
|
if (datasetId && datasetName) {
|
|
31128
31402
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
31129
31403
|
} else if (datasetId) {
|
|
31130
31404
|
assertUuid(datasetId);
|
|
31131
|
-
|
|
31405
|
+
path2 += `/${datasetId}`;
|
|
31132
31406
|
} else if (datasetName) {
|
|
31133
31407
|
params.append("name", datasetName);
|
|
31134
31408
|
} else {
|
|
31135
31409
|
throw new Error("Must provide datasetName or datasetId");
|
|
31136
31410
|
}
|
|
31137
|
-
const response = await this._get(
|
|
31411
|
+
const response = await this._get(path2, params);
|
|
31138
31412
|
let result;
|
|
31139
31413
|
if (Array.isArray(response)) {
|
|
31140
31414
|
if (response.length === 0) {
|
|
@@ -31175,20 +31449,20 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31175
31449
|
return response;
|
|
31176
31450
|
}
|
|
31177
31451
|
async readDatasetOpenaiFinetuning({ datasetId, datasetName }) {
|
|
31178
|
-
const
|
|
31452
|
+
const path2 = "/datasets";
|
|
31179
31453
|
if (datasetId !== undefined) {} else if (datasetName !== undefined) {
|
|
31180
31454
|
datasetId = (await this.readDataset({ datasetName })).id;
|
|
31181
31455
|
} else {
|
|
31182
31456
|
throw new Error("Must provide either datasetName or datasetId");
|
|
31183
31457
|
}
|
|
31184
|
-
const response = await this._getResponse(`${
|
|
31458
|
+
const response = await this._getResponse(`${path2}/${datasetId}/openai_ft`);
|
|
31185
31459
|
const datasetText = await response.text();
|
|
31186
31460
|
const dataset = datasetText.trim().split(`
|
|
31187
31461
|
`).map((line) => JSON.parse(line));
|
|
31188
31462
|
return dataset;
|
|
31189
31463
|
}
|
|
31190
31464
|
async* listDatasets({ limit = 100, offset = 0, datasetIds, datasetName, datasetNameContains, metadata } = {}) {
|
|
31191
|
-
const
|
|
31465
|
+
const path2 = "/datasets";
|
|
31192
31466
|
const params = new URLSearchParams({
|
|
31193
31467
|
limit: limit.toString(),
|
|
31194
31468
|
offset: offset.toString()
|
|
@@ -31207,7 +31481,7 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31207
31481
|
if (metadata !== undefined) {
|
|
31208
31482
|
params.append("metadata", JSON.stringify(metadata));
|
|
31209
31483
|
}
|
|
31210
|
-
for await (const datasets of this._getPaginated(
|
|
31484
|
+
for await (const datasets of this._getPaginated(path2, params)) {
|
|
31211
31485
|
yield* datasets;
|
|
31212
31486
|
}
|
|
31213
31487
|
}
|
|
@@ -31256,7 +31530,7 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31256
31530
|
});
|
|
31257
31531
|
}
|
|
31258
31532
|
async deleteDataset({ datasetId, datasetName }) {
|
|
31259
|
-
let
|
|
31533
|
+
let path2 = "/datasets";
|
|
31260
31534
|
let datasetId_ = datasetId;
|
|
31261
31535
|
if (datasetId !== undefined && datasetName !== undefined) {
|
|
31262
31536
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
@@ -31266,18 +31540,18 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31266
31540
|
}
|
|
31267
31541
|
if (datasetId_ !== undefined) {
|
|
31268
31542
|
assertUuid(datasetId_);
|
|
31269
|
-
|
|
31543
|
+
path2 += `/${datasetId_}`;
|
|
31270
31544
|
} else {
|
|
31271
31545
|
throw new Error("Must provide datasetName or datasetId");
|
|
31272
31546
|
}
|
|
31273
31547
|
await this.caller.call(async () => {
|
|
31274
|
-
const res = await this._fetch(this.apiUrl +
|
|
31548
|
+
const res = await this._fetch(this.apiUrl + path2, {
|
|
31275
31549
|
method: "DELETE",
|
|
31276
31550
|
headers: this.headers,
|
|
31277
31551
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
31278
31552
|
...this.fetchOptions
|
|
31279
31553
|
});
|
|
31280
|
-
await raiseForStatus(res, `delete ${
|
|
31554
|
+
await raiseForStatus(res, `delete ${path2}`, true);
|
|
31281
31555
|
return res;
|
|
31282
31556
|
});
|
|
31283
31557
|
}
|
|
@@ -31438,8 +31712,8 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31438
31712
|
}
|
|
31439
31713
|
async readExample(exampleId) {
|
|
31440
31714
|
assertUuid(exampleId);
|
|
31441
|
-
const
|
|
31442
|
-
const rawExample = await this._get(
|
|
31715
|
+
const path2 = `/examples/${exampleId}`;
|
|
31716
|
+
const rawExample = await this._get(path2);
|
|
31443
31717
|
const { attachment_urls, ...rest } = rawExample;
|
|
31444
31718
|
const example = rest;
|
|
31445
31719
|
if (attachment_urls) {
|
|
@@ -31522,24 +31796,24 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31522
31796
|
}
|
|
31523
31797
|
async deleteExample(exampleId) {
|
|
31524
31798
|
assertUuid(exampleId);
|
|
31525
|
-
const
|
|
31799
|
+
const path2 = `/examples/${exampleId}`;
|
|
31526
31800
|
await this.caller.call(async () => {
|
|
31527
|
-
const res = await this._fetch(this.apiUrl +
|
|
31801
|
+
const res = await this._fetch(this.apiUrl + path2, {
|
|
31528
31802
|
method: "DELETE",
|
|
31529
31803
|
headers: this.headers,
|
|
31530
31804
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
31531
31805
|
...this.fetchOptions
|
|
31532
31806
|
});
|
|
31533
|
-
await raiseForStatus(res, `delete ${
|
|
31807
|
+
await raiseForStatus(res, `delete ${path2}`, true);
|
|
31534
31808
|
return res;
|
|
31535
31809
|
});
|
|
31536
31810
|
}
|
|
31537
31811
|
async deleteExamples(exampleIds, options) {
|
|
31538
31812
|
exampleIds.forEach((id) => assertUuid(id));
|
|
31539
31813
|
if (options?.hardDelete) {
|
|
31540
|
-
const
|
|
31814
|
+
const path2 = this._getPlatformEndpointPath("datasets/examples/delete");
|
|
31541
31815
|
await this.caller.call(async () => {
|
|
31542
|
-
const res = await this._fetch(`${this.apiUrl}${
|
|
31816
|
+
const res = await this._fetch(`${this.apiUrl}${path2}`, {
|
|
31543
31817
|
method: "POST",
|
|
31544
31818
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
31545
31819
|
body: JSON.stringify({
|
|
@@ -31761,21 +32035,21 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
31761
32035
|
}
|
|
31762
32036
|
async readFeedback(feedbackId) {
|
|
31763
32037
|
assertUuid(feedbackId);
|
|
31764
|
-
const
|
|
31765
|
-
const response = await this._get(
|
|
32038
|
+
const path2 = `/feedback/${feedbackId}`;
|
|
32039
|
+
const response = await this._get(path2);
|
|
31766
32040
|
return response;
|
|
31767
32041
|
}
|
|
31768
32042
|
async deleteFeedback(feedbackId) {
|
|
31769
32043
|
assertUuid(feedbackId);
|
|
31770
|
-
const
|
|
32044
|
+
const path2 = `/feedback/${feedbackId}`;
|
|
31771
32045
|
await this.caller.call(async () => {
|
|
31772
|
-
const res = await this._fetch(this.apiUrl +
|
|
32046
|
+
const res = await this._fetch(this.apiUrl + path2, {
|
|
31773
32047
|
method: "DELETE",
|
|
31774
32048
|
headers: this.headers,
|
|
31775
32049
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
31776
32050
|
...this.fetchOptions
|
|
31777
32051
|
});
|
|
31778
|
-
await raiseForStatus(res, `delete ${
|
|
32052
|
+
await raiseForStatus(res, `delete ${path2}`, true);
|
|
31779
32053
|
return res;
|
|
31780
32054
|
});
|
|
31781
32055
|
}
|
|
@@ -32435,7 +32709,18 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
32435
32709
|
});
|
|
32436
32710
|
return response.json();
|
|
32437
32711
|
}
|
|
32438
|
-
|
|
32712
|
+
_getPromptCacheKey(promptIdentifier, includeModel) {
|
|
32713
|
+
const suffix = includeModel ? ":with_model" : "";
|
|
32714
|
+
return `${promptIdentifier}${suffix}`;
|
|
32715
|
+
}
|
|
32716
|
+
_makeFetchPromptFunc() {
|
|
32717
|
+
return async (key) => {
|
|
32718
|
+
const includeModel = key.endsWith(":with_model");
|
|
32719
|
+
const identifier = includeModel ? key.slice(0, -11) : key;
|
|
32720
|
+
return this._fetchPromptFromApi(identifier, { includeModel });
|
|
32721
|
+
};
|
|
32722
|
+
}
|
|
32723
|
+
async _fetchPromptFromApi(promptIdentifier, options) {
|
|
32439
32724
|
const [owner, promptName, commitHash] = parsePromptIdentifier(promptIdentifier);
|
|
32440
32725
|
const response = await this.caller.call(async () => {
|
|
32441
32726
|
const res = await this._fetch(`${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
|
|
@@ -32456,9 +32741,23 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
32456
32741
|
examples: result.examples
|
|
32457
32742
|
};
|
|
32458
32743
|
}
|
|
32744
|
+
async pullPromptCommit(promptIdentifier, options) {
|
|
32745
|
+
if (!options?.skipCache && this._promptCache) {
|
|
32746
|
+
const cacheKey = this._getPromptCacheKey(promptIdentifier, options?.includeModel);
|
|
32747
|
+
const cached = this._promptCache.get(cacheKey);
|
|
32748
|
+
if (cached) {
|
|
32749
|
+
return cached;
|
|
32750
|
+
}
|
|
32751
|
+
const result = await this._fetchPromptFromApi(promptIdentifier, options);
|
|
32752
|
+
this._promptCache.set(cacheKey, result);
|
|
32753
|
+
return result;
|
|
32754
|
+
}
|
|
32755
|
+
return this._fetchPromptFromApi(promptIdentifier, options);
|
|
32756
|
+
}
|
|
32459
32757
|
async _pullPrompt(promptIdentifier, options) {
|
|
32460
32758
|
const promptObject = await this.pullPromptCommit(promptIdentifier, {
|
|
32461
|
-
includeModel: options?.includeModel
|
|
32759
|
+
includeModel: options?.includeModel,
|
|
32760
|
+
skipCache: options?.skipCache
|
|
32462
32761
|
});
|
|
32463
32762
|
const prompt = JSON.stringify(promptObject.manifest);
|
|
32464
32763
|
return prompt;
|
|
@@ -32540,6 +32839,14 @@ Message: ${Array.isArray(result.detail) ? result.detail.join(`
|
|
|
32540
32839
|
throw new Error(`Invalid public ${kind} URL or token: ${urlOrToken}`);
|
|
32541
32840
|
}
|
|
32542
32841
|
}
|
|
32842
|
+
get promptCache() {
|
|
32843
|
+
return this._promptCache;
|
|
32844
|
+
}
|
|
32845
|
+
cleanup() {
|
|
32846
|
+
if (this._promptCache) {
|
|
32847
|
+
this._promptCache.stop();
|
|
32848
|
+
}
|
|
32849
|
+
}
|
|
32543
32850
|
async awaitPendingTraceBatches() {
|
|
32544
32851
|
if (this.manualFlushMode) {
|
|
32545
32852
|
console.warn("[WARNING]: When tracing in manual flush mode, you must call `await client.flush()` manually to submit trace batches.");
|
|
@@ -32841,6 +33148,12 @@ class RunTree {
|
|
|
32841
33148
|
writable: true,
|
|
32842
33149
|
value: undefined
|
|
32843
33150
|
});
|
|
33151
|
+
Object.defineProperty(this, "_awaitInputsOnPost", {
|
|
33152
|
+
enumerable: true,
|
|
33153
|
+
configurable: true,
|
|
33154
|
+
writable: true,
|
|
33155
|
+
value: undefined
|
|
33156
|
+
});
|
|
32844
33157
|
if (isRunTree(originalConfig)) {
|
|
32845
33158
|
Object.assign(this, { ...originalConfig });
|
|
32846
33159
|
return;
|
|
@@ -33103,23 +33416,23 @@ class RunTree {
|
|
|
33103
33416
|
}
|
|
33104
33417
|
}
|
|
33105
33418
|
const oldId = baseRun.id;
|
|
33106
|
-
const newId =
|
|
33419
|
+
const newId = uuid7Deterministic(oldId, projectName);
|
|
33107
33420
|
let newTraceId;
|
|
33108
33421
|
if (baseRun.trace_id) {
|
|
33109
|
-
newTraceId =
|
|
33422
|
+
newTraceId = uuid7Deterministic(baseRun.trace_id, projectName);
|
|
33110
33423
|
} else {
|
|
33111
33424
|
newTraceId = newId;
|
|
33112
33425
|
}
|
|
33113
33426
|
let newParentId;
|
|
33114
33427
|
if (baseRun.parent_run_id) {
|
|
33115
|
-
newParentId =
|
|
33428
|
+
newParentId = uuid7Deterministic(baseRun.parent_run_id, projectName);
|
|
33116
33429
|
}
|
|
33117
33430
|
let newDottedOrder;
|
|
33118
33431
|
if (baseRun.dotted_order) {
|
|
33119
33432
|
const segs = baseRun.dotted_order.split(".");
|
|
33120
33433
|
const remappedSegs = segs.map((seg) => {
|
|
33121
33434
|
const segId = seg.slice(-TIMESTAMP_LENGTH);
|
|
33122
|
-
const remappedId =
|
|
33435
|
+
const remappedId = uuid7Deterministic(segId, projectName);
|
|
33123
33436
|
return seg.slice(0, -TIMESTAMP_LENGTH) + remappedId;
|
|
33124
33437
|
});
|
|
33125
33438
|
newDottedOrder = remappedSegs.join(".");
|
|
@@ -33134,6 +33447,9 @@ class RunTree {
|
|
|
33134
33447
|
};
|
|
33135
33448
|
}
|
|
33136
33449
|
async postRun(excludeChildRuns = true) {
|
|
33450
|
+
if (this._awaitInputsOnPost) {
|
|
33451
|
+
this.inputs = await this.inputs;
|
|
33452
|
+
}
|
|
33137
33453
|
try {
|
|
33138
33454
|
const runtimeEnv = getRuntimeEnvironment2();
|
|
33139
33455
|
if (this.replicas && this.replicas.length > 0) {
|
|
@@ -35252,13 +35568,13 @@ function isInteger(str) {
|
|
|
35252
35568
|
}
|
|
35253
35569
|
return true;
|
|
35254
35570
|
}
|
|
35255
|
-
function escapePathComponent(
|
|
35256
|
-
if (
|
|
35257
|
-
return
|
|
35258
|
-
return
|
|
35571
|
+
function escapePathComponent(path2) {
|
|
35572
|
+
if (path2.indexOf("/") === -1 && path2.indexOf("~") === -1)
|
|
35573
|
+
return path2;
|
|
35574
|
+
return path2.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
35259
35575
|
}
|
|
35260
|
-
function unescapePathComponent(
|
|
35261
|
-
return
|
|
35576
|
+
function unescapePathComponent(path2) {
|
|
35577
|
+
return path2.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
35262
35578
|
}
|
|
35263
35579
|
function hasUndefined(obj) {
|
|
35264
35580
|
if (obj === undefined)
|
|
@@ -35474,8 +35790,8 @@ function applyOperation(document2, operation, validateOperation = false, mutateD
|
|
|
35474
35790
|
} else {
|
|
35475
35791
|
if (!mutateDocument)
|
|
35476
35792
|
document2 = _deepClone(document2);
|
|
35477
|
-
const
|
|
35478
|
-
const keys =
|
|
35793
|
+
const path2 = operation.path || "";
|
|
35794
|
+
const keys = path2.split("/");
|
|
35479
35795
|
let obj = document2;
|
|
35480
35796
|
let t = 1;
|
|
35481
35797
|
let len = keys.length;
|
|
@@ -39954,10 +40270,10 @@ var Runnable = class extends Serializable {
|
|
|
39954
40270
|
}
|
|
39955
40271
|
const paths = log.ops.filter((op) => op.path.startsWith("/logs/")).map((op) => op.path.split("/")[2]);
|
|
39956
40272
|
const dedupedPaths = [...new Set(paths)];
|
|
39957
|
-
for (const
|
|
40273
|
+
for (const path2 of dedupedPaths) {
|
|
39958
40274
|
let eventType;
|
|
39959
40275
|
let data = {};
|
|
39960
|
-
const logEntry = runLog.state.logs[
|
|
40276
|
+
const logEntry = runLog.state.logs[path2];
|
|
39961
40277
|
if (logEntry.end_time === undefined)
|
|
39962
40278
|
if (logEntry.streamed_output.length > 0)
|
|
39963
40279
|
eventType = "stream";
|
|
@@ -42055,17 +42371,17 @@ function findEnvFile(startDir, filenames = [".env", ".env.local"]) {
|
|
|
42055
42371
|
if (typeof process === "undefined" || !process.cwd) {
|
|
42056
42372
|
return null;
|
|
42057
42373
|
}
|
|
42058
|
-
const
|
|
42059
|
-
const
|
|
42374
|
+
const fs2 = __require("node:fs");
|
|
42375
|
+
const path2 = __require("node:path");
|
|
42060
42376
|
let currentDir = startDir || process.cwd();
|
|
42061
42377
|
while (true) {
|
|
42062
42378
|
for (const filename of filenames) {
|
|
42063
|
-
const candidate =
|
|
42064
|
-
if (
|
|
42379
|
+
const candidate = path2.join(currentDir, filename);
|
|
42380
|
+
if (fs2.existsSync(candidate)) {
|
|
42065
42381
|
return candidate;
|
|
42066
42382
|
}
|
|
42067
42383
|
}
|
|
42068
|
-
const parentDir =
|
|
42384
|
+
const parentDir = path2.dirname(currentDir);
|
|
42069
42385
|
if (parentDir === currentDir) {
|
|
42070
42386
|
break;
|
|
42071
42387
|
}
|
|
@@ -44787,7 +45103,7 @@ function stringToUuid(target) {
|
|
|
44787
45103
|
const bytes = digest.slice(0, 16);
|
|
44788
45104
|
bytes[8] = bytes[8] & 63 | 128;
|
|
44789
45105
|
bytes[6] = bytes[6] & 15 | 0;
|
|
44790
|
-
return
|
|
45106
|
+
return bytesToUuid2(bytes);
|
|
44791
45107
|
}
|
|
44792
45108
|
async function prewarmUuidCache(values) {
|
|
44793
45109
|
if (!checkWebCrypto())
|
|
@@ -44925,7 +45241,7 @@ function utf8Encode(str) {
|
|
|
44925
45241
|
}
|
|
44926
45242
|
return new Uint8Array(utf8);
|
|
44927
45243
|
}
|
|
44928
|
-
function
|
|
45244
|
+
function bytesToUuid2(bytes) {
|
|
44929
45245
|
const hex = [];
|
|
44930
45246
|
for (let i = 0;i < bytes.length; i++) {
|
|
44931
45247
|
const h = bytes[i].toString(16).padStart(2, "0");
|
|
@@ -44945,9 +45261,9 @@ var getContentTypeFromMimeType = (mimeType) => {
|
|
|
44945
45261
|
}
|
|
44946
45262
|
return;
|
|
44947
45263
|
};
|
|
44948
|
-
function getLocalServerUrl(
|
|
45264
|
+
function getLocalServerUrl(path2) {
|
|
44949
45265
|
const port = getEnv3("SERVER_PORT", "3000");
|
|
44950
|
-
return `http://localhost:${port}${
|
|
45266
|
+
return `http://localhost:${port}${path2}`;
|
|
44951
45267
|
}
|
|
44952
45268
|
// src/schemas/character.ts
|
|
44953
45269
|
import { z as z3 } from "zod";
|
|
@@ -45464,8 +45780,8 @@ class ActionStreamFilter {
|
|
|
45464
45780
|
// src/utils/paths.ts
|
|
45465
45781
|
var pathJoin = (...parts) => {
|
|
45466
45782
|
if (typeof process !== "undefined" && process.platform) {
|
|
45467
|
-
const
|
|
45468
|
-
return
|
|
45783
|
+
const path2 = __require("node:path");
|
|
45784
|
+
return path2.join(...parts);
|
|
45469
45785
|
}
|
|
45470
45786
|
return parts.filter((part) => part).join("/").replace(/\/+/g, "/").replace(/\/$/, "");
|
|
45471
45787
|
};
|
|
@@ -49130,6 +49446,41 @@ class AgentRuntime {
|
|
|
49130
49446
|
modelSettings.presencePenalty = presencePenalty;
|
|
49131
49447
|
return Object.keys(modelSettings).length > 0 ? modelSettings : null;
|
|
49132
49448
|
}
|
|
49449
|
+
logModelCall(modelType, modelKey, params, promptContent, elapsedTime, provider, response) {
|
|
49450
|
+
if (modelKey !== ModelType.TEXT_EMBEDDING && promptContent) {
|
|
49451
|
+
if (this.currentActionContext) {
|
|
49452
|
+
this.currentActionContext.prompts.push({
|
|
49453
|
+
modelType: modelKey,
|
|
49454
|
+
prompt: promptContent,
|
|
49455
|
+
timestamp: Date.now()
|
|
49456
|
+
});
|
|
49457
|
+
}
|
|
49458
|
+
}
|
|
49459
|
+
this.adapter.log({
|
|
49460
|
+
entityId: this.agentId,
|
|
49461
|
+
roomId: this.currentRoomId ?? this.agentId,
|
|
49462
|
+
body: {
|
|
49463
|
+
modelType,
|
|
49464
|
+
modelKey,
|
|
49465
|
+
params: {
|
|
49466
|
+
...typeof params === "object" && !Array.isArray(params) && params ? params : {},
|
|
49467
|
+
prompt: promptContent
|
|
49468
|
+
},
|
|
49469
|
+
prompt: promptContent,
|
|
49470
|
+
systemPrompt: this.character?.system || null,
|
|
49471
|
+
runId: this.getCurrentRunId(),
|
|
49472
|
+
timestamp: Date.now(),
|
|
49473
|
+
executionTime: elapsedTime,
|
|
49474
|
+
provider: provider || this.models.get(modelKey)?.[0]?.provider || "unknown",
|
|
49475
|
+
actionContext: this.currentActionContext ? {
|
|
49476
|
+
actionName: this.currentActionContext.actionName,
|
|
49477
|
+
actionId: this.currentActionContext.actionId
|
|
49478
|
+
} : undefined,
|
|
49479
|
+
response: Array.isArray(response) && response.every((x) => typeof x === "number") ? "[array]" : response
|
|
49480
|
+
},
|
|
49481
|
+
type: `useModel:${modelKey}`
|
|
49482
|
+
});
|
|
49483
|
+
}
|
|
49133
49484
|
async useModel(modelType, params, provider) {
|
|
49134
49485
|
const modelKey = typeof modelType === "string" ? modelType : ModelType[modelType];
|
|
49135
49486
|
const paramsObj = params;
|
|
@@ -49224,6 +49575,7 @@ class AgentRuntime {
|
|
|
49224
49575
|
duration: Number(elapsedTime2.toFixed(2)),
|
|
49225
49576
|
streaming: true
|
|
49226
49577
|
}, "Model output (stream with callback complete)");
|
|
49578
|
+
this.logModelCall(modelType, modelKey, params, promptContent, elapsedTime2, provider, fullText);
|
|
49227
49579
|
return fullText;
|
|
49228
49580
|
}
|
|
49229
49581
|
const elapsedTime = (typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now()) - startTime;
|
|
@@ -49233,39 +49585,7 @@ class AgentRuntime {
|
|
|
49233
49585
|
model: modelKey,
|
|
49234
49586
|
duration: Number(elapsedTime.toFixed(2))
|
|
49235
49587
|
}, "Model output");
|
|
49236
|
-
|
|
49237
|
-
if (this.currentActionContext) {
|
|
49238
|
-
this.currentActionContext.prompts.push({
|
|
49239
|
-
modelType: modelKey,
|
|
49240
|
-
prompt: promptContent,
|
|
49241
|
-
timestamp: Date.now()
|
|
49242
|
-
});
|
|
49243
|
-
}
|
|
49244
|
-
}
|
|
49245
|
-
this.adapter.log({
|
|
49246
|
-
entityId: this.agentId,
|
|
49247
|
-
roomId: this.currentRoomId ?? this.agentId,
|
|
49248
|
-
body: {
|
|
49249
|
-
modelType,
|
|
49250
|
-
modelKey,
|
|
49251
|
-
params: {
|
|
49252
|
-
...typeof params === "object" && !Array.isArray(params) && params ? params : {},
|
|
49253
|
-
prompt: promptContent
|
|
49254
|
-
},
|
|
49255
|
-
prompt: promptContent,
|
|
49256
|
-
systemPrompt: this.character?.system || null,
|
|
49257
|
-
runId: this.getCurrentRunId(),
|
|
49258
|
-
timestamp: Date.now(),
|
|
49259
|
-
executionTime: elapsedTime,
|
|
49260
|
-
provider: provider || this.models.get(modelKey)?.[0]?.provider || "unknown",
|
|
49261
|
-
actionContext: this.currentActionContext ? {
|
|
49262
|
-
actionName: this.currentActionContext.actionName,
|
|
49263
|
-
actionId: this.currentActionContext.actionId
|
|
49264
|
-
} : undefined,
|
|
49265
|
-
response: Array.isArray(response) && response.every((x) => typeof x === "number") ? "[array]" : response
|
|
49266
|
-
},
|
|
49267
|
-
type: `useModel:${modelKey}`
|
|
49268
|
-
});
|
|
49588
|
+
this.logModelCall(modelType, modelKey, params, promptContent, elapsedTime, provider, response);
|
|
49269
49589
|
return response;
|
|
49270
49590
|
}
|
|
49271
49591
|
async generateText(input, options) {
|
|
@@ -49878,7 +50198,7 @@ function getCryptoModule() {
|
|
|
49878
50198
|
}
|
|
49879
50199
|
return require_crypto_browserify();
|
|
49880
50200
|
}
|
|
49881
|
-
function
|
|
50201
|
+
function createHash2(algorithm) {
|
|
49882
50202
|
const crypto2 = getCryptoModule();
|
|
49883
50203
|
const hash = crypto2.createHash(algorithm);
|
|
49884
50204
|
return {
|
|
@@ -49987,7 +50307,7 @@ function encryptStringValue(value, salt) {
|
|
|
49987
50307
|
}
|
|
49988
50308
|
} catch {}
|
|
49989
50309
|
}
|
|
49990
|
-
const key =
|
|
50310
|
+
const key = createHash2("sha256").update(salt).digest().slice(0, 32);
|
|
49991
50311
|
const iv = BufferUtils.randomBytes(16);
|
|
49992
50312
|
const cipher = createCipheriv("aes-256-cbc", key, iv);
|
|
49993
50313
|
let encrypted = cipher.update(value, "utf8", "hex");
|
|
@@ -50005,7 +50325,7 @@ function decryptStringValue(value, salt) {
|
|
|
50005
50325
|
if (iv.length !== 16) {
|
|
50006
50326
|
return value;
|
|
50007
50327
|
}
|
|
50008
|
-
const key =
|
|
50328
|
+
const key = createHash2("sha256").update(salt).digest().slice(0, 32);
|
|
50009
50329
|
const decipher = createDecipheriv("aes-256-cbc", key, iv);
|
|
50010
50330
|
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
50011
50331
|
decrypted += decipher.final("utf8");
|
|
@@ -51214,5 +51534,5 @@ export {
|
|
|
51214
51534
|
ActionStreamFilter
|
|
51215
51535
|
};
|
|
51216
51536
|
|
|
51217
|
-
//# debugId=
|
|
51537
|
+
//# debugId=0EA8CF3BFF9CF58964756E2164756E21
|
|
51218
51538
|
//# sourceMappingURL=index.node.js.map
|