@eko-ai/eko 1.1.4 → 1.2.1
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/common/log.d.ts +2 -0
- package/dist/core/eko.d.ts +1 -0
- package/dist/extension/content/index.d.ts +1 -16
- package/dist/extension.cjs.js +778 -149
- package/dist/extension.esm.js +778 -149
- package/dist/extension_content_script.js +634 -6
- package/dist/index.cjs.js +787 -80
- package/dist/index.esm.js +787 -80
- package/dist/models/action.d.ts +1 -0
- package/dist/nodejs.cjs.js +712 -88
- package/dist/nodejs.esm.js +648 -24
- package/dist/types/action.types.d.ts +4 -0
- package/dist/types/eko.types.d.ts +6 -0
- package/dist/types/llm.types.d.ts +2 -0
- package/dist/web.cjs.js +651 -23
- package/dist/web.esm.js +651 -23
- package/package.json +5 -2
package/dist/index.cjs.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var os = require('os');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var util = require('util');
|
|
8
|
+
|
|
5
9
|
const VERSION$1 = '0.33.1'; // x-release-please-version
|
|
6
10
|
|
|
7
11
|
let auto$1 = false;
|
|
@@ -2714,7 +2718,7 @@ class ClaudeProvider {
|
|
|
2714
2718
|
if (typeof window !== 'undefined' &&
|
|
2715
2719
|
typeof document !== 'undefined' &&
|
|
2716
2720
|
(typeof param == 'string' || param.apiKey)) {
|
|
2717
|
-
|
|
2721
|
+
logger.warn(`
|
|
2718
2722
|
⚠️ Security Warning:
|
|
2719
2723
|
DO NOT use API Keys in browser/frontend code!
|
|
2720
2724
|
This will expose your credentials and may lead to unauthorized usage.
|
|
@@ -8782,6 +8786,630 @@ OpenAI.BatchesPage = BatchesPage;
|
|
|
8782
8786
|
OpenAI.Uploads = Uploads;
|
|
8783
8787
|
OpenAI.Responses = Responses;
|
|
8784
8788
|
|
|
8789
|
+
const prettyLogStyles = {
|
|
8790
|
+
reset: [0, 0],
|
|
8791
|
+
bold: [1, 22],
|
|
8792
|
+
dim: [2, 22],
|
|
8793
|
+
italic: [3, 23],
|
|
8794
|
+
underline: [4, 24],
|
|
8795
|
+
overline: [53, 55],
|
|
8796
|
+
inverse: [7, 27],
|
|
8797
|
+
hidden: [8, 28],
|
|
8798
|
+
strikethrough: [9, 29],
|
|
8799
|
+
black: [30, 39],
|
|
8800
|
+
red: [31, 39],
|
|
8801
|
+
green: [32, 39],
|
|
8802
|
+
yellow: [33, 39],
|
|
8803
|
+
blue: [34, 39],
|
|
8804
|
+
magenta: [35, 39],
|
|
8805
|
+
cyan: [36, 39],
|
|
8806
|
+
white: [37, 39],
|
|
8807
|
+
blackBright: [90, 39],
|
|
8808
|
+
redBright: [91, 39],
|
|
8809
|
+
greenBright: [92, 39],
|
|
8810
|
+
yellowBright: [93, 39],
|
|
8811
|
+
blueBright: [94, 39],
|
|
8812
|
+
magentaBright: [95, 39],
|
|
8813
|
+
cyanBright: [96, 39],
|
|
8814
|
+
whiteBright: [97, 39],
|
|
8815
|
+
bgBlack: [40, 49],
|
|
8816
|
+
bgRed: [41, 49],
|
|
8817
|
+
bgGreen: [42, 49],
|
|
8818
|
+
bgYellow: [43, 49],
|
|
8819
|
+
bgBlue: [44, 49],
|
|
8820
|
+
bgMagenta: [45, 49],
|
|
8821
|
+
bgCyan: [46, 49],
|
|
8822
|
+
bgWhite: [47, 49],
|
|
8823
|
+
bgBlackBright: [100, 49],
|
|
8824
|
+
bgRedBright: [101, 49],
|
|
8825
|
+
bgGreenBright: [102, 49],
|
|
8826
|
+
bgYellowBright: [103, 49],
|
|
8827
|
+
bgBlueBright: [104, 49],
|
|
8828
|
+
bgMagentaBright: [105, 49],
|
|
8829
|
+
bgCyanBright: [106, 49],
|
|
8830
|
+
bgWhiteBright: [107, 49],
|
|
8831
|
+
};
|
|
8832
|
+
|
|
8833
|
+
function formatTemplate(settings, template, values, hideUnsetPlaceholder = false) {
|
|
8834
|
+
const templateString = String(template);
|
|
8835
|
+
const ansiColorWrap = (placeholderValue, code) => `\u001b[${code[0]}m${placeholderValue}\u001b[${code[1]}m`;
|
|
8836
|
+
const styleWrap = (value, style) => {
|
|
8837
|
+
if (style != null && typeof style === "string") {
|
|
8838
|
+
return ansiColorWrap(value, prettyLogStyles[style]);
|
|
8839
|
+
}
|
|
8840
|
+
else if (style != null && Array.isArray(style)) {
|
|
8841
|
+
return style.reduce((prevValue, thisStyle) => styleWrap(prevValue, thisStyle), value);
|
|
8842
|
+
}
|
|
8843
|
+
else {
|
|
8844
|
+
if (style != null && style[value.trim()] != null) {
|
|
8845
|
+
return styleWrap(value, style[value.trim()]);
|
|
8846
|
+
}
|
|
8847
|
+
else if (style != null && style["*"] != null) {
|
|
8848
|
+
return styleWrap(value, style["*"]);
|
|
8849
|
+
}
|
|
8850
|
+
else {
|
|
8851
|
+
return value;
|
|
8852
|
+
}
|
|
8853
|
+
}
|
|
8854
|
+
};
|
|
8855
|
+
const defaultStyle = null;
|
|
8856
|
+
return templateString.replace(/{{(.+?)}}/g, (_, placeholder) => {
|
|
8857
|
+
const value = values[placeholder] != null ? String(values[placeholder]) : hideUnsetPlaceholder ? "" : _;
|
|
8858
|
+
return settings.stylePrettyLogs
|
|
8859
|
+
? styleWrap(value, settings?.prettyLogStyles?.[placeholder] ?? defaultStyle) + ansiColorWrap("", prettyLogStyles.reset)
|
|
8860
|
+
: value;
|
|
8861
|
+
});
|
|
8862
|
+
}
|
|
8863
|
+
|
|
8864
|
+
function formatNumberAddZeros(value, digits = 2, addNumber = 0) {
|
|
8865
|
+
if (value != null && isNaN(value)) {
|
|
8866
|
+
return "";
|
|
8867
|
+
}
|
|
8868
|
+
value = value != null ? value + addNumber : value;
|
|
8869
|
+
return digits === 2
|
|
8870
|
+
? value == null
|
|
8871
|
+
? "--"
|
|
8872
|
+
: value < 10
|
|
8873
|
+
? "0" + value
|
|
8874
|
+
: value.toString()
|
|
8875
|
+
: value == null
|
|
8876
|
+
? "---"
|
|
8877
|
+
: value < 10
|
|
8878
|
+
? "00" + value
|
|
8879
|
+
: value < 100
|
|
8880
|
+
? "0" + value
|
|
8881
|
+
: value.toString();
|
|
8882
|
+
}
|
|
8883
|
+
|
|
8884
|
+
function urlToObject(url) {
|
|
8885
|
+
return {
|
|
8886
|
+
href: url.href,
|
|
8887
|
+
protocol: url.protocol,
|
|
8888
|
+
username: url.username,
|
|
8889
|
+
password: url.password,
|
|
8890
|
+
host: url.host,
|
|
8891
|
+
hostname: url.hostname,
|
|
8892
|
+
port: url.port,
|
|
8893
|
+
pathname: url.pathname,
|
|
8894
|
+
search: url.search,
|
|
8895
|
+
searchParams: [...url.searchParams].map(([key, value]) => ({ key, value })),
|
|
8896
|
+
hash: url.hash,
|
|
8897
|
+
origin: url.origin,
|
|
8898
|
+
};
|
|
8899
|
+
}
|
|
8900
|
+
|
|
8901
|
+
var Runtime = {
|
|
8902
|
+
getCallerStackFrame,
|
|
8903
|
+
getErrorTrace,
|
|
8904
|
+
getMeta,
|
|
8905
|
+
transportJSON,
|
|
8906
|
+
transportFormatted: transportFormatted$1,
|
|
8907
|
+
isBuffer,
|
|
8908
|
+
isError,
|
|
8909
|
+
prettyFormatLogObj,
|
|
8910
|
+
prettyFormatErrorObj,
|
|
8911
|
+
};
|
|
8912
|
+
const meta = {
|
|
8913
|
+
runtime: "Nodejs",
|
|
8914
|
+
runtimeVersion: process?.version,
|
|
8915
|
+
hostname: os.hostname ? os.hostname() : undefined,
|
|
8916
|
+
};
|
|
8917
|
+
function getMeta(logLevelId, logLevelName, stackDepthLevel, hideLogPositionForPerformance, name, parentNames) {
|
|
8918
|
+
return Object.assign({}, meta, {
|
|
8919
|
+
name,
|
|
8920
|
+
parentNames,
|
|
8921
|
+
date: new Date(),
|
|
8922
|
+
logLevelId,
|
|
8923
|
+
logLevelName,
|
|
8924
|
+
path: !hideLogPositionForPerformance ? getCallerStackFrame(stackDepthLevel) : undefined,
|
|
8925
|
+
});
|
|
8926
|
+
}
|
|
8927
|
+
function getCallerStackFrame(stackDepthLevel, error = Error()) {
|
|
8928
|
+
return stackLineToStackFrame(error?.stack?.split("\n")?.filter((thisLine) => thisLine.includes(" at "))?.[stackDepthLevel]);
|
|
8929
|
+
}
|
|
8930
|
+
function getErrorTrace(error) {
|
|
8931
|
+
return error?.stack?.split("\n")?.reduce((result, line) => {
|
|
8932
|
+
if (line.includes(" at ")) {
|
|
8933
|
+
result.push(stackLineToStackFrame(line));
|
|
8934
|
+
}
|
|
8935
|
+
return result;
|
|
8936
|
+
}, []);
|
|
8937
|
+
}
|
|
8938
|
+
function stackLineToStackFrame(line) {
|
|
8939
|
+
const pathResult = {
|
|
8940
|
+
fullFilePath: undefined,
|
|
8941
|
+
fileName: undefined,
|
|
8942
|
+
fileNameWithLine: undefined,
|
|
8943
|
+
fileColumn: undefined,
|
|
8944
|
+
fileLine: undefined,
|
|
8945
|
+
filePath: undefined,
|
|
8946
|
+
filePathWithLine: undefined,
|
|
8947
|
+
method: undefined,
|
|
8948
|
+
};
|
|
8949
|
+
if (line != null && line.includes(" at ")) {
|
|
8950
|
+
line = line.replace(/^\s+at\s+/gm, "");
|
|
8951
|
+
const errorStackLine = line.split(" (");
|
|
8952
|
+
const fullFilePath = line?.slice(-1) === ")" ? line?.match(/\(([^)]+)\)/)?.[1] : line;
|
|
8953
|
+
const pathArray = fullFilePath?.includes(":") ? fullFilePath?.replace("file://", "")?.replace(process.cwd(), "")?.split(":") : undefined;
|
|
8954
|
+
const fileColumn = pathArray?.pop();
|
|
8955
|
+
const fileLine = pathArray?.pop();
|
|
8956
|
+
const filePath = pathArray?.pop();
|
|
8957
|
+
const filePathWithLine = path.normalize(`${filePath}:${fileLine}`);
|
|
8958
|
+
const fileName = filePath?.split("/")?.pop();
|
|
8959
|
+
const fileNameWithLine = `${fileName}:${fileLine}`;
|
|
8960
|
+
if (filePath != null && filePath.length > 0) {
|
|
8961
|
+
pathResult.fullFilePath = fullFilePath;
|
|
8962
|
+
pathResult.fileName = fileName;
|
|
8963
|
+
pathResult.fileNameWithLine = fileNameWithLine;
|
|
8964
|
+
pathResult.fileColumn = fileColumn;
|
|
8965
|
+
pathResult.fileLine = fileLine;
|
|
8966
|
+
pathResult.filePath = filePath;
|
|
8967
|
+
pathResult.filePathWithLine = filePathWithLine;
|
|
8968
|
+
pathResult.method = errorStackLine?.[1] != null ? errorStackLine?.[0] : undefined;
|
|
8969
|
+
}
|
|
8970
|
+
}
|
|
8971
|
+
return pathResult;
|
|
8972
|
+
}
|
|
8973
|
+
function isError(e) {
|
|
8974
|
+
return util.types?.isNativeError != null ? util.types.isNativeError(e) : e instanceof Error;
|
|
8975
|
+
}
|
|
8976
|
+
function prettyFormatLogObj(maskedArgs, settings) {
|
|
8977
|
+
return maskedArgs.reduce((result, arg) => {
|
|
8978
|
+
isError(arg) ? result.errors.push(prettyFormatErrorObj(arg, settings)) : result.args.push(arg);
|
|
8979
|
+
return result;
|
|
8980
|
+
}, { args: [], errors: [] });
|
|
8981
|
+
}
|
|
8982
|
+
function prettyFormatErrorObj(error, settings) {
|
|
8983
|
+
const errorStackStr = getErrorTrace(error).map((stackFrame) => {
|
|
8984
|
+
return formatTemplate(settings, settings.prettyErrorStackTemplate, { ...stackFrame }, true);
|
|
8985
|
+
});
|
|
8986
|
+
const placeholderValuesError = {
|
|
8987
|
+
errorName: ` ${error.name} `,
|
|
8988
|
+
errorMessage: Object.getOwnPropertyNames(error)
|
|
8989
|
+
.reduce((result, key) => {
|
|
8990
|
+
if (key !== "stack") {
|
|
8991
|
+
result.push(error[key]);
|
|
8992
|
+
}
|
|
8993
|
+
return result;
|
|
8994
|
+
}, [])
|
|
8995
|
+
.join(", "),
|
|
8996
|
+
errorStack: errorStackStr.join("\n"),
|
|
8997
|
+
};
|
|
8998
|
+
return formatTemplate(settings, settings.prettyErrorTemplate, placeholderValuesError);
|
|
8999
|
+
}
|
|
9000
|
+
function transportFormatted$1(logMetaMarkup, logArgs, logErrors, settings) {
|
|
9001
|
+
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
9002
|
+
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
9003
|
+
console.log(logMetaMarkup + util.formatWithOptions(settings.prettyInspectOptions, ...logArgs) + logErrorsStr);
|
|
9004
|
+
}
|
|
9005
|
+
function transportJSON(json) {
|
|
9006
|
+
console.log(jsonStringifyRecursive(json));
|
|
9007
|
+
function jsonStringifyRecursive(obj) {
|
|
9008
|
+
const cache = new Set();
|
|
9009
|
+
return JSON.stringify(obj, (key, value) => {
|
|
9010
|
+
if (typeof value === "object" && value !== null) {
|
|
9011
|
+
if (cache.has(value)) {
|
|
9012
|
+
return "[Circular]";
|
|
9013
|
+
}
|
|
9014
|
+
cache.add(value);
|
|
9015
|
+
}
|
|
9016
|
+
if (typeof value === "bigint") {
|
|
9017
|
+
return `${value}`;
|
|
9018
|
+
}
|
|
9019
|
+
if (typeof value === "undefined") {
|
|
9020
|
+
return "[undefined]";
|
|
9021
|
+
}
|
|
9022
|
+
return value;
|
|
9023
|
+
});
|
|
9024
|
+
}
|
|
9025
|
+
}
|
|
9026
|
+
function isBuffer(arg) {
|
|
9027
|
+
return Buffer.isBuffer(arg);
|
|
9028
|
+
}
|
|
9029
|
+
|
|
9030
|
+
class BaseLogger {
|
|
9031
|
+
constructor(settings, logObj, stackDepthLevel = 4) {
|
|
9032
|
+
this.logObj = logObj;
|
|
9033
|
+
this.stackDepthLevel = stackDepthLevel;
|
|
9034
|
+
this.runtime = Runtime;
|
|
9035
|
+
this.settings = {
|
|
9036
|
+
type: settings?.type ?? "pretty",
|
|
9037
|
+
name: settings?.name,
|
|
9038
|
+
parentNames: settings?.parentNames,
|
|
9039
|
+
minLevel: settings?.minLevel ?? 0,
|
|
9040
|
+
argumentsArrayName: settings?.argumentsArrayName,
|
|
9041
|
+
hideLogPositionForProduction: settings?.hideLogPositionForProduction ?? false,
|
|
9042
|
+
prettyLogTemplate: settings?.prettyLogTemplate ??
|
|
9043
|
+
"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t{{filePathWithLine}}{{nameWithDelimiterPrefix}}\t",
|
|
9044
|
+
prettyErrorTemplate: settings?.prettyErrorTemplate ?? "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}",
|
|
9045
|
+
prettyErrorStackTemplate: settings?.prettyErrorStackTemplate ?? " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}",
|
|
9046
|
+
prettyErrorParentNamesSeparator: settings?.prettyErrorParentNamesSeparator ?? ":",
|
|
9047
|
+
prettyErrorLoggerNameDelimiter: settings?.prettyErrorLoggerNameDelimiter ?? "\t",
|
|
9048
|
+
stylePrettyLogs: settings?.stylePrettyLogs ?? true,
|
|
9049
|
+
prettyLogTimeZone: settings?.prettyLogTimeZone ?? "UTC",
|
|
9050
|
+
prettyLogStyles: settings?.prettyLogStyles ?? {
|
|
9051
|
+
logLevelName: {
|
|
9052
|
+
"*": ["bold", "black", "bgWhiteBright", "dim"],
|
|
9053
|
+
SILLY: ["bold", "white"],
|
|
9054
|
+
TRACE: ["bold", "whiteBright"],
|
|
9055
|
+
DEBUG: ["bold", "green"],
|
|
9056
|
+
INFO: ["bold", "blue"],
|
|
9057
|
+
WARN: ["bold", "yellow"],
|
|
9058
|
+
ERROR: ["bold", "red"],
|
|
9059
|
+
FATAL: ["bold", "redBright"],
|
|
9060
|
+
},
|
|
9061
|
+
dateIsoStr: "white",
|
|
9062
|
+
filePathWithLine: "white",
|
|
9063
|
+
name: ["white", "bold"],
|
|
9064
|
+
nameWithDelimiterPrefix: ["white", "bold"],
|
|
9065
|
+
nameWithDelimiterSuffix: ["white", "bold"],
|
|
9066
|
+
errorName: ["bold", "bgRedBright", "whiteBright"],
|
|
9067
|
+
fileName: ["yellow"],
|
|
9068
|
+
fileNameWithLine: "white",
|
|
9069
|
+
},
|
|
9070
|
+
prettyInspectOptions: settings?.prettyInspectOptions ?? {
|
|
9071
|
+
colors: true,
|
|
9072
|
+
compact: false,
|
|
9073
|
+
depth: Infinity,
|
|
9074
|
+
},
|
|
9075
|
+
metaProperty: settings?.metaProperty ?? "_meta",
|
|
9076
|
+
maskPlaceholder: settings?.maskPlaceholder ?? "[***]",
|
|
9077
|
+
maskValuesOfKeys: settings?.maskValuesOfKeys ?? ["password"],
|
|
9078
|
+
maskValuesOfKeysCaseInsensitive: settings?.maskValuesOfKeysCaseInsensitive ?? false,
|
|
9079
|
+
maskValuesRegEx: settings?.maskValuesRegEx,
|
|
9080
|
+
prefix: [...(settings?.prefix ?? [])],
|
|
9081
|
+
attachedTransports: [...(settings?.attachedTransports ?? [])],
|
|
9082
|
+
overwrite: {
|
|
9083
|
+
mask: settings?.overwrite?.mask,
|
|
9084
|
+
toLogObj: settings?.overwrite?.toLogObj,
|
|
9085
|
+
addMeta: settings?.overwrite?.addMeta,
|
|
9086
|
+
addPlaceholders: settings?.overwrite?.addPlaceholders,
|
|
9087
|
+
formatMeta: settings?.overwrite?.formatMeta,
|
|
9088
|
+
formatLogObj: settings?.overwrite?.formatLogObj,
|
|
9089
|
+
transportFormatted: settings?.overwrite?.transportFormatted,
|
|
9090
|
+
transportJSON: settings?.overwrite?.transportJSON,
|
|
9091
|
+
},
|
|
9092
|
+
};
|
|
9093
|
+
}
|
|
9094
|
+
log(logLevelId, logLevelName, ...args) {
|
|
9095
|
+
if (logLevelId < this.settings.minLevel) {
|
|
9096
|
+
return;
|
|
9097
|
+
}
|
|
9098
|
+
const logArgs = [...this.settings.prefix, ...args];
|
|
9099
|
+
const maskedArgs = this.settings.overwrite?.mask != null
|
|
9100
|
+
? this.settings.overwrite?.mask(logArgs)
|
|
9101
|
+
: this.settings.maskValuesOfKeys != null && this.settings.maskValuesOfKeys.length > 0
|
|
9102
|
+
? this._mask(logArgs)
|
|
9103
|
+
: logArgs;
|
|
9104
|
+
const thisLogObj = this.logObj != null ? this._recursiveCloneAndExecuteFunctions(this.logObj) : undefined;
|
|
9105
|
+
const logObj = this.settings.overwrite?.toLogObj != null ? this.settings.overwrite?.toLogObj(maskedArgs, thisLogObj) : this._toLogObj(maskedArgs, thisLogObj);
|
|
9106
|
+
const logObjWithMeta = this.settings.overwrite?.addMeta != null
|
|
9107
|
+
? this.settings.overwrite?.addMeta(logObj, logLevelId, logLevelName)
|
|
9108
|
+
: this._addMetaToLogObj(logObj, logLevelId, logLevelName);
|
|
9109
|
+
let logMetaMarkup;
|
|
9110
|
+
let logArgsAndErrorsMarkup = undefined;
|
|
9111
|
+
if (this.settings.overwrite?.formatMeta != null) {
|
|
9112
|
+
logMetaMarkup = this.settings.overwrite?.formatMeta(logObjWithMeta?.[this.settings.metaProperty]);
|
|
9113
|
+
}
|
|
9114
|
+
if (this.settings.overwrite?.formatLogObj != null) {
|
|
9115
|
+
logArgsAndErrorsMarkup = this.settings.overwrite?.formatLogObj(maskedArgs, this.settings);
|
|
9116
|
+
}
|
|
9117
|
+
if (this.settings.type === "pretty") {
|
|
9118
|
+
logMetaMarkup = logMetaMarkup ?? this._prettyFormatLogObjMeta(logObjWithMeta?.[this.settings.metaProperty]);
|
|
9119
|
+
logArgsAndErrorsMarkup = logArgsAndErrorsMarkup ?? this.runtime.prettyFormatLogObj(maskedArgs, this.settings);
|
|
9120
|
+
}
|
|
9121
|
+
if (logMetaMarkup != null && logArgsAndErrorsMarkup != null) {
|
|
9122
|
+
this.settings.overwrite?.transportFormatted != null
|
|
9123
|
+
? this.settings.overwrite?.transportFormatted(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, this.settings)
|
|
9124
|
+
: this.runtime.transportFormatted(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, this.settings);
|
|
9125
|
+
}
|
|
9126
|
+
else {
|
|
9127
|
+
this.settings.overwrite?.transportJSON != null
|
|
9128
|
+
? this.settings.overwrite?.transportJSON(logObjWithMeta)
|
|
9129
|
+
: this.settings.type !== "hidden"
|
|
9130
|
+
? this.runtime.transportJSON(logObjWithMeta)
|
|
9131
|
+
: undefined;
|
|
9132
|
+
}
|
|
9133
|
+
if (this.settings.attachedTransports != null && this.settings.attachedTransports.length > 0) {
|
|
9134
|
+
this.settings.attachedTransports.forEach((transportLogger) => {
|
|
9135
|
+
transportLogger(logObjWithMeta);
|
|
9136
|
+
});
|
|
9137
|
+
}
|
|
9138
|
+
return logObjWithMeta;
|
|
9139
|
+
}
|
|
9140
|
+
attachTransport(transportLogger) {
|
|
9141
|
+
this.settings.attachedTransports.push(transportLogger);
|
|
9142
|
+
}
|
|
9143
|
+
getSubLogger(settings, logObj) {
|
|
9144
|
+
const subLoggerSettings = {
|
|
9145
|
+
...this.settings,
|
|
9146
|
+
...settings,
|
|
9147
|
+
parentNames: this.settings?.parentNames != null && this.settings?.name != null
|
|
9148
|
+
? [...this.settings.parentNames, this.settings.name]
|
|
9149
|
+
: this.settings?.name != null
|
|
9150
|
+
? [this.settings.name]
|
|
9151
|
+
: undefined,
|
|
9152
|
+
prefix: [...this.settings.prefix, ...(settings?.prefix ?? [])],
|
|
9153
|
+
};
|
|
9154
|
+
const subLogger = new this.constructor(subLoggerSettings, logObj ?? this.logObj, this.stackDepthLevel);
|
|
9155
|
+
return subLogger;
|
|
9156
|
+
}
|
|
9157
|
+
_mask(args) {
|
|
9158
|
+
const maskValuesOfKeys = this.settings.maskValuesOfKeysCaseInsensitive !== true ? this.settings.maskValuesOfKeys : this.settings.maskValuesOfKeys.map((key) => key.toLowerCase());
|
|
9159
|
+
return args?.map((arg) => {
|
|
9160
|
+
return this._recursiveCloneAndMaskValuesOfKeys(arg, maskValuesOfKeys);
|
|
9161
|
+
});
|
|
9162
|
+
}
|
|
9163
|
+
_recursiveCloneAndMaskValuesOfKeys(source, keys, seen = []) {
|
|
9164
|
+
if (seen.includes(source)) {
|
|
9165
|
+
return { ...source };
|
|
9166
|
+
}
|
|
9167
|
+
if (typeof source === "object" && source !== null) {
|
|
9168
|
+
seen.push(source);
|
|
9169
|
+
}
|
|
9170
|
+
if (this.runtime.isError(source) || this.runtime.isBuffer(source)) {
|
|
9171
|
+
return source;
|
|
9172
|
+
}
|
|
9173
|
+
else if (source instanceof Map) {
|
|
9174
|
+
return new Map(source);
|
|
9175
|
+
}
|
|
9176
|
+
else if (source instanceof Set) {
|
|
9177
|
+
return new Set(source);
|
|
9178
|
+
}
|
|
9179
|
+
else if (Array.isArray(source)) {
|
|
9180
|
+
return source.map((item) => this._recursiveCloneAndMaskValuesOfKeys(item, keys, seen));
|
|
9181
|
+
}
|
|
9182
|
+
else if (source instanceof Date) {
|
|
9183
|
+
return new Date(source.getTime());
|
|
9184
|
+
}
|
|
9185
|
+
else if (source instanceof URL) {
|
|
9186
|
+
return urlToObject(source);
|
|
9187
|
+
}
|
|
9188
|
+
else if (source !== null && typeof source === "object") {
|
|
9189
|
+
const baseObject = this.runtime.isError(source) ? this._cloneError(source) : Object.create(Object.getPrototypeOf(source));
|
|
9190
|
+
return Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
9191
|
+
o[prop] = keys.includes(this.settings?.maskValuesOfKeysCaseInsensitive !== true ? prop : prop.toLowerCase())
|
|
9192
|
+
? this.settings.maskPlaceholder
|
|
9193
|
+
: (() => {
|
|
9194
|
+
try {
|
|
9195
|
+
return this._recursiveCloneAndMaskValuesOfKeys(source[prop], keys, seen);
|
|
9196
|
+
}
|
|
9197
|
+
catch (e) {
|
|
9198
|
+
return null;
|
|
9199
|
+
}
|
|
9200
|
+
})();
|
|
9201
|
+
return o;
|
|
9202
|
+
}, baseObject);
|
|
9203
|
+
}
|
|
9204
|
+
else {
|
|
9205
|
+
if (typeof source === "string") {
|
|
9206
|
+
let modifiedSource = source;
|
|
9207
|
+
for (const regEx of this.settings?.maskValuesRegEx || []) {
|
|
9208
|
+
modifiedSource = modifiedSource.replace(regEx, this.settings?.maskPlaceholder || "");
|
|
9209
|
+
}
|
|
9210
|
+
return modifiedSource;
|
|
9211
|
+
}
|
|
9212
|
+
return source;
|
|
9213
|
+
}
|
|
9214
|
+
}
|
|
9215
|
+
_recursiveCloneAndExecuteFunctions(source, seen = []) {
|
|
9216
|
+
if (this.isObjectOrArray(source) && seen.includes(source)) {
|
|
9217
|
+
return this.shallowCopy(source);
|
|
9218
|
+
}
|
|
9219
|
+
if (this.isObjectOrArray(source)) {
|
|
9220
|
+
seen.push(source);
|
|
9221
|
+
}
|
|
9222
|
+
if (Array.isArray(source)) {
|
|
9223
|
+
return source.map((item) => this._recursiveCloneAndExecuteFunctions(item, seen));
|
|
9224
|
+
}
|
|
9225
|
+
else if (source instanceof Date) {
|
|
9226
|
+
return new Date(source.getTime());
|
|
9227
|
+
}
|
|
9228
|
+
else if (this.isObject(source)) {
|
|
9229
|
+
return Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
9230
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, prop);
|
|
9231
|
+
if (descriptor) {
|
|
9232
|
+
Object.defineProperty(o, prop, descriptor);
|
|
9233
|
+
const value = source[prop];
|
|
9234
|
+
o[prop] = typeof value === "function" ? value() : this._recursiveCloneAndExecuteFunctions(value, seen);
|
|
9235
|
+
}
|
|
9236
|
+
return o;
|
|
9237
|
+
}, Object.create(Object.getPrototypeOf(source)));
|
|
9238
|
+
}
|
|
9239
|
+
else {
|
|
9240
|
+
return source;
|
|
9241
|
+
}
|
|
9242
|
+
}
|
|
9243
|
+
isObjectOrArray(value) {
|
|
9244
|
+
return typeof value === "object" && value !== null;
|
|
9245
|
+
}
|
|
9246
|
+
isObject(value) {
|
|
9247
|
+
return typeof value === "object" && !Array.isArray(value) && value !== null;
|
|
9248
|
+
}
|
|
9249
|
+
shallowCopy(source) {
|
|
9250
|
+
if (Array.isArray(source)) {
|
|
9251
|
+
return [...source];
|
|
9252
|
+
}
|
|
9253
|
+
else {
|
|
9254
|
+
return { ...source };
|
|
9255
|
+
}
|
|
9256
|
+
}
|
|
9257
|
+
_toLogObj(args, clonedLogObj = {}) {
|
|
9258
|
+
args = args?.map((arg) => (this.runtime.isError(arg) ? this._toErrorObject(arg) : arg));
|
|
9259
|
+
if (this.settings.argumentsArrayName == null) {
|
|
9260
|
+
if (args.length === 1 && !Array.isArray(args[0]) && this.runtime.isBuffer(args[0]) !== true && !(args[0] instanceof Date)) {
|
|
9261
|
+
clonedLogObj = typeof args[0] === "object" && args[0] != null ? { ...args[0], ...clonedLogObj } : { 0: args[0], ...clonedLogObj };
|
|
9262
|
+
}
|
|
9263
|
+
else {
|
|
9264
|
+
clonedLogObj = { ...clonedLogObj, ...args };
|
|
9265
|
+
}
|
|
9266
|
+
}
|
|
9267
|
+
else {
|
|
9268
|
+
clonedLogObj = {
|
|
9269
|
+
...clonedLogObj,
|
|
9270
|
+
[this.settings.argumentsArrayName]: args,
|
|
9271
|
+
};
|
|
9272
|
+
}
|
|
9273
|
+
return clonedLogObj;
|
|
9274
|
+
}
|
|
9275
|
+
_cloneError(error) {
|
|
9276
|
+
const cloned = new error.constructor();
|
|
9277
|
+
Object.getOwnPropertyNames(error).forEach((key) => {
|
|
9278
|
+
cloned[key] = error[key];
|
|
9279
|
+
});
|
|
9280
|
+
return cloned;
|
|
9281
|
+
}
|
|
9282
|
+
_toErrorObject(error) {
|
|
9283
|
+
return {
|
|
9284
|
+
nativeError: error,
|
|
9285
|
+
name: error.name ?? "Error",
|
|
9286
|
+
message: error.message,
|
|
9287
|
+
stack: this.runtime.getErrorTrace(error),
|
|
9288
|
+
};
|
|
9289
|
+
}
|
|
9290
|
+
_addMetaToLogObj(logObj, logLevelId, logLevelName) {
|
|
9291
|
+
return {
|
|
9292
|
+
...logObj,
|
|
9293
|
+
[this.settings.metaProperty]: this.runtime.getMeta(logLevelId, logLevelName, this.stackDepthLevel, this.settings.hideLogPositionForProduction, this.settings.name, this.settings.parentNames),
|
|
9294
|
+
};
|
|
9295
|
+
}
|
|
9296
|
+
_prettyFormatLogObjMeta(logObjMeta) {
|
|
9297
|
+
if (logObjMeta == null) {
|
|
9298
|
+
return "";
|
|
9299
|
+
}
|
|
9300
|
+
let template = this.settings.prettyLogTemplate;
|
|
9301
|
+
const placeholderValues = {};
|
|
9302
|
+
if (template.includes("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}")) {
|
|
9303
|
+
template = template.replace("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}", "{{dateIsoStr}}");
|
|
9304
|
+
}
|
|
9305
|
+
else {
|
|
9306
|
+
if (this.settings.prettyLogTimeZone === "UTC") {
|
|
9307
|
+
placeholderValues["yyyy"] = logObjMeta?.date?.getUTCFullYear() ?? "----";
|
|
9308
|
+
placeholderValues["mm"] = formatNumberAddZeros(logObjMeta?.date?.getUTCMonth(), 2, 1);
|
|
9309
|
+
placeholderValues["dd"] = formatNumberAddZeros(logObjMeta?.date?.getUTCDate(), 2);
|
|
9310
|
+
placeholderValues["hh"] = formatNumberAddZeros(logObjMeta?.date?.getUTCHours(), 2);
|
|
9311
|
+
placeholderValues["MM"] = formatNumberAddZeros(logObjMeta?.date?.getUTCMinutes(), 2);
|
|
9312
|
+
placeholderValues["ss"] = formatNumberAddZeros(logObjMeta?.date?.getUTCSeconds(), 2);
|
|
9313
|
+
placeholderValues["ms"] = formatNumberAddZeros(logObjMeta?.date?.getUTCMilliseconds(), 3);
|
|
9314
|
+
}
|
|
9315
|
+
else {
|
|
9316
|
+
placeholderValues["yyyy"] = logObjMeta?.date?.getFullYear() ?? "----";
|
|
9317
|
+
placeholderValues["mm"] = formatNumberAddZeros(logObjMeta?.date?.getMonth(), 2, 1);
|
|
9318
|
+
placeholderValues["dd"] = formatNumberAddZeros(logObjMeta?.date?.getDate(), 2);
|
|
9319
|
+
placeholderValues["hh"] = formatNumberAddZeros(logObjMeta?.date?.getHours(), 2);
|
|
9320
|
+
placeholderValues["MM"] = formatNumberAddZeros(logObjMeta?.date?.getMinutes(), 2);
|
|
9321
|
+
placeholderValues["ss"] = formatNumberAddZeros(logObjMeta?.date?.getSeconds(), 2);
|
|
9322
|
+
placeholderValues["ms"] = formatNumberAddZeros(logObjMeta?.date?.getMilliseconds(), 3);
|
|
9323
|
+
}
|
|
9324
|
+
}
|
|
9325
|
+
const dateInSettingsTimeZone = this.settings.prettyLogTimeZone === "UTC" ? logObjMeta?.date : new Date(logObjMeta?.date?.getTime() - logObjMeta?.date?.getTimezoneOffset() * 60000);
|
|
9326
|
+
placeholderValues["rawIsoStr"] = dateInSettingsTimeZone?.toISOString();
|
|
9327
|
+
placeholderValues["dateIsoStr"] = dateInSettingsTimeZone?.toISOString().replace("T", " ").replace("Z", "");
|
|
9328
|
+
placeholderValues["logLevelName"] = logObjMeta?.logLevelName;
|
|
9329
|
+
placeholderValues["fileNameWithLine"] = logObjMeta?.path?.fileNameWithLine ?? "";
|
|
9330
|
+
placeholderValues["filePathWithLine"] = logObjMeta?.path?.filePathWithLine ?? "";
|
|
9331
|
+
placeholderValues["fullFilePath"] = logObjMeta?.path?.fullFilePath ?? "";
|
|
9332
|
+
let parentNamesString = this.settings.parentNames?.join(this.settings.prettyErrorParentNamesSeparator);
|
|
9333
|
+
parentNamesString = parentNamesString != null && logObjMeta?.name != null ? parentNamesString + this.settings.prettyErrorParentNamesSeparator : undefined;
|
|
9334
|
+
placeholderValues["name"] = logObjMeta?.name != null || parentNamesString != null ? (parentNamesString ?? "") + logObjMeta?.name ?? "" : "";
|
|
9335
|
+
placeholderValues["nameWithDelimiterPrefix"] =
|
|
9336
|
+
placeholderValues["name"].length > 0 ? this.settings.prettyErrorLoggerNameDelimiter + placeholderValues["name"] : "";
|
|
9337
|
+
placeholderValues["nameWithDelimiterSuffix"] =
|
|
9338
|
+
placeholderValues["name"].length > 0 ? placeholderValues["name"] + this.settings.prettyErrorLoggerNameDelimiter : "";
|
|
9339
|
+
if (this.settings.overwrite?.addPlaceholders != null) {
|
|
9340
|
+
this.settings.overwrite?.addPlaceholders(logObjMeta, placeholderValues);
|
|
9341
|
+
}
|
|
9342
|
+
return formatTemplate(this.settings, template, placeholderValues);
|
|
9343
|
+
}
|
|
9344
|
+
}
|
|
9345
|
+
|
|
9346
|
+
class Logger extends BaseLogger {
|
|
9347
|
+
constructor(settings, logObj) {
|
|
9348
|
+
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
9349
|
+
const isBrowserBlinkEngine = isBrowser ? window.chrome !== undefined && window.CSS !== undefined && window.CSS.supports("color", "green") : false;
|
|
9350
|
+
const isSafari = isBrowser ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
|
|
9351
|
+
settings = settings || {};
|
|
9352
|
+
settings.stylePrettyLogs = settings.stylePrettyLogs && isBrowser && !isBrowserBlinkEngine ? false : settings.stylePrettyLogs;
|
|
9353
|
+
super(settings, logObj, isSafari ? 4 : 5);
|
|
9354
|
+
}
|
|
9355
|
+
log(logLevelId, logLevelName, ...args) {
|
|
9356
|
+
return super.log(logLevelId, logLevelName, ...args);
|
|
9357
|
+
}
|
|
9358
|
+
silly(...args) {
|
|
9359
|
+
return super.log(0, "SILLY", ...args);
|
|
9360
|
+
}
|
|
9361
|
+
trace(...args) {
|
|
9362
|
+
return super.log(1, "TRACE", ...args);
|
|
9363
|
+
}
|
|
9364
|
+
debug(...args) {
|
|
9365
|
+
return super.log(2, "DEBUG", ...args);
|
|
9366
|
+
}
|
|
9367
|
+
info(...args) {
|
|
9368
|
+
return super.log(3, "INFO", ...args);
|
|
9369
|
+
}
|
|
9370
|
+
warn(...args) {
|
|
9371
|
+
return super.log(4, "WARN", ...args);
|
|
9372
|
+
}
|
|
9373
|
+
error(...args) {
|
|
9374
|
+
return super.log(5, "ERROR", ...args);
|
|
9375
|
+
}
|
|
9376
|
+
fatal(...args) {
|
|
9377
|
+
return super.log(6, "FATAL", ...args);
|
|
9378
|
+
}
|
|
9379
|
+
getSubLogger(settings, logObj) {
|
|
9380
|
+
return super.getSubLogger(settings, logObj);
|
|
9381
|
+
}
|
|
9382
|
+
}
|
|
9383
|
+
|
|
9384
|
+
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
9385
|
+
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
9386
|
+
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
9387
|
+
console.log(logMetaMarkup, ...logArgs, logErrorsStr);
|
|
9388
|
+
}
|
|
9389
|
+
function formatMeta(logObjMeta) {
|
|
9390
|
+
if (!logObjMeta) {
|
|
9391
|
+
return '';
|
|
9392
|
+
}
|
|
9393
|
+
const { date, logLevelName } = logObjMeta;
|
|
9394
|
+
const year = date.getFullYear();
|
|
9395
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
9396
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
9397
|
+
const hours = String(date.getHours()).padStart(2, '0');
|
|
9398
|
+
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
9399
|
+
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
9400
|
+
const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
|
|
9401
|
+
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
|
|
9402
|
+
const loggerName = logObjMeta.name;
|
|
9403
|
+
return `${formattedDate} ${logLevelName} ${loggerName}`;
|
|
9404
|
+
}
|
|
9405
|
+
const logger$1 = new Logger({
|
|
9406
|
+
name: "ekoLogger",
|
|
9407
|
+
overwrite: {
|
|
9408
|
+
transportFormatted,
|
|
9409
|
+
formatMeta,
|
|
9410
|
+
}
|
|
9411
|
+
});
|
|
9412
|
+
|
|
8785
9413
|
class OpenaiProvider {
|
|
8786
9414
|
constructor(param, defaultModel, options) {
|
|
8787
9415
|
this.defaultModel = 'gpt-4o';
|
|
@@ -8791,7 +9419,7 @@ class OpenaiProvider {
|
|
|
8791
9419
|
if (typeof window !== 'undefined' &&
|
|
8792
9420
|
typeof document !== 'undefined' &&
|
|
8793
9421
|
(typeof param == 'string' || param.apiKey)) {
|
|
8794
|
-
|
|
9422
|
+
logger$1.warn(`
|
|
8795
9423
|
⚠️ Security Warning:
|
|
8796
9424
|
DO NOT use API Keys in browser/frontend code!
|
|
8797
9425
|
This will expose your credentials and may lead to unauthorized usage.
|
|
@@ -9065,7 +9693,7 @@ class OpenaiProvider {
|
|
|
9065
9693
|
if (choice.finish_reason) {
|
|
9066
9694
|
stop_reason = choice.finish_reason;
|
|
9067
9695
|
if (currentToolUse) {
|
|
9068
|
-
|
|
9696
|
+
logger$1.debug("currentToolUse.accumulatedJson=", currentToolUse.accumulatedJson);
|
|
9069
9697
|
const toolCall = {
|
|
9070
9698
|
id: currentToolUse.id,
|
|
9071
9699
|
name: currentToolUse.name,
|
|
@@ -9159,7 +9787,7 @@ class ExecutionLogger {
|
|
|
9159
9787
|
if (this.shouldLog(level)) {
|
|
9160
9788
|
const timestamp = this.includeTimestamp ? new Date().toISOString() : '';
|
|
9161
9789
|
const contextSummary = this.summarizeContext(context);
|
|
9162
|
-
|
|
9790
|
+
logger$1.debug(`${timestamp} [${level.toUpperCase()}] ${message}${contextSummary}`);
|
|
9163
9791
|
}
|
|
9164
9792
|
}
|
|
9165
9793
|
/**
|
|
@@ -9227,7 +9855,7 @@ class ExecutionLogger {
|
|
|
9227
9855
|
* Logs an error that occurred during execution
|
|
9228
9856
|
*/
|
|
9229
9857
|
logError(error, context) {
|
|
9230
|
-
|
|
9858
|
+
logger$1.error(error);
|
|
9231
9859
|
try {
|
|
9232
9860
|
this.log('error', `Error occurred: ${error.message}`, context);
|
|
9233
9861
|
if (error.stack) {
|
|
@@ -9235,8 +9863,8 @@ class ExecutionLogger {
|
|
|
9235
9863
|
}
|
|
9236
9864
|
}
|
|
9237
9865
|
catch (error) {
|
|
9238
|
-
|
|
9239
|
-
|
|
9866
|
+
logger$1.error("An error occurs when trying to log another error:");
|
|
9867
|
+
logger$1.error(error);
|
|
9240
9868
|
}
|
|
9241
9869
|
}
|
|
9242
9870
|
extractFromDataUrl(dataUrl) {
|
|
@@ -9289,7 +9917,7 @@ class ExecutionLogger {
|
|
|
9289
9917
|
return '[image]';
|
|
9290
9918
|
}
|
|
9291
9919
|
catch (error) {
|
|
9292
|
-
|
|
9920
|
+
logger$1.warn('Failed to save debug image:', error);
|
|
9293
9921
|
return '[image]';
|
|
9294
9922
|
}
|
|
9295
9923
|
}
|
|
@@ -9328,7 +9956,7 @@ class ExecutionLogger {
|
|
|
9328
9956
|
const timestamp = this.includeTimestamp ? new Date().toISOString() : '';
|
|
9329
9957
|
const contextSummary = this.summarizeContext(context);
|
|
9330
9958
|
const formattedResult = await this.formatToolResult(result);
|
|
9331
|
-
|
|
9959
|
+
logger$1.debug(`${timestamp} [INFO] Tool executed: ${toolName}\n` +
|
|
9332
9960
|
`${timestamp} [INFO] Tool result: ${formattedResult}${contextSummary}`);
|
|
9333
9961
|
}
|
|
9334
9962
|
}
|
|
@@ -9361,7 +9989,7 @@ ${JSON.stringify(nodeOutputs)}
|
|
|
9361
9989
|
`,
|
|
9362
9990
|
},
|
|
9363
9991
|
];
|
|
9364
|
-
|
|
9992
|
+
logger$1.debug(messages);
|
|
9365
9993
|
const params = {
|
|
9366
9994
|
temperature: 0.7,
|
|
9367
9995
|
maxTokens: 8192,
|
|
@@ -9392,9 +10020,9 @@ ${JSON.stringify(nodeOutputs)}
|
|
|
9392
10020
|
}],
|
|
9393
10021
|
toolChoice: { type: 'tool', name: 'summarize_workflow' },
|
|
9394
10022
|
};
|
|
9395
|
-
|
|
10023
|
+
logger$1.debug(params);
|
|
9396
10024
|
const response = await llmProvider.generateText(messages, params);
|
|
9397
|
-
|
|
10025
|
+
logger$1.debug(response);
|
|
9398
10026
|
return {
|
|
9399
10027
|
isSuccessful: contextVariables.get("__isSuccessful__"),
|
|
9400
10028
|
summary: response.toolCalls[0].input.summary,
|
|
@@ -9493,9 +10121,7 @@ class WorkflowImpl {
|
|
|
9493
10121
|
const action_executing_result = await node.action.execute(node.input, node.output, context);
|
|
9494
10122
|
node.output.value = action_executing_result.nodeOutput;
|
|
9495
10123
|
const action_reacts = action_executing_result.reacts;
|
|
9496
|
-
|
|
9497
|
-
console.log(action_reacts);
|
|
9498
|
-
console.log("debug `action_reacts`...done");
|
|
10124
|
+
logger$1.debug("debug `action_reacts`...", action_reacts);
|
|
9499
10125
|
executing.delete(nodeId);
|
|
9500
10126
|
executed.add(nodeId);
|
|
9501
10127
|
callback && await ((_d = (_c = callback.hooks).afterSubtask) === null || _d === void 0 ? void 0 : _d.call(_c, node, context, (_e = node.output) === null || _e === void 0 ? void 0 : _e.value));
|
|
@@ -9511,12 +10137,10 @@ class WorkflowImpl {
|
|
|
9511
10137
|
workflowSummary = await summarizeWorkflow(this.llmProvider, this, this.variables, node_outputs);
|
|
9512
10138
|
}
|
|
9513
10139
|
else {
|
|
9514
|
-
|
|
10140
|
+
logger$1.warn("WorkflowImpl.llmProvider is undefined, cannot generate workflow summary");
|
|
9515
10141
|
}
|
|
9516
|
-
// Special context variables
|
|
9517
|
-
console.log("debug special context variables...");
|
|
9518
10142
|
let workflowPayload = this.variables.get("workflow_transcript");
|
|
9519
|
-
|
|
10143
|
+
logger$1.debug("workflowPayload", workflowPayload);
|
|
9520
10144
|
if (!workflowPayload) {
|
|
9521
10145
|
workflowPayload = workflowSummary === null || workflowSummary === void 0 ? void 0 : workflowSummary.payload;
|
|
9522
10146
|
}
|
|
@@ -9639,13 +10263,11 @@ function createReturnTool(actionName, outputDescription, outputSchema) {
|
|
|
9639
10263
|
description: 'The output value. Only provide a value if the previous tool result is not suitable for the output description. Otherwise, leave this as null.',
|
|
9640
10264
|
},
|
|
9641
10265
|
},
|
|
9642
|
-
required: ['use_tool_result', 'value'],
|
|
10266
|
+
required: ['isSuccessful', 'use_tool_result', 'value'],
|
|
9643
10267
|
},
|
|
9644
10268
|
async execute(context, params) {
|
|
9645
10269
|
context.variables.set(`__action_${actionName}_output`, params);
|
|
9646
|
-
console.
|
|
9647
|
-
console.log(params);
|
|
9648
|
-
console.info('debug the output...done');
|
|
10270
|
+
console.debug('debug the output...', params);
|
|
9649
10271
|
context.variables.set("__isSuccessful__", params.isSuccessful);
|
|
9650
10272
|
return { success: true };
|
|
9651
10273
|
},
|
|
@@ -9678,7 +10300,6 @@ class ActionImpl {
|
|
|
9678
10300
|
let params_copy = JSON.parse(JSON.stringify(params));
|
|
9679
10301
|
params_copy.tools = (_a = params_copy.tools) === null || _a === void 0 ? void 0 : _a.map(this.wrapToolInputSchema);
|
|
9680
10302
|
while (!((_b = context.signal) === null || _b === void 0 ? void 0 : _b.aborted)) {
|
|
9681
|
-
this.logger = context.logger;
|
|
9682
10303
|
roundMessages = [];
|
|
9683
10304
|
hasToolUse = false;
|
|
9684
10305
|
response = null;
|
|
@@ -9701,8 +10322,13 @@ class ActionImpl {
|
|
|
9701
10322
|
}
|
|
9702
10323
|
},
|
|
9703
10324
|
onToolUse: async (toolCall) => {
|
|
9704
|
-
|
|
9705
|
-
|
|
10325
|
+
logger$1.info("toolCall start", {
|
|
10326
|
+
assistant: assistantTextMessage,
|
|
10327
|
+
toolCall: {
|
|
10328
|
+
name: toolCall.name,
|
|
10329
|
+
input: toolCall.input,
|
|
10330
|
+
},
|
|
10331
|
+
});
|
|
9706
10332
|
hasToolUse = true;
|
|
9707
10333
|
const tool = toolMap.get(toolCall.name);
|
|
9708
10334
|
if (!tool) {
|
|
@@ -9742,7 +10368,7 @@ class ActionImpl {
|
|
|
9742
10368
|
};
|
|
9743
10369
|
// Store the promise of tool execution
|
|
9744
10370
|
toolExecutionPromise = (async () => {
|
|
9745
|
-
var _a, _b, _c, _d;
|
|
10371
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
9746
10372
|
try {
|
|
9747
10373
|
// beforeToolUse
|
|
9748
10374
|
context.__skip = false;
|
|
@@ -9768,12 +10394,18 @@ class ActionImpl {
|
|
|
9768
10394
|
// unwrap the toolCall
|
|
9769
10395
|
let unwrapped = this.unwrapToolCall(toolCall);
|
|
9770
10396
|
let input = unwrapped.toolCall.input;
|
|
9771
|
-
|
|
10397
|
+
logger$1.debug("unwrapped", unwrapped);
|
|
10398
|
+
if (unwrapped.thinking) {
|
|
10399
|
+
(_d = (_b = context.callback) === null || _b === void 0 ? void 0 : (_c = _b.hooks).onLlmMessage) === null || _d === void 0 ? void 0 : _d.call(_c, unwrapped.thinking);
|
|
10400
|
+
}
|
|
10401
|
+
else {
|
|
10402
|
+
logger$1.warn("LLM returns without `userSidePrompt`");
|
|
10403
|
+
}
|
|
9772
10404
|
if (unwrapped.userSidePrompt) {
|
|
9773
|
-
(
|
|
10405
|
+
(_g = (_e = context.callback) === null || _e === void 0 ? void 0 : (_f = _e.hooks).onLlmMessageUserSidePrompt) === null || _g === void 0 ? void 0 : _g.call(_f, unwrapped.userSidePrompt, toolCall.name);
|
|
9774
10406
|
}
|
|
9775
10407
|
else {
|
|
9776
|
-
|
|
10408
|
+
logger$1.warn("LLM returns without `userSidePrompt`");
|
|
9777
10409
|
}
|
|
9778
10410
|
// Execute the tool
|
|
9779
10411
|
let result = await tool.execute(context, input);
|
|
@@ -9811,15 +10443,30 @@ class ActionImpl {
|
|
|
9811
10443
|
content: [resultContent],
|
|
9812
10444
|
};
|
|
9813
10445
|
toolResultMessage = resultMessage;
|
|
9814
|
-
|
|
10446
|
+
const truncate = (x) => {
|
|
10447
|
+
const s = JSON.stringify(x);
|
|
10448
|
+
const maxLength = 1000;
|
|
10449
|
+
if (s.length < maxLength) {
|
|
10450
|
+
return x;
|
|
10451
|
+
}
|
|
10452
|
+
else {
|
|
10453
|
+
return s.slice(0, maxLength) + "...(truncated)";
|
|
10454
|
+
}
|
|
10455
|
+
};
|
|
10456
|
+
logger$1.info("toolCall done", {
|
|
10457
|
+
toolCall: {
|
|
10458
|
+
name: tool.name,
|
|
10459
|
+
result: truncate(result),
|
|
10460
|
+
},
|
|
10461
|
+
});
|
|
9815
10462
|
// Store tool results except for the return_output tool
|
|
9816
10463
|
if (tool.name !== 'return_output') {
|
|
9817
10464
|
this.toolResults.set(toolCall.id, resultContentText);
|
|
9818
10465
|
}
|
|
9819
10466
|
}
|
|
9820
10467
|
catch (err) {
|
|
9821
|
-
|
|
9822
|
-
|
|
10468
|
+
logger$1.error('An error occurred when calling tool:');
|
|
10469
|
+
logger$1.error(err);
|
|
9823
10470
|
const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred';
|
|
9824
10471
|
const errorResult = {
|
|
9825
10472
|
role: 'user',
|
|
@@ -9833,7 +10480,6 @@ class ActionImpl {
|
|
|
9833
10480
|
],
|
|
9834
10481
|
};
|
|
9835
10482
|
toolResultMessage = errorResult;
|
|
9836
|
-
this.logger.logError(err, context);
|
|
9837
10483
|
}
|
|
9838
10484
|
})();
|
|
9839
10485
|
},
|
|
@@ -9841,8 +10487,8 @@ class ActionImpl {
|
|
|
9841
10487
|
response = llmResponse;
|
|
9842
10488
|
},
|
|
9843
10489
|
onError: (error) => {
|
|
9844
|
-
|
|
9845
|
-
|
|
10490
|
+
logger$1.error('Stream Error:', error);
|
|
10491
|
+
logger$1.debug('Last message array sent to LLM:', JSON.stringify(messages, null, 2));
|
|
9846
10492
|
throw error;
|
|
9847
10493
|
},
|
|
9848
10494
|
};
|
|
@@ -9855,8 +10501,7 @@ class ActionImpl {
|
|
|
9855
10501
|
await this.llmProvider.generateStream(messages, params_copy, handler);
|
|
9856
10502
|
}
|
|
9857
10503
|
catch (e) {
|
|
9858
|
-
|
|
9859
|
-
console.warn(e);
|
|
10504
|
+
logger$1.warn("an error occurs when LLM generate response, retry...", e);
|
|
9860
10505
|
continue;
|
|
9861
10506
|
}
|
|
9862
10507
|
// Wait for tool execution to complete if it was started
|
|
@@ -9911,7 +10556,7 @@ class ActionImpl {
|
|
|
9911
10556
|
}
|
|
9912
10557
|
const finalImageCount = this.countImages(messages);
|
|
9913
10558
|
if (initialImageCount !== finalImageCount) {
|
|
9914
|
-
|
|
10559
|
+
logger$1.debug(`Removed ${initialImageCount - finalImageCount} images from history`);
|
|
9915
10560
|
}
|
|
9916
10561
|
}
|
|
9917
10562
|
countImages(messages) {
|
|
@@ -9928,9 +10573,8 @@ class ActionImpl {
|
|
|
9928
10573
|
return count;
|
|
9929
10574
|
}
|
|
9930
10575
|
async execute(input, output, context, outputSchema) {
|
|
9931
|
-
var _a, _b
|
|
9932
|
-
|
|
9933
|
-
console.log(`Executing action started: ${this.name}`);
|
|
10576
|
+
var _a, _b;
|
|
10577
|
+
logger$1.debug(`Executing action started: ${this.name}`);
|
|
9934
10578
|
// Create return tool with output schema
|
|
9935
10579
|
const returnTool = createReturnTool(this.name, output.description, outputSchema);
|
|
9936
10580
|
// Create tool map combining context tools, action tools, and return tool
|
|
@@ -9943,15 +10587,25 @@ class ActionImpl {
|
|
|
9943
10587
|
const existingTabs = await context.ekoConfig.chromeProxy.tabs.query({
|
|
9944
10588
|
windowId: currentWindow.id,
|
|
9945
10589
|
});
|
|
10590
|
+
// get patchs for task
|
|
10591
|
+
let patchs = [];
|
|
10592
|
+
if (context.ekoConfig.patchServerUrl) {
|
|
10593
|
+
patchs = await this.getPatchs(this.name, context.ekoConfig.patchServerUrl);
|
|
10594
|
+
}
|
|
9946
10595
|
// Prepare initial messages
|
|
9947
10596
|
const messages = [
|
|
9948
10597
|
{ role: 'system', content: this.formatSystemPrompt() },
|
|
9949
10598
|
{
|
|
9950
10599
|
role: 'user',
|
|
9951
|
-
content: this.formatUserPrompt(this.name, this.description, this.tabs, existingTabs),
|
|
10600
|
+
content: this.formatUserPrompt(this.name, this.description, this.tabs, existingTabs, patchs),
|
|
9952
10601
|
},
|
|
9953
10602
|
];
|
|
9954
|
-
|
|
10603
|
+
logger$1.info("action start", {
|
|
10604
|
+
action: {
|
|
10605
|
+
name: this.name,
|
|
10606
|
+
input,
|
|
10607
|
+
},
|
|
10608
|
+
});
|
|
9955
10609
|
// Configure tool parameters
|
|
9956
10610
|
const params = {
|
|
9957
10611
|
...this.llmConfig,
|
|
@@ -9968,19 +10622,15 @@ class ActionImpl {
|
|
|
9968
10622
|
throw new Error('Workflow cancelled');
|
|
9969
10623
|
}
|
|
9970
10624
|
roundCount++;
|
|
9971
|
-
|
|
10625
|
+
logger$1.info(`Starting round ${roundCount} of ${this.maxRounds}`);
|
|
9972
10626
|
const { response, hasToolUse, roundMessages } = await this.executeSingleRound(messages, params, toolMap, context);
|
|
9973
|
-
if (response === null || response === void 0 ? void 0 : response.textContent) {
|
|
9974
|
-
(_e = (_d = (_c = context.callback) === null || _c === void 0 ? void 0 : _c.hooks) === null || _d === void 0 ? void 0 : _d.onLlmMessage) === null || _e === void 0 ? void 0 : _e.call(_d, response.textContent);
|
|
9975
|
-
}
|
|
9976
10627
|
// Add round messages to conversation history
|
|
9977
10628
|
messages.push(...roundMessages);
|
|
9978
|
-
this.logger.log('debug', `Round ${roundCount} messages: ${JSON.stringify(roundMessages)}`, context);
|
|
9979
10629
|
// Check termination conditions
|
|
9980
10630
|
if (!hasToolUse && response) {
|
|
9981
10631
|
// LLM sent a message without using tools - request explicit return
|
|
9982
|
-
|
|
9983
|
-
|
|
10632
|
+
logger$1.info(`Assistant: ${response.textContent}`);
|
|
10633
|
+
logger$1.warn('LLM sent a message without using tools; requesting explicit return');
|
|
9984
10634
|
const returnOnlyParams = {
|
|
9985
10635
|
...params,
|
|
9986
10636
|
tools: [
|
|
@@ -10004,7 +10654,7 @@ class ActionImpl {
|
|
|
10004
10654
|
}
|
|
10005
10655
|
// If this is the last round, force an explicit return
|
|
10006
10656
|
if (roundCount === this.maxRounds) {
|
|
10007
|
-
|
|
10657
|
+
logger$1.warn('Max rounds reached, requesting explicit return');
|
|
10008
10658
|
const returnOnlyParams = {
|
|
10009
10659
|
...params,
|
|
10010
10660
|
tools: [
|
|
@@ -10027,7 +10677,7 @@ class ActionImpl {
|
|
|
10027
10677
|
const outputKey = `__action_${this.name}_output`;
|
|
10028
10678
|
const outputParams = context.variables.get(outputKey);
|
|
10029
10679
|
if (!outputParams) {
|
|
10030
|
-
|
|
10680
|
+
logger$1.warn('outputParams is `undefined`, action return `{}`');
|
|
10031
10681
|
return { nodeOutput: {}, reacts: messages };
|
|
10032
10682
|
}
|
|
10033
10683
|
context.variables.delete(outputKey);
|
|
@@ -10036,7 +10686,7 @@ class ActionImpl {
|
|
|
10036
10686
|
? Array.from(this.toolResults.values()).pop()
|
|
10037
10687
|
: outputParams === null || outputParams === void 0 ? void 0 : outputParams.value;
|
|
10038
10688
|
if (outputValue === undefined) {
|
|
10039
|
-
|
|
10689
|
+
logger$1.warn('Action completed without returning a value');
|
|
10040
10690
|
return { nodeOutput: {}, reacts: messages };
|
|
10041
10691
|
}
|
|
10042
10692
|
return { nodeOutput: outputValue, reacts: messages };
|
|
@@ -10044,7 +10694,7 @@ class ActionImpl {
|
|
|
10044
10694
|
formatSystemPrompt() {
|
|
10045
10695
|
const now = new Date();
|
|
10046
10696
|
const formattedTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
|
|
10047
|
-
|
|
10697
|
+
logger$1.debug('Now is ' + formattedTime);
|
|
10048
10698
|
return `You are an AI agent designed to automate browser tasks. Your goal is to accomplish the ultimate task following the rules. Now is ${formattedTime}.
|
|
10049
10699
|
|
|
10050
10700
|
## GENERIC:
|
|
@@ -10121,7 +10771,7 @@ Navigation Bar or Menu Changes: After logging in, the navigation bar will includ
|
|
|
10121
10771
|
- DO NOT REFUSE TO PERFORM THE MISSION
|
|
10122
10772
|
`;
|
|
10123
10773
|
}
|
|
10124
|
-
formatUserPrompt(name, description, mentionedTabs, existingTabs) {
|
|
10774
|
+
formatUserPrompt(name, description, mentionedTabs, existingTabs, patchItems) {
|
|
10125
10775
|
let prompt = `${name} -- The steps you can follow are ${description}`;
|
|
10126
10776
|
prompt = `Your ultimate task is: """${prompt}""". If you achieved your ultimate task, stop everything and use the done action in the next step to complete the task. If not, continue as usual.`;
|
|
10127
10777
|
if (existingTabs.length > 0) {
|
|
@@ -10134,8 +10784,37 @@ Navigation Bar or Menu Changes: After logging in, the navigation bar will includ
|
|
|
10134
10784
|
'\n\nYou should consider the following tabs firstly:\n' +
|
|
10135
10785
|
mentionedTabs.map((tab) => `- TabID=${tab.id}: ${tab.title} (${tab.url})`).join('\n');
|
|
10136
10786
|
}
|
|
10787
|
+
if (patchItems.length > 0) {
|
|
10788
|
+
prompt +=
|
|
10789
|
+
'\n\You can refer to the following cases and tips:\n' +
|
|
10790
|
+
patchItems.map((item) => `<task>${item.task}</task><tips>${item.patch}</tips>`).join('\n');
|
|
10791
|
+
}
|
|
10137
10792
|
return prompt;
|
|
10138
10793
|
}
|
|
10794
|
+
async getPatchs(task, patchServerUrl) {
|
|
10795
|
+
const form = {
|
|
10796
|
+
task,
|
|
10797
|
+
top_k: 3,
|
|
10798
|
+
};
|
|
10799
|
+
try {
|
|
10800
|
+
const response = await fetch(`${patchServerUrl}/search`, {
|
|
10801
|
+
method: 'POST',
|
|
10802
|
+
headers: {
|
|
10803
|
+
'Content-Type': 'application/json',
|
|
10804
|
+
},
|
|
10805
|
+
body: JSON.stringify(form),
|
|
10806
|
+
});
|
|
10807
|
+
if (!response.ok) {
|
|
10808
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
10809
|
+
}
|
|
10810
|
+
const data = await response.json();
|
|
10811
|
+
return data.map((entryWithScore) => entryWithScore.entry);
|
|
10812
|
+
}
|
|
10813
|
+
catch (error) {
|
|
10814
|
+
logger$1.error('Failed to fetch patches:', error);
|
|
10815
|
+
return [];
|
|
10816
|
+
}
|
|
10817
|
+
}
|
|
10139
10818
|
// Static factory method
|
|
10140
10819
|
static createPromptAction(name, description, tools, llmProvider, llmConfig) {
|
|
10141
10820
|
return new ActionImpl('prompt', name, description, tools, llmProvider, llmConfig);
|
|
@@ -10149,10 +10828,10 @@ Navigation Bar or Menu Changes: After logging in, the navigation bar will includ
|
|
|
10149
10828
|
// "type": "string",
|
|
10150
10829
|
// "description": 'Your observation of the previous steps. Should start with "In the previous step, I\'ve ...".',
|
|
10151
10830
|
// },
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10831
|
+
thinking: {
|
|
10832
|
+
"type": "string",
|
|
10833
|
+
"description": 'Your thinking draft.',
|
|
10834
|
+
},
|
|
10156
10835
|
userSidePrompt: {
|
|
10157
10836
|
"type": "string",
|
|
10158
10837
|
"description": 'The user-side prompt, showing why calling this tool. Should start with "I\'m calling the ...(tool) to ...(target)". Rememeber to keep the same language of the ultimate task.',
|
|
@@ -10162,7 +10841,7 @@ Navigation Bar or Menu Changes: After logging in, the navigation bar will includ
|
|
|
10162
10841
|
required: [
|
|
10163
10842
|
// comment for backup
|
|
10164
10843
|
// "observation",
|
|
10165
|
-
|
|
10844
|
+
"thinking",
|
|
10166
10845
|
"userSidePrompt",
|
|
10167
10846
|
"toolCall",
|
|
10168
10847
|
],
|
|
@@ -10346,9 +11025,7 @@ class WorkflowGenerator {
|
|
|
10346
11025
|
});
|
|
10347
11026
|
const workflowData = response.toolCalls[0].input.workflow;
|
|
10348
11027
|
// debug
|
|
10349
|
-
|
|
10350
|
-
console.log({ ...workflowData });
|
|
10351
|
-
console.log("Debug the workflow...Done");
|
|
11028
|
+
logger$1.debug("Debug the workflow...", { ...workflowData });
|
|
10352
11029
|
// Generate a new UUID if not provided
|
|
10353
11030
|
if (!workflowData.id) {
|
|
10354
11031
|
workflowData.id = v4();
|
|
@@ -10366,7 +11043,7 @@ class WorkflowGenerator {
|
|
|
10366
11043
|
const tools = nodeData.action.tools.filter((toolName) => {
|
|
10367
11044
|
let hasTool = this.toolRegistry.hasTools([toolName]);
|
|
10368
11045
|
if (!hasTool) {
|
|
10369
|
-
|
|
11046
|
+
logger$1.warn(`The [${toolName}] tool does not exist.`);
|
|
10370
11047
|
}
|
|
10371
11048
|
return hasTool;
|
|
10372
11049
|
}).map((toolName) => this.toolRegistry.getTool(toolName));
|
|
@@ -10515,25 +11192,56 @@ class ToolRegistry {
|
|
|
10515
11192
|
*/
|
|
10516
11193
|
class Eko {
|
|
10517
11194
|
constructor(llmConfig, ekoConfig) {
|
|
11195
|
+
var _a;
|
|
10518
11196
|
this.toolRegistry = new ToolRegistry();
|
|
10519
11197
|
this.workflowGeneratorMap = new Map();
|
|
10520
11198
|
this.prompt = "";
|
|
10521
11199
|
this.tabs = [];
|
|
10522
11200
|
this.workflow = undefined;
|
|
10523
|
-
console.info("using Eko@" + "51bc8c13f40aa7f870c443e92c811fbf0185f828");
|
|
10524
|
-
console.warn("this version is POC, should not used for production");
|
|
10525
11201
|
this.llmProvider = LLMProviderFactory.buildLLMProvider(llmConfig);
|
|
10526
11202
|
this.ekoConfig = this.buildEkoConfig(ekoConfig);
|
|
11203
|
+
this.registerLogger(logger$1, (_a = this.ekoConfig) === null || _a === void 0 ? void 0 : _a.logtailConfig);
|
|
10527
11204
|
this.registerTools();
|
|
11205
|
+
logger$1.info("using Eko@" + "53e9a9102e0665f469646841f5e5d2b772361b71");
|
|
11206
|
+
}
|
|
11207
|
+
registerLogger(logger, logtailConfig) {
|
|
11208
|
+
if (!logtailConfig) {
|
|
11209
|
+
return;
|
|
11210
|
+
}
|
|
11211
|
+
const { Node: Logtail } = require("@logtail/js");
|
|
11212
|
+
const logtail = new Logtail(logtailConfig === null || logtailConfig === void 0 ? void 0 : logtailConfig.sourceToken, {
|
|
11213
|
+
endpoint: `https://${logtailConfig === null || logtailConfig === void 0 ? void 0 : logtailConfig.ingestingHost}`,
|
|
11214
|
+
});
|
|
11215
|
+
const loggerInstaceUUID = v4();
|
|
11216
|
+
const logtailTransport = (logObj) => {
|
|
11217
|
+
const cloneLogObj = JSON.parse(JSON.stringify(logObj));
|
|
11218
|
+
if (cloneLogObj._meta) {
|
|
11219
|
+
delete cloneLogObj._meta;
|
|
11220
|
+
}
|
|
11221
|
+
const message = {
|
|
11222
|
+
logObj: cloneLogObj,
|
|
11223
|
+
logObjMeta: logObj._meta,
|
|
11224
|
+
loggerInstaceUUID,
|
|
11225
|
+
};
|
|
11226
|
+
const level = logObj._meta.logLevelName.toLowerCase();
|
|
11227
|
+
logtail.log(message, level);
|
|
11228
|
+
};
|
|
11229
|
+
logger.attachTransport((logObj) => { logtailTransport(logObj); });
|
|
11230
|
+
logger.info(`uuid=${loggerInstaceUUID}`);
|
|
10528
11231
|
}
|
|
10529
11232
|
buildEkoConfig(ekoConfig) {
|
|
10530
11233
|
if (!ekoConfig) {
|
|
10531
|
-
|
|
11234
|
+
logger$1.warn("`ekoConfig` is missing when construct `Eko` instance");
|
|
10532
11235
|
}
|
|
10533
11236
|
const defaultEkoConfig = {
|
|
10534
11237
|
workingWindowId: undefined,
|
|
10535
11238
|
chromeProxy: typeof chrome === 'undefined' ? undefined : chrome,
|
|
10536
11239
|
callback: undefined,
|
|
11240
|
+
patchServerUrl: "http://127.0.0.1:8000/eko",
|
|
11241
|
+
logtailConfig: {
|
|
11242
|
+
sourceToken: "v2K4fowTDC95wZgrWPuVqSmV",
|
|
11243
|
+
ingestingHost: "s1271080.eu-nbg-2.betterstackdata.com",
|
|
11244
|
+
}
|
|
10537
11245
|
};
|
|
10538
11246
|
return {
|
|
10539
11247
|
...defaultEkoConfig,
|
|
@@ -10564,11 +11272,12 @@ class Eko {
|
|
|
10564
11272
|
});
|
|
10565
11273
|
}
|
|
10566
11274
|
else {
|
|
10567
|
-
|
|
11275
|
+
logger$1.warn("`ekoConfig.callback` is missing when construct `Eko` instance.");
|
|
10568
11276
|
}
|
|
10569
11277
|
tools.forEach(tool => this.toolRegistry.registerTool(tool));
|
|
10570
11278
|
}
|
|
10571
11279
|
async generate(prompt, tabs = [], param) {
|
|
11280
|
+
logger$1.info("workflow generating...");
|
|
10572
11281
|
this.prompt = prompt;
|
|
10573
11282
|
this.tabs = tabs;
|
|
10574
11283
|
let toolRegistry = this.toolRegistry;
|
|
@@ -10587,12 +11296,12 @@ class Eko {
|
|
|
10587
11296
|
const generator = new WorkflowGenerator(this.llmProvider, toolRegistry);
|
|
10588
11297
|
const workflow = await generator.generateWorkflow(prompt, this.ekoConfig);
|
|
10589
11298
|
this.workflowGeneratorMap.set(workflow, generator);
|
|
10590
|
-
console.log("the workflow returned by generate");
|
|
10591
|
-
console.log(workflow);
|
|
10592
11299
|
this.workflow = workflow;
|
|
11300
|
+
logger$1.info("workflow generating...done");
|
|
10593
11301
|
return workflow;
|
|
10594
11302
|
}
|
|
10595
11303
|
async execute(workflow) {
|
|
11304
|
+
logger$1.info("workflow executing...");
|
|
10596
11305
|
let prompt = this.prompt;
|
|
10597
11306
|
let description = "";
|
|
10598
11307
|
workflow.nodes.forEach(node => {
|
|
@@ -10628,12 +11337,11 @@ class Eko {
|
|
|
10628
11337
|
},
|
|
10629
11338
|
],
|
|
10630
11339
|
};
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
console.log("debug the LLMProvider...done");
|
|
11340
|
+
logger$1.debug("workflow", json);
|
|
11341
|
+
logger$1.debug("LLMProvider", {
|
|
11342
|
+
client: (typeof this.llmProvider.client),
|
|
11343
|
+
defaultModel: this.llmProvider.defaultModel,
|
|
11344
|
+
});
|
|
10637
11345
|
const generator = new WorkflowGenerator(this.llmProvider, this.toolRegistry);
|
|
10638
11346
|
workflow = await generator.generateWorkflowFromJson(json, this.ekoConfig);
|
|
10639
11347
|
this.workflow = workflow;
|
|
@@ -10654,7 +11362,8 @@ class Eko {
|
|
|
10654
11362
|
}
|
|
10655
11363
|
}
|
|
10656
11364
|
const result = await workflow.execute(this.ekoConfig.callback);
|
|
10657
|
-
|
|
11365
|
+
logger$1.debug(result);
|
|
11366
|
+
logger$1.info("workflow executing...done");
|
|
10658
11367
|
return result;
|
|
10659
11368
|
}
|
|
10660
11369
|
async cancel() {
|
|
@@ -10931,8 +11640,6 @@ class WorkflowParser {
|
|
|
10931
11640
|
* In this example, `tabs_get` is a mock implementation that logs the `tabId` before calling the original `chrome.tabs.get` method, and the same as `chrome.windows.create` method.
|
|
10932
11641
|
*/
|
|
10933
11642
|
function createChromeApiProxy(mockClass) {
|
|
10934
|
-
console.log("debug mockClass:");
|
|
10935
|
-
console.log(mockClass);
|
|
10936
11643
|
// Helper function to recursively create nested proxies
|
|
10937
11644
|
function createNestedProxy(target, path) {
|
|
10938
11645
|
return new Proxy(target, {
|