test-wuying-agentbay-sdk 0.13.1-beta.20251224091333 → 0.13.1-beta.20251224094729
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/index.cjs +95 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +95 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -7561,6 +7561,10 @@ declare class MobileSimulateService {
|
|
|
7561
7561
|
* Log level type
|
|
7562
7562
|
*/
|
|
7563
7563
|
type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
7564
|
+
/**
|
|
7565
|
+
* Log format type
|
|
7566
|
+
*/
|
|
7567
|
+
type LogFormat = 'pretty' | 'sls';
|
|
7564
7568
|
/**
|
|
7565
7569
|
* Logger configuration options
|
|
7566
7570
|
*
|
|
@@ -7600,6 +7604,7 @@ interface LoggerConfig {
|
|
|
7600
7604
|
logFile?: string;
|
|
7601
7605
|
maxFileSize?: string;
|
|
7602
7606
|
enableConsole?: boolean;
|
|
7607
|
+
format?: LogFormat | string;
|
|
7603
7608
|
}
|
|
7604
7609
|
/**
|
|
7605
7610
|
* Set the log level
|
package/dist/index.d.ts
CHANGED
|
@@ -7561,6 +7561,10 @@ declare class MobileSimulateService {
|
|
|
7561
7561
|
* Log level type
|
|
7562
7562
|
*/
|
|
7563
7563
|
type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
7564
|
+
/**
|
|
7565
|
+
* Log format type
|
|
7566
|
+
*/
|
|
7567
|
+
type LogFormat = 'pretty' | 'sls';
|
|
7564
7568
|
/**
|
|
7565
7569
|
* Logger configuration options
|
|
7566
7570
|
*
|
|
@@ -7600,6 +7604,7 @@ interface LoggerConfig {
|
|
|
7600
7604
|
logFile?: string;
|
|
7601
7605
|
maxFileSize?: string;
|
|
7602
7606
|
enableConsole?: boolean;
|
|
7607
|
+
format?: LogFormat | string;
|
|
7603
7608
|
}
|
|
7604
7609
|
/**
|
|
7605
7610
|
* Set the log level
|
package/dist/index.mjs
CHANGED
|
@@ -2325,11 +2325,20 @@ var LOG_LEVEL_VALUES = {
|
|
|
2325
2325
|
};
|
|
2326
2326
|
var currentRequestId = "";
|
|
2327
2327
|
var currentLogLevel = process.env.LOG_LEVEL || process.env.AGENTBAY_LOG_LEVEL || "INFO";
|
|
2328
|
+
var currentLogFormat = process.env.AGENTBAY_LOG_FORMAT || "pretty";
|
|
2329
|
+
if (["sls", "compact"].includes(String(currentLogFormat).toLowerCase())) {
|
|
2330
|
+
currentLogFormat = "sls";
|
|
2331
|
+
} else {
|
|
2332
|
+
currentLogFormat = "pretty";
|
|
2333
|
+
}
|
|
2328
2334
|
var fileLoggingEnabled = false;
|
|
2329
2335
|
var logFilePath = null;
|
|
2330
2336
|
var logFileMaxSize = 10 * 1024 * 1024;
|
|
2331
2337
|
var consoleLoggingEnabled = true;
|
|
2332
2338
|
function shouldUseColors() {
|
|
2339
|
+
if (currentLogFormat === "sls") {
|
|
2340
|
+
return false;
|
|
2341
|
+
}
|
|
2333
2342
|
if (process.env.DISABLE_COLORS === "true") {
|
|
2334
2343
|
return false;
|
|
2335
2344
|
}
|
|
@@ -2371,6 +2380,9 @@ var SENSITIVE_FIELDS = [
|
|
|
2371
2380
|
"authorization"
|
|
2372
2381
|
];
|
|
2373
2382
|
function getLogLevelEmoji(level) {
|
|
2383
|
+
if (currentLogFormat === "sls") {
|
|
2384
|
+
return level;
|
|
2385
|
+
}
|
|
2374
2386
|
switch (level) {
|
|
2375
2387
|
case "DEBUG":
|
|
2376
2388
|
return "\u{1F41B} DEBUG";
|
|
@@ -2390,6 +2402,13 @@ function shouldLog(level) {
|
|
|
2390
2402
|
}
|
|
2391
2403
|
__name(shouldLog, "shouldLog");
|
|
2392
2404
|
function formatLogMessage(level, message, forFile = false) {
|
|
2405
|
+
if (currentLogFormat === "sls") {
|
|
2406
|
+
let formattedMessage2 = `${level}: ${message}`;
|
|
2407
|
+
if (currentRequestId) {
|
|
2408
|
+
formattedMessage2 += ` [RequestId=${currentRequestId}]`;
|
|
2409
|
+
}
|
|
2410
|
+
return formattedMessage2;
|
|
2411
|
+
}
|
|
2393
2412
|
let formattedMessage = `${getLogLevelEmoji(level)}: ${message}`;
|
|
2394
2413
|
if (currentRequestId) {
|
|
2395
2414
|
formattedMessage += ` [RequestId=${currentRequestId}]`;
|
|
@@ -2537,6 +2556,23 @@ function setupLogger(config) {
|
|
|
2537
2556
|
if (config.enableConsole !== void 0) {
|
|
2538
2557
|
consoleLoggingEnabled = config.enableConsole;
|
|
2539
2558
|
}
|
|
2559
|
+
if (config.format) {
|
|
2560
|
+
if (["sls", "compact"].includes(String(config.format).toLowerCase())) {
|
|
2561
|
+
currentLogFormat = "sls";
|
|
2562
|
+
} else {
|
|
2563
|
+
currentLogFormat = "pretty";
|
|
2564
|
+
}
|
|
2565
|
+
} else {
|
|
2566
|
+
const envFormat = process.env.AGENTBAY_LOG_FORMAT;
|
|
2567
|
+
if (envFormat) {
|
|
2568
|
+
if (["sls", "compact"].includes(String(envFormat).toLowerCase())) {
|
|
2569
|
+
currentLogFormat = "sls";
|
|
2570
|
+
} else {
|
|
2571
|
+
currentLogFormat = "pretty";
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
useColors = shouldUseColors();
|
|
2540
2576
|
}
|
|
2541
2577
|
__name(setupLogger, "setupLogger");
|
|
2542
2578
|
function log(message, ...args) {
|
|
@@ -2644,6 +2680,22 @@ ${error.stack}`;
|
|
|
2644
2680
|
__name(logError, "logError");
|
|
2645
2681
|
function logAPICall(apiName, requestData) {
|
|
2646
2682
|
if (!shouldLog("INFO")) return;
|
|
2683
|
+
if (currentLogFormat === "sls") {
|
|
2684
|
+
let message2 = `API Call: ${apiName}`;
|
|
2685
|
+
if (requestData) {
|
|
2686
|
+
const maskedData = maskSensitiveData(requestData);
|
|
2687
|
+
if (typeof maskedData === "string") {
|
|
2688
|
+
message2 += `, ${maskedData}`;
|
|
2689
|
+
} else {
|
|
2690
|
+
message2 += `, ${JSON.stringify(maskedData)}`;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
if (consoleLoggingEnabled) {
|
|
2694
|
+
process.stdout.write(message2 + "\n");
|
|
2695
|
+
}
|
|
2696
|
+
writeToFile(message2);
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2647
2699
|
const message = `\u{1F517} API Call: ${apiName}`;
|
|
2648
2700
|
const savedRequestId = currentRequestId;
|
|
2649
2701
|
currentRequestId = "";
|
|
@@ -2661,6 +2713,35 @@ function logAPICall(apiName, requestData) {
|
|
|
2661
2713
|
}
|
|
2662
2714
|
__name(logAPICall, "logAPICall");
|
|
2663
2715
|
function logAPIResponseWithDetails(apiName, requestId, success = true, keyFields, fullResponse) {
|
|
2716
|
+
if (currentLogFormat === "sls") {
|
|
2717
|
+
if (!shouldLog(success ? "INFO" : "ERROR")) return;
|
|
2718
|
+
const status = success ? "API Response" : "API Response Failed";
|
|
2719
|
+
let msg = `${status}: ${apiName}`;
|
|
2720
|
+
if (requestId) {
|
|
2721
|
+
msg += `, RequestId=${requestId}`;
|
|
2722
|
+
}
|
|
2723
|
+
if (keyFields) {
|
|
2724
|
+
for (const [key, value] of Object.entries(keyFields)) {
|
|
2725
|
+
const maskedValue = maskSensitiveData({ [key]: value });
|
|
2726
|
+
msg += `, ${key}=${maskedValue[key]}`;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
if (success) {
|
|
2730
|
+
if (consoleLoggingEnabled) {
|
|
2731
|
+
process.stdout.write(msg + "\n");
|
|
2732
|
+
}
|
|
2733
|
+
writeToFile(msg);
|
|
2734
|
+
} else {
|
|
2735
|
+
if (consoleLoggingEnabled) {
|
|
2736
|
+
process.stderr.write(msg + "\n");
|
|
2737
|
+
}
|
|
2738
|
+
writeToFile(msg);
|
|
2739
|
+
}
|
|
2740
|
+
if (fullResponse && shouldLog("DEBUG")) {
|
|
2741
|
+
logDebug(`Full Response: ${fullResponse}`);
|
|
2742
|
+
}
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2664
2745
|
if (success) {
|
|
2665
2746
|
if (shouldLog("INFO")) {
|
|
2666
2747
|
let mainMessage = `\u2705 API Response: ${apiName}`;
|
|
@@ -2732,6 +2813,16 @@ function logCodeExecutionOutput(requestId, rawOutput) {
|
|
|
2732
2813
|
return;
|
|
2733
2814
|
}
|
|
2734
2815
|
const actualOutput = texts.join("");
|
|
2816
|
+
if (currentLogFormat === "sls") {
|
|
2817
|
+
const header2 = `Code Execution Output (RequestID: ${requestId}):`;
|
|
2818
|
+
if (consoleLoggingEnabled) {
|
|
2819
|
+
process.stdout.write(header2 + "\n");
|
|
2820
|
+
process.stdout.write(actualOutput + "\n");
|
|
2821
|
+
}
|
|
2822
|
+
writeToFile(header2);
|
|
2823
|
+
writeToFile(actualOutput);
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2735
2826
|
const header = `\u{1F4CB} Code Execution Output (RequestID: ${requestId}):`;
|
|
2736
2827
|
if (useColors) {
|
|
2737
2828
|
process.stdout.write(`${ANSI_GREEN}\u2139\uFE0F INFO: ${header}${ANSI_RESET}
|
|
@@ -2761,6 +2852,10 @@ function logCodeExecutionOutput(requestId, rawOutput) {
|
|
|
2761
2852
|
__name(logCodeExecutionOutput, "logCodeExecutionOutput");
|
|
2762
2853
|
function logInfoWithColor(message, color = ANSI_RED) {
|
|
2763
2854
|
if (!shouldLog("INFO")) return;
|
|
2855
|
+
if (currentLogFormat === "sls") {
|
|
2856
|
+
logInfo(message);
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2764
2859
|
const emoji = "\u2139\uFE0F INFO";
|
|
2765
2860
|
const fullMessage = `${emoji}: ${message}`;
|
|
2766
2861
|
if (useColors) {
|