@nhtio/rocket-chat-openclaw-integration 0.1.0-master-7f84cdcb

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/index.d.mts ADDED
@@ -0,0 +1,751 @@
1
+ import { OpenClawPluginApi } from 'openclaw/plugin-sdk/core';
2
+ import { OpenClawPluginConfigSchema } from 'openclaw/plugin-sdk/core';
3
+ import { PluginRuntime } from 'openclaw/plugin-sdk/core';
4
+
5
+ /**
6
+ * Determine whether a prefix command is allowed.
7
+ *
8
+ * Risky commands (!model, !stop) require operator authorization.
9
+ */
10
+ export declare function authorizeCommand(params: {
11
+ account: ResolvedRocketChatAccount;
12
+ chatType: RocketChatChatType;
13
+ sender: RocketChatSender;
14
+ command: 'status' | 'model' | 'stop';
15
+ }): PolicyDecision;
16
+
17
+ /**
18
+ * Decide whether an inbound message is authorized to be processed.
19
+ *
20
+ * This is the single top-level policy function for v1.
21
+ */
22
+ export declare function authorizeInboundMessage(params: {
23
+ account: ResolvedRocketChatAccount;
24
+ chatType: RocketChatChatType;
25
+ roomId: string;
26
+ sender: RocketChatSender;
27
+ text: string;
28
+ }): PolicyDecision;
29
+
30
+ /**
31
+ * Build a REST request for Rocket.Chat `GET /api/v1/me`.
32
+ */
33
+ export declare function buildMeRequest(params: RocketChatMeParams): RocketChatMeRequest;
34
+
35
+ /**
36
+ * Build a REST request for Rocket.Chat `chat.postMessage`.
37
+ *
38
+ * Reference: https://developer.rocket.chat/reference/api/rest-api/endpoints/messaging/chat-endpoints/postmessage
39
+ */
40
+ export declare function buildPostMessageRequest(params: RocketChatPostMessageParams): RocketChatPostMessageRequest;
41
+
42
+ /**
43
+ * Build a REST request for Rocket.Chat `chat.react`.
44
+ *
45
+ * Reference: https://developer.rocket.chat/apidocs/react-to-message
46
+ */
47
+ export declare function buildReactRequest(params: RocketChatReactParams): RocketChatReactRequest;
48
+
49
+ /**
50
+ * Determine chat type for a room.
51
+ *
52
+ * v1: this is config-driven. The caller can supply an explicit room type map.
53
+ */
54
+ export declare function classifyChatType(params: {
55
+ roomId: string;
56
+ roomTypeById?: Record<string, RocketChatChatType>;
57
+ }): RocketChatChatType;
58
+
59
+ /**
60
+ * Compute the canonical conversation ids for OpenClaw session grammar.
61
+ */
62
+ export declare function computeSessionConversation(params: {
63
+ roomId: string;
64
+ threadId?: string;
65
+ }): RocketChatSessionConversation;
66
+
67
+ /**
68
+ * Options for periodic credential revalidation.
69
+ */
70
+ export declare interface CredentialRevalidationOptions {
71
+ /** Revalidation cadence in milliseconds. */
72
+ intervalMs: number;
73
+ }
74
+
75
+ /** DDP connect frame. */
76
+ export declare interface DdpConnectFrame {
77
+ msg: 'connect';
78
+ version: '1';
79
+ support: ['1'];
80
+ }
81
+
82
+ /**
83
+ * Log in using a resume token.
84
+ *
85
+ * In v1 we treat the Rocket.Chat PAT as the resume token for DDP login.
86
+ */
87
+ export declare function ddpLoginWithResume(params: {
88
+ ddp: DdpMethodClient;
89
+ resumeToken: string;
90
+ }): Promise<unknown>;
91
+
92
+ /**
93
+ * Correlates DDP method calls with result frames.
94
+ */
95
+ export declare class DdpMethodClient {
96
+ private readonly transport;
97
+ private nextId;
98
+ private pending;
99
+ constructor(transport: DdpTransport);
100
+ /**
101
+ * Call a DDP method.
102
+ */
103
+ call(method: string, params?: unknown[]): Promise<unknown>;
104
+ }
105
+
106
+ export declare interface DdpMethodFrame {
107
+ msg: 'method';
108
+ method: string;
109
+ id: string;
110
+ params?: unknown[];
111
+ }
112
+
113
+ /** DDP ping frame. */
114
+ export declare interface DdpPingFrame {
115
+ msg: 'ping';
116
+ }
117
+
118
+ /** DDP pong frame. */
119
+ export declare interface DdpPongFrame {
120
+ msg: 'pong';
121
+ }
122
+
123
+ export declare interface DdpReadyFrame {
124
+ msg: 'ready';
125
+ subs: string[];
126
+ }
127
+
128
+ export declare interface DdpResultFrame {
129
+ msg: 'result';
130
+ id: string;
131
+ result?: unknown;
132
+ error?: unknown;
133
+ }
134
+
135
+ export declare interface DdpSubFrame {
136
+ msg: 'sub';
137
+ id: string;
138
+ name: string;
139
+ params: unknown[];
140
+ }
141
+
142
+ /**
143
+ * Minimal subscription client.
144
+ */
145
+ export declare class DdpSubscriptionClient {
146
+ private readonly transport;
147
+ private nextId;
148
+ constructor(transport: DdpTransport);
149
+ /**
150
+ * Subscribe to a DDP stream.
151
+ *
152
+ * Resolves once the server acknowledges the subscription via a `ready` frame.
153
+ */
154
+ subscribe(name: string, params: unknown[]): Promise<{
155
+ subId: string;
156
+ }>;
157
+ /**
158
+ * Subscribe to the stream of room messages.
159
+ */
160
+ subscribeRoomMessages(roomId: string): Promise<{
161
+ subId: string;
162
+ }>;
163
+ }
164
+
165
+ /**
166
+ * A minimal transport interface for Rocket.Chat DDP.
167
+ *
168
+ * This abstraction keeps DDP protocol logic unit-testable without a real WebSocket.
169
+ */
170
+ export declare interface DdpTransport {
171
+ /**
172
+ * Register a callback for incoming DDP frames.
173
+ *
174
+ * The callback MUST be invoked for every parsed JSON frame.
175
+ */
176
+ onMessage(cb: (msg: unknown) => void): void;
177
+ /**
178
+ * Register a callback invoked when the underlying transport closes.
179
+ */
180
+ onClose(cb: (info?: {
181
+ code?: number;
182
+ reason?: string;
183
+ }) => void): void;
184
+ /**
185
+ * Send a JSON-serializable frame.
186
+ */
187
+ send(msg: unknown): void;
188
+ /**
189
+ * Close the underlying transport.
190
+ */
191
+ close(info?: {
192
+ code?: number;
193
+ reason?: string;
194
+ }): void;
195
+ }
196
+
197
+ /**
198
+ * Decode a `stream-room-messages` event payload into a normalized message shape.
199
+ *
200
+ * We support a couple of common payload shapes:
201
+ * - direct message object
202
+ * - DDP changed envelope with fields.args[0] = message
203
+ */
204
+ export declare function decodeRoomMessageEvent(raw: unknown): {
205
+ roomId: string;
206
+ messageId: string;
207
+ text: string;
208
+ sender: RocketChatSender;
209
+ threadId?: string;
210
+ } | null;
211
+
212
+ /**
213
+ * OpenClaw Rocket.Chat channel plugin entrypoint.
214
+ *
215
+ * This is a packaging skeleton only.
216
+ * - No Rocket.Chat networking is implemented yet.
217
+ * - The plugin exists so OpenClaw can discover/install the package as a channel plugin.
218
+ */
219
+ declare const _default: {
220
+ id: string;
221
+ name: string;
222
+ description: string;
223
+ configSchema: OpenClawPluginConfigSchema;
224
+ register: (api: OpenClawPluginApi) => void;
225
+ channelPlugin: never;
226
+ setChannelRuntime?: (runtime: PluginRuntime) => void;
227
+ };
228
+ export default _default;
229
+
230
+ /**
231
+ * Default DM policy for Rocket.Chat.
232
+ *
233
+ * v1 default is `pairing` (Slack-aligned).
234
+ */
235
+ export declare const DEFAULT_DM_POLICY: RocketChatDmPolicy;
236
+
237
+ /**
238
+ * Default group policy for Rocket.Chat.
239
+ *
240
+ * v1 default is `allowlist` (fail closed).
241
+ */
242
+ export declare const DEFAULT_GROUP_POLICY: RocketChatGroupPolicy;
243
+
244
+ /**
245
+ * Default setting for mention gating in group chats.
246
+ */
247
+ export declare const DEFAULT_REQUIRE_MENTION = true;
248
+
249
+ /**
250
+ * Map a parsed Rocket.Chat prefix command into an OpenClaw command message.
251
+ */
252
+ export declare function dispatchPrefixCommand(params: {
253
+ account: ResolvedRocketChatAccount;
254
+ chatType: RocketChatChatType;
255
+ sender: RocketChatSender;
256
+ parsed: RocketChatPrefixCommand;
257
+ }): RocketChatCommandDispatch;
258
+
259
+ /**
260
+ * A deterministic in-memory transport for unit testing DDP protocol logic.
261
+ */
262
+ export declare class FakeDdpTransport implements DdpTransport {
263
+ private messageHandlers;
264
+ private closeHandlers;
265
+ /** Outbound frames sent by the client. */
266
+ readonly sent: unknown[];
267
+ /** Whether close() has been called. */
268
+ closed: boolean;
269
+ onMessage(cb: (msg: unknown) => void): void;
270
+ onClose(cb: (info?: {
271
+ code?: number;
272
+ reason?: string;
273
+ }) => void): void;
274
+ send(msg: unknown): void;
275
+ close(info?: {
276
+ code?: number;
277
+ reason?: string;
278
+ }): void;
279
+ /**
280
+ * Inject an inbound message as if it arrived from Rocket.Chat.
281
+ */
282
+ inject(msg: unknown): void;
283
+ }
284
+
285
+ /**
286
+ * Validate current credentials by calling Rocket.Chat `GET /api/v1/me`.
287
+ */
288
+ export declare function getMe(params: RocketChatMeParams & {
289
+ fetcher?: (input: string, init?: RequestInit) => Promise<Response>;
290
+ }): Promise<unknown>;
291
+
292
+ /**
293
+ * Result of attempting to normalize an inbound message.
294
+ */
295
+ export declare type InboundNormalizeResult = {
296
+ ok: true;
297
+ value: RocketChatInboundMessage;
298
+ } | {
299
+ ok: false;
300
+ reason: string;
301
+ };
302
+
303
+ /**
304
+ * Install baseline protocol handlers.
305
+ *
306
+ * Responsibilities:
307
+ * - send initial connect
308
+ * - respond to ping with pong
309
+ */
310
+ export declare function installDdpProtocol(params: {
311
+ transport: DdpTransport;
312
+ }): {
313
+ sendConnect: () => void;
314
+ };
315
+
316
+ /**
317
+ * Create the initial DDP connect frame.
318
+ */
319
+ export declare function makeConnectFrame(): DdpConnectFrame;
320
+
321
+ /**
322
+ * Parse Rocket.Chat prefix commands.
323
+ *
324
+ * Rules:
325
+ * - Only treat as command if the trimmed message begins with '!'.
326
+ * - Commands supported: !status, !stop, !model <name>
327
+ */
328
+ export declare function parsePrefixCommand(text: string): RocketChatPrefixCommand;
329
+
330
+ /**
331
+ * The result of applying policy checks to an inbound message.
332
+ */
333
+ export declare interface PolicyDecision {
334
+ allowed: boolean;
335
+ reason?: string;
336
+ }
337
+
338
+ /**
339
+ * Post a message using Rocket.Chat REST API.
340
+ *
341
+ * This function accepts an optional fetch implementation to keep unit tests deterministic.
342
+ */
343
+ export declare function postMessage(params: RocketChatPostMessageParams & {
344
+ fetcher?: (input: string, init?: RequestInit) => Promise<Response>;
345
+ }): Promise<unknown>;
346
+
347
+ /**
348
+ * Normalize, classify, and authorize an inbound Rocket.Chat message event.
349
+ */
350
+ export declare function processInboundRoomMessage(params: {
351
+ account: ResolvedRocketChatAccount;
352
+ rawEvent: unknown;
353
+ roomTypeById?: Record<string, 'direct' | 'group'>;
354
+ }): InboundNormalizeResult;
355
+
356
+ /**
357
+ * Set or unset a reaction using Rocket.Chat REST API.
358
+ */
359
+ export declare function reactToMessage(params: RocketChatReactParams & {
360
+ fetcher?: (input: string, init?: RequestInit) => Promise<Response>;
361
+ }): Promise<unknown>;
362
+
363
+ /**
364
+ * Compute the effective channel config.
365
+ *
366
+ * This applies defaults, but does not validate credentials.
367
+ */
368
+ export declare function resolveChannelDefaults(cfg: RocketChatChannelConfig | undefined): Required<Pick<RocketChatChannelConfig, 'dmPolicy' | 'groupPolicy'>> & RocketChatChannelConfig;
369
+
370
+ /**
371
+ * Resolved account config for a specific OpenClaw agent id.
372
+ */
373
+ export declare interface ResolvedRocketChatAccount {
374
+ /** OpenClaw agent id / account id key. */
375
+ accountId: string;
376
+ /** Whether this account is enabled after all merges. */
377
+ enabled: boolean;
378
+ /** Rocket.Chat server base URL (https://...). */
379
+ serverUrl: string;
380
+ /** Rocket.Chat bot user id. */
381
+ userId: string;
382
+ /** Rocket.Chat bot username (for mention gating). */
383
+ username: string;
384
+ /** Rocket.Chat personal access token. */
385
+ pat: string;
386
+ /** Effective DM policy. */
387
+ dmPolicy: NonNullable<RocketChatChannelConfig['dmPolicy']>;
388
+ /** Effective group policy. */
389
+ groupPolicy: NonNullable<RocketChatChannelConfig['groupPolicy']>;
390
+ /** Effective sender allowlist. */
391
+ allowFrom: string[];
392
+ /** Effective operator allowlist for risky commands. */
393
+ commandAllowFrom: string[];
394
+ /** Effective per-room config. */
395
+ rooms: Record<string, RocketChatRoomConfig>;
396
+ /** Default mention gating for group chats when room override is not present. */
397
+ defaultRequireMention: boolean;
398
+ }
399
+
400
+ /**
401
+ * Resolve the effective Rocket.Chat account configuration for a given agent id.
402
+ *
403
+ * Merging rules:
404
+ * - Top-level `channels.rocketchat` is the base.
405
+ * - `channels.rocketchat.accounts[accountId]` overrides base.
406
+ *
407
+ * Validation rules:
408
+ * - If the merged account is enabled, it must have: serverUrl, userId, username, pat.
409
+ */
410
+ export declare function resolveRocketChatAccount(params: {
411
+ cfg: RocketChatOpenClawConfig;
412
+ accountId: string;
413
+ }): ResolvedRocketChatAccount;
414
+
415
+ /**
416
+ * Close the transport immediately when we determine the account is unauthorized.
417
+ *
418
+ * v1 spec requirement:
419
+ * - On any auth error/unauthorized response on the WebSocket (or any REST call),
420
+ * the plugin MUST immediately close the WebSocket and stop processing events
421
+ * for that account.
422
+ */
423
+ export declare function revokeOnUnauthorized(params: {
424
+ transport: DdpTransport;
425
+ reason: string;
426
+ }): void;
427
+
428
+ /**
429
+ * Per-account Rocket.Chat credentials and overrides.
430
+ */
431
+ export declare interface RocketChatAccountConfig {
432
+ /** Enable/disable this account. */
433
+ enabled?: boolean;
434
+ /** Rocket.Chat server base URL (must be https:// for production). */
435
+ serverUrl?: string;
436
+ /** Rocket.Chat user id for the bot account. */
437
+ userId?: string;
438
+ /** Rocket.Chat username for the bot account (used for mention gating). */
439
+ username?: string;
440
+ /**
441
+ * Rocket.Chat personal access token.
442
+ *
443
+ * Treated as a credential equivalent to a password.
444
+ */
445
+ pat?: string;
446
+ /** DM access policy override for this account. */
447
+ dmPolicy?: RocketChatDmPolicy;
448
+ /** Group chat access policy override for this account. */
449
+ groupPolicy?: RocketChatGroupPolicy;
450
+ /** Sender allowlist override for this account. */
451
+ allowFrom?: string[];
452
+ /** Operator allowlist override for this account (for !model / !stop). */
453
+ commandAllowFrom?: string[];
454
+ /** Room allowlist override for this account. */
455
+ rooms?: Record<string, RocketChatRoomConfig>;
456
+ }
457
+
458
+ /**
459
+ * Top-level channel config under `channels.rocketchat`.
460
+ */
461
+ export declare interface RocketChatChannelConfig {
462
+ /** Globally enable/disable the channel plugin. */
463
+ enabled?: boolean;
464
+ /** Default Rocket.Chat server base URL (https://...). */
465
+ serverUrl?: string;
466
+ /** Default DM policy (v1 default is pairing). */
467
+ dmPolicy?: RocketChatDmPolicy;
468
+ /** Default group policy (v1 default is allowlist). */
469
+ groupPolicy?: RocketChatGroupPolicy;
470
+ /** Global allowlist of senders permitted to interact. */
471
+ allowFrom?: string[];
472
+ /** Global operator allowlist for !model/!stop. */
473
+ commandAllowFrom?: string[];
474
+ /** Per-room allowlists and mention gating overrides. */
475
+ rooms?: Record<string, RocketChatRoomConfig>;
476
+ /** Per-account config keyed by OpenClaw agent id. */
477
+ accounts?: Record<string, RocketChatAccountConfig>;
478
+ }
479
+
480
+ /**
481
+ * Chat type classification used by the Rocket.Chat channel plugin.
482
+ *
483
+ * - `direct`: 1:1 DM
484
+ * - `group`: any multi-user room (public channel or private group)
485
+ */
486
+ export declare type RocketChatChatType = 'direct' | 'group';
487
+
488
+ /**
489
+ * Minimal Rocket.Chat client used by the OpenClaw channel plugin.
490
+ *
491
+ * v1 scope:
492
+ * - DDP connect + ping/pong
493
+ * - DDP login using resume token (PAT)
494
+ * - subscribe to stream-room-messages
495
+ *
496
+ * This class is intentionally transport-agnostic so it can be unit-tested.
497
+ */
498
+ export declare class RocketChatClient {
499
+ private readonly ddp;
500
+ private readonly subs;
501
+ private readonly protocol;
502
+ constructor(transport: DdpTransport);
503
+ /**
504
+ * Start the DDP session by sending the connect frame.
505
+ */
506
+ connect(): void;
507
+ /**
508
+ * Authenticate the DDP session.
509
+ */
510
+ loginWithResume(resumeToken: string): Promise<void>;
511
+ /**
512
+ * Subscribe to inbound room message streams for the provided rooms.
513
+ */
514
+ subscribeRoomMessages(roomIds: string[]): Promise<void>;
515
+ /**
516
+ * Convenience helper for the common connect/login/subscribe sequence.
517
+ */
518
+ start(params: {
519
+ resumeToken: string;
520
+ roomIds: string[];
521
+ }): Promise<void>;
522
+ }
523
+
524
+ /**
525
+ * Normalized command dispatch instruction.
526
+ */
527
+ export declare type RocketChatCommandDispatch = {
528
+ ok: true;
529
+ kind: 'openclaw-command';
530
+ commandText: string;
531
+ } | {
532
+ ok: false;
533
+ reason: string;
534
+ };
535
+
536
+ /**
537
+ * Supported DM access policies.
538
+ *
539
+ * This mirrors the Slack-style semantics referenced in the project spec:
540
+ * - `pairing`: requires pairing approval for new DM contacts (v1 may stub the pairing flow).
541
+ * - `allowlist`: only allowlisted users may DM.
542
+ * - `open`: allow any DM sender (still subject to safety controls; requires explicit allowlist `"*"`).
543
+ * - `disabled`: no DMs are processed.
544
+ */
545
+ export declare type RocketChatDmPolicy = 'pairing' | 'allowlist' | 'open' | 'disabled';
546
+
547
+ /**
548
+ * Supported group chat policies.
549
+ *
550
+ * Group chat = any multi-user room (public channels + private groups).
551
+ */
552
+ export declare type RocketChatGroupPolicy = 'open' | 'allowlist' | 'disabled';
553
+
554
+ /**
555
+ * Normalized inbound message event.
556
+ */
557
+ export declare interface RocketChatInboundMessage {
558
+ /** Rocket.Chat room id. */
559
+ roomId: string;
560
+ /** Rocket.Chat message id. */
561
+ messageId: string;
562
+ /** Message text. */
563
+ text: string;
564
+ /** Sender identity. */
565
+ sender: RocketChatSender;
566
+ /** Chat type (DM vs group). */
567
+ chatType: RocketChatChatType;
568
+ /** Optional thread id when the message belongs to a thread. */
569
+ threadId?: string;
570
+ }
571
+
572
+ export declare interface RocketChatMeParams {
573
+ serverUrl: string;
574
+ userId: string;
575
+ authToken: string;
576
+ }
577
+
578
+ export declare interface RocketChatMeRequest {
579
+ url: string;
580
+ method: 'GET';
581
+ headers: Record<string, string>;
582
+ }
583
+
584
+ /**
585
+ * Minimal OpenClaw config shape needed by this library.
586
+ *
587
+ * We intentionally avoid importing OpenClaw config types directly in v1 so this
588
+ * package can be unit-tested without binding to OpenClaw internal type shapes.
589
+ */
590
+ export declare interface RocketChatOpenClawConfig {
591
+ channels?: {
592
+ rocketchat?: RocketChatChannelConfig;
593
+ };
594
+ }
595
+
596
+ export declare interface RocketChatPostMessageParams {
597
+ /** Rocket.Chat base server URL, for example https://chat.example.com */
598
+ serverUrl: string;
599
+ /** Rocket.Chat user id for auth. */
600
+ userId: string;
601
+ /** Rocket.Chat personal access token for auth. */
602
+ authToken: string;
603
+ /** Room id to post into. */
604
+ roomId: string;
605
+ /** Message text. */
606
+ text: string;
607
+ /** Optional thread message id (Rocket.Chat tmid). */
608
+ threadId?: string;
609
+ }
610
+
611
+ export declare interface RocketChatPostMessageRequest {
612
+ url: string;
613
+ method: 'POST';
614
+ headers: Record<string, string>;
615
+ body: string;
616
+ }
617
+
618
+ export declare type RocketChatPrefixCommand = {
619
+ kind: 'command';
620
+ name: 'status';
621
+ raw: string;
622
+ } | {
623
+ kind: 'command';
624
+ name: 'stop';
625
+ raw: string;
626
+ } | {
627
+ kind: 'command';
628
+ name: 'model';
629
+ raw: string;
630
+ model: string;
631
+ } | {
632
+ kind: 'not-a-command';
633
+ };
634
+
635
+ export declare type RocketChatPrefixCommandName = 'status' | 'model' | 'stop';
636
+
637
+ export declare interface RocketChatReactParams {
638
+ /** Rocket.Chat base server URL, for example https://chat.example.com */
639
+ serverUrl: string;
640
+ /** Rocket.Chat user id for auth. */
641
+ userId: string;
642
+ /** Rocket.Chat personal access token for auth. */
643
+ authToken: string;
644
+ /** Message id to react to. */
645
+ messageId: string;
646
+ /** Emoji name (without surrounding colons), e.g. "smile". */
647
+ emoji: string;
648
+ /** Whether to add or remove the reaction. */
649
+ shouldReact: boolean;
650
+ }
651
+
652
+ export declare interface RocketChatReactRequest {
653
+ url: string;
654
+ method: 'POST';
655
+ headers: Record<string, string>;
656
+ body: string;
657
+ }
658
+
659
+ /**
660
+ * Per-room configuration.
661
+ */
662
+ export declare interface RocketChatRoomConfig {
663
+ /**
664
+ * Optional allowlist of Rocket.Chat user identifiers allowed to interact in this room.
665
+ *
666
+ * When omitted, the account/global allowlists are used.
667
+ */
668
+ users?: string[];
669
+ /**
670
+ * Override for mention gating in this room.
671
+ *
672
+ * When true, group chat messages must include `@<botUsername>` to be processed.
673
+ */
674
+ requireMention?: boolean;
675
+ }
676
+
677
+ /**
678
+ * Normalized sender identity.
679
+ *
680
+ * We keep this intentionally minimal so it can map to multiple Rocket.Chat payload shapes.
681
+ */
682
+ export declare interface RocketChatSender {
683
+ /** Rocket.Chat user id. */
684
+ id: string;
685
+ /** Rocket.Chat username (without @). */
686
+ username?: string;
687
+ }
688
+
689
+ /**
690
+ * Rocket.Chat session key components.
691
+ */
692
+ export declare interface RocketChatSessionConversation {
693
+ /** Base conversation id (room). */
694
+ baseConversationId: string;
695
+ /** Optional thread id (when replying in a thread). */
696
+ threadId?: string;
697
+ }
698
+
699
+ /**
700
+ * Factory for creating a transport per account.
701
+ */
702
+ export declare type RocketChatTransportFactory = (params: {
703
+ account: ResolvedRocketChatAccount;
704
+ }) => DdpTransport;
705
+
706
+ /**
707
+ * Start a periodic credential revalidation loop.
708
+ *
709
+ * This provides a bound on worst-case revocation latency for long-lived sessions.
710
+ * v1 target: <= 5 minutes.
711
+ */
712
+ export declare function startCredentialRevalidation(params: {
713
+ transport: DdpTransport;
714
+ validateOnce: () => Promise<{
715
+ ok: true;
716
+ } | {
717
+ ok: false;
718
+ reason: string;
719
+ }>;
720
+ options: CredentialRevalidationOptions;
721
+ }): {
722
+ stop: () => void;
723
+ };
724
+
725
+ /**
726
+ * Start (connect/login/subscribe) a Rocket.Chat client for a single account.
727
+ *
728
+ * v1 security requirements:
729
+ * - periodic credential revalidation to bound revocation latency
730
+ */
731
+ export declare function startRocketChatAccount(params: {
732
+ account: ResolvedRocketChatAccount;
733
+ roomIds: string[];
734
+ createTransport: RocketChatTransportFactory;
735
+ /** Override credential revalidation cadence. Default is 5 minutes. */
736
+ revalidateIntervalMs?: number;
737
+ /** Optional fetch injection for credential validation. */
738
+ fetcher?: (input: string, init?: RequestInit) => Promise<Response>;
739
+ }): Promise<{
740
+ client: RocketChatClient;
741
+ stop: () => void;
742
+ }>;
743
+
744
+ /**
745
+ * The current version of the package.
746
+ *
747
+ * @tip This constant is replaced during the build process with the actual version of the package.
748
+ */
749
+ export declare const version: string;
750
+
751
+ export { }