agent-swarm-kit 1.0.225 → 1.0.227
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/build/index.cjs +48 -11
- package/build/index.mjs +48 -11
- package/package.json +1 -1
- package/types.d.ts +3 -3
package/build/index.cjs
CHANGED
|
@@ -2936,6 +2936,23 @@ const NOOP_LOGGER = {
|
|
|
2936
2936
|
info() {
|
|
2937
2937
|
},
|
|
2938
2938
|
};
|
|
2939
|
+
/**
|
|
2940
|
+
* A scoped context class for client-specific logging.
|
|
2941
|
+
* Provides a structured context containing method and execution-level metadata,
|
|
2942
|
+
* enabling traceability and context-aware logging for client-specific operations.
|
|
2943
|
+
*
|
|
2944
|
+
* This class is used to encapsulate and manage the logging context for a specific client,
|
|
2945
|
+
* ensuring that logs are enriched with relevant contextual information such as method and execution contexts.
|
|
2946
|
+
*
|
|
2947
|
+
* @param {Object} context - The logging context object.
|
|
2948
|
+
* @param {IMethodContext} context.methodContext - The method-level context, typically containing metadata like clientId.
|
|
2949
|
+
* @param {IExecutionContext} context.executionContext - The execution-level context, typically containing metadata like clientId.
|
|
2950
|
+
*/
|
|
2951
|
+
const ClientLoggerContext = diScoped.scoped(class {
|
|
2952
|
+
constructor(context) {
|
|
2953
|
+
this.context = context;
|
|
2954
|
+
}
|
|
2955
|
+
});
|
|
2939
2956
|
/**
|
|
2940
2957
|
* Service class implementing the ILogger interface to provide logging functionality in the swarm system.
|
|
2941
2958
|
* Handles log, debug, and info messages with context awareness using MethodContextService and ExecutionContextService, routing logs to both a client-specific logger (via GLOBAL_CONFIG.CC_GET_CLIENT_LOGGER_ADAPTER) and a common logger.
|
|
@@ -2980,7 +2997,10 @@ class LoggerService {
|
|
|
2980
2997
|
* @param {...any[]} args - The message content and optional additional data (e.g., objects, strings).
|
|
2981
2998
|
* @returns {void}
|
|
2982
2999
|
*/
|
|
2983
|
-
this.log = (topic, ...args) => {
|
|
3000
|
+
this.log = async (topic, ...args) => {
|
|
3001
|
+
if (ClientLoggerContext.hasContext()) {
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
2984
3004
|
const methodContext = MethodContextService.hasContext()
|
|
2985
3005
|
? this.methodContextService.context
|
|
2986
3006
|
: null;
|
|
@@ -2992,8 +3012,12 @@ class LoggerService {
|
|
|
2992
3012
|
methodContext,
|
|
2993
3013
|
executionContext,
|
|
2994
3014
|
};
|
|
2995
|
-
|
|
2996
|
-
|
|
3015
|
+
return await ClientLoggerContext.runInContext(async () => {
|
|
3016
|
+
if (clientId) {
|
|
3017
|
+
await this.getLoggerAdapter().log(clientId, topic, ...args, context);
|
|
3018
|
+
}
|
|
3019
|
+
await this._commonLogger.log(topic, ...args, context);
|
|
3020
|
+
}, context);
|
|
2997
3021
|
};
|
|
2998
3022
|
/**
|
|
2999
3023
|
* Logs messages at the debug level, routing to both the client-specific logger (if clientId exists) and the common logger.
|
|
@@ -3002,7 +3026,10 @@ class LoggerService {
|
|
|
3002
3026
|
* @param {...any[]} args - The debug content and optional additional data (e.g., objects, strings).
|
|
3003
3027
|
* @returns {void}
|
|
3004
3028
|
*/
|
|
3005
|
-
this.debug = (topic, ...args) => {
|
|
3029
|
+
this.debug = async (topic, ...args) => {
|
|
3030
|
+
if (ClientLoggerContext.hasContext()) {
|
|
3031
|
+
return;
|
|
3032
|
+
}
|
|
3006
3033
|
const methodContext = MethodContextService.hasContext()
|
|
3007
3034
|
? this.methodContextService.context
|
|
3008
3035
|
: null;
|
|
@@ -3014,9 +3041,12 @@ class LoggerService {
|
|
|
3014
3041
|
methodContext,
|
|
3015
3042
|
executionContext,
|
|
3016
3043
|
};
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3044
|
+
return await ClientLoggerContext.runInContext(async () => {
|
|
3045
|
+
if (clientId) {
|
|
3046
|
+
await this.getLoggerAdapter().debug(clientId, topic, ...args, context);
|
|
3047
|
+
}
|
|
3048
|
+
await this._commonLogger.debug(topic, ...args, context);
|
|
3049
|
+
}, context);
|
|
3020
3050
|
};
|
|
3021
3051
|
/**
|
|
3022
3052
|
* Logs messages at the info level, routing to both the client-specific logger (if clientId exists) and the common logger.
|
|
@@ -3025,7 +3055,10 @@ class LoggerService {
|
|
|
3025
3055
|
* @param {...any[]} args - The info content and optional additional data (e.g., objects, strings).
|
|
3026
3056
|
* @returns {void}
|
|
3027
3057
|
*/
|
|
3028
|
-
this.info = (topic, ...args) => {
|
|
3058
|
+
this.info = async (topic, ...args) => {
|
|
3059
|
+
if (ClientLoggerContext.hasContext()) {
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3029
3062
|
const methodContext = MethodContextService.hasContext()
|
|
3030
3063
|
? this.methodContextService.context
|
|
3031
3064
|
: null;
|
|
@@ -3037,8 +3070,12 @@ class LoggerService {
|
|
|
3037
3070
|
methodContext,
|
|
3038
3071
|
executionContext,
|
|
3039
3072
|
};
|
|
3040
|
-
|
|
3041
|
-
|
|
3073
|
+
return await ClientLoggerContext.runInContext(async () => {
|
|
3074
|
+
if (clientId) {
|
|
3075
|
+
await this.getLoggerAdapter().info(clientId, topic, ...args, context);
|
|
3076
|
+
}
|
|
3077
|
+
await this._commonLogger.info(topic, ...args, context);
|
|
3078
|
+
}, context);
|
|
3042
3079
|
};
|
|
3043
3080
|
/**
|
|
3044
3081
|
* Sets a new common logger instance, replacing the default NOOP_LOGGER or previous logger.
|
|
@@ -7859,7 +7896,7 @@ class AgentValidationService {
|
|
|
7859
7896
|
});
|
|
7860
7897
|
agent.wikiList?.forEach((wikiName) => {
|
|
7861
7898
|
if (typeof wikiName !== "string") {
|
|
7862
|
-
throw new Error(`agent-swarm agent ${agentName}
|
|
7899
|
+
throw new Error(`agent-swarm agent ${agentName} wiki list is invalid (wikiName=${String(wikiName)}) source=${source}`);
|
|
7863
7900
|
}
|
|
7864
7901
|
this.wikiValidationService.validate(wikiName, source);
|
|
7865
7902
|
});
|
package/build/index.mjs
CHANGED
|
@@ -2934,6 +2934,23 @@ const NOOP_LOGGER = {
|
|
|
2934
2934
|
info() {
|
|
2935
2935
|
},
|
|
2936
2936
|
};
|
|
2937
|
+
/**
|
|
2938
|
+
* A scoped context class for client-specific logging.
|
|
2939
|
+
* Provides a structured context containing method and execution-level metadata,
|
|
2940
|
+
* enabling traceability and context-aware logging for client-specific operations.
|
|
2941
|
+
*
|
|
2942
|
+
* This class is used to encapsulate and manage the logging context for a specific client,
|
|
2943
|
+
* ensuring that logs are enriched with relevant contextual information such as method and execution contexts.
|
|
2944
|
+
*
|
|
2945
|
+
* @param {Object} context - The logging context object.
|
|
2946
|
+
* @param {IMethodContext} context.methodContext - The method-level context, typically containing metadata like clientId.
|
|
2947
|
+
* @param {IExecutionContext} context.executionContext - The execution-level context, typically containing metadata like clientId.
|
|
2948
|
+
*/
|
|
2949
|
+
const ClientLoggerContext = scoped(class {
|
|
2950
|
+
constructor(context) {
|
|
2951
|
+
this.context = context;
|
|
2952
|
+
}
|
|
2953
|
+
});
|
|
2937
2954
|
/**
|
|
2938
2955
|
* Service class implementing the ILogger interface to provide logging functionality in the swarm system.
|
|
2939
2956
|
* Handles log, debug, and info messages with context awareness using MethodContextService and ExecutionContextService, routing logs to both a client-specific logger (via GLOBAL_CONFIG.CC_GET_CLIENT_LOGGER_ADAPTER) and a common logger.
|
|
@@ -2978,7 +2995,10 @@ class LoggerService {
|
|
|
2978
2995
|
* @param {...any[]} args - The message content and optional additional data (e.g., objects, strings).
|
|
2979
2996
|
* @returns {void}
|
|
2980
2997
|
*/
|
|
2981
|
-
this.log = (topic, ...args) => {
|
|
2998
|
+
this.log = async (topic, ...args) => {
|
|
2999
|
+
if (ClientLoggerContext.hasContext()) {
|
|
3000
|
+
return;
|
|
3001
|
+
}
|
|
2982
3002
|
const methodContext = MethodContextService.hasContext()
|
|
2983
3003
|
? this.methodContextService.context
|
|
2984
3004
|
: null;
|
|
@@ -2990,8 +3010,12 @@ class LoggerService {
|
|
|
2990
3010
|
methodContext,
|
|
2991
3011
|
executionContext,
|
|
2992
3012
|
};
|
|
2993
|
-
|
|
2994
|
-
|
|
3013
|
+
return await ClientLoggerContext.runInContext(async () => {
|
|
3014
|
+
if (clientId) {
|
|
3015
|
+
await this.getLoggerAdapter().log(clientId, topic, ...args, context);
|
|
3016
|
+
}
|
|
3017
|
+
await this._commonLogger.log(topic, ...args, context);
|
|
3018
|
+
}, context);
|
|
2995
3019
|
};
|
|
2996
3020
|
/**
|
|
2997
3021
|
* Logs messages at the debug level, routing to both the client-specific logger (if clientId exists) and the common logger.
|
|
@@ -3000,7 +3024,10 @@ class LoggerService {
|
|
|
3000
3024
|
* @param {...any[]} args - The debug content and optional additional data (e.g., objects, strings).
|
|
3001
3025
|
* @returns {void}
|
|
3002
3026
|
*/
|
|
3003
|
-
this.debug = (topic, ...args) => {
|
|
3027
|
+
this.debug = async (topic, ...args) => {
|
|
3028
|
+
if (ClientLoggerContext.hasContext()) {
|
|
3029
|
+
return;
|
|
3030
|
+
}
|
|
3004
3031
|
const methodContext = MethodContextService.hasContext()
|
|
3005
3032
|
? this.methodContextService.context
|
|
3006
3033
|
: null;
|
|
@@ -3012,9 +3039,12 @@ class LoggerService {
|
|
|
3012
3039
|
methodContext,
|
|
3013
3040
|
executionContext,
|
|
3014
3041
|
};
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3042
|
+
return await ClientLoggerContext.runInContext(async () => {
|
|
3043
|
+
if (clientId) {
|
|
3044
|
+
await this.getLoggerAdapter().debug(clientId, topic, ...args, context);
|
|
3045
|
+
}
|
|
3046
|
+
await this._commonLogger.debug(topic, ...args, context);
|
|
3047
|
+
}, context);
|
|
3018
3048
|
};
|
|
3019
3049
|
/**
|
|
3020
3050
|
* Logs messages at the info level, routing to both the client-specific logger (if clientId exists) and the common logger.
|
|
@@ -3023,7 +3053,10 @@ class LoggerService {
|
|
|
3023
3053
|
* @param {...any[]} args - The info content and optional additional data (e.g., objects, strings).
|
|
3024
3054
|
* @returns {void}
|
|
3025
3055
|
*/
|
|
3026
|
-
this.info = (topic, ...args) => {
|
|
3056
|
+
this.info = async (topic, ...args) => {
|
|
3057
|
+
if (ClientLoggerContext.hasContext()) {
|
|
3058
|
+
return;
|
|
3059
|
+
}
|
|
3027
3060
|
const methodContext = MethodContextService.hasContext()
|
|
3028
3061
|
? this.methodContextService.context
|
|
3029
3062
|
: null;
|
|
@@ -3035,8 +3068,12 @@ class LoggerService {
|
|
|
3035
3068
|
methodContext,
|
|
3036
3069
|
executionContext,
|
|
3037
3070
|
};
|
|
3038
|
-
|
|
3039
|
-
|
|
3071
|
+
return await ClientLoggerContext.runInContext(async () => {
|
|
3072
|
+
if (clientId) {
|
|
3073
|
+
await this.getLoggerAdapter().info(clientId, topic, ...args, context);
|
|
3074
|
+
}
|
|
3075
|
+
await this._commonLogger.info(topic, ...args, context);
|
|
3076
|
+
}, context);
|
|
3040
3077
|
};
|
|
3041
3078
|
/**
|
|
3042
3079
|
* Sets a new common logger instance, replacing the default NOOP_LOGGER or previous logger.
|
|
@@ -7857,7 +7894,7 @@ class AgentValidationService {
|
|
|
7857
7894
|
});
|
|
7858
7895
|
agent.wikiList?.forEach((wikiName) => {
|
|
7859
7896
|
if (typeof wikiName !== "string") {
|
|
7860
|
-
throw new Error(`agent-swarm agent ${agentName}
|
|
7897
|
+
throw new Error(`agent-swarm agent ${agentName} wiki list is invalid (wikiName=${String(wikiName)}) source=${source}`);
|
|
7861
7898
|
}
|
|
7862
7899
|
this.wikiValidationService.validate(wikiName, source);
|
|
7863
7900
|
});
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -3449,7 +3449,7 @@ declare class LoggerService implements ILogger {
|
|
|
3449
3449
|
* @param {...any[]} args - The message content and optional additional data (e.g., objects, strings).
|
|
3450
3450
|
* @returns {void}
|
|
3451
3451
|
*/
|
|
3452
|
-
log: (topic: string, ...args: any[]) => void
|
|
3452
|
+
log: (topic: string, ...args: any[]) => Promise<void>;
|
|
3453
3453
|
/**
|
|
3454
3454
|
* Logs messages at the debug level, routing to both the client-specific logger (if clientId exists) and the common logger.
|
|
3455
3455
|
* Attaches method and execution context for detailed debugging, heavily used in ClientAgent (e.g., RUN_FN, EXECUTE_FN) when GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG is true.
|
|
@@ -3457,7 +3457,7 @@ declare class LoggerService implements ILogger {
|
|
|
3457
3457
|
* @param {...any[]} args - The debug content and optional additional data (e.g., objects, strings).
|
|
3458
3458
|
* @returns {void}
|
|
3459
3459
|
*/
|
|
3460
|
-
debug: (topic: string, ...args: any[]) => void
|
|
3460
|
+
debug: (topic: string, ...args: any[]) => Promise<void>;
|
|
3461
3461
|
/**
|
|
3462
3462
|
* Logs messages at the info level, routing to both the client-specific logger (if clientId exists) and the common logger.
|
|
3463
3463
|
* Attaches method and execution context for informational tracking, used in PerfService (e.g., startExecution) and DocService (e.g., dumpDocs) when GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO is true.
|
|
@@ -3465,7 +3465,7 @@ declare class LoggerService implements ILogger {
|
|
|
3465
3465
|
* @param {...any[]} args - The info content and optional additional data (e.g., objects, strings).
|
|
3466
3466
|
* @returns {void}
|
|
3467
3467
|
*/
|
|
3468
|
-
info: (topic: string, ...args: any[]) => void
|
|
3468
|
+
info: (topic: string, ...args: any[]) => Promise<void>;
|
|
3469
3469
|
/**
|
|
3470
3470
|
* Sets a new common logger instance, replacing the default NOOP_LOGGER or previous logger.
|
|
3471
3471
|
* Allows runtime customization of system-wide logging behavior, potentially used in testing or advanced configurations (e.g., redirecting logs to a file or console).
|