march-ai-sdk 0.3.0

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.
@@ -0,0 +1,790 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * March Agent SDK - Shared Types
5
+ * Port of Python march_agent types
6
+ */
7
+
8
+ interface KafkaMessage {
9
+ topic: string;
10
+ partition: number;
11
+ offset: number;
12
+ key: string;
13
+ headers: Record<string, string>;
14
+ body: Record<string, unknown>;
15
+ timestamp: number;
16
+ }
17
+ interface KafkaHeaders {
18
+ conversationId?: string;
19
+ userId?: string;
20
+ from_?: string;
21
+ to_?: string;
22
+ messageMetadata?: string;
23
+ messageSchema?: string;
24
+ attachment?: string;
25
+ [key: string]: string | undefined;
26
+ }
27
+ interface AgentRegistrationData {
28
+ id: string;
29
+ name: string;
30
+ about: string;
31
+ document: string;
32
+ representationName?: string;
33
+ baseUrl?: string;
34
+ metadata?: Record<string, unknown>;
35
+ relatedPages?: RelatedPage[];
36
+ }
37
+ interface RelatedPage {
38
+ name: string;
39
+ endpoint: string;
40
+ }
41
+ interface RegisterOptions {
42
+ name: string;
43
+ about: string;
44
+ document: string;
45
+ representationName?: string;
46
+ baseUrl?: string;
47
+ metadata?: Record<string, unknown>;
48
+ relatedPages?: RelatedPage[];
49
+ }
50
+ interface MessageHandler {
51
+ (message: any, sender: string): void | Promise<void>;
52
+ }
53
+ interface SenderFilterOptions {
54
+ senders?: string[];
55
+ }
56
+ interface StreamOptions {
57
+ persist?: boolean;
58
+ eventType?: string;
59
+ }
60
+ interface StreamerOptions {
61
+ awaiting?: boolean;
62
+ sendTo?: string;
63
+ }
64
+ declare const AttachmentInfoSchema: z.ZodObject<{
65
+ url: z.ZodString;
66
+ filename: z.ZodString;
67
+ contentType: z.ZodString;
68
+ size: z.ZodOptional<z.ZodNumber>;
69
+ fileType: z.ZodOptional<z.ZodString>;
70
+ }, "strip", z.ZodTypeAny, {
71
+ url: string;
72
+ filename: string;
73
+ contentType: string;
74
+ size?: number | undefined;
75
+ fileType?: string | undefined;
76
+ }, {
77
+ url: string;
78
+ filename: string;
79
+ contentType: string;
80
+ size?: number | undefined;
81
+ fileType?: string | undefined;
82
+ }>;
83
+ type AttachmentInfo = z.infer<typeof AttachmentInfoSchema>;
84
+ interface ConversationMessageData {
85
+ id: string;
86
+ conversationId: string;
87
+ role: 'user' | 'assistant' | 'system';
88
+ content: string;
89
+ from?: string;
90
+ to?: string;
91
+ createdAt: string;
92
+ metadata?: Record<string, unknown>;
93
+ }
94
+ interface ProduceAck {
95
+ topic: string;
96
+ partition: number;
97
+ offset: number;
98
+ correlationId?: string;
99
+ }
100
+ interface AppOptions {
101
+ gatewayUrl: string;
102
+ apiKey: string;
103
+ heartbeatInterval?: number;
104
+ maxConcurrentTasks?: number;
105
+ errorMessageTemplate?: string;
106
+ secure?: boolean;
107
+ }
108
+ interface ConversationData {
109
+ id: string;
110
+ userId: string;
111
+ agentId?: string;
112
+ awaitingRoute?: string;
113
+ pendingResponseSchema?: Record<string, unknown>;
114
+ createdAt: string;
115
+ updatedAt: string;
116
+ metadata?: Record<string, unknown>;
117
+ }
118
+ interface GetMessagesOptions {
119
+ role?: string;
120
+ from?: string;
121
+ to?: string;
122
+ limit?: number;
123
+ offset?: number;
124
+ }
125
+ interface MemoryMessage {
126
+ role: 'user' | 'assistant';
127
+ content: string;
128
+ timestamp?: string;
129
+ }
130
+ interface MemorySearchResult {
131
+ content: string;
132
+ similarity: number;
133
+ metadata?: Record<string, unknown>;
134
+ }
135
+ interface UserSummary {
136
+ userId: string;
137
+ summary: string;
138
+ updatedAt: string;
139
+ }
140
+
141
+ /**
142
+ * March Agent SDK - Conversation Client
143
+ * Port of Python march_agent/conversation_client.py
144
+ */
145
+
146
+ /**
147
+ * HTTP client for interacting with conversation-store API.
148
+ */
149
+ declare class ConversationClient {
150
+ private readonly baseUrl;
151
+ constructor(baseUrl: string);
152
+ /**
153
+ * Get conversation metadata.
154
+ */
155
+ getConversation(conversationId: string): Promise<ConversationData>;
156
+ /**
157
+ * Get messages from a conversation.
158
+ */
159
+ getMessages(conversationId: string, options?: GetMessagesOptions): Promise<ConversationMessageData[]>;
160
+ /**
161
+ * Update conversation fields (PATCH).
162
+ */
163
+ updateConversation(conversationId: string, data: Partial<ConversationData>): Promise<ConversationData>;
164
+ }
165
+
166
+ /**
167
+ * March Agent SDK - Conversation Message
168
+ * Port of Python march_agent/conversation_message.py
169
+ */
170
+
171
+ /**
172
+ * Represents a message from conversation history.
173
+ */
174
+ declare class ConversationMessage {
175
+ readonly id: string;
176
+ readonly conversationId: string;
177
+ readonly role: 'user' | 'assistant' | 'system';
178
+ readonly content: string;
179
+ readonly from?: string;
180
+ readonly to?: string;
181
+ readonly createdAt: Date;
182
+ readonly metadata?: Record<string, unknown>;
183
+ constructor(data: ConversationMessageData);
184
+ /**
185
+ * Create from API response
186
+ */
187
+ static fromApiResponse(data: Record<string, unknown>): ConversationMessage;
188
+ /**
189
+ * Check if this is a user message
190
+ */
191
+ isUser(): boolean;
192
+ /**
193
+ * Check if this is an assistant message
194
+ */
195
+ isAssistant(): boolean;
196
+ }
197
+
198
+ /**
199
+ * March Agent SDK - Conversation Helper
200
+ * Port of Python march_agent/conversation.py
201
+ */
202
+
203
+ interface GetHistoryOptions {
204
+ limit?: number;
205
+ offset?: number;
206
+ }
207
+ interface GetAgentHistoryOptions extends GetHistoryOptions {
208
+ agentName?: string;
209
+ }
210
+ /**
211
+ * Helper class for accessing conversation history.
212
+ * Provides convenient methods for fetching messages.
213
+ */
214
+ declare class Conversation {
215
+ readonly conversationId: string;
216
+ private readonly client;
217
+ private readonly agentName?;
218
+ constructor(conversationId: string, client: ConversationClient, agentName?: string);
219
+ /**
220
+ * Get all messages in the conversation.
221
+ */
222
+ getHistory(options?: GetHistoryOptions): Promise<ConversationMessage[]>;
223
+ /**
224
+ * Get messages to/from the current agent.
225
+ * Useful for getting conversation history for a specific agent.
226
+ */
227
+ getAgentHistory(options?: GetAgentHistoryOptions): Promise<ConversationMessage[]>;
228
+ /**
229
+ * Get the last N messages.
230
+ */
231
+ getLastMessages(count: number): Promise<ConversationMessage[]>;
232
+ /**
233
+ * Get user messages only.
234
+ */
235
+ getUserMessages(options?: GetHistoryOptions): Promise<ConversationMessage[]>;
236
+ /**
237
+ * Get assistant messages only.
238
+ */
239
+ getAssistantMessages(options?: GetHistoryOptions): Promise<ConversationMessage[]>;
240
+ }
241
+
242
+ /**
243
+ * March Agent SDK - Memory Client
244
+ * Port of Python march_agent/memory_client.py
245
+ */
246
+
247
+ /**
248
+ * Async HTTP client for AI memory API.
249
+ * Provides long-term memory storage and semantic search.
250
+ */
251
+ declare class MemoryClient {
252
+ private readonly baseUrl;
253
+ constructor(baseUrl: string);
254
+ /**
255
+ * Add messages to memory for a user/conversation.
256
+ */
257
+ addMessages(userId: string, conversationId: string, messages: MemoryMessage[]): Promise<{
258
+ added: number;
259
+ }>;
260
+ /**
261
+ * Search memory for relevant content.
262
+ */
263
+ search(userId: string, query: string, limit?: number): Promise<MemorySearchResult[]>;
264
+ /**
265
+ * Get user summary.
266
+ */
267
+ getUserSummary(userId: string): Promise<UserSummary | null>;
268
+ /**
269
+ * Clear user's memory.
270
+ */
271
+ clearMemory(userId: string): Promise<{
272
+ deleted: number;
273
+ }>;
274
+ }
275
+
276
+ /**
277
+ * March Agent SDK - Memory Helper
278
+ * Port of Python march_agent/memory.py
279
+ */
280
+
281
+ /**
282
+ * Helper class for accessing long-term memory.
283
+ * Provides convenient methods for storing and searching memories.
284
+ */
285
+ declare class Memory {
286
+ readonly userId: string;
287
+ readonly conversationId: string;
288
+ private readonly client;
289
+ constructor(userId: string, conversationId: string, client: MemoryClient);
290
+ /**
291
+ * Add messages to memory.
292
+ */
293
+ addMessages(messages: MemoryMessage[]): Promise<number>;
294
+ /**
295
+ * Add a single message to memory.
296
+ */
297
+ addMessage(role: 'user' | 'assistant', content: string): Promise<void>;
298
+ /**
299
+ * Search memory for relevant content.
300
+ */
301
+ search(query: string, limit?: number): Promise<MemorySearchResult[]>;
302
+ /**
303
+ * Get user summary.
304
+ */
305
+ getSummary(): Promise<UserSummary | null>;
306
+ /**
307
+ * Clear all memories for this user.
308
+ */
309
+ clear(): Promise<number>;
310
+ }
311
+
312
+ /**
313
+ * March Agent SDK - Attachment Client
314
+ * Port of Python march_agent/attachment_client.py
315
+ */
316
+
317
+ /**
318
+ * Create AttachmentInfo from API data
319
+ */
320
+ declare function createAttachmentInfo(data: Record<string, unknown>): AttachmentInfo;
321
+ /**
322
+ * HTTP client for downloading attachments.
323
+ */
324
+ declare class AttachmentClient {
325
+ private readonly baseUrl;
326
+ constructor(baseUrl: string);
327
+ /**
328
+ * Build full URL for an attachment.
329
+ */
330
+ private buildUrl;
331
+ /**
332
+ * Download attachment as bytes (Buffer).
333
+ */
334
+ download(url: string): Promise<Buffer>;
335
+ /**
336
+ * Download attachment as base64 string.
337
+ * Useful for LLM vision APIs.
338
+ */
339
+ downloadAsBase64(url: string): Promise<string>;
340
+ }
341
+
342
+ /**
343
+ * March Agent SDK - Message
344
+ * Port of Python march_agent/message.py
345
+ */
346
+
347
+ /**
348
+ * Represents an incoming message to the agent.
349
+ */
350
+ declare class Message {
351
+ readonly content: string;
352
+ readonly conversationId: string;
353
+ readonly userId: string;
354
+ readonly headers: Record<string, string>;
355
+ readonly rawBody: Record<string, unknown>;
356
+ readonly conversation?: Conversation;
357
+ readonly memory?: Memory;
358
+ readonly metadata?: Record<string, unknown>;
359
+ readonly schema?: Record<string, unknown>;
360
+ readonly attachment?: AttachmentInfo;
361
+ private readonly attachmentClient?;
362
+ constructor(options: {
363
+ content: string;
364
+ conversationId: string;
365
+ userId: string;
366
+ headers: Record<string, string>;
367
+ rawBody: Record<string, unknown>;
368
+ conversation?: Conversation;
369
+ memory?: Memory;
370
+ metadata?: Record<string, unknown>;
371
+ schema?: Record<string, unknown>;
372
+ attachment?: AttachmentInfo;
373
+ attachmentClient?: AttachmentClient;
374
+ });
375
+ /**
376
+ * Create Message from Kafka message data.
377
+ */
378
+ static fromKafkaMessage(body: Record<string, unknown>, headers: KafkaHeaders, options?: {
379
+ conversationClient?: ConversationClient;
380
+ memoryClient?: MemoryClient;
381
+ attachmentClient?: AttachmentClient;
382
+ agentName?: string;
383
+ }): Message;
384
+ /**
385
+ * Check if message has an attachment.
386
+ */
387
+ hasAttachment(): boolean;
388
+ /**
389
+ * Download attachment as bytes (Buffer).
390
+ *
391
+ * @throws Error if no attachment is available
392
+ */
393
+ getAttachmentBytes(): Promise<Buffer>;
394
+ /**
395
+ * Get attachment as base64 string (for LLM vision APIs).
396
+ *
397
+ * @throws Error if no attachment is available
398
+ */
399
+ getAttachmentBase64(): Promise<string>;
400
+ }
401
+
402
+ /**
403
+ * March Agent SDK - Gateway Client
404
+ * Port of Python march_agent/gateway_client.py
405
+ *
406
+ * gRPC client for communicating with the Agent Gateway.
407
+ */
408
+
409
+ /**
410
+ * Client for communicating with the Agent Gateway.
411
+ * Provides gRPC bidirectional streaming for Kafka consume/produce.
412
+ */
413
+ declare class GatewayClient {
414
+ private readonly gatewayUrl;
415
+ private readonly apiKey;
416
+ private readonly secure;
417
+ private client?;
418
+ private stream?;
419
+ private _connectionId?;
420
+ private messageQueue;
421
+ private pendingProduceAcks;
422
+ private pendingSubscribeAcks;
423
+ private messageHandlers;
424
+ private correlationCounter;
425
+ private connected;
426
+ constructor(gatewayUrl: string, apiKey: string, secure?: boolean);
427
+ /**
428
+ * HTTP URL for AI Inventory service via proxy.
429
+ */
430
+ get aiInventoryUrl(): string;
431
+ /**
432
+ * HTTP URL for Conversation Store service via proxy.
433
+ */
434
+ get conversationStoreUrl(): string;
435
+ /**
436
+ * HTTP URL for AI Memory service via proxy.
437
+ */
438
+ get aiMemoryUrl(): string;
439
+ /**
440
+ * HTTP URL for Attachment service via proxy.
441
+ */
442
+ get attachmentUrl(): string;
443
+ /**
444
+ * Register a handler for a topic.
445
+ */
446
+ registerHandler(topic: string, handler: (msg: KafkaMessage) => void): void;
447
+ /**
448
+ * Connect to the gateway and authenticate.
449
+ */
450
+ connect(agentNames: string[]): Promise<string[]>;
451
+ /**
452
+ * Handle incoming server messages.
453
+ */
454
+ private handleServerMessage;
455
+ /**
456
+ * Subscribe to an additional agent's topic.
457
+ */
458
+ subscribe(agentName: string): Promise<string>;
459
+ /**
460
+ * Unsubscribe from an agent's topic.
461
+ */
462
+ unsubscribe(agentName: string): void;
463
+ /**
464
+ * Produce a message to Kafka via the gateway.
465
+ */
466
+ produce(topic: string, key: string, headers: Record<string, string>, body: Record<string, unknown>, correlationId?: string): void;
467
+ /**
468
+ * Produce a message and wait for acknowledgment.
469
+ */
470
+ produceAndWait(topic: string, key: string, headers: Record<string, string>, body: Record<string, unknown>): Promise<ProduceAck>;
471
+ /**
472
+ * Consume a single message (polling from queue).
473
+ */
474
+ consumeOne(_timeout?: number): KafkaMessage | null;
475
+ /**
476
+ * Send a ping to the gateway.
477
+ */
478
+ ping(): void;
479
+ /**
480
+ * Make a sync POST request (used for registration).
481
+ */
482
+ httpPost(service: string, path: string, body: unknown): Promise<Response>;
483
+ /**
484
+ * Check if connected.
485
+ */
486
+ isConnected(): boolean;
487
+ /**
488
+ * Close the gateway connection.
489
+ */
490
+ close(): void;
491
+ }
492
+
493
+ /**
494
+ * March Agent SDK - Artifact Types
495
+ * Port of Python march_agent/artifact.py
496
+ */
497
+
498
+ /**
499
+ * Valid artifact types for message attachments
500
+ */
501
+ declare const ArtifactTypeSchema: z.ZodEnum<["document", "image", "iframe", "video", "audio", "code", "link", "file"]>;
502
+ type ArtifactType = z.infer<typeof ArtifactTypeSchema>;
503
+ /**
504
+ * Schema for artifact validation
505
+ */
506
+ declare const ArtifactSchema: z.ZodObject<{
507
+ url: z.ZodString;
508
+ type: z.ZodEnum<["document", "image", "iframe", "video", "audio", "code", "link", "file"]>;
509
+ title: z.ZodOptional<z.ZodString>;
510
+ description: z.ZodOptional<z.ZodString>;
511
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
512
+ }, "strip", z.ZodTypeAny, {
513
+ url: string;
514
+ type: "code" | "document" | "image" | "iframe" | "video" | "audio" | "link" | "file";
515
+ metadata?: Record<string, unknown> | undefined;
516
+ title?: string | undefined;
517
+ description?: string | undefined;
518
+ }, {
519
+ url: string;
520
+ type: "code" | "document" | "image" | "iframe" | "video" | "audio" | "link" | "file";
521
+ metadata?: Record<string, unknown> | undefined;
522
+ title?: string | undefined;
523
+ description?: string | undefined;
524
+ }>;
525
+ type Artifact = z.infer<typeof ArtifactSchema>;
526
+ /**
527
+ * Input type for adding artifacts (without strict validation)
528
+ */
529
+ interface ArtifactInput {
530
+ url: string;
531
+ type: ArtifactType | string;
532
+ title?: string;
533
+ description?: string;
534
+ metadata?: Record<string, unknown>;
535
+ }
536
+ /**
537
+ * Convert artifact input to validated artifact
538
+ */
539
+ declare function toArtifact(input: ArtifactInput): Artifact;
540
+
541
+ /**
542
+ * March Agent SDK - Streamer
543
+ * Port of Python march_agent/streamer.py
544
+ */
545
+
546
+ /**
547
+ * Handles streaming responses back to the conversation via the gateway.
548
+ */
549
+ declare class Streamer {
550
+ private readonly agentName;
551
+ private readonly originalMessage;
552
+ private readonly gatewayClient;
553
+ private readonly conversationClient?;
554
+ private readonly sendTo;
555
+ private awaiting;
556
+ private responseSchema?;
557
+ private messageMetadata?;
558
+ private artifacts;
559
+ private streamedContent;
560
+ private firstChunkSent;
561
+ private finished;
562
+ constructor(options: {
563
+ agentName: string;
564
+ originalMessage: Message;
565
+ gatewayClient: GatewayClient;
566
+ conversationClient?: ConversationClient;
567
+ awaiting?: boolean;
568
+ sendTo?: string;
569
+ });
570
+ /**
571
+ * Set response schema for form rendering (fluent API).
572
+ */
573
+ setResponseSchema(schema: Record<string, unknown>): this;
574
+ /**
575
+ * Set message metadata (fluent API).
576
+ */
577
+ setMessageMetadata(metadata: Record<string, unknown>): this;
578
+ /**
579
+ * Add an artifact to the message (fluent API).
580
+ */
581
+ addArtifact(artifact: ArtifactInput): this;
582
+ /**
583
+ * Set all artifacts at once (replaces any existing).
584
+ */
585
+ setArtifacts(artifacts: ArtifactInput[]): this;
586
+ /**
587
+ * Stream a content chunk.
588
+ */
589
+ stream(content: string, options?: StreamOptions): void;
590
+ /**
591
+ * Alias for stream() - write a content chunk.
592
+ */
593
+ write(content: string, persist?: boolean): void;
594
+ /**
595
+ * Finish streaming with done=true signal.
596
+ */
597
+ finish(awaitingOverride?: boolean): Promise<void>;
598
+ /**
599
+ * Send message to router via gateway.
600
+ */
601
+ private send;
602
+ /**
603
+ * Store response schema on conversation for form validation.
604
+ */
605
+ private setPendingResponseSchema;
606
+ /**
607
+ * Set awaiting_route to this agent's name.
608
+ */
609
+ private setAwaitingRoute;
610
+ /**
611
+ * Get the accumulated streamed content.
612
+ */
613
+ getStreamedContent(): string;
614
+ /**
615
+ * Support for async disposal (TypeScript 5.2+ "using" syntax).
616
+ */
617
+ [Symbol.asyncDispose](): Promise<void>;
618
+ }
619
+
620
+ /**
621
+ * March Agent SDK - Agent
622
+ * Port of Python march_agent/agent.py
623
+ */
624
+
625
+ /**
626
+ * Filter for matching message senders.
627
+ */
628
+ declare class SenderFilter {
629
+ private readonly _include;
630
+ private readonly _exclude;
631
+ readonly matchAll: boolean;
632
+ constructor(senders?: string[]);
633
+ /**
634
+ * Get included senders as an array (for compatibility with Python tests).
635
+ */
636
+ get include(): string[];
637
+ /**
638
+ * Get excluded senders as an array (for compatibility with Python tests).
639
+ */
640
+ get exclude(): string[];
641
+ /**
642
+ * Check if sender matches this filter.
643
+ */
644
+ matches(sender: string): boolean;
645
+ }
646
+ /**
647
+ * Core agent class that handles messaging via the Agent Gateway.
648
+ */
649
+ declare class Agent {
650
+ readonly name: string;
651
+ readonly agentData: AgentRegistrationData;
652
+ sendErrorResponses: boolean;
653
+ errorMessageTemplate: string;
654
+ private readonly gatewayClient;
655
+ private readonly conversationClient?;
656
+ private readonly memoryClient?;
657
+ private readonly attachmentClient?;
658
+ private readonly heartbeatInterval;
659
+ private messageHandlers;
660
+ private heartbeatManager?;
661
+ private initialized;
662
+ private running;
663
+ constructor(options: {
664
+ name: string;
665
+ gatewayClient: GatewayClient;
666
+ agentData: AgentRegistrationData;
667
+ heartbeatInterval?: number;
668
+ conversationClient?: ConversationClient;
669
+ memoryClient?: MemoryClient;
670
+ attachmentClient?: AttachmentClient;
671
+ errorMessageTemplate?: string;
672
+ });
673
+ /**
674
+ * Register a message handler.
675
+ *
676
+ * Usage:
677
+ * agent.onMessage(async (message, sender) => { ... })
678
+ * agent.onMessage(handler, { senders: ['user'] })
679
+ */
680
+ onMessage(handler: MessageHandler): void;
681
+ onMessage(handler: MessageHandler, options: SenderFilterOptions): void;
682
+ /**
683
+ * Initialize agent after gateway connection is established.
684
+ */
685
+ initializeWithGateway(): void;
686
+ /**
687
+ * Get sender from message headers.
688
+ */
689
+ private getSender;
690
+ /**
691
+ * Find first handler that matches the sender.
692
+ */
693
+ private findMatchingHandler;
694
+ /**
695
+ * Handle incoming Kafka message.
696
+ */
697
+ private handleKafkaMessage;
698
+ /**
699
+ * Async message handling with error recovery.
700
+ */
701
+ private handleMessageAsync;
702
+ /**
703
+ * Send error response to user when handler fails.
704
+ */
705
+ private sendErrorResponse;
706
+ /**
707
+ * Create a new Streamer for streaming responses.
708
+ */
709
+ streamer(message: Message, options?: StreamerOptions): Streamer;
710
+ /**
711
+ * Mark agent as ready to consume messages.
712
+ */
713
+ startConsuming(): void;
714
+ /**
715
+ * Shutdown agent gracefully.
716
+ */
717
+ shutdown(): void;
718
+ /**
719
+ * Check if agent is running.
720
+ */
721
+ isRunning(): boolean;
722
+ }
723
+
724
+ /**
725
+ * March Agent SDK - Main Application
726
+ * Port of Python march_agent/app.py
727
+ */
728
+
729
+ /**
730
+ * Main application class for March AI Agent framework.
731
+ *
732
+ * @example
733
+ * ```typescript
734
+ * import { MarchAgentApp } from 'march-ai-sdk'
735
+ *
736
+ * const app = new MarchAgentApp({
737
+ * gatewayUrl: 'agent-gateway:8080',
738
+ * apiKey: 'your-api-key',
739
+ * })
740
+ *
741
+ * const agent = app.registerMe({
742
+ * name: 'my-agent',
743
+ * about: 'A helpful assistant',
744
+ * document: 'Detailed description...',
745
+ * })
746
+ *
747
+ * agent.onMessage(async (message, sender) => {
748
+ * const streamer = agent.streamer(message)
749
+ * streamer.stream('Hello!')
750
+ * await streamer.finish()
751
+ * })
752
+ *
753
+ * app.run()
754
+ * ```
755
+ */
756
+ declare class MarchAgentApp {
757
+ readonly gatewayClient: GatewayClient;
758
+ readonly conversationClient: ConversationClient;
759
+ readonly memoryClient: MemoryClient;
760
+ readonly attachmentClient: AttachmentClient;
761
+ private readonly heartbeatInterval;
762
+ private readonly _maxConcurrentTasks;
763
+ private readonly errorMessageTemplate;
764
+ private agents;
765
+ private running;
766
+ private shutdownRequested;
767
+ constructor(options: AppOptions);
768
+ /**
769
+ * Register an agent with the backend.
770
+ */
771
+ registerMe(options: RegisterOptions): Promise<Agent>;
772
+ /**
773
+ * Register agent with AI Inventory service.
774
+ */
775
+ private registerWithInventory;
776
+ /**
777
+ * Start all registered agents and block until shutdown.
778
+ */
779
+ run(): Promise<void>;
780
+ /**
781
+ * Main consume loop.
782
+ */
783
+ private consumeLoop;
784
+ /**
785
+ * Shutdown all agents gracefully.
786
+ */
787
+ shutdown(): void;
788
+ }
789
+
790
+ export { Agent as A, Conversation as C, GatewayClient as G, type KafkaHeaders as K, MarchAgentApp as M, type ProduceAck as P, type RegisterOptions as R, SenderFilter as S, type UserSummary as U, type AgentRegistrationData as a, type AppOptions as b, type Artifact as c, type ArtifactInput as d, type ArtifactType as e, AttachmentClient as f, type AttachmentInfo as g, ConversationClient as h, type ConversationData as i, ConversationMessage as j, type GetMessagesOptions as k, type KafkaMessage as l, Memory as m, MemoryClient as n, type MemoryMessage as o, type MemorySearchResult as p, Message as q, type MessageHandler as r, type SenderFilterOptions as s, type StreamOptions as t, Streamer as u, type StreamerOptions as v, createAttachmentInfo as w, toArtifact as x };