@mcinteerj/openclaw-gmail 1.2.5 → 1.2.8
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 +1 -1
- package/src/accounts.ts +2 -2
- package/src/channel.ts +21 -17
package/package.json
CHANGED
package/src/accounts.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function resolveGmailAccount(
|
|
|
17
17
|
accountId?: string,
|
|
18
18
|
): ResolvedGmailAccount {
|
|
19
19
|
const resolvedId = accountId || DEFAULT_ACCOUNT_ID;
|
|
20
|
-
const account = cfg.channels?.gmail?.accounts?.[resolvedId];
|
|
20
|
+
const account = cfg.channels?.['openclaw-gmail']?.accounts?.[resolvedId];
|
|
21
21
|
|
|
22
22
|
if (!account) {
|
|
23
23
|
// Graceful fallback for UI logic that queries 'default' on unconfigured channels
|
|
@@ -46,7 +46,7 @@ export function resolveGmailAccount(
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export function listGmailAccountIds(cfg: ChannelConfig<GmailConfig>): string[] {
|
|
49
|
-
return Object.keys(cfg.channels?.gmail?.accounts || {});
|
|
49
|
+
return Object.keys(cfg.channels?.['openclaw-gmail']?.accounts || {});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export function resolveDefaultGmailAccountId(cfg: ChannelConfig<GmailConfig>): string {
|
package/src/channel.ts
CHANGED
|
@@ -211,7 +211,7 @@ export const gmailPlugin: ChannelPlugin<ResolvedGmailAccount> = {
|
|
|
211
211
|
setAccountEnabled: ({ cfg, accountId, enabled }) =>
|
|
212
212
|
setAccountEnabledInConfigSection({
|
|
213
213
|
cfg,
|
|
214
|
-
sectionKey: "gmail",
|
|
214
|
+
sectionKey: "openclaw-gmail",
|
|
215
215
|
accountId,
|
|
216
216
|
enabled,
|
|
217
217
|
allowTopLevel: true,
|
|
@@ -219,7 +219,7 @@ export const gmailPlugin: ChannelPlugin<ResolvedGmailAccount> = {
|
|
|
219
219
|
deleteAccount: ({ cfg, accountId }) =>
|
|
220
220
|
deleteAccountFromConfigSection({
|
|
221
221
|
cfg,
|
|
222
|
-
sectionKey: "gmail",
|
|
222
|
+
sectionKey: "openclaw-gmail",
|
|
223
223
|
accountId,
|
|
224
224
|
}),
|
|
225
225
|
},
|
|
@@ -277,6 +277,10 @@ export const gmailPlugin: ChannelPlugin<ResolvedGmailAccount> = {
|
|
|
277
277
|
messageToolHints: ({ cfg, accountId }: { cfg: OpenClawConfig; accountId: string }) => {
|
|
278
278
|
const account = resolveGmailAccount(cfg, accountId);
|
|
279
279
|
return [
|
|
280
|
+
"### Channel Behavior",
|
|
281
|
+
"- Email is an async channel—avoid narration or progress updates (each message becomes a separate email).",
|
|
282
|
+
"- Work silently; send ONE reply when complete. For long-running tasks, notify before starting or after completing.",
|
|
283
|
+
"",
|
|
280
284
|
"### Gmail Messaging",
|
|
281
285
|
"- To reply to this email, just write your response normally as text in your turn. This will Reply All to everyone on the thread.",
|
|
282
286
|
"- Your Markdown response is automatically converted to a rich HTML email using the `marked` library.",
|
|
@@ -331,31 +335,31 @@ export const gmailPlugin: ChannelPlugin<ResolvedGmailAccount> = {
|
|
|
331
335
|
|
|
332
336
|
ctx.setStatus({ accountId: ctx.accountId, running: true, connected: true });
|
|
333
337
|
|
|
334
|
-
//
|
|
335
|
-
|
|
338
|
+
// The channel manager treats startAccount's promise resolving as the channel
|
|
339
|
+
// "exiting", which triggers auto-restart. We must keep this promise pending
|
|
340
|
+
// until the channel manager signals stop via ctx.abortSignal.
|
|
341
|
+
const signal = ctx.abortSignal;
|
|
336
342
|
|
|
337
|
-
// Start the Gmail polling monitor
|
|
338
|
-
monitorGmail({
|
|
343
|
+
// Start the Gmail polling monitor (awaits until signal is aborted)
|
|
344
|
+
await monitorGmail({
|
|
339
345
|
account: ctx.account,
|
|
340
346
|
onMessage: async (msg) => {
|
|
341
347
|
await dispatchGmailMessage(ctx, msg);
|
|
342
348
|
},
|
|
343
|
-
signal
|
|
349
|
+
signal,
|
|
344
350
|
log: ctx.log,
|
|
345
351
|
setStatus: ctx.setStatus,
|
|
346
352
|
}).catch((err) => {
|
|
347
|
-
|
|
353
|
+
if (!signal.aborted) {
|
|
354
|
+
ctx.log?.error(`[gmail] Monitor error: ${String(err)}`);
|
|
355
|
+
}
|
|
348
356
|
});
|
|
349
357
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
ctx.setStatus({ accountId: ctx.accountId, running: false, connected: false });
|
|
357
|
-
},
|
|
358
|
-
};
|
|
358
|
+
// Cleanup after monitor exits
|
|
359
|
+
if (ctx.account.email) {
|
|
360
|
+
activeAccounts.delete(ctx.account.email.toLowerCase());
|
|
361
|
+
}
|
|
362
|
+
ctx.setStatus({ accountId: ctx.accountId, running: false, connected: false });
|
|
359
363
|
},
|
|
360
364
|
},
|
|
361
365
|
};
|