@ravi-hq/ravi 0.4.0 → 0.5.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/channels/email.d.ts +65 -11
- package/dist/channels/email.d.ts.map +1 -1
- package/dist/channels/email.js +233 -10
- package/dist/channels/email.js.map +1 -1
- package/dist/channels/sms.d.ts +71 -11
- package/dist/channels/sms.d.ts.map +1 -1
- package/dist/channels/sms.js +232 -10
- package/dist/channels/sms.js.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +41 -0
- package/dist/runtime.js.map +1 -0
- package/dist/tools/email-send.d.ts.map +1 -1
- package/dist/tools/email-send.js +11 -21
- package/dist/tools/email-send.js.map +1 -1
- package/dist/tools/feedback.d.ts.map +1 -1
- package/dist/tools/feedback.js +4 -3
- package/dist/tools/feedback.js.map +1 -1
- package/dist/tools/identity.d.ts.map +1 -1
- package/dist/tools/identity.js +3 -2
- package/dist/tools/identity.js.map +1 -1
- package/dist/tools/inbox.d.ts.map +1 -1
- package/dist/tools/inbox.js +4 -2
- package/dist/tools/inbox.js.map +1 -1
- package/dist/tools/passwords.d.ts.map +1 -1
- package/dist/tools/passwords.js +2 -1
- package/dist/tools/passwords.js.map +1 -1
- package/dist/tools/vault.d.ts.map +1 -1
- package/dist/tools/vault.js +2 -1
- package/dist/tools/vault.js.map +1 -1
- package/dist/types.d.ts +60 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/channels/sms.js
CHANGED
|
@@ -28,30 +28,44 @@ export function createSmsChannel() {
|
|
|
28
28
|
/**
|
|
29
29
|
* List all configured account IDs (identity UUIDs) for the ravi-sms channel.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
31
|
+
* Reads from the plugin config path first (set by `openclaw ravi login`),
|
|
32
|
+
* then falls back to the standard `channels.ravi-sms.accounts` path.
|
|
33
|
+
* Deduplicates when both sources contain the same UUID.
|
|
34
|
+
*
|
|
35
|
+
* @param cfg - The full OpenClaw gateway configuration object.
|
|
32
36
|
* @returns Array of identity UUID strings.
|
|
33
37
|
*/
|
|
34
38
|
listAccountIds: (cfg) => {
|
|
39
|
+
// Primary: read from plugin config (set by `openclaw ravi login`)
|
|
40
|
+
const plugins = cfg.plugins;
|
|
41
|
+
const uuid = plugins?.entries?.ravi?.config?.identityUuid;
|
|
42
|
+
// Fallback: standard channel accounts path
|
|
35
43
|
const channels = cfg.channels;
|
|
36
|
-
|
|
44
|
+
const channelIds = Object.keys(channels?.["ravi-sms"]?.accounts ?? {});
|
|
45
|
+
// Deduplicate — plugin config uuid takes priority
|
|
46
|
+
if (uuid) {
|
|
47
|
+
return [uuid, ...channelIds.filter((id) => id !== uuid)];
|
|
48
|
+
}
|
|
49
|
+
return channelIds;
|
|
37
50
|
},
|
|
38
51
|
/**
|
|
39
52
|
* Resolve an account configuration by its ID (identity UUID).
|
|
40
53
|
*
|
|
41
|
-
* Returns a
|
|
42
|
-
*
|
|
54
|
+
* Returns a minimal config with just the UUID if the account is not
|
|
55
|
+
* found in the standard channels path. The gateway adapter will fetch
|
|
56
|
+
* identity details at startup.
|
|
43
57
|
*
|
|
44
|
-
* @param cfg - The full OpenClaw
|
|
58
|
+
* @param cfg - The full OpenClaw gateway configuration object.
|
|
45
59
|
* @param accountId - The identity UUID to look up.
|
|
46
60
|
* @returns The resolved {@link SmsAccountConfig}.
|
|
47
61
|
*/
|
|
48
62
|
resolveAccount: (cfg, accountId) => {
|
|
49
63
|
const channels = cfg.channels;
|
|
50
64
|
const found = channels?.["ravi-sms"]?.accounts?.[accountId];
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
65
|
+
if (found)
|
|
66
|
+
return found;
|
|
67
|
+
// Fallback: return minimal config — gateway adapter fetches details at startup
|
|
68
|
+
return {
|
|
55
69
|
identityUuid: accountId,
|
|
56
70
|
identityName: "",
|
|
57
71
|
phone: "",
|
|
@@ -67,7 +81,7 @@ export function createSmsChannel() {
|
|
|
67
81
|
*
|
|
68
82
|
* @param event - The raw {@link SmsEvent} from the SSE stream.
|
|
69
83
|
* @param account - The {@link SmsAccountConfig} for the receiving identity.
|
|
70
|
-
* @returns A normalized {@link SmsInboundEnvelope}
|
|
84
|
+
* @returns A normalized {@link SmsInboundEnvelope}. Current implementation always returns non-null.
|
|
71
85
|
*/
|
|
72
86
|
normalizeInbound(event, account) {
|
|
73
87
|
const isReadOnly = event.sender_type !== "owner" && event.sender_type !== "self";
|
|
@@ -134,6 +148,214 @@ export function createSmsChannel() {
|
|
|
134
148
|
getSessionKey(agentId, accountId, phoneNumber) {
|
|
135
149
|
return `agent:${agentId}:ravi-sms:${accountId}:dm:${phoneNumber}`;
|
|
136
150
|
},
|
|
151
|
+
// ─── Gateway Adapter ──────────────────────────────────────────────────
|
|
152
|
+
gateway: {
|
|
153
|
+
/**
|
|
154
|
+
* Start monitoring inbound SMS for a single identity account.
|
|
155
|
+
*
|
|
156
|
+
* Called by the ChannelManager once per account. Opens an SSE stream
|
|
157
|
+
* to the Ravi backend, dispatches inbound SMS through the OpenClaw
|
|
158
|
+
* reply pipeline, and blocks until the abort signal fires.
|
|
159
|
+
*
|
|
160
|
+
* Bails out early if the identity has no phone number — SMS requires
|
|
161
|
+
* a provisioned phone number.
|
|
162
|
+
*
|
|
163
|
+
* Owner/self senders get full dispatch with reply delivery.
|
|
164
|
+
* External senders trigger an agent turn but reply delivery is suppressed.
|
|
165
|
+
*
|
|
166
|
+
* This gateway adapter is the ChannelManager-driven path, used when
|
|
167
|
+
* OpenClaw manages channel lifecycles directly. The `normalizeInbound` +
|
|
168
|
+
* `RaviListenerService` path in service.ts is the legacy self-managed
|
|
169
|
+
* approach for environments where the gateway doesn't call startAccount.
|
|
170
|
+
*
|
|
171
|
+
* @param ctx - Gateway context provided by the ChannelManager.
|
|
172
|
+
* @returns Promise that resolves when the account is stopped.
|
|
173
|
+
*/
|
|
174
|
+
startAccount: async (ctx) => {
|
|
175
|
+
const log = ctx.log ?? {
|
|
176
|
+
info: (...args) => console.log("[ravi-sms]", ...args),
|
|
177
|
+
warn: (...args) => console.warn("[ravi-sms]", ...args),
|
|
178
|
+
error: (...args) => console.error("[ravi-sms]", ...args),
|
|
179
|
+
};
|
|
180
|
+
// Lazy imports — only loaded when the gateway actually starts an account.
|
|
181
|
+
// This avoids pulling in runtime/auth/config/client/sse in test environments
|
|
182
|
+
// where gateway.startAccount() is never called.
|
|
183
|
+
let getRaviRuntime, loadAuth, RAVI_API_URL, RaviClient, RaviSSEClient;
|
|
184
|
+
try {
|
|
185
|
+
({ getRaviRuntime } = await import("../runtime.js"));
|
|
186
|
+
({ loadAuth } = await import("../auth.js"));
|
|
187
|
+
({ RAVI_API_URL } = await import("../config.js"));
|
|
188
|
+
({ RaviClient } = await import("../client.js"));
|
|
189
|
+
({ RaviSSEClient } = await import("../sse.js"));
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
193
|
+
log.error(`[ravi-sms] Failed to load dependencies: ${detail}. Is the plugin built correctly?`);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const runtime = getRaviRuntime();
|
|
197
|
+
const auth = loadAuth();
|
|
198
|
+
if (!auth?.access_token) {
|
|
199
|
+
log.error("[ravi-sms] No auth credentials — cannot start SMS channel. Run 'openclaw ravi login'.");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
// Build HTTP client for identity lookup + outbound replies
|
|
203
|
+
const client = new RaviClient({
|
|
204
|
+
apiUrl: RAVI_API_URL,
|
|
205
|
+
token: auth.access_token,
|
|
206
|
+
refreshToken: auth.refresh_token,
|
|
207
|
+
identityUuid: ctx.accountId,
|
|
208
|
+
});
|
|
209
|
+
// Fetch identity details (phone number, name) if not in config
|
|
210
|
+
let phone = ctx.account.phone;
|
|
211
|
+
let identityName = ctx.account.identityName;
|
|
212
|
+
if (!phone) {
|
|
213
|
+
try {
|
|
214
|
+
const identities = await client.listIdentities();
|
|
215
|
+
const identity = identities.find((i) => i.uuid === ctx.accountId);
|
|
216
|
+
phone = identity?.phone ?? "";
|
|
217
|
+
identityName = identity?.display_name ?? identity?.name ?? ctx.accountId;
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
if (err?.name === "RaviApiError") {
|
|
221
|
+
const status = err.status;
|
|
222
|
+
log.error(`[ravi-sms] Failed to fetch identity details (HTTP ${status}): ${err.message}` +
|
|
223
|
+
(status === 401 ? ". Token may be expired — run 'openclaw ravi login'." : ""));
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
227
|
+
log.error(`[ravi-sms] Failed to fetch identity details: ${detail}`);
|
|
228
|
+
}
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// SMS requires a phone number — bail out if the identity doesn't have one
|
|
233
|
+
if (!phone) {
|
|
234
|
+
log.info(`[ravi-sms] Identity ${identityName} has no phone number — skipping SMS channel`);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
log.info(`[ravi-sms] Starting SMS channel for ${identityName} (${phone})`);
|
|
238
|
+
// Build SSE client for real-time events
|
|
239
|
+
const sse = new RaviSSEClient({
|
|
240
|
+
apiUrl: RAVI_API_URL,
|
|
241
|
+
token: auth.access_token,
|
|
242
|
+
identityUuid: ctx.accountId,
|
|
243
|
+
});
|
|
244
|
+
sse.onSms((event) => {
|
|
245
|
+
try {
|
|
246
|
+
// Classify sender: owner/self get full reply; external/unknown wakes agent but suppresses delivery
|
|
247
|
+
const isAuthorizedSender = event.sender_type === "owner" || event.sender_type === "self";
|
|
248
|
+
// Resolve agent route — maps (channel, accountId) → agentId + session key
|
|
249
|
+
const route = runtime.channel.routing.resolveAgentRoute({
|
|
250
|
+
cfg: ctx.cfg,
|
|
251
|
+
channel: "ravi-sms",
|
|
252
|
+
accountId: ctx.accountId,
|
|
253
|
+
peer: { kind: "direct", id: event.from_number },
|
|
254
|
+
});
|
|
255
|
+
const sessionKey = route.sessionKey;
|
|
256
|
+
// Build MsgContext for dispatch
|
|
257
|
+
const msgCtx = {
|
|
258
|
+
Body: event.body,
|
|
259
|
+
BodyForAgent: event.body,
|
|
260
|
+
From: `ravi-sms:${event.from_number}`,
|
|
261
|
+
To: `ravi-sms:${phone}`,
|
|
262
|
+
SessionKey: sessionKey,
|
|
263
|
+
AccountId: ctx.accountId,
|
|
264
|
+
ChatType: "direct",
|
|
265
|
+
Provider: "ravi-sms",
|
|
266
|
+
Surface: "ravi-sms",
|
|
267
|
+
OriginatingChannel: "ravi-sms",
|
|
268
|
+
OriginatingTo: ctx.accountId,
|
|
269
|
+
SenderName: event.from_number,
|
|
270
|
+
SenderId: event.from_number,
|
|
271
|
+
Timestamp: Date.now(),
|
|
272
|
+
CommandAuthorized: isAuthorizedSender,
|
|
273
|
+
MessageSid: `ravi-sms:${event.id}`,
|
|
274
|
+
};
|
|
275
|
+
// Record inbound session so follow-ups route back through SMS
|
|
276
|
+
try {
|
|
277
|
+
runtime.channel.session.recordInboundSession({
|
|
278
|
+
storePath: runtime.channel.session.resolveStorePath(ctx.cfg.session?.store, { agentId: route.agentId }),
|
|
279
|
+
sessionKey,
|
|
280
|
+
ctx: msgCtx,
|
|
281
|
+
updateLastRoute: {
|
|
282
|
+
sessionKey,
|
|
283
|
+
channel: "ravi-sms",
|
|
284
|
+
to: ctx.accountId,
|
|
285
|
+
accountId: ctx.accountId,
|
|
286
|
+
phoneNumber: event.from_number,
|
|
287
|
+
},
|
|
288
|
+
onRecordError: (err) => {
|
|
289
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
290
|
+
log.error(`[ravi-sms] Session record error for ${event.from_number}: ${detail}`);
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
296
|
+
log.error(`[ravi-sms] recordInboundSession threw for ${event.from_number}: ${detail}`);
|
|
297
|
+
}
|
|
298
|
+
// Dispatch — triggers AI agent turn.
|
|
299
|
+
// For external senders: AI wakes up, can use tools, but deliver is suppressed.
|
|
300
|
+
runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
301
|
+
ctx: msgCtx,
|
|
302
|
+
cfg: ctx.cfg,
|
|
303
|
+
dispatcherOptions: {
|
|
304
|
+
deliver: async (payload) => {
|
|
305
|
+
if (!payload.text) {
|
|
306
|
+
log.info(`[ravi-sms] Deliver called with empty text for ${event.from_number} — skipping`);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
// Suppress reply delivery for external senders
|
|
310
|
+
if (!isAuthorizedSender) {
|
|
311
|
+
log.info(`[ravi-sms] Suppressing reply to external sender ${event.from_number}`);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
await client.sendSms(event.from_number, payload.text);
|
|
316
|
+
}
|
|
317
|
+
catch (err) {
|
|
318
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
319
|
+
const status = err?.status;
|
|
320
|
+
log.error(`[ravi-sms] Failed to deliver reply to ${event.from_number}` +
|
|
321
|
+
`${status ? ` (HTTP ${status})` : ""}: ${detail}`);
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
onError: (err) => {
|
|
325
|
+
log.error(`[ravi-sms] Dispatch error: ${err}`);
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
}).catch((err) => {
|
|
329
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
330
|
+
log.error(`[ravi-sms] dispatchReply failed for ${event.from_number}: ${detail}`);
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
catch (err) {
|
|
334
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
335
|
+
log.error(`[ravi-sms] Unhandled error processing event ${event.id}: ${detail}`);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
sse.onReconnect(() => {
|
|
339
|
+
log.info(`[ravi-sms] SSE reconnecting for ${identityName}`);
|
|
340
|
+
});
|
|
341
|
+
sse.connect();
|
|
342
|
+
log.info(`[ravi-sms] SSE connected for ${identityName} (${ctx.accountId})`);
|
|
343
|
+
// Block until gateway signals shutdown
|
|
344
|
+
await new Promise((resolve) => {
|
|
345
|
+
if (ctx.abortSignal.aborted) {
|
|
346
|
+
log.info(`[ravi-sms] Stopping SMS channel for ${identityName} (already aborted)`);
|
|
347
|
+
sse.disconnect();
|
|
348
|
+
resolve();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
ctx.abortSignal.addEventListener("abort", () => {
|
|
352
|
+
log.info(`[ravi-sms] Stopping SMS channel for ${identityName}`);
|
|
353
|
+
sse.disconnect();
|
|
354
|
+
resolve();
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
},
|
|
137
359
|
};
|
|
138
360
|
}
|
|
139
361
|
/** The singleton ravi-sms channel instance. */
|
package/dist/channels/sms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/channels/sms.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/channels/sms.ts"],"names":[],"mappings":"AAmDA,gFAAgF;AAEhF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,EAAE,EAAE,UAAmB;QAEvB,IAAI,EAAE;YACJ,EAAE,EAAE,UAAU;YACd,KAAK,EAAE,UAAU;YACjB,cAAc,EAAE,8BAA8B;YAC9C,KAAK,EACH,yGAAyG;YAC3G,OAAO,EAAE,CAAC,WAAW,CAAC;SACvB;QAED,YAAY,EAAE;YACZ,SAAS,EAAE,CAAC,QAA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gC,YAAY,KAAK,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC;gBAE5E,uCAAuC;gBACvC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAClC,IAAI,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;wBAC5B,GAAG,CAAC,IAAI,CAAC,uCAAuC,YAAY,oBAAoB,CAAC,CAAC;wBAClF,GAAG,CAAC,UAAU,EAAE,CAAC;wBACjB,OAAO,EAAE,CAAC;wBACV,OAAO;oBACT,CAAC;oBACD,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;wBAC7C,GAAG,CAAC,IAAI,CAAC,uCAAuC,YAAY,EAAE,CAAC,CAAC;wBAChE,GAAG,CAAC,UAAU,EAAE,CAAC;wBACjB,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,+CAA+C;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,EAAE,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -311,7 +311,7 @@ export const cliCommands = [
|
|
|
311
311
|
process.stderr.write(`Select an identity:\n`);
|
|
312
312
|
for (let i = 0; i < identities.length; i++) {
|
|
313
313
|
const id = identities[i];
|
|
314
|
-
const details = [id.
|
|
314
|
+
const details = [id.inbox, id.phone].filter(Boolean).join(", ");
|
|
315
315
|
process.stderr.write(` ${i + 1}. ${id.name}${details ? ` (${details})` : ""}\n`);
|
|
316
316
|
}
|
|
317
317
|
try {
|
|
@@ -384,8 +384,8 @@ export const cliCommands = [
|
|
|
384
384
|
output += `\nIdentities (${identities.length}):\n`;
|
|
385
385
|
for (const identity of identities) {
|
|
386
386
|
output += ` - ${identity.name} (${identity.uuid})\n`;
|
|
387
|
-
if (identity.
|
|
388
|
-
output += ` Email: ${identity.
|
|
387
|
+
if (identity.inbox)
|
|
388
|
+
output += ` Email: ${identity.inbox}\n`;
|
|
389
389
|
if (identity.phone)
|
|
390
390
|
output += ` Phone: ${identity.phone}\n`;
|
|
391
391
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module index
|
|
9
9
|
*/
|
|
10
|
-
export type { RaviPluginConfig, Identity, EmailThread, EmailMessage, EmailThreadDetail, SmsConversation, SmsMessage, PasswordEntry, SecretEntry, EncryptionMeta, EmailEvent, SmsEvent, SenderType, } from "./types.js";
|
|
10
|
+
export type { RaviPluginConfig, Identity, EmailThread, EmailMessage, EmailThreadDetail, SmsConversation, SmsMessage, PasswordEntry, SecretEntry, EncryptionMeta, EmailEvent, SmsEvent, SenderType, GatewayLogger, PluginRuntimeSubset, BaseGatewayContext, } from "./types.js";
|
|
11
|
+
export type { EmailGatewayContext } from "./channels/email.js";
|
|
12
|
+
export type { SmsGatewayContext } from "./channels/sms.js";
|
|
11
13
|
export { RaviClient, RaviApiError } from "./client.js";
|
|
12
14
|
export type { RaviClientConfig } from "./client.js";
|
|
13
15
|
export type { CryptoManager, KeyPair } from "./crypto.js";
|
|
@@ -17,6 +19,8 @@ export type { ToolDefinition, ToolContext } from "./tools/identity.js";
|
|
|
17
19
|
export type { EmailAccountConfig, EmailThreadContext, EmailInboundEnvelope } from "./channels/email.js";
|
|
18
20
|
export type { SmsAccountConfig, SmsThreadContext, SmsInboundEnvelope } from "./channels/sms.js";
|
|
19
21
|
export type { CliCommand } from "./cli.js";
|
|
22
|
+
export { setRaviRuntime, getRaviRuntime } from "./runtime.js";
|
|
23
|
+
import type { PluginRuntimeSubset } from "./types.js";
|
|
20
24
|
/**
|
|
21
25
|
* All agent tools combined into a single flat array.
|
|
22
26
|
*
|
|
@@ -37,6 +41,8 @@ interface PluginAPI {
|
|
|
37
41
|
config: Record<string, unknown>;
|
|
38
42
|
/** Validated plugin-specific config from plugins.entries.ravi.config. */
|
|
39
43
|
pluginConfig?: Record<string, unknown>;
|
|
44
|
+
/** PluginRuntime — provided by OpenClaw gateway hosts. May be absent in CLI-only or test environments. */
|
|
45
|
+
runtime?: PluginRuntimeSubset;
|
|
40
46
|
/** Structured logger (info, warn, error, debug). */
|
|
41
47
|
logger: {
|
|
42
48
|
info: (...args: unknown[]) => void;
|
|
@@ -74,6 +80,10 @@ interface PluginAPI {
|
|
|
74
80
|
start: () => void;
|
|
75
81
|
stop: () => void;
|
|
76
82
|
}): void;
|
|
83
|
+
/** Register a plugin lifecycle hook. */
|
|
84
|
+
on(hookName: string, handler: (...args: unknown[]) => unknown, opts?: {
|
|
85
|
+
priority?: number;
|
|
86
|
+
}): void;
|
|
77
87
|
}
|
|
78
88
|
/** Minimal Commander.js program interface for CLI registration. */
|
|
79
89
|
interface CLIProgram {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,YAAY,EACV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,WAAW,EACX,cAAc,EACd,UAAU,EACV,QAAQ,EACR,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,YAAY,EACV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,aAAa,EACb,WAAW,EACX,cAAc,EACd,UAAU,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,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,GAC3B,IAAI,CAAC;CACT;AAED,mEAAmE;AACnE,UAAU,UAAU;IAClB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CACnC;AAED,8CAA8C;AAC9C,UAAU,UAAU;IAClB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAClC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAClD,MAAM,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;CACtE;AAmCD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CA+I3D"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module index
|
|
9
9
|
*/
|
|
10
10
|
export { RaviClient, RaviApiError } from "./client.js";
|
|
11
|
+
export { setRaviRuntime, getRaviRuntime } from "./runtime.js";
|
|
11
12
|
// ─── Value Imports ───────────────────────────────────────────────────────────
|
|
12
13
|
import { RAVI_API_URL } from "./config.js";
|
|
13
14
|
import { RaviClient } from "./client.js";
|
|
@@ -24,6 +25,7 @@ import { passwordTools } from "./tools/passwords.js";
|
|
|
24
25
|
import { vaultTools } from "./tools/vault.js";
|
|
25
26
|
import { feedbackTools } from "./tools/feedback.js";
|
|
26
27
|
import { cliCommands } from "./cli.js";
|
|
28
|
+
import { setRaviRuntime } from "./runtime.js";
|
|
27
29
|
// ─── Combined Tools ──────────────────────────────────────────────────────────
|
|
28
30
|
/**
|
|
29
31
|
* All agent tools combined into a single flat array.
|
|
@@ -41,6 +43,35 @@ export const allTools = [
|
|
|
41
43
|
...vaultTools,
|
|
42
44
|
...feedbackTools,
|
|
43
45
|
];
|
|
46
|
+
// ─── Agent Context ───────────────────────────────────────────────────────────
|
|
47
|
+
/**
|
|
48
|
+
* Concise tool reference and email writing guide injected into every agent
|
|
49
|
+
* session via the `before_prompt_build` hook. Avoids duplicating guidance
|
|
50
|
+
* across individual tool descriptions.
|
|
51
|
+
*/
|
|
52
|
+
const RAVI_AGENT_CONTEXT = `## Ravi Identity Provider — Quick Reference
|
|
53
|
+
|
|
54
|
+
### Tool Index
|
|
55
|
+
**Identity:** ravi_identity_list, ravi_identity_create, ravi_get_info
|
|
56
|
+
**Email Inbox:** ravi_inbox_email, ravi_read_email
|
|
57
|
+
**Email Send:** ravi_email_compose, ravi_email_reply, ravi_email_forward
|
|
58
|
+
**SMS:** ravi_inbox_sms, ravi_read_sms, ravi_sms_send
|
|
59
|
+
**Passwords:** ravi_passwords_list, ravi_passwords_get, ravi_passwords_create, ravi_passwords_update, ravi_generate_password, ravi_passwords_delete
|
|
60
|
+
**Vault:** ravi_vault_list, ravi_vault_get, ravi_vault_set, ravi_vault_delete
|
|
61
|
+
**Feedback:** ravi_feedback
|
|
62
|
+
|
|
63
|
+
### Email Writing Best Practices
|
|
64
|
+
When composing, replying, or forwarding emails:
|
|
65
|
+
- Wrap body text in <p> tags for professional formatting — no plain text or <br> chains
|
|
66
|
+
- Subjects: 40-60 chars, specific, no ALL CAPS, no spam trigger words (free, urgent, act now)
|
|
67
|
+
- Max 2-3 links per email — use descriptive anchor text, never "Click here"
|
|
68
|
+
- End with a clear action item
|
|
69
|
+
- Sign with the identity name (from ravi_get_info), not the account owner's name
|
|
70
|
+
|
|
71
|
+
### Key Distinctions
|
|
72
|
+
- **Passwords** (ravi_passwords_*) = website credentials (domain + username + password)
|
|
73
|
+
- **Vault** (ravi_vault_*) = API keys, tokens, env vars (key-value secrets)
|
|
74
|
+
- **Feedback** (ravi_feedback) — use after any Ravi workflow, successful or not. The team reads every message.`;
|
|
44
75
|
// ─── Plugin Registration ─────────────────────────────────────────────────────
|
|
45
76
|
/**
|
|
46
77
|
* The OpenClaw plugin registration function.
|
|
@@ -56,6 +87,11 @@ export default function registerPlugin(api) {
|
|
|
56
87
|
const config = (api.pluginConfig ?? {});
|
|
57
88
|
// Load auth from ~/.ravi/auth.json (written by `openclaw ravi login`)
|
|
58
89
|
const auth = loadAuth();
|
|
90
|
+
// Store the PluginRuntime so channel gateway adapters can access it later.
|
|
91
|
+
// Available on the gateway but not in test environments.
|
|
92
|
+
if (api.runtime) {
|
|
93
|
+
setRaviRuntime(api.runtime);
|
|
94
|
+
}
|
|
59
95
|
// ── Always register CLI commands (login works even without auth) ───────
|
|
60
96
|
api.registerCli(({ program }) => {
|
|
61
97
|
const ravi = program
|
|
@@ -122,6 +158,10 @@ export default function registerPlugin(api) {
|
|
|
122
158
|
},
|
|
123
159
|
});
|
|
124
160
|
}
|
|
161
|
+
// ── Inject Ravi tool guide into every agent session ─────────────────────
|
|
162
|
+
api.on("before_prompt_build", () => ({
|
|
163
|
+
prependContext: RAVI_AGENT_CONTEXT,
|
|
164
|
+
}));
|
|
125
165
|
// ── Register channels ───────────────────────────────────────────────────
|
|
126
166
|
api.registerChannel({ plugin: raviEmailChannel });
|
|
127
167
|
api.registerChannel({ plugin: raviSmsChannel });
|
|
@@ -145,7 +185,7 @@ export default function registerPlugin(api) {
|
|
|
145
185
|
emailAccount: {
|
|
146
186
|
identityUuid,
|
|
147
187
|
identityName: name,
|
|
148
|
-
email: identity?.
|
|
188
|
+
email: identity?.inbox ?? "",
|
|
149
189
|
},
|
|
150
190
|
// Only register SMS handler if the identity has a phone number
|
|
151
191
|
...(identity?.phone ? {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0BH,OAAO,EAAE,U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AC,CAAC;gBACjE,MAAM,IAAI,GAAG,QAAQ,EAAE,YAAY,IAAI,QAAQ,EAAE,IAAI,IAAI,YAAY,CAAC;gBAEtE,OAAO,CAAC,WAAW,CAAC;oBAClB,MAAM,EAAE,YAAY;oBACpB,KAAK,EAAE,IAAI,CAAC,YAAY;oBACxB,YAAY;oBACZ,OAAO,EAAE,SAAS;oBAClB,YAAY,EAAE;wBACZ,YAAY;wBACZ,YAAY,EAAE,IAAI;wBAClB,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE;qBAC7B;oBACD,+DAA+D;oBAC/D,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;wBACpB,UAAU,EAAE;4BACV,YAAY;4BACZ,YAAY,EAAE,IAAI;4BAClB,KAAK,EAAE,QAAQ,CAAC,KAAK;yBACtB;qBACF,CAAC,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACf,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACT,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PluginRuntime singleton for the Ravi OpenClaw plugin.
|
|
3
|
+
*
|
|
4
|
+
* The OpenClaw gateway injects a `PluginRuntime` object during
|
|
5
|
+
* `registerPlugin()`. Channel gateway adapters need access to this
|
|
6
|
+
* runtime later (in `startAccount()`) to dispatch inbound messages
|
|
7
|
+
* and resolve agent routes. This module bridges that gap with a
|
|
8
|
+
* simple module-level store.
|
|
9
|
+
*
|
|
10
|
+
* Reading the runtime before it is set throws — this surfaces
|
|
11
|
+
* misconfiguration early rather than allowing undefined-property
|
|
12
|
+
* errors downstream in the dispatch pipeline.
|
|
13
|
+
*
|
|
14
|
+
* @module runtime
|
|
15
|
+
*/
|
|
16
|
+
import type { PluginRuntimeSubset } from "./types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Store the PluginRuntime reference.
|
|
19
|
+
*
|
|
20
|
+
* Called once during `registerPlugin()` when `api.runtime` is available.
|
|
21
|
+
* Must be called before any channel gateway adapter starts.
|
|
22
|
+
*
|
|
23
|
+
* @param next - The PluginRuntime object from the OpenClaw gateway.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setRaviRuntime(next: PluginRuntimeSubset): void;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve the stored PluginRuntime reference.
|
|
28
|
+
*
|
|
29
|
+
* @throws If called before `setRaviRuntime()` — indicates the plugin
|
|
30
|
+
* was not properly initialized via `registerPlugin()`.
|
|
31
|
+
* @returns The PluginRuntime object.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getRaviRuntime(): PluginRuntimeSubset;
|
|
34
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAItD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,mBAAmB,CAKpD"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PluginRuntime singleton for the Ravi OpenClaw plugin.
|
|
3
|
+
*
|
|
4
|
+
* The OpenClaw gateway injects a `PluginRuntime` object during
|
|
5
|
+
* `registerPlugin()`. Channel gateway adapters need access to this
|
|
6
|
+
* runtime later (in `startAccount()`) to dispatch inbound messages
|
|
7
|
+
* and resolve agent routes. This module bridges that gap with a
|
|
8
|
+
* simple module-level store.
|
|
9
|
+
*
|
|
10
|
+
* Reading the runtime before it is set throws — this surfaces
|
|
11
|
+
* misconfiguration early rather than allowing undefined-property
|
|
12
|
+
* errors downstream in the dispatch pipeline.
|
|
13
|
+
*
|
|
14
|
+
* @module runtime
|
|
15
|
+
*/
|
|
16
|
+
let runtime = null;
|
|
17
|
+
/**
|
|
18
|
+
* Store the PluginRuntime reference.
|
|
19
|
+
*
|
|
20
|
+
* Called once during `registerPlugin()` when `api.runtime` is available.
|
|
21
|
+
* Must be called before any channel gateway adapter starts.
|
|
22
|
+
*
|
|
23
|
+
* @param next - The PluginRuntime object from the OpenClaw gateway.
|
|
24
|
+
*/
|
|
25
|
+
export function setRaviRuntime(next) {
|
|
26
|
+
runtime = next;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieve the stored PluginRuntime reference.
|
|
30
|
+
*
|
|
31
|
+
* @throws If called before `setRaviRuntime()` — indicates the plugin
|
|
32
|
+
* was not properly initialized via `registerPlugin()`.
|
|
33
|
+
* @returns The PluginRuntime object.
|
|
34
|
+
*/
|
|
35
|
+
export function getRaviRuntime() {
|
|
36
|
+
if (!runtime) {
|
|
37
|
+
throw new Error("Ravi runtime not initialized — was registerPlugin() called?");
|
|
38
|
+
}
|
|
39
|
+
return runtime;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,IAAI,OAAO,GAA+B,IAAI,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,IAAyB;IACtD,OAAO,GAAG,IAAI,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-send.d.ts","sourceRoot":"","sources":["../../src/tools/email-send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,eAAe,CAAC;AAwCjE,oDAAoD;AACpD,eAAO,MAAM,cAAc,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"email-send.d.ts","sourceRoot":"","sources":["../../src/tools/email-send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,eAAe,CAAC;AAwCjE,oDAAoD;AACpD,eAAO,MAAM,cAAc,EAAE,cAAc,EAqM1C,CAAC"}
|
package/dist/tools/email-send.js
CHANGED
|
@@ -41,15 +41,10 @@ function buildSendOpts(params, attachmentUuids) {
|
|
|
41
41
|
export const emailSendTools = [
|
|
42
42
|
{
|
|
43
43
|
name: "ravi_email_compose",
|
|
44
|
-
description: "Compose and send a new email
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"Rate limits: 60 emails/hour, 500/day. " +
|
|
49
|
-
"Supports CC and BCC recipients — pass arrays of email addresses. " +
|
|
50
|
-
"Supports file attachments — provide an array of absolute file paths and they will be " +
|
|
51
|
-
"uploaded and attached to the email (max 10 MB each, dangerous extensions like .exe blocked). " +
|
|
52
|
-
"The sent email will appear in the inbox as an outbound message.",
|
|
44
|
+
description: "Compose and send a new email. Body is plain text (auto-converted to HTML) — or include your own " +
|
|
45
|
+
"HTML tags (<p>, <h2>, <a href>). See Email Writing Best Practices in the Ravi Quick Reference for formatting tips. " +
|
|
46
|
+
"Use ravi_get_info to get your identity name for signatures. " +
|
|
47
|
+
"Rate limits: 60/hour, 500/day. Supports CC, BCC, and file attachments (max 10 MB each).",
|
|
53
48
|
parameters: {
|
|
54
49
|
type: "object",
|
|
55
50
|
properties: {
|
|
@@ -93,15 +88,10 @@ export const emailSendTools = [
|
|
|
93
88
|
},
|
|
94
89
|
{
|
|
95
90
|
name: "ravi_email_reply",
|
|
96
|
-
description: "Reply to an existing email message
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"Body is plain text, automatically wrapped in HTML. " +
|
|
101
|
-
"Supports file attachments — provide an array of absolute file paths. " +
|
|
102
|
-
"Set reply_all to true to reply to all recipients (To + CC). " +
|
|
103
|
-
"Supports CC and BCC — pass arrays of email addresses. Use ravi_read_email to check existing CC " +
|
|
104
|
-
"recipients before replying, so you can include them appropriately.",
|
|
91
|
+
description: "Reply to an existing email message (threaded with correct headers). " +
|
|
92
|
+
"Read the thread with ravi_read_email first to understand context and see CC recipients. " +
|
|
93
|
+
"Subject is required — copy it from the thread (it's E2E encrypted on the server). " +
|
|
94
|
+
"Body is plain text, auto-wrapped in HTML. Supports reply_all, CC, BCC, and file attachments.",
|
|
105
95
|
parameters: {
|
|
106
96
|
type: "object",
|
|
107
97
|
properties: {
|
|
@@ -155,9 +145,9 @@ export const emailSendTools = [
|
|
|
155
145
|
},
|
|
156
146
|
{
|
|
157
147
|
name: "ravi_email_forward",
|
|
158
|
-
description: "Forward an email
|
|
159
|
-
"
|
|
160
|
-
"
|
|
148
|
+
description: "Forward an email to a new recipient. The original message content is included automatically. " +
|
|
149
|
+
"Read the thread with ravi_read_email first to review content. " +
|
|
150
|
+
"Subject is required — copy it from the thread (it's E2E encrypted on the server). " +
|
|
161
151
|
"Supports CC, BCC, and file attachments.",
|
|
162
152
|
parameters: {
|
|
163
153
|
type: "object",
|