agent-swarm-kit 1.0.74 → 1.0.76

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.74",
3
+ "version": "1.0.76",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "di-kit": "^1.0.12",
76
- "di-scoped": "^1.0.11",
76
+ "di-scoped": "^1.0.12",
77
77
  "functools-kit": "^1.0.74",
78
78
  "lodash-es": "4.17.21",
79
79
  "xml2js": "0.6.2"
package/types.d.ts CHANGED
@@ -460,7 +460,18 @@ interface ICustomEvent<T extends any = any> extends IBaseEvent {
460
460
  payload?: T;
461
461
  }
462
462
 
463
+ /**
464
+ * Interface representing a Bus.
465
+ */
463
466
  interface IBus {
467
+ /**
468
+ * Emits an event to a specific client.
469
+ *
470
+ * @template T - The type of event extending IBaseEvent.
471
+ * @param {string} clientId - The ID of the client to emit the event to.
472
+ * @param {T} event - The event to emit.
473
+ * @returns {Promise<void>} A promise that resolves when the event has been emitted.
474
+ */
464
475
  emit<T extends IBaseEvent>(clientId: string, event: T): Promise<void>;
465
476
  }
466
477
 
@@ -634,7 +645,7 @@ interface ISession {
634
645
  * @param {SendMessageFn} connector - The function to send messages.
635
646
  * @returns {ReceiveMessageFn}
636
647
  */
637
- connect(connector: SendMessageFn$1): ReceiveMessageFn;
648
+ connect(connector: SendMessageFn$1, ...args: unknown[]): ReceiveMessageFn;
638
649
  /**
639
650
  * Commit tool output.
640
651
  * @param {string} toolId - The `tool_call_id` for openai history
@@ -1412,6 +1423,7 @@ type ToolName = string;
1412
1423
  */
1413
1424
  interface IContext {
1414
1425
  clientId: string;
1426
+ requestId: string;
1415
1427
  agentName: AgentName;
1416
1428
  swarmName: SwarmName;
1417
1429
  storageName: StorageName;
@@ -1433,6 +1445,7 @@ declare const ContextService: (new () => {
1433
1445
  * Provides methods to log and debug messages.
1434
1446
  */
1435
1447
  declare class LoggerService implements ILogger {
1448
+ private readonly contextService;
1436
1449
  private _logger;
1437
1450
  /**
1438
1451
  * Logs messages using the current logger.
@@ -1960,7 +1973,7 @@ declare class SessionConnectionService implements ISession {
1960
1973
  * @param {SendMessageFn} connector - The function to send messages.
1961
1974
  * @returns {ReceiveMessageFn} The function to receive messages.
1962
1975
  */
1963
- connect: (connector: SendMessageFn$1) => ReceiveMessageFn;
1976
+ connect: (connector: SendMessageFn$1, clientId: string, swarmName: SwarmName) => ReceiveMessageFn;
1964
1977
  /**
1965
1978
  * Commits tool output to the session.
1966
1979
  * @param {string} toolId - The `tool_call_id` for openai history
@@ -2013,7 +2026,7 @@ declare class AgentPublicService implements TAgentConnectionService {
2013
2026
  * @param {AgentName} agentName - The name of the agent.
2014
2027
  * @returns {Promise<unknown>} The agent reference.
2015
2028
  */
2016
- createAgentRef: (clientId: string, agentName: AgentName) => Promise<ClientAgent>;
2029
+ createAgentRef: (requestId: string, clientId: string, agentName: AgentName) => Promise<ClientAgent>;
2017
2030
  /**
2018
2031
  * Executes a command on the agent.
2019
2032
  * @param {string} input - The input command.
@@ -2021,14 +2034,14 @@ declare class AgentPublicService implements TAgentConnectionService {
2021
2034
  * @param {AgentName} agentName - The name of the agent.
2022
2035
  * @returns {Promise<unknown>} The execution result.
2023
2036
  */
2024
- execute: (input: string, mode: ExecutionMode, clientId: string, agentName: AgentName) => Promise<void>;
2037
+ execute: (input: string, mode: ExecutionMode, requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2025
2038
  /**
2026
2039
  * Waits for the agent's output.
2027
2040
  * @param {string} clientId - The client ID.
2028
2041
  * @param {AgentName} agentName - The name of the agent.
2029
2042
  * @returns {Promise<unknown>} The output result.
2030
2043
  */
2031
- waitForOutput: (clientId: string, agentName: AgentName) => Promise<string>;
2044
+ waitForOutput: (requestId: string, clientId: string, agentName: AgentName) => Promise<string>;
2032
2045
  /**
2033
2046
  * Commits tool output to the agent.
2034
2047
  * @param {string} toolId - The `tool_call_id` for openai history
@@ -2037,7 +2050,7 @@ declare class AgentPublicService implements TAgentConnectionService {
2037
2050
  * @param {AgentName} agentName - The name of the agent.
2038
2051
  * @returns {Promise<unknown>} The commit result.
2039
2052
  */
2040
- commitToolOutput: (toolId: string, content: string, clientId: string, agentName: AgentName) => Promise<void>;
2053
+ commitToolOutput: (toolId: string, content: string, requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2041
2054
  /**
2042
2055
  * Commits a system message to the agent.
2043
2056
  * @param {string} message - The message to commit.
@@ -2045,7 +2058,7 @@ declare class AgentPublicService implements TAgentConnectionService {
2045
2058
  * @param {AgentName} agentName - The name of the agent.
2046
2059
  * @returns {Promise<unknown>} The commit result.
2047
2060
  */
2048
- commitSystemMessage: (message: string, clientId: string, agentName: AgentName) => Promise<void>;
2061
+ commitSystemMessage: (message: string, requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2049
2062
  /**
2050
2063
  * Commits user message to the agent without answer.
2051
2064
  * @param {string} message - The message to commit.
@@ -2053,28 +2066,28 @@ declare class AgentPublicService implements TAgentConnectionService {
2053
2066
  * @param {AgentName} agentName - The name of the agent.
2054
2067
  * @returns {Promise<unknown>} The commit result.
2055
2068
  */
2056
- commitUserMessage: (message: string, clientId: string, agentName: AgentName) => Promise<void>;
2069
+ commitUserMessage: (message: string, requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2057
2070
  /**
2058
2071
  * Commits flush of agent history
2059
2072
  * @param {string} clientId - The client ID.
2060
2073
  * @param {AgentName} agentName - The name of the agent.
2061
2074
  * @returns {Promise<unknown>} The commit result.
2062
2075
  */
2063
- commitFlush: (clientId: string, agentName: AgentName) => Promise<void>;
2076
+ commitFlush: (requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2064
2077
  /**
2065
2078
  * Commits change of agent to prevent the next tool execution from being called.
2066
2079
  * @param {string} clientId - The client ID.
2067
2080
  * @param {AgentName} agentName - The name of the agent.
2068
2081
  * @returns {Promise<unknown>} The commit result.
2069
2082
  */
2070
- commitAgentChange: (clientId: string, agentName: AgentName) => Promise<void>;
2083
+ commitAgentChange: (requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2071
2084
  /**
2072
2085
  * Disposes of the agent.
2073
2086
  * @param {string} clientId - The client ID.
2074
2087
  * @param {AgentName} agentName - The name of the agent.
2075
2088
  * @returns {Promise<unknown>} The dispose result.
2076
2089
  */
2077
- dispose: (clientId: string, agentName: AgentName) => Promise<void>;
2090
+ dispose: (requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2078
2091
  }
2079
2092
 
2080
2093
  interface IHistoryConnectionService extends HistoryConnectionService {
@@ -2099,7 +2112,7 @@ declare class HistoryPublicService implements THistoryConnectionService {
2099
2112
  * @param {AgentName} agentName - The agent name.
2100
2113
  * @returns {Promise<void>} A promise that resolves when the operation is complete.
2101
2114
  */
2102
- push: (message: IModelMessage, clientId: string, agentName: AgentName) => Promise<void>;
2115
+ push: (message: IModelMessage, requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2103
2116
  /**
2104
2117
  * Converts history to an array for a specific agent.
2105
2118
  * @param {string} prompt - The prompt.
@@ -2107,21 +2120,21 @@ declare class HistoryPublicService implements THistoryConnectionService {
2107
2120
  * @param {AgentName} agentName - The agent name.
2108
2121
  * @returns {Promise<any[]>} A promise that resolves to an array of history items.
2109
2122
  */
2110
- toArrayForAgent: (prompt: string, clientId: string, agentName: AgentName) => Promise<IModelMessage[]>;
2123
+ toArrayForAgent: (prompt: string, requestId: string, clientId: string, agentName: AgentName) => Promise<IModelMessage[]>;
2111
2124
  /**
2112
2125
  * Converts history to a raw array.
2113
2126
  * @param {string} clientId - The client ID.
2114
2127
  * @param {AgentName} agentName - The agent name.
2115
2128
  * @returns {Promise<any[]>} A promise that resolves to a raw array of history items.
2116
2129
  */
2117
- toArrayForRaw: (clientId: string, agentName: AgentName) => Promise<IModelMessage[]>;
2130
+ toArrayForRaw: (requestId: string, clientId: string, agentName: AgentName) => Promise<IModelMessage[]>;
2118
2131
  /**
2119
2132
  * Disposes of the history.
2120
2133
  * @param {string} clientId - The client ID.
2121
2134
  * @param {AgentName} agentName - The agent name.
2122
2135
  * @returns {Promise<void>} A promise that resolves when the operation is complete.
2123
2136
  */
2124
- dispose: (clientId: string, agentName: AgentName) => Promise<void>;
2137
+ dispose: (requestId: string, clientId: string, agentName: AgentName) => Promise<void>;
2125
2138
  }
2126
2139
 
2127
2140
  interface ISessionConnectionService extends SessionConnectionService {
@@ -2145,7 +2158,7 @@ declare class SessionPublicService implements TSessionConnectionService {
2145
2158
  * @param {SwarmName} swarmName - The swarm name.
2146
2159
  * @returns {Promise<void>}
2147
2160
  */
2148
- emit: (content: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2161
+ emit: (content: string, requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2149
2162
  /**
2150
2163
  * Executes a command in the session.
2151
2164
  * @param {string} content - The content to execute.
@@ -2153,7 +2166,7 @@ declare class SessionPublicService implements TSessionConnectionService {
2153
2166
  * @param {SwarmName} swarmName - The swarm name.
2154
2167
  * @returns {Promise<void>}
2155
2168
  */
2156
- execute: (content: string, mode: ExecutionMode, clientId: string, swarmName: SwarmName) => Promise<string>;
2169
+ execute: (content: string, mode: ExecutionMode, requestId: string, clientId: string, swarmName: SwarmName) => Promise<string>;
2157
2170
  /**
2158
2171
  * Connects to the session.
2159
2172
  * @param {SendMessageFn} connector - The function to send messages.
@@ -2161,7 +2174,7 @@ declare class SessionPublicService implements TSessionConnectionService {
2161
2174
  * @param {SwarmName} swarmName - The swarm name.
2162
2175
  * @returns {ReceiveMessageFn}
2163
2176
  */
2164
- connect: (connector: SendMessageFn$1, clientId: string, swarmName: SwarmName) => ReceiveMessageFn;
2177
+ connect: (connector: SendMessageFn$1, requestId: string, clientId: string, swarmName: SwarmName) => ReceiveMessageFn;
2165
2178
  /**
2166
2179
  * Commits tool output to the session.
2167
2180
  * @param {string} toolId - The `tool_call_id` for openai history
@@ -2170,7 +2183,7 @@ declare class SessionPublicService implements TSessionConnectionService {
2170
2183
  * @param {SwarmName} swarmName - The swarm name.
2171
2184
  * @returns {Promise<void>}
2172
2185
  */
2173
- commitToolOutput: (toolId: string, content: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2186
+ commitToolOutput: (toolId: string, content: string, requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2174
2187
  /**
2175
2188
  * Commits a system message to the session.
2176
2189
  * @param {string} message - The message to commit.
@@ -2178,7 +2191,7 @@ declare class SessionPublicService implements TSessionConnectionService {
2178
2191
  * @param {SwarmName} swarmName - The swarm name.
2179
2192
  * @returns {Promise<void>}
2180
2193
  */
2181
- commitSystemMessage: (message: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2194
+ commitSystemMessage: (message: string, requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2182
2195
  /**
2183
2196
  * Commits user message to the agent without answer.
2184
2197
  * @param {string} message - The message to commit.
@@ -2186,21 +2199,21 @@ declare class SessionPublicService implements TSessionConnectionService {
2186
2199
  * @param {SwarmName} swarmName - The swarm name.
2187
2200
  * @returns {Promise<void>}
2188
2201
  */
2189
- commitUserMessage: (message: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2202
+ commitUserMessage: (message: string, requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2190
2203
  /**
2191
2204
  * Commits flush of agent history
2192
2205
  * @param {string} clientId - The client ID.
2193
2206
  * @param {SwarmName} swarmName - The swarm name.
2194
2207
  * @returns {Promise<void>}
2195
2208
  */
2196
- commitFlush: (clientId: string, swarmName: SwarmName) => Promise<void>;
2209
+ commitFlush: (requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2197
2210
  /**
2198
2211
  * Disposes of the session.
2199
2212
  * @param {string} clientId - The client ID.
2200
2213
  * @param {SwarmName} swarmName - The swarm name.
2201
2214
  * @returns {Promise<void>}
2202
2215
  */
2203
- dispose: (clientId: string, swarmName: SwarmName) => Promise<void>;
2216
+ dispose: (requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2204
2217
  }
2205
2218
 
2206
2219
  interface ISwarmConnectionService extends SwarmConnectionService {
@@ -2223,28 +2236,28 @@ declare class SwarmPublicService implements TSwarmConnectionService {
2223
2236
  * @param {SwarmName} swarmName - The swarm name.
2224
2237
  * @returns {Promise<void>}
2225
2238
  */
2226
- cancelOutput: (clientId: string, swarmName: SwarmName) => Promise<void>;
2239
+ cancelOutput: (requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2227
2240
  /**
2228
2241
  * Waits for output from the swarm.
2229
2242
  * @param {string} clientId - The client ID.
2230
2243
  * @param {SwarmName} swarmName - The swarm name.
2231
2244
  * @returns {Promise<void>}
2232
2245
  */
2233
- waitForOutput: (clientId: string, swarmName: SwarmName) => Promise<string>;
2246
+ waitForOutput: (requestId: string, clientId: string, swarmName: SwarmName) => Promise<string>;
2234
2247
  /**
2235
2248
  * Gets the agent name from the swarm.
2236
2249
  * @param {string} clientId - The client ID.
2237
2250
  * @param {SwarmName} swarmName - The swarm name.
2238
2251
  * @returns {Promise<string>}
2239
2252
  */
2240
- getAgentName: (clientId: string, swarmName: SwarmName) => Promise<string>;
2253
+ getAgentName: (requestId: string, clientId: string, swarmName: SwarmName) => Promise<string>;
2241
2254
  /**
2242
2255
  * Gets the agent from the swarm.
2243
2256
  * @param {string} clientId - The client ID.
2244
2257
  * @param {SwarmName} swarmName - The swarm name.
2245
2258
  * @returns {Promise<IAgent>}
2246
2259
  */
2247
- getAgent: (clientId: string, swarmName: SwarmName) => Promise<IAgent>;
2260
+ getAgent: (requestId: string, clientId: string, swarmName: SwarmName) => Promise<IAgent>;
2248
2261
  /**
2249
2262
  * Sets the agent reference in the swarm.
2250
2263
  * @param {string} clientId - The client ID.
@@ -2253,7 +2266,7 @@ declare class SwarmPublicService implements TSwarmConnectionService {
2253
2266
  * @param {IAgent} agent - The agent instance.
2254
2267
  * @returns {Promise<void>}
2255
2268
  */
2256
- setAgentRef: (clientId: string, swarmName: SwarmName, agentName: AgentName, agent: IAgent) => Promise<void>;
2269
+ setAgentRef: (requestId: string, clientId: string, swarmName: SwarmName, agentName: AgentName, agent: IAgent) => Promise<void>;
2257
2270
  /**
2258
2271
  * Sets the agent name in the swarm.
2259
2272
  * @param {AgentName} agentName - The agent name.
@@ -2261,14 +2274,14 @@ declare class SwarmPublicService implements TSwarmConnectionService {
2261
2274
  * @param {SwarmName} swarmName - The swarm name.
2262
2275
  * @returns {Promise<void>}
2263
2276
  */
2264
- setAgentName: (agentName: AgentName, clientId: string, swarmName: SwarmName) => Promise<void>;
2277
+ setAgentName: (agentName: AgentName, requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2265
2278
  /**
2266
2279
  * Disposes of the swarm.
2267
2280
  * @param {string} clientId - The client ID.
2268
2281
  * @param {SwarmName} swarmName - The swarm name.
2269
2282
  * @returns {Promise<void>}
2270
2283
  */
2271
- dispose: (clientId: string, swarmName: SwarmName) => Promise<void>;
2284
+ dispose: (requestId: string, clientId: string, swarmName: SwarmName) => Promise<void>;
2272
2285
  }
2273
2286
 
2274
2287
  /**
@@ -2708,43 +2721,43 @@ declare class StoragePublicService implements TStorageConnectionService {
2708
2721
  * @param {number} total - The total number of items to retrieve.
2709
2722
  * @returns {Promise<IStorageData[]>} The list of storage data.
2710
2723
  */
2711
- take: (search: string, total: number, clientId: string, storageName: StorageName, score?: number) => Promise<IStorageData[]>;
2724
+ take: (search: string, total: number, requestId: string, clientId: string, storageName: StorageName, score?: number) => Promise<IStorageData[]>;
2712
2725
  /**
2713
2726
  * Upserts an item in the storage.
2714
2727
  * @param {IStorageData} item - The item to upsert.
2715
2728
  * @returns {Promise<void>}
2716
2729
  */
2717
- upsert: (item: IStorageData, clientId: string, storageName: StorageName) => Promise<void>;
2730
+ upsert: (item: IStorageData, requestId: string, clientId: string, storageName: StorageName) => Promise<void>;
2718
2731
  /**
2719
2732
  * Removes an item from the storage.
2720
2733
  * @param {IStorageData["id"]} itemId - The ID of the item to remove.
2721
2734
  * @returns {Promise<void>}
2722
2735
  */
2723
- remove: (itemId: IStorageData["id"], clientId: string, storageName: StorageName) => Promise<void>;
2736
+ remove: (itemId: IStorageData["id"], requestId: string, clientId: string, storageName: StorageName) => Promise<void>;
2724
2737
  /**
2725
2738
  * Retrieves an item from the storage by its ID.
2726
2739
  * @param {IStorageData["id"]} itemId - The ID of the item to retrieve.
2727
2740
  * @returns {Promise<IStorageData>} The retrieved item.
2728
2741
  */
2729
- get: (itemId: IStorageData["id"], clientId: string, storageName: StorageName) => Promise<IStorageData | null>;
2742
+ get: (itemId: IStorageData["id"], requestId: string, clientId: string, storageName: StorageName) => Promise<IStorageData | null>;
2730
2743
  /**
2731
2744
  * Retrieves a list of items from the storage, optionally filtered by a predicate function.
2732
2745
  * @param {function(IStorageData): boolean} [filter] - The optional filter function.
2733
2746
  * @returns {Promise<IStorageData[]>} The list of items.
2734
2747
  */
2735
- list: (clientId: string, storageName: StorageName, filter?: (item: IStorageData) => boolean) => Promise<IStorageData[]>;
2748
+ list: (requestId: string, clientId: string, storageName: StorageName, filter?: (item: IStorageData) => boolean) => Promise<IStorageData[]>;
2736
2749
  /**
2737
2750
  * Clears all items from the storage.
2738
2751
  * @returns {Promise<void>}
2739
2752
  */
2740
- clear: (clientId: string, storageName: StorageName) => Promise<void>;
2753
+ clear: (requestId: string, clientId: string, storageName: StorageName) => Promise<void>;
2741
2754
  /**
2742
2755
  * Disposes of the storage.
2743
2756
  * @param {string} clientId - The client ID.
2744
2757
  * @param {StorageName} storageName - The storage name.
2745
2758
  * @returns {Promise<void>}
2746
2759
  */
2747
- dispose: (clientId: string, storageName: StorageName) => Promise<void>;
2760
+ dispose: (requestId: string, clientId: string, storageName: StorageName) => Promise<void>;
2748
2761
  }
2749
2762
 
2750
2763
  /**
@@ -2892,21 +2905,21 @@ declare class StatePublicService<T extends IStateData = IStateData> implements T
2892
2905
  * @param {StateName} stateName - The name of the state.
2893
2906
  * @returns {Promise<T>} - The updated state.
2894
2907
  */
2895
- setState: (dispatchFn: (prevState: T) => Promise<T>, clientId: string, stateName: StateName) => Promise<T>;
2908
+ setState: (dispatchFn: (prevState: T) => Promise<T>, requestId: string, clientId: string, stateName: StateName) => Promise<T>;
2896
2909
  /**
2897
2910
  * Gets the current state.
2898
2911
  * @param {string} clientId - The client ID.
2899
2912
  * @param {StateName} stateName - The name of the state.
2900
2913
  * @returns {Promise<T>} - The current state.
2901
2914
  */
2902
- getState: (clientId: string, stateName: StateName) => Promise<T>;
2915
+ getState: (requestId: string, clientId: string, stateName: StateName) => Promise<T>;
2903
2916
  /**
2904
2917
  * Disposes the state.
2905
2918
  * @param {string} clientId - The client ID.
2906
2919
  * @param {StateName} stateName - The name of the state.
2907
2920
  * @returns {Promise<void>} - A promise that resolves when the state is disposed.
2908
2921
  */
2909
- dispose: (clientId: string, stateName: StateName) => Promise<void>;
2922
+ dispose: (requestId: string, clientId: string, stateName: StateName) => Promise<void>;
2910
2923
  }
2911
2924
 
2912
2925
  /**
@@ -2941,7 +2954,7 @@ declare class BusService implements IBus {
2941
2954
  * @param {EventSource} source - The event source.
2942
2955
  * @param {(event: T) => void} fn - The callback function to handle the event.
2943
2956
  */
2944
- subscribe: <T extends IBaseEvent>(clientId: string, source: EventSource, fn: (event: T) => void) => void;
2957
+ subscribe: <T extends IBaseEvent>(clientId: string, source: EventSource, fn: (event: T) => void) => () => void;
2945
2958
  /**
2946
2959
  * Subscribes to a single event for a specific client and source.
2947
2960
  * @param {string} clientId - The client ID.
@@ -3180,7 +3193,7 @@ interface ISessionConfig {
3180
3193
  * @param {SwarmName} swarmName - The name of the swarm.
3181
3194
  * @returns {Promise<void>} A promise that resolves when the connection is disposed.
3182
3195
  */
3183
- declare const disposeConnection: (clientId: string, swarmName: SwarmName) => Promise<void>;
3196
+ declare const disposeConnection: (clientId: string, swarmName: SwarmName, requestId?: string) => Promise<void>;
3184
3197
 
3185
3198
  /**
3186
3199
  * Retrieves the raw history as it is for a given client ID without any modifications.
@@ -3188,7 +3201,7 @@ declare const disposeConnection: (clientId: string, swarmName: SwarmName) => Pro
3188
3201
  * @param {string} clientId - The ID of the client whose history is to be retrieved.
3189
3202
  * @returns {Promise<Array>} A promise that resolves to an array containing the raw history.
3190
3203
  */
3191
- declare const getRawHistory: (clientId: string) => Promise<IModelMessage[]>;
3204
+ declare const getRawHistory: (clientId: string, requestId?: string) => Promise<IModelMessage[]>;
3192
3205
 
3193
3206
  /**
3194
3207
  * Retrieves the history prepared for a specific agent with resque algorithm tweaks
@@ -3334,7 +3347,16 @@ declare const executeForce: (content: string, clientId: string) => Promise<strin
3334
3347
  * @param {string} clientId - The ID of the client to listen for events from.
3335
3348
  * @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.
3336
3349
  */
3337
- declare const listenEvent: <T extends unknown = any>(clientId: string, topicName: string, fn: (data: T) => void) => void;
3350
+ declare const listenEvent: <T extends unknown = any>(clientId: string, topicName: string, fn: (data: T) => void) => () => void;
3351
+
3352
+ /**
3353
+ * Listens for an event on the swarm bus service and executes a callback function when the event is received.
3354
+ *
3355
+ * @template T - The type of the data payload.
3356
+ * @param {string} clientId - The ID of the client to listen for events from.
3357
+ * @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.
3358
+ */
3359
+ declare const listenEventOnce: <T extends unknown = any>(clientId: string, topicName: string, filterFn: (event: T) => boolean, fn: (data: T) => void) => () => void;
3338
3360
 
3339
3361
  /**
3340
3362
  * Retrieves the last message sent by the user from the client's message history.
@@ -3451,7 +3473,7 @@ declare const cancelOutputForce: (clientId: string) => Promise<void>;
3451
3473
  * @param {string} clientId - The ID of the client to subscribe to events for.
3452
3474
  * @param {function} fn - The callback function to handle the event.
3453
3475
  */
3454
- declare const listenAgentEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3476
+ declare const listenAgentEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3455
3477
 
3456
3478
  /**
3457
3479
  * Hook to subscribe to history events for a specific client.
@@ -3459,7 +3481,7 @@ declare const listenAgentEvent: (clientId: string, fn: (event: IBusEvent) => voi
3459
3481
  * @param {string} clientId - The ID of the client to subscribe to.
3460
3482
  * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
3461
3483
  */
3462
- declare const listenHistoryEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3484
+ declare const listenHistoryEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3463
3485
 
3464
3486
  /**
3465
3487
  * Hook to subscribe to session events for a specific client.
@@ -3467,7 +3489,7 @@ declare const listenHistoryEvent: (clientId: string, fn: (event: IBusEvent) => v
3467
3489
  * @param {string} clientId - The ID of the client to subscribe to session events for.
3468
3490
  * @param {function} fn - The callback function to handle the session events.
3469
3491
  */
3470
- declare const listenSessionEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3492
+ declare const listenSessionEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3471
3493
 
3472
3494
  /**
3473
3495
  * Hook to subscribe to state events for a specific client.
@@ -3475,7 +3497,7 @@ declare const listenSessionEvent: (clientId: string, fn: (event: IBusEvent) => v
3475
3497
  * @param {string} clientId - The ID of the client to subscribe to.
3476
3498
  * @param {function} fn - The callback function to handle the event.
3477
3499
  */
3478
- declare const listenStateEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3500
+ declare const listenStateEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3479
3501
 
3480
3502
  /**
3481
3503
  * Hook to subscribe to storage events for a specific client.
@@ -3483,7 +3505,7 @@ declare const listenStateEvent: (clientId: string, fn: (event: IBusEvent) => voi
3483
3505
  * @param {string} clientId - The ID of the client to subscribe to storage events for.
3484
3506
  * @param {function} fn - The callback function to handle the storage event.
3485
3507
  */
3486
- declare const listenStorageEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3508
+ declare const listenStorageEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3487
3509
 
3488
3510
  /**
3489
3511
  * Hook to subscribe to swarm events for a specific client.
@@ -3491,7 +3513,55 @@ declare const listenStorageEvent: (clientId: string, fn: (event: IBusEvent) => v
3491
3513
  * @param {string} clientId - The ID of the client to subscribe to events for.
3492
3514
  * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
3493
3515
  */
3494
- declare const listenSwarmEvent: (clientId: string, fn: (event: IBusEvent) => void) => void;
3516
+ declare const listenSwarmEvent: (clientId: string, fn: (event: IBusEvent) => void) => () => void;
3517
+
3518
+ /**
3519
+ * Hook to subscribe to agent events for a specific client.
3520
+ *
3521
+ * @param {string} clientId - The ID of the client to subscribe to events for.
3522
+ * @param {function} fn - The callback function to handle the event.
3523
+ */
3524
+ declare const listenAgentEventOnce: (clientId: string, filterFn: (event: IBusEvent) => boolean, fn: (event: IBusEvent) => void) => () => void;
3525
+
3526
+ /**
3527
+ * Hook to subscribe to history events for a specific client.
3528
+ *
3529
+ * @param {string} clientId - The ID of the client to subscribe to.
3530
+ * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
3531
+ */
3532
+ declare const listenHistoryEventOnce: (clientId: string, filterFn: (event: IBusEvent) => boolean, fn: (event: IBusEvent) => void) => () => void;
3533
+
3534
+ /**
3535
+ * Hook to subscribe to session events for a specific client.
3536
+ *
3537
+ * @param {string} clientId - The ID of the client to subscribe to session events for.
3538
+ * @param {function} fn - The callback function to handle the session events.
3539
+ */
3540
+ declare const listenSessionEventOnce: (clientId: string, filterFn: (event: IBusEvent) => boolean, fn: (event: IBusEvent) => void) => () => void;
3541
+
3542
+ /**
3543
+ * Hook to subscribe to state events for a specific client.
3544
+ *
3545
+ * @param {string} clientId - The ID of the client to subscribe to.
3546
+ * @param {function} fn - The callback function to handle the event.
3547
+ */
3548
+ declare const listenStateEventOnce: (clientId: string, filterFn: (event: IBusEvent) => boolean, fn: (event: IBusEvent) => void) => () => void;
3549
+
3550
+ /**
3551
+ * Hook to subscribe to storage events for a specific client.
3552
+ *
3553
+ * @param {string} clientId - The ID of the client to subscribe to storage events for.
3554
+ * @param {function} fn - The callback function to handle the storage event.
3555
+ */
3556
+ declare const listenStorageEventOnce: (clientId: string, filterFn: (event: IBusEvent) => boolean, fn: (event: IBusEvent) => void) => () => void;
3557
+
3558
+ /**
3559
+ * Hook to subscribe to swarm events for a specific client.
3560
+ *
3561
+ * @param {string} clientId - The ID of the client to subscribe to events for.
3562
+ * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
3563
+ */
3564
+ declare const listenSwarmEventOnce: (clientId: string, filterFn: (event: IBusEvent) => boolean, fn: (event: IBusEvent) => void) => () => void;
3495
3565
 
3496
3566
  declare const GLOBAL_CONFIG: {
3497
3567
  CC_TOOL_CALL_EXCEPTION_PROMPT: string;
@@ -3654,4 +3724,17 @@ declare class StateUtils implements TState {
3654
3724
  */
3655
3725
  declare const State: StateUtils;
3656
3726
 
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 };
3727
+ declare class LoggerUtils {
3728
+ /**
3729
+ * Sets the provided logger to the logger service.
3730
+ * @param {ILogger} logger - The logger instance to be used.
3731
+ */
3732
+ useLogger: (logger: ILogger) => void;
3733
+ }
3734
+ /**
3735
+ * Instance of LoggerUtils to be used for logging.
3736
+ * @type {LoggerUtils}
3737
+ */
3738
+ declare const Logger: LoggerUtils;
3739
+
3740
+ 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, Logger, 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, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };