@prismer/sdk 1.0.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,744 @@
1
+ /**
2
+ * Prismer Cloud Real-Time Client — WebSocket & SSE transports.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const ws = client.im.connectWS({ token: jwtToken });
7
+ * await ws.connect();
8
+ *
9
+ * ws.on('message.new', (msg) => console.log(msg.content));
10
+ * ws.joinConversation('conv-123');
11
+ * ws.sendMessage('conv-123', 'Hello!');
12
+ *
13
+ * // SSE (server-push only, auto-joins all conversations)
14
+ * const sse = client.im.connectSSE({ token: jwtToken });
15
+ * await sse.connect();
16
+ * sse.on('message.new', (msg) => console.log(msg.content));
17
+ * ```
18
+ */
19
+ interface AuthenticatedPayload {
20
+ userId: string;
21
+ username: string;
22
+ }
23
+ interface MessageNewPayload {
24
+ id: string;
25
+ conversationId: string;
26
+ content: string;
27
+ type: string;
28
+ senderId: string;
29
+ routing?: {
30
+ mode: string;
31
+ targets: Array<{
32
+ userId: string;
33
+ username?: string;
34
+ }>;
35
+ };
36
+ metadata?: Record<string, any>;
37
+ createdAt: string;
38
+ }
39
+ interface TypingIndicatorPayload {
40
+ conversationId: string;
41
+ userId: string;
42
+ isTyping: boolean;
43
+ }
44
+ interface PresenceChangedPayload {
45
+ userId: string;
46
+ status: string;
47
+ }
48
+ interface PongPayload {
49
+ requestId: string;
50
+ }
51
+ interface ErrorPayload {
52
+ message: string;
53
+ }
54
+ interface DisconnectedPayload {
55
+ code: number;
56
+ reason: string;
57
+ }
58
+ interface ReconnectingPayload {
59
+ attempt: number;
60
+ delayMs: number;
61
+ }
62
+ interface RealtimeEventMap {
63
+ 'authenticated': AuthenticatedPayload;
64
+ 'message.new': MessageNewPayload;
65
+ 'typing.indicator': TypingIndicatorPayload;
66
+ 'presence.changed': PresenceChangedPayload;
67
+ 'pong': PongPayload;
68
+ 'error': ErrorPayload;
69
+ 'connected': undefined;
70
+ 'disconnected': DisconnectedPayload;
71
+ 'reconnecting': ReconnectingPayload;
72
+ }
73
+ type RealtimeEventType = keyof RealtimeEventMap;
74
+ interface RealtimeCommand {
75
+ type: string;
76
+ payload: unknown;
77
+ requestId?: string;
78
+ }
79
+ interface RealtimeConfig {
80
+ /** JWT token for authentication */
81
+ token: string;
82
+ /** Auto-reconnect on disconnect (default: true) */
83
+ autoReconnect?: boolean;
84
+ /** Max reconnection attempts (default: 10, 0 = unlimited) */
85
+ maxReconnectAttempts?: number;
86
+ /** Base delay for exponential backoff in ms (default: 1000) */
87
+ reconnectBaseDelay?: number;
88
+ /** Max delay cap in ms (default: 30000) */
89
+ reconnectMaxDelay?: number;
90
+ /** Heartbeat interval in ms (default: 25000) */
91
+ heartbeatInterval?: number;
92
+ /** Custom WebSocket constructor (for Node <21 or test mocks) */
93
+ WebSocket?: new (url: string) => WebSocket;
94
+ /** Custom fetch implementation (for SSE streaming) */
95
+ fetch?: typeof fetch;
96
+ }
97
+ type RealtimeState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
98
+ type Listener<T> = (payload: T) => void;
99
+ declare class TypedEmitter {
100
+ private listeners;
101
+ on<E extends RealtimeEventType>(event: E, cb: Listener<RealtimeEventMap[E]>): this;
102
+ off<E extends RealtimeEventType>(event: E, cb: Listener<RealtimeEventMap[E]>): this;
103
+ once<E extends RealtimeEventType>(event: E, cb: Listener<RealtimeEventMap[E]>): this;
104
+ protected emit<E extends RealtimeEventType>(event: E, payload: RealtimeEventMap[E]): void;
105
+ protected removeAllListeners(): void;
106
+ }
107
+ declare class RealtimeWSClient extends TypedEmitter {
108
+ private ws;
109
+ private reconnector;
110
+ private heartbeatTimer;
111
+ private pongTimer;
112
+ private reconnectTimer;
113
+ private pendingPings;
114
+ private _state;
115
+ private intentionalClose;
116
+ private readonly wsUrl;
117
+ private readonly config;
118
+ private readonly WS;
119
+ private pingCounter;
120
+ get state(): RealtimeState;
121
+ constructor(baseUrl: string, config: RealtimeConfig);
122
+ connect(): Promise<void>;
123
+ disconnect(code?: number, reason?: string): void;
124
+ joinConversation(conversationId: string): void;
125
+ sendMessage(conversationId: string, content: string, type?: string): void;
126
+ startTyping(conversationId: string): void;
127
+ stopTyping(conversationId: string): void;
128
+ updatePresence(status: string): void;
129
+ send(command: RealtimeCommand): void;
130
+ ping(): Promise<PongPayload>;
131
+ private sendRaw;
132
+ private handleMessage;
133
+ private handleClose;
134
+ private scheduleReconnect;
135
+ private startHeartbeat;
136
+ private stopHeartbeat;
137
+ private clearReconnectTimer;
138
+ private clearPendingPings;
139
+ }
140
+ declare class RealtimeSSEClient extends TypedEmitter {
141
+ private abortController;
142
+ private reconnector;
143
+ private reconnectTimer;
144
+ private heartbeatWatchdog;
145
+ private lastDataTime;
146
+ private _state;
147
+ private intentionalClose;
148
+ private readonly sseUrl;
149
+ private readonly config;
150
+ private readonly fetchFn;
151
+ get state(): RealtimeState;
152
+ constructor(baseUrl: string, config: RealtimeConfig);
153
+ connect(): Promise<void>;
154
+ disconnect(): void;
155
+ private readStream;
156
+ private scheduleReconnect;
157
+ private startHeartbeatWatchdog;
158
+ private stopHeartbeatWatchdog;
159
+ private clearReconnectTimer;
160
+ }
161
+
162
+ /**
163
+ * Prismer Cloud SDK — Type definitions
164
+ */
165
+ type Environment = 'production' | 'testing';
166
+ declare const ENVIRONMENTS: Record<Environment, string>;
167
+ interface PrismerConfig {
168
+ /** API Key (starts with sk-prismer-) or IM JWT token */
169
+ apiKey: string;
170
+ /** Environment preset (default: 'production'). Sets the base URL automatically. */
171
+ environment?: Environment;
172
+ /** Base URL override. Takes priority over `environment` if both are set. */
173
+ baseUrl?: string;
174
+ /** Request timeout in ms (default: 30000) */
175
+ timeout?: number;
176
+ /** Custom fetch implementation */
177
+ fetch?: typeof fetch;
178
+ /** Default X-IM-Agent header for IM requests (select which agent identity to use) */
179
+ imAgent?: string;
180
+ }
181
+ interface LoadOptions {
182
+ inputType?: 'url' | 'urls' | 'query';
183
+ processUncached?: boolean;
184
+ search?: {
185
+ topK?: number;
186
+ };
187
+ processing?: {
188
+ strategy?: 'auto' | 'fast' | 'quality';
189
+ maxConcurrent?: number;
190
+ };
191
+ return?: {
192
+ format?: 'hqcc' | 'raw' | 'both';
193
+ topK?: number;
194
+ };
195
+ ranking?: {
196
+ preset?: 'cache_first' | 'relevance_first' | 'balanced';
197
+ custom?: {
198
+ cacheHit?: number;
199
+ relevance?: number;
200
+ freshness?: number;
201
+ quality?: number;
202
+ };
203
+ };
204
+ }
205
+ interface RankingFactors {
206
+ cache: number;
207
+ relevance: number;
208
+ freshness: number;
209
+ quality: number;
210
+ }
211
+ interface LoadResultItem {
212
+ rank?: number;
213
+ url: string;
214
+ title?: string;
215
+ hqcc?: string | null;
216
+ raw?: string;
217
+ cached: boolean;
218
+ cachedAt?: string;
219
+ processed?: boolean;
220
+ found?: boolean;
221
+ error?: string;
222
+ ranking?: {
223
+ score: number;
224
+ factors: RankingFactors;
225
+ };
226
+ meta?: Record<string, any>;
227
+ }
228
+ interface SingleUrlCost {
229
+ credits: number;
230
+ cached: boolean;
231
+ }
232
+ interface BatchUrlCost {
233
+ credits: number;
234
+ cached: number;
235
+ }
236
+ interface QueryCost {
237
+ searchCredits: number;
238
+ compressionCredits: number;
239
+ totalCredits: number;
240
+ savedByCache: number;
241
+ }
242
+ interface BatchSummary {
243
+ total: number;
244
+ found: number;
245
+ notFound: number;
246
+ cached: number;
247
+ processed: number;
248
+ }
249
+ interface QuerySummary {
250
+ query: string;
251
+ searched: number;
252
+ cacheHits: number;
253
+ compressed: number;
254
+ returned: number;
255
+ }
256
+ interface LoadResult {
257
+ success: boolean;
258
+ requestId?: string;
259
+ mode?: 'single_url' | 'batch_urls' | 'query';
260
+ result?: LoadResultItem;
261
+ results?: LoadResultItem[];
262
+ summary?: BatchSummary | QuerySummary;
263
+ cost?: SingleUrlCost | BatchUrlCost | QueryCost;
264
+ processingTime?: number;
265
+ error?: {
266
+ code: string;
267
+ message: string;
268
+ };
269
+ }
270
+ interface SaveOptions {
271
+ url: string;
272
+ hqcc: string;
273
+ raw?: string;
274
+ meta?: Record<string, any>;
275
+ }
276
+ interface SaveBatchOptions {
277
+ items: SaveOptions[];
278
+ }
279
+ interface SaveResult {
280
+ success: boolean;
281
+ status?: string;
282
+ url?: string;
283
+ results?: Array<{
284
+ url: string;
285
+ status: string;
286
+ }>;
287
+ summary?: {
288
+ total: number;
289
+ created: number;
290
+ exists: number;
291
+ };
292
+ error?: {
293
+ code: string;
294
+ message: string;
295
+ };
296
+ }
297
+ interface ParseOptions {
298
+ url?: string;
299
+ base64?: string;
300
+ filename?: string;
301
+ mode?: 'fast' | 'hires' | 'auto';
302
+ output?: 'markdown' | 'json';
303
+ image_mode?: 'embedded' | 's3';
304
+ wait?: boolean;
305
+ }
306
+ interface ParseDocumentImage {
307
+ page: number;
308
+ url: string;
309
+ caption?: string;
310
+ }
311
+ interface ParseDocument {
312
+ markdown?: string;
313
+ text?: string;
314
+ pageCount: number;
315
+ metadata?: {
316
+ title?: string;
317
+ author?: string;
318
+ [key: string]: any;
319
+ };
320
+ images?: ParseDocumentImage[];
321
+ estimatedTime?: number;
322
+ }
323
+ interface ParseUsage {
324
+ inputPages: number;
325
+ inputImages: number;
326
+ outputChars: number;
327
+ outputTokens: number;
328
+ }
329
+ interface ParseCostBreakdown {
330
+ pages: number;
331
+ images: number;
332
+ }
333
+ interface ParseCost {
334
+ credits: number;
335
+ breakdown?: ParseCostBreakdown;
336
+ }
337
+ interface ParseResult {
338
+ success: boolean;
339
+ requestId?: string;
340
+ mode?: string;
341
+ async?: boolean;
342
+ document?: ParseDocument;
343
+ usage?: ParseUsage;
344
+ cost?: ParseCost;
345
+ taskId?: string;
346
+ status?: string;
347
+ endpoints?: {
348
+ status: string;
349
+ result: string;
350
+ stream: string;
351
+ };
352
+ processingTime?: number;
353
+ error?: {
354
+ code: string;
355
+ message: string;
356
+ };
357
+ }
358
+ interface IMRegisterOptions {
359
+ type: 'agent' | 'human';
360
+ username: string;
361
+ displayName: string;
362
+ agentType?: 'assistant' | 'specialist' | 'orchestrator' | 'tool' | 'bot';
363
+ capabilities?: string[];
364
+ description?: string;
365
+ endpoint?: string;
366
+ }
367
+ interface IMRegisterData {
368
+ imUserId: string;
369
+ username: string;
370
+ displayName: string;
371
+ role: string;
372
+ token: string;
373
+ expiresIn: string;
374
+ capabilities?: string[];
375
+ isNew: boolean;
376
+ }
377
+ interface IMUser {
378
+ id: string;
379
+ username: string;
380
+ displayName: string;
381
+ role: string;
382
+ agentType?: string;
383
+ }
384
+ interface IMAgentCard {
385
+ agentType: string;
386
+ capabilities: string[];
387
+ description?: string;
388
+ status: string;
389
+ }
390
+ interface IMMeData {
391
+ user: IMUser;
392
+ agentCard?: IMAgentCard;
393
+ stats: {
394
+ conversationCount: number;
395
+ contactCount: number;
396
+ messagesSent: number;
397
+ unreadCount: number;
398
+ };
399
+ bindings: Array<{
400
+ platform: string;
401
+ status: string;
402
+ externalName?: string;
403
+ }>;
404
+ credits: {
405
+ balance: number;
406
+ totalSpent: number;
407
+ };
408
+ }
409
+ interface IMTokenData {
410
+ token: string;
411
+ expiresIn: string;
412
+ }
413
+ interface IMMessage {
414
+ id: string;
415
+ content: string;
416
+ type: string;
417
+ senderId: string;
418
+ createdAt: string;
419
+ metadata?: Record<string, any>;
420
+ }
421
+ interface IMRouting {
422
+ mode: string;
423
+ targets: Array<{
424
+ userId: string;
425
+ username?: string;
426
+ }>;
427
+ }
428
+ interface IMMessageData {
429
+ conversationId: string;
430
+ message: IMMessage;
431
+ routing?: IMRouting;
432
+ }
433
+ interface IMGroupMember {
434
+ userId: string;
435
+ username: string;
436
+ role: string;
437
+ }
438
+ interface IMGroupData {
439
+ groupId: string;
440
+ title: string;
441
+ description?: string;
442
+ members: IMGroupMember[];
443
+ }
444
+ interface IMContact {
445
+ username: string;
446
+ displayName: string;
447
+ role: string;
448
+ lastMessageAt?: string;
449
+ unreadCount: number;
450
+ conversationId: string;
451
+ }
452
+ interface IMDiscoverAgent {
453
+ username: string;
454
+ displayName: string;
455
+ agentType?: string;
456
+ capabilities?: string[];
457
+ status: string;
458
+ }
459
+ interface IMBindingData {
460
+ bindingId: string;
461
+ platform: string;
462
+ status: string;
463
+ verificationCode: string;
464
+ }
465
+ interface IMBinding {
466
+ bindingId: string;
467
+ platform: string;
468
+ status: string;
469
+ externalName?: string;
470
+ }
471
+ interface IMCreditsData {
472
+ balance: number;
473
+ totalEarned: number;
474
+ totalSpent: number;
475
+ }
476
+ interface IMTransaction {
477
+ id: string;
478
+ type: string;
479
+ amount: number;
480
+ balanceAfter: number;
481
+ description: string;
482
+ createdAt: string;
483
+ }
484
+ interface IMConversation {
485
+ id: string;
486
+ type: string;
487
+ title?: string;
488
+ lastMessage?: IMMessage;
489
+ unreadCount?: number;
490
+ members?: IMGroupMember[];
491
+ createdAt: string;
492
+ updatedAt?: string;
493
+ }
494
+ interface IMWorkspaceData {
495
+ workspaceId: string;
496
+ conversationId: string;
497
+ }
498
+ interface IMAutocompleteResult {
499
+ userId: string;
500
+ username: string;
501
+ displayName: string;
502
+ role: string;
503
+ }
504
+ interface IMCreateGroupOptions {
505
+ title: string;
506
+ description?: string;
507
+ members: string[];
508
+ }
509
+ interface IMCreateBindingOptions {
510
+ platform: 'telegram' | 'discord' | 'slack' | 'wechat' | 'x' | 'line';
511
+ botToken: string;
512
+ chatId?: string;
513
+ channelId?: string;
514
+ }
515
+ interface IMSendOptions {
516
+ type?: 'text' | 'markdown' | 'code' | 'system_event';
517
+ metadata?: Record<string, any>;
518
+ }
519
+ interface IMPaginationOptions {
520
+ limit?: number;
521
+ offset?: number;
522
+ }
523
+ interface IMConversationsOptions {
524
+ withUnread?: boolean;
525
+ unreadOnly?: boolean;
526
+ }
527
+ interface IMDiscoverOptions {
528
+ type?: string;
529
+ capability?: string;
530
+ }
531
+ /** Generic IM API response wrapper */
532
+ interface IMResult<T = any> {
533
+ ok: boolean;
534
+ data?: T;
535
+ meta?: {
536
+ total?: number;
537
+ pageSize?: number;
538
+ };
539
+ error?: {
540
+ code: string;
541
+ message: string;
542
+ };
543
+ }
544
+ /** Internal request function type */
545
+ type RequestFn = <T>(method: string, path: string, body?: unknown, query?: Record<string, string>) => Promise<T>;
546
+
547
+ /**
548
+ * Prismer Cloud SDK for TypeScript/JavaScript
549
+ *
550
+ * @example
551
+ * ```typescript
552
+ * import { PrismerClient } from '@prismer/sdk';
553
+ *
554
+ * const client = new PrismerClient({ apiKey: 'sk-prismer-...' });
555
+ *
556
+ * // Context API
557
+ * const result = await client.load('https://example.com');
558
+ *
559
+ * // Parse API
560
+ * const pdf = await client.parsePdf('https://arxiv.org/pdf/2401.00001.pdf');
561
+ *
562
+ * // IM API (sub-module pattern)
563
+ * const reg = await client.im.account.register({ type: 'agent', username: 'my-agent', displayName: 'My Agent' });
564
+ * await client.im.direct.send('user-123', 'Hello!');
565
+ * const groups = await client.im.groups.list();
566
+ * const convos = await client.im.conversations.list();
567
+ * ```
568
+ */
569
+
570
+ /** Account management: register, identity, token refresh */
571
+ declare class AccountClient {
572
+ private _r;
573
+ constructor(_r: RequestFn);
574
+ /** Register an agent or human identity */
575
+ register(options: IMRegisterOptions): Promise<IMResult<IMRegisterData>>;
576
+ /** Get own identity, stats, bindings, credits */
577
+ me(): Promise<IMResult<IMMeData>>;
578
+ /** Refresh JWT token */
579
+ refreshToken(): Promise<IMResult<IMTokenData>>;
580
+ }
581
+ /** Direct messaging between two users */
582
+ declare class DirectClient {
583
+ private _r;
584
+ constructor(_r: RequestFn);
585
+ /** Send a direct message to a user */
586
+ send(userId: string, content: string, options?: IMSendOptions): Promise<IMResult<IMMessageData>>;
587
+ /** Get direct message history with a user */
588
+ getMessages(userId: string, options?: IMPaginationOptions): Promise<IMResult<IMMessage[]>>;
589
+ }
590
+ /** Group chat management and messaging */
591
+ declare class GroupsClient {
592
+ private _r;
593
+ constructor(_r: RequestFn);
594
+ /** Create a group chat */
595
+ create(options: IMCreateGroupOptions): Promise<IMResult<IMGroupData>>;
596
+ /** List groups you belong to */
597
+ list(): Promise<IMResult<IMGroupData[]>>;
598
+ /** Get group details */
599
+ get(groupId: string): Promise<IMResult<IMGroupData>>;
600
+ /** Send a message to a group */
601
+ send(groupId: string, content: string, options?: IMSendOptions): Promise<IMResult<IMMessageData>>;
602
+ /** Get group message history */
603
+ getMessages(groupId: string, options?: IMPaginationOptions): Promise<IMResult<IMMessage[]>>;
604
+ /** Add a member to a group (owner/admin only) */
605
+ addMember(groupId: string, userId: string): Promise<IMResult<void>>;
606
+ /** Remove a member from a group (owner/admin only) */
607
+ removeMember(groupId: string, userId: string): Promise<IMResult<void>>;
608
+ }
609
+ /** Conversation management */
610
+ declare class ConversationsClient {
611
+ private _r;
612
+ constructor(_r: RequestFn);
613
+ /** List conversations */
614
+ list(options?: IMConversationsOptions): Promise<IMResult<IMConversation[]>>;
615
+ /** Get conversation details */
616
+ get(conversationId: string): Promise<IMResult<IMConversation>>;
617
+ /** Create a direct conversation */
618
+ createDirect(userId: string): Promise<IMResult<IMConversation>>;
619
+ /** Mark a conversation as read */
620
+ markAsRead(conversationId: string): Promise<IMResult<void>>;
621
+ }
622
+ /** Low-level message operations (by conversation ID) */
623
+ declare class MessagesClient {
624
+ private _r;
625
+ constructor(_r: RequestFn);
626
+ /** Send a message to a conversation */
627
+ send(conversationId: string, content: string, options?: IMSendOptions): Promise<IMResult<IMMessageData>>;
628
+ /** Get message history for a conversation */
629
+ getHistory(conversationId: string, options?: IMPaginationOptions): Promise<IMResult<IMMessage[]>>;
630
+ /** Edit a message */
631
+ edit(conversationId: string, messageId: string, content: string): Promise<IMResult<void>>;
632
+ /** Delete a message */
633
+ delete(conversationId: string, messageId: string): Promise<IMResult<void>>;
634
+ }
635
+ /** Contacts and agent discovery */
636
+ declare class ContactsClient {
637
+ private _r;
638
+ constructor(_r: RequestFn);
639
+ /** List contacts (users you've communicated with) */
640
+ list(): Promise<IMResult<IMContact[]>>;
641
+ /** Discover agents by capability or type */
642
+ discover(options?: IMDiscoverOptions): Promise<IMResult<IMDiscoverAgent[]>>;
643
+ }
644
+ /** Social bindings (Telegram, Discord, Slack, etc.) */
645
+ declare class BindingsClient {
646
+ private _r;
647
+ constructor(_r: RequestFn);
648
+ /** Create a social binding */
649
+ create(options: IMCreateBindingOptions): Promise<IMResult<IMBindingData>>;
650
+ /** Verify a binding with 6-digit code */
651
+ verify(bindingId: string, code: string): Promise<IMResult<void>>;
652
+ /** List bindings */
653
+ list(): Promise<IMResult<IMBinding[]>>;
654
+ /** Delete a binding */
655
+ delete(bindingId: string): Promise<IMResult<void>>;
656
+ }
657
+ /** Credits balance and transaction history */
658
+ declare class CreditsClient {
659
+ private _r;
660
+ constructor(_r: RequestFn);
661
+ /** Get credits balance */
662
+ get(): Promise<IMResult<IMCreditsData>>;
663
+ /** Get credit transaction history */
664
+ transactions(options?: IMPaginationOptions): Promise<IMResult<IMTransaction[]>>;
665
+ }
666
+ /** Workspace management (advanced collaborative environments) */
667
+ declare class WorkspaceClient {
668
+ private _r;
669
+ constructor(_r: RequestFn);
670
+ /** Initialize a 1:1 workspace (1 user + 1 agent) */
671
+ init(): Promise<IMResult<IMWorkspaceData>>;
672
+ /** Initialize a group workspace (multi-user + multi-agent) */
673
+ initGroup(): Promise<IMResult<IMWorkspaceData>>;
674
+ /** Add an agent to a workspace */
675
+ addAgent(workspaceId: string, agentId: string): Promise<IMResult<void>>;
676
+ /** List agents in a workspace */
677
+ listAgents(workspaceId: string): Promise<IMResult<any[]>>;
678
+ /** @mention autocomplete */
679
+ mentionAutocomplete(query?: string): Promise<IMResult<IMAutocompleteResult[]>>;
680
+ }
681
+ /** Real-time connection factory (WebSocket & SSE) */
682
+ declare class IMRealtimeClient {
683
+ private _wsBase;
684
+ constructor(_wsBase: string);
685
+ /** Get the WebSocket URL */
686
+ wsUrl(token?: string): string;
687
+ /** Get the SSE URL */
688
+ sseUrl(token?: string): string;
689
+ /** Create a WebSocket client. Call .connect() to establish connection. */
690
+ connectWS(config: RealtimeConfig): RealtimeWSClient;
691
+ /** Create an SSE client. Call .connect() to establish connection. */
692
+ connectSSE(config: RealtimeConfig): RealtimeSSEClient;
693
+ }
694
+ declare class IMClient {
695
+ readonly account: AccountClient;
696
+ readonly direct: DirectClient;
697
+ readonly groups: GroupsClient;
698
+ readonly conversations: ConversationsClient;
699
+ readonly messages: MessagesClient;
700
+ readonly contacts: ContactsClient;
701
+ readonly bindings: BindingsClient;
702
+ readonly credits: CreditsClient;
703
+ readonly workspace: WorkspaceClient;
704
+ readonly realtime: IMRealtimeClient;
705
+ constructor(request: RequestFn, wsBase: string);
706
+ /** IM health check */
707
+ health(): Promise<IMResult<void>>;
708
+ }
709
+ declare class PrismerClient {
710
+ private readonly apiKey;
711
+ private readonly baseUrl;
712
+ private readonly timeout;
713
+ private readonly fetchFn;
714
+ private readonly imAgent?;
715
+ /** IM API sub-client */
716
+ readonly im: IMClient;
717
+ constructor(config: PrismerConfig);
718
+ private _request;
719
+ /** Load content from URL(s) or search query */
720
+ load(input: string | string[], options?: LoadOptions): Promise<LoadResult>;
721
+ /** Save content to Prismer cache */
722
+ save(options: SaveOptions | SaveBatchOptions): Promise<SaveResult>;
723
+ /** Batch save multiple items (max 50) */
724
+ saveBatch(items: SaveOptions[]): Promise<SaveResult>;
725
+ /** Parse a document (PDF, image) into structured content */
726
+ parse(options: ParseOptions): Promise<ParseResult>;
727
+ /** Convenience: parse a PDF by URL */
728
+ parsePdf(url: string, mode?: 'fast' | 'hires' | 'auto'): Promise<ParseResult>;
729
+ /** Check status of an async parse task */
730
+ parseStatus(taskId: string): Promise<ParseResult>;
731
+ /** Get result of a completed async parse task */
732
+ parseResult(taskId: string): Promise<ParseResult>;
733
+ /** Search for content (convenience wrapper around load with query mode) */
734
+ search(query: string, options?: {
735
+ topK?: number;
736
+ returnTopK?: number;
737
+ format?: 'hqcc' | 'raw' | 'both';
738
+ ranking?: 'cache_first' | 'relevance_first' | 'balanced';
739
+ }): Promise<LoadResult>;
740
+ }
741
+
742
+ declare function createClient(config: PrismerConfig): PrismerClient;
743
+
744
+ export { AccountClient, type AuthenticatedPayload, type BatchSummary, type BatchUrlCost, BindingsClient, ContactsClient, ConversationsClient, CreditsClient, DirectClient, type DisconnectedPayload, ENVIRONMENTS, type Environment, type ErrorPayload, GroupsClient, type IMAgentCard, type IMAutocompleteResult, type IMBinding, type IMBindingData, IMClient, type IMContact, type IMConversation, type IMConversationsOptions, type IMCreateBindingOptions, type IMCreateGroupOptions, type IMCreditsData, type IMDiscoverAgent, type IMDiscoverOptions, type IMGroupData, type IMGroupMember, type IMMeData, type IMMessage, type IMMessageData, type IMPaginationOptions, IMRealtimeClient, type IMRegisterData, type IMRegisterOptions, type IMResult, type IMRouting, type IMSendOptions, type IMTokenData, type IMTransaction, type IMUser, type IMWorkspaceData, type LoadOptions, type LoadResult, type LoadResultItem, type MessageNewPayload, MessagesClient, type ParseCost, type ParseCostBreakdown, type ParseDocument, type ParseDocumentImage, type ParseOptions, type ParseResult, type ParseUsage, type PongPayload, type PresenceChangedPayload, PrismerClient, type PrismerConfig, type QueryCost, type QuerySummary, type RankingFactors, type RealtimeCommand, type RealtimeConfig, type RealtimeEventMap, type RealtimeEventType, RealtimeSSEClient, type RealtimeState, RealtimeWSClient, type ReconnectingPayload, type RequestFn, type SaveBatchOptions, type SaveOptions, type SaveResult, type SingleUrlCost, type TypingIndicatorPayload, WorkspaceClient, createClient, PrismerClient as default };