@mcinteerj/openclaw-gmail 1.4.1 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcinteerj/openclaw-gmail",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Gmail channel plugin for OpenClaw - direct API or gog CLI",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/src/channel.ts CHANGED
@@ -27,7 +27,7 @@ import { createGmailClient, type GmailClient } from "./gmail-client.js";
27
27
  import crypto from "node:crypto";
28
28
 
29
29
  const meta = {
30
- id: "gmail",
30
+ id: "openclaw-gmail",
31
31
  label: "Gmail",
32
32
  selectionLabel: "Gmail",
33
33
  detailLabel: "Gmail",
@@ -71,8 +71,8 @@ function buildGmailMsgContext(
71
71
  ConversationLabel: threadLabel,
72
72
  SenderName: msg.sender.name,
73
73
  SenderId: msg.sender.id,
74
- Provider: "gmail" as const,
75
- Surface: "gmail" as const,
74
+ Provider: "openclaw-gmail" as const,
75
+ Surface: "openclaw-gmail" as const,
76
76
  MessageSid: msg.channelMessageId,
77
77
  ReplyToId: msg.channelMessageId,
78
78
  ThreadLabel: threadLabel,
@@ -83,7 +83,7 @@ function buildGmailMsgContext(
83
83
  MediaType: msg.mediaType,
84
84
  MediaUrl: msg.mediaUrl,
85
85
  CommandAuthorized: false,
86
- OriginatingChannel: "gmail" as const,
86
+ OriginatingChannel: "openclaw-gmail" as const,
87
87
  OriginatingTo: msg.threadId,
88
88
  });
89
89
 
@@ -105,7 +105,7 @@ async function dispatchGmailMessage(
105
105
 
106
106
  // Build the dispatch context
107
107
  const ctxPayload = buildGmailMsgContext(msg, account, cfg);
108
- const gmailCfg = cfg.channels?.gmail as GmailConfig | undefined;
108
+ const gmailCfg = cfg.channels?.["openclaw-gmail"] as GmailConfig | undefined;
109
109
 
110
110
  // Build reply dispatcher options using gateway's reply capability
111
111
  const deliver = async (payload: { text: string }) => {
@@ -255,6 +255,13 @@ export const gmailPlugin: ChannelPlugin<ResolvedGmailAccount> = {
255
255
  const client = (emailKey && activeClients.get(emailKey)) || createGmailClient(account, ctx.cfg);
256
256
  return sendGmailText({ ...ctx, client });
257
257
  },
258
+ sendMedia: (ctx: any) => {
259
+ const account = resolveGmailAccount(ctx.cfg, ctx.accountId);
260
+ const emailKey = account.email?.toLowerCase();
261
+ const client = (emailKey && activeClients.get(emailKey)) || createGmailClient(account, ctx.cfg);
262
+ const text = [ctx.text, ctx.mediaUrl].filter(Boolean).join("\n\n");
263
+ return sendGmailText({ ...ctx, text, client });
264
+ },
258
265
  resolveTarget: ({ to, allowFrom }) => {
259
266
  const trimmed = to?.trim() ?? "";
260
267
  const normalized = normalizeGmailTarget(trimmed);
package/src/inbound.ts CHANGED
@@ -76,7 +76,7 @@ export function parseInboundGmail(payload: GogPayload, accountId?: string): Inbo
76
76
  const fullText = `[Thread Context: ID=${payload.threadId}, Subject="${subject}"]\n\n${finalText}${attachmentContext}`;
77
77
 
78
78
  return {
79
- channelId: "gmail",
79
+ channelId: "openclaw-gmail",
80
80
  accountId,
81
81
  channelMessageId: payload.id,
82
82
  threadId: payload.threadId,
@@ -138,7 +138,7 @@ export function parseSearchGmail(msg: GogSearchMessage, accountId?: string, acco
138
138
  const fullText = `[Thread Context: ID=${msg.threadId}, Subject="${subject}"]\n\n${finalText}`;
139
139
 
140
140
  return {
141
- channelId: "gmail",
141
+ channelId: "openclaw-gmail",
142
142
  accountId,
143
143
  channelMessageId: msg.id,
144
144
  threadId: msg.threadId,
package/src/onboarding.ts CHANGED
@@ -7,7 +7,7 @@ import { readGogCredentials, runOAuthFlow, createOAuth2Client } from "./auth.js"
7
7
  import { ApiGmailClient } from "./api-client.js";
8
8
 
9
9
  const execAsync = promisify(exec);
10
- const channel = "gmail" as const;
10
+ const channel = "openclaw-gmail" as const;
11
11
 
12
12
  const MIN_GOG_VERSION = "1.2.0";
13
13
 
@@ -92,7 +92,7 @@ export const gmailOnboardingAdapter: ChannelOnboardingAdapter = {
92
92
  getStatus: async ({ cfg }: { cfg: OpenClawConfig }) => {
93
93
  const ids = listGmailAccountIds(cfg);
94
94
  const configured = ids.length > 0;
95
- const gmailConfig = (cfg.channels as any)?.gmail || {};
95
+ const gmailConfig = (cfg.channels as any)?.["openclaw-gmail"] || {};
96
96
  const accounts = gmailConfig.accounts || {};
97
97
  const backends = new Set(
98
98
  Object.values(accounts).map((a: any) => a.backend || "gog"),
@@ -128,7 +128,7 @@ export const gmailOnboardingAdapter: ChannelOnboardingAdapter = {
128
128
  }) => {
129
129
  // --- Account selection (unchanged) ---
130
130
  const existingIds = listGmailAccountIds(cfg);
131
- const gmailOverride = accountOverrides.gmail?.trim();
131
+ const gmailOverride = (accountOverrides["openclaw-gmail"] ?? accountOverrides.gmail)?.trim();
132
132
  const defaultAccountId = resolveDefaultGmailAccountId(cfg);
133
133
  let accountId = gmailOverride || defaultAccountId;
134
134
 
@@ -154,7 +154,7 @@ export const gmailOnboardingAdapter: ChannelOnboardingAdapter = {
154
154
  if (!email) throw new Error("Email required");
155
155
 
156
156
  // --- Detect available auth sources ---
157
- const gmailConfig = (cfg.channels as any)?.gmail || {};
157
+ const gmailConfig = (cfg.channels as any)?.["openclaw-gmail"] || {};
158
158
  const existingAccount = gmailConfig.accounts?.[email];
159
159
  const existingOAuth = existingAccount?.oauth;
160
160
  const gogInstalled = await checkGogInstalled();
@@ -330,7 +330,7 @@ export const gmailOnboardingAdapter: ChannelOnboardingAdapter = {
330
330
  ...cfg,
331
331
  channels: {
332
332
  ...cfg.channels,
333
- gmail: {
333
+ "openclaw-gmail": {
334
334
  dmPolicy: "allowlist",
335
335
  archiveOnReply: true,
336
336
  ...gmailConfig,
@@ -349,7 +349,7 @@ export const gmailOnboardingAdapter: ChannelOnboardingAdapter = {
349
349
  ...cfg,
350
350
  channels: {
351
351
  ...cfg.channels,
352
- gmail: { ...cfg.channels?.gmail, enabled: false },
352
+ "openclaw-gmail": { ...(cfg.channels as any)?.["openclaw-gmail"], enabled: false },
353
353
  },
354
354
  }),
355
355
  };
package/src/outbound.ts CHANGED
@@ -18,7 +18,7 @@ export interface GmailOutboundContext extends OutboundContext {
18
18
  export async function sendGmailText(ctx: GmailOutboundContext) {
19
19
  const { to, text, accountId, cfg, threadId, replyToId, subject: explicitSubject, client } = ctx;
20
20
  const account = resolveGmailAccount(cfg, accountId);
21
- const gmailCfg = cfg.channels?.gmail as GmailConfig | undefined;
21
+ const gmailCfg = cfg.channels?.["openclaw-gmail"] as GmailConfig | undefined;
22
22
 
23
23
  // Validate we have a target - prioritize threadId if it's valid
24
24
  const effectiveThreadId = isGmailThreadId(String(threadId)) ? String(threadId) : undefined;
@@ -141,5 +141,5 @@ export async function sendGmailText(ctx: GmailOutboundContext) {
141
141
  });
142
142
  }
143
143
 
144
- return { id: "sent" };
144
+ return { channel: "openclaw-gmail", messageId: "sent" };
145
145
  }