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.
package/src/types.ts ADDED
@@ -0,0 +1,196 @@
1
+ /**
2
+ * March Agent SDK - Shared Types
3
+ * Port of Python march_agent types
4
+ */
5
+
6
+ import { z } from 'zod'
7
+
8
+ // ============================================================================
9
+ // Kafka Message Types
10
+ // ============================================================================
11
+
12
+ export interface KafkaMessage {
13
+ topic: string
14
+ partition: number
15
+ offset: number
16
+ key: string
17
+ headers: Record<string, string>
18
+ body: Record<string, unknown>
19
+ timestamp: number
20
+ }
21
+
22
+ export interface KafkaHeaders {
23
+ conversationId?: string
24
+ userId?: string
25
+ from_?: string
26
+ to_?: string
27
+ messageMetadata?: string
28
+ messageSchema?: string
29
+ attachment?: string
30
+ [key: string]: string | undefined
31
+ }
32
+
33
+ // ============================================================================
34
+ // Agent Registration Types
35
+ // ============================================================================
36
+
37
+ export interface AgentRegistrationData {
38
+ id: string
39
+ name: string
40
+ about: string
41
+ document: string
42
+ representationName?: string
43
+ baseUrl?: string
44
+ metadata?: Record<string, unknown>
45
+ relatedPages?: RelatedPage[]
46
+ }
47
+
48
+ export interface RelatedPage {
49
+ name: string
50
+ endpoint: string
51
+ }
52
+
53
+ export interface RegisterOptions {
54
+ name: string
55
+ about: string
56
+ document: string
57
+ representationName?: string
58
+ baseUrl?: string
59
+ metadata?: Record<string, unknown>
60
+ relatedPages?: RelatedPage[]
61
+ }
62
+
63
+ // ============================================================================
64
+ // Message Types
65
+ // ============================================================================
66
+
67
+ // Forward reference - actual Message class is imported where needed
68
+ // Using 'any' here to avoid circular dependency, but consumers should use Message type
69
+ export interface MessageHandler {
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
+ (message: any, sender: string): void | Promise<void>
72
+ }
73
+
74
+ export interface SenderFilterOptions {
75
+ senders?: string[]
76
+ }
77
+
78
+ // ============================================================================
79
+ // Streamer Types
80
+ // ============================================================================
81
+
82
+ export interface StreamOptions {
83
+ persist?: boolean
84
+ eventType?: string
85
+ }
86
+
87
+ export interface StreamerOptions {
88
+ awaiting?: boolean
89
+ sendTo?: string
90
+ }
91
+
92
+ // ============================================================================
93
+ // Attachment Types
94
+ // ============================================================================
95
+
96
+ export const AttachmentInfoSchema = z.object({
97
+ url: z.string(),
98
+ filename: z.string(),
99
+ contentType: z.string(),
100
+ size: z.number().optional(),
101
+ fileType: z.string().optional(),
102
+ })
103
+
104
+ export type AttachmentInfo = z.infer<typeof AttachmentInfoSchema>
105
+
106
+ export function isImageAttachment(attachment: AttachmentInfo): boolean {
107
+ return attachment.contentType?.startsWith('image/') || false
108
+ }
109
+
110
+ export function isPdfAttachment(attachment: AttachmentInfo): boolean {
111
+ return attachment.contentType === 'application/pdf'
112
+ }
113
+
114
+ // ============================================================================
115
+ // Conversation Message Types
116
+ // ============================================================================
117
+
118
+ export interface ConversationMessageData {
119
+ id: string
120
+ conversationId: string
121
+ role: 'user' | 'assistant' | 'system'
122
+ content: string
123
+ from?: string
124
+ to?: string
125
+ createdAt: string
126
+ metadata?: Record<string, unknown>
127
+ }
128
+
129
+ // ============================================================================
130
+ // Gateway Client Types
131
+ // ============================================================================
132
+
133
+ export interface ProduceAck {
134
+ topic: string
135
+ partition: number
136
+ offset: number
137
+ correlationId?: string
138
+ }
139
+
140
+ // ============================================================================
141
+ // App Configuration Types
142
+ // ============================================================================
143
+
144
+ export interface AppOptions {
145
+ gatewayUrl: string
146
+ apiKey: string
147
+ heartbeatInterval?: number
148
+ maxConcurrentTasks?: number
149
+ errorMessageTemplate?: string
150
+ secure?: boolean
151
+ }
152
+
153
+ // ============================================================================
154
+ // HTTP Response Types
155
+ // ============================================================================
156
+
157
+ export interface ConversationData {
158
+ id: string
159
+ userId: string
160
+ agentId?: string
161
+ awaitingRoute?: string
162
+ pendingResponseSchema?: Record<string, unknown>
163
+ createdAt: string
164
+ updatedAt: string
165
+ metadata?: Record<string, unknown>
166
+ }
167
+
168
+ export interface GetMessagesOptions {
169
+ role?: string
170
+ from?: string
171
+ to?: string
172
+ limit?: number
173
+ offset?: number
174
+ }
175
+
176
+ // ============================================================================
177
+ // Memory Types
178
+ // ============================================================================
179
+
180
+ export interface MemoryMessage {
181
+ role: 'user' | 'assistant'
182
+ content: string
183
+ timestamp?: string
184
+ }
185
+
186
+ export interface MemorySearchResult {
187
+ content: string
188
+ similarity: number
189
+ metadata?: Record<string, unknown>
190
+ }
191
+
192
+ export interface UserSummary {
193
+ userId: string
194
+ summary: string
195
+ updatedAt: string
196
+ }