@alfe.ai/openclaw-google-chat 0.0.5 → 0.0.7
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 +5 -16
- package/dist/plugin2.js +5 -16
- package/package.json +1 -1
package/dist/plugin2.cjs
CHANGED
|
@@ -51,9 +51,9 @@ var StateManager = class {
|
|
|
51
51
|
}
|
|
52
52
|
if (this.dirty) await this.flush();
|
|
53
53
|
}
|
|
54
|
-
/** Get the last-seen timestamp for a space, or
|
|
54
|
+
/** Get the last-seen timestamp for a space, or undefined if not yet tracked. */
|
|
55
55
|
getLastSeenTimestamp(spaceName) {
|
|
56
|
-
return this.state.spaces[spaceName]?.lastSeenTimestamp
|
|
56
|
+
return this.state.spaces[spaceName]?.lastSeenTimestamp;
|
|
57
57
|
}
|
|
58
58
|
/** Get the agent's userId for a space (if previously resolved). */
|
|
59
59
|
getAgentUserId(spaceName) {
|
|
@@ -66,7 +66,7 @@ var StateManager = class {
|
|
|
66
66
|
/** Update state for a space. */
|
|
67
67
|
updateSpace(spaceName, data) {
|
|
68
68
|
const existing = this.state.spaces[spaceName] ?? {
|
|
69
|
-
lastSeenTimestamp: (/* @__PURE__ */ new Date(
|
|
69
|
+
lastSeenTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
70
70
|
agentUserId: "",
|
|
71
71
|
peerUserId: ""
|
|
72
72
|
};
|
|
@@ -156,10 +156,6 @@ async function listMembers(token, spaceName) {
|
|
|
156
156
|
} while (pageToken);
|
|
157
157
|
return allMembers;
|
|
158
158
|
}
|
|
159
|
-
/** Fetch the last N messages from a space (for backfill on new space discovery). */
|
|
160
|
-
async function listRecentMessages(token, spaceName, limit) {
|
|
161
|
-
return (await request(token, `/${spaceName}/messages?${new URLSearchParams({ pageSize: String(limit) }).toString()}`)).messages ?? [];
|
|
162
|
-
}
|
|
163
159
|
//#endregion
|
|
164
160
|
//#region src/markdown-to-gchat.ts
|
|
165
161
|
/**
|
|
@@ -202,7 +198,6 @@ const WARM_THRESHOLD_MS = 1800 * 1e3;
|
|
|
202
198
|
const DORMANT_THRESHOLD_MS = 7200 * 1e3;
|
|
203
199
|
const DISCOVERY_INTERVAL_MS = 3e4;
|
|
204
200
|
const DEDUP_SIZE = 100;
|
|
205
|
-
const BACKFILL_COUNT = 20;
|
|
206
201
|
const MAX_RETRY_DELAY_MS = 6e4;
|
|
207
202
|
const BASE_RETRY_DELAY_MS = 2e3;
|
|
208
203
|
var GChatPoller = class {
|
|
@@ -285,13 +280,7 @@ var GChatPoller = class {
|
|
|
285
280
|
} catch (err) {
|
|
286
281
|
this.log.warn(`Failed to resolve members for ${spaceName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
287
282
|
}
|
|
288
|
-
|
|
289
|
-
try {
|
|
290
|
-
const recent = await listRecentMessages(token, spaceName, BACKFILL_COUNT);
|
|
291
|
-
if (recent.length > 0) lastSeenTimestamp = recent[recent.length - 1].createTime;
|
|
292
|
-
} catch (err) {
|
|
293
|
-
this.log.warn(`Backfill failed for ${spaceName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
294
|
-
}
|
|
283
|
+
const lastSeenTimestamp = this.stateManager.getLastSeenTimestamp(spaceName) ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
295
284
|
this.stateManager.updateSpace(spaceName, {
|
|
296
285
|
lastSeenTimestamp,
|
|
297
286
|
agentUserId,
|
|
@@ -316,7 +305,7 @@ var GChatPoller = class {
|
|
|
316
305
|
let peerDisplayName = null;
|
|
317
306
|
for (const m of members) {
|
|
318
307
|
if (m.member.type !== "HUMAN") continue;
|
|
319
|
-
if (this.agentEmail && m.member.displayName
|
|
308
|
+
if (this.agentEmail && m.member.displayName?.toLowerCase().includes(this.agentEmail.split("@")[0].toLowerCase())) agentUserId = m.member.name;
|
|
320
309
|
else {
|
|
321
310
|
peerUserId = m.member.name;
|
|
322
311
|
peerDisplayName = m.member.displayName || null;
|
package/dist/plugin2.js
CHANGED
|
@@ -51,9 +51,9 @@ var StateManager = class {
|
|
|
51
51
|
}
|
|
52
52
|
if (this.dirty) await this.flush();
|
|
53
53
|
}
|
|
54
|
-
/** Get the last-seen timestamp for a space, or
|
|
54
|
+
/** Get the last-seen timestamp for a space, or undefined if not yet tracked. */
|
|
55
55
|
getLastSeenTimestamp(spaceName) {
|
|
56
|
-
return this.state.spaces[spaceName]?.lastSeenTimestamp
|
|
56
|
+
return this.state.spaces[spaceName]?.lastSeenTimestamp;
|
|
57
57
|
}
|
|
58
58
|
/** Get the agent's userId for a space (if previously resolved). */
|
|
59
59
|
getAgentUserId(spaceName) {
|
|
@@ -66,7 +66,7 @@ var StateManager = class {
|
|
|
66
66
|
/** Update state for a space. */
|
|
67
67
|
updateSpace(spaceName, data) {
|
|
68
68
|
const existing = this.state.spaces[spaceName] ?? {
|
|
69
|
-
lastSeenTimestamp: (/* @__PURE__ */ new Date(
|
|
69
|
+
lastSeenTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
70
70
|
agentUserId: "",
|
|
71
71
|
peerUserId: ""
|
|
72
72
|
};
|
|
@@ -156,10 +156,6 @@ async function listMembers(token, spaceName) {
|
|
|
156
156
|
} while (pageToken);
|
|
157
157
|
return allMembers;
|
|
158
158
|
}
|
|
159
|
-
/** Fetch the last N messages from a space (for backfill on new space discovery). */
|
|
160
|
-
async function listRecentMessages(token, spaceName, limit) {
|
|
161
|
-
return (await request(token, `/${spaceName}/messages?${new URLSearchParams({ pageSize: String(limit) }).toString()}`)).messages ?? [];
|
|
162
|
-
}
|
|
163
159
|
//#endregion
|
|
164
160
|
//#region src/markdown-to-gchat.ts
|
|
165
161
|
/**
|
|
@@ -202,7 +198,6 @@ const WARM_THRESHOLD_MS = 1800 * 1e3;
|
|
|
202
198
|
const DORMANT_THRESHOLD_MS = 7200 * 1e3;
|
|
203
199
|
const DISCOVERY_INTERVAL_MS = 3e4;
|
|
204
200
|
const DEDUP_SIZE = 100;
|
|
205
|
-
const BACKFILL_COUNT = 20;
|
|
206
201
|
const MAX_RETRY_DELAY_MS = 6e4;
|
|
207
202
|
const BASE_RETRY_DELAY_MS = 2e3;
|
|
208
203
|
var GChatPoller = class {
|
|
@@ -285,13 +280,7 @@ var GChatPoller = class {
|
|
|
285
280
|
} catch (err) {
|
|
286
281
|
this.log.warn(`Failed to resolve members for ${spaceName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
287
282
|
}
|
|
288
|
-
|
|
289
|
-
try {
|
|
290
|
-
const recent = await listRecentMessages(token, spaceName, BACKFILL_COUNT);
|
|
291
|
-
if (recent.length > 0) lastSeenTimestamp = recent[recent.length - 1].createTime;
|
|
292
|
-
} catch (err) {
|
|
293
|
-
this.log.warn(`Backfill failed for ${spaceName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
294
|
-
}
|
|
283
|
+
const lastSeenTimestamp = this.stateManager.getLastSeenTimestamp(spaceName) ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
295
284
|
this.stateManager.updateSpace(spaceName, {
|
|
296
285
|
lastSeenTimestamp,
|
|
297
286
|
agentUserId,
|
|
@@ -316,7 +305,7 @@ var GChatPoller = class {
|
|
|
316
305
|
let peerDisplayName = null;
|
|
317
306
|
for (const m of members) {
|
|
318
307
|
if (m.member.type !== "HUMAN") continue;
|
|
319
|
-
if (this.agentEmail && m.member.displayName
|
|
308
|
+
if (this.agentEmail && m.member.displayName?.toLowerCase().includes(this.agentEmail.split("@")[0].toLowerCase())) agentUserId = m.member.name;
|
|
320
309
|
else {
|
|
321
310
|
peerUserId = m.member.name;
|
|
322
311
|
peerDisplayName = m.member.displayName || null;
|
package/package.json
CHANGED