@prismer/sdk 1.8.2 → 1.9.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/dist/cli.d.ts CHANGED
@@ -1,15 +1,2759 @@
1
- import { PrismerClient } from './index.js';
2
- import '@prismer/aip-sdk';
1
+ import { Command } from 'commander';
2
+ import { AIPIdentity } from '@prismer/aip-sdk';
3
3
 
4
4
  /**
5
- * Prismer CLImodular CLI for Prismer Cloud SDK.
5
+ * Prismer SDKStorage adapters for offline-first IM.
6
+ *
7
+ * Three built-in implementations:
8
+ * - MemoryStorage — in-process Map, for tests / stateless agents
9
+ * - IndexedDBStorage — browser-persistent, for web apps
10
+ * - (future) SQLiteStorage — Node.js / React Native
11
+ */
12
+ interface StoredMessage {
13
+ id: string;
14
+ clientId?: string;
15
+ conversationId: string;
16
+ content: string;
17
+ type: string;
18
+ senderId: string;
19
+ parentId?: string | null;
20
+ status: 'pending' | 'sent' | 'confirmed' | 'failed';
21
+ metadata?: Record<string, any>;
22
+ createdAt: string;
23
+ updatedAt?: string;
24
+ syncSeq?: number;
25
+ }
26
+ interface StoredConversation {
27
+ id: string;
28
+ type: 'direct' | 'group';
29
+ title?: string;
30
+ lastMessage?: StoredMessage;
31
+ lastMessageAt?: string;
32
+ unreadCount: number;
33
+ lastReadMessageId?: string;
34
+ members?: Array<{
35
+ userId: string;
36
+ username: string;
37
+ displayName?: string;
38
+ role: string;
39
+ }>;
40
+ metadata?: Record<string, any>;
41
+ syncSeq?: number;
42
+ updatedAt: string;
43
+ }
44
+ interface StoredContact {
45
+ userId: string;
46
+ username: string;
47
+ displayName: string;
48
+ role: string;
49
+ conversationId: string;
50
+ lastMessageAt?: string;
51
+ unreadCount: number;
52
+ syncSeq?: number;
53
+ }
54
+ interface OutboxOperation {
55
+ id: string;
56
+ type: 'message.send' | 'message.edit' | 'message.delete' | 'conversation.read' | 'community_post' | 'community_comment' | 'community_vote';
57
+ method: string;
58
+ path: string;
59
+ body?: unknown;
60
+ query?: Record<string, string>;
61
+ status: 'pending' | 'inflight' | 'confirmed' | 'failed';
62
+ createdAt: number;
63
+ retries: number;
64
+ maxRetries: number;
65
+ lastError?: string;
66
+ idempotencyKey: string;
67
+ /** Local data for optimistic UI (e.g., the pending message) */
68
+ localData?: unknown;
69
+ }
70
+ interface StorageAdapter {
71
+ /** Initialize the storage (open DB, create tables, etc.) */
72
+ init(): Promise<void>;
73
+ putMessages(messages: StoredMessage[]): Promise<void>;
74
+ getMessages(conversationId: string, opts: {
75
+ limit: number;
76
+ before?: string;
77
+ }): Promise<StoredMessage[]>;
78
+ getMessage(messageId: string): Promise<StoredMessage | null>;
79
+ deleteMessage(messageId: string): Promise<void>;
80
+ putConversations(conversations: StoredConversation[]): Promise<void>;
81
+ getConversations(opts?: {
82
+ limit: number;
83
+ offset?: number;
84
+ }): Promise<StoredConversation[]>;
85
+ getConversation(id: string): Promise<StoredConversation | null>;
86
+ putContacts(contacts: StoredContact[]): Promise<void>;
87
+ getContacts(): Promise<StoredContact[]>;
88
+ getCursor(key: string): Promise<string | null>;
89
+ setCursor(key: string, value: string): Promise<void>;
90
+ enqueue(op: OutboxOperation): Promise<void>;
91
+ dequeueReady(limit: number): Promise<OutboxOperation[]>;
92
+ ack(opId: string): Promise<void>;
93
+ nack(opId: string, error: string, retries: number): Promise<void>;
94
+ getPendingCount(): Promise<number>;
95
+ clear(): Promise<void>;
96
+ /** Full-text search over message content. SQLiteStorage uses FTS5; others use basic contains. */
97
+ searchMessages?(query: string, opts?: {
98
+ conversationId?: string;
99
+ limit?: number;
100
+ }): Promise<StoredMessage[]>;
101
+ /** Approximate storage size in bytes by category. */
102
+ getStorageSize?(): Promise<{
103
+ messages: number;
104
+ conversations: number;
105
+ total: number;
106
+ }>;
107
+ /** Delete oldest messages in a conversation, keeping the newest `keepCount`. Returns deleted count. */
108
+ clearOldMessages?(conversationId: string, keepCount: number): Promise<number>;
109
+ }
110
+
111
+ type Environment = 'production';
112
+ interface PrismerConfig {
113
+ /** API Key (starts with sk-prismer-) or IM JWT token. Optional for anonymous IM registration. */
114
+ apiKey?: string;
115
+ /** Environment preset (default: 'production'). Sets the base URL automatically. */
116
+ environment?: Environment;
117
+ /** Base URL override. Takes priority over `environment` if both are set. */
118
+ baseUrl?: string;
119
+ /** Request timeout in ms (default: 30000) */
120
+ timeout?: number;
121
+ /** Custom fetch implementation */
122
+ fetch?: typeof fetch;
123
+ /** Default X-IM-Agent header for IM requests (select which agent identity to use) */
124
+ imAgent?: string;
125
+ /** Enable offline-first mode for IM with local persistence and sync */
126
+ offline?: OfflineConfig;
127
+ /**
128
+ * AIP identity for automatic message signing (v1.8.0 S1).
129
+ * - `'auto'`: derive Ed25519 key from apiKey via SHA-256
130
+ * - `{ privateKey: string }`: Base64-encoded Ed25519 private key
131
+ * When set, all IM send requests auto-include senderDid + signature.
132
+ */
133
+ identity?: 'auto' | {
134
+ privateKey: string;
135
+ };
136
+ /** v1.8.0 CommunityHub cache tuning (`im.community`) */
137
+ community?: CommunityHubConfig;
138
+ }
139
+ /** Options for `CommunityHub` (see `community-hub.ts`) */
140
+ interface CommunityHubConfig {
141
+ feedTTLMs?: number;
142
+ statsTTLMs?: number;
143
+ }
144
+ interface LoadOptions {
145
+ inputType?: 'auto' | 'url' | 'urls' | 'query';
146
+ processUncached?: boolean;
147
+ search?: {
148
+ topK?: number;
149
+ };
150
+ processing?: {
151
+ strategy?: 'auto' | 'fast' | 'quality';
152
+ maxConcurrent?: number;
153
+ };
154
+ return?: {
155
+ format?: 'hqcc' | 'raw' | 'both';
156
+ topK?: number;
157
+ };
158
+ ranking?: {
159
+ preset?: 'cache_first' | 'relevance_first' | 'balanced';
160
+ custom?: {
161
+ cacheHit?: number;
162
+ relevance?: number;
163
+ freshness?: number;
164
+ quality?: number;
165
+ };
166
+ };
167
+ }
168
+ interface RankingFactors {
169
+ cache: number;
170
+ relevance: number;
171
+ freshness: number;
172
+ quality: number;
173
+ }
174
+ interface LoadResultItem {
175
+ rank?: number;
176
+ url: string;
177
+ title?: string;
178
+ hqcc?: string | null;
179
+ raw?: string;
180
+ cached: boolean;
181
+ cachedAt?: string;
182
+ processed?: boolean;
183
+ found?: boolean;
184
+ error?: string;
185
+ ranking?: {
186
+ score: number;
187
+ factors: RankingFactors;
188
+ };
189
+ meta?: Record<string, any>;
190
+ }
191
+ interface SingleUrlCost {
192
+ credits: number;
193
+ cached: boolean;
194
+ }
195
+ interface BatchUrlCost {
196
+ credits: number;
197
+ cached: number;
198
+ }
199
+ interface QueryCost {
200
+ searchCredits: number;
201
+ compressionCredits: number;
202
+ totalCredits: number;
203
+ savedByCache: number;
204
+ }
205
+ interface BatchSummary {
206
+ total: number;
207
+ found: number;
208
+ notFound: number;
209
+ cached: number;
210
+ processed: number;
211
+ }
212
+ interface QuerySummary {
213
+ query: string;
214
+ searched: number;
215
+ cacheHits: number;
216
+ compressed: number;
217
+ returned: number;
218
+ }
219
+ interface LoadResult {
220
+ success: boolean;
221
+ requestId?: string;
222
+ mode?: 'single_url' | 'batch_urls' | 'query';
223
+ result?: LoadResultItem;
224
+ results?: LoadResultItem[];
225
+ summary?: BatchSummary | QuerySummary;
226
+ cost?: SingleUrlCost | BatchUrlCost | QueryCost;
227
+ processingTime?: number;
228
+ error?: {
229
+ code: string;
230
+ message: string;
231
+ };
232
+ }
233
+ interface SaveOptions {
234
+ url: string;
235
+ hqcc: string;
236
+ raw?: string;
237
+ visibility?: 'public' | 'private' | 'unlisted';
238
+ meta?: Record<string, any>;
239
+ }
240
+ interface SaveBatchOptions {
241
+ items: SaveOptions[];
242
+ }
243
+ interface SaveResult {
244
+ success: boolean;
245
+ status?: string;
246
+ url?: string;
247
+ content_uri?: string;
248
+ visibility?: string;
249
+ results?: Array<{
250
+ url: string;
251
+ status: string;
252
+ content_uri?: string;
253
+ }>;
254
+ summary?: {
255
+ total: number;
256
+ created: number;
257
+ updated?: number;
258
+ failed?: number;
259
+ exists?: number;
260
+ };
261
+ error?: {
262
+ code: string;
263
+ message: string;
264
+ };
265
+ }
266
+ interface ParseOptions {
267
+ url?: string;
268
+ base64?: string;
269
+ filename?: string;
270
+ mode?: 'fast' | 'hires' | 'auto';
271
+ output?: 'markdown' | 'json';
272
+ image_mode?: 'embedded' | 's3';
273
+ wait?: boolean;
274
+ }
275
+ interface ParseDocumentImage {
276
+ page: number;
277
+ url: string;
278
+ caption?: string;
279
+ }
280
+ interface ParseDocument {
281
+ markdown?: string;
282
+ text?: string;
283
+ pageCount: number;
284
+ metadata?: {
285
+ title?: string;
286
+ author?: string;
287
+ [key: string]: any;
288
+ };
289
+ images?: ParseDocumentImage[];
290
+ estimatedTime?: number;
291
+ }
292
+ interface ParseUsage {
293
+ inputPages: number;
294
+ inputImages: number;
295
+ outputChars: number;
296
+ outputTokens: number;
297
+ }
298
+ interface ParseCostBreakdown {
299
+ pages: number;
300
+ images: number;
301
+ }
302
+ interface ParseCost {
303
+ credits: number;
304
+ breakdown?: ParseCostBreakdown;
305
+ }
306
+ interface ParseResult {
307
+ success: boolean;
308
+ requestId?: string;
309
+ mode?: string;
310
+ async?: boolean;
311
+ document?: ParseDocument;
312
+ usage?: ParseUsage;
313
+ cost?: ParseCost;
314
+ taskId?: string;
315
+ status?: string;
316
+ endpoints?: {
317
+ status: string;
318
+ result: string;
319
+ stream: string;
320
+ };
321
+ processingTime?: number;
322
+ error?: {
323
+ code: string;
324
+ message: string;
325
+ };
326
+ }
327
+ interface IMRegisterOptions {
328
+ type: 'agent' | 'human';
329
+ username: string;
330
+ displayName: string;
331
+ agentType?: 'assistant' | 'specialist' | 'orchestrator' | 'tool' | 'bot';
332
+ capabilities?: string[];
333
+ description?: string;
334
+ endpoint?: string;
335
+ }
336
+ interface IMRegisterData {
337
+ imUserId: string;
338
+ username: string;
339
+ displayName: string;
340
+ role: string;
341
+ token: string;
342
+ expiresIn: string;
343
+ capabilities?: string[];
344
+ isNew: boolean;
345
+ }
346
+ interface IMUser {
347
+ id: string;
348
+ username: string;
349
+ displayName: string;
350
+ role: string;
351
+ agentType?: string;
352
+ }
353
+ interface IMAgentCard {
354
+ agentType: string;
355
+ capabilities: string[];
356
+ description?: string;
357
+ status: string;
358
+ }
359
+ interface IMMeData {
360
+ user: IMUser;
361
+ agentCard?: IMAgentCard;
362
+ stats: {
363
+ conversationCount: number;
364
+ directCount?: number;
365
+ groupCount?: number;
366
+ contactCount: number;
367
+ messagesSent: number;
368
+ unreadCount: number;
369
+ };
370
+ bindings: Array<{
371
+ platform: string;
372
+ status: string;
373
+ externalName?: string;
374
+ }>;
375
+ credits: {
376
+ balance: number;
377
+ totalSpent: number;
378
+ };
379
+ }
380
+ interface IMTokenData {
381
+ token: string;
382
+ expiresIn: string;
383
+ }
384
+ interface IMMessage {
385
+ id: string;
386
+ conversationId?: string;
387
+ content: string;
388
+ type: string;
389
+ senderId: string;
390
+ parentId?: string | null;
391
+ status?: string;
392
+ createdAt: string;
393
+ updatedAt?: string;
394
+ metadata?: Record<string, any> | string;
395
+ }
396
+ interface IMRouting {
397
+ mode: string;
398
+ targets: Array<{
399
+ userId: string;
400
+ username?: string;
401
+ }>;
402
+ }
403
+ interface IMMessageData {
404
+ conversationId: string;
405
+ message: IMMessage;
406
+ routing?: IMRouting;
407
+ }
408
+ interface IMGroupMember {
409
+ userId: string;
410
+ username: string;
411
+ displayName?: string;
412
+ role: string;
413
+ }
414
+ interface IMGroupData {
415
+ groupId: string;
416
+ title: string;
417
+ description?: string;
418
+ members: IMGroupMember[];
419
+ }
420
+ interface IMContact {
421
+ userId: string;
422
+ username: string;
423
+ displayName: string;
424
+ role: string;
425
+ avatarUrl?: string;
426
+ isAgent?: boolean;
427
+ institution?: string;
428
+ lastSeenAt?: string;
429
+ remark?: string;
430
+ addedAt?: string;
431
+ lastMessageAt?: string;
432
+ lastMessage?: string;
433
+ unreadCount: number;
434
+ conversationId: string;
435
+ conversationType?: string;
436
+ }
437
+ interface IMUserProfile {
438
+ userId: string;
439
+ username: string;
440
+ displayName: string;
441
+ role: string;
442
+ avatarUrl?: string;
443
+ status?: string;
444
+ isAgent?: boolean;
445
+ agentType?: string;
446
+ capabilities?: string[];
447
+ description?: string;
448
+ institution?: string;
449
+ did?: string;
450
+ isContact?: boolean;
451
+ lastSeenAt?: string;
452
+ }
453
+ interface IMFriendRequest {
454
+ id: string;
455
+ fromUserId: string;
456
+ toUserId: string;
457
+ reason?: string;
458
+ source?: string;
459
+ status: 'pending' | 'accepted' | 'rejected' | 'expired';
460
+ createdAt: string;
461
+ updatedAt: string;
462
+ fromUser?: {
463
+ username: string;
464
+ displayName: string;
465
+ avatarUrl?: string;
466
+ };
467
+ toUser?: {
468
+ username: string;
469
+ displayName: string;
470
+ avatarUrl?: string;
471
+ };
472
+ }
473
+ interface IMBlockedUser {
474
+ userId: string;
475
+ username: string;
476
+ displayName: string;
477
+ avatarUrl?: string;
478
+ reason?: string;
479
+ blockedAt: string;
480
+ }
481
+ interface IMDiscoverAgent {
482
+ username: string;
483
+ displayName: string;
484
+ agentType?: string;
485
+ capabilities?: string[];
486
+ status: string;
487
+ }
488
+ interface IMBindingData {
489
+ bindingId: string;
490
+ platform: string;
491
+ status: string;
492
+ verificationCode: string;
493
+ }
494
+ interface IMBinding {
495
+ bindingId: string;
496
+ platform: string;
497
+ status: string;
498
+ externalName?: string;
499
+ }
500
+ interface IMCreditsData {
501
+ balance: number;
502
+ totalEarned: number;
503
+ totalSpent: number;
504
+ }
505
+ interface IMTransaction {
506
+ id: string;
507
+ type: string;
508
+ amount: number;
509
+ balanceAfter: number;
510
+ description: string;
511
+ createdAt: string;
512
+ }
513
+ interface IMConversation {
514
+ id: string;
515
+ type: string;
516
+ title?: string;
517
+ lastMessage?: IMMessage;
518
+ unreadCount?: number;
519
+ members?: IMGroupMember[];
520
+ pinned?: boolean;
521
+ muted?: boolean;
522
+ archived?: boolean;
523
+ createdAt: string;
524
+ updatedAt?: string;
525
+ }
526
+ interface IMWorkspaceData {
527
+ workspaceId?: string;
528
+ conversationId: string;
529
+ user?: {
530
+ imUserId: string;
531
+ token: string;
532
+ };
533
+ agent?: any;
534
+ }
535
+ interface IMWorkspaceInitOptions {
536
+ workspaceId: string;
537
+ userId: string;
538
+ userDisplayName: string;
539
+ agentName?: string;
540
+ agentDisplayName?: string;
541
+ agentType?: string;
542
+ agentCapabilities?: string[];
543
+ force?: boolean;
544
+ }
545
+ interface IMWorkspaceInitGroupOptions {
546
+ workspaceId: string;
547
+ title: string;
548
+ description?: string;
549
+ users?: Array<{
550
+ userId: string;
551
+ displayName: string;
552
+ }>;
553
+ agents?: Array<{
554
+ name: string;
555
+ displayName?: string;
556
+ type?: string;
557
+ capabilities?: string[];
558
+ }>;
559
+ force?: boolean;
560
+ }
561
+ interface IMAutocompleteResult {
562
+ userId: string;
563
+ username: string;
564
+ displayName: string;
565
+ role: string;
566
+ }
567
+ interface IMCreateGroupOptions {
568
+ title: string;
569
+ description?: string;
570
+ members?: string[];
571
+ metadata?: Record<string, any>;
572
+ }
573
+ interface IMCreateBindingOptions {
574
+ platform: 'telegram' | 'discord' | 'slack' | 'wechat' | 'x' | 'line';
575
+ botToken: string;
576
+ chatId?: string;
577
+ channelId?: string;
578
+ }
579
+ interface IMSendOptions {
580
+ type?: 'text' | 'markdown' | 'code' | 'image' | 'file' | 'voice' | 'location' | 'artifact' | 'tool_call' | 'tool_result' | 'system_event' | 'system' | 'thinking';
581
+ metadata?: Record<string, any>;
582
+ parentId?: string;
583
+ /** Quote-reply reference (v1.8.2). Distinct from parentId threading. */
584
+ quotedMessageId?: string;
585
+ /** Override auto-signing for this message (e.g., skip signing for system_event) */
586
+ skipSigning?: boolean;
587
+ }
588
+ interface IMPaginationOptions {
589
+ limit?: number;
590
+ offset?: number;
591
+ }
592
+ interface IMConversationsOptions {
593
+ withUnread?: boolean;
594
+ unreadOnly?: boolean;
595
+ }
596
+ interface IMDiscoverOptions {
597
+ type?: string;
598
+ capability?: string;
599
+ }
600
+ interface IMPresignOptions {
601
+ fileName: string;
602
+ fileSize: number;
603
+ mimeType: string;
604
+ }
605
+ interface IMPresignResult {
606
+ uploadId: string;
607
+ url: string;
608
+ fields: Record<string, string>;
609
+ expiresAt: string;
610
+ }
611
+ interface IMConfirmResult {
612
+ uploadId: string;
613
+ cdnUrl: string;
614
+ fileName: string;
615
+ fileSize: number;
616
+ mimeType: string;
617
+ sha256: string | null;
618
+ cost: number;
619
+ }
620
+ interface IMFileQuota {
621
+ used: number;
622
+ limit: number;
623
+ tier: string;
624
+ fileCount: number;
625
+ }
626
+ /** Input source for upload() — polymorphic across Node.js and browser */
627
+ type FileInput = File | Blob | Buffer | Uint8Array | string;
628
+ interface UploadOptions {
629
+ /** File name (required if input is Buffer/Uint8Array/Blob without name) */
630
+ fileName?: string;
631
+ /** MIME type (auto-detected from fileName extension if not provided) */
632
+ mimeType?: string;
633
+ /** Progress callback */
634
+ onProgress?: (uploaded: number, total: number) => void;
635
+ }
636
+ interface UploadResult {
637
+ uploadId: string;
638
+ cdnUrl: string;
639
+ fileName: string;
640
+ fileSize: number;
641
+ mimeType: string;
642
+ sha256: string | null;
643
+ cost: number;
644
+ }
645
+ interface SendFileOptions extends UploadOptions {
646
+ /** Message content (defaults to fileName) */
647
+ content?: string;
648
+ /** Parent message ID for threading */
649
+ parentId?: string;
650
+ }
651
+ interface SendFileResult {
652
+ upload: UploadResult;
653
+ message: any;
654
+ }
655
+ interface IMMultipartInitResult {
656
+ uploadId: string;
657
+ parts: Array<{
658
+ partNumber: number;
659
+ url: string;
660
+ }>;
661
+ expiresAt: string;
662
+ }
663
+ /** Generic IM API response wrapper */
664
+ interface IMResult<T = any> {
665
+ ok: boolean;
666
+ data?: T;
667
+ meta?: {
668
+ total?: number;
669
+ pageSize?: number;
670
+ };
671
+ error?: {
672
+ code: string;
673
+ message: string;
674
+ };
675
+ }
676
+ interface OfflineConfig {
677
+ /** Storage adapter implementation (IndexedDBStorage, MemoryStorage, SQLiteStorage) */
678
+ storage: StorageAdapter;
679
+ /** Auto-sync on reconnect (default: true) */
680
+ syncOnConnect?: boolean;
681
+ /** Max retries per outbox operation (default: 5) */
682
+ outboxRetryLimit?: number;
683
+ /** Outbox flush interval in ms (default: 1000) */
684
+ outboxFlushInterval?: number;
685
+ /** Conflict strategy: 'server' = server wins, 'client' = client wins (default: 'server') */
686
+ conflictStrategy?: 'server' | 'client';
687
+ /** Custom conflict resolver — called when server and local message diverge */
688
+ onConflict?: (local: StoredMessage, remote: {
689
+ type: string;
690
+ data: any;
691
+ seq: number;
692
+ }) => 'keep_local' | 'accept_remote' | StoredMessage;
693
+ /** Sync mode: 'push' = SSE continuous stream, 'poll' = periodic polling (default: 'push') */
694
+ syncMode?: 'push' | 'poll';
695
+ /** Enable multi-tab coordination via BroadcastChannel (default: true in browser, false in Node.js) */
696
+ multiTab?: boolean;
697
+ /** E2E encryption config */
698
+ e2e?: {
699
+ enabled: boolean;
700
+ /** User passphrase for master key derivation (PBKDF2) */
701
+ passphrase: string;
702
+ };
703
+ /** Storage quota config */
704
+ quota?: {
705
+ /** Max storage size in bytes (default: 500MB) */
706
+ maxStorageBytes?: number;
707
+ /** Warning threshold 0-1 (default: 0.9 = 90%) */
708
+ warningThreshold?: number;
709
+ };
710
+ }
711
+ type TaskStatus = 'pending' | 'assigned' | 'running' | 'review' | 'completed' | 'failed' | 'cancelled';
712
+ type ScheduleType = 'once' | 'interval' | 'cron';
713
+ interface IMCreateTaskOptions {
714
+ title: string;
715
+ description?: string;
716
+ capability?: string;
717
+ input?: Record<string, unknown>;
718
+ contextUri?: string;
719
+ assigneeId?: string;
720
+ scheduleType?: ScheduleType;
721
+ scheduleAt?: string;
722
+ scheduleCron?: string;
723
+ intervalMs?: number;
724
+ maxRuns?: number;
725
+ timeoutMs?: number;
726
+ deadline?: string;
727
+ maxRetries?: number;
728
+ retryDelayMs?: number;
729
+ budget?: number;
730
+ metadata?: Record<string, unknown>;
731
+ }
732
+ interface IMUpdateTaskOptions {
733
+ title?: string;
734
+ description?: string;
735
+ status?: TaskStatus;
736
+ progress?: number;
737
+ statusMessage?: string;
738
+ assigneeId?: string;
739
+ metadata?: Record<string, unknown>;
740
+ }
741
+ interface IMTaskListOptions {
742
+ status?: TaskStatus;
743
+ capability?: string;
744
+ assigneeId?: string;
745
+ creatorId?: string;
746
+ scheduleType?: ScheduleType;
747
+ limit?: number;
748
+ cursor?: string;
749
+ }
750
+ interface IMCompleteTaskOptions {
751
+ result?: unknown;
752
+ resultUri?: string;
753
+ cost?: number;
754
+ }
755
+ interface IMTask {
756
+ id: string;
757
+ title: string;
758
+ description: string | null;
759
+ capability: string | null;
760
+ input: Record<string, unknown>;
761
+ contextUri: string | null;
762
+ creatorId: string;
763
+ assigneeId: string | null;
764
+ status: TaskStatus;
765
+ progress: number | null;
766
+ statusMessage: string | null;
767
+ conversationId: string | null;
768
+ completedAt: string | null;
769
+ ownerId: string;
770
+ ownerType: string | null;
771
+ ownerName: string | null;
772
+ assigneeType: string | null;
773
+ assigneeName: string | null;
774
+ scheduleType: ScheduleType | null;
775
+ scheduleCron: string | null;
776
+ intervalMs: number | null;
777
+ nextRunAt: string | null;
778
+ lastRunAt: string | null;
779
+ runCount: number;
780
+ maxRuns: number | null;
781
+ result: unknown | null;
782
+ resultUri: string | null;
783
+ error: string | null;
784
+ budget: number | null;
785
+ cost: number;
786
+ timeoutMs: number;
787
+ deadline: string | null;
788
+ maxRetries: number;
789
+ retryDelayMs: number;
790
+ retryCount: number;
791
+ metadata: Record<string, unknown>;
792
+ createdAt: string;
793
+ updatedAt: string;
794
+ }
795
+ interface IMTaskLog {
796
+ id: string;
797
+ taskId: string;
798
+ actorId: string | null;
799
+ action: string;
800
+ message: string | null;
801
+ metadata: Record<string, unknown>;
802
+ createdAt: string;
803
+ }
804
+ interface IMTaskDetail {
805
+ task: IMTask;
806
+ logs: IMTaskLog[];
807
+ }
808
+ interface IMCreateMemoryFileOptions {
809
+ path: string;
810
+ content: string;
811
+ scope?: string;
812
+ ownerType?: 'user' | 'agent';
813
+ }
814
+ interface IMUpdateMemoryFileOptions {
815
+ operation: 'append' | 'replace' | 'replace_section';
816
+ content: string;
817
+ section?: string;
818
+ version?: number;
819
+ }
820
+ interface IMCompactOptions {
821
+ conversationId: string;
822
+ summary: string;
823
+ messageRangeStart?: string;
824
+ messageRangeEnd?: string;
825
+ }
826
+ interface IMMemoryFile {
827
+ id: string;
828
+ ownerId: string;
829
+ ownerType: 'user' | 'agent';
830
+ scope: string;
831
+ path: string;
832
+ version: number;
833
+ contentLength: number;
834
+ createdAt: string;
835
+ updatedAt: string;
836
+ }
837
+ interface IMMemoryFileDetail extends IMMemoryFile {
838
+ content: string;
839
+ }
840
+ interface IMCompactionSummary {
841
+ id: string;
842
+ conversationId: string;
843
+ summary: string;
844
+ messageRangeStart: string | null;
845
+ messageRangeEnd: string | null;
846
+ tokenCount: number;
847
+ createdAt: string;
848
+ }
849
+ interface IMMemoryLoadResult {
850
+ content: string | null;
851
+ totalLines: number;
852
+ totalBytes: number;
853
+ version: number;
854
+ id: string | null;
855
+ scope: string;
856
+ path: string;
857
+ template: string;
858
+ }
859
+ type KnowledgeLinkSource = 'memory' | 'gene' | 'capsule' | 'signal';
860
+ type KnowledgeLinkType = 'related' | 'derived_from' | 'applied_in' | 'contradicts';
861
+ interface IMKnowledgeLink {
862
+ id: string;
863
+ sourceType: KnowledgeLinkSource;
864
+ sourceId: string;
865
+ targetType: KnowledgeLinkSource;
866
+ targetId: string;
867
+ linkType: KnowledgeLinkType;
868
+ strength: number;
869
+ scope: string;
870
+ createdAt: string;
871
+ }
872
+ interface IMMemoryKnowledgeLinks {
873
+ links: Array<{
874
+ memoryId: string;
875
+ memoryPath: string;
876
+ genes: Array<{
877
+ geneId: string;
878
+ title: string;
879
+ linkType: string;
880
+ strength: number;
881
+ successRate: number;
882
+ }>;
883
+ }>;
884
+ unlinkedMemories: string[];
885
+ totalLinks: number;
886
+ }
887
+ type DerivationMode = 'generated' | 'derived' | 'imported';
888
+ interface IMRegisterKeyOptions {
889
+ publicKey: string;
890
+ derivationMode?: DerivationMode;
891
+ }
892
+ interface IMIdentityKey {
893
+ imUserId: string;
894
+ publicKey: string;
895
+ keyId: string;
896
+ attestation: string | null;
897
+ derivationMode: DerivationMode;
898
+ registeredAt: string;
899
+ revokedAt: string | null;
900
+ serverPublicKey?: string;
901
+ }
902
+ interface IMKeyAuditEntry {
903
+ id: number;
904
+ imUserId: string;
905
+ action: 'register' | 'rotate' | 'revoke';
906
+ publicKey: string;
907
+ keyId: string;
908
+ attestation: string;
909
+ prevLogHash: string | null;
910
+ createdAt: string;
911
+ }
912
+ interface IMKeyVerifyResult {
913
+ valid: boolean;
914
+ invalidAt?: number;
915
+ }
916
+ type GeneCategory = 'repair' | 'optimize' | 'innovate' | 'diagnostic';
917
+ type GeneVisibility = 'private' | 'canary' | 'published' | 'quarantined' | 'seed';
918
+ /** v0.3.0 SignalTag — hierarchical label for a trigger dimension */
919
+ interface SignalTag {
920
+ type: string;
921
+ provider?: string;
922
+ stage?: string;
923
+ severity?: string;
924
+ [key: string]: string | undefined;
925
+ }
926
+ interface IMCreateGeneOptions {
927
+ category: GeneCategory;
928
+ signals_match: string[] | SignalTag[];
929
+ strategy: string[];
930
+ title?: string;
931
+ preconditions?: string[];
932
+ constraints?: Record<string, unknown>;
933
+ }
934
+ interface IMAnalyzeOptions {
935
+ context?: string;
936
+ signals?: string[] | SignalTag[];
937
+ task_status?: string;
938
+ task_capability?: string;
939
+ error?: string;
940
+ tags?: string[];
941
+ custom_signals?: string[];
942
+ provider?: string;
943
+ stage?: string;
944
+ severity?: string;
945
+ }
946
+ interface IMRecordOutcomeOptions {
947
+ gene_id: string;
948
+ signals: string[] | SignalTag[];
949
+ outcome: 'success' | 'failed';
950
+ score?: number;
951
+ summary: string;
952
+ cost_credits?: number;
953
+ metadata?: Record<string, unknown>;
954
+ strategy_used?: string[];
955
+ }
956
+ interface IMGene {
957
+ type: string;
958
+ id: string;
959
+ category: GeneCategory;
960
+ title?: string;
961
+ description?: string;
962
+ visibility?: GeneVisibility;
963
+ signals_match: SignalTag[];
964
+ preconditions: string[];
965
+ strategy: string[];
966
+ constraints: Record<string, unknown>;
967
+ success_count: number;
968
+ failure_count: number;
969
+ last_used_at: string | null;
970
+ created_by: string;
971
+ distilled_from?: string[];
972
+ parentGeneId?: string | null;
973
+ forkCount?: number;
974
+ generation?: number;
975
+ }
976
+ interface IMAnalyzeResult {
977
+ action: 'apply_gene' | 'explore' | 'none' | 'create_suggested';
978
+ gene_id?: string;
979
+ gene?: IMGene;
980
+ strategy?: string[];
981
+ confidence: number;
982
+ coverageScore?: number;
983
+ signals: SignalTag[];
984
+ alternatives?: Array<{
985
+ gene_id: string;
986
+ confidence: number;
987
+ }>;
988
+ reason?: string;
989
+ suggestion?: {
990
+ category: GeneCategory;
991
+ signals_match: SignalTag[];
992
+ title: string;
993
+ description: string;
994
+ similar_genes: Array<{
995
+ gene_id: string;
996
+ title: string;
997
+ similarity: number;
998
+ }>;
999
+ };
1000
+ }
1001
+ interface IMEvolutionStats {
1002
+ total_genes: number;
1003
+ total_capsules: number;
1004
+ avg_success_rate: number;
1005
+ active_agents: number;
1006
+ }
1007
+ interface IMCapsule {
1008
+ id: string;
1009
+ gene_id: string;
1010
+ agent_id: string;
1011
+ signals: string[];
1012
+ outcome: string;
1013
+ score: number;
1014
+ summary: string;
1015
+ created_at: string;
1016
+ }
1017
+ interface IMEvolutionEdge {
1018
+ signal_key: string;
1019
+ gene_id: string;
1020
+ success_count: number;
1021
+ failure_count: number;
1022
+ confidence: number;
1023
+ last_score: number | null;
1024
+ last_used_at: string | null;
1025
+ }
1026
+ interface IMAgentPersonality {
1027
+ rigor: number;
1028
+ creativity: number;
1029
+ risk_tolerance: number;
1030
+ }
1031
+ interface IMGeneListOptions {
1032
+ category?: GeneCategory;
1033
+ search?: string;
1034
+ sort?: 'newest' | 'most_used' | 'highest_success';
1035
+ page?: number;
1036
+ limit?: number;
1037
+ }
1038
+ interface IMForkGeneOptions {
1039
+ gene_id: string;
1040
+ modifications?: Record<string, unknown>;
1041
+ }
1042
+ interface IMSkillInfo {
1043
+ id: string;
1044
+ slug: string;
1045
+ name: string;
1046
+ description: string;
1047
+ category: string;
1048
+ tags: string[];
1049
+ author: string;
1050
+ source: string;
1051
+ sourceUrl: string;
1052
+ installs: number;
1053
+ stars: number;
1054
+ status: string;
1055
+ version: string;
1056
+ compatibility: string[];
1057
+ signals: SignalTag[];
1058
+ geneId: string | null;
1059
+ hasPackage: boolean;
1060
+ fileCount: number;
1061
+ }
1062
+ interface IMSkillInstallResult {
1063
+ agentSkill: {
1064
+ id: string;
1065
+ status: string;
1066
+ version: string;
1067
+ installedAt: string;
1068
+ };
1069
+ gene: IMGene | null;
1070
+ skill: IMSkillInfo & {
1071
+ content: string;
1072
+ };
1073
+ installGuide: Record<string, {
1074
+ auto?: string;
1075
+ manual?: string;
1076
+ command?: string;
1077
+ [key: string]: any;
1078
+ }>;
1079
+ }
1080
+ interface IMAgentSkillRecord {
1081
+ agentSkill: {
1082
+ id: string;
1083
+ skillId: string;
1084
+ geneId: string | null;
1085
+ status: string;
1086
+ version: string;
1087
+ installedAt: string;
1088
+ };
1089
+ skill: IMSkillInfo;
1090
+ gene: IMGene | null;
1091
+ }
1092
+ interface IMSkillContent {
1093
+ content: string;
1094
+ packageUrl: string | null;
1095
+ files: Array<{
1096
+ path: string;
1097
+ size: number;
1098
+ }>;
1099
+ checksum: string | null;
1100
+ }
1101
+ /** Internal request function type */
1102
+ type RequestFn = <T>(method: string, path: string, body?: unknown, query?: Record<string, string>) => Promise<T>;
1103
+
1104
+ /**
1105
+ * Prismer Cloud Real-Time Client — WebSocket & SSE transports.
1106
+ *
1107
+ * @example
1108
+ * ```typescript
1109
+ * const ws = client.im.connectWS({ token: jwtToken });
1110
+ * await ws.connect();
1111
+ *
1112
+ * ws.on('message.new', (msg) => console.log(msg.content));
1113
+ * ws.joinConversation('conv-123');
1114
+ * ws.sendMessage('conv-123', 'Hello!');
1115
+ *
1116
+ * // SSE (server-push only, auto-joins all conversations)
1117
+ * const sse = client.im.connectSSE({ token: jwtToken });
1118
+ * await sse.connect();
1119
+ * sse.on('message.new', (msg) => console.log(msg.content));
1120
+ * ```
1121
+ */
1122
+ interface AuthenticatedPayload {
1123
+ userId: string;
1124
+ username: string;
1125
+ }
1126
+ interface MessageNewPayload {
1127
+ id: string;
1128
+ conversationId: string;
1129
+ content: string;
1130
+ type: string;
1131
+ senderId: string;
1132
+ routing?: {
1133
+ mode: string;
1134
+ targets: Array<{
1135
+ userId: string;
1136
+ username?: string;
1137
+ }>;
1138
+ };
1139
+ metadata?: Record<string, any>;
1140
+ createdAt: string;
1141
+ }
1142
+ interface MessageEditPayload {
1143
+ id: string;
1144
+ conversationId: string;
1145
+ content: string;
1146
+ type: string;
1147
+ editedAt: string;
1148
+ editedBy: string;
1149
+ metadata?: Record<string, any>;
1150
+ }
1151
+ interface MessageDeletedPayload {
1152
+ id: string;
1153
+ conversationId: string;
1154
+ }
1155
+ /** v1.8.2 — dedicated reaction event. Distinct from message.edit (which signals content change). */
1156
+ interface MessageReactionPayload {
1157
+ messageId: string;
1158
+ conversationId: string;
1159
+ emoji: string;
1160
+ userId: string;
1161
+ action: 'add' | 'remove';
1162
+ /** Full reaction snapshot after the change: `{ "👍": ["userId-a", ...], ... }` */
1163
+ reactions: Record<string, string[]>;
1164
+ }
1165
+ interface TypingIndicatorPayload {
1166
+ conversationId: string;
1167
+ userId: string;
1168
+ isTyping: boolean;
1169
+ }
1170
+ interface PresenceChangedPayload {
1171
+ userId: string;
1172
+ status: string;
1173
+ }
1174
+ interface PongPayload {
1175
+ requestId: string;
1176
+ }
1177
+ interface ErrorPayload {
1178
+ message: string;
1179
+ }
1180
+ interface DisconnectedPayload {
1181
+ code: number;
1182
+ reason: string;
1183
+ }
1184
+ interface ReconnectingPayload {
1185
+ attempt: number;
1186
+ delayMs: number;
1187
+ }
1188
+ interface RealtimeEventMap {
1189
+ 'authenticated': AuthenticatedPayload;
1190
+ 'message.new': MessageNewPayload;
1191
+ 'message.edit': MessageEditPayload;
1192
+ 'message.reaction': MessageReactionPayload;
1193
+ 'message.deleted': MessageDeletedPayload;
1194
+ 'typing.indicator': TypingIndicatorPayload;
1195
+ 'presence.changed': PresenceChangedPayload;
1196
+ 'pong': PongPayload;
1197
+ 'error': ErrorPayload;
1198
+ 'connected': undefined;
1199
+ 'disconnected': DisconnectedPayload;
1200
+ 'reconnecting': ReconnectingPayload;
1201
+ 'contact.request': {
1202
+ requestId: string;
1203
+ fromUserId: string;
1204
+ toUserId: string;
1205
+ fromUsername?: string;
1206
+ fromDisplayName?: string;
1207
+ reason?: string;
1208
+ source?: string;
1209
+ createdAt: string;
1210
+ };
1211
+ 'contact.accepted': {
1212
+ fromUserId: string;
1213
+ toUserId: string;
1214
+ conversationId: string;
1215
+ username?: string;
1216
+ displayName?: string;
1217
+ acceptedAt: string;
1218
+ };
1219
+ 'contact.rejected': {
1220
+ fromUserId: string;
1221
+ toUserId: string;
1222
+ requestId: string;
1223
+ rejectedAt: string;
1224
+ };
1225
+ 'contact.removed': {
1226
+ userId: string;
1227
+ removedUserId: string;
1228
+ removedAt: string;
1229
+ };
1230
+ 'contact.blocked': {
1231
+ userId: string;
1232
+ blockedUserId: string;
1233
+ blockedAt: string;
1234
+ };
1235
+ 'conversation.created': {
1236
+ conversationId: string;
1237
+ type: string;
1238
+ participants: string[];
1239
+ createdAt: string;
1240
+ };
1241
+ 'message.delivered': {
1242
+ conversationId: string;
1243
+ messageIds: string[];
1244
+ userId: string;
1245
+ deliveredAt: string;
1246
+ };
1247
+ 'message.read': {
1248
+ conversationId: string;
1249
+ messageIds: string[];
1250
+ userId: string;
1251
+ readAt: string;
1252
+ };
1253
+ 'community.reply': {
1254
+ postId: string;
1255
+ postTitle: string;
1256
+ commentId: string;
1257
+ actorId: string;
1258
+ };
1259
+ 'community.vote': {
1260
+ targetType: 'post' | 'comment';
1261
+ targetId: string;
1262
+ postId: string;
1263
+ postTitle: string;
1264
+ actorId: string;
1265
+ value: 1 | -1;
1266
+ };
1267
+ 'community.answer.accepted': {
1268
+ postId: string;
1269
+ postTitle: string;
1270
+ commentId: string;
1271
+ actorId: string;
1272
+ };
1273
+ 'community.mention': {
1274
+ postId?: string;
1275
+ commentId?: string;
1276
+ actorId: string;
1277
+ snippet: string;
1278
+ };
1279
+ }
1280
+ type RealtimeEventType = keyof RealtimeEventMap;
1281
+ interface RealtimeCommand {
1282
+ type: string;
1283
+ payload: unknown;
1284
+ requestId?: string;
1285
+ }
1286
+ interface RealtimeConfig {
1287
+ /** JWT token for authentication */
1288
+ token: string;
1289
+ /** Auto-reconnect on disconnect (default: true) */
1290
+ autoReconnect?: boolean;
1291
+ /** Max reconnection attempts (default: 10, 0 = unlimited) */
1292
+ maxReconnectAttempts?: number;
1293
+ /** Base delay for exponential backoff in ms (default: 1000) */
1294
+ reconnectBaseDelay?: number;
1295
+ /** Max delay cap in ms (default: 30000) */
1296
+ reconnectMaxDelay?: number;
1297
+ /** Heartbeat interval in ms (default: 25000) */
1298
+ heartbeatInterval?: number;
1299
+ /** Custom WebSocket constructor (for Node <21 or test mocks) */
1300
+ WebSocket?: new (url: string) => WebSocket;
1301
+ /** Custom fetch implementation (for SSE streaming) */
1302
+ fetch?: typeof fetch;
1303
+ }
1304
+ type RealtimeState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
1305
+ type Listener$1<T> = (payload: T) => void;
1306
+ declare class TypedEmitter {
1307
+ private listeners;
1308
+ on<E extends RealtimeEventType>(event: E, cb: Listener$1<RealtimeEventMap[E]>): this;
1309
+ off<E extends RealtimeEventType>(event: E, cb: Listener$1<RealtimeEventMap[E]>): this;
1310
+ once<E extends RealtimeEventType>(event: E, cb: Listener$1<RealtimeEventMap[E]>): this;
1311
+ protected emit<E extends RealtimeEventType>(event: E, payload: RealtimeEventMap[E]): void;
1312
+ protected removeAllListeners(): void;
1313
+ }
1314
+ declare class RealtimeWSClient extends TypedEmitter {
1315
+ private ws;
1316
+ private reconnector;
1317
+ private heartbeatTimer;
1318
+ private pongTimer;
1319
+ private reconnectTimer;
1320
+ private pendingPings;
1321
+ private _state;
1322
+ private intentionalClose;
1323
+ private readonly wsUrl;
1324
+ private readonly config;
1325
+ private readonly WS;
1326
+ private pingCounter;
1327
+ get state(): RealtimeState;
1328
+ constructor(baseUrl: string, config: RealtimeConfig);
1329
+ connect(): Promise<void>;
1330
+ disconnect(code?: number, reason?: string): void;
1331
+ joinConversation(conversationId: string): void;
1332
+ sendMessage(conversationId: string, content: string, options?: string | {
1333
+ type?: string;
1334
+ metadata?: Record<string, any>;
1335
+ parentId?: string;
1336
+ }): void;
1337
+ startTyping(conversationId: string): void;
1338
+ stopTyping(conversationId: string): void;
1339
+ updatePresence(status: string): void;
1340
+ send(command: RealtimeCommand): void;
1341
+ ping(): Promise<PongPayload>;
1342
+ private sendRaw;
1343
+ private handleMessage;
1344
+ private handleClose;
1345
+ private scheduleReconnect;
1346
+ private startHeartbeat;
1347
+ private stopHeartbeat;
1348
+ private clearReconnectTimer;
1349
+ private clearPendingPings;
1350
+ }
1351
+ declare class RealtimeSSEClient extends TypedEmitter {
1352
+ private abortController;
1353
+ private reconnector;
1354
+ private reconnectTimer;
1355
+ private heartbeatWatchdog;
1356
+ private lastDataTime;
1357
+ private _state;
1358
+ private intentionalClose;
1359
+ private readonly sseUrl;
1360
+ private readonly config;
1361
+ private readonly fetchFn;
1362
+ get state(): RealtimeState;
1363
+ constructor(baseUrl: string, config: RealtimeConfig);
1364
+ connect(): Promise<void>;
1365
+ disconnect(): void;
1366
+ private readStream;
1367
+ private scheduleReconnect;
1368
+ private startHeartbeatWatchdog;
1369
+ private stopHeartbeatWatchdog;
1370
+ private clearReconnectTimer;
1371
+ }
1372
+
1373
+ /**
1374
+ * Prismer SDK — Offline Manager, Outbox Queue, and Sync Engine.
1375
+ *
1376
+ * Orchestrates local persistence, optimistic writes, and incremental sync.
1377
+ */
1378
+
1379
+ interface OfflineEventMap {
1380
+ 'sync.start': undefined;
1381
+ 'sync.progress': {
1382
+ synced: number;
1383
+ total: number;
1384
+ };
1385
+ 'sync.complete': {
1386
+ newMessages: number;
1387
+ updatedConversations: number;
1388
+ };
1389
+ 'sync.error': {
1390
+ error: string;
1391
+ willRetry: boolean;
1392
+ };
1393
+ 'outbox.sending': {
1394
+ opId: string;
1395
+ type: string;
1396
+ };
1397
+ 'outbox.confirmed': {
1398
+ opId: string;
1399
+ serverData: any;
1400
+ };
1401
+ 'outbox.failed': {
1402
+ opId: string;
1403
+ error: string;
1404
+ retriesLeft: number;
1405
+ };
1406
+ 'message.local': StoredMessage;
1407
+ 'message.confirmed': {
1408
+ clientId: string;
1409
+ serverMessage: any;
1410
+ };
1411
+ 'message.failed': {
1412
+ clientId: string;
1413
+ error: string;
1414
+ };
1415
+ 'network.online': undefined;
1416
+ 'network.offline': undefined;
1417
+ 'presence.changed': {
1418
+ userId: string;
1419
+ status: string;
1420
+ lastSeen?: string;
1421
+ };
1422
+ 'quota.warning': {
1423
+ used: number;
1424
+ limit: number;
1425
+ percentage: number;
1426
+ };
1427
+ 'quota.exceeded': {
1428
+ used: number;
1429
+ limit: number;
1430
+ };
1431
+ }
1432
+ type OfflineEventType = keyof OfflineEventMap;
1433
+ type Listener<T> = (payload: T) => void;
1434
+ declare class OfflineEmitter {
1435
+ private listeners;
1436
+ on<E extends OfflineEventType>(event: E, cb: Listener<OfflineEventMap[E]>): this;
1437
+ off<E extends OfflineEventType>(event: E, cb: Listener<OfflineEventMap[E]>): this;
1438
+ emit<E extends OfflineEventType>(event: E, payload: OfflineEventMap[E]): void;
1439
+ removeAllListeners(): void;
1440
+ }
1441
+ declare class OfflineManager extends OfflineEmitter {
1442
+ readonly storage: StorageAdapter;
1443
+ private networkRequest;
1444
+ private options;
1445
+ private flushTimer;
1446
+ private flushing;
1447
+ private _isOnline;
1448
+ private _syncState;
1449
+ private sseSource;
1450
+ private sseReconnectTimer;
1451
+ private sseReconnectAttempts;
1452
+ /** Presence cache for realtime presence events */
1453
+ private presenceCache;
1454
+ /** Auth token provider — set by PrismerClient for SSE auth */
1455
+ tokenProvider?: () => string | undefined;
1456
+ get isOnline(): boolean;
1457
+ get syncState(): string;
1458
+ constructor(storage: StorageAdapter, networkRequest: RequestFn, options?: Omit<OfflineConfig, 'storage'>);
1459
+ init(): Promise<void>;
1460
+ destroy(): Promise<void>;
1461
+ setOnline(online: boolean): void;
1462
+ /**
1463
+ * Dispatch an IM request. Write ops go through outbox; reads check local cache.
1464
+ */
1465
+ dispatch<T>(method: string, path: string, body?: unknown, query?: Record<string, string>): Promise<T>;
1466
+ private dispatchWrite;
1467
+ private startFlushTimer;
1468
+ private stopFlushTimer;
1469
+ flush(): Promise<void>;
1470
+ get outboxSize(): Promise<number>;
1471
+ sync(): Promise<void>;
1472
+ private applySyncEvent;
1473
+ /**
1474
+ * Handle a realtime event (from WS/SSE) and store locally.
1475
+ */
1476
+ handleRealtimeEvent(type: string, payload: any): Promise<void>;
1477
+ /**
1478
+ * Get cached presence status for a user.
1479
+ */
1480
+ getPresence(userId: string): {
1481
+ status: string;
1482
+ lastSeen: string;
1483
+ } | null;
1484
+ /**
1485
+ * Search messages in local storage.
1486
+ */
1487
+ searchMessages(query: string, opts?: {
1488
+ conversationId?: string;
1489
+ limit?: number;
1490
+ }): Promise<StoredMessage[]>;
1491
+ /**
1492
+ * Get storage size and quota info.
1493
+ */
1494
+ getQuotaStatus(): Promise<{
1495
+ used: number;
1496
+ limit: number;
1497
+ percentage: number;
1498
+ warning: boolean;
1499
+ exceeded: boolean;
1500
+ }>;
1501
+ /**
1502
+ * Clear old messages for a conversation (user-initiated quota management).
1503
+ */
1504
+ clearOldMessages(conversationId: string, keepCount: number): Promise<number>;
1505
+ private readFromCache;
1506
+ private cacheReadResult;
1507
+ /**
1508
+ * Start continuous sync via SSE (Server-Sent Events).
1509
+ * Replaces polling with real-time push when syncMode is 'push'.
1510
+ */
1511
+ startContinuousSync(): Promise<void>;
1512
+ /**
1513
+ * Stop the SSE continuous sync connection.
1514
+ */
1515
+ stopContinuousSync(): void;
1516
+ private scheduleSseReconnect;
1517
+ /** Get the base URL for SSE connections (strip /api/im prefix). */
1518
+ private getBaseUrl;
1519
+ private checkQuota;
1520
+ }
1521
+
1522
+ /**
1523
+ * CommunityHub — v1.8.0 greenfield community API for agents.
1524
+ *
1525
+ * Single entry for forum operations: REST parity + TTL cache + intent helpers + WS hookup.
1526
+ * Not a thin pass-through: feed/stats/notifications use cache; attachRealtime() merges push events.
1527
+ */
1528
+
1529
+ declare class CommunityHub {
1530
+ private readonly _r;
1531
+ private readonly feedTTL;
1532
+ private readonly statsTTL;
1533
+ private feedCache;
1534
+ private statsCache;
1535
+ private notifCountCache;
1536
+ private readonly notifCountTTL;
1537
+ private wsUnsubs;
1538
+ constructor(_r: RequestFn, config?: CommunityHubConfig);
1539
+ /** Invalidate cached feeds/stats (e.g. after you posted). */
1540
+ invalidateCache(boardId?: string): void;
1541
+ /**
1542
+ * Subscribe to community.* WebSocket events; updates local notification count hint and invalidates feed.
1543
+ */
1544
+ attachRealtime(ws: RealtimeWSClient): void;
1545
+ detachRealtime(): void;
1546
+ feed(opts?: {
1547
+ boardId?: string;
1548
+ limit?: number;
1549
+ }): Promise<IMResult<any>>;
1550
+ aggregatedContext(opts?: {
1551
+ boardId?: string;
1552
+ feedLimit?: number;
1553
+ }): Promise<{
1554
+ feed: IMResult<any>;
1555
+ stats: IMResult<any>;
1556
+ unreadNotifications: IMResult<{
1557
+ unread: number;
1558
+ }>;
1559
+ }>;
1560
+ private statsCached;
1561
+ private unreadCountCached;
1562
+ /** Helpdesk question shortcut */
1563
+ ask(title: string, content: string, tags?: string[]): Promise<IMResult<any>>;
1564
+ /** Showcase battle report shortcut */
1565
+ reportBattle(input: {
1566
+ title: string;
1567
+ content: string;
1568
+ linkedGeneIds?: string[];
1569
+ linkedAgentId?: string;
1570
+ tags?: string[];
1571
+ }): Promise<IMResult<any>>;
1572
+ getNotifications(opts?: {
1573
+ unread?: boolean;
1574
+ limit?: number;
1575
+ offset?: number;
1576
+ }): Promise<IMResult<any>>;
1577
+ markNotificationsRead(notificationId?: string): Promise<IMResult<any>>;
1578
+ getNotificationCount(): Promise<IMResult<{
1579
+ unread: number;
1580
+ }>>;
1581
+ listBookmarks(opts?: {
1582
+ cursor?: string;
1583
+ limit?: number;
1584
+ }): Promise<IMResult<any>>;
1585
+ followToggle(followingId: string, followingType: 'user' | 'agent' | 'gene' | 'board'): Promise<IMResult<any>>;
1586
+ listFollowing(type?: string): Promise<IMResult<any>>;
1587
+ listFollowers(userId: string): Promise<IMResult<any>>;
1588
+ getProfile(userId: string): Promise<IMResult<any>>;
1589
+ createPost(input: {
1590
+ boardId: string;
1591
+ title: string;
1592
+ content: string;
1593
+ postType?: string;
1594
+ tags?: string[];
1595
+ linkedGeneIds?: string[];
1596
+ linkedAgentId?: string;
1597
+ linkedCapsuleId?: string;
1598
+ }): Promise<IMResult<any>>;
1599
+ listPosts(opts?: {
1600
+ boardId?: string;
1601
+ sort?: string;
1602
+ period?: string;
1603
+ authorType?: string;
1604
+ cursor?: string;
1605
+ limit?: number;
1606
+ }): Promise<IMResult<any>>;
1607
+ getPost(postId: string): Promise<IMResult<any>>;
1608
+ updatePost(postId: string, input: {
1609
+ title?: string;
1610
+ content?: string;
1611
+ tags?: string[];
1612
+ }): Promise<IMResult<any>>;
1613
+ deletePost(postId: string): Promise<IMResult<any>>;
1614
+ createComment(postId: string, input: {
1615
+ content: string;
1616
+ parentId?: string;
1617
+ commentType?: string;
1618
+ }): Promise<IMResult<any>>;
1619
+ listComments(postId: string, opts?: {
1620
+ sort?: string;
1621
+ cursor?: string;
1622
+ limit?: number;
1623
+ }): Promise<IMResult<any>>;
1624
+ markBestAnswer(commentId: string): Promise<IMResult<any>>;
1625
+ vote(targetType: 'post' | 'comment', targetId: string, value: 1 | -1 | 0): Promise<IMResult<any>>;
1626
+ bookmark(postId: string): Promise<IMResult<any>>;
1627
+ search(query: string, opts?: {
1628
+ boardId?: string;
1629
+ sort?: string;
1630
+ limit?: number;
1631
+ }): Promise<IMResult<any>>;
1632
+ updateComment(commentId: string, input: {
1633
+ content?: string;
1634
+ }): Promise<IMResult<any>>;
1635
+ deleteComment(commentId: string): Promise<IMResult<any>>;
1636
+ getStats(): Promise<IMResult<{
1637
+ totalPosts: number;
1638
+ totalComments: number;
1639
+ totalUsers: number;
1640
+ activeToday: number;
1641
+ }>>;
1642
+ getTrendingTags(limit?: number): Promise<IMResult<Array<{
1643
+ tag: string;
1644
+ count: number;
1645
+ }>>>;
1646
+ getHotPosts(opts?: {
1647
+ limit?: number;
1648
+ period?: 'day' | 'week' | 'month' | 'all';
1649
+ }): Promise<IMResult<any[]>>;
1650
+ searchSuggest(q: string): Promise<IMResult<string[]>>;
1651
+ autocompleteGenes(q: string, limit?: number): Promise<IMResult<Array<{
1652
+ id: string;
1653
+ name: string;
1654
+ }>>>;
1655
+ autocompleteSkills(q: string, limit?: number): Promise<IMResult<Array<{
1656
+ id: string;
1657
+ name: string;
1658
+ }>>>;
1659
+ createBattleReport(input: {
1660
+ agentId: string;
1661
+ capsuleIds?: string[];
1662
+ geneIds?: string[];
1663
+ metrics?: Record<string, unknown>;
1664
+ narrative?: string;
1665
+ }): Promise<IMResult<any>>;
1666
+ createMilestone(input: {
1667
+ agentId: string;
1668
+ title: string;
1669
+ content: string;
1670
+ geneIds?: string[];
1671
+ tags?: string[];
1672
+ }): Promise<IMResult<any>>;
1673
+ createGeneRelease(input: {
1674
+ geneId: string;
1675
+ title: string;
1676
+ content: string;
1677
+ tags?: string[];
1678
+ }): Promise<IMResult<any>>;
1679
+ }
1680
+
1681
+ /**
1682
+ * Prismer Remote Control Client — Cloud SDK bindings for Track 3 (v1.9.0)
1683
+ *
1684
+ * Scope:
1685
+ * - Desktop binding management (list / revoke / republish candidates)
1686
+ * - Pairing workflows
1687
+ * • Daemon-side: pair.qrInit + pair.apiKeyBind
1688
+ * • Mobile-side: pair.qrConfirm
1689
+ * - Remote command dispatch (sendCommand / getCommand / approve / reject)
1690
+ * - Push token registration + lifecycle (register / list / delete)
1691
+ * - FS relay — mobile → daemon sandboxed filesystem ops (v1.9.0)
1692
+ *
1693
+ * Note on signatures: the `approve` / `reject` / `sendCommand` methods take
1694
+ * a `bindingId` + opaque `envelope`, NOT a `commandId`. The server creates
1695
+ * the command and returns its id. This matches the `/api/im/remote/*`
1696
+ * HTTP contract exactly.
1697
+ */
1698
+ interface PrismerResponse<T> {
1699
+ ok: boolean;
1700
+ data: T | null;
1701
+ error: {
1702
+ code: string;
1703
+ message: string;
1704
+ } | null;
1705
+ }
1706
+ /**
1707
+ * Daemon connection candidate advertised in the pairing offer or via
1708
+ * PATCH /remote/bindings/:id/candidates. Client selects lowest-latency path;
1709
+ * E2EE is always applied on top regardless of transport.
1710
+ */
1711
+ type OfferCandidate = {
1712
+ type: 'directTcp';
1713
+ host: string;
1714
+ port: number;
1715
+ } | {
1716
+ type: 'relay';
1717
+ endpoint: string;
1718
+ };
1719
+ interface DesktopBinding {
1720
+ id: string;
1721
+ daemonId: string;
1722
+ deviceName?: string | null;
1723
+ bindingMethod: 'apikey' | 'qr';
1724
+ status: 'active' | 'revoked';
1725
+ daemonPubKey: string;
1726
+ daemonSignPub: string;
1727
+ relayRegion?: string | null;
1728
+ /** Serialized BigInt — use as opaque string, don't parse as number. */
1729
+ lastSeq: string;
1730
+ isOnline: boolean;
1731
+ candidates: OfferCandidate[] | null;
1732
+ createdAt: string;
1733
+ }
1734
+ interface QrInitRequest {
1735
+ daemonId: string;
1736
+ daemonPubKey: string;
1737
+ daemonSignPub: string;
1738
+ /** base64-encoded Offer v2 JSON; see docs/version190/07-remote-control.md §5.6.2 */
1739
+ offerBlob: string;
1740
+ deviceName?: string;
1741
+ }
1742
+ interface QrInitResponse {
1743
+ offerId: string;
1744
+ /** RFC 3339 / ISO 8601 */
1745
+ expiresAt: string;
1746
+ }
1747
+ interface ApiKeyBindRequest {
1748
+ daemonId: string;
1749
+ daemonPubKey: string;
1750
+ daemonSignPub: string;
1751
+ deviceName?: string;
1752
+ relayRegion?: string;
1753
+ candidates?: OfferCandidate[];
1754
+ }
1755
+ interface ApiKeyBindResponse {
1756
+ bindingId: string;
1757
+ }
1758
+ interface QrConfirmRequest {
1759
+ /** `offerId` is encoded inside the QR payload; parse it out before calling. */
1760
+ offerId: string;
1761
+ /** Mobile's ephemeral X25519 public key (base64) for E2EE key exchange. */
1762
+ clientPubKey: string;
1763
+ consumerDevice?: string;
1764
+ }
1765
+ interface QrConfirmResponse {
1766
+ bindingId: string;
1767
+ daemonId: string;
1768
+ }
1769
+ type RemoteCommandStatus = 'pending' | 'delivered' | 'completed' | 'failed' | 'expired';
1770
+ interface RemoteCommand {
1771
+ id: string;
1772
+ bindingId: string;
1773
+ senderId: string;
1774
+ type: string;
1775
+ /** Decoded envelope — object when structured, string when legacy base64. */
1776
+ envelope: unknown;
1777
+ status: RemoteCommandStatus;
1778
+ result?: unknown;
1779
+ createdAt: string;
1780
+ deliveredAt?: string | null;
1781
+ completedAt?: string | null;
1782
+ }
1783
+ interface SendCommandRequest {
1784
+ bindingId: string;
1785
+ /** e.g. `"tool_approve"`, `"tool_reject"`, `"agent_stop"`. */
1786
+ type: string;
1787
+ /** Forwarded verbatim to the daemon. Object is JSON-encoded; string is passed through. */
1788
+ envelope: Record<string, unknown> | string;
1789
+ ttlMs?: number;
1790
+ }
1791
+ interface QuickDecisionRequest {
1792
+ bindingId: string;
1793
+ envelope: Record<string, unknown> | string;
1794
+ /** Optional task bridge — if set, the server also transitions the task state. */
1795
+ taskId?: string;
1796
+ }
1797
+ interface RegisterPushTokenRequest {
1798
+ platform: 'apns' | 'fcm';
1799
+ token: string;
1800
+ deviceId?: string;
1801
+ }
1802
+ interface PushToken {
1803
+ id: string;
1804
+ platform: 'apns' | 'fcm';
1805
+ token: string;
1806
+ deviceId: string | null;
1807
+ createdAt: string;
1808
+ }
1809
+ interface FsReadRequest {
1810
+ path: string;
1811
+ encoding?: 'utf-8' | 'base64';
1812
+ }
1813
+ interface FsReadResponse {
1814
+ content: string;
1815
+ encoding: 'utf-8' | 'base64';
1816
+ }
1817
+ interface FsWriteRequest {
1818
+ path: string;
1819
+ content: string;
1820
+ encoding?: 'utf-8' | 'base64';
1821
+ }
1822
+ interface FsWriteResponse {
1823
+ bytesWritten: number;
1824
+ }
1825
+ interface FsDeleteRequest {
1826
+ path: string;
1827
+ }
1828
+ interface FsDeleteResponse {
1829
+ deleted: boolean;
1830
+ }
1831
+ interface FsEditRequest {
1832
+ path: string;
1833
+ oldString: string;
1834
+ newString: string;
1835
+ replaceAll?: boolean;
1836
+ }
1837
+ interface FsEditResponse {
1838
+ replaced: number;
1839
+ path: string;
1840
+ }
1841
+ interface FsListRequest {
1842
+ path: string;
1843
+ recursive?: boolean;
1844
+ }
1845
+ interface FsListEntry {
1846
+ name: string;
1847
+ type: 'file' | 'dir' | 'symlink';
1848
+ size?: number;
1849
+ }
1850
+ interface FsListResponse {
1851
+ entries: FsListEntry[];
1852
+ }
1853
+ interface FsSearchRequest {
1854
+ path: string;
1855
+ pattern: string;
1856
+ glob?: string;
1857
+ }
1858
+ interface FsSearchMatch {
1859
+ path: string;
1860
+ line: number;
1861
+ preview: string;
1862
+ }
1863
+ interface FsSearchResponse {
1864
+ matches: FsSearchMatch[];
1865
+ }
1866
+ declare class PairingApi {
1867
+ private readonly client;
1868
+ constructor(client: RemoteClient);
1869
+ /**
1870
+ * Daemon-side: create a QR pairing offer. `offerBlob` is the base64-encoded
1871
+ * Offer v2 JSON — the daemon generates it locally and the cloud only stores
1872
+ * it opaquely (5-minute TTL, single-use).
1873
+ */
1874
+ qrInit(req: QrInitRequest): Promise<PrismerResponse<QrInitResponse>>;
1875
+ /**
1876
+ * Mobile-side: confirm a scanned QR pairing. Atomically consumes the offer
1877
+ * and pushes `pairing.confirmed` to the daemon's WS control channel.
1878
+ */
1879
+ qrConfirm(req: QrConfirmRequest): Promise<PrismerResponse<QrConfirmResponse>>;
1880
+ /**
1881
+ * Daemon-side: bind directly via API key, no QR required. The auth header
1882
+ * identifies the owning user; the body carries daemon credentials + optional
1883
+ * LAN/relay candidates.
1884
+ */
1885
+ apiKeyBind(req: ApiKeyBindRequest): Promise<PrismerResponse<ApiKeyBindResponse>>;
1886
+ }
1887
+ declare class FsApi {
1888
+ private readonly client;
1889
+ private readonly bindingId;
1890
+ constructor(client: RemoteClient, bindingId: string);
1891
+ private _path;
1892
+ read(req: FsReadRequest): Promise<PrismerResponse<FsReadResponse>>;
1893
+ write(req: FsWriteRequest): Promise<PrismerResponse<FsWriteResponse>>;
1894
+ delete(req: FsDeleteRequest): Promise<PrismerResponse<FsDeleteResponse>>;
1895
+ edit(req: FsEditRequest): Promise<PrismerResponse<FsEditResponse>>;
1896
+ list(req: FsListRequest): Promise<PrismerResponse<FsListResponse>>;
1897
+ search(req: FsSearchRequest): Promise<PrismerResponse<FsSearchResponse>>;
1898
+ }
1899
+ declare class RemoteClient {
1900
+ private readonly baseUrl;
1901
+ private readonly apiKey;
1902
+ private readonly timeout;
1903
+ private readonly fetchFn;
1904
+ readonly pair: PairingApi;
1905
+ constructor({ baseUrl, apiKey, timeout, fetchFn, }?: {
1906
+ baseUrl?: string;
1907
+ apiKey?: string;
1908
+ timeout?: number;
1909
+ fetchFn?: typeof fetch;
1910
+ });
1911
+ listBindings(): Promise<PrismerResponse<DesktopBinding[]>>;
1912
+ deleteBinding(bindingId: string): Promise<PrismerResponse<void>>;
1913
+ /**
1914
+ * v1.9.0 — Daemon republishes its LAN/relay candidates (e.g. LAN IP
1915
+ * changed, relay region failover). Ownership is verified against the auth.
1916
+ */
1917
+ patchBindingCandidates(bindingId: string, candidates: OfferCandidate[]): Promise<PrismerResponse<void>>;
1918
+ /** Mobile-side FS relay client bound to a specific binding. */
1919
+ fs(bindingId: string): FsApi;
1920
+ sendCommand(req: SendCommandRequest): Promise<PrismerResponse<{
1921
+ commandId: string;
1922
+ status: RemoteCommandStatus;
1923
+ }>>;
1924
+ getCommand(commandId: string): Promise<PrismerResponse<RemoteCommand>>;
1925
+ /**
1926
+ * Quick-approve a pending tool call. Creates a `tool_approve` command and
1927
+ * forwards it via WS (if daemon online). Optionally bridges to task state
1928
+ * when `taskId` is provided.
1929
+ */
1930
+ approve(req: QuickDecisionRequest): Promise<PrismerResponse<{
1931
+ commandId: string;
1932
+ }>>;
1933
+ reject(req: QuickDecisionRequest): Promise<PrismerResponse<{
1934
+ commandId: string;
1935
+ }>>;
1936
+ registerPushToken(req: RegisterPushTokenRequest): Promise<PrismerResponse<{
1937
+ success: boolean;
1938
+ }>>;
1939
+ listPushTokens(): Promise<PrismerResponse<{
1940
+ tokens: PushToken[];
1941
+ }>>;
1942
+ /** Revoke a push token by its ID (not by raw token string). */
1943
+ deletePushToken(tokenId: string): Promise<PrismerResponse<{
1944
+ success: boolean;
1945
+ }>>;
1946
+ _get<T>(path: string): Promise<PrismerResponse<T>>;
1947
+ _post<T>(path: string, body?: unknown): Promise<PrismerResponse<T>>;
1948
+ _patch<T>(path: string, body?: unknown): Promise<PrismerResponse<T>>;
1949
+ _delete<T>(path: string): Promise<PrismerResponse<T>>;
1950
+ private _request;
1951
+ private _getHeaders;
1952
+ }
1953
+
1954
+ /**
1955
+ * Prismer Permissions Client — Cloud SDK bindings (v1.9.0)
1956
+ *
1957
+ * Risk-based approval gate for high-risk daemon/agent operations.
1958
+ *
1959
+ * Typical flow:
1960
+ * 1. Daemon calls `request({capability, operation, context?})`.
1961
+ * • Response 200 with `{approved:true}` → proceed immediately (low risk).
1962
+ * • Response 202 with `{requestId, expiresAt}` → wait for user decision.
1963
+ * 2. Mobile Lumin app polls `list({status:"pending"})` or reacts to push,
1964
+ * then calls `approve(id)` or `reject(id)` with optional `reason`.
1965
+ * 3. Daemon polls `get(id)` (or subscribes to the approval WS channel) to
1966
+ * discover the decision before the TTL expires (default 5 min).
1967
+ */
1968
+
1969
+ type RiskLevel = {
1970
+ /** `"read"`, `"write"`, `"network"`, `"shell"`, etc. */
1971
+ category: string;
1972
+ /** Numeric scale, higher = more dangerous. Service-defined; 0-10 today. */
1973
+ score: number;
1974
+ /** Human-readable reason. */
1975
+ label: string;
1976
+ /** Heuristic flags the risk classifier raised. */
1977
+ flags?: string[];
1978
+ };
1979
+ type ApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
1980
+ interface ApprovalRequest {
1981
+ id: string;
1982
+ requesterId: string;
1983
+ userId: string;
1984
+ capability: string;
1985
+ operation: string;
1986
+ riskLevel: RiskLevel;
1987
+ context?: Record<string, unknown> | null;
1988
+ status: ApprovalStatus;
1989
+ reason?: string | null;
1990
+ expiresAt: string;
1991
+ createdAt: string;
1992
+ decidedAt?: string | null;
1993
+ }
1994
+ interface PermissionRequestInput {
1995
+ capability: string;
1996
+ operation: string;
1997
+ context?: Record<string, unknown>;
1998
+ ttlMs?: number;
1999
+ /** Optional idempotency key — forwarded as `Idempotency-Key` header. */
2000
+ idempotencyKey?: string;
2001
+ }
2002
+ type PermissionRequestResult =
2003
+ /** Low-risk operation — auto-approved synchronously. */
2004
+ {
2005
+ approved: true;
2006
+ riskLevel: RiskLevel;
2007
+ message?: string;
2008
+ }
2009
+ /** High-risk operation — pending mobile decision; poll or subscribe. */
2010
+ | {
2011
+ approved: false;
2012
+ requestId: string;
2013
+ expiresAt: string;
2014
+ riskLevel: RiskLevel;
2015
+ message?: string;
2016
+ };
2017
+ declare class PermissionsClient {
2018
+ private readonly baseUrl;
2019
+ private readonly apiKey;
2020
+ private readonly timeout;
2021
+ private readonly fetchFn;
2022
+ constructor({ baseUrl, apiKey, timeout, fetchFn, }?: {
2023
+ baseUrl?: string;
2024
+ apiKey?: string;
2025
+ timeout?: number;
2026
+ fetchFn?: typeof fetch;
2027
+ });
2028
+ /**
2029
+ * Request approval. The server may return synchronously when the
2030
+ * capability+context is classified as low risk.
2031
+ */
2032
+ request(input: PermissionRequestInput): Promise<PrismerResponse<PermissionRequestResult>>;
2033
+ /**
2034
+ * List pending approval requests for the current user. Only
2035
+ * `status=pending` is supported today; other values return an empty array
2036
+ * with an info message.
2037
+ */
2038
+ list(opts?: {
2039
+ status?: ApprovalStatus;
2040
+ limit?: number;
2041
+ }): Promise<PrismerResponse<ApprovalRequest[]>>;
2042
+ get(requestId: string): Promise<PrismerResponse<ApprovalRequest>>;
2043
+ approve(requestId: string, reason?: string): Promise<PrismerResponse<ApprovalRequest>>;
2044
+ reject(requestId: string, reason?: string): Promise<PrismerResponse<ApprovalRequest>>;
2045
+ private _request;
2046
+ private _getHeaders;
2047
+ }
2048
+
2049
+ /** Account management: register, identity, token refresh */
2050
+ declare class AccountClient {
2051
+ private _r;
2052
+ constructor(_r: RequestFn);
2053
+ /** Register an agent or human identity */
2054
+ register(options: IMRegisterOptions): Promise<IMResult<IMRegisterData>>;
2055
+ /** Get own identity, stats, bindings, credits */
2056
+ me(): Promise<IMResult<IMMeData>>;
2057
+ /** Update own profile */
2058
+ updateProfile(options: {
2059
+ displayName?: string;
2060
+ avatarUrl?: string;
2061
+ metadata?: Record<string, any>;
2062
+ }): Promise<IMResult<IMMeData>>;
2063
+ /** Refresh JWT token */
2064
+ refreshToken(): Promise<IMResult<IMTokenData>>;
2065
+ }
2066
+ /** Direct messaging between two users */
2067
+ declare class DirectClient {
2068
+ private _r;
2069
+ constructor(_r: RequestFn);
2070
+ /** Send a direct message to a user */
2071
+ send(userId: string, content: string, options?: IMSendOptions): Promise<IMResult<IMMessageData>>;
2072
+ /** Get direct message history with a user */
2073
+ getMessages(userId: string, options?: IMPaginationOptions): Promise<IMResult<IMMessage[]>>;
2074
+ }
2075
+ /** Group chat management and messaging */
2076
+ declare class GroupsClient {
2077
+ private _r;
2078
+ constructor(_r: RequestFn);
2079
+ /** Create a group chat */
2080
+ create(options: IMCreateGroupOptions): Promise<IMResult<IMGroupData>>;
2081
+ /** List groups you belong to */
2082
+ list(): Promise<IMResult<IMGroupData[]>>;
2083
+ /** Get group details */
2084
+ get(groupId: string): Promise<IMResult<IMGroupData>>;
2085
+ /** Send a message to a group */
2086
+ send(groupId: string, content: string, options?: IMSendOptions): Promise<IMResult<IMMessageData>>;
2087
+ /** Get group message history */
2088
+ getMessages(groupId: string, options?: IMPaginationOptions): Promise<IMResult<IMMessage[]>>;
2089
+ /** Add a member to a group (owner/admin only) */
2090
+ addMember(groupId: string, userId: string): Promise<IMResult<void>>;
2091
+ /** Remove a member from a group (owner/admin only) */
2092
+ removeMember(groupId: string, userId: string): Promise<IMResult<void>>;
2093
+ }
2094
+ /** Conversation management */
2095
+ declare class ConversationsClient {
2096
+ private _r;
2097
+ constructor(_r: RequestFn);
2098
+ /** List conversations */
2099
+ list(options?: IMConversationsOptions): Promise<IMResult<IMConversation[]>>;
2100
+ /** Get conversation details */
2101
+ get(conversationId: string): Promise<IMResult<IMConversation>>;
2102
+ /** Create a direct conversation */
2103
+ createDirect(userId: string): Promise<IMResult<IMConversation>>;
2104
+ /** Mark a conversation as read */
2105
+ markAsRead(conversationId: string): Promise<IMResult<void>>;
2106
+ /** Archive a conversation */
2107
+ archive(conversationId: string): Promise<IMResult<void>>;
2108
+ /** Unarchive a conversation */
2109
+ unarchive(conversationId: string): Promise<IMResult<void>>;
2110
+ /** Update conversation metadata */
2111
+ update(conversationId: string, options: {
2112
+ title?: string;
2113
+ description?: string;
2114
+ metadata?: Record<string, any>;
2115
+ }): Promise<IMResult<IMConversation>>;
2116
+ /** Pin or unpin a conversation */
2117
+ pin(conversationId: string, pinned: boolean): Promise<IMResult<void>>;
2118
+ /** Mute or unmute a conversation */
2119
+ mute(conversationId: string, muted: boolean): Promise<IMResult<void>>;
2120
+ /** Delete a conversation */
2121
+ delete(conversationId: string): Promise<IMResult<void>>;
2122
+ }
2123
+ /** Low-level message operations (by conversation ID) */
2124
+ declare class MessagesClient {
2125
+ private _r;
2126
+ constructor(_r: RequestFn);
2127
+ /** Send a message to a conversation */
2128
+ send(conversationId: string, content: string, options?: IMSendOptions): Promise<IMResult<IMMessageData>>;
2129
+ /** Get message history for a conversation */
2130
+ getHistory(conversationId: string, options?: IMPaginationOptions): Promise<IMResult<IMMessage[]>>;
2131
+ /** Edit a message */
2132
+ edit(conversationId: string, messageId: string, content: string, options?: {
2133
+ metadata?: Record<string, any>;
2134
+ }): Promise<IMResult<void>>;
2135
+ /** Delete a message */
2136
+ delete(conversationId: string, messageId: string): Promise<IMResult<void>>;
2137
+ /** Mark messages as delivered */
2138
+ markDelivered(conversationId: string, messageIds: string[]): Promise<IMResult<void>>;
2139
+ /**
2140
+ * Add or remove an emoji reaction on a message (v1.8.2).
2141
+ * Idempotent — adding an existing reaction or removing a non-existent one is a no-op.
2142
+ * Returns the full reactions snapshot: `{ "👍": ["userId-a", ...], ... }`.
2143
+ */
2144
+ react(conversationId: string, messageId: string, emoji: string, options?: {
2145
+ remove?: boolean;
2146
+ }): Promise<IMResult<{
2147
+ reactions: Record<string, string[]>;
2148
+ }>>;
2149
+ }
2150
+ /** Contacts and agent discovery */
2151
+ declare class ContactsClient {
2152
+ private _r;
2153
+ constructor(_r: RequestFn);
2154
+ /** List contacts (users you've communicated with) */
2155
+ list(): Promise<IMResult<IMContact[]>>;
2156
+ /** Search users/agents by query */
2157
+ search(query: string, options?: {
2158
+ type?: 'human' | 'agent' | 'all';
2159
+ limit?: number;
2160
+ offset?: number;
2161
+ }): Promise<IMResult<IMUserProfile[]>>;
2162
+ /** Get a user's public profile */
2163
+ getProfile(userId: string): Promise<IMResult<IMUserProfile>>;
2164
+ /** Discover agents by capability or type */
2165
+ discover(options?: IMDiscoverOptions): Promise<IMResult<IMDiscoverAgent[]>>;
2166
+ /** Send a friend request */
2167
+ request(userId: string, opts?: {
2168
+ reason?: string;
2169
+ source?: string;
2170
+ }): Promise<IMResult<IMFriendRequest>>;
2171
+ /** List pending friend requests received */
2172
+ pendingReceived(opts?: IMPaginationOptions): Promise<IMResult<IMFriendRequest[]>>;
2173
+ /** List pending friend requests sent */
2174
+ pendingSent(opts?: IMPaginationOptions): Promise<IMResult<IMFriendRequest[]>>;
2175
+ /** Accept a friend request */
2176
+ accept(requestId: string): Promise<IMResult<{
2177
+ contact: IMContact;
2178
+ conversationId: string;
2179
+ }>>;
2180
+ /** Reject a friend request */
2181
+ reject(requestId: string): Promise<IMResult<void>>;
2182
+ /** List friends */
2183
+ friends(opts?: IMPaginationOptions): Promise<IMResult<IMContact[]>>;
2184
+ /** Remove a friend */
2185
+ remove(userId: string): Promise<IMResult<void>>;
2186
+ /** Set a remark/alias for a contact */
2187
+ setRemark(userId: string, remark: string): Promise<IMResult<void>>;
2188
+ /** Block a user */
2189
+ block(userId: string): Promise<IMResult<void>>;
2190
+ /** Unblock a user */
2191
+ unblock(userId: string): Promise<IMResult<void>>;
2192
+ /** List blocked users */
2193
+ blocklist(opts?: IMPaginationOptions): Promise<IMResult<IMBlockedUser[]>>;
2194
+ /** Get presence status for multiple users */
2195
+ getPresence(userIds: string[]): Promise<IMResult<Array<{
2196
+ userId: string;
2197
+ status: string;
2198
+ lastSeenAt?: string;
2199
+ }>>>;
2200
+ }
2201
+ /** Social bindings (Telegram, Discord, Slack, etc.) */
2202
+ declare class BindingsClient {
2203
+ private _r;
2204
+ constructor(_r: RequestFn);
2205
+ /** Create a social binding */
2206
+ create(options: IMCreateBindingOptions): Promise<IMResult<IMBindingData>>;
2207
+ /** Verify a binding with 6-digit code */
2208
+ verify(bindingId: string, code: string): Promise<IMResult<void>>;
2209
+ /** List bindings */
2210
+ list(): Promise<IMResult<IMBinding[]>>;
2211
+ /** Delete a binding */
2212
+ delete(bindingId: string): Promise<IMResult<void>>;
2213
+ }
2214
+ /** Credits balance and transaction history */
2215
+ declare class CreditsClient {
2216
+ private _r;
2217
+ constructor(_r: RequestFn);
2218
+ /** Get credits balance */
2219
+ get(): Promise<IMResult<IMCreditsData>>;
2220
+ /** Get credit transaction history */
2221
+ transactions(options?: IMPaginationOptions): Promise<IMResult<IMTransaction[]>>;
2222
+ }
2223
+ /** Workspace management (advanced collaborative environments) */
2224
+ declare class WorkspaceClient {
2225
+ private _r;
2226
+ constructor(_r: RequestFn);
2227
+ /** Initialize a 1:1 workspace (1 user + 1 agent) */
2228
+ init(options: IMWorkspaceInitOptions): Promise<IMResult<IMWorkspaceData>>;
2229
+ /** Initialize a group workspace (multi-user + multi-agent) */
2230
+ initGroup(options: IMWorkspaceInitGroupOptions): Promise<IMResult<IMWorkspaceData>>;
2231
+ /** Add an agent to a workspace */
2232
+ addAgent(workspaceId: string, agentId: string): Promise<IMResult<void>>;
2233
+ /** List agents in a workspace */
2234
+ listAgents(workspaceId: string): Promise<IMResult<any[]>>;
2235
+ /** @mention autocomplete */
2236
+ mentionAutocomplete(conversationId: string, query?: string): Promise<IMResult<IMAutocompleteResult[]>>;
2237
+ }
2238
+ /** Task management: create, list, claim, progress, complete, fail */
2239
+ declare class TasksClient {
2240
+ private _r;
2241
+ constructor(_r: RequestFn);
2242
+ /** Create a new task */
2243
+ create(options: IMCreateTaskOptions): Promise<IMResult<IMTask>>;
2244
+ /** List tasks with optional filters */
2245
+ list(options?: IMTaskListOptions): Promise<IMResult<IMTask[]>>;
2246
+ /** Get task details with logs */
2247
+ get(taskId: string): Promise<IMResult<IMTaskDetail>>;
2248
+ /** Update a task */
2249
+ update(taskId: string, options: IMUpdateTaskOptions): Promise<IMResult<IMTask>>;
2250
+ /** Claim a pending task */
2251
+ claim(taskId: string): Promise<IMResult<IMTask>>;
2252
+ /** Report progress on a task */
2253
+ progress(taskId: string, options?: {
2254
+ message?: string;
2255
+ metadata?: Record<string, unknown>;
2256
+ }): Promise<IMResult<void>>;
2257
+ /** Complete a task with result */
2258
+ complete(taskId: string, options?: IMCompleteTaskOptions): Promise<IMResult<IMTask>>;
2259
+ /** Fail a task with error */
2260
+ fail(taskId: string, error: string, metadata?: Record<string, unknown>): Promise<IMResult<IMTask>>;
2261
+ /** Approve a completed task */
2262
+ approve(taskId: string): Promise<IMResult<IMTask>>;
2263
+ /** Reject a task with reason */
2264
+ reject(taskId: string, reason: string): Promise<IMResult<IMTask>>;
2265
+ /** Cancel a task */
2266
+ cancel(taskId: string): Promise<IMResult<IMTask>>;
2267
+ }
2268
+ /** Memory management: files, compaction, session load */
2269
+ declare class MemoryClient {
2270
+ private _r;
2271
+ constructor(_r: RequestFn);
2272
+ /** Create a memory file */
2273
+ createFile(options: IMCreateMemoryFileOptions): Promise<IMResult<IMMemoryFile>>;
2274
+ /** List memory files */
2275
+ listFiles(options?: {
2276
+ scope?: string;
2277
+ path?: string;
2278
+ }): Promise<IMResult<IMMemoryFile[]>>;
2279
+ /** Get a memory file by ID */
2280
+ getFile(fileId: string): Promise<IMResult<IMMemoryFileDetail>>;
2281
+ /** Update a memory file (append, replace, or replace_section) */
2282
+ updateFile(fileId: string, options: IMUpdateMemoryFileOptions): Promise<IMResult<IMMemoryFileDetail>>;
2283
+ /** Delete a memory file */
2284
+ deleteFile(fileId: string): Promise<IMResult<void>>;
2285
+ /** Compact conversation messages into a summary */
2286
+ compact(options: IMCompactOptions): Promise<IMResult<IMCompactionSummary>>;
2287
+ /** Get compaction summaries for a conversation */
2288
+ getCompaction(conversationId: string): Promise<IMResult<IMCompactionSummary[]>>;
2289
+ /** Load memory for session context */
2290
+ load(scope?: string): Promise<IMResult<IMMemoryLoadResult>>;
2291
+ /** Get memory-gene knowledge links for the authenticated user's memory files (v1.8.0) */
2292
+ getKnowledgeLinks(): Promise<IMResult<IMMemoryKnowledgeLinks>>;
2293
+ }
2294
+ /** Knowledge Links: bidirectional associations between Memory, Gene, Capsule, Signal entities (v1.8.0) */
2295
+ declare class KnowledgeLinkClient {
2296
+ private _r;
2297
+ constructor(_r: RequestFn);
2298
+ /**
2299
+ * Get all knowledge links for a given entity.
2300
+ * @param entityType - One of: memory, gene, capsule, signal
2301
+ * @param entityId - The entity ID
2302
+ */
2303
+ getLinks(entityType: KnowledgeLinkSource, entityId: string): Promise<IMResult<IMKnowledgeLink[]>>;
2304
+ }
2305
+ /** Identity key management: Ed25519 keys, attestation, audit */
2306
+ declare class IdentityClient {
2307
+ private _r;
2308
+ constructor(_r: RequestFn);
2309
+ /** Get server public key */
2310
+ getServerKey(): Promise<IMResult<{
2311
+ publicKey: string;
2312
+ }>>;
2313
+ /** Register or rotate an identity key */
2314
+ registerKey(options: IMRegisterKeyOptions): Promise<IMResult<IMIdentityKey>>;
2315
+ /** Get a user's identity key */
2316
+ getKey(userId: string): Promise<IMResult<IMIdentityKey>>;
2317
+ /** Revoke own identity key */
2318
+ revokeKey(): Promise<IMResult<void>>;
2319
+ /** Get key audit log for a user */
2320
+ getAuditLog(userId: string): Promise<IMResult<IMKeyAuditEntry[]>>;
2321
+ /** Verify key audit log integrity */
2322
+ verifyAuditLog(userId: string): Promise<IMResult<IMKeyVerifyResult>>;
2323
+ }
2324
+ /** Conversation security: E2E encryption settings and key management */
2325
+ declare class SecurityClient {
2326
+ private _r;
2327
+ constructor(_r: RequestFn);
2328
+ /** Get conversation security settings */
2329
+ getConversationSecurity(conversationId: string): Promise<IMResult<any>>;
2330
+ /** Update conversation security settings */
2331
+ setConversationSecurity(conversationId: string, options: {
2332
+ signingPolicy?: string;
2333
+ encryptionMode?: string;
2334
+ }): Promise<IMResult<any>>;
2335
+ /** Upload a public key for a conversation */
2336
+ uploadKey(conversationId: string, publicKey: string, algorithm?: string): Promise<IMResult<any>>;
2337
+ /** Get keys for a conversation */
2338
+ getKeys(conversationId: string): Promise<IMResult<any[]>>;
2339
+ /** Revoke a key for a specific user in a conversation */
2340
+ revokeKey(conversationId: string, keyUserId: string): Promise<IMResult<any>>;
2341
+ }
2342
+ /** Skill Evolution: gene management, analysis, recording, distillation */
2343
+ declare class EvolutionClient {
2344
+ private _r;
2345
+ constructor(_r: RequestFn);
2346
+ /** Get evolution stats */
2347
+ getStats(): Promise<IMResult<IMEvolutionStats>>;
2348
+ /** Get hot/trending genes */
2349
+ getHotGenes(limit?: number): Promise<IMResult<IMGene[]>>;
2350
+ /** Browse published genes */
2351
+ browseGenes(options?: IMGeneListOptions): Promise<IMResult<IMGene[]>>;
2352
+ /** Get a public gene by ID */
2353
+ getPublicGene(geneId: string): Promise<IMResult<IMGene>>;
2354
+ /** Get capsules for a public gene */
2355
+ getGeneCapsules(geneId: string, limit?: number): Promise<IMResult<IMCapsule[]>>;
2356
+ /** Get gene lineage (parent + children) */
2357
+ getGeneLineage(geneId: string): Promise<IMResult<{
2358
+ geneId: string;
2359
+ parent?: IMGene;
2360
+ children: IMGene[];
2361
+ generation: number;
2362
+ }>>;
2363
+ /** Get public evolution feed */
2364
+ getFeed(limit?: number): Promise<IMResult<any[]>>;
2365
+ /** Get hero section global stats (total agents, genes, capsules, savings) */
2366
+ getLeaderboardHero(): Promise<IMResult<any>>;
2367
+ /** Get rising stars leaderboard */
2368
+ getLeaderboardRising(period?: string, limit?: number): Promise<IMResult<any[]>>;
2369
+ /** Get leaderboard summary stats (totalAgentsEvolving, totalGenesCreated, etc.) */
2370
+ getLeaderboardStats(): Promise<IMResult<any>>;
2371
+ /** Get agent improvement board */
2372
+ getLeaderboardAgents(period?: string, domain?: string): Promise<IMResult<any[]>>;
2373
+ /** Get gene impact board */
2374
+ getLeaderboardGenes(period?: string, sort?: string): Promise<IMResult<any[]>>;
2375
+ /** Get contributor board */
2376
+ getLeaderboardContributors(period?: string): Promise<IMResult<any[]>>;
2377
+ /** Get cross-environment comparison data */
2378
+ getLeaderboardComparison(): Promise<IMResult<any>>;
2379
+ /** Get public profile page data for an agent or owner */
2380
+ getPublicProfile(entityId: string): Promise<IMResult<any>>;
2381
+ /** Render agent/creator card as PNG */
2382
+ renderCard(input: {
2383
+ type: string;
2384
+ agentId?: string;
2385
+ agentName?: string;
2386
+ [key: string]: unknown;
2387
+ }): Promise<IMResult<any>>;
2388
+ /** Get benchmark data for profile FOMO section */
2389
+ getBenchmark(): Promise<IMResult<any>>;
2390
+ /** Get gene highlight capsules for profile page */
2391
+ getHighlights(geneId: string): Promise<IMResult<any[]>>;
2392
+ /** Analyze signals and get gene recommendation */
2393
+ analyze(options: IMAnalyzeOptions & {
2394
+ scope?: string;
2395
+ }): Promise<IMResult<IMAnalyzeResult>>;
2396
+ /** Record an outcome (success/failure) for a gene */
2397
+ record(options: IMRecordOutcomeOptions & {
2398
+ scope?: string;
2399
+ }): Promise<IMResult<any>>;
2400
+ /**
2401
+ * One-step evolution: analyze context → get gene recommendation → auto-record outcome.
2402
+ * Combines analyze() + record() into a single call for the common case.
2403
+ *
2404
+ * Usage:
2405
+ * const result = await client.evolution.evolve({
2406
+ * error: 'Connection timeout after 10s',
2407
+ * outcome: 'success',
2408
+ * score: 0.85,
2409
+ * summary: 'Fixed with exponential backoff',
2410
+ * });
2411
+ */
2412
+ evolve(options: {
2413
+ error?: string;
2414
+ task_status?: string;
2415
+ task_capability?: string;
2416
+ tags?: string[];
2417
+ signals?: Array<string | {
2418
+ type: string;
2419
+ provider?: string;
2420
+ stage?: string;
2421
+ severity?: string;
2422
+ }>;
2423
+ provider?: string;
2424
+ stage?: string;
2425
+ severity?: string;
2426
+ outcome: 'success' | 'failed';
2427
+ score?: number;
2428
+ summary?: string;
2429
+ strategy_used?: string[];
2430
+ scope?: string;
2431
+ }): Promise<IMResult<{
2432
+ analysis: IMAnalyzeResult;
2433
+ recorded: boolean;
2434
+ edge_updated?: boolean;
2435
+ }>>;
2436
+ /** Trigger gene distillation */
2437
+ distill(dryRun?: boolean): Promise<IMResult<any>>;
2438
+ /** List own genes */
2439
+ listGenes(signals?: string, scope?: string): Promise<IMResult<IMGene[]>>;
2440
+ /** Create a new gene */
2441
+ createGene(options: IMCreateGeneOptions & {
2442
+ scope?: string;
2443
+ }): Promise<IMResult<IMGene>>;
2444
+ /** Delete a gene */
2445
+ deleteGene(geneId: string): Promise<IMResult<void>>;
2446
+ /** Publish a gene. Pass skipCanary=true to bypass canary validation (MVP/admin). */
2447
+ publishGene(geneId: string, options?: {
2448
+ skipCanary?: boolean;
2449
+ }): Promise<IMResult<IMGene>>;
2450
+ /** Import a published gene */
2451
+ importGene(geneId: string): Promise<IMResult<IMGene>>;
2452
+ /** Fork a gene with modifications */
2453
+ forkGene(options: IMForkGeneOptions): Promise<IMResult<IMGene>>;
2454
+ /** Get signal-gene edges */
2455
+ getEdges(options?: {
2456
+ signalKey?: string;
2457
+ geneId?: string;
2458
+ limit?: number;
2459
+ scope?: string;
2460
+ }): Promise<IMResult<IMEvolutionEdge[]>>;
2461
+ /** Get agent personality profile */
2462
+ getPersonality(agentId: string): Promise<IMResult<{
2463
+ personality: IMAgentPersonality;
2464
+ stats: any;
2465
+ }>>;
2466
+ /** Get own capsule history */
2467
+ getCapsules(options?: {
2468
+ page?: number;
2469
+ limit?: number;
2470
+ scope?: string;
2471
+ }): Promise<IMResult<IMCapsule[]>>;
2472
+ /** Get evolution report */
2473
+ getReport(agentId?: string, scope?: string): Promise<IMResult<any>>;
2474
+ /** List available evolution scopes */
2475
+ listScopes(): Promise<IMResult<string[]>>;
2476
+ /** Get recent evolution stories (for L1 narrative embedding) */
2477
+ getStories(options?: {
2478
+ limit?: number;
2479
+ since?: number;
2480
+ }): Promise<IMResult<any[]>>;
2481
+ /** Get north-star metrics comparison (standard vs hypergraph) */
2482
+ getMetrics(): Promise<IMResult<{
2483
+ standard: any;
2484
+ hypergraph: any;
2485
+ verdict: string;
2486
+ }>>;
2487
+ /** Trigger metrics collection snapshot */
2488
+ collectMetrics(windowHours?: number): Promise<IMResult<{
2489
+ standard: any;
2490
+ hypergraph: any;
2491
+ }>>;
2492
+ /** Search skills catalog */
2493
+ searchSkills(options?: {
2494
+ query?: string;
2495
+ category?: string;
2496
+ limit?: number;
2497
+ }): Promise<IMResult<any[]>>;
2498
+ /** Get skill catalog stats */
2499
+ getSkillStats(): Promise<IMResult<any>>;
2500
+ /** Install a skill — creates Gene + returns content + install guide */
2501
+ installSkill(slugOrId: string, scope?: string): Promise<IMResult<IMSkillInstallResult>>;
2502
+ /** Uninstall a skill */
2503
+ uninstallSkill(slugOrId: string): Promise<IMResult<{
2504
+ uninstalled: boolean;
2505
+ }>>;
2506
+ /** List installed skills for this agent */
2507
+ installedSkills(): Promise<IMResult<IMAgentSkillRecord[]>>;
2508
+ /** Get full skill content (SKILL.md + package info) */
2509
+ getSkillContent(slugOrId: string): Promise<IMResult<IMSkillContent>>;
2510
+ /** Create/submit a community skill */
2511
+ createSkill(input: {
2512
+ name: string;
2513
+ description: string;
2514
+ category: string;
2515
+ tags?: string[];
2516
+ content?: string;
2517
+ signals?: Array<{
2518
+ type: string;
2519
+ }>;
2520
+ author?: string;
2521
+ }): Promise<IMResult<any>>;
2522
+ /** Star a skill (increment community rating) */
2523
+ starSkill(skillId: string): Promise<IMResult<{
2524
+ stars: number;
2525
+ }>>;
2526
+ /**
2527
+ * Install a skill and write SKILL.md to local filesystem.
2528
+ * Combines cloud install + local file sync for Claude Code / OpenClaw / OpenCode.
2529
+ * @param slugOrId - Skill slug or ID
2530
+ * @param options - Local install options
2531
+ */
2532
+ installSkillLocal(slugOrId: string, options?: {
2533
+ /** Target platforms (default: all detected) */
2534
+ platforms?: Array<'claude-code' | 'openclaw' | 'opencode' | 'plugin'>;
2535
+ /** Write to project-level paths instead of global */
2536
+ project?: boolean;
2537
+ /** Project root directory (for project-level installs) */
2538
+ projectRoot?: string;
2539
+ }): Promise<IMResult<IMSkillInstallResult & {
2540
+ localPaths: string[];
2541
+ }>>;
2542
+ /**
2543
+ * Uninstall a skill and remove local SKILL.md files.
2544
+ */
2545
+ uninstallSkillLocal(slugOrId: string): Promise<IMResult<{
2546
+ uninstalled: boolean;
2547
+ removedPaths: string[];
2548
+ }>>;
2549
+ /**
2550
+ * Sync all installed skills to local filesystem.
2551
+ */
2552
+ syncSkillsLocal(options?: {
2553
+ platforms?: Array<'claude-code' | 'openclaw' | 'opencode' | 'plugin'>;
2554
+ }): Promise<{
2555
+ synced: number;
2556
+ failed: number;
2557
+ paths: string[];
2558
+ }>;
2559
+ /** Export a Gene as a Skill */
2560
+ exportAsSkill(geneId: string, options?: {
2561
+ slug?: string;
2562
+ displayName?: string;
2563
+ changelog?: string;
2564
+ }): Promise<IMResult<any>>;
2565
+ /** Submit a raw-context evolution report (auto-creates signals + gene match) */
2566
+ submitReport(options: {
2567
+ rawContext: string;
2568
+ outcome: 'success' | 'failed';
2569
+ taskContext?: string;
2570
+ taskError?: string;
2571
+ taskId?: string;
2572
+ metadata?: Record<string, unknown>;
2573
+ }): Promise<IMResult<any>>;
2574
+ /** Get status of a submitted report by traceId */
2575
+ getReportStatus(traceId: string): Promise<IMResult<any>>;
2576
+ /** Get evolution achievements for the current agent */
2577
+ getAchievements(): Promise<IMResult<any[]>>;
2578
+ /** Get a sync snapshot (global gene/edge state since a sequence number) */
2579
+ getSyncSnapshot(since?: number): Promise<IMResult<any>>;
2580
+ /** Bidirectional sync: push local outcomes and pull remote updates */
2581
+ sync(options?: {
2582
+ pushOutcomes?: any[];
2583
+ pullSince?: number;
2584
+ }): Promise<IMResult<any>>;
2585
+ }
2586
+
2587
+ /** File upload management (presign → upload → confirm) */
2588
+ declare class FilesClient {
2589
+ private _r;
2590
+ private _baseUrl;
2591
+ private _fetchFn;
2592
+ private _getAuthHeaders;
2593
+ constructor(_r: RequestFn, _baseUrl: string, _fetchFn: typeof fetch, _getAuthHeaders: () => Record<string, string>);
2594
+ /** Get a presigned upload URL */
2595
+ presign(options: IMPresignOptions): Promise<IMResult<IMPresignResult>>;
2596
+ /** Confirm an uploaded file (triggers validation + CDN activation) */
2597
+ confirm(uploadId: string): Promise<IMResult<IMConfirmResult>>;
2598
+ /** Get storage quota */
2599
+ quota(): Promise<IMResult<IMFileQuota>>;
2600
+ /** Delete a file */
2601
+ delete(uploadId: string): Promise<IMResult<void>>;
2602
+ /** List allowed MIME types */
2603
+ types(): Promise<IMResult<{
2604
+ allowedMimeTypes: string[];
2605
+ }>>;
2606
+ /** Initialize a multipart upload (for files > 10 MB) */
2607
+ initMultipart(opts: {
2608
+ fileName: string;
2609
+ fileSize: number;
2610
+ mimeType: string;
2611
+ }): Promise<IMResult<IMMultipartInitResult>>;
2612
+ /** Complete a multipart upload */
2613
+ completeMultipart(uploadId: string, parts: Array<{
2614
+ partNumber: number;
2615
+ etag: string;
2616
+ }>): Promise<IMResult<IMConfirmResult>>;
2617
+ /**
2618
+ * Upload a file (full lifecycle: presign → upload → confirm).
2619
+ *
2620
+ * @param input - File, Blob, Buffer, Uint8Array, or file path (Node.js string)
2621
+ * @param opts - Optional fileName, mimeType, onProgress
2622
+ * @returns Confirmed upload result with CDN URL
2623
+ */
2624
+ upload(input: FileInput, opts?: UploadOptions): Promise<UploadResult>;
2625
+ /**
2626
+ * Upload a file and send it as a message in one call.
2627
+ *
2628
+ * @param conversationId - Target conversation
2629
+ * @param input - File input (same as upload())
2630
+ * @param opts - Upload options + optional message content/parentId
2631
+ */
2632
+ sendFile(conversationId: string, input: FileInput, opts?: SendFileOptions): Promise<SendFileResult>;
2633
+ private _uploadSimple;
2634
+ private _uploadMultipart;
2635
+ }
2636
+ /** Real-time connection factory (WebSocket & SSE) */
2637
+ declare class IMRealtimeClient {
2638
+ private _wsBase;
2639
+ constructor(_wsBase: string);
2640
+ /** Get the WebSocket URL */
2641
+ wsUrl(token?: string): string;
2642
+ /** Get the SSE URL */
2643
+ sseUrl(token?: string): string;
2644
+ /** Create a WebSocket client. Call .connect() to establish connection. */
2645
+ connectWS(config: RealtimeConfig): RealtimeWSClient;
2646
+ /** Create an SSE client. Call .connect() to establish connection. */
2647
+ connectSSE(config: RealtimeConfig): RealtimeSSEClient;
2648
+ }
2649
+ declare class IMClient {
2650
+ readonly account: AccountClient;
2651
+ readonly direct: DirectClient;
2652
+ readonly groups: GroupsClient;
2653
+ readonly conversations: ConversationsClient;
2654
+ readonly messages: MessagesClient;
2655
+ readonly contacts: ContactsClient;
2656
+ readonly bindings: BindingsClient;
2657
+ readonly credits: CreditsClient;
2658
+ readonly workspace: WorkspaceClient;
2659
+ readonly tasks: TasksClient;
2660
+ readonly memory: MemoryClient;
2661
+ readonly knowledge: KnowledgeLinkClient;
2662
+ readonly identity: IdentityClient;
2663
+ readonly security: SecurityClient;
2664
+ readonly evolution: EvolutionClient;
2665
+ readonly community: CommunityHub;
2666
+ readonly files: FilesClient;
2667
+ readonly realtime: IMRealtimeClient;
2668
+ /** Offline manager (null if offline mode not enabled) */
2669
+ readonly offline: OfflineManager | null;
2670
+ constructor(request: RequestFn, wsBase: string, fetchFn: typeof fetch, getAuthHeaders: () => Record<string, string>, offlineManager?: OfflineManager | null, communityHubConfig?: CommunityHubConfig | null);
2671
+ /** IM health check */
2672
+ health(): Promise<IMResult<void>>;
2673
+ /** Get workspace superset view with slot filtering */
2674
+ getWorkspace(scope?: string, slots?: string[], includeContent?: boolean): Promise<any>;
2675
+ }
2676
+ declare class PrismerClient {
2677
+ private apiKey;
2678
+ private readonly baseUrl;
2679
+ private readonly timeout;
2680
+ private readonly fetchFn;
2681
+ private readonly imAgent?;
2682
+ private _offlineManager;
2683
+ /** AIP identity for auto-signing (v1.8.0 S1) */
2684
+ private _identity;
2685
+ private _identityReady;
2686
+ /** IM API sub-client */
2687
+ readonly im: IMClient;
2688
+ /** Remote Control API sub-client (Track 3) */
2689
+ readonly remote: RemoteClient;
2690
+ readonly permissions: PermissionsClient;
2691
+ constructor(config?: PrismerConfig);
2692
+ /** Wait for identity to be ready (useful for tests or explicit await) */
2693
+ ensureIdentity(): Promise<AIPIdentity | null>;
2694
+ /** Auto-sign a message body and send (v1.8.0 S1) */
2695
+ private _signAndSend;
2696
+ /** Build auth headers for raw HTTP requests (used by file upload) */
2697
+ private _getAuthHeaders;
2698
+ /**
2699
+ * Set or update the auth token (API key or IM JWT).
2700
+ * Useful after anonymous registration to set the returned JWT.
2701
+ */
2702
+ setToken(token: string): void;
2703
+ /** Cleanup resources (offline manager, timers). Call when disposing the client. */
2704
+ destroy(): Promise<void>;
2705
+ private _request;
2706
+ /** Load content from URL(s) or search query */
2707
+ load(input: string | string[], options?: LoadOptions): Promise<LoadResult>;
2708
+ /** Save content to Prismer cache */
2709
+ save(options: SaveOptions | SaveBatchOptions): Promise<SaveResult>;
2710
+ /** Batch save multiple items (max 50) */
2711
+ saveBatch(items: SaveOptions[]): Promise<SaveResult>;
2712
+ /** Parse a document (PDF, image) into structured content */
2713
+ parse(options: ParseOptions): Promise<ParseResult>;
2714
+ /** Convenience: parse a PDF by URL */
2715
+ parsePdf(url: string, mode?: 'fast' | 'hires' | 'auto'): Promise<ParseResult>;
2716
+ /** Check status of an async parse task */
2717
+ parseStatus(taskId: string): Promise<ParseResult>;
2718
+ /** Get result of a completed async parse task */
2719
+ parseResult(taskId: string): Promise<ParseResult>;
2720
+ /** Search for content (convenience wrapper around load with query mode) */
2721
+ search(query: string, options?: {
2722
+ topK?: number;
2723
+ returnTopK?: number;
2724
+ format?: 'hqcc' | 'raw' | 'both';
2725
+ ranking?: 'cache_first' | 'relevance_first' | 'balanced';
2726
+ }): Promise<LoadResult>;
2727
+ }
2728
+
2729
+ /**
2730
+ * Prismer CLI — library-exported command registrations.
2731
+ *
2732
+ * As of v1.9.0 this module does NOT ship a `prismer` binary. Instead the
2733
+ * runtime package (@prismer/runtime) owns the single `prismer` entry point
2734
+ * and calls `registerSdkCliCommands(program, { skipConflicting: true })` to
2735
+ * mount these commands onto its own commander tree.
6
2736
  *
7
2737
  * Top-level shortcuts: send, load, search, parse, recall, discover, skill
8
2738
  * Grouped namespaces: im, context, evolve, task, memory, file, workspace, security, identity
9
2739
  * Utilities: init, register, status, config, token
2740
+ *
2741
+ * `{ skipConflicting: true }` skips setup/init/status/daemon — those names
2742
+ * are owned by the runtime CLI; `register` is always included (no runtime
2743
+ * collision; covers the IM identity flow).
10
2744
  */
11
2745
 
2746
+ declare let cliVersion: string;
12
2747
  declare function getIMClient(): PrismerClient;
13
2748
  declare function getAPIClient(): PrismerClient;
2749
+ interface SdkCliOptions {
2750
+ /**
2751
+ * Skip commands that the runtime CLI already owns (setup, init, status,
2752
+ * daemon). `register` is always mounted — runtime does not provide it.
2753
+ */
2754
+ skipConflicting?: boolean;
2755
+ }
2756
+
2757
+ declare function registerSdkCliCommands(program: Command, opts?: SdkCliOptions): void;
14
2758
 
15
- export { getAPIClient, getIMClient };
2759
+ export { type SdkCliOptions, cliVersion, getAPIClient, getIMClient, registerSdkCliCommands };