@agentxjs/core 1.9.5-dev → 1.9.7-dev

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 (80) hide show
  1. package/dist/Processor-DT0N1qI6.d.ts +64 -0
  2. package/dist/agent/engine/internal/index.d.ts +223 -0
  3. package/dist/agent/engine/internal/index.js +24 -0
  4. package/dist/agent/engine/internal/index.js.map +1 -0
  5. package/dist/agent/engine/mealy/index.d.ts +157 -0
  6. package/dist/agent/engine/mealy/index.js +26 -0
  7. package/dist/agent/engine/mealy/index.js.map +1 -0
  8. package/dist/agent/index.d.ts +244 -0
  9. package/dist/agent/index.js +66 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/agent/types/index.d.ts +322 -0
  12. package/dist/agent/types/index.js +12 -0
  13. package/dist/agent/types/index.js.map +1 -0
  14. package/dist/base-m40r3Qgu.d.ts +157 -0
  15. package/dist/bus-uF1DM2ox.d.ts +906 -0
  16. package/dist/chunk-7D4SUZUM.js +38 -0
  17. package/dist/chunk-7D4SUZUM.js.map +1 -0
  18. package/dist/chunk-7ZDX3O6I.js +173 -0
  19. package/dist/chunk-7ZDX3O6I.js.map +1 -0
  20. package/dist/chunk-E5FPOAPO.js +123 -0
  21. package/dist/chunk-E5FPOAPO.js.map +1 -0
  22. package/dist/chunk-EKHT54KN.js +272 -0
  23. package/dist/chunk-EKHT54KN.js.map +1 -0
  24. package/dist/chunk-I7GYR3MN.js +502 -0
  25. package/dist/chunk-I7GYR3MN.js.map +1 -0
  26. package/dist/chunk-K6WXQ2RW.js +38 -0
  27. package/dist/chunk-K6WXQ2RW.js.map +1 -0
  28. package/dist/chunk-RL3JRNXM.js +3 -0
  29. package/dist/chunk-RL3JRNXM.js.map +1 -0
  30. package/dist/chunk-TBU7FFZT.js +543 -0
  31. package/dist/chunk-TBU7FFZT.js.map +1 -0
  32. package/dist/combinators-nEa5dD0T.d.ts +271 -0
  33. package/dist/common/index.d.ts +1 -0
  34. package/dist/common/index.js +2 -0
  35. package/dist/common/index.js.map +1 -0
  36. package/dist/common/logger/index.d.ts +163 -0
  37. package/dist/common/logger/index.js +184 -0
  38. package/dist/common/logger/index.js.map +1 -0
  39. package/dist/container/index.d.ts +110 -0
  40. package/dist/container/index.js +127 -0
  41. package/dist/container/index.js.map +1 -0
  42. package/dist/driver/index.d.ts +266 -0
  43. package/dist/driver/index.js +1 -0
  44. package/dist/driver/index.js.map +1 -0
  45. package/dist/event/index.d.ts +55 -0
  46. package/dist/event/index.js +60 -0
  47. package/dist/event/index.js.map +1 -0
  48. package/dist/event/types/index.d.ts +1149 -0
  49. package/dist/event/types/index.js +56 -0
  50. package/dist/event/types/index.js.map +1 -0
  51. package/dist/event-CDuTzs__.d.ts +296 -0
  52. package/dist/image/index.d.ts +112 -0
  53. package/dist/image/index.js +151 -0
  54. package/dist/image/index.js.map +1 -0
  55. package/dist/index.d.ts +8 -0
  56. package/dist/index.js +67 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/message-BMrMm1pq.d.ts +305 -0
  59. package/dist/mq/index.d.ts +165 -0
  60. package/dist/mq/index.js +37 -0
  61. package/dist/mq/index.js.map +1 -0
  62. package/dist/network/index.d.ts +567 -0
  63. package/dist/network/index.js +435 -0
  64. package/dist/network/index.js.map +1 -0
  65. package/dist/persistence/index.d.ts +155 -0
  66. package/dist/persistence/index.js +1 -0
  67. package/dist/persistence/index.js.map +1 -0
  68. package/dist/runtime/index.d.ts +240 -0
  69. package/dist/runtime/index.js +347 -0
  70. package/dist/runtime/index.js.map +1 -0
  71. package/dist/session/index.d.ts +92 -0
  72. package/dist/session/index.js +56 -0
  73. package/dist/session/index.js.map +1 -0
  74. package/dist/workspace/index.d.ts +111 -0
  75. package/dist/workspace/index.js +1 -0
  76. package/dist/workspace/index.js.map +1 -0
  77. package/dist/wrapper-Y3UTVU2E.js +3635 -0
  78. package/dist/wrapper-Y3UTVU2E.js.map +1 -0
  79. package/package.json +73 -14
  80. package/tsconfig.json +0 -10
@@ -0,0 +1,906 @@
1
+ import { S as SystemEvent, B as BusEvent } from './base-m40r3Qgu.js';
2
+
3
+ /**
4
+ * Command Events - API operations (request/response)
5
+ *
6
+ * Command events for the EventBus system.
7
+ */
8
+
9
+ /**
10
+ * Text content part for user messages
11
+ */
12
+ interface TextPart {
13
+ type: "text";
14
+ text: string;
15
+ }
16
+ /**
17
+ * Image content part for user messages
18
+ */
19
+ interface ImagePart {
20
+ type: "image";
21
+ data: string;
22
+ mediaType: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
23
+ }
24
+ /**
25
+ * File content part for user messages
26
+ */
27
+ interface FilePart {
28
+ type: "file";
29
+ data: string;
30
+ filename: string;
31
+ mediaType: string;
32
+ }
33
+ /**
34
+ * User content part - content that users can send in messages
35
+ */
36
+ type UserContentPart = TextPart | ImagePart | FilePart;
37
+ /**
38
+ * AgentXResponse - Base interface for all command response data
39
+ *
40
+ * All command response data types should extend this interface
41
+ * to ensure consistent structure and enable automatic client-side handling.
42
+ */
43
+ interface AgentXResponse {
44
+ /**
45
+ * Request ID for correlation and tracking
46
+ */
47
+ requestId: string;
48
+ /**
49
+ * Error message if the request failed
50
+ */
51
+ error?: string;
52
+ /**
53
+ * Session IDs that the client should subscribe to
54
+ */
55
+ __subscriptions?: string[];
56
+ }
57
+ /**
58
+ * MCP Server Configuration
59
+ */
60
+ interface McpServerConfig {
61
+ command?: string;
62
+ args?: string[];
63
+ env?: Record<string, string>;
64
+ url?: string;
65
+ }
66
+ /**
67
+ * Image metadata for storing provider-specific data
68
+ */
69
+ interface ImageMetadata {
70
+ claudeSdkSessionId?: string;
71
+ }
72
+ /**
73
+ * Image storage record
74
+ */
75
+ interface ImageRecord {
76
+ imageId: string;
77
+ containerId: string;
78
+ sessionId: string;
79
+ name: string;
80
+ description?: string;
81
+ systemPrompt?: string;
82
+ parentImageId?: string;
83
+ mcpServers?: Record<string, McpServerConfig>;
84
+ metadata?: ImageMetadata;
85
+ createdAt: number;
86
+ updatedAt: number;
87
+ }
88
+ /**
89
+ * Image list item with online status
90
+ */
91
+ interface ImageListItem extends ImageRecord {
92
+ /** Whether an agent is currently running for this image */
93
+ online: boolean;
94
+ /** Current agent ID if online */
95
+ agentId?: string;
96
+ }
97
+ /**
98
+ * Base interface for Command request events
99
+ */
100
+ interface BaseCommandRequest<T extends string, D = unknown> extends SystemEvent<T, D, "command", "request", "request"> {
101
+ }
102
+ /**
103
+ * Base interface for Command response events
104
+ *
105
+ * All response data types must extend AgentXResponse to ensure:
106
+ * - Consistent structure (requestId, error)
107
+ * - Automatic client-side handling (__subscriptions, etc.)
108
+ */
109
+ interface BaseCommandResponse<T extends string, D extends AgentXResponse = AgentXResponse> extends SystemEvent<T, D, "command", "response", "result"> {
110
+ }
111
+ /**
112
+ * Request to create a container
113
+ */
114
+ interface ContainerCreateRequest extends BaseCommandRequest<"container_create_request", {
115
+ requestId: string;
116
+ containerId: string;
117
+ }> {
118
+ }
119
+ /**
120
+ * Response to container creation
121
+ */
122
+ interface ContainerCreateResponse extends BaseCommandResponse<"container_create_response", AgentXResponse & {
123
+ containerId: string;
124
+ }> {
125
+ }
126
+ /**
127
+ * Request to get a container
128
+ */
129
+ interface ContainerGetRequest extends BaseCommandRequest<"container_get_request", {
130
+ requestId: string;
131
+ containerId: string;
132
+ }> {
133
+ }
134
+ /**
135
+ * Response to container get
136
+ */
137
+ interface ContainerGetResponse extends BaseCommandResponse<"container_get_response", AgentXResponse & {
138
+ containerId?: string;
139
+ exists: boolean;
140
+ }> {
141
+ }
142
+ /**
143
+ * Request to list containers
144
+ */
145
+ interface ContainerListRequest extends BaseCommandRequest<"container_list_request", {
146
+ requestId: string;
147
+ }> {
148
+ }
149
+ /**
150
+ * Response to container list
151
+ */
152
+ interface ContainerListResponse extends BaseCommandResponse<"container_list_response", AgentXResponse & {
153
+ containerIds: string[];
154
+ }> {
155
+ }
156
+ /**
157
+ * Request to get an agent
158
+ */
159
+ interface AgentGetRequest extends BaseCommandRequest<"agent_get_request", {
160
+ requestId: string;
161
+ agentId: string;
162
+ }> {
163
+ }
164
+ /**
165
+ * Response to agent get
166
+ */
167
+ interface AgentGetResponse extends BaseCommandResponse<"agent_get_response", AgentXResponse & {
168
+ agentId?: string;
169
+ containerId?: string;
170
+ exists: boolean;
171
+ }> {
172
+ }
173
+ /**
174
+ * Request to list agents
175
+ */
176
+ interface AgentListRequest extends BaseCommandRequest<"agent_list_request", {
177
+ requestId: string;
178
+ containerId: string;
179
+ }> {
180
+ }
181
+ /**
182
+ * Response to agent list
183
+ */
184
+ interface AgentListResponse extends BaseCommandResponse<"agent_list_response", AgentXResponse & {
185
+ agents: Array<{
186
+ agentId: string;
187
+ containerId: string;
188
+ imageId: string;
189
+ }>;
190
+ }> {
191
+ }
192
+ /**
193
+ * Request to destroy an agent
194
+ */
195
+ interface AgentDestroyRequest extends BaseCommandRequest<"agent_destroy_request", {
196
+ requestId: string;
197
+ agentId: string;
198
+ }> {
199
+ }
200
+ /**
201
+ * Response to agent destroy
202
+ */
203
+ interface AgentDestroyResponse extends BaseCommandResponse<"agent_destroy_response", AgentXResponse & {
204
+ agentId: string;
205
+ success: boolean;
206
+ }> {
207
+ }
208
+ /**
209
+ * Request to destroy all agents in a container
210
+ */
211
+ interface AgentDestroyAllRequest extends BaseCommandRequest<"agent_destroy_all_request", {
212
+ requestId: string;
213
+ containerId: string;
214
+ }> {
215
+ }
216
+ /**
217
+ * Response to destroy all agents
218
+ */
219
+ interface AgentDestroyAllResponse extends BaseCommandResponse<"agent_destroy_all_response", AgentXResponse & {
220
+ containerId: string;
221
+ }> {
222
+ }
223
+ /**
224
+ * Request to send a message
225
+ * Can use either imageId (preferred) or agentId
226
+ * If using imageId and agent is not running, it will be auto-activated
227
+ */
228
+ interface MessageSendRequest extends BaseCommandRequest<"message_send_request", {
229
+ requestId: string;
230
+ /** Image ID (preferred) - will auto-activate if offline */
231
+ imageId?: string;
232
+ /** Agent ID (legacy) - must be already running */
233
+ agentId?: string;
234
+ /** Message content (text-only or multimodal) */
235
+ content: string | UserContentPart[];
236
+ }> {
237
+ }
238
+ /**
239
+ * Response to message send (acknowledges message received, not completion)
240
+ */
241
+ interface MessageSendResponse extends BaseCommandResponse<"message_send_response", AgentXResponse & {
242
+ imageId?: string;
243
+ agentId: string;
244
+ }> {
245
+ }
246
+ /**
247
+ * Request to interrupt an agent
248
+ * Can use either imageId or agentId
249
+ */
250
+ interface AgentInterruptRequest extends BaseCommandRequest<"agent_interrupt_request", {
251
+ requestId: string;
252
+ /** Image ID (preferred) */
253
+ imageId?: string;
254
+ /** Agent ID (legacy) */
255
+ agentId?: string;
256
+ }> {
257
+ }
258
+ /**
259
+ * Response to agent interrupt
260
+ */
261
+ interface AgentInterruptResponse extends BaseCommandResponse<"agent_interrupt_response", AgentXResponse & {
262
+ imageId?: string;
263
+ agentId?: string;
264
+ }> {
265
+ }
266
+ /**
267
+ * Request to create a new image (conversation)
268
+ */
269
+ interface ImageCreateRequest extends BaseCommandRequest<"image_create_request", {
270
+ requestId: string;
271
+ containerId: string;
272
+ config: {
273
+ name?: string;
274
+ description?: string;
275
+ systemPrompt?: string;
276
+ };
277
+ }> {
278
+ }
279
+ /**
280
+ * Response to image creation
281
+ *
282
+ * Includes __subscriptions with the new image's sessionId for auto-subscription.
283
+ * Note: record is optional because it may be undefined on error.
284
+ */
285
+ interface ImageCreateResponse extends BaseCommandResponse<"image_create_response", AgentXResponse & {
286
+ record?: ImageRecord;
287
+ }> {
288
+ }
289
+ /**
290
+ * Request to run an image (create or reuse agent)
291
+ */
292
+ interface ImageRunRequest extends BaseCommandRequest<"image_run_request", {
293
+ requestId: string;
294
+ imageId: string;
295
+ }> {
296
+ }
297
+ /**
298
+ * Response to image run
299
+ */
300
+ interface ImageRunResponse extends BaseCommandResponse<"image_run_response", AgentXResponse & {
301
+ imageId: string;
302
+ agentId: string;
303
+ /** true if reusing existing agent, false if newly created */
304
+ reused: boolean;
305
+ }> {
306
+ }
307
+ /**
308
+ * Request to stop an image (destroy agent, keep image)
309
+ */
310
+ interface ImageStopRequest extends BaseCommandRequest<"image_stop_request", {
311
+ requestId: string;
312
+ imageId: string;
313
+ }> {
314
+ }
315
+ /**
316
+ * Response to image stop
317
+ */
318
+ interface ImageStopResponse extends BaseCommandResponse<"image_stop_response", AgentXResponse & {
319
+ imageId: string;
320
+ }> {
321
+ }
322
+ /**
323
+ * Request to update an image (name, description, etc.)
324
+ */
325
+ interface ImageUpdateRequest extends BaseCommandRequest<"image_update_request", {
326
+ requestId: string;
327
+ imageId: string;
328
+ updates: {
329
+ name?: string;
330
+ description?: string;
331
+ };
332
+ }> {
333
+ }
334
+ /**
335
+ * Response to image update
336
+ *
337
+ * Note: record is optional because it may be undefined on error.
338
+ */
339
+ interface ImageUpdateResponse extends BaseCommandResponse<"image_update_response", AgentXResponse & {
340
+ record?: ImageRecord;
341
+ }> {
342
+ }
343
+ /**
344
+ * Request to list all images
345
+ */
346
+ interface ImageListRequest extends BaseCommandRequest<"image_list_request", {
347
+ requestId: string;
348
+ containerId?: string;
349
+ }> {
350
+ }
351
+ /**
352
+ * Response to image list
353
+ *
354
+ * Includes __subscriptions with all images' sessionIds for auto-subscription.
355
+ */
356
+ interface ImageListResponse extends BaseCommandResponse<"image_list_response", AgentXResponse & {
357
+ records: ImageListItem[];
358
+ }> {
359
+ }
360
+ /**
361
+ * Request to get an image by ID
362
+ */
363
+ interface ImageGetRequest extends BaseCommandRequest<"image_get_request", {
364
+ requestId: string;
365
+ imageId: string;
366
+ }> {
367
+ }
368
+ /**
369
+ * Response to image get
370
+ *
371
+ * Includes __subscriptions with the image's sessionId for auto-subscription.
372
+ */
373
+ interface ImageGetResponse extends BaseCommandResponse<"image_get_response", AgentXResponse & {
374
+ record?: ImageListItem | null;
375
+ }> {
376
+ }
377
+ /**
378
+ * Request to delete an image
379
+ */
380
+ interface ImageDeleteRequest extends BaseCommandRequest<"image_delete_request", {
381
+ requestId: string;
382
+ imageId: string;
383
+ }> {
384
+ }
385
+ /**
386
+ * Response to image delete
387
+ */
388
+ interface ImageDeleteResponse extends BaseCommandResponse<"image_delete_response", AgentXResponse & {
389
+ imageId: string;
390
+ }> {
391
+ }
392
+ /**
393
+ * Request to get messages for an image
394
+ */
395
+ interface ImageMessagesRequest extends BaseCommandRequest<"image_messages_request", {
396
+ requestId: string;
397
+ imageId: string;
398
+ }> {
399
+ }
400
+ /**
401
+ * Response to image messages request
402
+ */
403
+ interface ImageMessagesResponse extends BaseCommandResponse<"image_messages_response", AgentXResponse & {
404
+ imageId: string;
405
+ messages: Array<{
406
+ id: string;
407
+ role: "user" | "assistant" | "tool_call" | "tool_result";
408
+ content: unknown;
409
+ timestamp: number;
410
+ }>;
411
+ }> {
412
+ }
413
+ /**
414
+ * All Command request events
415
+ */
416
+ type CommandRequest = ContainerCreateRequest | ContainerGetRequest | ContainerListRequest | AgentGetRequest | AgentListRequest | AgentDestroyRequest | AgentDestroyAllRequest | MessageSendRequest | AgentInterruptRequest | ImageCreateRequest | ImageRunRequest | ImageStopRequest | ImageUpdateRequest | ImageListRequest | ImageGetRequest | ImageDeleteRequest | ImageMessagesRequest;
417
+ /**
418
+ * All Command response events
419
+ */
420
+ type CommandResponse = ContainerCreateResponse | ContainerGetResponse | ContainerListResponse | AgentGetResponse | AgentListResponse | AgentDestroyResponse | AgentDestroyAllResponse | MessageSendResponse | AgentInterruptResponse | ImageCreateResponse | ImageRunResponse | ImageStopResponse | ImageUpdateResponse | ImageListResponse | ImageGetResponse | ImageDeleteResponse | ImageMessagesResponse;
421
+ /**
422
+ * All Command events (requests + responses)
423
+ */
424
+ type CommandEvent = CommandRequest | CommandResponse;
425
+ /**
426
+ * Command event type strings
427
+ */
428
+ type CommandEventType = CommandEvent["type"];
429
+ /**
430
+ * Type guard: is this a CommandEvent?
431
+ */
432
+ declare function isCommandEvent(event: {
433
+ source?: string;
434
+ }): event is CommandEvent;
435
+ /**
436
+ * Type guard: is this a Command request event?
437
+ */
438
+ declare function isCommandRequest(event: {
439
+ source?: string;
440
+ category?: string;
441
+ }): event is CommandRequest;
442
+ /**
443
+ * Type guard: is this a Command response event?
444
+ */
445
+ declare function isCommandResponse(event: {
446
+ source?: string;
447
+ category?: string;
448
+ }): event is CommandResponse;
449
+ /**
450
+ * CommandEventMap - Maps event type string to event interface
451
+ *
452
+ * Enables type-safe event handling:
453
+ * ```typescript
454
+ * bus.onCommand("container_create_request", (event) => {
455
+ * event.data.requestId; // string
456
+ * event.data.containerId; // string
457
+ * });
458
+ * ```
459
+ */
460
+ interface CommandEventMap {
461
+ container_create_request: ContainerCreateRequest;
462
+ container_create_response: ContainerCreateResponse;
463
+ container_get_request: ContainerGetRequest;
464
+ container_get_response: ContainerGetResponse;
465
+ container_list_request: ContainerListRequest;
466
+ container_list_response: ContainerListResponse;
467
+ agent_get_request: AgentGetRequest;
468
+ agent_get_response: AgentGetResponse;
469
+ agent_list_request: AgentListRequest;
470
+ agent_list_response: AgentListResponse;
471
+ agent_destroy_request: AgentDestroyRequest;
472
+ agent_destroy_response: AgentDestroyResponse;
473
+ agent_destroy_all_request: AgentDestroyAllRequest;
474
+ agent_destroy_all_response: AgentDestroyAllResponse;
475
+ message_send_request: MessageSendRequest;
476
+ message_send_response: MessageSendResponse;
477
+ agent_interrupt_request: AgentInterruptRequest;
478
+ agent_interrupt_response: AgentInterruptResponse;
479
+ image_create_request: ImageCreateRequest;
480
+ image_create_response: ImageCreateResponse;
481
+ image_run_request: ImageRunRequest;
482
+ image_run_response: ImageRunResponse;
483
+ image_stop_request: ImageStopRequest;
484
+ image_stop_response: ImageStopResponse;
485
+ image_update_request: ImageUpdateRequest;
486
+ image_update_response: ImageUpdateResponse;
487
+ image_list_request: ImageListRequest;
488
+ image_list_response: ImageListResponse;
489
+ image_get_request: ImageGetRequest;
490
+ image_get_response: ImageGetResponse;
491
+ image_delete_request: ImageDeleteRequest;
492
+ image_delete_response: ImageDeleteResponse;
493
+ image_messages_request: ImageMessagesRequest;
494
+ image_messages_response: ImageMessagesResponse;
495
+ }
496
+ /**
497
+ * Maps request event type to its corresponding response event type
498
+ */
499
+ interface CommandRequestResponseMap {
500
+ container_create_request: "container_create_response";
501
+ container_get_request: "container_get_response";
502
+ container_list_request: "container_list_response";
503
+ agent_get_request: "agent_get_response";
504
+ agent_list_request: "agent_list_response";
505
+ agent_destroy_request: "agent_destroy_response";
506
+ agent_destroy_all_request: "agent_destroy_all_response";
507
+ message_send_request: "message_send_response";
508
+ agent_interrupt_request: "agent_interrupt_response";
509
+ image_create_request: "image_create_response";
510
+ image_run_request: "image_run_response";
511
+ image_stop_request: "image_stop_response";
512
+ image_update_request: "image_update_response";
513
+ image_list_request: "image_list_response";
514
+ image_get_request: "image_get_response";
515
+ image_delete_request: "image_delete_response";
516
+ image_messages_request: "image_messages_response";
517
+ }
518
+ /**
519
+ * All command request types
520
+ */
521
+ type CommandRequestType = keyof CommandRequestResponseMap;
522
+ /**
523
+ * Get response type for a request type
524
+ */
525
+ type ResponseTypeFor<T extends CommandRequestType> = CommandRequestResponseMap[T];
526
+ /**
527
+ * Get response event for a request type
528
+ */
529
+ type ResponseEventFor<T extends CommandRequestType> = CommandEventMap[ResponseTypeFor<T>];
530
+ /**
531
+ * Get request data type (without requestId, as it's auto-generated)
532
+ */
533
+ type RequestDataFor<T extends CommandRequestType> = Omit<CommandEventMap[T]["data"], "requestId">;
534
+
535
+ /**
536
+ * EventBus Interfaces - EventBus, EventProducer, EventConsumer
537
+ *
538
+ * Central event bus interfaces for ecosystem communication.
539
+ */
540
+
541
+ /**
542
+ * Unsubscribe function type
543
+ */
544
+ type Unsubscribe = () => void;
545
+ /**
546
+ * Event handler function type
547
+ */
548
+ type BusEventHandler<E extends BusEvent = BusEvent> = (event: E) => void;
549
+ /**
550
+ * Subscription options for advanced event handling
551
+ */
552
+ interface SubscribeOptions<E extends BusEvent = BusEvent> {
553
+ /**
554
+ * Event filter - only events returning true will trigger the handler
555
+ * Useful for filtering by agentId, sessionId, etc.
556
+ */
557
+ filter?: (event: E) => boolean;
558
+ /**
559
+ * Priority - higher numbers execute first (default: 0)
560
+ * Useful for ensuring certain handlers run before others
561
+ */
562
+ priority?: number;
563
+ /**
564
+ * Whether to trigger only once then auto-unsubscribe
565
+ */
566
+ once?: boolean;
567
+ }
568
+ /**
569
+ * EventProducer interface - Write-only view
570
+ *
571
+ * Used by components that produce events:
572
+ * - Effector (emits DriveableEvents from Claude API)
573
+ * - Receptor (emits stream events)
574
+ * - Agent (emits state/message events)
575
+ *
576
+ * Producer can only emit events, cannot subscribe.
577
+ * This prevents accidental event loops and clarifies data flow.
578
+ *
579
+ * @example
580
+ * ```typescript
581
+ * class Effector {
582
+ * constructor(private producer: EventProducer) {}
583
+ *
584
+ * async sendMessage(message: UserMessage) {
585
+ * // Can only emit, cannot subscribe
586
+ * this.producer.emit({
587
+ * type: "message_start",
588
+ * timestamp: Date.now(),
589
+ * data: { messageId: "msg-1", model: "claude" },
590
+ * });
591
+ * }
592
+ * }
593
+ * ```
594
+ */
595
+ interface EventProducer {
596
+ /**
597
+ * Emit a single event to the bus
598
+ *
599
+ * @param event - The event to emit
600
+ */
601
+ emit(event: BusEvent): void;
602
+ /**
603
+ * Emit multiple events (batch operation)
604
+ *
605
+ * @param events - Array of events to emit
606
+ */
607
+ emitBatch(events: BusEvent[]): void;
608
+ /**
609
+ * Emit a typed command event
610
+ *
611
+ * @param type - The command event type
612
+ * @param data - Event data (type-checked)
613
+ */
614
+ emitCommand<T extends keyof CommandEventMap>(type: T, data: CommandEventMap[T]["data"]): void;
615
+ }
616
+ /**
617
+ * EventConsumer interface - Read-only view
618
+ *
619
+ * Used by components that consume events:
620
+ * - BusDriver (subscribes to DriveableEvents)
621
+ * - UI components (subscribes to display events)
622
+ * - Presenters (subscribes to forward events)
623
+ *
624
+ * Consumer can only subscribe to events, cannot emit.
625
+ * This prevents accidental event emission and clarifies data flow.
626
+ *
627
+ * @example
628
+ * ```typescript
629
+ * class BusDriver {
630
+ * constructor(private consumer: EventConsumer) {}
631
+ *
632
+ * async *receive(message: UserMessage) {
633
+ * // Can only subscribe, cannot emit
634
+ * this.consumer.on('message_start', (event) => {
635
+ * console.log('Received:', event.type);
636
+ * });
637
+ * }
638
+ * }
639
+ * ```
640
+ */
641
+ interface EventConsumer {
642
+ /**
643
+ * Subscribe to a specific event type
644
+ *
645
+ * @param type - The event type to listen for
646
+ * @param handler - Callback invoked when event is received
647
+ * @param options - Subscription options (filter, priority, once)
648
+ * @returns Unsubscribe function
649
+ */
650
+ on<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
651
+ type: T;
652
+ }>, options?: SubscribeOptions<BusEvent & {
653
+ type: T;
654
+ }>): Unsubscribe;
655
+ /**
656
+ * Subscribe to multiple event types
657
+ *
658
+ * @param types - Array of event types to listen for
659
+ * @param handler - Callback invoked when any matching event is received
660
+ * @param options - Subscription options
661
+ * @returns Unsubscribe function
662
+ */
663
+ on(types: string[], handler: BusEventHandler, options?: SubscribeOptions): Unsubscribe;
664
+ /**
665
+ * Subscribe to all events
666
+ *
667
+ * @param handler - Callback invoked for every event
668
+ * @param options - Subscription options
669
+ * @returns Unsubscribe function
670
+ */
671
+ onAny(handler: BusEventHandler, options?: SubscribeOptions): Unsubscribe;
672
+ /**
673
+ * Subscribe to an event type once (auto-unsubscribes after first trigger)
674
+ *
675
+ * @param type - Event type to subscribe to
676
+ * @param handler - Callback function
677
+ * @returns Unsubscribe function
678
+ */
679
+ once<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
680
+ type: T;
681
+ }>): Unsubscribe;
682
+ /**
683
+ * Subscribe to a CommandEvent with full type safety
684
+ *
685
+ * @example
686
+ * ```typescript
687
+ * consumer.onCommand("container_create_request", (event) => {
688
+ * event.data.requestId; // string
689
+ * event.data.containerId; // string
690
+ * });
691
+ * ```
692
+ *
693
+ * @param type - The command event type
694
+ * @param handler - Callback with fully typed event
695
+ * @returns Unsubscribe function
696
+ */
697
+ onCommand<T extends keyof CommandEventMap>(type: T, handler: (event: CommandEventMap[T]) => void): Unsubscribe;
698
+ /**
699
+ * Send a command request and wait for response
700
+ *
701
+ * Automatically generates requestId, emits request, waits for matching response.
702
+ *
703
+ * @example
704
+ * ```typescript
705
+ * const response = await consumer.request("container_create_request", {
706
+ * containerId: "my-container"
707
+ * });
708
+ * // response is ContainerCreateResponse
709
+ * console.log(response.data.containerId);
710
+ * ```
711
+ *
712
+ * @param type - The request event type
713
+ * @param data - Request data (without requestId)
714
+ * @param timeout - Timeout in milliseconds (default: 30000)
715
+ * @returns Promise of response event
716
+ */
717
+ request<T extends CommandRequestType>(type: T, data: RequestDataFor<T>, timeout?: number): Promise<ResponseEventFor<T>>;
718
+ }
719
+ /**
720
+ * EventBus interface - Central event bus for ecosystem communication.
721
+ *
722
+ * Extends both Producer and Consumer interfaces for internal use.
723
+ * External components should use restricted views via asProducer/asConsumer.
724
+ *
725
+ * @example
726
+ * ```typescript
727
+ * const bus = new EventBus();
728
+ *
729
+ * // Subscribe to specific event type
730
+ * bus.on('text_chunk', (e) => {
731
+ * console.log('Received text:', e.data.text);
732
+ * });
733
+ *
734
+ * // Subscribe with options
735
+ * bus.on('text_delta', handler, {
736
+ * filter: (e) => e.agentId === 'agent-1',
737
+ * priority: 10,
738
+ * once: true
739
+ * });
740
+ *
741
+ * // Subscribe to all events
742
+ * bus.onAny((e) => {
743
+ * console.log('Event:', e.type);
744
+ * });
745
+ *
746
+ * // Emit event
747
+ * bus.emit({ type: 'text_chunk', data: { text: 'Hello' } });
748
+ * ```
749
+ */
750
+ interface EventBus {
751
+ /**
752
+ * Emit an event to the bus.
753
+ *
754
+ * All subscribed handlers will receive this event.
755
+ *
756
+ * @param event - The event to emit
757
+ */
758
+ emit(event: BusEvent): void;
759
+ /**
760
+ * Emit multiple events (batch operation).
761
+ *
762
+ * @param events - Array of events to emit
763
+ */
764
+ emitBatch(events: BusEvent[]): void;
765
+ /**
766
+ * Subscribe to a specific event type.
767
+ *
768
+ * @param type - The event type to listen for
769
+ * @param handler - Callback invoked when event is received
770
+ * @param options - Subscription options (filter, priority, once)
771
+ * @returns Unsubscribe function
772
+ */
773
+ on<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
774
+ type: T;
775
+ }>, options?: SubscribeOptions<BusEvent & {
776
+ type: T;
777
+ }>): Unsubscribe;
778
+ /**
779
+ * Subscribe to multiple event types.
780
+ *
781
+ * @param types - Array of event types to listen for
782
+ * @param handler - Callback invoked when any matching event is received
783
+ * @param options - Subscription options
784
+ * @returns Unsubscribe function
785
+ */
786
+ on(types: string[], handler: BusEventHandler, options?: SubscribeOptions): Unsubscribe;
787
+ /**
788
+ * Subscribe to all events.
789
+ *
790
+ * @param handler - Callback invoked for every event
791
+ * @param options - Subscription options
792
+ * @returns Unsubscribe function
793
+ */
794
+ onAny(handler: BusEventHandler, options?: SubscribeOptions): Unsubscribe;
795
+ /**
796
+ * Subscribe to an event type once (auto-unsubscribes after first trigger).
797
+ *
798
+ * @param type - Event type to subscribe to
799
+ * @param handler - Callback function
800
+ * @returns Unsubscribe function
801
+ */
802
+ once<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
803
+ type: T;
804
+ }>): Unsubscribe;
805
+ /**
806
+ * Subscribe to a CommandEvent with full type safety.
807
+ *
808
+ * @example
809
+ * ```typescript
810
+ * bus.onCommand("container_create_request", (event) => {
811
+ * event.data.requestId; // string
812
+ * event.data.containerId; // string
813
+ * });
814
+ * ```
815
+ *
816
+ * @param type - The command event type
817
+ * @param handler - Callback with fully typed event
818
+ * @returns Unsubscribe function
819
+ */
820
+ onCommand<T extends keyof CommandEventMap>(type: T, handler: (event: CommandEventMap[T]) => void): Unsubscribe;
821
+ /**
822
+ * Emit a CommandEvent with full type safety.
823
+ *
824
+ * @example
825
+ * ```typescript
826
+ * bus.emitCommand("container_create_request", {
827
+ * requestId: "req_123",
828
+ * containerId: "my-container"
829
+ * });
830
+ * ```
831
+ *
832
+ * @param type - The command event type
833
+ * @param data - Event data (type-checked)
834
+ */
835
+ emitCommand<T extends keyof CommandEventMap>(type: T, data: CommandEventMap[T]["data"]): void;
836
+ /**
837
+ * Send a command request and wait for response.
838
+ *
839
+ * Automatically generates requestId, emits request, waits for matching response.
840
+ *
841
+ * @example
842
+ * ```typescript
843
+ * const response = await bus.request("container_create_request", {
844
+ * containerId: "my-container"
845
+ * });
846
+ * // response is ContainerCreateResponse
847
+ * console.log(response.data.containerId);
848
+ * ```
849
+ *
850
+ * @param type - The request event type
851
+ * @param data - Request data (without requestId)
852
+ * @param timeout - Timeout in milliseconds (default: 30000)
853
+ * @returns Promise of response event
854
+ */
855
+ request<T extends CommandRequestType>(type: T, data: RequestDataFor<T>, timeout?: number): Promise<ResponseEventFor<T>>;
856
+ /**
857
+ * Get a read-only consumer view of the bus.
858
+ *
859
+ * Use this to safely expose event subscription to external code
860
+ * without allowing them to emit events.
861
+ *
862
+ * @example
863
+ * ```typescript
864
+ * class BusDriver {
865
+ * constructor(consumer: EventConsumer) {
866
+ * // Can only subscribe, cannot emit
867
+ * consumer.on('text_delta', ...);
868
+ * }
869
+ * }
870
+ * ```
871
+ *
872
+ * @returns EventConsumer - Read-only view
873
+ */
874
+ asConsumer(): EventConsumer;
875
+ /**
876
+ * Get a write-only producer view of the bus.
877
+ *
878
+ * Use this to give components the ability to emit events
879
+ * without exposing subscription capabilities.
880
+ *
881
+ * @example
882
+ * ```typescript
883
+ * class ClaudeReceptor {
884
+ * constructor(producer: EventProducer) {
885
+ * // Can only emit, cannot subscribe
886
+ * producer.emit({ type: 'text_delta', ... });
887
+ * }
888
+ * }
889
+ * ```
890
+ *
891
+ * @returns EventProducer - Write-only view
892
+ */
893
+ asProducer(): EventProducer;
894
+ /**
895
+ * Destroy the bus and clean up resources.
896
+ *
897
+ * All subscriptions will be terminated.
898
+ * After calling destroy():
899
+ * - All subscriptions are removed
900
+ * - New emissions are ignored
901
+ * - New subscriptions are no-ops
902
+ */
903
+ destroy(): void;
904
+ }
905
+
906
+ export { type CommandRequest as $, type AgentXResponse as A, type BusEventHandler as B, type CommandEventMap as C, type ImageCreateRequest as D, type EventBus as E, type FilePart as F, type ImageCreateResponse as G, type ImageRunRequest as H, type ImagePart as I, type ImageRunResponse as J, type ImageStopRequest as K, type ImageStopResponse as L, type McpServerConfig as M, type ImageUpdateRequest as N, type ImageUpdateResponse as O, type ImageListRequest as P, type ImageListResponse as Q, type RequestDataFor as R, type SubscribeOptions as S, type TextPart as T, type Unsubscribe as U, type ImageGetRequest as V, type ImageGetResponse as W, type ImageDeleteRequest as X, type ImageDeleteResponse as Y, type ImageMessagesRequest as Z, type ImageMessagesResponse as _, type CommandRequestType as a, type CommandResponse as a0, type CommandEvent as a1, type CommandEventType as a2, isCommandEvent as a3, isCommandRequest as a4, isCommandResponse as a5, type CommandRequestResponseMap as a6, type ResponseTypeFor as a7, type ResponseEventFor as b, type EventConsumer as c, type EventProducer as d, type UserContentPart as e, type ImageMetadata as f, type ImageRecord as g, type ImageListItem as h, type ContainerCreateRequest as i, type ContainerCreateResponse as j, type ContainerGetRequest as k, type ContainerGetResponse as l, type ContainerListRequest as m, type ContainerListResponse as n, type AgentGetRequest as o, type AgentGetResponse as p, type AgentListRequest as q, type AgentListResponse as r, type AgentDestroyRequest as s, type AgentDestroyResponse as t, type AgentDestroyAllRequest as u, type AgentDestroyAllResponse as v, type MessageSendRequest as w, type MessageSendResponse as x, type AgentInterruptRequest as y, type AgentInterruptResponse as z };