@openclaw/googlechat 2026.10.10-beta.5 → 2026.11.5-beta.1

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 (145) hide show
  1. package/dist/.setup/{actions-CSE3qGrO.mjs → actions-DNDmJvwi.mjs} +16 -15
  2. package/dist/.setup/{approval-auth-DH1sJm7S.mjs → approval-auth-AkJ2Rg0h.mjs} +3 -4
  3. package/dist/.setup/{approval-card-text-BKg_4mXq.mjs → approval-card-text-9o-Dfr9Z.mjs} +1 -2
  4. package/dist/.setup/{approval-handler.runtime-Bx0dTqDd.mjs → approval-handler.runtime-CKuHeY6y.mjs} +5 -6
  5. package/dist/.setup/{channel-BBRTocXs.mjs → channel-WKI4stP3.mjs} +84 -98
  6. package/dist/.setup/{channel-base-sWlG7EP1.mjs → channel-base-DjVHuLDF.mjs} +17 -22
  7. package/dist/.setup/{channel.adapters--OFb3A2Y.mjs → channel.adapters-C9mflxGl.mjs} +271 -334
  8. package/dist/.setup/{channel.runtime-uaSH6k2d.mjs → channel.runtime-CBwK8353.mjs} +305 -357
  9. package/dist/.setup/{doctor-contract-BzoaiFSD.mjs → doctor-contract-WrFOPxEj.mjs} +6 -12
  10. package/dist/.setup/{runtime-C5OOOlaP.mjs → runtime-zEzHA5rr.mjs} +1 -2
  11. package/dist/.setup/{secret-contract-api-BG_8yVjr.mjs → secret-contract-api-CLRweErW.mjs} +1 -1
  12. package/dist/.setup/{secret-contract-D7KjX374.mjs → secret-contract-h2P-4VpL.mjs} +1 -2
  13. package/dist/.setup/setup-plugin-api-Bz3mVqQ5.mjs +2 -0
  14. package/dist/.source-module-urls/974ffefea973cf3ea18e1534d25b091bcf1b68760a2b9eda0cd9bd9392096c64.json +1 -1
  15. package/dist/api.js +2 -2
  16. package/dist/channel-config-api.js +1 -2
  17. package/dist/channel-plugin-api.js +1 -1
  18. package/dist/directory-contract-api.js +2 -3
  19. package/dist/doctor-contract-api.js +1 -1
  20. package/dist/index.js +1 -2
  21. package/dist/runtime-api.js +1 -1
  22. package/dist/secret-contract-api.js +1 -1
  23. package/dist/setup-entry.js +3 -4
  24. package/dist/setup-plugin-api.js +1 -1
  25. package/node_modules/google-auth-library/build/src/auth/authclient.js.map +1 -0
  26. package/node_modules/google-auth-library/build/src/auth/awsclient.js.map +1 -0
  27. package/node_modules/google-auth-library/build/src/auth/awsrequestsigner.js.map +1 -0
  28. package/node_modules/google-auth-library/build/src/auth/baseexternalclient.js.map +1 -0
  29. package/node_modules/google-auth-library/build/src/auth/certificatesubjecttokensupplier.js.map +1 -0
  30. package/node_modules/google-auth-library/build/src/auth/computeclient.js.map +1 -0
  31. package/node_modules/google-auth-library/build/src/auth/credentials.js.map +1 -0
  32. package/node_modules/google-auth-library/build/src/auth/defaultawssecuritycredentialssupplier.js.map +1 -0
  33. package/node_modules/google-auth-library/build/src/auth/downscopedclient.js.map +1 -0
  34. package/node_modules/google-auth-library/build/src/auth/envDetect.js.map +1 -0
  35. package/node_modules/google-auth-library/build/src/auth/executable-response.js.map +1 -0
  36. package/node_modules/google-auth-library/build/src/auth/externalAccountAuthorizedUserClient.js.map +1 -0
  37. package/node_modules/google-auth-library/build/src/auth/externalclient.js.map +1 -0
  38. package/node_modules/google-auth-library/build/src/auth/filesubjecttokensupplier.js.map +1 -0
  39. package/node_modules/google-auth-library/build/src/auth/gdchclient.js.map +1 -0
  40. package/node_modules/google-auth-library/build/src/auth/googleauth.js.map +1 -0
  41. package/node_modules/google-auth-library/build/src/auth/iam.js.map +1 -0
  42. package/node_modules/google-auth-library/build/src/auth/identitypoolclient.js.map +1 -0
  43. package/node_modules/google-auth-library/build/src/auth/idtokenclient.js.map +1 -0
  44. package/node_modules/google-auth-library/build/src/auth/impersonated.js.map +1 -0
  45. package/node_modules/google-auth-library/build/src/auth/jwtaccess.js.map +1 -0
  46. package/node_modules/google-auth-library/build/src/auth/jwtclient.js.map +1 -0
  47. package/node_modules/google-auth-library/build/src/auth/loginticket.js.map +1 -0
  48. package/node_modules/google-auth-library/build/src/auth/oauth2client.js.map +1 -0
  49. package/node_modules/google-auth-library/build/src/auth/oauth2common.js.map +1 -0
  50. package/node_modules/google-auth-library/build/src/auth/passthrough.js.map +1 -0
  51. package/node_modules/google-auth-library/build/src/auth/pluggable-auth-client.js.map +1 -0
  52. package/node_modules/google-auth-library/build/src/auth/pluggable-auth-handler.js.map +1 -0
  53. package/node_modules/google-auth-library/build/src/auth/refreshclient.js.map +1 -0
  54. package/node_modules/google-auth-library/build/src/auth/stscredentials.js.map +1 -0
  55. package/node_modules/google-auth-library/build/src/auth/urlsubjecttokensupplier.js.map +1 -0
  56. package/node_modules/google-auth-library/build/src/crypto/browser/crypto.js.map +1 -0
  57. package/node_modules/google-auth-library/build/src/crypto/crypto.js.map +1 -0
  58. package/node_modules/google-auth-library/build/src/crypto/node/crypto.js.map +1 -0
  59. package/node_modules/google-auth-library/build/src/crypto/shared.js.map +1 -0
  60. package/node_modules/google-auth-library/build/src/gtoken/errorWithCode.js.map +1 -0
  61. package/node_modules/google-auth-library/build/src/gtoken/getCredentials.js.map +1 -0
  62. package/node_modules/google-auth-library/build/src/gtoken/getToken.js.map +1 -0
  63. package/node_modules/google-auth-library/build/src/gtoken/googleToken.js.map +1 -0
  64. package/node_modules/google-auth-library/build/src/gtoken/jwsSign.js.map +1 -0
  65. package/node_modules/google-auth-library/build/src/gtoken/revokeToken.js.map +1 -0
  66. package/node_modules/google-auth-library/build/src/gtoken/tokenHandler.js.map +1 -0
  67. package/node_modules/google-auth-library/build/src/gtoken/tokenOptions.js.map +1 -0
  68. package/node_modules/google-auth-library/build/src/index.js.map +1 -0
  69. package/node_modules/google-auth-library/build/src/shared.cjs.map +1 -0
  70. package/node_modules/google-auth-library/build/src/util.js.map +1 -0
  71. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/gaxios.js +166 -5
  72. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/gaxios.js.map +1 -1
  73. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/retry.js +12 -2
  74. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/retry.js.map +1 -1
  75. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/gaxios.js +167 -6
  76. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/gaxios.js.map +1 -1
  77. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/retry.js +12 -2
  78. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/retry.js.map +1 -1
  79. package/node_modules/google-auth-library/node_modules/gaxios/package.json +32 -25
  80. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js +14 -1
  81. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js.map +1 -1
  82. package/node_modules/google-auth-library/node_modules/gcp-metadata/package.json +19 -20
  83. package/node_modules/google-auth-library/node_modules/google-logging-utils/package.json +2 -2
  84. package/node_modules/google-auth-library/package.json +7 -9
  85. package/node_modules/zod/package.json +1 -1
  86. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  87. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  88. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  89. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  90. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  91. package/node_modules/zod/src/v4/core/util.ts +13 -0
  92. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  93. package/node_modules/zod/v4/core/compile.cjs +8 -0
  94. package/node_modules/zod/v4/core/compile.js +8 -0
  95. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  96. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  97. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  98. package/node_modules/zod/v4/core/schemas.js +30 -0
  99. package/node_modules/zod/v4/core/util.cjs +15 -0
  100. package/node_modules/zod/v4/core/util.d.cts +2 -0
  101. package/node_modules/zod/v4/core/util.d.ts +2 -0
  102. package/node_modules/zod/v4/core/util.js +14 -0
  103. package/node_modules/zod/v4/core/versions.cjs +1 -1
  104. package/node_modules/zod/v4/core/versions.js +1 -1
  105. package/openclaw.plugin.json +0 -30
  106. package/package.json +6 -6
  107. package/dist/.setup/setup-plugin-api-CFDZH0Qp.mjs +0 -2
  108. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.d.ts +0 -1
  109. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.js +0 -109
  110. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.js.map +0 -1
  111. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.d.ts +0 -1
  112. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.js +0 -81
  113. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.js.map +0 -1
  114. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.d.ts +0 -1
  115. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.js +0 -128
  116. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.js.map +0 -1
  117. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.d.ts +0 -1
  118. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.js +0 -1510
  119. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.js.map +0 -1
  120. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.d.ts +0 -1
  121. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.js +0 -61
  122. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.js.map +0 -1
  123. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.d.ts +0 -1
  124. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.js +0 -367
  125. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.js.map +0 -1
  126. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  127. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.d.ts +0 -1
  128. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.js +0 -71
  129. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.js.map +0 -1
  130. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.d.ts +0 -1
  131. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.js +0 -76
  132. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.js.map +0 -1
  133. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.d.ts +0 -1
  134. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.js +0 -123
  135. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.js.map +0 -1
  136. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.d.ts +0 -1
  137. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.js +0 -1472
  138. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.js.map +0 -1
  139. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.d.ts +0 -1
  140. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.js +0 -23
  141. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.js.map +0 -1
  142. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.d.ts +0 -1
  143. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.js +0 -362
  144. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.js.map +0 -1
  145. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/tsconfig.tsbuildinfo +0 -1
@@ -1,14 +1,16 @@
1
- import { C as updateGoogleChatMessage, D as googleChatApprovalControls, O as readGoogleChatApprovalActionToken, S as sendGoogleChatMessage, b as downloadGoogleChatMedia, c as googleChatIngressIdentity, d as formatGoogleChatTextChunks, f as isGoogleChatGroupSpace, l as normalizeGoogleChatUserId, u as buildGoogleChatGroupPolicyScope, v as GoogleChatApiError, w as verifyGoogleChatRequest, x as probeGoogleChat, y as deleteGoogleChatMessage } from "./channel.adapters--OFb3A2Y.mjs";
2
- import { n as googleChatApprovalAuth } from "./approval-auth-DH1sJm7S.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";
1
+ import { C as sendGoogleChatMessage, O as googleChatApprovalControls, S as probeGoogleChat, T as verifyGoogleChatRequest, b as deleteGoogleChatMessage, c as googleChatIngressIdentity, d as formatGoogleChatMediaText, f as formatGoogleChatTextChunks, k as readGoogleChatApprovalActionToken, l as normalizeGoogleChatUserId, p as isGoogleChatGroupSpace, u as buildGoogleChatGroupPolicyScope, w as updateGoogleChatMessage, x as downloadGoogleChatMedia, y as GoogleChatApiError } from "./channel.adapters-C9mflxGl.mjs";
2
+ import { n as googleChatApprovalAuth } from "./approval-auth-AkJ2Rg0h.mjs";
3
+ import { t as getGoogleChatRuntime } from "./runtime-zEzHA5rr.mjs";
4
+ import { n as escapeGoogleChatApprovalCardText, t as buildGoogleChatApprovalTextWidget } from "./approval-card-text-9o-Dfr9Z.mjs";
5
+ import { createChannelIngressError } from "openclaw/plugin-sdk/channel-outbound";
6
+ import { channelBlockedPatch, channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
5
7
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
6
8
  import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";
7
9
  import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
8
10
  import { MediaFetchError } from "openclaw/plugin-sdk/media-runtime";
11
+ import { formatApprovalDecisionLabel } from "openclaw/plugin-sdk/approval-runtime";
9
12
  import { channelIngressRoutes, createStandardRawEventIngressMonitor } from "openclaw/plugin-sdk/channel-ingress-runtime";
10
- import { createChannelIngressError } from "openclaw/plugin-sdk/channel-outbound";
11
- import { channelBlockedPatch, channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
13
+ import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
12
14
  import { isRecord as isRecord$1 } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
13
15
  import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
14
16
  import { createChannelInboundEnvelopeBuilderAsync, createChannelPartialDeliveryError, formatInboundMediaUnavailableText, recordChannelBotPairLoopAndCheckSuppression, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
@@ -20,19 +22,13 @@ import { resolveApprovalOverGateway } from "openclaw/plugin-sdk/approval-gateway
20
22
  import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
21
23
  import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
22
24
  import { GROUP_POLICY_BLOCKED_LABEL, resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
23
- import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
24
25
  import { createWebhookInFlightLimiter, readJsonWebhookBodyOrReject, runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
25
26
  import { registerWebhookTargetWithPluginRoute, resolveWebhookTargetWithAuthOrReject, withResolvedWebhookRequestPipeline } from "openclaw/plugin-sdk/webhook-targets";
26
- //#region extensions/googlechat/src/approval-terminal-card.ts
27
+ // extensions/googlechat/src/approval-card-click.ts
27
28
  const GOOGLECHAT_APPROVAL_CARD_ID = "openclaw-approval";
28
29
  function formatCanonicalOutcome(approval) {
29
- switch (approval.status) {
30
- case "allowed": return approval.decision === "allow-always" ? "Allowed always" : "Allowed once";
31
- case "denied": return "Denied";
32
- case "expired": return "Expired";
33
- case "cancelled": return "Cancelled";
34
- }
35
- return "Unavailable";
30
+ if (approval.status === "allowed" || approval.status === "denied") return formatApprovalDecisionLabel(approval.decision);
31
+ return approval.status === "expired" ? "Expired" : approval.status === "cancelled" ? "Cancelled" : "Unavailable";
36
32
  }
37
33
  function buildSubjectSection(presentation) {
38
34
  if (presentation.kind === "exec") return {
@@ -46,32 +42,6 @@ function buildSubjectSection(presentation) {
46
42
  widgets: [buildGoogleChatApprovalTextWidget(requestText, "html")]
47
43
  };
48
44
  }
49
- /** Render the canonical first-answer result without retaining any actionable buttons. */
50
- function buildGoogleChatCanonicalApprovalTerminalCards(result) {
51
- const { approval } = result;
52
- const kindLabel = approval.presentation.kind === "plugin" ? "Plugin" : "Exec";
53
- const detailLines = [
54
- `<b>Approval ID:</b> ${escapeGoogleChatApprovalCardText(JSON.stringify(approval.id).slice(1, -1))}`,
55
- `<b>Status:</b> ${escapeGoogleChatApprovalCardText(approval.status)}`,
56
- ...approval.status === "allowed" || approval.status === "denied" ? [`<b>Decision:</b> ${escapeGoogleChatApprovalCardText(approval.decision)}`] : [],
57
- `<b>Reason:</b> ${escapeGoogleChatApprovalCardText(approval.reason)}`
58
- ];
59
- return [{
60
- cardId: GOOGLECHAT_APPROVAL_CARD_ID,
61
- card: {
62
- header: {
63
- title: `${kindLabel} Approval: ${formatCanonicalOutcome(approval)}`,
64
- subtitle: result.applied ? "Resolved by this action" : "Already resolved"
65
- },
66
- sections: [buildSubjectSection(approval.presentation), {
67
- header: "Details",
68
- widgets: [buildGoogleChatApprovalTextWidget(detailLines.join("<br>"), "html")]
69
- }]
70
- }
71
- }];
72
- }
73
- //#endregion
74
- //#region extensions/googlechat/src/approval-card-click.ts
75
45
  function logIgnored(target, message) {
76
46
  target.runtime.log?.(`[${target.account.accountId}] googlechat approval ignored: ${message}`);
77
47
  }
@@ -121,10 +91,30 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
121
91
  accountId: params.target.account.accountId,
122
92
  senderId: actor
123
93
  });
94
+ const { approval } = result;
95
+ const kindLabel = approval.presentation.kind === "plugin" ? "Plugin" : "Exec";
96
+ const detailLines = [
97
+ `<b>Approval ID:</b> ${escapeGoogleChatApprovalCardText(JSON.stringify(approval.id).slice(1, -1))}`,
98
+ `<b>Status:</b> ${escapeGoogleChatApprovalCardText(approval.status)}`,
99
+ ...approval.status === "allowed" || approval.status === "denied" ? [`<b>Decision:</b> ${escapeGoogleChatApprovalCardText(approval.decision)}`] : [],
100
+ `<b>Reason:</b> ${escapeGoogleChatApprovalCardText(approval.reason)}`
101
+ ];
124
102
  await updateGoogleChatMessage({
125
103
  account: params.target.account,
126
104
  messageName: consumed.messageName,
127
- cardsV2: buildGoogleChatCanonicalApprovalTerminalCards(result)
105
+ cardsV2: [{
106
+ cardId: GOOGLECHAT_APPROVAL_CARD_ID,
107
+ card: {
108
+ header: {
109
+ title: `${kindLabel} Approval: ${formatCanonicalOutcome(approval)}`,
110
+ subtitle: result.applied ? "Resolved by this action" : "Already resolved"
111
+ },
112
+ sections: [buildSubjectSection(approval.presentation), {
113
+ header: "Details",
114
+ widgets: [buildGoogleChatApprovalTextWidget(detailLines.join("<br>"), "html")]
115
+ }]
116
+ }
117
+ }]
128
118
  });
129
119
  return result;
130
120
  });
@@ -138,38 +128,7 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
138
128
  params.target.runtime.log?.(`[${params.target.account.accountId}] googlechat approval ${label} id=${consumed.approvalId} status=${result.approval.status} decision=${decision} sender=${actor || "unknown"}`);
139
129
  return true;
140
130
  }
141
- //#endregion
142
- //#region extensions/googlechat/src/monitor-access.ts
143
- function resolveGoogleChatGroupConfig(params) {
144
- const { groupId, groupName, groups } = params;
145
- const entries = groups ?? {};
146
- const keys = Object.keys(entries);
147
- if (keys.length === 0) return {
148
- entry: void 0,
149
- allowlistConfigured: false,
150
- deprecatedNameMatch: false
151
- };
152
- const { "*": fallback, ...scopes } = entries;
153
- const scope = buildGoogleChatGroupPolicyScope({
154
- tree: {
155
- defaults: fallback,
156
- scopes
157
- },
158
- groupId
159
- });
160
- const entry = scope.matchKey ? entries[scope.matchKey] : void 0;
161
- const normalizedGroupName = normalizeLowercaseStringOrEmpty(groupName ?? "");
162
- const deprecatedNameMatch = !entry && Boolean(groupName && keys.some((key) => {
163
- const trimmed = key.trim();
164
- if (!trimmed || trimmed === "*" || /^spaces\//i.test(trimmed)) return false;
165
- return trimmed === groupName || normalizeLowercaseStringOrEmpty(trimmed) === normalizedGroupName;
166
- }));
167
- return {
168
- entry: deprecatedNameMatch ? void 0 : entry ?? fallback,
169
- allowlistConfigured: true,
170
- deprecatedNameMatch
171
- };
172
- }
131
+ // extensions/googlechat/src/monitor-access.ts
173
132
  function extractMentionInfo(annotations, botUser) {
174
133
  const mentionAnnotations = annotations.filter((entry) => entry.type === "USER_MENTION");
175
134
  const hasAnyMention = mentionAnnotations.length > 0;
@@ -186,21 +145,15 @@ function extractMentionInfo(annotations, botUser) {
186
145
  }
187
146
  const warnedDeprecatedUsersEmailAllowFrom = /* @__PURE__ */ new Set();
188
147
  const warnedMutableGroupKeys = /* @__PURE__ */ new Set();
148
+ function markDeprecatedEntriesWarning(entries, warned) {
149
+ const key = entries.map((entry) => normalizeLowercaseStringOrEmpty(entry)).toSorted((a, b) => a.localeCompare(b)).join(",");
150
+ if (entries.length === 0 || warned.has(key)) return false;
151
+ warned.add(key);
152
+ return true;
153
+ }
189
154
  function warnDeprecatedUsersEmailEntries(logVerbose, entries) {
190
155
  const deprecated = normalizeTrimmedStringList(entries).filter((v) => /^users\/.+@.+/i.test(v));
191
- if (deprecated.length === 0) return;
192
- const key = deprecated.map((v) => normalizeLowercaseStringOrEmpty(v)).toSorted((a, b) => a.localeCompare(b)).join(",");
193
- if (warnedDeprecatedUsersEmailAllowFrom.has(key)) return;
194
- warnedDeprecatedUsersEmailAllowFrom.add(key);
195
- logVerbose(`Deprecated allowFrom entry detected: "users/<email>" is no longer treated as an email allowlist. Use raw email (alice@example.com) or immutable user id (users/<id>). entries=${deprecated.join(", ")}`);
196
- }
197
- function warnMutableGroupKeysConfigured(logVerbose, groups) {
198
- const mutableKeys = Object.keys(groups ?? {}).map((key) => key.trim()).filter((key) => key && key !== "*" && !/^spaces\//i.test(key));
199
- if (mutableKeys.length === 0) return;
200
- const warningKey = mutableKeys.map((key) => normalizeLowercaseStringOrEmpty(key)).toSorted((a, b) => a.localeCompare(b)).join(",");
201
- if (warnedMutableGroupKeys.has(warningKey)) return;
202
- warnedMutableGroupKeys.add(warningKey);
203
- logVerbose(`Deprecated Google Chat group key detected: group routing now requires stable space ids (spaces/<spaceId>). Update channels.googlechat.groups keys: ${mutableKeys.join(", ")}`);
156
+ if (markDeprecatedEntriesWarning(deprecated, warnedDeprecatedUsersEmailAllowFrom)) logVerbose(`Deprecated allowFrom entry detected: "users/<email>" is no longer treated as an email allowlist. Use raw email (alice@example.com) or immutable user id (users/<id>). entries=${deprecated.join(", ")}`);
204
157
  }
205
158
  async function applyGoogleChatInboundAccessPolicy(params) {
206
159
  const { account, config, core, space, message, isGroup, senderId, senderName, senderEmail, rawBody, statusSink, logVerbose } = params;
@@ -224,12 +177,39 @@ async function applyGoogleChatInboundAccessPolicy(params) {
224
177
  blockedLabel: GROUP_POLICY_BLOCKED_LABEL.space,
225
178
  log: logVerbose
226
179
  });
227
- warnMutableGroupKeysConfigured(logVerbose, account.config.groups ?? void 0);
228
- const groupConfigResolved = resolveGoogleChatGroupConfig({
229
- groupId: spaceId,
230
- groupName: space.displayName ?? null,
231
- groups: account.config.groups ?? void 0
232
- });
180
+ const mutableKeys = Object.keys(account.config.groups ?? {}).map((key) => key.trim()).filter((key) => key && key !== "*" && !/^spaces\//i.test(key));
181
+ if (markDeprecatedEntriesWarning(mutableKeys, warnedMutableGroupKeys)) logVerbose(`Deprecated Google Chat group key detected: group routing now requires stable space ids (spaces/<spaceId>). Update channels.googlechat.groups keys: ${mutableKeys.join(", ")}`);
182
+ const groupName = space.displayName ?? null;
183
+ const groups = account.config.groups;
184
+ const groupConfigResolved = (() => {
185
+ const entries = groups ?? {};
186
+ const keys = Object.keys(entries);
187
+ if (keys.length === 0) return {
188
+ entry: void 0,
189
+ allowlistConfigured: false,
190
+ deprecatedNameMatch: false
191
+ };
192
+ const { "*": fallback, ...scopes } = entries;
193
+ const scope = buildGoogleChatGroupPolicyScope({
194
+ tree: {
195
+ defaults: fallback,
196
+ scopes
197
+ },
198
+ groupId: spaceId
199
+ });
200
+ const entry = scope.matchKey ? entries[scope.matchKey] : void 0;
201
+ const normalizedGroupName = normalizeLowercaseStringOrEmpty(groupName ?? "");
202
+ const deprecatedNameMatch = !entry && Boolean(groupName && keys.some((key) => {
203
+ const trimmed = key.trim();
204
+ if (!trimmed || trimmed === "*" || /^spaces\//i.test(trimmed)) return false;
205
+ return trimmed === groupName || normalizeLowercaseStringOrEmpty(trimmed) === normalizedGroupName;
206
+ }));
207
+ return {
208
+ entry: deprecatedNameMatch ? void 0 : entry ?? fallback,
209
+ allowlistConfigured: true,
210
+ deprecatedNameMatch
211
+ };
212
+ })();
233
213
  const groupEntry = groupConfigResolved.entry;
234
214
  const groupUsers = groupEntry?.users ?? account.config.groupAllowFrom ?? [];
235
215
  let effectiveWasMentioned;
@@ -390,40 +370,10 @@ async function applyGoogleChatInboundAccessPolicy(params) {
390
370
  groupSystemPrompt: normalizeOptionalString(groupEntry?.systemPrompt)
391
371
  };
392
372
  }
393
- //#endregion
394
- //#region extensions/googlechat/src/monitor-durable.ts
395
- function resolveGoogleChatDurableReplyOptions(params) {
396
- if (params.infoKind !== "final" || params.hasTypingMessage) return false;
397
- const threadId = params.payload.replyToId?.trim() || void 0;
398
- if (!threadId) return {
399
- to: params.spaceId,
400
- replyToId: null
401
- };
402
- return {
403
- to: params.spaceId,
404
- replyToId: threadId,
405
- threadId
406
- };
407
- }
408
- //#endregion
409
- //#region extensions/googlechat/src/monitor-event.ts
410
- var GoogleChatEventPayloadError = class extends Error {
411
- constructor() {
412
- super("invalid payload");
413
- this.name = "GoogleChatEventPayloadError";
414
- }
415
- };
416
- function recordParamsToActionParameters(params) {
417
- if (!params) return;
418
- const entries = Object.entries(params).filter((entry) => typeof entry[1] === "string").map(([key, value]) => ({
419
- key,
420
- value
421
- }));
422
- return entries.length > 0 ? entries : void 0;
423
- }
373
+ // extensions/googlechat/src/monitor-event.ts
424
374
  /** Normalize only at authenticated dispatch; durable admission stores the untouched envelope. */
425
375
  function parseGoogleChatInboundPayload(raw) {
426
- if (!isRecord$1(raw)) throw new GoogleChatEventPayloadError();
376
+ if (!isRecord$1(raw)) throw new Error("invalid payload");
427
377
  let eventPayload = raw;
428
378
  const rawObj = raw;
429
379
  const chat = rawObj.chat;
@@ -440,7 +390,12 @@ function parseGoogleChatInboundPayload(raw) {
440
390
  const buttonClickedPayload = chatPayload?.buttonClickedPayload;
441
391
  if (buttonClickedPayload) {
442
392
  const invokedFunction = rawObj.commonEventObject.invokedFunction;
443
- const actionParameters = recordParamsToActionParameters(rawObj.commonEventObject.parameters);
393
+ const parameters = rawObj.commonEventObject.parameters;
394
+ const entries = parameters ? Object.entries(parameters).filter((entry) => typeof entry[1] === "string").map(([key, value]) => ({
395
+ key,
396
+ value
397
+ })) : [];
398
+ const actionParameters = entries.length > 0 ? entries : void 0;
444
399
  eventPayload = {
445
400
  type: "CARD_CLICKED",
446
401
  space: buttonClickedPayload.space,
@@ -460,14 +415,13 @@ function parseGoogleChatInboundPayload(raw) {
460
415
  }
461
416
  const event = eventPayload;
462
417
  const eventType = event.type ?? event.eventType;
463
- if (typeof eventType !== "string" || !isRecord$1(event.space)) throw new GoogleChatEventPayloadError();
418
+ if (typeof eventType !== "string" || !isRecord$1(event.space)) throw new Error("invalid payload");
464
419
  if (eventType === "MESSAGE") {
465
- if (!isRecord$1(event.message) || !event.space?.name?.trim() || !event.message?.name?.trim()) throw new GoogleChatEventPayloadError();
466
- } else if (eventType === "CARD_CLICKED" && !isRecord$1(event.user)) throw new GoogleChatEventPayloadError();
420
+ if (!isRecord$1(event.message) || !event.space?.name?.trim() || !event.message?.name?.trim()) throw new Error("invalid payload");
421
+ } else if (eventType === "CARD_CLICKED" && !isRecord$1(event.user)) throw new Error("invalid payload");
467
422
  return event;
468
423
  }
469
- //#endregion
470
- //#region extensions/googlechat/src/monitor-ingress.ts
424
+ // extensions/googlechat/src/monitor-ingress.ts
471
425
  const GoogleChatIngressPermanentError = createChannelIngressError("GoogleChatIngressPermanentError", { withReason: true });
472
426
  function requiredString(value, field) {
473
427
  if (typeof value === "string" && value.trim()) return value.trim();
@@ -530,9 +484,7 @@ function createGoogleChatIngressMonitor(options) {
530
484
  if (!isRecord$1(rawEvent)) throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope must be an object.");
531
485
  const durableEvent = { ...rawEvent };
532
486
  delete durableEvent.authorizationEventObject;
533
- const serialized = JSON.stringify(durableEvent);
534
- if (typeof serialized !== "string") throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope cannot be serialized.");
535
- return serialized;
487
+ return JSON.stringify(durableEvent);
536
488
  };
537
489
  return createStandardRawEventIngressMonitor({
538
490
  queue: () => getGoogleChatRuntime().state.openChannelIngressQueue({ accountId: options.accountId }),
@@ -553,116 +505,7 @@ function createGoogleChatIngressMonitor(options) {
553
505
  classifyAdmissionError: (error) => error instanceof GoogleChatIngressPermanentError ? error.message : void 0
554
506
  });
555
507
  }
556
- //#endregion
557
- //#region extensions/googlechat/src/monitor-reply-delivery.ts
558
- function createGoogleChatTypingMessage(params) {
559
- const name = params.messageName.trim();
560
- const requestedThreadName = params.requestedThreadName?.trim();
561
- if (!requestedThreadName) return {
562
- placement: "top-level",
563
- name
564
- };
565
- return {
566
- placement: "thread",
567
- name,
568
- requestedThreadName,
569
- deliveredThreadName: params.deliveredThreadName?.trim() || requestedThreadName
570
- };
571
- }
572
- async function deliverGoogleChatReply(params) {
573
- const { payload, account, spaceId, runtime, core, config, statusSink } = params;
574
- let typingMessage = params.typingMessage;
575
- const replyThreadName = payload.replyToId?.trim() || void 0;
576
- const reply = resolveSendableOutboundReplyParts(payload);
577
- let deliveryThreadName = replyThreadName;
578
- const acceptedText = [];
579
- const runTextOperation = async (operation) => await operation.catch((error) => {
580
- if (acceptedText.length === 0) throw error;
581
- throw createChannelPartialDeliveryError(error, {
582
- messageIds: acceptedText.flatMap(({ id }) => id ? [id] : []),
583
- content: acceptedText.map(({ text }) => text).join("\n"),
584
- visibleReplySent: true
585
- });
586
- });
587
- const typingMatchesReply = typingMessage?.placement === "thread" ? typingMessage.requestedThreadName === replyThreadName : typingMessage?.placement === "top-level" ? replyThreadName === void 0 : false;
588
- if (typingMessage && !typingMatchesReply) {
589
- try {
590
- await deleteGoogleChatMessage({
591
- account,
592
- messageName: typingMessage.name
593
- });
594
- } catch (err) {
595
- runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
596
- }
597
- typingMessage = void 0;
598
- } else if (typingMessage?.placement === "thread") deliveryThreadName = typingMessage.deliveredThreadName;
599
- if (reply.hasMedia) runtime.error?.("Google Chat outbound attachments require user OAuth and are not supported by this service-account channel; sending text fallback only.");
600
- const chunkLimit = account.config.textChunkLimit ?? 4e3;
601
- const chunkMode = core.channel.text.resolveChunkMode(config, "googlechat", account.accountId);
602
- const chunks = formatGoogleChatTextChunks(reply.text, chunkLimit).flatMap((chunk) => core.channel.text.chunkMarkdownTextWithMode(chunk, chunkLimit, chunkMode));
603
- const rejection = reply.hasMedia && !reply.hasText ? "Google Chat outbound attachments require user OAuth and no text fallback is available." : reply.hasText && !chunks.some((chunk) => chunk) ? "Google Chat reply has no visible text after formatting." : void 0;
604
- if (rejection) {
605
- try {
606
- if (typingMessage) await deleteGoogleChatMessage({
607
- account,
608
- messageName: typingMessage.name
609
- });
610
- } catch (err) {
611
- runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
612
- }
613
- throw new PlatformMessageNotDispatchedError(rejection, {
614
- cause: void 0,
615
- retryable: false
616
- });
617
- }
618
- const recordOutboundStatus = () => {
619
- try {
620
- statusSink?.({ lastOutboundAt: Date.now() });
621
- } catch (err) {
622
- runtime.error?.(`Google Chat outbound status update failed: ${String(err)}`);
623
- }
624
- };
625
- const sendTextMessage = async (chunk) => {
626
- const sent = await runTextOperation(sendGoogleChatMessage({
627
- account,
628
- space: spaceId,
629
- text: chunk,
630
- thread: deliveryThreadName
631
- }));
632
- if (sent) acceptedText.push({
633
- id: sent.messageName?.trim() || void 0,
634
- text: chunk
635
- });
636
- if (replyThreadName) deliveryThreadName = sent?.threadName?.trim() || deliveryThreadName;
637
- };
638
- for (const chunk of chunks) {
639
- if (!chunk) continue;
640
- if (typingMessage) {
641
- try {
642
- const updated = await updateGoogleChatMessage({
643
- account,
644
- messageName: typingMessage.name,
645
- text: chunk
646
- });
647
- acceptedText.push({
648
- id: updated.messageName?.trim() || typingMessage.name,
649
- text: chunk
650
- });
651
- } catch (error) {
652
- if (!(error instanceof GoogleChatApiError) || error.status !== 404) throw error;
653
- runtime.error?.(`Google Chat typing update failed: ${String(error)}`);
654
- await sendTextMessage(chunk);
655
- }
656
- typingMessage = void 0;
657
- recordOutboundStatus();
658
- continue;
659
- }
660
- await sendTextMessage(chunk);
661
- recordOutboundStatus();
662
- }
663
- }
664
- //#endregion
665
- //#region extensions/googlechat/src/monitor-reply-target.ts
508
+ // extensions/googlechat/src/monitor-reply-target.ts
666
509
  /**
667
510
  * Google Chat only accepts a thread resource (`spaces/x/threads/y`) as a reply
668
511
  * target. The automatic reply pipeline supplies the inbound *message* resource
@@ -679,8 +522,7 @@ function normalizeGoogleChatReplyTarget(params) {
679
522
  replyToId: params.replyThreadName
680
523
  };
681
524
  }
682
- //#endregion
683
- //#region extensions/googlechat/src/monitor-webhook.ts
525
+ // extensions/googlechat/src/monitor-webhook.ts
684
526
  function extractBearerToken(header) {
685
527
  const authHeader = Array.isArray(header) ? typeof header[0] === "string" ? header[0] : "" : typeof header === "string" ? header : "";
686
528
  return normalizeLowercaseStringOrEmpty(authHeader).startsWith("bearer ") ? authHeader.slice(7).trim() : "";
@@ -823,8 +665,7 @@ function createGoogleChatWebhookRequestHandler(params) {
823
665
  });
824
666
  };
825
667
  }
826
- //#endregion
827
- //#region extensions/googlechat/src/monitor-routing.ts
668
+ // extensions/googlechat/src/monitor-routing.ts
828
669
  const webhookTargets = /* @__PURE__ */ new Map();
829
670
  const webhookRateLimiter = createFixedWindowRateLimiter(WEBHOOK_RATE_LIMIT_DEFAULTS);
830
671
  const webhookInFlightLimiter = createWebhookInFlightLimiter();
@@ -862,19 +703,25 @@ function registerGoogleChatWebhookTarget(target) {
862
703
  }
863
704
  }).unregister;
864
705
  }
865
- //#endregion
866
- //#region extensions/googlechat/src/monitor.ts
706
+ // extensions/googlechat/src/monitor.ts
867
707
  setGoogleChatWebhookEventProcessor(processGoogleChatEvent);
708
+ function createGoogleChatTypingMessage(params) {
709
+ const name = params.messageName.trim();
710
+ const requestedThreadName = params.requestedThreadName?.trim();
711
+ if (!requestedThreadName) return {
712
+ placement: "top-level",
713
+ name
714
+ };
715
+ return {
716
+ placement: "thread",
717
+ name,
718
+ requestedThreadName,
719
+ deliveredThreadName: params.deliveredThreadName?.trim() || requestedThreadName
720
+ };
721
+ }
868
722
  function logVerbose(core, runtime, message) {
869
723
  if (core.logging.shouldLogVerbose()) runtime.log?.(`[googlechat] ${message}`);
870
724
  }
871
- function resolveBotDisplayName(params) {
872
- const { accountName, agentId, config } = params;
873
- if (accountName?.trim()) return accountName.trim();
874
- const agent = resolveAgentConfig(config, agentId);
875
- if (agent?.name?.trim()) return agent.name.trim();
876
- return agent?.identity?.name?.trim() || "OpenClaw";
877
- }
878
725
  async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, config = target.config) {
879
726
  const eventType = event.type ?? event.eventType;
880
727
  if (eventType === "CARD_CLICKED") {
@@ -895,7 +742,7 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
895
742
  const sender = message.sender ?? event.user;
896
743
  const senderId = sender?.name ?? "";
897
744
  const senderName = sender?.displayName ?? "";
898
- const senderEmail = sender?.email ?? void 0;
745
+ const senderEmail = sender?.email;
899
746
  const isBotSender = sender?.type?.toUpperCase() === "BOT";
900
747
  const appUserId = account.config.botUser?.trim() || "users/app";
901
748
  const allowBots = account.config.allowBots === true;
@@ -960,38 +807,28 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
960
807
  }
961
808
  }
962
809
  const mediaInputs = attachments.map((attachment) => ({ contentType: attachment.contentType }));
963
- const first = attachments.at(0);
964
- if (first) try {
965
- const attachmentData = await downloadAttachment(first, account, mediaMaxMb, core);
966
- if (attachmentData) mediaInputs[0] = {
967
- path: attachmentData.path,
968
- url: attachmentData.path,
969
- contentType: attachmentData.contentType ?? first.contentType
970
- };
971
- else {
972
- const notice = `[Google Chat attachment unavailable: ${first.driveDataRef ? "Google Drive files are not downloadable" : "unsupported attachment source"}; upload the file directly]`;
973
- rawBody = formatInboundMediaUnavailableText({
974
- body: rawBody,
975
- notice
976
- });
977
- runtime.error?.(`[${account.accountId}] ${notice}`);
978
- }
979
- } catch (error) {
980
- if (!(error instanceof MediaFetchError) || error.code !== "max_bytes") throw error;
981
- const notice = `[Google Chat attachment too large; maximum ${mediaMaxMb} MB]`;
982
- rawBody = formatInboundMediaUnavailableText({
983
- body: rawBody,
984
- notice
985
- });
986
- runtime.error?.(`[${account.accountId}] ${notice} Increase channels.googlechat.mediaMaxMb to process larger attachments.`);
987
- }
988
- const additionalCount = attachments.length - 1;
989
- if (additionalCount > 0) {
990
- const notice = `[Google Chat: ${additionalCount} additional ${additionalCount === 1 ? "attachment was" : "attachments were"} not processed; only the first attachment is supported]`;
810
+ const attachmentNotices = /* @__PURE__ */ new Set();
811
+ const reportAttachmentUnavailable = (notice, hint = "") => {
812
+ if (attachmentNotices.has(notice)) return;
813
+ attachmentNotices.add(notice);
991
814
  rawBody = formatInboundMediaUnavailableText({
992
815
  body: rawBody,
993
816
  notice
994
817
  });
818
+ runtime.error?.(`[${account.accountId}] ${notice}${hint}`);
819
+ };
820
+ for (const [index, attachment] of attachments.entries()) try {
821
+ const attachmentData = await downloadAttachment(attachment, account, mediaMaxMb, core);
822
+ if (attachmentData) mediaInputs[index] = {
823
+ path: attachmentData.path,
824
+ url: attachmentData.path,
825
+ contentType: attachmentData.contentType ?? attachment.contentType
826
+ };
827
+ else reportAttachmentUnavailable(`[Google Chat attachment unavailable: ${attachment.driveDataRef ? "Google Drive files are not downloadable" : "unsupported attachment source"}; upload the file directly]`);
828
+ } catch (error) {
829
+ const missing = error instanceof GoogleChatApiError && error.status === 404;
830
+ if (!missing && (!(error instanceof MediaFetchError) || error.code !== "max_bytes")) throw error;
831
+ reportAttachmentUnavailable(missing ? "[Google Chat attachment unavailable: file not found; upload the file directly]" : `[Google Chat attachment too large; maximum ${mediaMaxMb} MB]`, missing ? "" : " Increase channels.googlechat.mediaMaxMb to process larger attachments.");
995
832
  }
996
833
  const media = mediaInputs.length === 0 ? [] : await toInboundMediaFactsWithMetadata(mediaInputs);
997
834
  const fromLabel = isGroup ? space.displayName || `space:${spaceId}` : senderName || `user:${senderId}`;
@@ -1050,7 +887,7 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
1050
887
  WasMentioned: isGroup ? effectiveWasMentioned : void 0,
1051
888
  CommandAuthorized: commandAuthorized,
1052
889
  GroupSubject: void 0,
1053
- GroupSpace: isGroup ? space.displayName ?? void 0 : void 0
890
+ GroupSpace: isGroup ? space.displayName : void 0
1054
891
  }
1055
892
  });
1056
893
  let typingIndicator = account.config.typingIndicator ?? "message";
@@ -1061,11 +898,14 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
1061
898
  let typingMessage;
1062
899
  const effectiveReplyThreadName = account.config.replyToMode && account.config.replyToMode !== "off" ? replyThreadName : void 0;
1063
900
  if (typingIndicator === "message") try {
1064
- const botName = resolveBotDisplayName({
1065
- accountName: account.config.name,
1066
- agentId: route.agentId,
1067
- config
1068
- });
901
+ const accountName = account.config.name;
902
+ const agentId = route.agentId;
903
+ let botName;
904
+ if (accountName?.trim()) botName = accountName.trim();
905
+ else {
906
+ const agent = resolveAgentConfig(config, agentId);
907
+ botName = agent?.name?.trim() ? agent.name.trim() : agent?.identity?.name?.trim() || "OpenClaw";
908
+ }
1069
909
  const result = await sendGoogleChatMessage({
1070
910
  account,
1071
911
  space: spaceId,
@@ -1080,76 +920,186 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
1080
920
  } catch (err) {
1081
921
  runtime.error?.(`Failed sending typing message: ${String(err)}`);
1082
922
  }
1083
- await core.channel.inbound.run({
1084
- channel: "googlechat",
1085
- accountId: route.accountId,
1086
- raw: message,
1087
- ...turnAdoptionLifecycle ? { turnAdoptionLifecycle } : {},
1088
- adapter: {
1089
- ingest: () => ({
1090
- id: message.name ?? spaceId,
1091
- timestamp: timestampMs,
1092
- rawText: rawBody,
1093
- textForAgent: rawBody,
1094
- textForCommands: rawBody,
1095
- raw: message
1096
- }),
1097
- resolveTurn: () => ({
1098
- cfg: config,
1099
- channel: "googlechat",
1100
- accountId: route.accountId,
1101
- route: {
1102
- agentId: route.agentId,
1103
- sessionKey: route.sessionKey
1104
- },
1105
- ctxPayload,
1106
- delivery: {
1107
- durable: (payload, info) => resolveGoogleChatDurableReplyOptions({
1108
- payload: normalizeGoogleChatReplyTarget({
1109
- payload,
1110
- sourceMessageName: message.name,
1111
- replyThreadName: effectiveReplyThreadName
1112
- }),
1113
- infoKind: info.kind,
1114
- spaceId,
1115
- hasTypingMessage: Boolean(typingMessage)
1116
- }),
1117
- deliver: async (payload) => {
1118
- await deliverGoogleChatReply({
1119
- payload: normalizeGoogleChatReplyTarget({
923
+ const cleanupTypingMessage = async () => {
924
+ const placeholder = typingMessage;
925
+ typingMessage = void 0;
926
+ if (!placeholder) return;
927
+ try {
928
+ await deleteGoogleChatMessage({
929
+ account,
930
+ messageName: placeholder.name
931
+ });
932
+ } catch (error) {
933
+ runtime.error?.(`Google Chat typing cleanup failed: ${String(error)}`);
934
+ }
935
+ };
936
+ let deferred = false;
937
+ const typingTurnLifecycle = typingMessage ? {
938
+ ...turnAdoptionLifecycle,
939
+ onAdopted: () => turnAdoptionLifecycle?.onAdopted(),
940
+ onDeferred: () => {
941
+ turnAdoptionLifecycle?.onDeferred();
942
+ deferred = true;
943
+ },
944
+ onSettled: () => deferred ? cleanupTypingMessage() : void 0
945
+ } : turnAdoptionLifecycle;
946
+ try {
947
+ await core.channel.inbound.run({
948
+ channel: "googlechat",
949
+ accountId: route.accountId,
950
+ raw: message,
951
+ ...typingTurnLifecycle ? { turnAdoptionLifecycle: typingTurnLifecycle } : {},
952
+ adapter: {
953
+ ingest: () => ({
954
+ id: message.name ?? spaceId,
955
+ timestamp: timestampMs,
956
+ rawText: rawBody,
957
+ textForAgent: rawBody,
958
+ textForCommands: rawBody,
959
+ raw: message
960
+ }),
961
+ resolveTurn: () => ({
962
+ cfg: config,
963
+ channel: "googlechat",
964
+ accountId: route.accountId,
965
+ route: {
966
+ agentId: route.agentId,
967
+ sessionKey: route.sessionKey
968
+ },
969
+ ctxPayload,
970
+ delivery: {
971
+ durable: (payload, info) => {
972
+ const normalizedPayload = normalizeGoogleChatReplyTarget({
1120
973
  payload,
1121
974
  sourceMessageName: message.name,
1122
975
  replyThreadName: effectiveReplyThreadName
1123
- }),
1124
- account,
1125
- spaceId,
1126
- runtime,
1127
- core,
1128
- config,
1129
- statusSink,
1130
- typingMessage
1131
- });
1132
- typingMessage = void 0;
1133
- },
1134
- onDelivered: () => {
1135
- statusSink?.({ lastOutboundAt: Date.now() });
976
+ });
977
+ if (info.kind !== "final" || Boolean(typingMessage)) return false;
978
+ const threadId = normalizedPayload.replyToId?.trim() || void 0;
979
+ if (!threadId) return {
980
+ to: spaceId,
981
+ replyToId: null
982
+ };
983
+ return {
984
+ to: spaceId,
985
+ replyToId: threadId,
986
+ threadId
987
+ };
988
+ },
989
+ deliver: async (payload) => {
990
+ const normalizedPayload = normalizeGoogleChatReplyTarget({
991
+ payload,
992
+ sourceMessageName: message.name,
993
+ replyThreadName: effectiveReplyThreadName
994
+ });
995
+ let deliveryTypingMessage = typingMessage;
996
+ const targetThreadName = normalizedPayload.replyToId?.trim() || void 0;
997
+ const reply = resolveSendableOutboundReplyParts(normalizedPayload);
998
+ let deliveryThreadName = targetThreadName;
999
+ const acceptedText = [];
1000
+ const runTextOperation = async (operation) => await operation.catch((error) => {
1001
+ if (acceptedText.length === 0) throw error;
1002
+ throw createChannelPartialDeliveryError(error, {
1003
+ messageIds: acceptedText.flatMap(({ id }) => id ? [id] : []),
1004
+ content: acceptedText.map(({ text }) => text).join("\n"),
1005
+ visibleReplySent: true
1006
+ });
1007
+ });
1008
+ const typingMatchesReply = deliveryTypingMessage?.placement === "thread" ? deliveryTypingMessage.requestedThreadName === targetThreadName : deliveryTypingMessage?.placement === "top-level" ? targetThreadName === void 0 : false;
1009
+ if (deliveryTypingMessage && !typingMatchesReply) {
1010
+ await cleanupTypingMessage();
1011
+ deliveryTypingMessage = void 0;
1012
+ } else if (deliveryTypingMessage?.placement === "thread") deliveryThreadName = deliveryTypingMessage.deliveredThreadName;
1013
+ let text;
1014
+ try {
1015
+ text = formatGoogleChatMediaText(reply.text, reply.mediaUrls);
1016
+ } catch (cause) {
1017
+ await cleanupTypingMessage();
1018
+ throw new PlatformMessageNotDispatchedError(cause instanceof Error ? cause.message : String(cause), {
1019
+ cause,
1020
+ retryable: false
1021
+ });
1022
+ }
1023
+ const chunkLimit = account.config.textChunkLimit ?? 4e3;
1024
+ const chunkMode = core.channel.text.resolveChunkMode(config, "googlechat", account.accountId);
1025
+ const chunks = formatGoogleChatTextChunks(text, chunkLimit).flatMap((chunk) => core.channel.text.chunkMarkdownTextWithMode(chunk, chunkLimit, chunkMode));
1026
+ const rejection = text && !chunks.some((chunk) => chunk) ? "Google Chat reply has no visible text after formatting." : void 0;
1027
+ if (rejection) {
1028
+ await cleanupTypingMessage();
1029
+ throw new PlatformMessageNotDispatchedError(rejection, {
1030
+ cause: void 0,
1031
+ retryable: false
1032
+ });
1033
+ }
1034
+ const recordOutboundStatus = () => {
1035
+ try {
1036
+ statusSink?.({ lastOutboundAt: Date.now() });
1037
+ } catch (err) {
1038
+ runtime.error?.(`Google Chat outbound status update failed: ${String(err)}`);
1039
+ }
1040
+ };
1041
+ const sendTextMessage = async (chunk) => {
1042
+ const sent = await runTextOperation(sendGoogleChatMessage({
1043
+ account,
1044
+ space: spaceId,
1045
+ text: chunk,
1046
+ thread: deliveryThreadName
1047
+ }));
1048
+ if (sent) acceptedText.push({
1049
+ id: sent.messageName?.trim() || void 0,
1050
+ text: chunk
1051
+ });
1052
+ if (targetThreadName) deliveryThreadName = sent?.threadName?.trim() || deliveryThreadName;
1053
+ };
1054
+ for (const chunk of chunks) {
1055
+ if (!chunk) continue;
1056
+ if (deliveryTypingMessage) {
1057
+ typingMessage = void 0;
1058
+ try {
1059
+ const updated = await updateGoogleChatMessage({
1060
+ account,
1061
+ messageName: deliveryTypingMessage.name,
1062
+ text: chunk
1063
+ });
1064
+ acceptedText.push({
1065
+ id: updated.messageName?.trim() || deliveryTypingMessage.name,
1066
+ text: chunk
1067
+ });
1068
+ } catch (error) {
1069
+ if (!(error instanceof GoogleChatApiError) || error.status !== 404) throw error;
1070
+ runtime.error?.(`Google Chat typing update failed: ${String(error)}`);
1071
+ await sendTextMessage(chunk);
1072
+ }
1073
+ deliveryTypingMessage = void 0;
1074
+ recordOutboundStatus();
1075
+ continue;
1076
+ }
1077
+ await sendTextMessage(chunk);
1078
+ recordOutboundStatus();
1079
+ }
1080
+ },
1081
+ onDelivered: () => {
1082
+ statusSink?.({ lastOutboundAt: Date.now() });
1083
+ },
1084
+ onError: (err, info) => {
1085
+ runtime.error?.(`[${account.accountId}] Google Chat ${info.kind} reply failed: ${String(err)}`);
1086
+ }
1136
1087
  },
1137
- onError: (err, info) => {
1138
- runtime.error?.(`[${account.accountId}] Google Chat ${info.kind} reply failed: ${String(err)}`);
1139
- }
1140
- },
1141
- replyPipeline: {},
1142
- record: { onRecordError: (err) => {
1143
- runtime.error?.(`googlechat: failed updating session meta: ${String(err)}`);
1144
- } }
1145
- })
1146
- }
1147
- });
1088
+ replyPipeline: {},
1089
+ record: { onRecordError: (err) => {
1090
+ runtime.error?.(`googlechat: failed updating session meta: ${String(err)}`);
1091
+ } }
1092
+ })
1093
+ }
1094
+ });
1095
+ } finally {
1096
+ if (!deferred) await cleanupTypingMessage();
1097
+ }
1148
1098
  }
1149
1099
  async function downloadAttachment(attachment, account, mediaMaxMb, core) {
1150
1100
  const resourceName = attachment.attachmentDataRef?.resourceName;
1151
1101
  if (!resourceName) return null;
1152
- const maxBytes = Math.max(1, mediaMaxMb) * 1024 * 1024;
1102
+ const maxBytes = mediaMaxMb * 1024 * 1024;
1153
1103
  const downloaded = await downloadGoogleChatMedia({
1154
1104
  account,
1155
1105
  resourceName,
@@ -1229,13 +1179,11 @@ function resolveGoogleChatWebhookPath({ webhookPath, webhookUrl }) {
1229
1179
  defaultPath: "/googlechat"
1230
1180
  });
1231
1181
  }
1232
- //#endregion
1233
- //#region extensions/googlechat/src/channel.runtime.ts
1182
+ // extensions/googlechat/src/channel.runtime.ts
1234
1183
  const googleChatChannelRuntime = {
1235
1184
  probeGoogleChat,
1236
1185
  sendGoogleChatMessage,
1237
1186
  resolveGoogleChatWebhookPath,
1238
1187
  startGoogleChatMonitor
1239
1188
  };
1240
- //#endregion
1241
1189
  export { googleChatChannelRuntime };