@openclaw/googlechat 2026.7.2-beta.7 → 2026.8.1-beta.2

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.
@@ -1,6 +1,6 @@
1
- import { l as resolveGoogleChatAccount } from "./channel-base-hw9ErEr5.js";
2
- import { m as resolveGoogleChatOutboundSpace, v as sendGoogleChatMessage } from "./channel.adapters-DaipaeYt.js";
3
- import { n as describeGoogleChatMessageTool } from "./channel-kouqKs2x.js";
1
+ import { l as resolveGoogleChatAccount } from "./channel-base-BpHXDsur.js";
2
+ import { m as resolveGoogleChatOutboundSpace, y as sendGoogleChatMessage } from "./channel.adapters-DiI1p1ml.js";
3
+ import { n as describeGoogleChatMessageTool } from "./channel-DkSxE2Ch.js";
4
4
  import { extractToolSend } from "openclaw/plugin-sdk/tool-send";
5
5
  import { jsonResult, readStringArrayParam, readStringParam } from "openclaw/plugin-sdk/channel-actions";
6
6
  //#region extensions/googlechat/src/actions.ts
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as googlechatSetupAdapter, i as googlechatSetupWizard } from "./channel-base-hw9ErEr5.js";
2
- import { t as googlechatPlugin } from "./channel-kouqKs2x.js";
1
+ import { a as googlechatSetupAdapter, i as googlechatSetupWizard } from "./channel-base-BpHXDsur.js";
2
+ import { t as googlechatPlugin } from "./channel-DkSxE2Ch.js";
3
3
  export { googlechatPlugin, googlechatSetupAdapter, googlechatSetupWizard };
@@ -1,5 +1,5 @@
1
- import { l as resolveGoogleChatAccount } from "./channel-base-hw9ErEr5.js";
2
- import { d as isGoogleChatUserTarget, f as normalizeGoogleChatTarget } from "./channel.adapters-DaipaeYt.js";
1
+ import { l as resolveGoogleChatAccount } from "./channel-base-BpHXDsur.js";
2
+ import { d as isGoogleChatUserTarget, f as normalizeGoogleChatTarget } from "./channel.adapters-DiI1p1ml.js";
3
3
  import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
5
5
  //#region extensions/googlechat/src/approval-auth.ts
@@ -1,6 +1,6 @@
1
- import { l as resolveGoogleChatAccount } from "./channel-base-hw9ErEr5.js";
2
- import { M as unregisterGoogleChatManualApprovalFollowupSuppression, O as registerGoogleChatApprovalCardBinding, S as buildGoogleChatApprovalActionParameters, T as createGoogleChatApprovalToken, j as unregisterGoogleChatApprovalCardBindings, k as registerGoogleChatManualApprovalFollowupSuppression, m as resolveGoogleChatOutboundSpace, v as sendGoogleChatMessage, x as GOOGLECHAT_APPROVAL_ACTION, y as updateGoogleChatMessage } from "./channel.adapters-DaipaeYt.js";
3
- import { i as shouldHandleGoogleChatNativeApprovalRequest, r as isGoogleChatNativeApprovalClientEnabled } from "./channel-kouqKs2x.js";
1
+ import { l as resolveGoogleChatAccount } from "./channel-base-BpHXDsur.js";
2
+ import { A as registerGoogleChatManualApprovalFollowupSuppression, C as buildGoogleChatApprovalActionParameters, E as createGoogleChatApprovalToken, M as unregisterGoogleChatApprovalCardBindings, N as unregisterGoogleChatManualApprovalFollowupSuppression, S as GOOGLECHAT_APPROVAL_ACTION, b as updateGoogleChatMessage, k as registerGoogleChatApprovalCardBinding, m as resolveGoogleChatOutboundSpace, y as sendGoogleChatMessage } from "./channel.adapters-DiI1p1ml.js";
3
+ import { i as shouldHandleGoogleChatNativeApprovalRequest, r as isGoogleChatNativeApprovalClientEnabled } from "./channel-DkSxE2Ch.js";
4
4
  import { buildChannelApprovalNativeTargetKey } from "openclaw/plugin-sdk/approval-native-runtime";
5
5
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
@@ -1,9 +1,9 @@
1
- import { c as resolveDefaultGoogleChatAccountId, l as resolveGoogleChatAccount, n as createGoogleChatPluginBase, o as inspectGoogleChatAccount, s as listGoogleChatAccountIds, t as GOOGLECHAT_CHANNEL_ID } from "./channel-base-hw9ErEr5.js";
2
- import { a as googlechatPairingTextAdapter, d as isGoogleChatUserTarget, f as normalizeGoogleChatTarget, i as googlechatOutboundAdapter, n as googlechatGroupsAdapter, o as googlechatSecurityAdapter, p as resolveGoogleChatOutboundSessionRoute, r as googlechatMessageAdapter, s as googlechatThreadingAdapter, t as googlechatDirectoryAdapter, u as isGoogleChatSpaceTarget } from "./channel.adapters-DaipaeYt.js";
1
+ import { c as resolveDefaultGoogleChatAccountId, l as resolveGoogleChatAccount, n as createGoogleChatPluginBase, o as inspectGoogleChatAccount, s as listGoogleChatAccountIds, t as GOOGLECHAT_CHANNEL_ID } from "./channel-base-BpHXDsur.js";
2
+ import { a as googlechatPairingTextAdapter, d as isGoogleChatUserTarget, f as normalizeGoogleChatTarget, i as googlechatOutboundAdapter, n as googlechatGroupsAdapter, o as googlechatSecurityAdapter, p as resolveGoogleChatOutboundSessionRoute, r as googlechatMessageAdapter, s as googlechatThreadingAdapter, t as googlechatDirectoryAdapter, u as isGoogleChatSpaceTarget } from "./channel.adapters-DiI1p1ml.js";
3
3
  import { n as buildChannelConfigSchema, t as GoogleChatConfigSchema } from "./config-api-CsD0IFxF.js";
4
4
  import { t as DEFAULT_ACCOUNT_ID } from "./runtime-api-Dh0CNVS4.js";
5
- import { n as googleChatApprovalAuth, r as normalizeGoogleChatApproverId, t as getGoogleChatApprovalApprovers } from "./approval-auth-ykO6i_ub.js";
6
- import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BpuSvJro.js";
5
+ import { n as googleChatApprovalAuth, r as normalizeGoogleChatApproverId, t as getGoogleChatApprovalApprovers } from "./approval-auth-Bm8YFEkI.js";
6
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BLvSmTXT.js";
7
7
  import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-BFYyuE0F.js";
8
8
  import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
9
9
  import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
@@ -17,6 +17,7 @@ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "opencl
17
17
  import { createAccountStatusSink, runPassiveAccountLifecycle } from "openclaw/plugin-sdk/channel-outbound";
18
18
  import { buildMutableAllowEntryDetector, collectStandardAllowlistLists, createDangerousNameMatchingMutableAllowlistWarningCollector } from "openclaw/plugin-sdk/channel-policy";
19
19
  import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
20
+ import { channelBlockedPatch } from "openclaw/plugin-sdk/gateway-runtime";
20
21
  //#region extensions/googlechat/src/approval-native.ts
21
22
  const DEFAULT_APPROVAL_FORWARDING_MODE = "session";
22
23
  function isGoogleChatAccountConfigured(params) {
@@ -141,7 +142,7 @@ const googleChatApprovalCapability = createApproverRestrictedNativeApprovalCapab
141
142
  approvalKind,
142
143
  request
143
144
  }),
144
- load: async () => (await import("./approval-handler.runtime-CBeHrXtL.js")).googleChatApprovalNativeRuntime
145
+ load: async () => (await import("./approval-handler.runtime-B-p-W-_V.js")).googleChatApprovalNativeRuntime
145
146
  })
146
147
  });
147
148
  const collectGoogleChatMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
@@ -156,15 +157,14 @@ const collectGoogleChatMutableAllowlistWarnings = createDangerousNameMatchingMut
156
157
  stableIdPattern: /^[^@]+$/
157
158
  }),
158
159
  collectLists: (scope) => collectStandardAllowlistLists(scope, {
159
- includeAllowFrom: false,
160
- includeDm: true,
161
160
  includeGroups: true,
162
161
  groupField: "users"
163
162
  })
164
163
  });
165
164
  //#endregion
166
165
  //#region extensions/googlechat/src/gateway.ts
167
- const loadGoogleChatChannelRuntime$1 = createLazyRuntimeNamedExport(() => import("./channel.runtime-BbwE9vOC.js"), "googleChatChannelRuntime");
166
+ const loadGoogleChatChannelRuntime$1 = createLazyRuntimeNamedExport(() => import("./channel.runtime-CqOzrZWb.js"), "googleChatChannelRuntime");
167
+ const UNRESOLVED_WEBHOOK_URL_ERROR = "Invalid webhookUrl: expected an absolute URL such as https://chat.example.com/googlechat. No inbound webhook route was registered.";
168
168
  async function startGoogleChatGatewayAccount(ctx) {
169
169
  const account = ctx.account;
170
170
  const statusSink = createAccountStatusSink({
@@ -173,10 +173,14 @@ async function startGoogleChatGatewayAccount(ctx) {
173
173
  });
174
174
  ctx.log?.info?.(`[${account.accountId}] starting Google Chat webhook`);
175
175
  const { resolveGoogleChatWebhookPath, startGoogleChatMonitor } = await loadGoogleChatChannelRuntime$1();
176
+ const webhookPath = resolveGoogleChatWebhookPath({ account });
176
177
  statusSink({
177
178
  running: true,
178
179
  lastStartAt: Date.now(),
179
- webhookPath: resolveGoogleChatWebhookPath({ account }),
180
+ ...webhookPath ? {
181
+ webhookPath,
182
+ lifecycle: "starting"
183
+ } : channelBlockedPatch(UNRESOLVED_WEBHOOK_URL_ERROR, { webhookPath: void 0 }),
180
184
  audienceType: account.config.audienceType,
181
185
  audience: account.config.audience
182
186
  });
@@ -237,13 +241,13 @@ function describeGoogleChatMessageTool({ cfg, accountId }) {
237
241
  }
238
242
  //#endregion
239
243
  //#region extensions/googlechat/src/channel.ts
240
- const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-BbwE9vOC.js"), "googleChatChannelRuntime");
244
+ const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-CqOzrZWb.js"), "googleChatChannelRuntime");
241
245
  const googlechatActions = {
242
246
  describeMessageTool: describeGoogleChatMessageTool,
243
247
  supportsAction: ({ action }) => action === "send",
244
248
  extractToolSend: ({ args }) => extractToolSend(args, "sendMessage"),
245
249
  handleAction: async (ctx) => {
246
- const { googlechatMessageActions } = await import("./actions-D81dCtkC.js");
250
+ const { googlechatMessageActions } = await import("./actions-BIY4DNRJ.js");
247
251
  if (!googlechatMessageActions.handleAction) throw new Error("Google Chat actions are not available.");
248
252
  return await googlechatMessageActions.handleAction(ctx);
249
253
  }
@@ -265,6 +269,12 @@ const googlechatPlugin = createChatChannelPlugin({
265
269
  ],
266
270
  targetIdComparison: "case-sensitive",
267
271
  normalizeTarget: normalizeGoogleChatTarget,
272
+ inferTargetChatType: ({ to }) => {
273
+ const target = normalizeGoogleChatTarget(to);
274
+ if (!target) return;
275
+ if (isGoogleChatUserTarget(target)) return "direct";
276
+ return isGoogleChatSpaceTarget(target) ? "group" : void 0;
277
+ },
268
278
  resolveOutboundSessionRoute: (params) => resolveGoogleChatOutboundSessionRoute(params),
269
279
  targetResolver: {
270
280
  looksLikeId: (raw, normalized) => {
@@ -237,7 +237,9 @@ const googlechatSetupContract = defineChannelSetupContract({
237
237
  cli: {
238
238
  flags: "--use-env",
239
239
  description: "Use Google Chat environment credentials"
240
- }
240
+ },
241
+ envVars: ["GOOGLE_CHAT_SERVICE_ACCOUNT", "GOOGLE_CHAT_SERVICE_ACCOUNT_FILE"],
242
+ envVarMode: "any"
241
243
  }
242
244
  },
243
245
  legacyAdapter: googlechatSetupAdapter
@@ -452,7 +454,6 @@ function createGoogleChatPluginBase(params = {}) {
452
454
  return {
453
455
  id: GOOGLECHAT_CHANNEL_ID,
454
456
  meta: { ...googlechatMeta },
455
- setup: googlechatSetupAdapter,
456
457
  setupContract: googlechatSetupContract,
457
458
  setupWizard: googlechatSetupWizard,
458
459
  capabilities: {
@@ -1,2 +1,2 @@
1
- import { t as googlechatPlugin } from "./channel-kouqKs2x.js";
1
+ import { t as googlechatPlugin } from "./channel-DkSxE2Ch.js";
2
2
  export { googlechatPlugin };
@@ -1,16 +1,17 @@
1
- import { l as resolveGoogleChatAccount, r as formatGoogleChatAllowFromEntry, u as MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES } from "./channel-base-hw9ErEr5.js";
1
+ import { l as resolveGoogleChatAccount, r as formatGoogleChatAllowFromEntry, u as MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES } from "./channel-base-BpHXDsur.js";
2
2
  import { d as fetchWithSsrFGuard$1, m as missingTargetError, r as PAIRING_APPROVED_MESSAGE } from "./runtime-api-Dh0CNVS4.js";
3
3
  import { buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/channel-core";
4
4
  import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
5
- import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ import { asNullableObjectRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { resolveUserPath } from "openclaw/plugin-sdk/text-utility-runtime";
7
7
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
8
- import { parseMediaContentLength, readResponseTextSnippet } from "openclaw/plugin-sdk/media-runtime";
8
+ import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
9
+ import { MediaFetchError, parseMediaContentLength, readResponseTextSnippet } from "openclaw/plugin-sdk/media-runtime";
10
+ import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
9
11
  import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
10
12
  import { buildHostnameAllowlistPolicyFromSuffixAllowlist, fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
11
13
  import crypto from "node:crypto";
12
14
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
13
- import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
14
15
  import { createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
15
16
  import { FormatCapabilityProfile, markdownToIR, renderMarkdownIRChunksWithinLimit, renderMarkdownWithMarkers, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
16
17
  import fs from "node:fs/promises";
@@ -189,9 +190,6 @@ function installGoogleAuthHeaderCompatibilityInterceptor(transport) {
189
190
  transport.interceptors.response.add({ resolved: async (response) => normalizeGoogleAuthResponseHeaders(response) });
190
191
  return transport;
191
192
  }
192
- function asNullableObjectRecord(value) {
193
- return value !== null && typeof value === "object" ? value : null;
194
- }
195
193
  function hasProxyAgentShape(value) {
196
194
  const record = asNullableObjectRecord(value);
197
195
  return record !== null && record.proxy instanceof URL;
@@ -404,6 +402,7 @@ function createGoogleAuthFetch() {
404
402
  statusText: response.statusText
405
403
  });
406
404
  } finally {
405
+ if (!response.bodyUsed) response.body?.cancel().catch(() => void 0);
407
406
  await release();
408
407
  }
409
408
  };
@@ -617,30 +616,32 @@ const GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS = 3e4;
617
616
  const GOOGLECHAT_JSON_RESPONSE_MAX_BYTES = 16 * 1024 * 1024;
618
617
  const GOOGLECHAT_ERROR_BODY_MAX_BYTES = 16 * 1024;
619
618
  const GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES = 20 * 1024 * 1024;
619
+ var GoogleChatApiError = class extends Error {
620
+ constructor(status, message) {
621
+ super(message);
622
+ this.status = status;
623
+ this.name = "GoogleChatApiError";
624
+ }
625
+ };
620
626
  function resolveGoogleChatMediaTimeoutMs(maxBytes) {
621
627
  if (!maxBytes) return GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS;
622
628
  const transferMs = Math.ceil(maxBytes / GOOGLECHAT_MEDIA_MIN_BYTES_PER_SECOND * 1e3);
623
629
  return Math.min(GOOGLECHAT_MEDIA_TIMEOUT_GRACE_MS + transferMs, GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS);
624
630
  }
625
631
  async function readGoogleChatJsonResponse(response, label) {
626
- const bytes = await readResponseWithLimit(response, GOOGLECHAT_JSON_RESPONSE_MAX_BYTES, {
632
+ return readProviderJsonResponse(response, label, {
633
+ maxBytes: GOOGLECHAT_JSON_RESPONSE_MAX_BYTES,
627
634
  chunkTimeoutMs: GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS,
628
- onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`${label}: response body stalled after ${chunkTimeoutMs}ms`),
629
- onOverflow: ({ maxBytes }) => /* @__PURE__ */ new Error(`${label}: JSON response exceeds ${maxBytes} bytes`)
635
+ onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`${label}: response body stalled after ${chunkTimeoutMs}ms`)
630
636
  });
631
- try {
632
- return JSON.parse(new TextDecoder().decode(bytes));
633
- } catch (cause) {
634
- throw new Error(`${label}: malformed JSON response`, { cause });
635
- }
636
637
  }
637
638
  async function readGoogleChatErrorResponse(response, label) {
638
- return await readResponseTextSnippet(response, {
639
+ return redactToolPayloadText(await readResponseTextSnippet(response, {
639
640
  maxBytes: GOOGLECHAT_ERROR_BODY_MAX_BYTES,
640
641
  maxChars: GOOGLECHAT_ERROR_BODY_MAX_BYTES,
641
642
  chunkTimeoutMs: GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS,
642
643
  onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`${label} error response stalled after ${chunkTimeoutMs}ms`)
643
- }) ?? "";
644
+ }) ?? "");
644
645
  }
645
646
  const headersToObject = (headers) => headers instanceof Headers ? Object.fromEntries(headers.entries()) : Array.isArray(headers) ? Object.fromEntries(headers) : headers || {};
646
647
  async function withGoogleChatResponse(params) {
@@ -661,7 +662,7 @@ async function withGoogleChatResponse(params) {
661
662
  try {
662
663
  if (!response.ok) {
663
664
  const text = await readGoogleChatErrorResponse(response, errorPrefix);
664
- throw new Error(`${errorPrefix} ${response.status}: ${text || response.statusText}`);
665
+ throw new GoogleChatApiError(response.status, `${errorPrefix} ${response.status}: ${text || response.statusText}`);
665
666
  }
666
667
  return await handleResponse(response);
667
668
  } finally {
@@ -705,27 +706,40 @@ async function fetchBuffer(account, url, init, options) {
705
706
  const lengthHeader = res.headers.get("content-length");
706
707
  if (lengthHeader) {
707
708
  const length = parseMediaContentLength(lengthHeader);
708
- if (length !== null && length > maxBytes) throw new Error(`Google Chat media exceeds max bytes (${maxBytes})`);
709
+ if (length !== null && length > maxBytes) throw new MediaFetchError("max_bytes", `Google Chat media exceeds max bytes (${maxBytes})`);
709
710
  }
710
711
  return {
711
712
  buffer: await readResponseWithLimit(res, maxBytes, {
712
713
  chunkTimeoutMs: GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS,
713
- onOverflow: () => /* @__PURE__ */ new Error(`Google Chat media exceeds max bytes (${maxBytes})`)
714
+ onOverflow: () => new MediaFetchError("max_bytes", `Google Chat media exceeds max bytes (${maxBytes})`)
714
715
  }),
715
716
  contentType: res.headers.get("content-type") ?? void 0
716
717
  };
717
718
  }
718
719
  });
719
720
  }
721
+ /**
722
+ * A Google Chat `thread` must be a `spaces/{space}/threads/{thread}` resource
723
+ * name that belongs to the target space. Reply routing sometimes yields other
724
+ * shapes — a bare id, a `spaces/{space}/messages/{message}` name, or a thread
725
+ * from a different (or wrongly-cased) space — and passing any of those makes the
726
+ * Chat API reject the whole send with `400 INVALID_ARGUMENT`. Accept only a
727
+ * well-formed, same-space thread name; callers drop the rest so the message
728
+ * still delivers to the space (as a new thread) instead of failing outright.
729
+ */
730
+ function isUsableGoogleChatThreadName(thread, space) {
731
+ return /^spaces\/[^/]+\/threads\/[^/]+$/.test(thread) && thread.startsWith(`${space}/threads/`);
732
+ }
720
733
  async function sendGoogleChatMessage(params) {
721
734
  const { account, space, text, thread, cardsV2 } = params;
735
+ const usableThread = thread && isUsableGoogleChatThreadName(thread, space) ? thread : void 0;
722
736
  if (text && (!cardsV2 || cardsV2.length === 0) && shouldSuppressGoogleChatManualExecApprovalFollowupText(text)) return null;
723
737
  const body = {};
724
738
  if (text) body.text = text;
725
739
  if (cardsV2 && cardsV2.length > 0) body.cardsV2 = cardsV2;
726
- if (thread) body.thread = { name: thread };
740
+ if (usableThread) body.thread = { name: usableThread };
727
741
  const urlObj = new URL(`${CHAT_API_BASE}/${space}/messages`);
728
- if (thread) urlObj.searchParams.set("messageReplyOption", "REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD");
742
+ if (usableThread) urlObj.searchParams.set("messageReplyOption", "REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD");
729
743
  const result = await fetchJson(account, urlObj.toString(), {
730
744
  method: "POST",
731
745
  body: JSON.stringify(body)
@@ -1159,7 +1173,7 @@ function resolveGoogleChatGroupRequireMention(params) {
1159
1173
  }
1160
1174
  //#endregion
1161
1175
  //#region extensions/googlechat/src/channel.adapters.ts
1162
- const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-BbwE9vOC.js"), "googleChatChannelRuntime");
1176
+ const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-CqOzrZWb.js"), "googleChatChannelRuntime");
1163
1177
  function createGoogleChatSendReceipt(params) {
1164
1178
  const messageId = params.messageId?.trim();
1165
1179
  return createMessageReceiptFromOutboundResults({
@@ -1169,7 +1183,7 @@ function createGoogleChatSendReceipt(params) {
1169
1183
  chatId: params.chatId,
1170
1184
  conversationId: params.chatId
1171
1185
  }] : [],
1172
- threadId: params.chatId,
1186
+ threadId: params.threadId,
1173
1187
  kind: params.kind
1174
1188
  });
1175
1189
  }
@@ -1293,18 +1307,20 @@ const googlechatOutboundAdapter = {
1293
1307
  });
1294
1308
  const thread = typeof threadId === "number" ? String(threadId) : threadId ?? replyToId ?? void 0;
1295
1309
  const { sendGoogleChatMessage } = await loadGoogleChatChannelRuntime();
1296
- const messageId = (await sendGoogleChatMessage({
1310
+ const result = await sendGoogleChatMessage({
1297
1311
  account,
1298
1312
  space,
1299
1313
  text,
1300
1314
  thread
1301
- }))?.messageName ?? "";
1315
+ });
1316
+ const messageId = result?.messageName ?? "";
1302
1317
  return {
1303
1318
  messageId,
1304
1319
  chatId: space,
1305
1320
  receipt: createGoogleChatSendReceipt({
1306
1321
  messageId,
1307
1322
  chatId: space,
1323
+ threadId: result?.threadName ?? thread,
1308
1324
  kind: "text"
1309
1325
  })
1310
1326
  };
@@ -1321,4 +1337,4 @@ const googlechatMessageAdapter = defineChannelMessageAdapter({
1321
1337
  send: { text: googlechatOutboundAdapter.attachedResults.sendText }
1322
1338
  });
1323
1339
  //#endregion
1324
- export { releaseGoogleChatApprovalCardBinding as A, claimGoogleChatApprovalCardBinding as C, readGoogleChatApprovalActionToken as D, getGoogleChatApprovalCardBinding as E, unregisterGoogleChatManualApprovalFollowupSuppression as M, registerGoogleChatApprovalCardBinding as O, buildGoogleChatApprovalActionParameters as S, createGoogleChatApprovalToken as T, probeGoogleChat as _, googlechatPairingTextAdapter as a, verifyGoogleChatRequest as b, buildGoogleChatGroupPolicyScope as c, isGoogleChatUserTarget as d, normalizeGoogleChatTarget as f, downloadGoogleChatMedia as g, deleteGoogleChatMessage as h, googlechatOutboundAdapter as i, unregisterGoogleChatApprovalCardBindings as j, registerGoogleChatManualApprovalFollowupSuppression as k, isGoogleChatGroupSpace as l, resolveGoogleChatOutboundSpace as m, googlechatGroupsAdapter as n, googlechatSecurityAdapter as o, resolveGoogleChatOutboundSessionRoute as p, googlechatMessageAdapter as r, googlechatThreadingAdapter as s, googlechatDirectoryAdapter as t, isGoogleChatSpaceTarget as u, sendGoogleChatMessage as v, completeGoogleChatApprovalCardBinding as w, GOOGLECHAT_APPROVAL_ACTION as x, updateGoogleChatMessage as y };
1340
+ export { registerGoogleChatManualApprovalFollowupSuppression as A, buildGoogleChatApprovalActionParameters as C, getGoogleChatApprovalCardBinding as D, createGoogleChatApprovalToken as E, unregisterGoogleChatApprovalCardBindings as M, unregisterGoogleChatManualApprovalFollowupSuppression as N, readGoogleChatApprovalActionToken as O, GOOGLECHAT_APPROVAL_ACTION as S, completeGoogleChatApprovalCardBinding as T, downloadGoogleChatMedia as _, googlechatPairingTextAdapter as a, updateGoogleChatMessage as b, buildGoogleChatGroupPolicyScope as c, isGoogleChatUserTarget as d, normalizeGoogleChatTarget as f, deleteGoogleChatMessage as g, GoogleChatApiError as h, googlechatOutboundAdapter as i, releaseGoogleChatApprovalCardBinding as j, registerGoogleChatApprovalCardBinding as k, isGoogleChatGroupSpace as l, resolveGoogleChatOutboundSpace as m, googlechatGroupsAdapter as n, googlechatSecurityAdapter as o, resolveGoogleChatOutboundSessionRoute as p, googlechatMessageAdapter as r, googlechatThreadingAdapter as s, googlechatDirectoryAdapter as t, isGoogleChatSpaceTarget as u, probeGoogleChat as v, claimGoogleChatApprovalCardBinding as w, verifyGoogleChatRequest as x, sendGoogleChatMessage as y };
@@ -1,19 +1,22 @@
1
- import { A as releaseGoogleChatApprovalCardBinding, C as claimGoogleChatApprovalCardBinding, D as readGoogleChatApprovalActionToken, E as getGoogleChatApprovalCardBinding, _ as probeGoogleChat, b as verifyGoogleChatRequest, c as buildGoogleChatGroupPolicyScope, g as downloadGoogleChatMedia, h as deleteGoogleChatMessage, l as isGoogleChatGroupSpace, v as sendGoogleChatMessage, w as completeGoogleChatApprovalCardBinding, y as updateGoogleChatMessage } from "./channel.adapters-DaipaeYt.js";
1
+ import { D as getGoogleChatApprovalCardBinding, O as readGoogleChatApprovalActionToken, T as completeGoogleChatApprovalCardBinding, _ as downloadGoogleChatMedia, b as updateGoogleChatMessage, c as buildGoogleChatGroupPolicyScope, g as deleteGoogleChatMessage, h as GoogleChatApiError, j as releaseGoogleChatApprovalCardBinding, l as isGoogleChatGroupSpace, v as probeGoogleChat, w as claimGoogleChatApprovalCardBinding, x as verifyGoogleChatRequest, y as sendGoogleChatMessage } from "./channel.adapters-DiI1p1ml.js";
2
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-Dh0CNVS4.js";
3
- import { n as googleChatApprovalAuth } from "./approval-auth-ykO6i_ub.js";
3
+ import { n as googleChatApprovalAuth } from "./approval-auth-Bm8YFEkI.js";
4
4
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";
6
6
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
7
- import { collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
8
- import { createChannelIngressError, createChannelIngressMonitor } from "openclaw/plugin-sdk/channel-outbound";
9
- import { recordChannelBotPairLoopAndCheckSuppression, resolveChannelInboundRouteEnvelope, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
10
- import { WEBHOOK_RATE_LIMIT_DEFAULTS, createFixedWindowRateLimiter, normalizeWebhookPath, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
7
+ import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates, formatErrorMessage, isApprovalNotFoundError } from "openclaw/plugin-sdk/error-runtime";
8
+ import { MediaFetchError } from "openclaw/plugin-sdk/media-runtime";
9
+ import { createChannelIngressError } from "openclaw/plugin-sdk/channel-outbound";
10
+ import { createChannelPartialDeliveryError, formatInboundMediaUnavailableText, recordChannelBotPairLoopAndCheckSuppression, resolveChannelInboundRouteEnvelope, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
11
+ import { WEBHOOK_RATE_LIMIT_DEFAULTS, canonicalizeWebhookRouteKey, createFixedWindowRateLimiter, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
11
12
  import { registerWebhookTargetWithPluginRoute, resolveWebhookTargetWithAuthOrReject, withResolvedWebhookRequestPipeline } from "openclaw/plugin-sdk/webhook-targets";
12
13
  import { createWebhookInFlightLimiter, readJsonWebhookBodyOrReject, runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
14
+ import { channelBlockedPatch, channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
13
15
  import { isRecord } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
14
16
  import { resolveApprovalOverGateway } from "openclaw/plugin-sdk/approval-gateway-runtime";
15
- import { channelIngressRoutes, createChannelIngressResolver, defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
17
+ import { channelIngressRoutes, createChannelIngressResolver, createStandardRawEventIngressMonitor, defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
16
18
  import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
19
+ import { parseDateStringTimestampMs } from "openclaw/plugin-sdk/number-runtime";
17
20
  //#region extensions/googlechat/src/approval-terminal-card.ts
18
21
  const GOOGLECHAT_APPROVAL_CARD_ID = "openclaw-approval";
19
22
  const MAX_TEXT_PARAGRAPH_CHARS = 1800;
@@ -128,8 +131,9 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
128
131
  approvalId: consumed.approvalId,
129
132
  approvalKind: consumed.approvalKind,
130
133
  decision: consumed.decision,
131
- senderId: actor,
132
- clientDisplayName: `Google Chat approval (${actor?.trim() || "unknown"})`
134
+ channel: "googlechat",
135
+ accountId: params.target.account.accountId,
136
+ senderId: actor
133
137
  });
134
138
  await updateGoogleChatMessage({
135
139
  account: params.target.account,
@@ -137,6 +141,11 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
137
141
  cardsV2: buildGoogleChatCanonicalApprovalTerminalCards(result)
138
142
  });
139
143
  } catch (error) {
144
+ if (isApprovalNotFoundError(error)) {
145
+ completeGoogleChatApprovalCardBinding(token);
146
+ logIgnored(params.target, `approval expired or no longer exists id=${consumed.approvalId}`);
147
+ return true;
148
+ }
140
149
  releaseGoogleChatApprovalCardBinding(token);
141
150
  throw error;
142
151
  }
@@ -332,6 +341,7 @@ async function applyGoogleChatInboundAccessPolicy(params) {
332
341
  kind: isGroup ? "group" : "direct",
333
342
  id: spaceId
334
343
  },
344
+ contextBinding: params.contextBinding,
335
345
  route,
336
346
  allowFrom: rawConfigAllowFrom,
337
347
  groupAllowFrom,
@@ -424,6 +434,7 @@ async function applyGoogleChatInboundAccessPolicy(params) {
424
434
  }
425
435
  return {
426
436
  ok: true,
437
+ channelIngress: resolvedAccess,
427
438
  commandAuthorized,
428
439
  effectiveWasMentioned,
429
440
  groupBotLoopProtection: groupEntry?.botLoopProtection,
@@ -513,9 +524,6 @@ function parseGoogleChatInboundPayload(raw) {
513
524
  }
514
525
  //#endregion
515
526
  //#region extensions/googlechat/src/monitor-ingress.ts
516
- const GOOGLECHAT_INGRESS_PAYLOAD_VERSION = 1;
517
- const GOOGLECHAT_INGRESS_POLL_INTERVAL_MS = 500;
518
- const GOOGLECHAT_INGRESS_MAX_CONCURRENT_DELIVERIES = 8;
519
527
  const GoogleChatIngressPermanentError = createChannelIngressError("GoogleChatIngressPermanentError", { withReason: true });
520
528
  function requiredString(value, field) {
521
529
  if (typeof value === "string" && value.trim()) return value.trim();
@@ -584,63 +592,60 @@ function createGoogleChatIngressMonitor(options) {
584
592
  if (typeof serialized !== "string") throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope cannot be serialized.");
585
593
  return serialized;
586
594
  };
587
- const monitor = createChannelIngressMonitor({
595
+ return createStandardRawEventIngressMonitor({
588
596
  queue: options.queue ?? (() => getGoogleChatRuntime().state.openChannelIngressQueue({ accountId: options.accountId })),
589
597
  inspect: (rawEvent) => inspectGoogleChatIngressEvent(rawEvent),
590
598
  payload: {
591
- storage: "raw-event",
592
- version: GOOGLECHAT_INGRESS_PAYLOAD_VERSION,
593
599
  serialize: serializeForIngress,
594
600
  deserialize: (rawEvent, { claim }) => deserializeGoogleChatIngressEvent(rawEvent, claim.id),
595
601
  createClaimError: (kind, claim) => new GoogleChatIngressPermanentError("invalid-event", kind === "invalid-version" ? `Google Chat ingress row ${claim.id} has an invalid payload.` : `Google Chat ingress row ${claim.id} has invalid message identity.`)
596
602
  },
597
603
  deliver: (rawEvent, lifecycle, claim) => options.dispatch(normalizeClaimedGoogleChatEvent(rawEvent, claim.id), lifecycle),
598
- pollIntervalMs: options.pollIntervalMs ?? GOOGLECHAT_INGRESS_POLL_INTERVAL_MS,
599
- retention: "standard",
604
+ pollIntervalMs: options.pollIntervalMs,
600
605
  drain: {
601
606
  resolveNonRetryableFailure: resolveGoogleChatIngressNonRetryableFailure,
602
- startLimit: GOOGLECHAT_INGRESS_MAX_CONCURRENT_DELIVERIES,
603
607
  ...options.adoptionStallTimeoutMs === void 0 ? {} : { adoptionStallTimeoutMs: options.adoptionStallTimeoutMs },
604
608
  onLog: (message) => options.runtime.error?.(`googlechat: ${message}`)
605
609
  },
606
610
  ...options.abortSignal ? { abortSignal: options.abortSignal } : {},
607
- admissionMode: "while-running",
608
611
  createStoppedError: () => /* @__PURE__ */ new Error("Google Chat ingress is stopped."),
609
- onError: (error) => options.runtime.error?.(`googlechat ingress drain failed: ${formatErrorMessage(error)}`)
612
+ onError: (error) => options.runtime.error?.(`googlechat ingress drain failed: ${formatErrorMessage(error)}`),
613
+ classifyAdmissionError: (error) => error instanceof GoogleChatIngressPermanentError ? error.message : void 0
610
614
  });
611
- return {
612
- receive: async (rawEvent) => {
613
- if (!monitor.isRunning()) throw new Error("Google Chat ingress is stopped.");
614
- let facts;
615
- try {
616
- facts = inspectGoogleChatIngressEvent(rawEvent);
617
- } catch (error) {
618
- if (error instanceof GoogleChatIngressPermanentError) return {
619
- kind: "invalid",
620
- message: error.message
621
- };
622
- throw error;
623
- }
624
- if (!facts) return { kind: "ignored" };
625
- await monitor.admit(rawEvent, { facts });
626
- return { kind: "durable" };
627
- },
628
- start: monitor.start,
629
- stop: monitor.stop,
630
- waitForIdle: monitor.waitForIdle
631
- };
632
615
  }
633
616
  //#endregion
634
617
  //#region extensions/googlechat/src/monitor-reply-delivery.ts
618
+ function createGoogleChatTypingMessage(params) {
619
+ const name = params.messageName.trim();
620
+ const requestedThreadName = params.requestedThreadName?.trim();
621
+ if (!requestedThreadName) return {
622
+ placement: "top-level",
623
+ name
624
+ };
625
+ return {
626
+ placement: "thread",
627
+ name,
628
+ requestedThreadName,
629
+ deliveredThreadName: params.deliveredThreadName?.trim() || requestedThreadName
630
+ };
631
+ }
635
632
  async function deliverGoogleChatReply(params) {
636
633
  const { payload, account, spaceId, runtime, core, config, statusSink } = params;
637
634
  let typingMessage = params.typingMessage;
638
635
  const replyThreadName = payload.replyToId?.trim() || void 0;
639
- const typingMessageThreadName = typingMessage?.thread?.trim() || void 0;
640
636
  const reply = resolveSendableOutboundReplyParts(payload);
641
- const text = reply.text;
642
- let firstTextChunk = true;
643
- if (typingMessage && typingMessageThreadName !== replyThreadName) {
637
+ let deliveryThreadName = replyThreadName;
638
+ const acceptedText = [];
639
+ const runTextOperation = async (operation) => await operation.catch((error) => {
640
+ if (acceptedText.length === 0) throw error;
641
+ throw createChannelPartialDeliveryError(error, {
642
+ messageIds: acceptedText.flatMap(({ id }) => id ? [id] : []),
643
+ content: acceptedText.map(({ text }) => text).join("\n"),
644
+ visibleReplySent: true
645
+ });
646
+ });
647
+ const typingMatchesReply = typingMessage?.placement === "thread" ? typingMessage.requestedThreadName === replyThreadName : typingMessage?.placement === "top-level" ? replyThreadName === void 0 : false;
648
+ if (typingMessage && !typingMatchesReply) {
644
649
  try {
645
650
  await deleteGoogleChatMessage({
646
651
  account,
@@ -650,7 +655,7 @@ async function deliverGoogleChatReply(params) {
650
655
  runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
651
656
  }
652
657
  typingMessage = void 0;
653
- }
658
+ } else if (typingMessage?.placement === "thread") deliveryThreadName = typingMessage.deliveredThreadName;
654
659
  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.");
655
660
  if (reply.hasMedia && !reply.hasText) {
656
661
  try {
@@ -661,7 +666,10 @@ async function deliverGoogleChatReply(params) {
661
666
  } catch (err) {
662
667
  runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
663
668
  }
664
- throw new Error("Google Chat outbound attachments require user OAuth and no text fallback is available.");
669
+ throw new PlatformMessageNotDispatchedError("Google Chat outbound attachments require user OAuth and no text fallback is available.", {
670
+ cause: void 0,
671
+ retryable: false
672
+ });
665
673
  }
666
674
  const chunkLimit = account.config.textChunkLimit ?? 4e3;
667
675
  const chunkMode = core.channel.text.resolveChunkMode(config, "googlechat", account.accountId);
@@ -673,35 +681,42 @@ async function deliverGoogleChatReply(params) {
673
681
  }
674
682
  };
675
683
  const sendTextMessage = async (chunk) => {
676
- await sendGoogleChatMessage({
684
+ const sent = await runTextOperation(sendGoogleChatMessage({
677
685
  account,
678
686
  space: spaceId,
679
687
  text: chunk,
680
- thread: replyThreadName
688
+ thread: deliveryThreadName
689
+ }));
690
+ if (sent) acceptedText.push({
691
+ id: sent.messageName?.trim() || void 0,
692
+ text: chunk
681
693
  });
694
+ if (replyThreadName) deliveryThreadName = sent?.threadName?.trim() || deliveryThreadName;
682
695
  };
683
- const chunks = core.channel.text.chunkMarkdownTextWithMode(text, chunkLimit, chunkMode);
696
+ const chunks = core.channel.text.chunkMarkdownTextWithMode(reply.text, chunkLimit, chunkMode);
684
697
  for (const chunk of chunks) {
685
698
  if (!chunk) continue;
686
- if (firstTextChunk && typingMessage) {
699
+ if (typingMessage) {
687
700
  try {
688
- await updateGoogleChatMessage({
701
+ const updated = await updateGoogleChatMessage({
689
702
  account,
690
703
  messageName: typingMessage.name,
691
704
  text: chunk
692
705
  });
693
- } catch (err) {
694
- runtime.error?.(`Google Chat message send failed: ${String(err)}`);
695
- typingMessage = void 0;
696
- }
697
- if (typingMessage) {
698
- firstTextChunk = false;
699
- recordOutboundStatus();
700
- continue;
706
+ acceptedText.push({
707
+ id: updated.messageName?.trim() || typingMessage.name,
708
+ text: chunk
709
+ });
710
+ } catch (error) {
711
+ if (!(error instanceof GoogleChatApiError) || error.status !== 404) throw error;
712
+ runtime.error?.(`Google Chat typing update failed: ${String(error)}`);
713
+ await sendTextMessage(chunk);
701
714
  }
715
+ typingMessage = void 0;
716
+ recordOutboundStatus();
717
+ continue;
702
718
  }
703
719
  await sendTextMessage(chunk);
704
- firstTextChunk = false;
705
720
  recordOutboundStatus();
706
721
  }
707
722
  }
@@ -781,7 +796,7 @@ function warnAppPrincipalMisconfiguration(params) {
781
796
  }
782
797
  function createGoogleChatWebhookRequestHandler(params) {
783
798
  return async (req, res) => {
784
- const path = normalizeWebhookPath(new URL(req.url ?? "/", "http://localhost").pathname);
799
+ const path = canonicalizeWebhookRouteKey(new URL(req.url ?? "/", "http://localhost").pathname);
785
800
  const config = params.webhookTargets.get(path)?.[0]?.config;
786
801
  const clientIp = resolveRequestClientIp(req, config?.gateway?.trustedProxies, config?.gateway?.allowRealIpFallback === true) ?? "unknown";
787
802
  return await withResolvedWebhookRequestPipeline({
@@ -913,6 +928,7 @@ function registerGoogleChatWebhookTarget(target) {
913
928
  source: "googlechat-webhook",
914
929
  accountId: target.account.accountId,
915
930
  log: target.runtime.log,
931
+ throwOnFailure: true,
916
932
  handler: async (req, res) => {
917
933
  if (!await handleGoogleChatWebhookRequest(req, res) && !res.headersSent) {
918
934
  res.statusCode = 404;
@@ -937,11 +953,6 @@ function normalizeAudienceType(value) {
937
953
  if (normalized === "app-url" || normalized === "app_url" || normalized === "app") return "app-url";
938
954
  if (normalized === "project-number" || normalized === "project_number" || normalized === "project") return "project-number";
939
955
  }
940
- function resolveGoogleChatTimestampMs(eventTime) {
941
- if (!eventTime) return;
942
- const parsed = Date.parse(eventTime);
943
- return Number.isFinite(parsed) ? parsed : void 0;
944
- }
945
956
  function resolveGoogleChatBotLoopProtection(params) {
946
957
  if (!params.allowBots || !params.isBotSender || !params.senderId || params.senderId === params.appUserId) return;
947
958
  return {
@@ -952,7 +963,7 @@ function resolveGoogleChatBotLoopProtection(params) {
952
963
  config: params.config,
953
964
  defaultsConfig: params.defaultsConfig,
954
965
  defaultEnabled: true,
955
- nowMs: resolveGoogleChatTimestampMs(params.eventTime)
966
+ nowMs: parseDateStringTimestampMs(params.eventTime)
956
967
  };
957
968
  }
958
969
  function resolveGoogleChatBotLoopProtectionConfig(params) {
@@ -1026,8 +1037,17 @@ async function processMessageWithPipeline(params) {
1026
1037
  }
1027
1038
  const messageText = (message.argumentText ?? message.text ?? "").trim();
1028
1039
  const attachments = message.attachment ?? [];
1029
- const rawBody = messageText;
1040
+ let rawBody = messageText;
1030
1041
  if (!rawBody && attachments.length === 0) return;
1042
+ const { route, buildEnvelope } = resolveChannelInboundRouteEnvelope({
1043
+ cfg: config,
1044
+ channel: "googlechat",
1045
+ accountId: account.accountId,
1046
+ peer: {
1047
+ kind: isGroup ? "group" : "direct",
1048
+ id: spaceId
1049
+ }
1050
+ });
1031
1051
  const access = await applyGoogleChatInboundAccessPolicy({
1032
1052
  account,
1033
1053
  config,
@@ -1039,6 +1059,12 @@ async function processMessageWithPipeline(params) {
1039
1059
  senderName,
1040
1060
  senderEmail,
1041
1061
  rawBody,
1062
+ contextBinding: {
1063
+ agentId: route.agentId,
1064
+ sessionKey: route.sessionKey,
1065
+ ...message.name ? { messageId: message.name } : {},
1066
+ inboundEventKind: "user_request"
1067
+ },
1042
1068
  statusSink,
1043
1069
  logVerbose: (messageLocal) => logVerbose(core, runtime, messageLocal)
1044
1070
  });
@@ -1062,28 +1088,27 @@ async function processMessageWithPipeline(params) {
1062
1088
  core,
1063
1089
  runtime
1064
1090
  })) return;
1065
- const { route, buildEnvelope } = resolveChannelInboundRouteEnvelope({
1066
- cfg: config,
1067
- channel: "googlechat",
1068
- accountId: account.accountId,
1069
- peer: {
1070
- kind: isGroup ? "group" : "direct",
1071
- id: spaceId
1072
- }
1073
- });
1074
1091
  const mediaInputs = attachments.map((attachment) => ({ contentType: attachment.contentType }));
1075
1092
  const first = attachments.at(0);
1076
- if (first) {
1093
+ if (first) try {
1077
1094
  const attachmentData = await downloadAttachment(first, account, mediaMaxMb, core);
1078
1095
  if (attachmentData) mediaInputs[0] = {
1079
1096
  path: attachmentData.path,
1080
1097
  url: attachmentData.path,
1081
1098
  contentType: attachmentData.contentType ?? first.contentType
1082
1099
  };
1100
+ } catch (error) {
1101
+ if (!(error instanceof MediaFetchError) || error.code !== "max_bytes") throw error;
1102
+ const notice = `[Google Chat attachment too large; maximum ${mediaMaxMb} MB]`;
1103
+ rawBody = formatInboundMediaUnavailableText({
1104
+ body: rawBody,
1105
+ notice
1106
+ });
1107
+ runtime.error?.(`[${account.accountId}] ${notice} Increase channels.googlechat.mediaMaxMb to process larger attachments.`);
1083
1108
  }
1084
1109
  const media = await toInboundMediaFactsWithMetadata(mediaInputs);
1085
1110
  const fromLabel = isGroup ? space.displayName || `space:${spaceId}` : senderName || `user:${senderId}`;
1086
- const timestampMs = resolveGoogleChatTimestampMs(event.eventTime);
1111
+ const timestampMs = parseDateStringTimestampMs(event.eventTime);
1087
1112
  const body = buildEnvelope({
1088
1113
  channel: "Google Chat",
1089
1114
  from: fromLabel,
@@ -1092,6 +1117,7 @@ async function processMessageWithPipeline(params) {
1092
1117
  });
1093
1118
  const replyThreadName = isGroup ? message.thread?.name : void 0;
1094
1119
  const ctxPayload = core.channel.inbound.buildContext({
1120
+ channelIngress: access.channelIngress,
1095
1121
  channel: "googlechat",
1096
1122
  accountId: route.accountId,
1097
1123
  messageId: message.name,
@@ -1155,10 +1181,11 @@ async function processMessageWithPipeline(params) {
1155
1181
  })} is typing..._`,
1156
1182
  thread: typingMessageThreadName
1157
1183
  });
1158
- if (result?.messageName) typingMessage = {
1159
- name: result.messageName,
1160
- thread: typingMessageThreadName
1161
- };
1184
+ if (result?.messageName) typingMessage = createGoogleChatTypingMessage({
1185
+ messageName: result.messageName,
1186
+ requestedThreadName: typingMessageThreadName,
1187
+ deliveredThreadName: result.threadName
1188
+ });
1162
1189
  } catch (err) {
1163
1190
  runtime.error?.(`Failed sending typing message: ${String(err)}`);
1164
1191
  }
@@ -1248,6 +1275,16 @@ async function monitorGoogleChatProvider(options) {
1248
1275
  }
1249
1276
  const audienceType = normalizeAudienceType(options.account.config.audienceType);
1250
1277
  const audience = options.account.config.audience?.trim();
1278
+ if (!audienceType || !audience) {
1279
+ const error = "Google Chat webhook authentication requires channels.googlechat.audienceType and channels.googlechat.audience.";
1280
+ options.runtime.error?.(`[${options.account.accountId}] ${error}`);
1281
+ options.statusSink?.(channelBlockedPatch(error, {
1282
+ running: true,
1283
+ connected: false,
1284
+ webhookPath: void 0
1285
+ }));
1286
+ return async () => {};
1287
+ }
1251
1288
  const mediaMaxMb = options.account.config.mediaMaxMb ?? 20;
1252
1289
  warnAppPrincipalMisconfiguration({
1253
1290
  accountId: options.account.accountId,
@@ -1279,6 +1316,7 @@ async function monitorGoogleChatProvider(options) {
1279
1316
  let unregisterTarget;
1280
1317
  try {
1281
1318
  unregisterTarget = registerGoogleChatWebhookTarget(target);
1319
+ options.statusSink?.(channelReadyPatch());
1282
1320
  } catch (error) {
1283
1321
  await ingress.stop();
1284
1322
  throw error;
@@ -1296,7 +1334,7 @@ function resolveGoogleChatWebhookPath(params) {
1296
1334
  webhookPath: params.account.config.webhookPath,
1297
1335
  webhookUrl: params.account.config.webhookUrl,
1298
1336
  defaultPath: "/googlechat"
1299
- }) ?? "/googlechat";
1337
+ });
1300
1338
  }
1301
1339
  //#endregion
1302
1340
  //#region extensions/googlechat/src/channel.runtime.ts
@@ -1,4 +1,4 @@
1
- import { t as googlechatDirectoryAdapter } from "./channel.adapters-DaipaeYt.js";
1
+ import { t as googlechatDirectoryAdapter } from "./channel.adapters-DiI1p1ml.js";
2
2
  //#region extensions/googlechat/directory-contract-api.ts
3
3
  const googlechatDirectoryContractPlugin = {
4
4
  id: "googlechat",
@@ -1,4 +1,4 @@
1
- import { asObjectRecord, defineChannelAliasMigration, defineKeyMoveMigration, hasLegacyAccountStreamingAliases, normalizeChannelConfigEntries } from "openclaw/plugin-sdk/runtime-doctor";
1
+ import { asObjectRecord, defineChannelAliasMigration, defineKeyMoveMigration, hasLegacyAccountStreamingAliases, normalizeChannelConfigEntries } from "openclaw/plugin-sdk/runtime-doctor-migrations";
2
2
  //#region extensions/googlechat/src/doctor-contract.ts
3
3
  const streamingAliasMigration = defineChannelAliasMigration({
4
4
  channelId: "googlechat",
@@ -1,2 +1,2 @@
1
- import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BpuSvJro.js";
1
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BLvSmTXT.js";
2
2
  export { legacyConfigRules, normalizeCompatibilityConfig };
@@ -1,4 +1,4 @@
1
- import { n as createGoogleChatPluginBase } from "./channel-base-hw9ErEr5.js";
1
+ import { n as createGoogleChatPluginBase } from "./channel-base-BpHXDsur.js";
2
2
  //#region extensions/googlechat/src/channel.setup.ts
3
3
  const googlechatSetupPlugin = createGoogleChatPluginBase();
4
4
  //#endregion
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "id": "googlechat",
3
+ "doctorContract": {
4
+ "configRepair": true
5
+ },
3
6
  "name": "Google Chat",
4
7
  "description": "OpenClaw Google Chat channel plugin for spaces and direct messages.",
5
8
  "icon": "https://cdn.simpleicons.org/googlechat",
@@ -403,6 +406,29 @@
403
406
  "id"
404
407
  ],
405
408
  "additionalProperties": false
409
+ },
410
+ {
411
+ "type": "object",
412
+ "properties": {
413
+ "source": {
414
+ "type": "string",
415
+ "const": "store"
416
+ },
417
+ "provider": {
418
+ "type": "string",
419
+ "pattern": "^[a-z][a-z0-9_-]{0,63}$"
420
+ },
421
+ "id": {
422
+ "type": "string",
423
+ "pattern": "^[A-Z][A-Z0-9_]{0,127}$"
424
+ }
425
+ },
426
+ "required": [
427
+ "source",
428
+ "provider",
429
+ "id"
430
+ ],
431
+ "additionalProperties": false
406
432
  }
407
433
  ]
408
434
  }
@@ -840,6 +866,29 @@
840
866
  "id"
841
867
  ],
842
868
  "additionalProperties": false
869
+ },
870
+ {
871
+ "type": "object",
872
+ "properties": {
873
+ "source": {
874
+ "type": "string",
875
+ "const": "store"
876
+ },
877
+ "provider": {
878
+ "type": "string",
879
+ "pattern": "^[a-z][a-z0-9_-]{0,63}$"
880
+ },
881
+ "id": {
882
+ "type": "string",
883
+ "pattern": "^[A-Z][A-Z0-9_]{0,127}$"
884
+ }
885
+ },
886
+ "required": [
887
+ "source",
888
+ "provider",
889
+ "id"
890
+ ],
891
+ "additionalProperties": false
843
892
  }
844
893
  ]
845
894
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/googlechat",
3
- "version": "2026.7.2-beta.7",
3
+ "version": "2026.8.1-beta.2",
4
4
  "description": "OpenClaw Google Chat channel plugin for spaces and direct messages.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "zod": "4.4.3"
13
13
  },
14
14
  "peerDependencies": {
15
- "openclaw": ">=2026.7.2-beta.7"
15
+ "openclaw": ">=2026.8.1-beta.2"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "openclaw": {
@@ -51,7 +51,7 @@
51
51
  "systemImage": "message.badge",
52
52
  "markdownCapable": true,
53
53
  "doctorCapabilities": {
54
- "dmAllowFromMode": "nestedOnly",
54
+ "dmAllowFromMode": "topOnly",
55
55
  "groupModel": "route",
56
56
  "groupAllowFromFallbackToAllowFrom": false,
57
57
  "warnOnEmptyGroupSenderAllowlist": false
@@ -118,7 +118,12 @@
118
118
  "cli": {
119
119
  "flags": "--use-env",
120
120
  "description": "Use Google Chat environment credentials"
121
- }
121
+ },
122
+ "envVars": [
123
+ "GOOGLE_CHAT_SERVICE_ACCOUNT",
124
+ "GOOGLE_CHAT_SERVICE_ACCOUNT_FILE"
125
+ ],
126
+ "envVarMode": "any"
122
127
  }
123
128
  ]
124
129
  }
@@ -129,10 +134,10 @@
129
134
  "minHostVersion": ">=2026.4.10"
130
135
  },
131
136
  "compat": {
132
- "pluginApi": ">=2026.7.2-beta.7"
137
+ "pluginApi": ">=2026.8.1-beta.2"
133
138
  },
134
139
  "build": {
135
- "openclawVersion": "2026.7.2-beta.7"
140
+ "openclawVersion": "2026.8.1-beta.2"
136
141
  },
137
142
  "release": {
138
143
  "publishToClawHub": true,