@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/web.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
|
/**
|
|
2
6
|
* Get clickable elements on the page
|
|
3
7
|
*
|
|
@@ -8189,7 +8193,7 @@ var loadSerializedSVG = function (svg) {
|
|
|
8189
8193
|
});
|
|
8190
8194
|
};
|
|
8191
8195
|
|
|
8192
|
-
var Logger = /** @class */ (function () {
|
|
8196
|
+
var Logger$1 = /** @class */ (function () {
|
|
8193
8197
|
function Logger(_a) {
|
|
8194
8198
|
var id = _a.id, enabled = _a.enabled;
|
|
8195
8199
|
this.id = id;
|
|
@@ -8273,7 +8277,7 @@ var Context = /** @class */ (function () {
|
|
|
8273
8277
|
var _a;
|
|
8274
8278
|
this.windowBounds = windowBounds;
|
|
8275
8279
|
this.instanceName = "#" + Context.instanceCount++;
|
|
8276
|
-
this.logger = new Logger({ id: this.instanceName, enabled: options.logging });
|
|
8280
|
+
this.logger = new Logger$1({ id: this.instanceName, enabled: options.logging });
|
|
8277
8281
|
this.cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new Cache(this, options);
|
|
8278
8282
|
}
|
|
8279
8283
|
Context.instanceCount = 1;
|
|
@@ -8980,6 +8984,630 @@ class Screenshot {
|
|
|
8980
8984
|
}
|
|
8981
8985
|
}
|
|
8982
8986
|
|
|
8987
|
+
const prettyLogStyles = {
|
|
8988
|
+
reset: [0, 0],
|
|
8989
|
+
bold: [1, 22],
|
|
8990
|
+
dim: [2, 22],
|
|
8991
|
+
italic: [3, 23],
|
|
8992
|
+
underline: [4, 24],
|
|
8993
|
+
overline: [53, 55],
|
|
8994
|
+
inverse: [7, 27],
|
|
8995
|
+
hidden: [8, 28],
|
|
8996
|
+
strikethrough: [9, 29],
|
|
8997
|
+
black: [30, 39],
|
|
8998
|
+
red: [31, 39],
|
|
8999
|
+
green: [32, 39],
|
|
9000
|
+
yellow: [33, 39],
|
|
9001
|
+
blue: [34, 39],
|
|
9002
|
+
magenta: [35, 39],
|
|
9003
|
+
cyan: [36, 39],
|
|
9004
|
+
white: [37, 39],
|
|
9005
|
+
blackBright: [90, 39],
|
|
9006
|
+
redBright: [91, 39],
|
|
9007
|
+
greenBright: [92, 39],
|
|
9008
|
+
yellowBright: [93, 39],
|
|
9009
|
+
blueBright: [94, 39],
|
|
9010
|
+
magentaBright: [95, 39],
|
|
9011
|
+
cyanBright: [96, 39],
|
|
9012
|
+
whiteBright: [97, 39],
|
|
9013
|
+
bgBlack: [40, 49],
|
|
9014
|
+
bgRed: [41, 49],
|
|
9015
|
+
bgGreen: [42, 49],
|
|
9016
|
+
bgYellow: [43, 49],
|
|
9017
|
+
bgBlue: [44, 49],
|
|
9018
|
+
bgMagenta: [45, 49],
|
|
9019
|
+
bgCyan: [46, 49],
|
|
9020
|
+
bgWhite: [47, 49],
|
|
9021
|
+
bgBlackBright: [100, 49],
|
|
9022
|
+
bgRedBright: [101, 49],
|
|
9023
|
+
bgGreenBright: [102, 49],
|
|
9024
|
+
bgYellowBright: [103, 49],
|
|
9025
|
+
bgBlueBright: [104, 49],
|
|
9026
|
+
bgMagentaBright: [105, 49],
|
|
9027
|
+
bgCyanBright: [106, 49],
|
|
9028
|
+
bgWhiteBright: [107, 49],
|
|
9029
|
+
};
|
|
9030
|
+
|
|
9031
|
+
function formatTemplate(settings, template, values, hideUnsetPlaceholder = false) {
|
|
9032
|
+
const templateString = String(template);
|
|
9033
|
+
const ansiColorWrap = (placeholderValue, code) => `\u001b[${code[0]}m${placeholderValue}\u001b[${code[1]}m`;
|
|
9034
|
+
const styleWrap = (value, style) => {
|
|
9035
|
+
if (style != null && typeof style === "string") {
|
|
9036
|
+
return ansiColorWrap(value, prettyLogStyles[style]);
|
|
9037
|
+
}
|
|
9038
|
+
else if (style != null && Array.isArray(style)) {
|
|
9039
|
+
return style.reduce((prevValue, thisStyle) => styleWrap(prevValue, thisStyle), value);
|
|
9040
|
+
}
|
|
9041
|
+
else {
|
|
9042
|
+
if (style != null && style[value.trim()] != null) {
|
|
9043
|
+
return styleWrap(value, style[value.trim()]);
|
|
9044
|
+
}
|
|
9045
|
+
else if (style != null && style["*"] != null) {
|
|
9046
|
+
return styleWrap(value, style["*"]);
|
|
9047
|
+
}
|
|
9048
|
+
else {
|
|
9049
|
+
return value;
|
|
9050
|
+
}
|
|
9051
|
+
}
|
|
9052
|
+
};
|
|
9053
|
+
const defaultStyle = null;
|
|
9054
|
+
return templateString.replace(/{{(.+?)}}/g, (_, placeholder) => {
|
|
9055
|
+
const value = values[placeholder] != null ? String(values[placeholder]) : hideUnsetPlaceholder ? "" : _;
|
|
9056
|
+
return settings.stylePrettyLogs
|
|
9057
|
+
? styleWrap(value, settings?.prettyLogStyles?.[placeholder] ?? defaultStyle) + ansiColorWrap("", prettyLogStyles.reset)
|
|
9058
|
+
: value;
|
|
9059
|
+
});
|
|
9060
|
+
}
|
|
9061
|
+
|
|
9062
|
+
function formatNumberAddZeros(value, digits = 2, addNumber = 0) {
|
|
9063
|
+
if (value != null && isNaN(value)) {
|
|
9064
|
+
return "";
|
|
9065
|
+
}
|
|
9066
|
+
value = value != null ? value + addNumber : value;
|
|
9067
|
+
return digits === 2
|
|
9068
|
+
? value == null
|
|
9069
|
+
? "--"
|
|
9070
|
+
: value < 10
|
|
9071
|
+
? "0" + value
|
|
9072
|
+
: value.toString()
|
|
9073
|
+
: value == null
|
|
9074
|
+
? "---"
|
|
9075
|
+
: value < 10
|
|
9076
|
+
? "00" + value
|
|
9077
|
+
: value < 100
|
|
9078
|
+
? "0" + value
|
|
9079
|
+
: value.toString();
|
|
9080
|
+
}
|
|
9081
|
+
|
|
9082
|
+
function urlToObject(url) {
|
|
9083
|
+
return {
|
|
9084
|
+
href: url.href,
|
|
9085
|
+
protocol: url.protocol,
|
|
9086
|
+
username: url.username,
|
|
9087
|
+
password: url.password,
|
|
9088
|
+
host: url.host,
|
|
9089
|
+
hostname: url.hostname,
|
|
9090
|
+
port: url.port,
|
|
9091
|
+
pathname: url.pathname,
|
|
9092
|
+
search: url.search,
|
|
9093
|
+
searchParams: [...url.searchParams].map(([key, value]) => ({ key, value })),
|
|
9094
|
+
hash: url.hash,
|
|
9095
|
+
origin: url.origin,
|
|
9096
|
+
};
|
|
9097
|
+
}
|
|
9098
|
+
|
|
9099
|
+
var Runtime = {
|
|
9100
|
+
getCallerStackFrame,
|
|
9101
|
+
getErrorTrace,
|
|
9102
|
+
getMeta,
|
|
9103
|
+
transportJSON,
|
|
9104
|
+
transportFormatted: transportFormatted$1,
|
|
9105
|
+
isBuffer,
|
|
9106
|
+
isError,
|
|
9107
|
+
prettyFormatLogObj,
|
|
9108
|
+
prettyFormatErrorObj,
|
|
9109
|
+
};
|
|
9110
|
+
const meta = {
|
|
9111
|
+
runtime: "Nodejs",
|
|
9112
|
+
runtimeVersion: process?.version,
|
|
9113
|
+
hostname: hostname ? hostname() : undefined,
|
|
9114
|
+
};
|
|
9115
|
+
function getMeta(logLevelId, logLevelName, stackDepthLevel, hideLogPositionForPerformance, name, parentNames) {
|
|
9116
|
+
return Object.assign({}, meta, {
|
|
9117
|
+
name,
|
|
9118
|
+
parentNames,
|
|
9119
|
+
date: new Date(),
|
|
9120
|
+
logLevelId,
|
|
9121
|
+
logLevelName,
|
|
9122
|
+
path: !hideLogPositionForPerformance ? getCallerStackFrame(stackDepthLevel) : undefined,
|
|
9123
|
+
});
|
|
9124
|
+
}
|
|
9125
|
+
function getCallerStackFrame(stackDepthLevel, error = Error()) {
|
|
9126
|
+
return stackLineToStackFrame(error?.stack?.split("\n")?.filter((thisLine) => thisLine.includes(" at "))?.[stackDepthLevel]);
|
|
9127
|
+
}
|
|
9128
|
+
function getErrorTrace(error) {
|
|
9129
|
+
return error?.stack?.split("\n")?.reduce((result, line) => {
|
|
9130
|
+
if (line.includes(" at ")) {
|
|
9131
|
+
result.push(stackLineToStackFrame(line));
|
|
9132
|
+
}
|
|
9133
|
+
return result;
|
|
9134
|
+
}, []);
|
|
9135
|
+
}
|
|
9136
|
+
function stackLineToStackFrame(line) {
|
|
9137
|
+
const pathResult = {
|
|
9138
|
+
fullFilePath: undefined,
|
|
9139
|
+
fileName: undefined,
|
|
9140
|
+
fileNameWithLine: undefined,
|
|
9141
|
+
fileColumn: undefined,
|
|
9142
|
+
fileLine: undefined,
|
|
9143
|
+
filePath: undefined,
|
|
9144
|
+
filePathWithLine: undefined,
|
|
9145
|
+
method: undefined,
|
|
9146
|
+
};
|
|
9147
|
+
if (line != null && line.includes(" at ")) {
|
|
9148
|
+
line = line.replace(/^\s+at\s+/gm, "");
|
|
9149
|
+
const errorStackLine = line.split(" (");
|
|
9150
|
+
const fullFilePath = line?.slice(-1) === ")" ? line?.match(/\(([^)]+)\)/)?.[1] : line;
|
|
9151
|
+
const pathArray = fullFilePath?.includes(":") ? fullFilePath?.replace("file://", "")?.replace(process.cwd(), "")?.split(":") : undefined;
|
|
9152
|
+
const fileColumn = pathArray?.pop();
|
|
9153
|
+
const fileLine = pathArray?.pop();
|
|
9154
|
+
const filePath = pathArray?.pop();
|
|
9155
|
+
const filePathWithLine = normalize(`${filePath}:${fileLine}`);
|
|
9156
|
+
const fileName = filePath?.split("/")?.pop();
|
|
9157
|
+
const fileNameWithLine = `${fileName}:${fileLine}`;
|
|
9158
|
+
if (filePath != null && filePath.length > 0) {
|
|
9159
|
+
pathResult.fullFilePath = fullFilePath;
|
|
9160
|
+
pathResult.fileName = fileName;
|
|
9161
|
+
pathResult.fileNameWithLine = fileNameWithLine;
|
|
9162
|
+
pathResult.fileColumn = fileColumn;
|
|
9163
|
+
pathResult.fileLine = fileLine;
|
|
9164
|
+
pathResult.filePath = filePath;
|
|
9165
|
+
pathResult.filePathWithLine = filePathWithLine;
|
|
9166
|
+
pathResult.method = errorStackLine?.[1] != null ? errorStackLine?.[0] : undefined;
|
|
9167
|
+
}
|
|
9168
|
+
}
|
|
9169
|
+
return pathResult;
|
|
9170
|
+
}
|
|
9171
|
+
function isError(e) {
|
|
9172
|
+
return types?.isNativeError != null ? types.isNativeError(e) : e instanceof Error;
|
|
9173
|
+
}
|
|
9174
|
+
function prettyFormatLogObj(maskedArgs, settings) {
|
|
9175
|
+
return maskedArgs.reduce((result, arg) => {
|
|
9176
|
+
isError(arg) ? result.errors.push(prettyFormatErrorObj(arg, settings)) : result.args.push(arg);
|
|
9177
|
+
return result;
|
|
9178
|
+
}, { args: [], errors: [] });
|
|
9179
|
+
}
|
|
9180
|
+
function prettyFormatErrorObj(error, settings) {
|
|
9181
|
+
const errorStackStr = getErrorTrace(error).map((stackFrame) => {
|
|
9182
|
+
return formatTemplate(settings, settings.prettyErrorStackTemplate, { ...stackFrame }, true);
|
|
9183
|
+
});
|
|
9184
|
+
const placeholderValuesError = {
|
|
9185
|
+
errorName: ` ${error.name} `,
|
|
9186
|
+
errorMessage: Object.getOwnPropertyNames(error)
|
|
9187
|
+
.reduce((result, key) => {
|
|
9188
|
+
if (key !== "stack") {
|
|
9189
|
+
result.push(error[key]);
|
|
9190
|
+
}
|
|
9191
|
+
return result;
|
|
9192
|
+
}, [])
|
|
9193
|
+
.join(", "),
|
|
9194
|
+
errorStack: errorStackStr.join("\n"),
|
|
9195
|
+
};
|
|
9196
|
+
return formatTemplate(settings, settings.prettyErrorTemplate, placeholderValuesError);
|
|
9197
|
+
}
|
|
9198
|
+
function transportFormatted$1(logMetaMarkup, logArgs, logErrors, settings) {
|
|
9199
|
+
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
9200
|
+
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
9201
|
+
console.log(logMetaMarkup + formatWithOptions(settings.prettyInspectOptions, ...logArgs) + logErrorsStr);
|
|
9202
|
+
}
|
|
9203
|
+
function transportJSON(json) {
|
|
9204
|
+
console.log(jsonStringifyRecursive(json));
|
|
9205
|
+
function jsonStringifyRecursive(obj) {
|
|
9206
|
+
const cache = new Set();
|
|
9207
|
+
return JSON.stringify(obj, (key, value) => {
|
|
9208
|
+
if (typeof value === "object" && value !== null) {
|
|
9209
|
+
if (cache.has(value)) {
|
|
9210
|
+
return "[Circular]";
|
|
9211
|
+
}
|
|
9212
|
+
cache.add(value);
|
|
9213
|
+
}
|
|
9214
|
+
if (typeof value === "bigint") {
|
|
9215
|
+
return `${value}`;
|
|
9216
|
+
}
|
|
9217
|
+
if (typeof value === "undefined") {
|
|
9218
|
+
return "[undefined]";
|
|
9219
|
+
}
|
|
9220
|
+
return value;
|
|
9221
|
+
});
|
|
9222
|
+
}
|
|
9223
|
+
}
|
|
9224
|
+
function isBuffer(arg) {
|
|
9225
|
+
return Buffer.isBuffer(arg);
|
|
9226
|
+
}
|
|
9227
|
+
|
|
9228
|
+
class BaseLogger {
|
|
9229
|
+
constructor(settings, logObj, stackDepthLevel = 4) {
|
|
9230
|
+
this.logObj = logObj;
|
|
9231
|
+
this.stackDepthLevel = stackDepthLevel;
|
|
9232
|
+
this.runtime = Runtime;
|
|
9233
|
+
this.settings = {
|
|
9234
|
+
type: settings?.type ?? "pretty",
|
|
9235
|
+
name: settings?.name,
|
|
9236
|
+
parentNames: settings?.parentNames,
|
|
9237
|
+
minLevel: settings?.minLevel ?? 0,
|
|
9238
|
+
argumentsArrayName: settings?.argumentsArrayName,
|
|
9239
|
+
hideLogPositionForProduction: settings?.hideLogPositionForProduction ?? false,
|
|
9240
|
+
prettyLogTemplate: settings?.prettyLogTemplate ??
|
|
9241
|
+
"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t{{filePathWithLine}}{{nameWithDelimiterPrefix}}\t",
|
|
9242
|
+
prettyErrorTemplate: settings?.prettyErrorTemplate ?? "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}",
|
|
9243
|
+
prettyErrorStackTemplate: settings?.prettyErrorStackTemplate ?? " • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}",
|
|
9244
|
+
prettyErrorParentNamesSeparator: settings?.prettyErrorParentNamesSeparator ?? ":",
|
|
9245
|
+
prettyErrorLoggerNameDelimiter: settings?.prettyErrorLoggerNameDelimiter ?? "\t",
|
|
9246
|
+
stylePrettyLogs: settings?.stylePrettyLogs ?? true,
|
|
9247
|
+
prettyLogTimeZone: settings?.prettyLogTimeZone ?? "UTC",
|
|
9248
|
+
prettyLogStyles: settings?.prettyLogStyles ?? {
|
|
9249
|
+
logLevelName: {
|
|
9250
|
+
"*": ["bold", "black", "bgWhiteBright", "dim"],
|
|
9251
|
+
SILLY: ["bold", "white"],
|
|
9252
|
+
TRACE: ["bold", "whiteBright"],
|
|
9253
|
+
DEBUG: ["bold", "green"],
|
|
9254
|
+
INFO: ["bold", "blue"],
|
|
9255
|
+
WARN: ["bold", "yellow"],
|
|
9256
|
+
ERROR: ["bold", "red"],
|
|
9257
|
+
FATAL: ["bold", "redBright"],
|
|
9258
|
+
},
|
|
9259
|
+
dateIsoStr: "white",
|
|
9260
|
+
filePathWithLine: "white",
|
|
9261
|
+
name: ["white", "bold"],
|
|
9262
|
+
nameWithDelimiterPrefix: ["white", "bold"],
|
|
9263
|
+
nameWithDelimiterSuffix: ["white", "bold"],
|
|
9264
|
+
errorName: ["bold", "bgRedBright", "whiteBright"],
|
|
9265
|
+
fileName: ["yellow"],
|
|
9266
|
+
fileNameWithLine: "white",
|
|
9267
|
+
},
|
|
9268
|
+
prettyInspectOptions: settings?.prettyInspectOptions ?? {
|
|
9269
|
+
colors: true,
|
|
9270
|
+
compact: false,
|
|
9271
|
+
depth: Infinity,
|
|
9272
|
+
},
|
|
9273
|
+
metaProperty: settings?.metaProperty ?? "_meta",
|
|
9274
|
+
maskPlaceholder: settings?.maskPlaceholder ?? "[***]",
|
|
9275
|
+
maskValuesOfKeys: settings?.maskValuesOfKeys ?? ["password"],
|
|
9276
|
+
maskValuesOfKeysCaseInsensitive: settings?.maskValuesOfKeysCaseInsensitive ?? false,
|
|
9277
|
+
maskValuesRegEx: settings?.maskValuesRegEx,
|
|
9278
|
+
prefix: [...(settings?.prefix ?? [])],
|
|
9279
|
+
attachedTransports: [...(settings?.attachedTransports ?? [])],
|
|
9280
|
+
overwrite: {
|
|
9281
|
+
mask: settings?.overwrite?.mask,
|
|
9282
|
+
toLogObj: settings?.overwrite?.toLogObj,
|
|
9283
|
+
addMeta: settings?.overwrite?.addMeta,
|
|
9284
|
+
addPlaceholders: settings?.overwrite?.addPlaceholders,
|
|
9285
|
+
formatMeta: settings?.overwrite?.formatMeta,
|
|
9286
|
+
formatLogObj: settings?.overwrite?.formatLogObj,
|
|
9287
|
+
transportFormatted: settings?.overwrite?.transportFormatted,
|
|
9288
|
+
transportJSON: settings?.overwrite?.transportJSON,
|
|
9289
|
+
},
|
|
9290
|
+
};
|
|
9291
|
+
}
|
|
9292
|
+
log(logLevelId, logLevelName, ...args) {
|
|
9293
|
+
if (logLevelId < this.settings.minLevel) {
|
|
9294
|
+
return;
|
|
9295
|
+
}
|
|
9296
|
+
const logArgs = [...this.settings.prefix, ...args];
|
|
9297
|
+
const maskedArgs = this.settings.overwrite?.mask != null
|
|
9298
|
+
? this.settings.overwrite?.mask(logArgs)
|
|
9299
|
+
: this.settings.maskValuesOfKeys != null && this.settings.maskValuesOfKeys.length > 0
|
|
9300
|
+
? this._mask(logArgs)
|
|
9301
|
+
: logArgs;
|
|
9302
|
+
const thisLogObj = this.logObj != null ? this._recursiveCloneAndExecuteFunctions(this.logObj) : undefined;
|
|
9303
|
+
const logObj = this.settings.overwrite?.toLogObj != null ? this.settings.overwrite?.toLogObj(maskedArgs, thisLogObj) : this._toLogObj(maskedArgs, thisLogObj);
|
|
9304
|
+
const logObjWithMeta = this.settings.overwrite?.addMeta != null
|
|
9305
|
+
? this.settings.overwrite?.addMeta(logObj, logLevelId, logLevelName)
|
|
9306
|
+
: this._addMetaToLogObj(logObj, logLevelId, logLevelName);
|
|
9307
|
+
let logMetaMarkup;
|
|
9308
|
+
let logArgsAndErrorsMarkup = undefined;
|
|
9309
|
+
if (this.settings.overwrite?.formatMeta != null) {
|
|
9310
|
+
logMetaMarkup = this.settings.overwrite?.formatMeta(logObjWithMeta?.[this.settings.metaProperty]);
|
|
9311
|
+
}
|
|
9312
|
+
if (this.settings.overwrite?.formatLogObj != null) {
|
|
9313
|
+
logArgsAndErrorsMarkup = this.settings.overwrite?.formatLogObj(maskedArgs, this.settings);
|
|
9314
|
+
}
|
|
9315
|
+
if (this.settings.type === "pretty") {
|
|
9316
|
+
logMetaMarkup = logMetaMarkup ?? this._prettyFormatLogObjMeta(logObjWithMeta?.[this.settings.metaProperty]);
|
|
9317
|
+
logArgsAndErrorsMarkup = logArgsAndErrorsMarkup ?? this.runtime.prettyFormatLogObj(maskedArgs, this.settings);
|
|
9318
|
+
}
|
|
9319
|
+
if (logMetaMarkup != null && logArgsAndErrorsMarkup != null) {
|
|
9320
|
+
this.settings.overwrite?.transportFormatted != null
|
|
9321
|
+
? this.settings.overwrite?.transportFormatted(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, this.settings)
|
|
9322
|
+
: this.runtime.transportFormatted(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, this.settings);
|
|
9323
|
+
}
|
|
9324
|
+
else {
|
|
9325
|
+
this.settings.overwrite?.transportJSON != null
|
|
9326
|
+
? this.settings.overwrite?.transportJSON(logObjWithMeta)
|
|
9327
|
+
: this.settings.type !== "hidden"
|
|
9328
|
+
? this.runtime.transportJSON(logObjWithMeta)
|
|
9329
|
+
: undefined;
|
|
9330
|
+
}
|
|
9331
|
+
if (this.settings.attachedTransports != null && this.settings.attachedTransports.length > 0) {
|
|
9332
|
+
this.settings.attachedTransports.forEach((transportLogger) => {
|
|
9333
|
+
transportLogger(logObjWithMeta);
|
|
9334
|
+
});
|
|
9335
|
+
}
|
|
9336
|
+
return logObjWithMeta;
|
|
9337
|
+
}
|
|
9338
|
+
attachTransport(transportLogger) {
|
|
9339
|
+
this.settings.attachedTransports.push(transportLogger);
|
|
9340
|
+
}
|
|
9341
|
+
getSubLogger(settings, logObj) {
|
|
9342
|
+
const subLoggerSettings = {
|
|
9343
|
+
...this.settings,
|
|
9344
|
+
...settings,
|
|
9345
|
+
parentNames: this.settings?.parentNames != null && this.settings?.name != null
|
|
9346
|
+
? [...this.settings.parentNames, this.settings.name]
|
|
9347
|
+
: this.settings?.name != null
|
|
9348
|
+
? [this.settings.name]
|
|
9349
|
+
: undefined,
|
|
9350
|
+
prefix: [...this.settings.prefix, ...(settings?.prefix ?? [])],
|
|
9351
|
+
};
|
|
9352
|
+
const subLogger = new this.constructor(subLoggerSettings, logObj ?? this.logObj, this.stackDepthLevel);
|
|
9353
|
+
return subLogger;
|
|
9354
|
+
}
|
|
9355
|
+
_mask(args) {
|
|
9356
|
+
const maskValuesOfKeys = this.settings.maskValuesOfKeysCaseInsensitive !== true ? this.settings.maskValuesOfKeys : this.settings.maskValuesOfKeys.map((key) => key.toLowerCase());
|
|
9357
|
+
return args?.map((arg) => {
|
|
9358
|
+
return this._recursiveCloneAndMaskValuesOfKeys(arg, maskValuesOfKeys);
|
|
9359
|
+
});
|
|
9360
|
+
}
|
|
9361
|
+
_recursiveCloneAndMaskValuesOfKeys(source, keys, seen = []) {
|
|
9362
|
+
if (seen.includes(source)) {
|
|
9363
|
+
return { ...source };
|
|
9364
|
+
}
|
|
9365
|
+
if (typeof source === "object" && source !== null) {
|
|
9366
|
+
seen.push(source);
|
|
9367
|
+
}
|
|
9368
|
+
if (this.runtime.isError(source) || this.runtime.isBuffer(source)) {
|
|
9369
|
+
return source;
|
|
9370
|
+
}
|
|
9371
|
+
else if (source instanceof Map) {
|
|
9372
|
+
return new Map(source);
|
|
9373
|
+
}
|
|
9374
|
+
else if (source instanceof Set) {
|
|
9375
|
+
return new Set(source);
|
|
9376
|
+
}
|
|
9377
|
+
else if (Array.isArray(source)) {
|
|
9378
|
+
return source.map((item) => this._recursiveCloneAndMaskValuesOfKeys(item, keys, seen));
|
|
9379
|
+
}
|
|
9380
|
+
else if (source instanceof Date) {
|
|
9381
|
+
return new Date(source.getTime());
|
|
9382
|
+
}
|
|
9383
|
+
else if (source instanceof URL) {
|
|
9384
|
+
return urlToObject(source);
|
|
9385
|
+
}
|
|
9386
|
+
else if (source !== null && typeof source === "object") {
|
|
9387
|
+
const baseObject = this.runtime.isError(source) ? this._cloneError(source) : Object.create(Object.getPrototypeOf(source));
|
|
9388
|
+
return Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
9389
|
+
o[prop] = keys.includes(this.settings?.maskValuesOfKeysCaseInsensitive !== true ? prop : prop.toLowerCase())
|
|
9390
|
+
? this.settings.maskPlaceholder
|
|
9391
|
+
: (() => {
|
|
9392
|
+
try {
|
|
9393
|
+
return this._recursiveCloneAndMaskValuesOfKeys(source[prop], keys, seen);
|
|
9394
|
+
}
|
|
9395
|
+
catch (e) {
|
|
9396
|
+
return null;
|
|
9397
|
+
}
|
|
9398
|
+
})();
|
|
9399
|
+
return o;
|
|
9400
|
+
}, baseObject);
|
|
9401
|
+
}
|
|
9402
|
+
else {
|
|
9403
|
+
if (typeof source === "string") {
|
|
9404
|
+
let modifiedSource = source;
|
|
9405
|
+
for (const regEx of this.settings?.maskValuesRegEx || []) {
|
|
9406
|
+
modifiedSource = modifiedSource.replace(regEx, this.settings?.maskPlaceholder || "");
|
|
9407
|
+
}
|
|
9408
|
+
return modifiedSource;
|
|
9409
|
+
}
|
|
9410
|
+
return source;
|
|
9411
|
+
}
|
|
9412
|
+
}
|
|
9413
|
+
_recursiveCloneAndExecuteFunctions(source, seen = []) {
|
|
9414
|
+
if (this.isObjectOrArray(source) && seen.includes(source)) {
|
|
9415
|
+
return this.shallowCopy(source);
|
|
9416
|
+
}
|
|
9417
|
+
if (this.isObjectOrArray(source)) {
|
|
9418
|
+
seen.push(source);
|
|
9419
|
+
}
|
|
9420
|
+
if (Array.isArray(source)) {
|
|
9421
|
+
return source.map((item) => this._recursiveCloneAndExecuteFunctions(item, seen));
|
|
9422
|
+
}
|
|
9423
|
+
else if (source instanceof Date) {
|
|
9424
|
+
return new Date(source.getTime());
|
|
9425
|
+
}
|
|
9426
|
+
else if (this.isObject(source)) {
|
|
9427
|
+
return Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
9428
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, prop);
|
|
9429
|
+
if (descriptor) {
|
|
9430
|
+
Object.defineProperty(o, prop, descriptor);
|
|
9431
|
+
const value = source[prop];
|
|
9432
|
+
o[prop] = typeof value === "function" ? value() : this._recursiveCloneAndExecuteFunctions(value, seen);
|
|
9433
|
+
}
|
|
9434
|
+
return o;
|
|
9435
|
+
}, Object.create(Object.getPrototypeOf(source)));
|
|
9436
|
+
}
|
|
9437
|
+
else {
|
|
9438
|
+
return source;
|
|
9439
|
+
}
|
|
9440
|
+
}
|
|
9441
|
+
isObjectOrArray(value) {
|
|
9442
|
+
return typeof value === "object" && value !== null;
|
|
9443
|
+
}
|
|
9444
|
+
isObject(value) {
|
|
9445
|
+
return typeof value === "object" && !Array.isArray(value) && value !== null;
|
|
9446
|
+
}
|
|
9447
|
+
shallowCopy(source) {
|
|
9448
|
+
if (Array.isArray(source)) {
|
|
9449
|
+
return [...source];
|
|
9450
|
+
}
|
|
9451
|
+
else {
|
|
9452
|
+
return { ...source };
|
|
9453
|
+
}
|
|
9454
|
+
}
|
|
9455
|
+
_toLogObj(args, clonedLogObj = {}) {
|
|
9456
|
+
args = args?.map((arg) => (this.runtime.isError(arg) ? this._toErrorObject(arg) : arg));
|
|
9457
|
+
if (this.settings.argumentsArrayName == null) {
|
|
9458
|
+
if (args.length === 1 && !Array.isArray(args[0]) && this.runtime.isBuffer(args[0]) !== true && !(args[0] instanceof Date)) {
|
|
9459
|
+
clonedLogObj = typeof args[0] === "object" && args[0] != null ? { ...args[0], ...clonedLogObj } : { 0: args[0], ...clonedLogObj };
|
|
9460
|
+
}
|
|
9461
|
+
else {
|
|
9462
|
+
clonedLogObj = { ...clonedLogObj, ...args };
|
|
9463
|
+
}
|
|
9464
|
+
}
|
|
9465
|
+
else {
|
|
9466
|
+
clonedLogObj = {
|
|
9467
|
+
...clonedLogObj,
|
|
9468
|
+
[this.settings.argumentsArrayName]: args,
|
|
9469
|
+
};
|
|
9470
|
+
}
|
|
9471
|
+
return clonedLogObj;
|
|
9472
|
+
}
|
|
9473
|
+
_cloneError(error) {
|
|
9474
|
+
const cloned = new error.constructor();
|
|
9475
|
+
Object.getOwnPropertyNames(error).forEach((key) => {
|
|
9476
|
+
cloned[key] = error[key];
|
|
9477
|
+
});
|
|
9478
|
+
return cloned;
|
|
9479
|
+
}
|
|
9480
|
+
_toErrorObject(error) {
|
|
9481
|
+
return {
|
|
9482
|
+
nativeError: error,
|
|
9483
|
+
name: error.name ?? "Error",
|
|
9484
|
+
message: error.message,
|
|
9485
|
+
stack: this.runtime.getErrorTrace(error),
|
|
9486
|
+
};
|
|
9487
|
+
}
|
|
9488
|
+
_addMetaToLogObj(logObj, logLevelId, logLevelName) {
|
|
9489
|
+
return {
|
|
9490
|
+
...logObj,
|
|
9491
|
+
[this.settings.metaProperty]: this.runtime.getMeta(logLevelId, logLevelName, this.stackDepthLevel, this.settings.hideLogPositionForProduction, this.settings.name, this.settings.parentNames),
|
|
9492
|
+
};
|
|
9493
|
+
}
|
|
9494
|
+
_prettyFormatLogObjMeta(logObjMeta) {
|
|
9495
|
+
if (logObjMeta == null) {
|
|
9496
|
+
return "";
|
|
9497
|
+
}
|
|
9498
|
+
let template = this.settings.prettyLogTemplate;
|
|
9499
|
+
const placeholderValues = {};
|
|
9500
|
+
if (template.includes("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}")) {
|
|
9501
|
+
template = template.replace("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}", "{{dateIsoStr}}");
|
|
9502
|
+
}
|
|
9503
|
+
else {
|
|
9504
|
+
if (this.settings.prettyLogTimeZone === "UTC") {
|
|
9505
|
+
placeholderValues["yyyy"] = logObjMeta?.date?.getUTCFullYear() ?? "----";
|
|
9506
|
+
placeholderValues["mm"] = formatNumberAddZeros(logObjMeta?.date?.getUTCMonth(), 2, 1);
|
|
9507
|
+
placeholderValues["dd"] = formatNumberAddZeros(logObjMeta?.date?.getUTCDate(), 2);
|
|
9508
|
+
placeholderValues["hh"] = formatNumberAddZeros(logObjMeta?.date?.getUTCHours(), 2);
|
|
9509
|
+
placeholderValues["MM"] = formatNumberAddZeros(logObjMeta?.date?.getUTCMinutes(), 2);
|
|
9510
|
+
placeholderValues["ss"] = formatNumberAddZeros(logObjMeta?.date?.getUTCSeconds(), 2);
|
|
9511
|
+
placeholderValues["ms"] = formatNumberAddZeros(logObjMeta?.date?.getUTCMilliseconds(), 3);
|
|
9512
|
+
}
|
|
9513
|
+
else {
|
|
9514
|
+
placeholderValues["yyyy"] = logObjMeta?.date?.getFullYear() ?? "----";
|
|
9515
|
+
placeholderValues["mm"] = formatNumberAddZeros(logObjMeta?.date?.getMonth(), 2, 1);
|
|
9516
|
+
placeholderValues["dd"] = formatNumberAddZeros(logObjMeta?.date?.getDate(), 2);
|
|
9517
|
+
placeholderValues["hh"] = formatNumberAddZeros(logObjMeta?.date?.getHours(), 2);
|
|
9518
|
+
placeholderValues["MM"] = formatNumberAddZeros(logObjMeta?.date?.getMinutes(), 2);
|
|
9519
|
+
placeholderValues["ss"] = formatNumberAddZeros(logObjMeta?.date?.getSeconds(), 2);
|
|
9520
|
+
placeholderValues["ms"] = formatNumberAddZeros(logObjMeta?.date?.getMilliseconds(), 3);
|
|
9521
|
+
}
|
|
9522
|
+
}
|
|
9523
|
+
const dateInSettingsTimeZone = this.settings.prettyLogTimeZone === "UTC" ? logObjMeta?.date : new Date(logObjMeta?.date?.getTime() - logObjMeta?.date?.getTimezoneOffset() * 60000);
|
|
9524
|
+
placeholderValues["rawIsoStr"] = dateInSettingsTimeZone?.toISOString();
|
|
9525
|
+
placeholderValues["dateIsoStr"] = dateInSettingsTimeZone?.toISOString().replace("T", " ").replace("Z", "");
|
|
9526
|
+
placeholderValues["logLevelName"] = logObjMeta?.logLevelName;
|
|
9527
|
+
placeholderValues["fileNameWithLine"] = logObjMeta?.path?.fileNameWithLine ?? "";
|
|
9528
|
+
placeholderValues["filePathWithLine"] = logObjMeta?.path?.filePathWithLine ?? "";
|
|
9529
|
+
placeholderValues["fullFilePath"] = logObjMeta?.path?.fullFilePath ?? "";
|
|
9530
|
+
let parentNamesString = this.settings.parentNames?.join(this.settings.prettyErrorParentNamesSeparator);
|
|
9531
|
+
parentNamesString = parentNamesString != null && logObjMeta?.name != null ? parentNamesString + this.settings.prettyErrorParentNamesSeparator : undefined;
|
|
9532
|
+
placeholderValues["name"] = logObjMeta?.name != null || parentNamesString != null ? (parentNamesString ?? "") + logObjMeta?.name ?? "" : "";
|
|
9533
|
+
placeholderValues["nameWithDelimiterPrefix"] =
|
|
9534
|
+
placeholderValues["name"].length > 0 ? this.settings.prettyErrorLoggerNameDelimiter + placeholderValues["name"] : "";
|
|
9535
|
+
placeholderValues["nameWithDelimiterSuffix"] =
|
|
9536
|
+
placeholderValues["name"].length > 0 ? placeholderValues["name"] + this.settings.prettyErrorLoggerNameDelimiter : "";
|
|
9537
|
+
if (this.settings.overwrite?.addPlaceholders != null) {
|
|
9538
|
+
this.settings.overwrite?.addPlaceholders(logObjMeta, placeholderValues);
|
|
9539
|
+
}
|
|
9540
|
+
return formatTemplate(this.settings, template, placeholderValues);
|
|
9541
|
+
}
|
|
9542
|
+
}
|
|
9543
|
+
|
|
9544
|
+
class Logger extends BaseLogger {
|
|
9545
|
+
constructor(settings, logObj) {
|
|
9546
|
+
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
9547
|
+
const isBrowserBlinkEngine = isBrowser ? window.chrome !== undefined && window.CSS !== undefined && window.CSS.supports("color", "green") : false;
|
|
9548
|
+
const isSafari = isBrowser ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
|
|
9549
|
+
settings = settings || {};
|
|
9550
|
+
settings.stylePrettyLogs = settings.stylePrettyLogs && isBrowser && !isBrowserBlinkEngine ? false : settings.stylePrettyLogs;
|
|
9551
|
+
super(settings, logObj, isSafari ? 4 : 5);
|
|
9552
|
+
}
|
|
9553
|
+
log(logLevelId, logLevelName, ...args) {
|
|
9554
|
+
return super.log(logLevelId, logLevelName, ...args);
|
|
9555
|
+
}
|
|
9556
|
+
silly(...args) {
|
|
9557
|
+
return super.log(0, "SILLY", ...args);
|
|
9558
|
+
}
|
|
9559
|
+
trace(...args) {
|
|
9560
|
+
return super.log(1, "TRACE", ...args);
|
|
9561
|
+
}
|
|
9562
|
+
debug(...args) {
|
|
9563
|
+
return super.log(2, "DEBUG", ...args);
|
|
9564
|
+
}
|
|
9565
|
+
info(...args) {
|
|
9566
|
+
return super.log(3, "INFO", ...args);
|
|
9567
|
+
}
|
|
9568
|
+
warn(...args) {
|
|
9569
|
+
return super.log(4, "WARN", ...args);
|
|
9570
|
+
}
|
|
9571
|
+
error(...args) {
|
|
9572
|
+
return super.log(5, "ERROR", ...args);
|
|
9573
|
+
}
|
|
9574
|
+
fatal(...args) {
|
|
9575
|
+
return super.log(6, "FATAL", ...args);
|
|
9576
|
+
}
|
|
9577
|
+
getSubLogger(settings, logObj) {
|
|
9578
|
+
return super.getSubLogger(settings, logObj);
|
|
9579
|
+
}
|
|
9580
|
+
}
|
|
9581
|
+
|
|
9582
|
+
function transportFormatted(logMetaMarkup, logArgs, logErrors, settings) {
|
|
9583
|
+
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
|
|
9584
|
+
settings.prettyInspectOptions.colors = settings.stylePrettyLogs;
|
|
9585
|
+
console.log(logMetaMarkup, ...logArgs, logErrorsStr);
|
|
9586
|
+
}
|
|
9587
|
+
function formatMeta(logObjMeta) {
|
|
9588
|
+
if (!logObjMeta) {
|
|
9589
|
+
return '';
|
|
9590
|
+
}
|
|
9591
|
+
const { date, logLevelName } = logObjMeta;
|
|
9592
|
+
const year = date.getFullYear();
|
|
9593
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
9594
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
9595
|
+
const hours = String(date.getHours()).padStart(2, '0');
|
|
9596
|
+
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
9597
|
+
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
9598
|
+
const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
|
|
9599
|
+
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
|
|
9600
|
+
const loggerName = logObjMeta.name;
|
|
9601
|
+
return `${formattedDate} ${logLevelName} ${loggerName}`;
|
|
9602
|
+
}
|
|
9603
|
+
const logger = new Logger({
|
|
9604
|
+
name: "ekoLogger",
|
|
9605
|
+
overwrite: {
|
|
9606
|
+
transportFormatted,
|
|
9607
|
+
formatMeta,
|
|
9608
|
+
}
|
|
9609
|
+
});
|
|
9610
|
+
|
|
8983
9611
|
class CancelWorkflow {
|
|
8984
9612
|
constructor() {
|
|
8985
9613
|
this.name = 'cancel_workflow';
|
|
@@ -9001,7 +9629,7 @@ class CancelWorkflow {
|
|
|
9001
9629
|
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
9002
9630
|
}
|
|
9003
9631
|
const reason = params.reason;
|
|
9004
|
-
|
|
9632
|
+
logger.info("The workflow has been cancelled because: " + reason);
|
|
9005
9633
|
await ((_a = context.workflow) === null || _a === void 0 ? void 0 : _a.cancel());
|
|
9006
9634
|
return;
|
|
9007
9635
|
}
|
|
@@ -9028,7 +9656,7 @@ class HumanInputText {
|
|
|
9028
9656
|
throw new Error('Invalid parameters. Expected an object with a "question" property.');
|
|
9029
9657
|
}
|
|
9030
9658
|
const question = params.question;
|
|
9031
|
-
|
|
9659
|
+
logger.debug("question: " + question);
|
|
9032
9660
|
let onHumanInputText = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputText;
|
|
9033
9661
|
if (onHumanInputText) {
|
|
9034
9662
|
let answer;
|
|
@@ -9036,14 +9664,14 @@ class HumanInputText {
|
|
|
9036
9664
|
answer = await onHumanInputText(question);
|
|
9037
9665
|
}
|
|
9038
9666
|
catch (e) {
|
|
9039
|
-
|
|
9667
|
+
logger.warn(e);
|
|
9040
9668
|
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
9041
9669
|
}
|
|
9042
|
-
|
|
9670
|
+
logger.debug("answer: " + answer);
|
|
9043
9671
|
return { status: "OK", answer: answer };
|
|
9044
9672
|
}
|
|
9045
9673
|
else {
|
|
9046
|
-
|
|
9674
|
+
logger.error("`onHumanInputText` not implemented");
|
|
9047
9675
|
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
9048
9676
|
}
|
|
9049
9677
|
}
|
|
@@ -9082,8 +9710,8 @@ class HumanInputSingleChoice {
|
|
|
9082
9710
|
}
|
|
9083
9711
|
const question = params.question;
|
|
9084
9712
|
const choices = params.choices.map((e) => e.choice);
|
|
9085
|
-
|
|
9086
|
-
|
|
9713
|
+
logger.debug("question: " + question);
|
|
9714
|
+
logger.debug("choices: " + choices);
|
|
9087
9715
|
let onHumanInputSingleChoice = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputSingleChoice;
|
|
9088
9716
|
if (onHumanInputSingleChoice) {
|
|
9089
9717
|
let answer;
|
|
@@ -9091,14 +9719,14 @@ class HumanInputSingleChoice {
|
|
|
9091
9719
|
answer = await onHumanInputSingleChoice(question, choices);
|
|
9092
9720
|
}
|
|
9093
9721
|
catch (e) {
|
|
9094
|
-
|
|
9722
|
+
logger.warn(e);
|
|
9095
9723
|
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
9096
9724
|
}
|
|
9097
|
-
|
|
9725
|
+
logger.debug("answer: " + answer);
|
|
9098
9726
|
return { status: "OK", answer: answer };
|
|
9099
9727
|
}
|
|
9100
9728
|
else {
|
|
9101
|
-
|
|
9729
|
+
logger.error("`onHumanInputSingleChoice` not implemented");
|
|
9102
9730
|
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
9103
9731
|
}
|
|
9104
9732
|
}
|
|
@@ -9137,8 +9765,8 @@ class HumanInputMultipleChoice {
|
|
|
9137
9765
|
}
|
|
9138
9766
|
const question = params.question;
|
|
9139
9767
|
const choices = params.choices.map((e) => e.choice);
|
|
9140
|
-
|
|
9141
|
-
|
|
9768
|
+
logger.debug("question: " + question);
|
|
9769
|
+
logger.debug("choices: " + choices);
|
|
9142
9770
|
let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanInputMultipleChoice;
|
|
9143
9771
|
if (onHumanInputMultipleChoice) {
|
|
9144
9772
|
let answer;
|
|
@@ -9146,14 +9774,14 @@ class HumanInputMultipleChoice {
|
|
|
9146
9774
|
answer = await onHumanInputMultipleChoice(question, choices);
|
|
9147
9775
|
}
|
|
9148
9776
|
catch (e) {
|
|
9149
|
-
|
|
9150
|
-
return { status: "
|
|
9777
|
+
logger.warn(e);
|
|
9778
|
+
return { status: "Error: Cannot get user's answer.", answer: [] };
|
|
9151
9779
|
}
|
|
9152
|
-
|
|
9780
|
+
logger.debug("answer: " + answer);
|
|
9153
9781
|
return { status: "OK", answer: answer };
|
|
9154
9782
|
}
|
|
9155
9783
|
else {
|
|
9156
|
-
|
|
9784
|
+
logger.error("`onHumanInputMultipleChoice` not implemented");
|
|
9157
9785
|
return { status: "Error: Cannot get user's answer.", answer: [] };
|
|
9158
9786
|
}
|
|
9159
9787
|
}
|
|
@@ -9187,7 +9815,7 @@ When calling this tool to transfer control to the user, please explain in detail
|
|
|
9187
9815
|
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
9188
9816
|
}
|
|
9189
9817
|
const reason = params.reason;
|
|
9190
|
-
|
|
9818
|
+
logger.debug("reason: " + reason);
|
|
9191
9819
|
let onHumanOperate = (_a = context.callback) === null || _a === void 0 ? void 0 : _a.hooks.onHumanOperate;
|
|
9192
9820
|
if (onHumanOperate) {
|
|
9193
9821
|
let userOperation;
|
|
@@ -9195,10 +9823,10 @@ When calling this tool to transfer control to the user, please explain in detail
|
|
|
9195
9823
|
userOperation = await onHumanOperate(reason);
|
|
9196
9824
|
}
|
|
9197
9825
|
catch (e) {
|
|
9198
|
-
|
|
9199
|
-
return { status: "
|
|
9826
|
+
logger.warn(e);
|
|
9827
|
+
return { status: "Error: Cannot get user's operation.", userOperation: "" };
|
|
9200
9828
|
}
|
|
9201
|
-
|
|
9829
|
+
logger.debug("userOperation: " + userOperation);
|
|
9202
9830
|
if (userOperation == "") {
|
|
9203
9831
|
return { status: "OK", userOperation: "Done. Please take a screenshot to ensure the result." };
|
|
9204
9832
|
}
|
|
@@ -9207,7 +9835,7 @@ When calling this tool to transfer control to the user, please explain in detail
|
|
|
9207
9835
|
}
|
|
9208
9836
|
}
|
|
9209
9837
|
else {
|
|
9210
|
-
|
|
9838
|
+
logger.error("`onHumanOperate` not implemented");
|
|
9211
9839
|
return { status: "Error: Cannot get user's operation.", userOperation: "" };
|
|
9212
9840
|
}
|
|
9213
9841
|
}
|