agent-swarm-kit 1.0.72 → 1.0.74

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.72",
3
+ "version": "1.0.74",
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
@@ -390,7 +390,7 @@ type StateName = string;
390
390
  /**
391
391
  * Interface representing the base context for an event.
392
392
  */
393
- interface IBaseEventContext {
393
+ interface IBusEventContext {
394
394
  /**
395
395
  * The name of the agent.
396
396
  */
@@ -412,6 +412,10 @@ interface IBaseEventContext {
412
412
  * Type representing the possible sources of an event.
413
413
  */
414
414
  type EventSource = string;
415
+ /**
416
+ * Type representing the possible sources of an event for the internal bus.
417
+ */
418
+ type EventBusSource = "agent-bus" | "history-bus" | "session-bus" | "state-bus" | "storage-bus" | "swarm-bus";
415
419
  /**
416
420
  * Interface representing the base structure of an event.
417
421
  */
@@ -420,8 +424,18 @@ interface IBaseEvent {
420
424
  * The source of the event.
421
425
  */
422
426
  source: EventSource;
427
+ /**
428
+ * The client id
429
+ */
430
+ clientId: string;
423
431
  }
424
- interface IBusEvent extends IBaseEvent {
432
+ interface IBusEvent extends Omit<IBaseEvent, keyof {
433
+ source: never;
434
+ }> {
435
+ /**
436
+ * The source of the event.
437
+ */
438
+ source: EventBusSource;
425
439
  /**
426
440
  * The type of the event.
427
441
  */
@@ -437,7 +451,13 @@ interface IBusEvent extends IBaseEvent {
437
451
  /**
438
452
  * The context of the event.
439
453
  */
440
- context: Partial<IBaseEventContext>;
454
+ context: Partial<IBusEventContext>;
455
+ }
456
+ interface ICustomEvent<T extends any = any> extends IBaseEvent {
457
+ /**
458
+ * The payload of the event, if any.
459
+ */
460
+ payload?: T;
441
461
  }
442
462
 
443
463
  interface IBus {
@@ -2911,16 +2931,17 @@ declare class StateSchemaService {
2911
2931
 
2912
2932
  declare class BusService implements IBus {
2913
2933
  private readonly loggerService;
2934
+ private readonly sessionValidationService;
2914
2935
  private _eventSourceSet;
2936
+ private _eventWildcardMap;
2915
2937
  private getEventSubject;
2916
2938
  /**
2917
2939
  * Subscribes to events for a specific client and source.
2918
2940
  * @param {string} clientId - The client ID.
2919
2941
  * @param {EventSource} source - The event source.
2920
2942
  * @param {(event: T) => void} fn - The callback function to handle the event.
2921
- * @returns {Subscription} The subscription object.
2922
2943
  */
2923
- subscribe: <T extends IBaseEvent>(clientId: string, source: EventSource, fn: (event: T) => void) => () => void;
2944
+ subscribe: <T extends IBaseEvent>(clientId: string, source: EventSource, fn: (event: T) => void) => void;
2924
2945
  /**
2925
2946
  * Subscribes to a single event for a specific client and source.
2926
2947
  * @param {string} clientId - The client ID.
@@ -3312,9 +3333,8 @@ declare const executeForce: (content: string, clientId: string) => Promise<strin
3312
3333
  * @template T - The type of the data payload.
3313
3334
  * @param {string} clientId - The ID of the client to listen for events from.
3314
3335
  * @param {(data: T) => void} fn - The callback function to execute when the event is received. The data payload is passed as an argument to this function.
3315
- * @returns {void} - Returns nothing.
3316
3336
  */
3317
- declare const listenEvent: <T extends unknown = any>(clientId: string, topicName: string, fn: (data: T) => void) => () => void;
3337
+ declare const listenEvent: <T extends unknown = any>(clientId: string, topicName: string, fn: (data: T) => void) => void;
3318
3338
 
3319
3339
  /**
3320
3340
  * Retrieves the last message sent by the user from the client's message history.
@@ -3430,54 +3450,48 @@ declare const cancelOutputForce: (clientId: string) => Promise<void>;
3430
3450
  *
3431
3451
  * @param {string} clientId - The ID of the client to subscribe to events for.
3432
3452
  * @param {function} fn - The callback function to handle the event.
3433
- * @returns {function} - A function to unsubscribe from the event.
3434
3453
  */
3435
- declare const listenAgentEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3454
+ declare const listenAgentEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3436
3455
 
3437
3456
  /**
3438
3457
  * Hook to subscribe to history events for a specific client.
3439
3458
  *
3440
3459
  * @param {string} clientId - The ID of the client to subscribe to.
3441
3460
  * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
3442
- * @returns {Function} - The unsubscribe function.
3443
3461
  */
3444
- declare const listenHistoryEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3462
+ declare const listenHistoryEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3445
3463
 
3446
3464
  /**
3447
3465
  * Hook to subscribe to session events for a specific client.
3448
3466
  *
3449
3467
  * @param {string} clientId - The ID of the client to subscribe to session events for.
3450
3468
  * @param {function} fn - The callback function to handle the session events.
3451
- * @returns {function} - The unsubscribe function to stop listening to session events.
3452
3469
  */
3453
- declare const listenSessionEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3470
+ declare const listenSessionEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3454
3471
 
3455
3472
  /**
3456
3473
  * Hook to subscribe to state events for a specific client.
3457
3474
  *
3458
3475
  * @param {string} clientId - The ID of the client to subscribe to.
3459
3476
  * @param {function} fn - The callback function to handle the event.
3460
- * @returns {function} - The unsubscribe function to stop listening to the events.
3461
3477
  */
3462
- declare const listenStateEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3478
+ declare const listenStateEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3463
3479
 
3464
3480
  /**
3465
3481
  * Hook to subscribe to storage events for a specific client.
3466
3482
  *
3467
3483
  * @param {string} clientId - The ID of the client to subscribe to storage events for.
3468
3484
  * @param {function} fn - The callback function to handle the storage event.
3469
- * @returns {function} - A function to unsubscribe from the storage events.
3470
3485
  */
3471
- declare const listenStorageEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3486
+ declare const listenStorageEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3472
3487
 
3473
3488
  /**
3474
3489
  * Hook to subscribe to swarm events for a specific client.
3475
3490
  *
3476
3491
  * @param {string} clientId - The ID of the client to subscribe to events for.
3477
3492
  * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
3478
- * @returns {Function} - A function to unsubscribe from the event.
3479
3493
  */
3480
- declare const listenSwarmEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3494
+ declare const listenSwarmEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3481
3495
 
3482
3496
  declare const GLOBAL_CONFIG: {
3483
3497
  CC_TOOL_CALL_EXCEPTION_PROMPT: string;
@@ -3640,4 +3654,4 @@ declare class StateUtils implements TState {
3640
3654
  */
3641
3655
  declare const State: StateUtils;
3642
3656
 
3643
- export { ContextService, type EventSource, History, HistoryAdapter, HistoryInstance, type IAgentSchema, type IAgentTool, type IBaseEvent, type IBaseEventContext, type ICompletionArgs, type ICompletionSchema, 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, type ReceiveMessageFn, 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, listenEvent, listenHistoryEvent, listenSessionEvent, listenStateEvent, listenStorageEvent, listenSwarmEvent, makeAutoDispose, makeConnection, session, setConfig, swarm };
3657
+ export { ContextService, type EventSource, 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, type ReceiveMessageFn, 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, listenEvent, listenHistoryEvent, listenSessionEvent, listenStateEvent, listenStorageEvent, listenSwarmEvent, makeAutoDispose, makeConnection, session, setConfig, swarm };