@kartik.doda/openclaw-plugin-test 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -0
  3. package/dist/cli/admin-api.d.ts +58 -0
  4. package/dist/cli/admin-api.d.ts.map +1 -0
  5. package/dist/cli/admin-api.js +242 -0
  6. package/dist/cli/admin-api.js.map +1 -0
  7. package/dist/cli/auth.d.ts +5 -0
  8. package/dist/cli/auth.d.ts.map +1 -0
  9. package/dist/cli/auth.js +184 -0
  10. package/dist/cli/auth.js.map +1 -0
  11. package/dist/cli/bot.d.ts +3 -0
  12. package/dist/cli/bot.d.ts.map +1 -0
  13. package/dist/cli/bot.js +100 -0
  14. package/dist/cli/bot.js.map +1 -0
  15. package/dist/cli/config-updater.d.ts +70 -0
  16. package/dist/cli/config-updater.d.ts.map +1 -0
  17. package/dist/cli/config-updater.js +277 -0
  18. package/dist/cli/config-updater.js.map +1 -0
  19. package/dist/cli/credentials.d.ts +14 -0
  20. package/dist/cli/credentials.d.ts.map +1 -0
  21. package/dist/cli/credentials.js +45 -0
  22. package/dist/cli/credentials.js.map +1 -0
  23. package/dist/cli/rate-limiter.d.ts +17 -0
  24. package/dist/cli/rate-limiter.d.ts.map +1 -0
  25. package/dist/cli/rate-limiter.js +78 -0
  26. package/dist/cli/rate-limiter.js.map +1 -0
  27. package/dist/cli/setup.d.ts +2 -0
  28. package/dist/cli/setup.d.ts.map +1 -0
  29. package/dist/cli/setup.js +292 -0
  30. package/dist/cli/setup.js.map +1 -0
  31. package/dist/cli/ui.d.ts +30 -0
  32. package/dist/cli/ui.d.ts.map +1 -0
  33. package/dist/cli/ui.js +202 -0
  34. package/dist/cli/ui.js.map +1 -0
  35. package/dist/client/ddp.d.ts +31 -0
  36. package/dist/client/ddp.d.ts.map +1 -0
  37. package/dist/client/ddp.js +86 -0
  38. package/dist/client/ddp.js.map +1 -0
  39. package/dist/client/rest.d.ts +49 -0
  40. package/dist/client/rest.d.ts.map +1 -0
  41. package/dist/client/rest.js +347 -0
  42. package/dist/client/rest.js.map +1 -0
  43. package/dist/config/access-store.d.ts +29 -0
  44. package/dist/config/access-store.d.ts.map +1 -0
  45. package/dist/config/access-store.js +71 -0
  46. package/dist/config/access-store.js.map +1 -0
  47. package/dist/config/schema.d.ts +33 -0
  48. package/dist/config/schema.d.ts.map +1 -0
  49. package/dist/config/schema.js +52 -0
  50. package/dist/config/schema.js.map +1 -0
  51. package/dist/config/store.d.ts +11 -0
  52. package/dist/config/store.d.ts.map +1 -0
  53. package/dist/config/store.js +82 -0
  54. package/dist/config/store.js.map +1 -0
  55. package/dist/index.d.ts +4 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +17 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/plugin.d.ts +5 -0
  60. package/dist/plugin.d.ts.map +1 -0
  61. package/dist/plugin.js +164 -0
  62. package/dist/plugin.js.map +1 -0
  63. package/dist/service/attachments.d.ts +10 -0
  64. package/dist/service/attachments.d.ts.map +1 -0
  65. package/dist/service/attachments.js +105 -0
  66. package/dist/service/attachments.js.map +1 -0
  67. package/dist/service/channel.d.ts +25 -0
  68. package/dist/service/channel.d.ts.map +1 -0
  69. package/dist/service/channel.js +747 -0
  70. package/dist/service/channel.js.map +1 -0
  71. package/dist/service/gateway.d.ts +7 -0
  72. package/dist/service/gateway.d.ts.map +1 -0
  73. package/dist/service/gateway.js +621 -0
  74. package/dist/service/gateway.js.map +1 -0
  75. package/dist/service/group-history.d.ts +8 -0
  76. package/dist/service/group-history.d.ts.map +1 -0
  77. package/dist/service/group-history.js +24 -0
  78. package/dist/service/group-history.js.map +1 -0
  79. package/dist/service/inbound.d.ts +16 -0
  80. package/dist/service/inbound.d.ts.map +1 -0
  81. package/dist/service/inbound.js +189 -0
  82. package/dist/service/inbound.js.map +1 -0
  83. package/dist/service/runtime-state.d.ts +8 -0
  84. package/dist/service/runtime-state.d.ts.map +1 -0
  85. package/dist/service/runtime-state.js +3 -0
  86. package/dist/service/runtime-state.js.map +1 -0
  87. package/dist/types.d.ts +220 -0
  88. package/dist/types.d.ts.map +1 -0
  89. package/dist/types.js +2 -0
  90. package/dist/types.js.map +1 -0
  91. package/dist/utils.d.ts +15 -0
  92. package/dist/utils.d.ts.map +1 -0
  93. package/dist/utils.js +68 -0
  94. package/dist/utils.js.map +1 -0
  95. package/package.json +57 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rocket.Chat
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # Rocket.Chat Plugin for OpenClaw
2
+
3
+ A [OpenClaw](https://opencode.ai) channel plugin that connects [Rocket.Chat](https://rocket.chat) directly — **no external bridge server**. The plugin speaks to Rocket.Chat over a real-time **WebSocket/DDP** connection for both inbound and outbound traffic, and routes messages into OpenClaw's agent runtime.
4
+
5
+ - Inbound: real-time DDP stream, deduplicated via an on-disk checkpoint, filtered (bot's own messages, system events, empty/duplicate messages), and dispatched to the agent.
6
+ - Outbound: agent replies posted back into the same Rocket.Chat room/thread.
7
+ - Control: a built-in `!`-command interface for bot management (no native slash commands).
8
+
9
+ ## Installation
10
+
11
+ Install the plugin:
12
+
13
+ ```bash
14
+ openclaw plugins install <plugin-package>
15
+ ```
16
+
17
+ > This plugin will soon be published to npm. Once the official package is available you'll install it the same way — the setup steps below remain identical.
18
+
19
+ ## Setup
20
+
21
+ The plugin ships an interactive wizard that provisions everything for you — no manual editing of `openclaw.json` required.
22
+
23
+ ### Prerequisites
24
+ - A Rocket.Chat server you have **admin** access to. The wizard uses admin rights **once**, only to create the bot account.
25
+ - An AI provider and a default agent already configured in OpenClaw. (The wizard can create a dedicated agent for the bot, or bind it to one you pick.)
26
+
27
+ ### Run the wizard
28
+
29
+ ```bash
30
+ openclaw rocketchat setup
31
+ ```
32
+
33
+ The wizard will:
34
+ 1. Ask for your Rocket.Chat **server URL** and an **admin** login.
35
+ 2. Create a dedicated **bot user** on your server and issue a personal access token for it.
36
+ 3. Create a dedicated OpenClaw **agent** for the bot (e.g. `rc-<bot>`) — or bind it to an existing agent.
37
+ 4. Write the channel account and `bindings` into `~/.openclaw/openclaw.json`.
38
+ 5. Optionally invite the bot into a group or channel.
39
+
40
+ > The bot is just a normal Rocket.Chat user — invite or @-mention it like anyone else. Its access token is stored by the plugin under the OpenClaw config dir, so you never handle it by hand.
41
+
42
+ ### Verify
43
+
44
+ In Rocket.Chat, DM the bot (or @-mention it in a group it's been invited to) and send:
45
+
46
+ ```
47
+ !status
48
+ ```
49
+
50
+ You should see `gateway - online` and `runtime - ready`. If you don't, see Troubleshooting below.
51
+
52
+ ## Configuration (manual)
53
+
54
+ Prefer the wizard above — but if you want to edit config by hand, a complete, annotated reference of the plugin's settings is shipped in **[`openclaw.example.json`](./openclaw.example.json)**. Merge its `channels.rocketchat` and `bindings` blocks into your `~/.openclaw/openclaw.json` and set:
55
+
56
+ - `channels.rocketchat.accounts.main.serverUrl` → your Rocket.Chat URL.
57
+ - `auth.userId` / `auth.accessToken` → the bot user's ID and personal access token (created via `openclaw rocketchat setup`, or in Rocket.Chat → My Account → Personal Access Tokens).
58
+ - `bindings[0].agentId` → the agent the bot should use.
59
+
60
+ The `bindings` entry is what connects the bot account to an agent — **without it the bot will not respond.** Plugin registration is handled by `openclaw plugins install`, so you don't need to touch `plugins.load`.
61
+
62
+ ### Account field reference
63
+
64
+ Each entry under `channels.rocketchat.accounts.<id>`:
65
+
66
+ | Field | Type | Default | Notes |
67
+ |---|---|---|---|
68
+ | `enabled` | boolean | — | Must be `true` to start the gateway. |
69
+ | `serverUrl` | string | — | Rocket.Chat base URL (https recommended). |
70
+ | `auth` | object | — | `mode: "token"` (`userId` + `accessToken`) **or** `mode: "password"` (`username` + `password`). |
71
+ | `transport.mode` | `"websocket"` | — | Only WebSocket/DDP is supported. |
72
+ | `transport.reconnectDelayMs` | number | `2000` | Delay before reconnecting the DDP socket. |
73
+ | `transport.maxConcurrent` | number | `50` | Max rooms processed in parallel per bot account. |
74
+ | `mentionNames` | string[] | `[]` | Names that trigger the bot in group chats (e.g. `["rocketbot"]`). In DMs the bot always responds. |
75
+ | `agent` | string | — | Optional agent override; otherwise the `bindings` entry decides. |
76
+ | `owner` | string | — | Rocket.Chat username that always has access (and is exempt from denials). |
77
+
78
+
79
+ ## `!` commands
80
+
81
+ Send these in a DM to the bot, or @-mention the bot with the command in a group.
82
+
83
+ **Bot management**
84
+ | Command | Description |
85
+ |---|---|
86
+ | `!help` | Show the command menu. |
87
+ | `!status` | OpenClaw-side status: gateway, bot, agent, runtime. |
88
+ | `!access` | Who is allowed to use the bot. |
89
+ | `!add-bot <user>` | Create a new bot account + dedicated agent. |
90
+ | `!remove-bot <user...>` | Delete bot account(s). |
91
+ | `!add-group <group> [bot]` | Invite a bot into a group. |
92
+ | `!kick <user> [group]` | Remove a user from a group. |
93
+ | `!lend <group\|dm> <user>` | Grant access to a group or DM. |
94
+ | `!revoke <group\|dm> <user>` | Revoke access. |
95
+
96
+ **Context & model**
97
+ | Command | Description |
98
+ |---|---|
99
+ | `!compact` | Compress conversation history. |
100
+ | `!reset` | Wipe all context. |
101
+ | `!new [model]` | Fresh session (optionally switch model). |
102
+ | `!model [name\|#]` | List or switch the model. |
103
+
104
+ **Behavior**
105
+ | Command | Description |
106
+ |---|---|
107
+ | `!think <level>` | Set reasoning depth (`off`..`high`). |
108
+ | `!abort` | Stop the in-flight reply. |
109
+ | `!reasoning on/off` | Show/hide reasoning text. |
110
+ | `!verbose on/off` | Show/hide debug detail. |
111
+
112
+ **Tools & skills**
113
+ | Command | Description |
114
+ |---|---|
115
+ | `!tools` | List the agent's tools. |
116
+ | `!skills` | List installed skills. |
117
+ | `!skill <name>` | Run a skill. |
118
+
119
+ ## Troubleshooting
120
+
121
+ - **`!status` shows `gateway - offline`/`stopped`** — the DDP socket isn't connected. Check `serverUrl`, that the bot user exists, and that OpenClaw was restarted after config changes (`openclaw restart`). Look at OpenClaw logs for `[rocketchat:<id>] ddp status: …`.
122
+ - **Bot doesn't reply in a group** — make sure you @-mention it using one of its `mentionNames`, and that `bindings` points the account at a valid agent.
123
+ - **`runtime - unavailable`** — the agent runtime wasn't ready when the message arrived; restart OpenClaw and retry.
124
+ - **Duplicate/replayed messages** — the plugin deduplicates via `~/.openclaw/rocketchat/<id>.db`; if you suspect staleness, that file is the checkpoint.
125
+
126
+ ## Learn more
127
+
128
+ - Blog: https://readyy.hashnode.dev/building-rocket-chat-channel-plugin-for-openclaw
@@ -0,0 +1,58 @@
1
+ import type { RCLoginResult, RCUser } from "../types.js";
2
+ export declare function isTimeoutError(e: unknown): boolean;
3
+ export type LoginChallenge = {
4
+ transactionId: string;
5
+ methods: string[];
6
+ };
7
+ export declare class TwoFactorRequiredError extends Error {
8
+ readonly challenge: LoginChallenge;
9
+ constructor(message: string, challenge: LoginChallenge);
10
+ }
11
+ export type LoginAsOptions = {
12
+ /** Optional TOTP / email 2FA code for an in-progress challenge. */
13
+ code?: string;
14
+ /** Transaction id returned by a prior 2FA challenge. */
15
+ transactionId?: string;
16
+ };
17
+ export declare function loginAs(baseUrl: string, user: string, password: string, opts?: LoginAsOptions): Promise<RCLoginResult>;
18
+ export declare function createBotUser(baseUrl: string, auth: RCLoginResult, opts: {
19
+ username: string;
20
+ name: string;
21
+ password: string;
22
+ email: string;
23
+ }): Promise<RCUser>;
24
+ export declare function deleteUser(baseUrl: string, auth: RCLoginResult, username: string): Promise<void>;
25
+ export declare function getUserInfo(baseUrl: string, auth: RCLoginResult, opts: {
26
+ username?: string;
27
+ userId?: string;
28
+ }): Promise<RCUser | null>;
29
+ export type VerifyAdminResult = {
30
+ ok: true;
31
+ } | {
32
+ ok: false;
33
+ reason: "not-admin";
34
+ } | {
35
+ ok: false;
36
+ reason: "unauthorized";
37
+ } | {
38
+ ok: false;
39
+ reason: "unreachable";
40
+ };
41
+ export declare function verifyAdmin(baseUrl: string, auth: RCLoginResult): Promise<VerifyAdminResult>;
42
+ export declare function createDirectMessage(baseUrl: string, auth: RCLoginResult, username: string): Promise<string>;
43
+ export declare function sendMessage(baseUrl: string, auth: RCLoginResult, roomId: string, text: string): Promise<void>;
44
+ export interface RocketChatGroup {
45
+ _id: string;
46
+ name: string;
47
+ isPrivate?: boolean;
48
+ }
49
+ export interface RocketChatMember {
50
+ _id: string;
51
+ username: string;
52
+ name?: string;
53
+ }
54
+ export declare function listGroupMembers(baseUrl: string, auth: RCLoginResult, roomId: string): Promise<RocketChatMember[]>;
55
+ export declare function getGroupByName(baseUrl: string, auth: RCLoginResult, name: string): Promise<RocketChatGroup | null>;
56
+ export declare function inviteToGroup(baseUrl: string, auth: RCLoginResult, groupId: string, username: string, isPrivate?: boolean): Promise<void>;
57
+ export declare function checkServerHealth(baseUrl: string): Promise<boolean>;
58
+ //# sourceMappingURL=admin-api.d.ts.map
@@ -0,0 +1 @@
1
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M,EACf,IAAI,EAAE,aAAa,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAkBjC;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,UAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASzE"}
@@ -0,0 +1,242 @@
1
+ import { RocketChatClientError } from "../client/rest.js";
2
+ import { getErrorMessage } from "../utils.js";
3
+ const REQUEST_TIMEOUT_MS = 15_000;
4
+ export function isTimeoutError(e) {
5
+ return (e instanceof DOMException &&
6
+ (e.name === "TimeoutError" || e.name === "AbortError"));
7
+ }
8
+ function fetchWithTimeout(url, init = {}, timeoutMs = REQUEST_TIMEOUT_MS) {
9
+ const controller = new AbortController();
10
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
11
+ return fetch(url, { ...init, signal: controller.signal }).finally(() => clearTimeout(timer));
12
+ }
13
+ function extractRecord(json, field) {
14
+ const value = json[field];
15
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
16
+ throw new RocketChatClientError(`RC API response missing or invalid "${field}"`);
17
+ }
18
+ return value;
19
+ }
20
+ function extractString(obj, key) {
21
+ const v = obj[key];
22
+ if (typeof v !== "string" || v.length === 0) {
23
+ throw new RocketChatClientError(`RC API response missing or invalid "${key}"`);
24
+ }
25
+ return v;
26
+ }
27
+ async function adminFetch(baseUrl, path, opts = {}) {
28
+ const headers = { "Content-Type": "application/json" };
29
+ if (opts.userId && opts.authToken) {
30
+ headers["X-Auth-Token"] = opts.authToken;
31
+ headers["X-User-Id"] = opts.userId;
32
+ }
33
+ const res = await fetchWithTimeout(new URL(path, baseUrl), {
34
+ method: opts.method ?? "POST",
35
+ headers,
36
+ ...(opts.body ? { body: JSON.stringify(opts.body) } : {}),
37
+ });
38
+ const json = (await res.json());
39
+ if (!opts.raw && (!res.ok || json.success === false)) {
40
+ const msg = getErrorMessage(json, res.statusText);
41
+ throw new RocketChatClientError(`RC API ${path} failed: ${msg}`);
42
+ }
43
+ return json;
44
+ }
45
+ export class TwoFactorRequiredError extends Error {
46
+ challenge;
47
+ constructor(message, challenge) {
48
+ super(message);
49
+ this.name = "TwoFactorRequiredError";
50
+ this.challenge = challenge;
51
+ }
52
+ }
53
+ function parseLoginChallenge(json) {
54
+ const errorType = typeof json.errorType === "string" ? json.errorType : "";
55
+ const status = typeof json.status === "string" ? json.status : "";
56
+ const message = typeof json.error === "string" ? json.error : "";
57
+ // Only treat as a 2FA challenge on Rocket.Chat's explicit challenge signals.
58
+ // A regular failed login (bad password, rate limit, "user not found") must NOT
59
+ // be mistaken for 2FA, otherwise the wizard hangs waiting for a code that was
60
+ // never sent (e.g. a bot account without 2FA provisioned).
61
+ const explicitChallenge = /^(totp-required|code-required|email-required|totp-invalid|code-invalid)$/i.test(errorType) ||
62
+ (status === "error" &&
63
+ /(two-factor|verification code|2fa|totp|enter the code)/i.test(message));
64
+ if (!explicitChallenge)
65
+ return null;
66
+ const details = (json.details ?? {});
67
+ const methodsRaw = details.method ?? details.methods;
68
+ const methods = Array.isArray(methodsRaw)
69
+ ? methodsRaw.filter((m) => typeof m === "string")
70
+ : typeof methodsRaw === "string"
71
+ ? [methodsRaw]
72
+ : ["totp"];
73
+ const transactionId = typeof details.code === "string" && details.code.length > 0
74
+ ? details.code
75
+ : typeof details.token === "string" && details.token.length > 0
76
+ ? details.token
77
+ : "";
78
+ return { transactionId, methods };
79
+ }
80
+ export async function loginAs(baseUrl, user, password, opts = {}) {
81
+ const body = { user, password };
82
+ if (opts.code) {
83
+ body.code = opts.code;
84
+ // Rocket.Chat sends the 2FA transaction id back as `codeAgain`.
85
+ if (opts.transactionId)
86
+ body.codeAgain = opts.transactionId;
87
+ }
88
+ const json = await adminFetch(baseUrl, "/api/v1/login", { body, raw: true });
89
+ const challenge = parseLoginChallenge(json);
90
+ if (challenge) {
91
+ throw new TwoFactorRequiredError("Two-factor authentication required", challenge);
92
+ }
93
+ const data = extractRecord(json, "data");
94
+ return { userId: extractString(data, "userId"), authToken: extractString(data, "authToken") };
95
+ }
96
+ export async function createBotUser(baseUrl, auth, opts) {
97
+ const json = await adminFetch(baseUrl, "/api/v1/users.create", {
98
+ userId: auth.userId,
99
+ authToken: auth.authToken,
100
+ body: {
101
+ username: opts.username,
102
+ name: opts.name,
103
+ password: opts.password,
104
+ email: opts.email,
105
+ roles: ["bot"],
106
+ verified: true,
107
+ requirePasswordChange: false,
108
+ sendWelcomeEmail: false,
109
+ },
110
+ });
111
+ const userRecord = extractRecord(json, "user");
112
+ return {
113
+ _id: extractString(userRecord, "_id"),
114
+ username: extractString(userRecord, "username"),
115
+ name: extractString(userRecord, "name"),
116
+ };
117
+ }
118
+ export async function deleteUser(baseUrl, auth, username) {
119
+ await adminFetch(baseUrl, "/api/v1/users.delete", {
120
+ userId: auth.userId,
121
+ authToken: auth.authToken,
122
+ body: { username },
123
+ });
124
+ }
125
+ export async function getUserInfo(baseUrl, auth, opts) {
126
+ const url = new URL("/api/v1/users.info", baseUrl);
127
+ if (opts.username)
128
+ url.searchParams.set("username", opts.username);
129
+ if (opts.userId)
130
+ url.searchParams.set("userId", opts.userId);
131
+ try {
132
+ const json = await adminFetch(baseUrl, url.toString(), {
133
+ method: "GET",
134
+ userId: auth.userId,
135
+ authToken: auth.authToken,
136
+ });
137
+ const user = json.user;
138
+ return {
139
+ _id: user._id,
140
+ username: user.username,
141
+ name: user.name,
142
+ ...(Array.isArray(user.roles) ? { roles: user.roles } : {}),
143
+ };
144
+ }
145
+ catch {
146
+ return null;
147
+ }
148
+ }
149
+ export async function verifyAdmin(baseUrl, auth) {
150
+ try {
151
+ const user = await getUserInfo(baseUrl, auth, { userId: auth.userId });
152
+ const roles = user?.roles;
153
+ if (!roles)
154
+ return { ok: false, reason: "unreachable" };
155
+ return roles.includes("admin") ? { ok: true } : { ok: false, reason: "not-admin" };
156
+ }
157
+ catch (e) {
158
+ if (e instanceof RocketChatClientError && /401|unauthorized/i.test(e.message)) {
159
+ return { ok: false, reason: "unauthorized" };
160
+ }
161
+ return { ok: false, reason: "unreachable" };
162
+ }
163
+ }
164
+ export async function createDirectMessage(baseUrl, auth, username) {
165
+ const json = await adminFetch(baseUrl, "/api/v1/im.create", {
166
+ userId: auth.userId,
167
+ authToken: auth.authToken,
168
+ body: { username },
169
+ });
170
+ const room = extractRecord(json, "room");
171
+ return extractString(room, "_id");
172
+ }
173
+ export async function sendMessage(baseUrl, auth, roomId, text) {
174
+ await adminFetch(baseUrl, "/api/v1/chat.postMessage", {
175
+ userId: auth.userId,
176
+ authToken: auth.authToken,
177
+ body: { roomId, text },
178
+ });
179
+ }
180
+ export async function listGroupMembers(baseUrl, auth, roomId) {
181
+ for (const endpoint of ["/api/v1/groups.members", "/api/v1/channels.members"]) {
182
+ try {
183
+ const url = new URL(endpoint, baseUrl);
184
+ url.searchParams.set("roomId", roomId);
185
+ url.searchParams.set("count", "0");
186
+ const json = await adminFetch(baseUrl, url.toString(), {
187
+ method: "GET",
188
+ userId: auth.userId,
189
+ authToken: auth.authToken,
190
+ });
191
+ const members = json.members ??
192
+ [];
193
+ const resolved = members
194
+ .map((m) => ({ _id: m._id ?? "", username: m.username ?? "", name: m.name ?? "" }))
195
+ .filter((m) => m._id && m.username);
196
+ if (resolved.length > 0 || json.members !== undefined) {
197
+ return resolved;
198
+ }
199
+ }
200
+ catch { }
201
+ }
202
+ return [];
203
+ }
204
+ export async function getGroupByName(baseUrl, auth, name) {
205
+ for (const endpoint of ["/api/v1/groups.info", "/api/v1/channels.info"]) {
206
+ try {
207
+ const url = new URL(endpoint, baseUrl);
208
+ url.searchParams.set("roomName", name);
209
+ const json = await adminFetch(baseUrl, url.toString(), {
210
+ method: "GET",
211
+ userId: auth.userId,
212
+ authToken: auth.authToken,
213
+ });
214
+ const group = (json.group ?? json.channel);
215
+ if (group?._id) {
216
+ return { _id: group._id, name: group.name ?? name, isPrivate: group.t === "p" };
217
+ }
218
+ }
219
+ catch { }
220
+ }
221
+ return null;
222
+ }
223
+ export async function inviteToGroup(baseUrl, auth, groupId, username, isPrivate = true) {
224
+ const endpoint = isPrivate ? "/api/v1/groups.invite" : "/api/v1/channels.invite";
225
+ await adminFetch(baseUrl, endpoint, {
226
+ userId: auth.userId,
227
+ authToken: auth.authToken,
228
+ body: { roomId: groupId, username },
229
+ });
230
+ }
231
+ export async function checkServerHealth(baseUrl) {
232
+ try {
233
+ const res = await fetchWithTimeout(new URL("/api/info", baseUrl), {
234
+ method: "GET",
235
+ });
236
+ return res.ok;
237
+ }
238
+ catch {
239
+ return false;
240
+ }
241
+ }
242
+ //# sourceMappingURL=admin-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-api.js","sourceRoot":"","sources":["../../src/cli/admin-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,MAAM,UAAU,cAAc,CAAC,CAAU;IACvC,OAAO,CACL,CAAC,YAAY,YAAY;QACzB,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CACvD,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,GAAiB,EACjB,OAAoB,EAAE,EACtB,SAAS,GAAG,kBAAkB;IAE9B,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAA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AAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAClF,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAe,EACf,IAAmB,EACnB,OAAe,EACf,QAAgB,EAChB,SAAS,GAAG,IAAI;IAEhB,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,yBAAyB,CAAC;IACjF,MAAM,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE;QAClC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;KACpC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;YAChE,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,EAAE,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { RCLoginResult } from "../types.js";
2
+ export declare function tryBotLogin(rcUrl: string, username: string, password: string): Promise<RCLoginResult | null>;
3
+ export declare function loginForServer(rcUrl: string, user: string, password: string, label: string): Promise<RCLoginResult | null>;
4
+ export declare function resolveAdminAuth(rcUrl: string, forceFresh?: boolean): Promise<RCLoginResult | null>;
5
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/cli/auth.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAE/B;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAE/B;AA6FD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,UAAU,UAAQ,GACjB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAsG/B"}