@alfe.ai/openclaw-google-chat 0.0.13 → 0.0.15
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/plugin2.cjs +23 -8
- package/dist/plugin2.js +23 -8
- package/package.json +2 -2
package/dist/plugin2.cjs
CHANGED
|
@@ -285,7 +285,7 @@ var GChatPoller = class {
|
|
|
285
285
|
}
|
|
286
286
|
async initSpace(spaceName, token) {
|
|
287
287
|
this.log.info(`New DM space discovered: ${spaceName}`);
|
|
288
|
-
let agentUserId = this.stateManager.
|
|
288
|
+
let agentUserId = this.stateManager.getCachedAgentUserId(this.agentEmail) ?? "";
|
|
289
289
|
let peerUserId = this.stateManager.getPeerUserId(spaceName) ?? "";
|
|
290
290
|
let peerDisplayName = null;
|
|
291
291
|
if (!agentUserId || !peerUserId) try {
|
|
@@ -333,17 +333,30 @@ var GChatPoller = class {
|
|
|
333
333
|
peerDisplayName = m.member.displayName || null;
|
|
334
334
|
break;
|
|
335
335
|
}
|
|
336
|
-
else if (humans.length >= 2) {
|
|
337
|
-
agentUserId = humans[0].member.name;
|
|
338
|
-
peerUserId = humans[1].member.name;
|
|
339
|
-
peerDisplayName = humans[1].member.displayName || null;
|
|
340
|
-
}
|
|
341
336
|
return {
|
|
342
337
|
agentUserId,
|
|
343
338
|
peerUserId,
|
|
344
339
|
peerDisplayName
|
|
345
340
|
};
|
|
346
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Learn the agent's own Chat user id (`users/{id}`) from a message it just
|
|
344
|
+
* sent — `sendMessage` returns the created message whose `sender.name` is the
|
|
345
|
+
* authenticated user. This is the authoritative source the email-based
|
|
346
|
+
* `getMember` lookup can't provide, and it's what makes pollSpace's self-skip
|
|
347
|
+
* (`msg.sender.name === state.agentUserId`) reliably skip the agent's own
|
|
348
|
+
* replies instead of the peer's messages. Cached globally (per email) so every
|
|
349
|
+
* space — current and future — picks it up.
|
|
350
|
+
*/
|
|
351
|
+
rememberAgentIdentity(sent, state) {
|
|
352
|
+
const id = sent.sender.name;
|
|
353
|
+
if (!id) return;
|
|
354
|
+
if (state.agentUserId !== id) {
|
|
355
|
+
state.agentUserId = id;
|
|
356
|
+
this.stateManager.updateSpace(state.spaceName, { agentUserId: id });
|
|
357
|
+
}
|
|
358
|
+
this.stateManager.setAgentIdentity(id, this.agentEmail);
|
|
359
|
+
}
|
|
347
360
|
scheduleSpacePoll(state) {
|
|
348
361
|
if (!this.running) return;
|
|
349
362
|
const interval = this.computeInterval(state);
|
|
@@ -441,12 +454,14 @@ var GChatPoller = class {
|
|
|
441
454
|
if (!raw) return;
|
|
442
455
|
const text = markdownToGChat(raw);
|
|
443
456
|
try {
|
|
444
|
-
await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
457
|
+
const sent = await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
458
|
+
this.rememberAgentIdentity(sent, state);
|
|
445
459
|
} catch (err) {
|
|
446
460
|
if (isHttpStatus(err, 401)) {
|
|
447
461
|
this.tokenManager.invalidate();
|
|
448
462
|
try {
|
|
449
|
-
await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
463
|
+
const sent = await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
464
|
+
this.rememberAgentIdentity(sent, state);
|
|
450
465
|
} catch (refreshErr) {
|
|
451
466
|
this.log.error(`Token refresh failed during reply: ${refreshErr instanceof Error ? refreshErr.message : String(refreshErr)}`);
|
|
452
467
|
throw refreshErr;
|
package/dist/plugin2.js
CHANGED
|
@@ -285,7 +285,7 @@ var GChatPoller = class {
|
|
|
285
285
|
}
|
|
286
286
|
async initSpace(spaceName, token) {
|
|
287
287
|
this.log.info(`New DM space discovered: ${spaceName}`);
|
|
288
|
-
let agentUserId = this.stateManager.
|
|
288
|
+
let agentUserId = this.stateManager.getCachedAgentUserId(this.agentEmail) ?? "";
|
|
289
289
|
let peerUserId = this.stateManager.getPeerUserId(spaceName) ?? "";
|
|
290
290
|
let peerDisplayName = null;
|
|
291
291
|
if (!agentUserId || !peerUserId) try {
|
|
@@ -333,17 +333,30 @@ var GChatPoller = class {
|
|
|
333
333
|
peerDisplayName = m.member.displayName || null;
|
|
334
334
|
break;
|
|
335
335
|
}
|
|
336
|
-
else if (humans.length >= 2) {
|
|
337
|
-
agentUserId = humans[0].member.name;
|
|
338
|
-
peerUserId = humans[1].member.name;
|
|
339
|
-
peerDisplayName = humans[1].member.displayName || null;
|
|
340
|
-
}
|
|
341
336
|
return {
|
|
342
337
|
agentUserId,
|
|
343
338
|
peerUserId,
|
|
344
339
|
peerDisplayName
|
|
345
340
|
};
|
|
346
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Learn the agent's own Chat user id (`users/{id}`) from a message it just
|
|
344
|
+
* sent — `sendMessage` returns the created message whose `sender.name` is the
|
|
345
|
+
* authenticated user. This is the authoritative source the email-based
|
|
346
|
+
* `getMember` lookup can't provide, and it's what makes pollSpace's self-skip
|
|
347
|
+
* (`msg.sender.name === state.agentUserId`) reliably skip the agent's own
|
|
348
|
+
* replies instead of the peer's messages. Cached globally (per email) so every
|
|
349
|
+
* space — current and future — picks it up.
|
|
350
|
+
*/
|
|
351
|
+
rememberAgentIdentity(sent, state) {
|
|
352
|
+
const id = sent.sender.name;
|
|
353
|
+
if (!id) return;
|
|
354
|
+
if (state.agentUserId !== id) {
|
|
355
|
+
state.agentUserId = id;
|
|
356
|
+
this.stateManager.updateSpace(state.spaceName, { agentUserId: id });
|
|
357
|
+
}
|
|
358
|
+
this.stateManager.setAgentIdentity(id, this.agentEmail);
|
|
359
|
+
}
|
|
347
360
|
scheduleSpacePoll(state) {
|
|
348
361
|
if (!this.running) return;
|
|
349
362
|
const interval = this.computeInterval(state);
|
|
@@ -441,12 +454,14 @@ var GChatPoller = class {
|
|
|
441
454
|
if (!raw) return;
|
|
442
455
|
const text = markdownToGChat(raw);
|
|
443
456
|
try {
|
|
444
|
-
await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
457
|
+
const sent = await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
458
|
+
this.rememberAgentIdentity(sent, state);
|
|
445
459
|
} catch (err) {
|
|
446
460
|
if (isHttpStatus(err, 401)) {
|
|
447
461
|
this.tokenManager.invalidate();
|
|
448
462
|
try {
|
|
449
|
-
await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
463
|
+
const sent = await sendMessage(await this.tokenManager.getAccessToken(), state.spaceName, text);
|
|
464
|
+
this.rememberAgentIdentity(sent, state);
|
|
450
465
|
} catch (refreshErr) {
|
|
451
466
|
this.log.error(`Token refresh failed during reply: ${refreshErr instanceof Error ? refreshErr.message : String(refreshErr)}`);
|
|
452
467
|
throw refreshErr;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/openclaw-google-chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "OpenClaw Google Chat plugin — DM polling and auto-reply via connected Google account",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"openclaw.plugin.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@alfe.ai/agent-api-client": "^0.
|
|
30
|
+
"@alfe.ai/agent-api-client": "^0.2.2",
|
|
31
31
|
"@alfe.ai/config": "^0.0.9"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|