hiloop-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,823 @@
1
+ /** Hiloop SDK client for agents to interact with the Hiloop platform. */
2
+ import type { KeyPair } from "./crypto.js";
3
+ import type { Channel, ChannelMessage, ChannelParticipant, ConvSession, ConvSessionMessage, ConvSessionParticipant, ConvSessionRole, CreateChannelOptions, CreateConvSessionOptions, CreateInteractionOptions, GuestToken, Interaction, Message, PaginatedResult } from "./types.js";
4
+ export declare class HiloopError extends Error {
5
+ statusCode: number;
6
+ constructor(statusCode: number, message: string);
7
+ }
8
+ export interface HiloopClientOptions {
9
+ apiKey: string;
10
+ baseUrl?: string;
11
+ /** Agent's X25519 secret key (base64). Required for E2E encryption. */
12
+ secretKey?: string;
13
+ /** Agent's X25519 public key (base64). Required for E2E encryption. */
14
+ publicKey?: string;
15
+ /** Space's public key (base64). Required for E2E encryption. */
16
+ spacePublicKey?: string;
17
+ /** Space's public key ID. Required for E2E encryption. */
18
+ spaceKeyId?: string;
19
+ /** Server's public key ID. Used as default recipientKeyId for content wrapping. */
20
+ serverKeyId?: string;
21
+ timeout?: number;
22
+ }
23
+ export declare class HiloopClient {
24
+ private apiKey;
25
+ private baseUrl;
26
+ private timeout;
27
+ private crypto;
28
+ private secretKeyB64;
29
+ private publicKeyB64;
30
+ constructor(options: HiloopClientOptions);
31
+ private encryptField;
32
+ /**
33
+ * Encrypt multiple fields with a SINGLE shared content key (AES-256-GCM).
34
+ * The content key is wrapped once using ECDH + HKDF + AES-GCM.
35
+ *
36
+ * This avoids the DB unique constraint issue where per-field wrappings
37
+ * with the same (scope, recipientKeyId) are silently dropped.
38
+ */
39
+ private encryptFields;
40
+ private bytesToBase64;
41
+ private request;
42
+ /** Fetch binary content (e.g. file download). Returns raw ArrayBuffer. */
43
+ private requestBinary;
44
+ createInteraction(opts: CreateInteractionOptions): Promise<Interaction>;
45
+ getInteraction(interactionId: string): Promise<Interaction>;
46
+ /** Try to decrypt encrypted interaction fields using content wrappings. */
47
+ private decryptInteractionFields;
48
+ cancelInteraction(interactionId: string): Promise<Interaction>;
49
+ /** Update description/context on an interaction. Accepts plaintext — auto-encrypts. */
50
+ updateInteractionContext(interactionId: string, opts: {
51
+ description?: string;
52
+ context?: string;
53
+ }): Promise<Record<string, unknown>>;
54
+ acknowledgeInteraction(interactionId: string): Promise<Interaction>;
55
+ /** AG-018/019: Update priority, deadline, or context metadata on a pending interaction. */
56
+ updateInteractionMetadata(interactionId: string, opts: {
57
+ priority?: string;
58
+ deadlineMinutes?: number;
59
+ encryptedContext?: string;
60
+ }): Promise<{
61
+ id: string;
62
+ priority: string;
63
+ deadlineAt: string | null;
64
+ updatedAt: string;
65
+ }>;
66
+ /** Get the transition log for an interaction. */
67
+ getInteractionTransitions(interactionId: string): Promise<{
68
+ transitions: Record<string, unknown>[];
69
+ }>;
70
+ /** HU-073 (agent side): Read pending task control signal (pause/resume/cancel). */
71
+ getTaskControl(interactionId: string): Promise<{
72
+ signal: string | null;
73
+ signalAt: string | null;
74
+ }>;
75
+ /** HU-073 (agent side): Acknowledge task control signal, clearing it. */
76
+ ackTaskControl(interactionId: string): Promise<{
77
+ acknowledged: string | null;
78
+ }>;
79
+ /** Single long-poll for a response (server-side timeout, max ~30s). */
80
+ awaitResponse(interactionId: string, timeout?: number): Promise<Interaction>;
81
+ /**
82
+ * Wait for a human to respond to an interaction, polling repeatedly.
83
+ * Returns the interaction once it has a response (status is responded/completed),
84
+ * or throws after the timeout expires.
85
+ *
86
+ * @param interactionId - The interaction to wait for
87
+ * @param timeoutSeconds - Maximum wait time in seconds (default 300, max 3600)
88
+ */
89
+ waitForResponse(interactionId: string, timeoutSeconds?: number): Promise<Interaction>;
90
+ listInteractions(filters?: {
91
+ status?: string;
92
+ type?: string;
93
+ page?: number;
94
+ pageSize?: number;
95
+ }): Promise<PaginatedResult<Interaction>>;
96
+ sendMessage(interactionId: string, content: string): Promise<Message>;
97
+ /** Push content blocks to an interaction. */
98
+ pushContentBlocks(interactionId: string, blocks: Array<{
99
+ blockType: string;
100
+ data: Record<string, unknown>;
101
+ position?: number;
102
+ }>): Promise<{
103
+ items: Record<string, unknown>[];
104
+ count: number;
105
+ }>;
106
+ /** List content blocks for an interaction. */
107
+ listContentBlocks(interactionId: string): Promise<{
108
+ items: Record<string, unknown>[];
109
+ total: number;
110
+ }>;
111
+ /** Update a content block. */
112
+ updateContentBlock(interactionId: string, blockId: string, data: Record<string, unknown>): Promise<{
113
+ id: string;
114
+ blockType: string;
115
+ data: Record<string, unknown>;
116
+ position: number;
117
+ updatedAt: string;
118
+ }>;
119
+ /** Delete a content block. */
120
+ deleteContentBlock(interactionId: string, blockId: string): Promise<{
121
+ deleted: boolean;
122
+ }>;
123
+ /** Upload a file attachment to an interaction (base64-encoded). */
124
+ uploadAttachment(interactionId: string, opts: {
125
+ fileName: string;
126
+ mimeType: string;
127
+ content: string;
128
+ messageId?: string;
129
+ }): Promise<{
130
+ id: string;
131
+ fileName: string;
132
+ mimeType: string;
133
+ sizeBytes: number;
134
+ createdAt: string;
135
+ }>;
136
+ /** List attachments for an interaction, optionally filtered by messageId. */
137
+ listAttachments(interactionId: string, messageId?: string): Promise<{
138
+ items: Record<string, unknown>[];
139
+ total: number;
140
+ }>;
141
+ /** Download raw binary content of a specific attachment. */
142
+ getAttachment(interactionId: string, fileId: string): Promise<ArrayBuffer>;
143
+ /** List all reactions for messages in an interaction. */
144
+ listInteractionReactions(interactionId: string): Promise<{
145
+ items: Record<string, unknown>[];
146
+ }>;
147
+ /** Add a reaction emoji to a message in an interaction. */
148
+ addInteractionReaction(interactionId: string, messageId: string, emoji: string): Promise<{
149
+ id: string;
150
+ messageId: string;
151
+ emoji: string;
152
+ createdAt: string;
153
+ }>;
154
+ /** Remove a reaction emoji from a message in an interaction. */
155
+ removeInteractionReaction(interactionId: string, messageId: string, emoji: string): Promise<{
156
+ ok: boolean;
157
+ }>;
158
+ /** Mark all messages in an interaction as read by this agent. */
159
+ markInteractionRead(interactionId: string): Promise<{
160
+ markedRead: number;
161
+ }>;
162
+ /** Send a typing indicator for an interaction. */
163
+ sendInteractionTyping(interactionId: string, isTyping: boolean): Promise<{
164
+ ok: boolean;
165
+ }>;
166
+ listMessages(interactionId: string, page?: number, pageSize?: number): Promise<PaginatedResult<Message>>;
167
+ /** AD-060: Push agent telemetry activity status + plan to the platform. */
168
+ pushTelemetry(opts: {
169
+ status: string;
170
+ focus?: string;
171
+ plan?: {
172
+ name?: string;
173
+ tasks: Array<{
174
+ name: string;
175
+ completed: boolean;
176
+ }>;
177
+ };
178
+ }): Promise<{
179
+ ok: boolean;
180
+ }>;
181
+ /** AG-041: List webhook delivery history for the agent. */
182
+ listWebhookDeliveries(limit?: number): Promise<{
183
+ items: Record<string, unknown>[];
184
+ total: number;
185
+ }>;
186
+ /** AG-041: Get webhook delivery statistics for the agent. */
187
+ getWebhookDeliveryStats(): Promise<Record<string, unknown>>;
188
+ /** AG-041: Manually retry a failed webhook delivery. */
189
+ retryWebhookDelivery(deliveryId: string): Promise<{
190
+ queued: boolean;
191
+ deliveryId: string;
192
+ }>;
193
+ /** BL-042: Check remaining plan quota for this space. */
194
+ getQuota(): Promise<Record<string, unknown>>;
195
+ /** AD-060: Log an inter-agent communication event for monitoring. */
196
+ logComm(opts: {
197
+ direction: "sent" | "received";
198
+ content: string;
199
+ otherAgentName?: string;
200
+ }): Promise<{
201
+ id: string;
202
+ createdAt: string;
203
+ }>;
204
+ /** Get space encryption info (space public key). */
205
+ getEncryptionInfo(): Promise<{
206
+ spaceKeyId: string;
207
+ spacePublicKey: string;
208
+ }>;
209
+ /** Get this agent's currently registered public key. */
210
+ getAgentPublicKey(): Promise<{
211
+ keyId: string;
212
+ publicKey: string;
213
+ fingerprint: string;
214
+ }>;
215
+ /** Register (or confirm) this agent's public key (idempotent). */
216
+ putAgentPublicKey(publicKey: string, fingerprint: string): Promise<{
217
+ keyId: string;
218
+ publicKey: string;
219
+ fingerprint: string;
220
+ }>;
221
+ /** List space teams for this agent's space. */
222
+ listSpaceTeams(): Promise<{
223
+ items: Record<string, unknown>[];
224
+ total: number;
225
+ }>;
226
+ /** Get availability status for a specific space user. */
227
+ getUserAvailability(userId: string): Promise<{
228
+ userId: string;
229
+ availability: string;
230
+ }>;
231
+ /** List space users visible to this agent. */
232
+ listSpaceUsers(opts?: {
233
+ limit?: number;
234
+ offset?: number;
235
+ }): Promise<{
236
+ items: Record<string, unknown>[];
237
+ total: number;
238
+ }>;
239
+ createConvSession(opts: CreateConvSessionOptions): Promise<ConvSession>;
240
+ getConvSession(sessionId: string): Promise<ConvSession>;
241
+ listConvSessions(opts?: {
242
+ status?: string;
243
+ isPublic?: boolean;
244
+ limit?: number;
245
+ offset?: number;
246
+ page?: number;
247
+ }): Promise<ConvSession[]>;
248
+ closeConvSession(sessionId: string): Promise<ConvSession>;
249
+ /**
250
+ * Send a message to a conversation session.
251
+ * The content must be pre-encrypted using encryptAes() with the shared session key.
252
+ */
253
+ /**
254
+ * Send a message in a conv session. Accepts plaintext — encrypts automatically
255
+ * using the session message key (`{agentPub}:{AES-GCM ciphertext}` format).
256
+ */
257
+ sendConvSessionMessage(sessionId: string, content: string): Promise<ConvSessionMessage>;
258
+ /** Send a typing indicator to a conv session (HU-034). */
259
+ sendConvSessionTyping(sessionId: string, typing: boolean): Promise<void>;
260
+ /** Edit a previously sent conv session message. */
261
+ editConvSessionMessage(sessionId: string, msgId: string, encryptedContent: string): Promise<ConvSessionMessage>;
262
+ /** Soft-delete a conv session message. */
263
+ deleteConvSessionMessage(sessionId: string, msgId: string): Promise<{
264
+ ok: boolean;
265
+ }>;
266
+ listConvSessionTimeline(sessionId: string, opts?: {
267
+ limit?: number;
268
+ before?: string;
269
+ }): Promise<{
270
+ items: Record<string, unknown>[];
271
+ }>;
272
+ addConvSessionParticipant(sessionId: string, userId: string, role?: ConvSessionRole): Promise<ConvSessionParticipant>;
273
+ removeConvSessionParticipant(sessionId: string, userId: string): Promise<void>;
274
+ /** Update a participant's role in a conversation session. */
275
+ updateConvSessionParticipantRole(sessionId: string, userId: string, role: string): Promise<{
276
+ ok: boolean;
277
+ }>;
278
+ listConvSessionParticipants(sessionId: string): Promise<ConvSessionParticipant[]>;
279
+ createGuestToken(sessionId: string, opts?: {
280
+ displayName?: string;
281
+ expiresInHours?: number;
282
+ }): Promise<GuestToken>;
283
+ listGuestTokens(sessionId: string): Promise<GuestToken[]>;
284
+ revokeGuestToken(sessionId: string, tokenId: string): Promise<void>;
285
+ /** AG-060: Create multiple interactions in a single API call. */
286
+ createInteractionBatch(interactions: CreateInteractionOptions[]): Promise<{
287
+ results: {
288
+ id: string;
289
+ kind: string;
290
+ status: string;
291
+ error?: string;
292
+ }[];
293
+ total: number;
294
+ successes: number;
295
+ }>;
296
+ /** Archive a conversation session. */
297
+ archiveConvSession(sessionId: string): Promise<ConvSession>;
298
+ /** Create a group interaction involving multiple participants (AG-061). */
299
+ createGroupInteraction(opts: CreateInteractionOptions, participants: {
300
+ userId: string;
301
+ role?: string;
302
+ }[]): Promise<{
303
+ id: string;
304
+ kind: string;
305
+ status: string;
306
+ participants: {
307
+ userId: string;
308
+ role: string;
309
+ }[];
310
+ }>;
311
+ /** Add a reference from one interaction to another (AG-062). */
312
+ addInteractionReference(interactionId: string, targetInteractionId: string, opts?: {
313
+ referenceType?: string;
314
+ note?: string;
315
+ }): Promise<Record<string, unknown>>;
316
+ /** List all references for an interaction (AG-062). */
317
+ listInteractionReferences(interactionId: string): Promise<{
318
+ items: Record<string, unknown>[];
319
+ total: number;
320
+ }>;
321
+ /** Remove an interaction reference by its ID (AG-062). */
322
+ removeInteractionReference(interactionId: string, refId: string): Promise<{
323
+ deleted: boolean;
324
+ }>;
325
+ /** Get public metadata for a public agent by slug. */
326
+ getPublicAgentInfo(slug: string): Promise<{
327
+ name: string;
328
+ description: string | null;
329
+ slug: string;
330
+ isPublic: boolean;
331
+ }>;
332
+ /** Create an interaction as a public (anonymous) user on a public agent. */
333
+ createPublicInteraction(slug: string, opts: {
334
+ encryptedTitle: string;
335
+ type?: string;
336
+ priority?: string;
337
+ deadlineMinutes?: number;
338
+ }): Promise<{
339
+ id: string;
340
+ kind: string;
341
+ status: string;
342
+ priority: string;
343
+ createdAt: string;
344
+ }>;
345
+ /** Get the status of a public interaction by slug + ID. */
346
+ getPublicInteraction(slug: string, interactionId: string): Promise<{
347
+ id: string;
348
+ kind: string;
349
+ status: string;
350
+ priority: string;
351
+ encryptedTitle: string | null;
352
+ encryptedResponse: string | null;
353
+ createdAt: string;
354
+ updatedAt: string;
355
+ }>;
356
+ /** Long-poll for a response on a public interaction (returns when responded/completed/cancelled/expired). */
357
+ awaitPublicInteraction(slug: string, interactionId: string, timeoutMs?: number): Promise<{
358
+ id: string;
359
+ status: string;
360
+ encryptedResponse: string | null;
361
+ respondedAt: string | null;
362
+ }>;
363
+ /** Send a message to a public interaction as an anonymous user. */
364
+ sendPublicMessage(slug: string, interactionId: string, encryptedContent: string): Promise<{
365
+ id: string;
366
+ interactionId: string;
367
+ senderType: string;
368
+ encryptedContent: string;
369
+ createdAt: string;
370
+ }>;
371
+ /** List interactions created on a public agent (paginated). */
372
+ listPublicInteractions(slug: string, opts?: {
373
+ page?: number;
374
+ pageSize?: number;
375
+ }): Promise<{
376
+ items: Record<string, unknown>[];
377
+ total: number;
378
+ page: number;
379
+ pageSize: number;
380
+ }>;
381
+ /** Cancel a public interaction (anonymous user side). */
382
+ cancelPublicInteraction(slug: string, interactionId: string): Promise<{
383
+ id: string;
384
+ status: string;
385
+ }>;
386
+ /** Get the transition log for a public interaction. */
387
+ getPublicInteractionTransitions(slug: string, interactionId: string): Promise<{
388
+ transitions: Record<string, unknown>[];
389
+ }>;
390
+ /** Look up a public session by its public token (no auth required). */
391
+ getPublicSession(publicToken: string): Promise<{
392
+ session: Record<string, unknown>;
393
+ }>;
394
+ /** Join a public session as a guest using its public token. */
395
+ joinPublicSession(publicToken: string, displayName: string): Promise<{
396
+ sessionId: string;
397
+ guestToken: string;
398
+ }>;
399
+ /** Get a human-facing interaction detail view. */
400
+ getHumanInteraction(interactionId: string): Promise<Record<string, unknown>>;
401
+ /** Mark an interaction as viewed by the authenticated user. */
402
+ viewInteraction(interactionId: string): Promise<{
403
+ id: string;
404
+ status: string;
405
+ }>;
406
+ /** Submit a response to an interaction. */
407
+ respondToHumanInteraction(interactionId: string, opts: {
408
+ encryptedResponse: string;
409
+ responseEventType?: string;
410
+ }): Promise<Record<string, unknown>>;
411
+ /** Snooze an interaction until a given ISO datetime. */
412
+ snoozeInteraction(interactionId: string, snoozedUntil: string): Promise<{
413
+ id: string;
414
+ snoozedUntil: string | null;
415
+ }>;
416
+ /** Toggle the pinned state of an interaction. */
417
+ pinInteraction(interactionId: string, pinned: boolean): Promise<{
418
+ id: string;
419
+ isPinned: boolean;
420
+ }>;
421
+ /** Get the human user's activity feed (all interactions). */
422
+ getFeed(opts?: {
423
+ page?: number;
424
+ pageSize?: number;
425
+ view?: string;
426
+ q?: string;
427
+ type?: string;
428
+ priority?: string;
429
+ pinned?: boolean;
430
+ agentId?: string;
431
+ }): Promise<{
432
+ items: Record<string, unknown>[];
433
+ total: number;
434
+ }>;
435
+ /** Get badge counts (e.g. open interactions) for the authenticated user. */
436
+ getBadges(): Promise<{
437
+ open: number;
438
+ }>;
439
+ /** Get the authenticated user's current availability status. */
440
+ getMyAvailability(): Promise<{
441
+ status: string;
442
+ }>;
443
+ /** Update the authenticated user's availability status. */
444
+ updateMyAvailability(status: "active" | "away" | "dnd" | "offline"): Promise<{
445
+ status: string;
446
+ }>;
447
+ /** List delegation rules for the authenticated user. */
448
+ listDelegations(): Promise<{
449
+ items: Record<string, unknown>[];
450
+ }>;
451
+ /** Create a delegation rule for the authenticated user. */
452
+ createDelegation(opts: {
453
+ delegateToUserId: string;
454
+ triggerStatus?: string;
455
+ delegateToTeamId?: string;
456
+ }): Promise<{
457
+ ok: boolean;
458
+ }>;
459
+ /** Remove a delegation rule by delegateId. */
460
+ deleteDelegation(delegateId: string): Promise<{
461
+ ok: boolean;
462
+ }>;
463
+ /** List sent notifications for the authenticated user. */
464
+ listNotifications(): Promise<{
465
+ items: Record<string, unknown>[];
466
+ total: number;
467
+ }>;
468
+ /** Get notification preferences for the authenticated user. */
469
+ getNotificationPreferences(): Promise<{
470
+ preferences: Record<string, unknown>[];
471
+ }>;
472
+ /** Update notification preference for a specific channel. */
473
+ updateNotificationPreference(channel: "push" | "email" | "sms" | "in_app", opts: {
474
+ enabled?: boolean;
475
+ quietHoursStart?: number;
476
+ quietHoursEnd?: number;
477
+ digestEnabled?: boolean;
478
+ digestFrequency?: "daily" | "weekly";
479
+ minPriority?: string;
480
+ }): Promise<Record<string, unknown>>;
481
+ /** Register a push token for the authenticated user's device. */
482
+ registerPushToken(opts: {
483
+ token: string;
484
+ platform: "fcm" | "apns" | "apns_voip";
485
+ deviceId?: string;
486
+ }): Promise<{
487
+ id: string;
488
+ token: string;
489
+ platform: string;
490
+ }>;
491
+ /** Remove the push token for the authenticated user's device. */
492
+ deletePushToken(opts: {
493
+ token: string;
494
+ platform: string;
495
+ }): Promise<{
496
+ deleted: boolean;
497
+ }>;
498
+ /** Save (upsert) a response draft for an interaction. */
499
+ saveDraft(interactionId: string, encryptedDraft: string): Promise<{
500
+ id: string;
501
+ updatedAt: string;
502
+ }>;
503
+ /** Get the saved response draft for an interaction. */
504
+ getDraft(interactionId: string): Promise<{
505
+ id: string;
506
+ encryptedDraft: string;
507
+ updatedAt: string;
508
+ } | null>;
509
+ /** Delete the saved response draft for an interaction. */
510
+ deleteDraft(interactionId: string): Promise<{
511
+ deleted: boolean;
512
+ }>;
513
+ /** Unsnooze an interaction before its scheduled snooze time. */
514
+ unsnoozeInteraction(interactionId: string): Promise<{
515
+ id: string;
516
+ snoozedUntil: null;
517
+ }>;
518
+ /** Create a milestone alert for an interaction. */
519
+ createMilestoneAlert(interactionId: string, opts: {
520
+ encryptedLabel: string;
521
+ triggerAt: string;
522
+ }): Promise<{
523
+ id: string;
524
+ triggeredAt: string | null;
525
+ }>;
526
+ /** List milestone alerts for an interaction. */
527
+ listMilestoneAlerts(interactionId: string): Promise<{
528
+ alerts: Record<string, unknown>[];
529
+ }>;
530
+ /** Delete a milestone alert. */
531
+ deleteMilestoneAlert(interactionId: string, alertId: string): Promise<{
532
+ deleted: boolean;
533
+ }>;
534
+ /** Get the approval chain for an interaction. */
535
+ getApprovalChain(interactionId: string): Promise<{
536
+ chain: Record<string, unknown>[];
537
+ }>;
538
+ /** Respond to an approval chain step. */
539
+ respondToApprovalChain(interactionId: string, opts: {
540
+ decision: string;
541
+ encryptedComment?: string;
542
+ }): Promise<{
543
+ ok: boolean;
544
+ status: string;
545
+ }>;
546
+ /** List comments on an interaction. */
547
+ listInteractionComments(interactionId: string): Promise<{
548
+ comments: Record<string, unknown>[];
549
+ }>;
550
+ /** Post a comment on an interaction. */
551
+ createInteractionComment(interactionId: string, opts: {
552
+ encryptedContent: string;
553
+ parentId?: string;
554
+ }): Promise<{
555
+ id: string;
556
+ createdAt: string;
557
+ }>;
558
+ /** Mark a comment as resolved. */
559
+ resolveInteractionComment(interactionId: string, commentId: string): Promise<{
560
+ id: string;
561
+ isResolved: boolean;
562
+ }>;
563
+ /** Delete a comment. */
564
+ deleteInteractionComment(interactionId: string, commentId: string): Promise<{
565
+ deleted: boolean;
566
+ }>;
567
+ /** Submit review feedback for an interaction. */
568
+ submitReviewFeedback(interactionId: string, opts: {
569
+ rating: number;
570
+ encryptedFeedback?: string;
571
+ }): Promise<{
572
+ id: string;
573
+ rating: number;
574
+ }>;
575
+ /** Cast a vote on an interaction. */
576
+ voteOnInteraction(interactionId: string, opts: {
577
+ choice: string;
578
+ encryptedComment?: string;
579
+ }): Promise<{
580
+ id: string;
581
+ choice: string;
582
+ }>;
583
+ /** Get aggregate vote results for an interaction. */
584
+ getVoteResults(interactionId: string): Promise<{
585
+ results: Record<string, number>;
586
+ total: number;
587
+ }>;
588
+ /** Get the current user's vote on an interaction. */
589
+ getMyVote(interactionId: string): Promise<{
590
+ choice: string | null;
591
+ id: string | null;
592
+ }>;
593
+ /** List tags on an interaction. */
594
+ getInteractionTags(interactionId: string): Promise<{
595
+ tags: string[];
596
+ }>;
597
+ /** Add a tag to an interaction. */
598
+ addInteractionTag(interactionId: string, tag: string): Promise<{
599
+ tags: string[];
600
+ }>;
601
+ /** Remove a tag from an interaction. */
602
+ deleteInteractionTag(interactionId: string, tag: string): Promise<{
603
+ deleted: boolean;
604
+ }>;
605
+ /** List all space-wide tags. */
606
+ listSpaceTags(): Promise<{
607
+ tags: string[];
608
+ }>;
609
+ /** List response templates for the current user. */
610
+ listResponseTemplates(): Promise<{
611
+ templates: Record<string, unknown>[];
612
+ }>;
613
+ /** Create a response template. */
614
+ createResponseTemplate(opts: {
615
+ encryptedContent: string;
616
+ type?: string;
617
+ }): Promise<{
618
+ id: string;
619
+ createdAt: string;
620
+ }>;
621
+ /** Delete a response template. */
622
+ deleteResponseTemplate(templateId: string): Promise<{
623
+ deleted: boolean;
624
+ }>;
625
+ /** Get review feedback for an interaction. */
626
+ getReviewFeedback(interactionId: string): Promise<{
627
+ feedback: Record<string, unknown>[];
628
+ }>;
629
+ /** Use a response template (increments usage count). */
630
+ useResponseTemplate(templateId: string): Promise<{
631
+ id: string;
632
+ encryptedContent: string;
633
+ }>;
634
+ /** List messages for a human interaction. */
635
+ listInteractionMessages(interactionId: string, opts?: {
636
+ before?: string;
637
+ limit?: number;
638
+ }): Promise<{
639
+ messages: Record<string, unknown>[];
640
+ total: number;
641
+ }>;
642
+ /** Send a message to a human interaction thread. */
643
+ sendInteractionMessage(interactionId: string, opts: {
644
+ encryptedContent: string;
645
+ role?: string;
646
+ }): Promise<{
647
+ id: string;
648
+ createdAt: string;
649
+ }>;
650
+ /** Mark messages as read for an interaction. */
651
+ markMessagesRead(interactionId: string): Promise<{
652
+ markedCount: number;
653
+ }>;
654
+ /** Get aggregated reactions for all messages in an interaction. */
655
+ getInteractionReactions(interactionId: string): Promise<{
656
+ reactions: Record<string, unknown>[];
657
+ }>;
658
+ /** Add a reaction to a specific message. */
659
+ addMessageReaction(interactionId: string, messageId: string, emoji: string): Promise<{
660
+ ok: boolean;
661
+ }>;
662
+ /** Remove a reaction from a specific message. */
663
+ removeMessageReaction(interactionId: string, messageId: string, emoji: string): Promise<{
664
+ deleted: boolean;
665
+ }>;
666
+ /** Get agent activity data for the space (for human dashboard). */
667
+ getAgentActivity(): Promise<{
668
+ agents: Record<string, unknown>[];
669
+ }>;
670
+ /** List interaction references for a human interaction. */
671
+ listHumanInteractionReferences(interactionId: string): Promise<{
672
+ references: Record<string, unknown>[];
673
+ }>;
674
+ /** Add a reference link between two interactions. */
675
+ addHumanInteractionReference(interactionId: string, opts: {
676
+ targetInteractionId: string;
677
+ type?: string;
678
+ }): Promise<{
679
+ id: string;
680
+ }>;
681
+ /** Get current usage and quota for the space. */
682
+ getUsage(): Promise<{
683
+ usage: Record<string, unknown>;
684
+ quota: Record<string, unknown>;
685
+ }>;
686
+ /** Get feature gate flags for the current user. */
687
+ getFeatureGates(): Promise<{
688
+ gates: Record<string, boolean>;
689
+ }>;
690
+ /** Track that the current user is viewing an interaction. */
691
+ trackInteractionViewing(interactionId: string): Promise<{
692
+ ok: boolean;
693
+ }>;
694
+ /** Get who is currently viewing an interaction. */
695
+ getInteractionViewers(interactionId: string): Promise<{
696
+ viewers: Record<string, unknown>[];
697
+ }>;
698
+ /** Stop tracking viewing presence for an interaction. */
699
+ stopTrackingViewing(interactionId: string): Promise<{
700
+ ok: boolean;
701
+ }>;
702
+ /** Get human-assigned tasks (interactions requiring action). */
703
+ getHumanTasks(opts?: {
704
+ page?: number;
705
+ pageSize?: number;
706
+ }): Promise<{
707
+ items: Record<string, unknown>[];
708
+ total: number;
709
+ }>;
710
+ /** List space members (humans). */
711
+ getHumanMembers(opts?: {
712
+ page?: number;
713
+ pageSize?: number;
714
+ }): Promise<{
715
+ members: Record<string, unknown>[];
716
+ total: number;
717
+ }>;
718
+ /** Get aggregated notification digest for the current user. */
719
+ getNotificationDigest(opts?: {
720
+ since?: string;
721
+ }): Promise<{
722
+ digest: Record<string, unknown>[];
723
+ }>;
724
+ /** Create a new agent-to-agent channel. */
725
+ createChannel(opts: CreateChannelOptions): Promise<Channel>;
726
+ /** Get a channel by ID. */
727
+ getChannel(channelId: string): Promise<Channel>;
728
+ /** List channels with optional filters. */
729
+ listChannels(filters?: {
730
+ status?: string;
731
+ page?: number;
732
+ pageSize?: number;
733
+ }): Promise<PaginatedResult<Channel>>;
734
+ /** Close a channel. */
735
+ closeChannel(channelId: string): Promise<Channel>;
736
+ /** Add a participant to a channel. */
737
+ addChannelParticipant(channelId: string, agentId: string): Promise<ChannelParticipant>;
738
+ /** Remove a participant from a channel. */
739
+ removeChannelParticipant(channelId: string, agentId: string): Promise<{
740
+ ok: boolean;
741
+ }>;
742
+ /** Send a message in a channel. */
743
+ sendChannelMessage(channelId: string, content: string): Promise<ChannelMessage>;
744
+ /** List messages in a channel. */
745
+ listChannelMessages(channelId: string, opts?: {
746
+ page?: number;
747
+ pageSize?: number;
748
+ before?: string;
749
+ after?: string;
750
+ }): Promise<PaginatedResult<ChannelMessage>>;
751
+ /** Log a detailed activity entry visible to the human (thinking, tool calls, decisions). */
752
+ logActivity(entry: {
753
+ logType: string;
754
+ content?: string;
755
+ metadata?: Record<string, unknown>;
756
+ }): Promise<Record<string, unknown>>;
757
+ /** List participants in a channel. */
758
+ listChannelParticipants(channelId: string): Promise<{
759
+ participants: ChannelParticipant[];
760
+ }>;
761
+ /** Register or update commands for this agent (batch, max 50). */
762
+ registerCommands(commands: {
763
+ name: string;
764
+ description: string;
765
+ argumentHint?: string;
766
+ parameters?: Record<string, unknown>;
767
+ annotations?: {
768
+ destructive?: boolean;
769
+ longRunning?: boolean;
770
+ };
771
+ }[]): Promise<{
772
+ commands: Record<string, unknown>[];
773
+ count: number;
774
+ }>;
775
+ /** List all commands registered by this agent. */
776
+ listCommands(): Promise<{
777
+ commands: Record<string, unknown>[];
778
+ }>;
779
+ /** Update a registered command by name. */
780
+ updateCommand(name: string, updates: {
781
+ description?: string;
782
+ argumentHint?: string;
783
+ parameters?: Record<string, unknown>;
784
+ annotations?: {
785
+ destructive?: boolean;
786
+ longRunning?: boolean;
787
+ };
788
+ }): Promise<Record<string, unknown>>;
789
+ /** Remove a registered command by name. */
790
+ removeCommand(name: string): Promise<{
791
+ removed: boolean;
792
+ }>;
793
+ /** Poll for pending command invocations. */
794
+ getInvocations(opts?: {
795
+ status?: string;
796
+ convSessionId?: string;
797
+ limit?: number;
798
+ offset?: number;
799
+ }): Promise<{
800
+ invocations: Record<string, unknown>[];
801
+ count: number;
802
+ }>;
803
+ /** Acknowledge a command invocation (pending -> running). */
804
+ ackInvocation(invocationId: string): Promise<Record<string, unknown>>;
805
+ /** Mark an invocation as completed. */
806
+ completeInvocation(invocationId: string, opts?: {
807
+ result?: string;
808
+ }): Promise<Record<string, unknown>>;
809
+ /** Mark an invocation as failed. */
810
+ failInvocation(invocationId: string, opts?: {
811
+ error?: string;
812
+ }): Promise<Record<string, unknown>>;
813
+ static generateKeyPair(): KeyPair;
814
+ /** Encrypt plaintext with AES-256-GCM for session messages. */
815
+ static encryptAes(plaintext: string, keyBase64: string): Promise<string>;
816
+ /** Decrypt AES-256-GCM ciphertext from session messages. */
817
+ static decryptAes(ciphertextBase64: string, keyBase64: string): Promise<string>;
818
+ }
819
+ /**
820
+ * Return all wrappings as-is. Each encrypted field has its own random content
821
+ * key, so every wrapping is unique even when scope + recipientKeyId match.
822
+ * The frontend tries each wrapping until one successfully decrypts.
823
+ */