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