@kadi.build/core 0.0.1-alpha.3 → 0.0.1-alpha.5

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.
Files changed (128) hide show
  1. package/README.md +754 -606
  2. package/dist/KadiClient.d.ts +440 -0
  3. package/dist/KadiClient.d.ts.map +1 -0
  4. package/dist/KadiClient.js +1518 -0
  5. package/dist/KadiClient.js.map +1 -0
  6. package/dist/errors/error-codes.d.ts +215 -0
  7. package/dist/errors/error-codes.d.ts.map +1 -0
  8. package/dist/errors/error-codes.js +295 -0
  9. package/dist/errors/error-codes.js.map +1 -0
  10. package/dist/index.d.ts +15 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +24 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/loadAbility.d.ts +106 -0
  15. package/dist/loadAbility.d.ts.map +1 -0
  16. package/dist/loadAbility.js +376 -0
  17. package/dist/loadAbility.js.map +1 -0
  18. package/dist/messages/BrokerMessages.d.ts +84 -0
  19. package/dist/messages/BrokerMessages.d.ts.map +1 -0
  20. package/dist/messages/BrokerMessages.js +125 -0
  21. package/dist/messages/BrokerMessages.js.map +1 -0
  22. package/dist/messages/MessageBuilder.d.ts +83 -0
  23. package/dist/messages/MessageBuilder.d.ts.map +1 -0
  24. package/dist/messages/MessageBuilder.js +144 -0
  25. package/dist/messages/MessageBuilder.js.map +1 -0
  26. package/dist/schemas/events.schemas.d.ts +177 -0
  27. package/dist/schemas/events.schemas.d.ts.map +1 -0
  28. package/dist/schemas/events.schemas.js +265 -0
  29. package/dist/schemas/events.schemas.js.map +1 -0
  30. package/dist/schemas/index.d.ts +3 -0
  31. package/dist/schemas/index.d.ts.map +1 -0
  32. package/dist/schemas/index.js +4 -0
  33. package/dist/schemas/index.js.map +1 -0
  34. package/dist/schemas/kadi.schemas.d.ts +70 -0
  35. package/dist/schemas/kadi.schemas.d.ts.map +1 -0
  36. package/dist/schemas/kadi.schemas.js +120 -0
  37. package/dist/schemas/kadi.schemas.js.map +1 -0
  38. package/dist/transports/BrokerTransport.d.ts +106 -0
  39. package/dist/transports/BrokerTransport.d.ts.map +1 -0
  40. package/dist/transports/BrokerTransport.js +177 -0
  41. package/dist/transports/BrokerTransport.js.map +1 -0
  42. package/dist/transports/NativeTransport.d.ts +82 -0
  43. package/dist/transports/NativeTransport.d.ts.map +1 -0
  44. package/dist/transports/NativeTransport.js +263 -0
  45. package/dist/transports/NativeTransport.js.map +1 -0
  46. package/dist/transports/StdioTransport.d.ts +112 -0
  47. package/dist/transports/StdioTransport.d.ts.map +1 -0
  48. package/dist/transports/StdioTransport.js +445 -0
  49. package/dist/transports/StdioTransport.js.map +1 -0
  50. package/dist/transports/Transport.d.ts +93 -0
  51. package/dist/transports/Transport.d.ts.map +1 -0
  52. package/dist/transports/Transport.js +13 -0
  53. package/dist/transports/Transport.js.map +1 -0
  54. package/dist/types/broker.d.ts +31 -0
  55. package/dist/types/broker.d.ts.map +1 -0
  56. package/dist/types/broker.js +6 -0
  57. package/dist/types/broker.js.map +1 -0
  58. package/dist/types/core.d.ts +139 -0
  59. package/dist/types/core.d.ts.map +1 -0
  60. package/dist/types/core.js +26 -0
  61. package/dist/types/core.js.map +1 -0
  62. package/dist/types/events.d.ts +186 -0
  63. package/dist/types/events.d.ts.map +1 -0
  64. package/dist/types/events.js +16 -0
  65. package/dist/types/events.js.map +1 -0
  66. package/dist/types/index.d.ts +9 -0
  67. package/dist/types/index.d.ts.map +1 -0
  68. package/dist/types/index.js +13 -0
  69. package/dist/types/index.js.map +1 -0
  70. package/dist/types/protocol.d.ts +160 -0
  71. package/dist/types/protocol.d.ts.map +1 -0
  72. package/dist/types/protocol.js +5 -0
  73. package/dist/types/protocol.js.map +1 -0
  74. package/dist/utils/agentUtils.d.ts +187 -0
  75. package/dist/utils/agentUtils.d.ts.map +1 -0
  76. package/dist/utils/agentUtils.js +185 -0
  77. package/dist/utils/agentUtils.js.map +1 -0
  78. package/dist/utils/commandUtils.d.ts +45 -0
  79. package/dist/utils/commandUtils.d.ts.map +1 -0
  80. package/dist/utils/commandUtils.js +145 -0
  81. package/dist/utils/commandUtils.js.map +1 -0
  82. package/dist/utils/configUtils.d.ts +55 -0
  83. package/dist/utils/configUtils.d.ts.map +1 -0
  84. package/dist/utils/configUtils.js +100 -0
  85. package/dist/utils/configUtils.js.map +1 -0
  86. package/dist/utils/logger.d.ts +59 -0
  87. package/dist/utils/logger.d.ts.map +1 -0
  88. package/dist/utils/logger.js +122 -0
  89. package/dist/utils/logger.js.map +1 -0
  90. package/dist/utils/pathUtils.d.ts +48 -0
  91. package/dist/utils/pathUtils.d.ts.map +1 -0
  92. package/dist/utils/pathUtils.js +128 -0
  93. package/dist/utils/pathUtils.js.map +1 -0
  94. package/package.json +56 -5
  95. package/agent.json +0 -18
  96. package/examples/example-abilities/echo-js/README.md +0 -131
  97. package/examples/example-abilities/echo-js/agent.json +0 -63
  98. package/examples/example-abilities/echo-js/package.json +0 -24
  99. package/examples/example-abilities/echo-js/service.js +0 -43
  100. package/examples/example-abilities/hash-go/agent.json +0 -53
  101. package/examples/example-abilities/hash-go/cmd/hash_ability/main.go +0 -340
  102. package/examples/example-abilities/hash-go/go.mod +0 -3
  103. package/examples/example-agent/abilities/echo-js/0.0.1/README.md +0 -131
  104. package/examples/example-agent/abilities/echo-js/0.0.1/agent.json +0 -63
  105. package/examples/example-agent/abilities/echo-js/0.0.1/package-lock.json +0 -93
  106. package/examples/example-agent/abilities/echo-js/0.0.1/package.json +0 -24
  107. package/examples/example-agent/abilities/echo-js/0.0.1/service.js +0 -41
  108. package/examples/example-agent/abilities/hash-go/0.0.1/agent.json +0 -53
  109. package/examples/example-agent/abilities/hash-go/0.0.1/bin/hash_ability +0 -0
  110. package/examples/example-agent/abilities/hash-go/0.0.1/cmd/hash_ability/main.go +0 -340
  111. package/examples/example-agent/abilities/hash-go/0.0.1/go.mod +0 -3
  112. package/examples/example-agent/agent.json +0 -39
  113. package/examples/example-agent/index.js +0 -102
  114. package/examples/example-agent/package-lock.json +0 -93
  115. package/examples/example-agent/package.json +0 -17
  116. package/src/KadiAbility.js +0 -478
  117. package/src/index.js +0 -65
  118. package/src/loadAbility.js +0 -1086
  119. package/src/servers/BaseRpcServer.js +0 -404
  120. package/src/servers/BrokerRpcServer.js +0 -776
  121. package/src/servers/StdioRpcServer.js +0 -360
  122. package/src/transport/BrokerMessageBuilder.js +0 -377
  123. package/src/transport/IpcMessageBuilder.js +0 -1229
  124. package/src/utils/agentUtils.js +0 -137
  125. package/src/utils/commandUtils.js +0 -64
  126. package/src/utils/configUtils.js +0 -72
  127. package/src/utils/logger.js +0 -161
  128. package/src/utils/pathUtils.js +0 -86
@@ -0,0 +1,440 @@
1
+ import { EventEmitter } from 'events';
2
+ import { JSONSchema, BrokerConnection } from './types/core.js';
3
+ import { LoadedAbility } from './loadAbility.js';
4
+ export interface KadiClientConfig {
5
+ /** Agent display name for identification */
6
+ name?: string;
7
+ /** Agent version string */
8
+ version?: string;
9
+ /** Human-readable description of the agent */
10
+ description?: string;
11
+ /** Role when connecting to broker - determines available operations */
12
+ role?: 'agent' | 'ability';
13
+ /** Communication protocol - determines how the client serves requests */
14
+ protocol?: 'native' | 'stdio' | 'broker';
15
+ /** Primary network segment for message routing - defines which network this client operates in. Used for isolation and access control between different environments. */
16
+ network?: string;
17
+ /** Additional network identifiers this client belongs to - enables participation in multiple network segments simultaneously */
18
+ networks?: string[];
19
+ /** Named broker configurations - enables connection to multiple brokers simultaneously */
20
+ brokers?: {
21
+ [brokerName: string]: string;
22
+ };
23
+ /** Default broker name for message routing when no specific broker is targeted */
24
+ defaultBroker?: string;
25
+ /** Maximum buffer size for message handling (primarily for stdio protocol) */
26
+ maxBufferSize?: number;
27
+ /** Path to ability agent.json configuration file */
28
+ abilityAgentJSON?: string;
29
+ [key: string]: any;
30
+ }
31
+ export interface ToolSchema {
32
+ name?: string;
33
+ description?: string;
34
+ inputSchema?: JSONSchema;
35
+ outputSchema?: JSONSchema;
36
+ }
37
+ type ToolHandler = (params: unknown) => Promise<unknown>;
38
+ interface RegisteredTool {
39
+ name: string;
40
+ handler: ToolHandler;
41
+ schema?: ToolSchema;
42
+ }
43
+ /**
44
+ * KadiClient - Unified client for KADI protocol
45
+ *
46
+ * This class combines the functionality of KadiAgent and KadiAbility,
47
+ * providing a single interface for:
48
+ *
49
+ * 1. Registering tools that can be called by others
50
+ * 2. Calling remote tools on other services
51
+ * 3. Supporting multiple protocols (native, stdio, broker)
52
+ * 4. Connecting to broker with configurable role (agent, ability, service)
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // Create as an ability
57
+ * const service = new KadiClient({
58
+ * name: 'math-service',
59
+ * role: 'ability',
60
+ * protocol: 'broker'
61
+ * });
62
+ *
63
+ * // Register tools
64
+ * service.registerTool('add', async ({a, b}) => ({result: a + b}));
65
+ *
66
+ * // With schema
67
+ * service.tool('multiply', async ({a, b}) => ({result: a * b}));
68
+ *
69
+ * // Start serving
70
+ * await service.serve();
71
+ * ```
72
+ */
73
+ export declare class KadiClient extends EventEmitter {
74
+ readonly name: string;
75
+ readonly version: string;
76
+ readonly description: string;
77
+ readonly role: 'agent' | 'ability';
78
+ protocol: 'native' | 'stdio' | 'broker';
79
+ readonly network: string;
80
+ readonly networks: string[];
81
+ readonly brokers: {
82
+ [brokerName: string]: string;
83
+ };
84
+ readonly defaultBroker?: string;
85
+ readonly abilityAgentJSON?: string;
86
+ private readonly logger;
87
+ private protocolHandler?;
88
+ readonly toolHandlers: Map<string, RegisteredTool>;
89
+ private readonly _abilities;
90
+ private readonly _brokerConnections;
91
+ private _isConnected;
92
+ private _agentId;
93
+ private _idFactory;
94
+ private _pendingResponses;
95
+ private _pendingToolCalls;
96
+ private _currentBroker?;
97
+ /**
98
+ * Resolver function for the native protocol serve promise.
99
+ * When serve() is called with native protocol, it creates a promise to keep
100
+ * the process alive. This resolver allows us to resolve that promise during
101
+ * disconnect(), enabling clean shutdown of native abilities.
102
+ */
103
+ private _nativeServePromiseResolve?;
104
+ /**
105
+ * Stores all event subscriptions as a Map of pattern → array of callback functions
106
+ * Example structure:
107
+ * {
108
+ * 'user.login' => [handleLogin, logLoginEvent], // 2 functions listening to user.login
109
+ * 'payment.*' => [processPayment], // 1 function listening to all payment events
110
+ * 'system.shutdown' => [saveState, cleanupResources] // 2 functions for shutdown
111
+ * }
112
+ * When an event arrives, we check which patterns match and call all their callbacks
113
+ */
114
+ private _eventSubscriptions;
115
+ constructor(options?: KadiClientConfig);
116
+ /**
117
+ * Get the currently active broker name
118
+ */
119
+ get currentBroker(): string | undefined;
120
+ /**
121
+ * Set the currently active broker
122
+ * @param brokerName The name of the broker to use
123
+ * @throws Error if the broker name doesn't exist in configuration
124
+ */
125
+ setCurrentBroker(brokerName: string): void;
126
+ /**
127
+ * Get the current broker's connection (if connected)
128
+ */
129
+ private getCurrentBrokerConnection;
130
+ /**
131
+ * Resolve broker configuration with agent.json integration
132
+ * Precedence: Code brokers > agent.json brokers > environment defaults
133
+ */
134
+ private resolveBrokerConfiguration;
135
+ /**
136
+ * Resolve default broker with fallback logic
137
+ * Priority: Explicit defaultBroker > agent.json defaultBroker > 'prod' key > first broker key
138
+ */
139
+ private resolveDefaultBroker;
140
+ /**
141
+ * Register a tool for this service
142
+ *
143
+ * @param name - Tool name
144
+ * @param handler - Handler function
145
+ * @param schema - Optional schema
146
+ * @returns This instance for chaining
147
+ */
148
+ registerTool(name: string, handler: ToolHandler, schema?: ToolSchema): this;
149
+ /**
150
+ * Get all registered tool names
151
+ */
152
+ getToolNames(): string[];
153
+ /**
154
+ * Get all registered tools (agent compatibility)
155
+ */
156
+ getTools(): string[];
157
+ /**
158
+ * Check if a tool is registered
159
+ */
160
+ hasTool(name: string): boolean;
161
+ /**
162
+ * Get tool handler
163
+ */
164
+ getToolHandler(name: string): ToolHandler | undefined;
165
+ /**
166
+ * Get tool schema
167
+ */
168
+ getToolSchema(name: string): ToolSchema | undefined;
169
+ /**
170
+ * Publish an event
171
+ */
172
+ publishEvent(eventName: string, data?: any): void;
173
+ /**
174
+ * Connect to all configured brokers (for event subscription and/or broker protocol)
175
+ * Always connects to ALL brokers defined in this.brokers for maximum redundancy
176
+ */
177
+ connectToBrokers(): Promise<void>;
178
+ /**
179
+ * Check if connected to a specific broker URL
180
+ */
181
+ isConnectedToBroker(url: string): boolean;
182
+ /**
183
+ * Connect to a single broker
184
+ */
185
+ connectToBroker(url: string, brokerName?: string): Promise<void>;
186
+ /**
187
+ * Perform KADI protocol handshake
188
+ */
189
+ private performHandshake;
190
+ /**
191
+ * Start heartbeat to keep broker connection alive
192
+ * Sends ping messages at the specified interval to prevent timeout
193
+ */
194
+ private startHeartbeat;
195
+ /**
196
+ * Register capabilities with broker
197
+ */
198
+ private registerCapabilities;
199
+ /**
200
+ * Send request to broker and wait for response
201
+ */
202
+ private sendRequest;
203
+ /**
204
+ * Handle incoming broker messages
205
+ */
206
+ private handleBrokerMessage;
207
+ /**
208
+ * Handle tool invocation result from broker
209
+ */
210
+ private handleToolResult;
211
+ /**
212
+ * Handle incoming tool invocation request
213
+ */
214
+ private handleToolInvocation;
215
+ /**
216
+ * Extract tool definitions for broker registration
217
+ */
218
+ private extractToolsForBroker;
219
+ /**
220
+ * Start serving (main entry point)
221
+ *
222
+ * @param options - Optional serve options
223
+ */
224
+ serve(options?: {
225
+ mode?: 'native' | 'stdio' | 'broker';
226
+ }): Promise<void>;
227
+ /**
228
+ * Start the client (alias for serve for agent compatibility)
229
+ */
230
+ start(): Promise<void>;
231
+ /**
232
+ * Discover tools available from a remote agent
233
+ *
234
+ * This function queries the broker to find what tools
235
+ * a specific remote agent provides.
236
+ *
237
+ * @param targetAgent - The name of the agent to discover tools from
238
+ * @returns Array of tool names available from the target agent
239
+ */
240
+ discoverRemoteTools(targetAgent: string): Promise<string[]>;
241
+ /**
242
+ * Call a tool on a remote agent via the broker
243
+ *
244
+ * This function sends an RPC call through the broker to invoke
245
+ * a specific tool on a remote agent.
246
+ *
247
+ * @param targetAgent - The name of the agent that has the tool
248
+ * @param toolName - The tool name to invoke
249
+ * @param params - The parameters to pass to the tool
250
+ * @returns The result from the remote tool invocation
251
+ */
252
+ callTool<TInput = unknown, TOutput = unknown>(targetAgent: string, toolName: string, params?: TInput): Promise<TOutput>;
253
+ /**
254
+ * Send a request directly to the broker
255
+ * Uses the current broker or the specified broker
256
+ *
257
+ * @param method The RPC method to call (e.g., 'kadi.ability.list')
258
+ * @param params The parameters for the method
259
+ * @param brokerName Optional broker name to use (overrides current broker)
260
+ * @returns The response from the broker
261
+ */
262
+ sendBrokerRequest(method: string, params?: unknown, brokerName?: string): Promise<unknown>;
263
+ /**
264
+ * Load an external ability and make its methods available for calling
265
+ *
266
+ * This is the KadiClient's convenient wrapper for loading abilities. It handles
267
+ * broker resolution from your client config and delegates the actual loading
268
+ * to the standalone loadAbility() function.
269
+ *
270
+ * Note: This method delegates to the standalone loadAbility() function after
271
+ * resolving broker configurations. If you need more control or don't have a
272
+ * KadiClient instance, you can use the standalone loadAbility() function directly.
273
+ *
274
+ * @param nameOrPath - Which ability to load. Can be:
275
+ * - "ability-name" - loads from your installed abilities
276
+ * - "/path/to/ability" - loads from a folder path
277
+ *
278
+ * @param protocol - How to connect to the ability:
279
+ * - 'native': Load directly into this process (fastest, same language only)
280
+ * - 'stdio': Spawn as child process, communicate via stdin/stdout (any language)
281
+ * - 'broker': Connect via broker (ability runs anywhere, most flexible)
282
+ *
283
+ * @param options - Configuration for how to load the ability:
284
+ *
285
+ * broker: Which named broker to use (from your KadiClient config). Only for 'broker' protocol.
286
+ * Example: 'prod', 'local', 'staging'
287
+ * Uses your current/default broker if not specified.
288
+ *
289
+ * brokerUrl: Direct broker WebSocket URL. Only for 'broker' protocol.
290
+ * Example: 'ws://localhost:8080', 'wss://broker.company.com'
291
+ * Overrides the 'broker' option if provided.
292
+ *
293
+ * spawnAbility: Whether to start the ability first. Only for 'broker' protocol.
294
+ * - true: Start the ability process AND connect to it (useful for development)
295
+ * - false (default): Just connect to an already-running ability
296
+ * Most production setups use false since abilities run independently.
297
+ *
298
+ * networks: Which KADI networks to search for the ability. Only for 'broker' protocol.
299
+ * Example: ['global', 'team-alpha', 'dev-environment']
300
+ * search specific networks to find them. Defaults to ['global'] if not specified.
301
+ *
302
+ * @returns A proxy object that lets you call the ability's methods directly.
303
+ * Example: ability.processData({input: "hello"}) calls the ability's processData method.
304
+ *
305
+ * @example
306
+ * // Load a JavaScript ability in the same process (fastest)
307
+ * const mathLib = await client.loadAbility('math-utils', 'native');
308
+ * const result = await mathLib.add({a: 5, b: 3}); // Returns 8
309
+ *
310
+ * @example
311
+ * // Load a Go/Python/Rust ability via child process
312
+ * const imageProcessor = await client.loadAbility('image-resizer', 'stdio');
313
+ * const thumbnail = await imageProcessor.resize({image: buffer, size: '100x100'});
314
+ *
315
+ * @example
316
+ * // Connect to an ability running on a remote broker (using named broker from config)
317
+ * const aiService = await client.loadAbility('gpt-analyzer', 'broker', {
318
+ * broker: 'prod', // Use the 'prod' broker from KadiClient config
319
+ * networks: ['ai-services', 'global'] // Look in these networks
320
+ * });
321
+ * const analysis = await aiService.analyze({text: "Hello world"});
322
+ */
323
+ loadAbility(nameOrPath: string, protocol?: 'native' | 'stdio' | 'broker', options?: {
324
+ broker?: string;
325
+ brokerUrl?: string;
326
+ spawnAbility?: boolean;
327
+ networks?: string[];
328
+ }): Promise<LoadedAbility>;
329
+ /**
330
+ * Disconnect from brokers and cleanup resources
331
+ */
332
+ disconnect(): Promise<void>;
333
+ /**
334
+ * Helper to load agent.json exports
335
+ */
336
+ private _loadAgentJsonExports;
337
+ /**
338
+ * Find agent.json file
339
+ * TODO: Not sure, but maybe this function can be moved to pathUtils.ts?
340
+ */
341
+ private _findAgentJson;
342
+ /**
343
+ * Subscribe to events with unified API across all protocols
344
+ *
345
+ * @param pattern Event pattern - exact string for native/stdio, wildcards supported for broker
346
+ * @param callback Function to call when event is received
347
+ * @returns Unsubscribe function
348
+ */
349
+ subscribeToEvent(pattern: string, callback: (data: any) => void): () => void;
350
+ /**
351
+ * Subscribe to multiple events at once
352
+ *
353
+ * @param patterns Array of event patterns
354
+ * @param callback Function to call when any event is received (receives eventName and data)
355
+ * @returns Unsubscribe function that removes all subscriptions
356
+ */
357
+ subscribeToEvents(patterns: string[], callback: (eventName: string, data: any) => void): () => void;
358
+ /**
359
+ * Unsubscribe from event pattern
360
+ *
361
+ * @param pattern Event pattern to unsubscribe from
362
+ * @param callback Optional specific callback to remove (if not provided, removes all)
363
+ */
364
+ unsubscribeFromEvent(pattern: string, callback?: (data: any) => void): void;
365
+ /**
366
+ * Subscribe to an event only once
367
+ *
368
+ * @param pattern Event pattern
369
+ * @param callback Function to call when event is received (auto-unsubscribes after first call)
370
+ */
371
+ onceEvent(pattern: string, callback: (data: any) => void): void;
372
+ /**
373
+ * Setup universal event subscription that works regardless of client protocol
374
+ *
375
+ * @private
376
+ * @param pattern Event pattern to subscribe to
377
+ */
378
+ /**
379
+ * Marker to track if we've already set up the event transport infrastructure
380
+ */
381
+ private _eventTransportSetup;
382
+ /**
383
+ * Setup the event transport infrastructure ONCE, then subscribe to specific patterns
384
+ * TODO: I do not understand this function very well - better step by step comments
385
+ * would be nice.
386
+ *
387
+ * @private
388
+ * @param pattern Event pattern to subscribe to (e.g., 'echo.test-event')
389
+ */
390
+ private _setupProtocolEventSubscription;
391
+ /**
392
+ * Subscribe to broker events
393
+ *
394
+ * @private
395
+ * @param pattern Event pattern to subscribe to
396
+ */
397
+ private _subscribeToBrokerEvent;
398
+ /**
399
+ * Setup broker event delivery handler
400
+ *
401
+ * @private
402
+ */
403
+ private _brokerEventHandlerSetup;
404
+ private _setupBrokerEventHandler;
405
+ /**
406
+ * Clean up protocol-specific event subscription
407
+ *
408
+ * @private
409
+ * @param pattern Event pattern to clean up
410
+ */
411
+ private _cleanupProtocolEventSubscription;
412
+ /**
413
+ * Check if event name matches pattern
414
+ *
415
+ * @private
416
+ * @param eventName Event name to check
417
+ * @param pattern Pattern to match against (supports wildcards for broker protocol)
418
+ * @returns True if matches
419
+ */
420
+ private _matchesPattern;
421
+ /**
422
+ * Dispatch event to subscribers - This is the final delivery step
423
+ *
424
+ * After all the routing through transports and pattern matching,
425
+ * this function actually calls the user's callback functions with the event data.
426
+ *
427
+ * Example: If user did `client.subscribeToEvent('user.login', myFunction)`
428
+ * then when 'user.login' event arrives, this calls `myFunction(eventData)`
429
+ *
430
+ * @private
431
+ * @param pattern Pattern that matched (e.g., 'user.login' or 'payment.*')
432
+ * @param data Event data to pass to the callbacks
433
+ */
434
+ private _dispatchEvent;
435
+ get isConnected(): boolean;
436
+ get agentId(): string;
437
+ get broker(): BrokerConnection | undefined;
438
+ }
439
+ export default KadiClient;
440
+ //# sourceMappingURL=KadiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KadiClient.d.ts","sourceRoot":"","sources":["../src/KadiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAOtC,OAAO,EACL,UAAU,EAGV,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAe,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAyB9D,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACzC,yKAAyK;IACzK,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gIAAgI;IAChI,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,0FAA0F;IAC1F,OAAO,CAAC,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,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