@openclaw/googlechat 2026.9.6 → 2026.9.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.
Files changed (35) hide show
  1. package/assets/icon.png +0 -0
  2. package/dist/.setup/actions-K6_7xusH.mjs +56 -0
  3. package/dist/.setup/{approval-auth-C6NmZR0i.mjs → approval-auth-DXvh9tfx.mjs} +2 -2
  4. package/dist/.setup/approval-card-text-BKg_4mXq.mjs +12 -0
  5. package/dist/.setup/{approval-handler.runtime-DPTrNUbd.mjs → approval-handler.runtime-CT2MVoa-.mjs} +42 -81
  6. package/dist/.setup/{channel-E2g6ySbf.mjs → channel-DAUmcC2J.mjs} +34 -82
  7. package/dist/.setup/{channel-base-B3EzcV7X.mjs → channel-base-inLf3HGV.mjs} +15 -36
  8. package/dist/.setup/{channel.adapters-CSAwKSvQ.mjs → channel.adapters-DIQot11j.mjs} +85 -172
  9. package/dist/.setup/{channel.runtime-BdzxoqvE.mjs → channel.runtime-C-B60lWL.mjs} +84 -161
  10. package/dist/.setup/doctor-contract-wLrnvLUn.mjs +294 -0
  11. package/dist/.setup/runtime-C5OOOlaP.mjs +8 -0
  12. package/dist/.setup/{secret-contract-DmWM0kwM.mjs → secret-contract-B7H-kkqq.mjs} +4 -11
  13. package/dist/.setup/{secret-contract-api-DHLd5XO3.mjs → secret-contract-api-GavLI-0W.mjs} +1 -1
  14. package/dist/.setup/{setup-plugin-api-C0zTOlHy.mjs → setup-plugin-api-CAzvWHwN.mjs} +1 -1
  15. package/dist/.setup/{setup-plugin-api-DWL3ZytB.mjs → setup-plugin-api-DPYc1usm.mjs} +1 -1
  16. package/dist/api.js +2 -2
  17. package/dist/channel-plugin-api.js +1 -1
  18. package/dist/directory-contract-api.js +1 -1
  19. package/dist/doctor-contract-api.js +1 -1
  20. package/dist/runtime-api.js +2 -3
  21. package/dist/secret-contract-api.js +1 -1
  22. package/dist/setup-entry.js +2 -2
  23. package/dist/setup-plugin-api.js +1 -1
  24. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/gcp-residency.d.ts +13 -4
  25. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/gcp-residency.js +24 -19
  26. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/gcp-residency.js.map +1 -1
  27. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js +65 -37
  28. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js.map +1 -1
  29. package/node_modules/google-auth-library/node_modules/gcp-metadata/package.json +1 -1
  30. package/node_modules/google-auth-library/package.json +6 -6
  31. package/package.json +5 -5
  32. package/dist/.setup/actions-BM-Gd-H7.mjs +0 -72
  33. package/dist/.setup/approval-card-text-ChngxXdJ.mjs +0 -6
  34. package/dist/.setup/doctor-contract-BLvSmTXT.mjs +0 -115
  35. package/dist/.setup/runtime-api-Cc5ZuXih.mjs +0 -24
@@ -1,33 +1,29 @@
1
- import { C as verifyGoogleChatRequest, D as readGoogleChatApprovalActionToken, E as googleChatApprovalControls, S as updateGoogleChatMessage, _ as GoogleChatApiError, b as probeGoogleChat, c as googleChatIngressIdentity, d as isGoogleChatGroupSpace, l as normalizeGoogleChatUserId, u as buildGoogleChatGroupPolicyScope, v as deleteGoogleChatMessage, x as sendGoogleChatMessage, y as downloadGoogleChatMedia } from "./channel.adapters-CSAwKSvQ.mjs";
2
- import { C as resolveWebhookPath, E as warnMissingProviderGroupPolicyFallbackOnce, O as getGoogleChatRuntime, b as resolveAllowlistProviderRuntimeGroupPolicy, c as createChannelPairingController, f as isDangerousNameMatchingEnabled, n as GROUP_POLICY_BLOCKED_LABEL, x as resolveDefaultGroupPolicy } from "./runtime-api-Cc5ZuXih.mjs";
3
- import { n as googleChatApprovalAuth } from "./approval-auth-C6NmZR0i.mjs";
4
- import { t as escapeGoogleChatApprovalCardText } from "./approval-card-text-ChngxXdJ.mjs";
5
- import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { C as verifyGoogleChatRequest, D as readGoogleChatApprovalActionToken, E as googleChatApprovalControls, S as updateGoogleChatMessage, _ as GoogleChatApiError, b as probeGoogleChat, c as googleChatIngressIdentity, d as isGoogleChatGroupSpace, l as normalizeGoogleChatUserId, u as buildGoogleChatGroupPolicyScope, v as deleteGoogleChatMessage, x as sendGoogleChatMessage, y as downloadGoogleChatMedia } from "./channel.adapters-DIQot11j.mjs";
2
+ import { n as googleChatApprovalAuth } from "./approval-auth-DXvh9tfx.mjs";
3
+ import { t as getGoogleChatRuntime } from "./runtime-C5OOOlaP.mjs";
4
+ import { n as escapeGoogleChatApprovalCardText, t as buildGoogleChatApprovalTextWidget } from "./approval-card-text-BKg_4mXq.mjs";
5
+ import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";
7
- import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
8
7
  import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
9
8
  import { MediaFetchError } from "openclaw/plugin-sdk/media-runtime";
10
- import { createChannelIngressError } from "openclaw/plugin-sdk/channel-outbound";
11
- import { createChannelPartialDeliveryError, formatInboundMediaUnavailableText, recordChannelBotPairLoopAndCheckSuppression, resolveChannelInboundRouteEnvelope, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
12
- import { WEBHOOK_RATE_LIMIT_DEFAULTS, canonicalizeWebhookRouteKey, createFixedWindowRateLimiter, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
13
- import { registerWebhookTargetWithPluginRoute, resolveWebhookTargetWithAuthOrReject, withResolvedWebhookRequestPipeline } from "openclaw/plugin-sdk/webhook-targets";
14
- import { createWebhookInFlightLimiter, readJsonWebhookBodyOrReject, runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
15
9
  import { channelIngressRoutes, createStandardRawEventIngressMonitor } from "openclaw/plugin-sdk/channel-ingress-runtime";
10
+ import { createChannelIngressError } from "openclaw/plugin-sdk/channel-outbound";
16
11
  import { channelBlockedPatch, channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
17
- import { isRecord } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
12
+ import { isRecord as isRecord$1 } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
18
13
  import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
14
+ import { createChannelPartialDeliveryError, formatInboundMediaUnavailableText, recordChannelBotPairLoopAndCheckSuppression, resolveChannelInboundRouteEnvelope, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
19
15
  import { parseDateStringTimestampMs } from "openclaw/plugin-sdk/number-runtime";
16
+ import { createRuntimeConfigReader } from "openclaw/plugin-sdk/runtime-config-snapshot";
17
+ import { WEBHOOK_RATE_LIMIT_DEFAULTS, canonicalizeWebhookRouteKey, createFixedWindowRateLimiter, resolveRequestClientIp, resolveWebhookPath } from "openclaw/plugin-sdk/webhook-ingress";
20
18
  import { resolveApprovalOverGateway } from "openclaw/plugin-sdk/approval-gateway-runtime";
19
+ import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
20
+ import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
21
+ import { GROUP_POLICY_BLOCKED_LABEL, resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
21
22
  import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
23
+ import { createWebhookInFlightLimiter, readJsonWebhookBodyOrReject, runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
24
+ import { registerWebhookTargetWithPluginRoute, resolveWebhookTargetWithAuthOrReject, withResolvedWebhookRequestPipeline } from "openclaw/plugin-sdk/webhook-targets";
22
25
  //#region extensions/googlechat/src/approval-terminal-card.ts
23
26
  const GOOGLECHAT_APPROVAL_CARD_ID = "openclaw-approval";
24
- const MAX_TEXT_PARAGRAPH_CHARS = 1800;
25
- function truncateText(text) {
26
- return text.length <= MAX_TEXT_PARAGRAPH_CHARS ? text : `${truncateUtf16Safe(text, 1797)}...`;
27
- }
28
- function formatApprovalId(value) {
29
- return JSON.stringify(value).slice(1, -1);
30
- }
31
27
  function formatCanonicalOutcome(approval) {
32
28
  switch (approval.status) {
33
29
  case "allowed": return approval.decision === "allow-always" ? "Allowed always" : "Allowed once";
@@ -40,12 +36,13 @@ function formatCanonicalOutcome(approval) {
40
36
  function buildSubjectSection(presentation) {
41
37
  if (presentation.kind === "exec") return {
42
38
  header: "Command",
43
- widgets: [{ textParagraph: { text: escapeGoogleChatApprovalCardText(truncateText(presentation.commandPreview ?? presentation.commandText)) } }]
39
+ widgets: [buildGoogleChatApprovalTextWidget(presentation.commandPreview ?? presentation.commandText)]
44
40
  };
45
41
  const description = presentation.description.trim();
42
+ const requestText = `<b>${escapeGoogleChatApprovalCardText(presentation.title)}</b>${description ? `<br>${escapeGoogleChatApprovalCardText(description)}` : ""}`;
46
43
  return {
47
44
  header: "Request",
48
- widgets: [{ textParagraph: { text: truncateText(`<b>${escapeGoogleChatApprovalCardText(presentation.title)}</b>${description ? `<br>${escapeGoogleChatApprovalCardText(description)}` : ""}`) } }]
45
+ widgets: [buildGoogleChatApprovalTextWidget(requestText, "html")]
49
46
  };
50
47
  }
51
48
  /** Render the canonical first-answer result without retaining any actionable buttons. */
@@ -53,7 +50,7 @@ function buildGoogleChatCanonicalApprovalTerminalCards(result) {
53
50
  const { approval } = result;
54
51
  const kindLabel = approval.presentation.kind === "plugin" ? "Plugin" : "Exec";
55
52
  const detailLines = [
56
- `<b>Approval ID:</b> ${escapeGoogleChatApprovalCardText(formatApprovalId(approval.id))}`,
53
+ `<b>Approval ID:</b> ${escapeGoogleChatApprovalCardText(JSON.stringify(approval.id).slice(1, -1))}`,
57
54
  `<b>Status:</b> ${escapeGoogleChatApprovalCardText(approval.status)}`,
58
55
  ...approval.status === "allowed" || approval.status === "denied" ? [`<b>Decision:</b> ${escapeGoogleChatApprovalCardText(approval.decision)}`] : [],
59
56
  `<b>Reason:</b> ${escapeGoogleChatApprovalCardText(approval.reason)}`
@@ -67,7 +64,7 @@ function buildGoogleChatCanonicalApprovalTerminalCards(result) {
67
64
  },
68
65
  sections: [buildSubjectSection(approval.presentation), {
69
66
  header: "Details",
70
- widgets: [{ textParagraph: { text: truncateText(detailLines.join("<br>")) } }]
67
+ widgets: [buildGoogleChatApprovalTextWidget(detailLines.join("<br>"), "html")]
71
68
  }]
72
69
  }
73
70
  }];
@@ -169,14 +166,13 @@ function resolveGoogleChatGroupConfig(params) {
169
166
  return {
170
167
  entry: deprecatedNameMatch ? void 0 : entry ?? fallback,
171
168
  allowlistConfigured: true,
172
- fallback,
173
169
  deprecatedNameMatch
174
170
  };
175
171
  }
176
172
  function extractMentionInfo(annotations, botUser) {
177
173
  const mentionAnnotations = annotations.filter((entry) => entry.type === "USER_MENTION");
178
174
  const hasAnyMention = mentionAnnotations.length > 0;
179
- const botTargets = new Set(["users/app", botUser?.trim()].filter(Boolean));
175
+ const botTargets = new Set(normalizeTrimmedStringList(["users/app", botUser]));
180
176
  return {
181
177
  hasAnyMention,
182
178
  wasMentioned: mentionAnnotations.some((entry) => {
@@ -190,7 +186,7 @@ function extractMentionInfo(annotations, botUser) {
190
186
  const warnedDeprecatedUsersEmailAllowFrom = /* @__PURE__ */ new Set();
191
187
  const warnedMutableGroupKeys = /* @__PURE__ */ new Set();
192
188
  function warnDeprecatedUsersEmailEntries(logVerbose, entries) {
193
- const deprecated = entries.map((v) => normalizeOptionalString(v)).filter((v) => Boolean(v)).filter((v) => /^users\/.+@.+/i.test(v));
189
+ const deprecated = normalizeTrimmedStringList(entries).filter((v) => /^users\/.+@.+/i.test(v));
194
190
  if (deprecated.length === 0) return;
195
191
  const key = deprecated.map((v) => normalizeLowercaseStringOrEmpty(v)).toSorted((a, b) => a.localeCompare(b)).join(",");
196
192
  if (warnedDeprecatedUsersEmailAllowFrom.has(key)) return;
@@ -426,11 +422,9 @@ function recordParamsToActionParameters(params) {
426
422
  }
427
423
  /** Normalize only at authenticated dispatch; durable admission stores the untouched envelope. */
428
424
  function parseGoogleChatInboundPayload(raw) {
429
- if (!isRecord(raw)) throw new GoogleChatEventPayloadError();
425
+ if (!isRecord$1(raw)) throw new GoogleChatEventPayloadError();
430
426
  let eventPayload = raw;
431
- let addOnBearerToken = "";
432
427
  const rawObj = raw;
433
- if (rawObj.commonEventObject?.hostApp === "CHAT") addOnBearerToken = typeof rawObj.authorizationEventObject?.systemIdToken === "string" ? rawObj.authorizationEventObject.systemIdToken.trim() : "";
434
428
  const chat = rawObj.chat;
435
429
  const messagePayload = chat?.messagePayload;
436
430
  if (rawObj.commonEventObject?.hostApp === "CHAT" && chat && messagePayload) eventPayload = {
@@ -465,14 +459,11 @@ function parseGoogleChatInboundPayload(raw) {
465
459
  }
466
460
  const event = eventPayload;
467
461
  const eventType = event.type ?? event.eventType;
468
- if (typeof eventType !== "string" || !isRecord(event.space)) throw new GoogleChatEventPayloadError();
462
+ if (typeof eventType !== "string" || !isRecord$1(event.space)) throw new GoogleChatEventPayloadError();
469
463
  if (eventType === "MESSAGE") {
470
- if (!isRecord(event.message) || !event.space?.name?.trim() || !event.message?.name?.trim()) throw new GoogleChatEventPayloadError();
471
- } else if (eventType === "CARD_CLICKED" && !isRecord(event.user)) throw new GoogleChatEventPayloadError();
472
- return {
473
- event,
474
- addOnBearerToken
475
- };
464
+ if (!isRecord$1(event.message) || !event.space?.name?.trim() || !event.message?.name?.trim()) throw new GoogleChatEventPayloadError();
465
+ } else if (eventType === "CARD_CLICKED" && !isRecord$1(event.user)) throw new GoogleChatEventPayloadError();
466
+ return event;
476
467
  }
477
468
  //#endregion
478
469
  //#region extensions/googlechat/src/monitor-ingress.ts
@@ -482,19 +473,19 @@ function requiredString(value, field) {
482
473
  throw new GoogleChatIngressPermanentError("invalid-event", `Google Chat MESSAGE event is missing ${field}.`);
483
474
  }
484
475
  function inspectGoogleChatIngressEvent(raw) {
485
- if (!isRecord(raw)) throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope must be an object.");
486
- const commonEventObject = isRecord(raw.commonEventObject) ? raw.commonEventObject : null;
487
- const chat = isRecord(raw.chat) ? raw.chat : null;
476
+ if (!isRecord$1(raw)) throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope must be an object.");
477
+ const commonEventObject = isRecord$1(raw.commonEventObject) ? raw.commonEventObject : null;
478
+ const chat = isRecord$1(raw.chat) ? raw.chat : null;
488
479
  const isAddOn = commonEventObject?.hostApp === "CHAT";
489
480
  let eventType = raw.type ?? raw.eventType;
490
- let space = isRecord(raw.space) ? raw.space : null;
491
- let message = isRecord(raw.message) ? raw.message : null;
481
+ let space = isRecord$1(raw.space) ? raw.space : null;
482
+ let message = isRecord$1(raw.message) ? raw.message : null;
492
483
  if (isAddOn) {
493
- const messagePayload = isRecord(chat?.messagePayload) ? chat.messagePayload : null;
484
+ const messagePayload = isRecord$1(chat?.messagePayload) ? chat.messagePayload : null;
494
485
  if (!messagePayload) return null;
495
486
  eventType = "MESSAGE";
496
- space = isRecord(messagePayload.space) ? messagePayload.space : null;
497
- message = isRecord(messagePayload.message) ? messagePayload.message : null;
487
+ space = isRecord$1(messagePayload.space) ? messagePayload.space : null;
488
+ message = isRecord$1(messagePayload.message) ? messagePayload.message : null;
498
489
  }
499
490
  if (eventType !== "MESSAGE") return null;
500
491
  const spaceName = requiredString(space?.name, "space.name");
@@ -514,9 +505,9 @@ function deserializeGoogleChatIngressEvent(rawEvent, claimedId) {
514
505
  }
515
506
  function normalizeClaimedGoogleChatEvent(raw, claimedId) {
516
507
  try {
517
- const parsed = parseGoogleChatInboundPayload(raw);
518
- if ((parsed.event.type ?? parsed.event.eventType) !== "MESSAGE") throw new GoogleChatEventPayloadError();
519
- return parsed.event;
508
+ const event = parseGoogleChatInboundPayload(raw);
509
+ if ((event.type ?? event.eventType) !== "MESSAGE") throw new GoogleChatEventPayloadError();
510
+ return event;
520
511
  } catch (error) {
521
512
  throw new GoogleChatIngressPermanentError("invalid-event", `Google Chat ingress row ${claimedId} cannot be normalized.`, { cause: error });
522
513
  }
@@ -537,7 +528,7 @@ function resolveGoogleChatIngressNonRetryableFailure(error) {
537
528
  }
538
529
  function createGoogleChatIngressMonitor(options) {
539
530
  const serializeForIngress = (rawEvent) => {
540
- if (!isRecord(rawEvent)) throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope must be an object.");
531
+ if (!isRecord$1(rawEvent)) throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope must be an object.");
541
532
  const durableEvent = { ...rawEvent };
542
533
  delete durableEvent.authorizationEventObject;
543
534
  const serialized = JSON.stringify(durableEvent);
@@ -546,7 +537,7 @@ function createGoogleChatIngressMonitor(options) {
546
537
  };
547
538
  return createStandardRawEventIngressMonitor({
548
539
  queue: options.queue ?? (() => getGoogleChatRuntime().state.openChannelIngressQueue({ accountId: options.accountId })),
549
- inspect: (rawEvent) => inspectGoogleChatIngressEvent(rawEvent),
540
+ inspect: inspectGoogleChatIngressEvent,
550
541
  payload: {
551
542
  serialize: serializeForIngress,
552
543
  deserialize: (rawEvent, { claim }) => deserializeGoogleChatIngressEvent(rawEvent, claim.id),
@@ -683,13 +674,13 @@ const ADD_ON_PREAUTH_TIMEOUT_MS = 3e3;
683
674
  const GOOGLECHAT_WEBHOOK_ACCEPTED_HEADER = "x-openclaw-delivery-accepted";
684
675
  const GOOGLECHAT_WEBHOOK_ACCEPTED_VALUE = "durable";
685
676
  function parseGoogleChatInboundPayloadOrReject(raw, res) {
686
- if (!isRecord(raw)) {
677
+ if (!isRecord$1(raw)) {
687
678
  res.statusCode = 400;
688
679
  res.end("invalid payload");
689
680
  return null;
690
681
  }
691
- const commonEventObject = isRecord(raw.commonEventObject) ? raw.commonEventObject : null;
692
- const authorizationEventObject = isRecord(raw.authorizationEventObject) ? raw.authorizationEventObject : null;
682
+ const commonEventObject = isRecord$1(raw.commonEventObject) ? raw.commonEventObject : null;
683
+ const authorizationEventObject = isRecord$1(raw.authorizationEventObject) ? raw.authorizationEventObject : null;
693
684
  let addOnBearerToken = "";
694
685
  if (commonEventObject?.hostApp === "CHAT" && typeof authorizationEventObject?.systemIdToken === "string") addOnBearerToken = authorizationEventObject.systemIdToken.trim();
695
686
  return {
@@ -697,27 +688,9 @@ function parseGoogleChatInboundPayloadOrReject(raw, res) {
697
688
  addOnBearerToken
698
689
  };
699
690
  }
700
- async function verifyGoogleChatTargetAuth(target, bearer) {
701
- const verification = await verifyGoogleChatRequest({
702
- bearer,
703
- audienceType: target.audienceType,
704
- audience: target.audience,
705
- expectedAddOnPrincipal: target.account.config.appPrincipal
706
- });
707
- return verification.ok ? { ok: true } : {
708
- ok: false,
709
- reason: verification.reason ?? "unknown"
710
- };
711
- }
712
691
  function logGoogleChatWebhookAuthRejections(rejections) {
713
692
  for (const rejection of rejections) rejection.target.runtime.log?.(`[${rejection.target.account.accountId}] Google Chat webhook auth rejected: ${rejection.reason}`);
714
693
  }
715
- function logGoogleChatWebhookAuthRejectedForTargets(targets, reason) {
716
- logGoogleChatWebhookAuthRejections(targets.map((target) => ({
717
- target,
718
- reason
719
- })));
720
- }
721
694
  async function resolveGoogleChatWebhookTargetWithAuthOrReject(params) {
722
695
  const rejections = [];
723
696
  let verifiedTargetCount = 0;
@@ -725,14 +698,19 @@ async function resolveGoogleChatWebhookTargetWithAuthOrReject(params) {
725
698
  targets: params.targets,
726
699
  res: params.res,
727
700
  isMatch: async (target) => {
728
- const verification = await verifyGoogleChatTargetAuth(target, params.bearer);
701
+ const verification = await verifyGoogleChatRequest({
702
+ bearer: params.bearer,
703
+ audienceType: target.audienceType,
704
+ audience: target.audience,
705
+ expectedAddOnPrincipal: target.account.config.appPrincipal
706
+ });
729
707
  if (verification.ok) {
730
708
  verifiedTargetCount += 1;
731
709
  return true;
732
710
  }
733
711
  rejections.push({
734
712
  target,
735
- reason: verification.reason
713
+ reason: verification.reason ?? "unknown"
736
714
  });
737
715
  return false;
738
716
  }
@@ -794,7 +772,10 @@ function createGoogleChatWebhookRequestHandler(params) {
794
772
  if (!parsed) return true;
795
773
  parsedInbound = parsed;
796
774
  if (!parsed.addOnBearerToken) {
797
- logGoogleChatWebhookAuthRejectedForTargets(targets, "missing token");
775
+ logGoogleChatWebhookAuthRejections(targets.map((target) => ({
776
+ target,
777
+ reason: "missing token"
778
+ })));
798
779
  res.statusCode = 401;
799
780
  res.end("unauthorized");
800
781
  return true;
@@ -806,11 +787,6 @@ function createGoogleChatWebhookRequestHandler(params) {
806
787
  });
807
788
  if (!selectedTarget) return true;
808
789
  }
809
- if (!selectedTarget || !parsedInbound) {
810
- res.statusCode = 401;
811
- res.end("unauthorized");
812
- return true;
813
- }
814
790
  const dispatchTarget = selectedTarget;
815
791
  dispatchTarget.statusSink?.({ lastInboundAt: Date.now() });
816
792
  try {
@@ -823,7 +799,7 @@ function createGoogleChatWebhookRequestHandler(params) {
823
799
  if (admission.kind === "ignored") {
824
800
  let event;
825
801
  try {
826
- event = parseGoogleChatInboundPayload(parsedInbound.raw).event;
802
+ event = parseGoogleChatInboundPayload(parsedInbound.raw);
827
803
  } catch {
828
804
  res.statusCode = 400;
829
805
  res.end("invalid payload");
@@ -882,7 +858,7 @@ function registerGoogleChatWebhookTarget(target) {
882
858
  log: target.runtime.log,
883
859
  throwOnFailure: true,
884
860
  handler: async (req, res) => {
885
- if (!await handleGoogleChatWebhookRequest(req, res) && !res.headersSent) {
861
+ if (!await googleChatWebhookRequestHandler(req, res) && !res.headersSent) {
886
862
  res.statusCode = 404;
887
863
  res.setHeader("Content-Type", "text/plain; charset=utf-8");
888
864
  res.end("Not Found");
@@ -891,9 +867,6 @@ function registerGoogleChatWebhookTarget(target) {
891
867
  }
892
868
  }).unregister;
893
869
  }
894
- async function handleGoogleChatWebhookRequest(req, res) {
895
- return await googleChatWebhookRequestHandler(req, res);
896
- }
897
870
  //#endregion
898
871
  //#region extensions/googlechat/src/monitor.ts
899
872
  setGoogleChatWebhookEventProcessor(processGoogleChatEvent);
@@ -905,29 +878,14 @@ function normalizeAudienceType(value) {
905
878
  if (normalized === "app-url" || normalized === "app_url" || normalized === "app") return "app-url";
906
879
  if (normalized === "project-number" || normalized === "project_number" || normalized === "project") return "project-number";
907
880
  }
908
- function resolveGoogleChatBotLoopProtection(params) {
909
- if (!params.allowBots || !params.isBotSender || !params.senderId || params.senderId === params.appUserId) return;
910
- return {
911
- scopeId: params.accountId,
912
- conversationId: params.conversationId,
913
- senderId: params.senderId,
914
- receiverId: params.appUserId,
915
- config: params.config,
916
- defaultsConfig: params.defaultsConfig,
917
- defaultEnabled: true,
918
- nowMs: parseDateStringTimestampMs(params.eventTime)
919
- };
920
- }
921
- function resolveGoogleChatBotLoopProtectionConfig(params) {
922
- return mergePairLoopGuardConfig(params.accountConfig, params.groupConfig);
923
- }
924
- function shouldSuppressGoogleChatBotLoop(params) {
925
- if (!params.botLoopProtection) return false;
926
- if (!recordChannelBotPairLoopAndCheckSuppression(params.botLoopProtection).suppressed) return false;
927
- logVerbose(params.core, params.runtime, `skip bot-to-bot loop in ${params.botLoopProtection.conversationId}`);
928
- return true;
881
+ function resolveBotDisplayName(params) {
882
+ const { accountName, agentId, config } = params;
883
+ if (accountName?.trim()) return accountName.trim();
884
+ const agent = resolveAgentConfig(config, agentId);
885
+ if (agent?.name?.trim()) return agent.name.trim();
886
+ return agent?.identity?.name?.trim() || "OpenClaw";
929
887
  }
930
- async function processGoogleChatEvent(event, target, turnAdoptionLifecycle) {
888
+ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, config = target.config) {
931
889
  const eventType = event.type ?? event.eventType;
932
890
  if (eventType === "CARD_CLICKED") {
933
891
  await maybeHandleGoogleChatApprovalCardClick({
@@ -937,33 +895,7 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle) {
937
895
  return;
938
896
  }
939
897
  if (eventType !== "MESSAGE") return;
940
- if (!event.message || !event.space) return;
941
- await processMessageWithPipeline({
942
- event,
943
- account: target.account,
944
- config: target.config,
945
- runtime: target.runtime,
946
- core: target.core,
947
- statusSink: target.statusSink,
948
- mediaMaxMb: target.mediaMaxMb,
949
- turnAdoptionLifecycle
950
- });
951
- }
952
- /**
953
- * Resolve bot display name with fallback chain:
954
- * 1. Account config name
955
- * 2. Agent name from config
956
- * 3. Agent identity name, then "OpenClaw"
957
- */
958
- function resolveBotDisplayName(params) {
959
- const { accountName, agentId, config } = params;
960
- if (accountName?.trim()) return accountName.trim();
961
- const agent = resolveAgentConfig(config, agentId);
962
- if (agent?.name?.trim()) return agent.name.trim();
963
- return agent?.identity?.name?.trim() || "OpenClaw";
964
- }
965
- async function processMessageWithPipeline(params) {
966
- const { event, account, config, runtime, core, statusSink, mediaMaxMb, turnAdoptionLifecycle } = params;
898
+ const { account, runtime, core, statusSink, mediaMaxMb } = target;
967
899
  const space = event.space;
968
900
  const message = event.message;
969
901
  if (!space || !message) return;
@@ -1022,24 +954,21 @@ async function processMessageWithPipeline(params) {
1022
954
  });
1023
955
  if (!access.ok) return;
1024
956
  const { commandAuthorized, effectiveWasMentioned, groupBotLoopProtection, groupSystemPrompt } = access;
1025
- if (shouldSuppressGoogleChatBotLoop({
1026
- botLoopProtection: resolveGoogleChatBotLoopProtection({
1027
- allowBots,
1028
- isBotSender,
1029
- senderId,
1030
- appUserId,
1031
- accountId: account.accountId,
957
+ if (allowBots && isBotSender && senderId && senderId !== appUserId) {
958
+ if (recordChannelBotPairLoopAndCheckSuppression({
959
+ scopeId: account.accountId,
1032
960
  conversationId: spaceId,
1033
- config: resolveGoogleChatBotLoopProtectionConfig({
1034
- accountConfig: account.config.botLoopProtection,
1035
- groupConfig: groupBotLoopProtection
1036
- }),
961
+ senderId,
962
+ receiverId: appUserId,
963
+ config: mergePairLoopGuardConfig(account.config.botLoopProtection, groupBotLoopProtection),
1037
964
  defaultsConfig: config.channels?.defaults?.botLoopProtection,
1038
- eventTime: event.eventTime
1039
- }),
1040
- core,
1041
- runtime
1042
- })) return;
965
+ defaultEnabled: true,
966
+ nowMs: parseDateStringTimestampMs(event.eventTime)
967
+ }).suppressed) {
968
+ logVerbose(core, runtime, `skip bot-to-bot loop in ${spaceId}`);
969
+ return;
970
+ }
971
+ }
1043
972
  const mediaInputs = attachments.map((attachment) => ({ contentType: attachment.contentType }));
1044
973
  const first = attachments.at(0);
1045
974
  if (first) try {
@@ -1231,13 +1160,9 @@ async function downloadAttachment(attachment, account, mediaMaxMb, core) {
1231
1160
  contentType: saved.contentType
1232
1161
  };
1233
1162
  }
1234
- async function monitorGoogleChatProvider(options) {
1163
+ async function startGoogleChatMonitor(options) {
1235
1164
  const core = getGoogleChatRuntime();
1236
- const webhookPath = resolveWebhookPath({
1237
- webhookPath: options.webhookPath,
1238
- webhookUrl: options.webhookUrl,
1239
- defaultPath: "/googlechat"
1240
- });
1165
+ const webhookPath = resolveGoogleChatWebhookPath(options);
1241
1166
  if (!webhookPath) {
1242
1167
  options.runtime.error?.(`[${options.account.accountId}] invalid webhook path`);
1243
1168
  return async () => {};
@@ -1261,12 +1186,13 @@ async function monitorGoogleChatProvider(options) {
1261
1186
  appPrincipal: options.account.config.appPrincipal,
1262
1187
  log: options.runtime.log
1263
1188
  });
1189
+ const readConfig = createRuntimeConfigReader(options.config);
1264
1190
  const ingress = createGoogleChatIngressMonitor({
1265
1191
  accountId: options.account.accountId,
1266
1192
  runtime: options.runtime,
1267
1193
  abortSignal: options.abortSignal,
1268
1194
  dispatch: async (event, lifecycle) => {
1269
- await processGoogleChatEvent(event, target, lifecycle);
1195
+ await processGoogleChatEvent(event, target, lifecycle, readConfig());
1270
1196
  }
1271
1197
  });
1272
1198
  const target = {
@@ -1295,13 +1221,10 @@ async function monitorGoogleChatProvider(options) {
1295
1221
  await ingress.stop();
1296
1222
  };
1297
1223
  }
1298
- async function startGoogleChatMonitor(params) {
1299
- return await monitorGoogleChatProvider(params);
1300
- }
1301
- function resolveGoogleChatWebhookPath(params) {
1224
+ function resolveGoogleChatWebhookPath({ webhookPath, webhookUrl }) {
1302
1225
  return resolveWebhookPath({
1303
- webhookPath: params.account.config.webhookPath,
1304
- webhookUrl: params.account.config.webhookUrl,
1226
+ webhookPath,
1227
+ webhookUrl,
1305
1228
  defaultPath: "/googlechat"
1306
1229
  });
1307
1230
  }