agent-swarm-kit 1.0.80 → 1.0.82

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -63,17 +63,17 @@ interface ILogger {
63
63
  * Logs a message.
64
64
  * @param {...any[]} args - The message or messages to log.
65
65
  */
66
- log(...args: any[]): void;
66
+ log(topic: string, ...args: any[]): void;
67
67
  /**
68
68
  * Logs a debug message.
69
69
  * @param {...any[]} args - The debug message or messages to log.
70
70
  */
71
- debug(...args: any[]): void;
71
+ debug(topic: string, ...args: any[]): void;
72
72
  /**
73
73
  * Logs a info message.
74
74
  * @param {...any[]} args - The debug message or messages to log.
75
75
  */
76
- info(...args: any[]): void;
76
+ info(topic: string, ...args: any[]): void;
77
77
  }
78
78
 
79
79
  /**
@@ -548,7 +548,7 @@ interface ISwarmCallbacks extends ISwarmSessionCallbacks {
548
548
  interface ISwarmParams extends Omit<ISwarmSchema, keyof {
549
549
  agentList: never;
550
550
  onAgentChanged: never;
551
- }>, ISwarmCallbacks {
551
+ }> {
552
552
  /** Client identifier */
553
553
  clientId: string;
554
554
  /** Logger instance */
@@ -563,6 +563,10 @@ interface ISwarmParams extends Omit<ISwarmSchema, keyof {
563
563
  * @interface
564
564
  */
565
565
  interface ISwarmSchema {
566
+ /** Fetch the active agent on init */
567
+ getActiveAgent?: (clientId: string, swarmName: SwarmName, defaultAgent: AgentName) => Promise<AgentName> | AgentName;
568
+ /** Update the active agent after navigation */
569
+ setActiveAgent?: (clientId: string, agentName: AgentName, swarmName: SwarmName) => Promise<void> | void;
566
570
  /** Default agent name */
567
571
  defaultAgent: AgentName;
568
572
  /** Name of the swarm */
@@ -971,6 +975,7 @@ interface IHistoryInstance {
971
975
  * Type for History Instance Constructor
972
976
  */
973
977
  type THistoryInstanceCtor = new (clientId: string, ...args: unknown[]) => IHistoryInstance;
978
+ declare const HISTORY_INSTANCE_WAIT_FOR_INIT: unique symbol;
974
979
  /**
975
980
  * Class representing a History Instance
976
981
  */
@@ -978,11 +983,16 @@ declare class HistoryInstance implements IHistoryInstance {
978
983
  readonly clientId: string;
979
984
  readonly callbacks: Partial<IHistoryInstanceCallbacks>;
980
985
  private _array;
986
+ /**
987
+ * Makes the singleshot for initialization
988
+ * @param agentName - The agent name.
989
+ */
990
+ private [HISTORY_INSTANCE_WAIT_FOR_INIT];
981
991
  /**
982
992
  * Wait for the history to initialize.
983
993
  * @param agentName - The agent name.
984
994
  */
985
- waitForInit: ((agentName: AgentName) => Promise<void>) & functools_kit.ISingleshotClearable;
995
+ waitForInit(agentName: AgentName): Promise<void>;
986
996
  /**
987
997
  * Create a HistoryInstance.
988
998
  * @param clientId - The client ID.
@@ -1001,13 +1011,13 @@ declare class HistoryInstance implements IHistoryInstance {
1001
1011
  * @param agentName - The agent name.
1002
1012
  * @returns A promise that resolves when the message is pushed.
1003
1013
  */
1004
- push: (value: IModelMessage, agentName: AgentName) => Promise<void>;
1014
+ push(value: IModelMessage, agentName: AgentName): Promise<void>;
1005
1015
  /**
1006
1016
  * Dispose of the history for a given agent.
1007
1017
  * @param agentName - The agent name or null.
1008
1018
  * @returns A promise that resolves when the history is disposed.
1009
1019
  */
1010
- dispose: (agentName: AgentName | null) => Promise<void>;
1020
+ dispose(agentName: AgentName | null): Promise<void>;
1011
1021
  }
1012
1022
  /**
1013
1023
  * Class representing History Utilities
@@ -1470,22 +1480,26 @@ declare const MethodContextService: (new () => {
1470
1480
  declare class LoggerService implements ILogger {
1471
1481
  private readonly methodContextService;
1472
1482
  private readonly executionContextService;
1473
- private _logger;
1483
+ private _commonLogger;
1484
+ /**
1485
+ * Creates the client logs adapter using factory
1486
+ */
1487
+ private getLoggerAdapter;
1474
1488
  /**
1475
1489
  * Logs messages using the current logger.
1476
1490
  * @param {...any} args - The messages to log.
1477
1491
  */
1478
- log: (...args: any[]) => void;
1492
+ log: (topic: string, ...args: any[]) => void;
1479
1493
  /**
1480
1494
  * Logs debug messages using the current logger.
1481
1495
  * @param {...any} args - The debug messages to log.
1482
1496
  */
1483
- debug: (...args: any[]) => void;
1497
+ debug: (topic: string, ...args: any[]) => void;
1484
1498
  /**
1485
1499
  * Logs info messages using the current logger.
1486
1500
  * @param {...any} args - The info messages to log.
1487
1501
  */
1488
- info: (...args: any[]) => void;
1502
+ info: (topic: string, ...args: any[]) => void;
1489
1503
  /**
1490
1504
  * Sets a new logger.
1491
1505
  * @param {ILogger} logger - The new logger to set.
@@ -3595,11 +3609,169 @@ declare const listenStorageEventOnce: (clientId: string, filterFn: (event: IBusE
3595
3609
  */
3596
3610
  declare const listenSwarmEventOnce: (clientId: string, filterFn: (event: IBusEvent) => boolean, fn: (event: IBusEvent) => void) => () => void;
3597
3611
 
3612
+ declare const LOGGER_INSTANCE_WAIT_FOR_INIT: unique symbol;
3613
+ /**
3614
+ * @interface ILoggerInstanceCallbacks
3615
+ * @description Callbacks for logger instance events.
3616
+ */
3617
+ interface ILoggerInstanceCallbacks {
3618
+ onInit(clientId: string): void;
3619
+ onDispose(clientId: string): void;
3620
+ onLog(clientId: string, topic: string, ...args: any[]): void;
3621
+ onDebug(clientId: string, topic: string, ...args: any[]): void;
3622
+ onInfo(clientId: string, topic: string, ...args: any[]): void;
3623
+ }
3624
+ /**
3625
+ * @interface ILoggerInstance
3626
+ * @extends ILogger
3627
+ * @description Interface for logger instances.
3628
+ */
3629
+ interface ILoggerInstance extends ILogger {
3630
+ waitForInit(initial: boolean): Promise<void> | void;
3631
+ dispose(): Promise<void> | void;
3632
+ }
3633
+ /**
3634
+ * @interface ILoggerAdapter
3635
+ * @description Interface for logger adapter.
3636
+ */
3637
+ interface ILoggerAdapter {
3638
+ log(clientId: string, topic: string, ...args: any[]): Promise<void>;
3639
+ debug(clientId: string, topic: string, ...args: any[]): Promise<void>;
3640
+ info(clientId: string, topic: string, ...args: any[]): Promise<void>;
3641
+ dispose(clientId: string): Promise<void>;
3642
+ }
3643
+ /**
3644
+ * @interface ILoggerControl
3645
+ * @description Interface for logger control.
3646
+ */
3647
+ interface ILoggerControl {
3648
+ useCommonAdapter(logger: ILogger): void;
3649
+ useClientCallbacks(Callbacks: Partial<ILoggerInstanceCallbacks>): void;
3650
+ useClientAdapter(Ctor: TLoggerInstanceCtor): void;
3651
+ }
3652
+ type TLoggerInstanceCtor = new (clientId: string, ...args: unknown[]) => ILoggerInstance;
3653
+ /**
3654
+ * @class LoggerInstance
3655
+ * @implements ILoggerInstance
3656
+ * @description Logger instance class.
3657
+ */
3658
+ declare class LoggerInstance implements ILoggerInstance {
3659
+ readonly clientId: string;
3660
+ readonly callbacks: Partial<ILoggerInstanceCallbacks>;
3661
+ constructor(clientId: string, callbacks: Partial<ILoggerInstanceCallbacks>);
3662
+ private [LOGGER_INSTANCE_WAIT_FOR_INIT];
3663
+ /**
3664
+ * @method waitForInit
3665
+ * @description Waits for initialization.
3666
+ * @returns {Promise<void>}
3667
+ */
3668
+ waitForInit(): Promise<void>;
3669
+ /**
3670
+ * @method log
3671
+ * @description Logs a message.
3672
+ * @param {string} topic - The topic of the log.
3673
+ * @param {...any[]} args - The log arguments.
3674
+ */
3675
+ log(topic: string, ...args: any[]): void;
3676
+ /**
3677
+ * @method debug
3678
+ * @description Logs a debug message.
3679
+ * @param {string} topic - The topic of the debug log.
3680
+ * @param {...any[]} args - The debug log arguments.
3681
+ */
3682
+ debug(topic: string, ...args: any[]): void;
3683
+ /**
3684
+ * @method info
3685
+ * @description Logs an info message.
3686
+ * @param {string} topic - The topic of the info log.
3687
+ * @param {...any[]} args - The info log arguments.
3688
+ */
3689
+ info(topic: string, ...args: any[]): void;
3690
+ /**
3691
+ * @method dispose
3692
+ * @description Disposes the logger instance.
3693
+ */
3694
+ dispose(): void;
3695
+ }
3696
+ /**
3697
+ * @class LoggerUtils
3698
+ * @implements ILoggerAdapter, ILoggerControl
3699
+ * @description Utility class for logger.
3700
+ */
3701
+ declare class LoggerUtils implements ILoggerAdapter, ILoggerControl {
3702
+ private LoggerFactory;
3703
+ private LoggerCallbacks;
3704
+ private getLogger;
3705
+ /**
3706
+ * @method useCommonAdapter
3707
+ * @description Sets the common logger adapter.
3708
+ * @param {ILogger} logger - The logger instance.
3709
+ */
3710
+ useCommonAdapter: (logger: ILogger) => void;
3711
+ /**
3712
+ * @method useClientCallbacks
3713
+ * @description Sets the client-specific callbacks.
3714
+ * @param {Partial<ILoggerInstanceCallbacks>} Callbacks - The callbacks.
3715
+ */
3716
+ useClientCallbacks: (Callbacks: Partial<ILoggerInstanceCallbacks>) => void;
3717
+ /**
3718
+ * @method useClientAdapter
3719
+ * @description Sets the client-specific logger adapter.
3720
+ * @param {TLoggerInstanceCtor} Ctor - The logger instance constructor.
3721
+ */
3722
+ useClientAdapter: (Ctor: TLoggerInstanceCtor) => void;
3723
+ /**
3724
+ * @method log
3725
+ * @description Logs a message.
3726
+ * @param {string} clientId - The client ID.
3727
+ * @param {string} topic - The topic of the log.
3728
+ * @param {...any[]} args - The log arguments.
3729
+ * @returns {Promise<void>}
3730
+ */
3731
+ log: (clientId: string, topic: string, ...args: any[]) => Promise<void>;
3732
+ /**
3733
+ * @method debug
3734
+ * @description Logs a debug message.
3735
+ * @param {string} clientId - The client ID.
3736
+ * @param {string} topic - The topic of the debug log.
3737
+ * @param {...any[]} args - The debug log arguments.
3738
+ * @returns {Promise<void>}
3739
+ */
3740
+ debug: (clientId: string, topic: string, ...args: any[]) => Promise<void>;
3741
+ /**
3742
+ * @method info
3743
+ * @description Logs an info message.
3744
+ * @param {string} clientId - The client ID.
3745
+ * @param {string} topic - The topic of the info log.
3746
+ * @param {...any[]} args - The info log arguments.
3747
+ * @returns {Promise<void>}
3748
+ */
3749
+ info: (clientId: string, topic: string, ...args: any[]) => Promise<void>;
3750
+ /**
3751
+ * @method dispose
3752
+ * @description Disposes the logger instance.
3753
+ * @param {string} clientId - The client ID.
3754
+ * @returns {Promise<void>}
3755
+ */
3756
+ dispose: (clientId: string) => Promise<void>;
3757
+ }
3758
+ /**
3759
+ * @constant LoggerAdapter
3760
+ * @description Singleton instance of LoggerUtils.
3761
+ */
3762
+ declare const LoggerAdapter: LoggerUtils;
3763
+ /**
3764
+ * @constant Logger
3765
+ * @description Logger control interface.
3766
+ */
3767
+ declare const Logger: ILoggerControl;
3768
+
3598
3769
  declare const GLOBAL_CONFIG: {
3599
3770
  CC_TOOL_CALL_EXCEPTION_PROMPT: string;
3600
3771
  CC_EMPTY_OUTPUT_PLACEHOLDERS: string[];
3601
3772
  CC_KEEP_MESSAGES: number;
3602
3773
  CC_GET_AGENT_HISTORY_ADAPTER: (clientId: string, agentName: AgentName) => IHistoryAdapter;
3774
+ CC_GET_CLIENT_LOGGER_ADAPTER: () => ILoggerAdapter;
3603
3775
  CC_SWARM_AGENT_CHANGED: (clientId: string, agentName: AgentName, swarmName: SwarmName) => Promise<void>;
3604
3776
  CC_SWARM_DEFAULT_AGENT: (clientId: string, swarmName: SwarmName, defaultAgent: AgentName) => Promise<AgentName>;
3605
3777
  CC_AGENT_DEFAULT_VALIDATION: (output: string) => Promise<string | null>;
@@ -3760,19 +3932,6 @@ declare class StateUtils implements TState {
3760
3932
  */
3761
3933
  declare const State: StateUtils;
3762
3934
 
3763
- declare class LoggerUtils {
3764
- /**
3765
- * Sets the provided logger to the logger service.
3766
- * @param {ILogger} logger - The logger instance to be used.
3767
- */
3768
- useLogger: (logger: ILogger) => void;
3769
- }
3770
- /**
3771
- * Instance of LoggerUtils to be used for logging.
3772
- * @type {LoggerUtils}
3773
- */
3774
- declare const Logger: LoggerUtils;
3775
-
3776
3935
  /**
3777
3936
  * Utility class for schema-related operations.
3778
3937
  */
@@ -3791,4 +3950,4 @@ declare class SchemaUtils {
3791
3950
  */
3792
3951
  declare const Schema: SchemaUtils;
3793
3952
 
3794
- export { type EventSource, ExecutionContextService, History, HistoryAdapter, HistoryInstance, type IAgentSchema, type IAgentTool, type IBaseEvent, type IBusEvent, type IBusEventContext, type ICompletionArgs, type ICompletionSchema, type ICustomEvent, type IEmbeddingSchema, type IHistoryAdapter, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type IStateSchema, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, Logger, MethodContextService, type ReceiveMessageFn, Schema, type SendMessageFn$1 as SendMessageFn, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
3953
+ export { type EventSource, ExecutionContextService, History, HistoryAdapter, HistoryInstance, type IAgentSchema, type IAgentTool, type IBaseEvent, type IBusEvent, type IBusEventContext, type ICompletionArgs, type ICompletionSchema, type ICustomEvent, type IEmbeddingSchema, type IHistoryAdapter, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type ILoggerAdapter, type ILoggerInstance, type ILoggerInstanceCallbacks, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type IStateSchema, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, Logger, LoggerAdapter, LoggerInstance, MethodContextService, type ReceiveMessageFn, Schema, type SendMessageFn$1 as SendMessageFn, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };