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

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-FZq5jdkN.js";
3
+ import { n as describeGoogleChatMessageTool } from "./channel-Cy93IxLN.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-Cy93IxLN.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-FZq5jdkN.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-FZq5jdkN.js";
3
+ import { i as shouldHandleGoogleChatNativeApprovalRequest, r as isGoogleChatNativeApprovalClientEnabled } from "./channel-Cy93IxLN.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-FZq5jdkN.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-AECosdcm.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-DcfApI4d.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-CU_z4ppv.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-CU_z4ppv.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-B5wHFHkX.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-Cy93IxLN.js";
2
2
  export { googlechatPlugin };
@@ -1,21 +1,22 @@
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";
17
18
  import { adaptScopedAccountAccessor } from "openclaw/plugin-sdk/channel-config-helpers";
18
- import { buildChannelGroupsScopeTree, composeAccountWarningCollectors, createAllowlistProviderOpenWarningCollector, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
19
+ import { buildChannelGroupsScopeTree, createAllowlistProviderOpenWarningCollector, createConditionalWarningCollector, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
19
20
  import { createChannelDirectoryAdapter, listResolvedDirectoryGroupEntriesFromMapKeys, listResolvedDirectoryUserEntriesFromAllowFrom } from "openclaw/plugin-sdk/directory-runtime";
20
21
  //#region extensions/googlechat/src/approval-card-actions.ts
21
22
  const GOOGLECHAT_APPROVAL_ACTION = "openclaw.approval";
@@ -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;
@@ -295,15 +293,19 @@ function assertUrlPrefixField(record, fieldName, expectedPrefix) {
295
293
  function validateGoogleChatServiceAccountCredentials(credentials) {
296
294
  const type = readOptionalTrimmedString(credentials, "type");
297
295
  if (type && type !== "service_account") throw new Error(`Google Chat credentials must use service_account auth, got "${type}" instead`);
298
- readRequiredTrimmedString(credentials, "client_email");
299
- readRequiredTrimmedString(credentials, "private_key");
296
+ const clientEmail = readRequiredTrimmedString(credentials, "client_email");
297
+ const privateKey = readRequiredTrimmedString(credentials, "private_key");
300
298
  const universeDomain = readOptionalTrimmedString(credentials, "universe_domain");
301
299
  if (universeDomain && universeDomain !== GOOGLE_AUTH_UNIVERSE_DOMAIN) throw new Error(`Google Chat service account field "universe_domain" must be ${GOOGLE_AUTH_UNIVERSE_DOMAIN}, got ${universeDomain}`);
302
300
  assertExactUrlField(credentials, "auth_uri", GOOGLE_AUTH_URI);
303
301
  assertExactUrlField(credentials, "auth_provider_x509_cert_url", GOOGLE_AUTH_PROVIDER_CERTS_URL);
304
302
  assertExactUrlField(credentials, "token_uri", GOOGLE_AUTH_TOKEN_URI);
305
303
  assertUrlPrefixField(credentials, "client_x509_cert_url", GOOGLE_CLIENT_CERTS_URL_PREFIX);
306
- return credentials;
304
+ return {
305
+ ...credentials,
306
+ client_email: clientEmail,
307
+ private_key: privateKey
308
+ };
307
309
  }
308
310
  async function readCredentialsFile(filePath) {
309
311
  const resolvedPath = resolveUserPath(filePath);
@@ -404,6 +406,7 @@ function createGoogleAuthFetch() {
404
406
  statusText: response.statusText
405
407
  });
406
408
  } finally {
409
+ if (!response.bodyUsed) response.body?.cancel().catch(() => void 0);
407
410
  await release();
408
411
  }
409
412
  };
@@ -617,30 +620,32 @@ const GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS = 3e4;
617
620
  const GOOGLECHAT_JSON_RESPONSE_MAX_BYTES = 16 * 1024 * 1024;
618
621
  const GOOGLECHAT_ERROR_BODY_MAX_BYTES = 16 * 1024;
619
622
  const GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES = 20 * 1024 * 1024;
623
+ var GoogleChatApiError = class extends Error {
624
+ constructor(status, message) {
625
+ super(message);
626
+ this.status = status;
627
+ this.name = "GoogleChatApiError";
628
+ }
629
+ };
620
630
  function resolveGoogleChatMediaTimeoutMs(maxBytes) {
621
631
  if (!maxBytes) return GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS;
622
632
  const transferMs = Math.ceil(maxBytes / GOOGLECHAT_MEDIA_MIN_BYTES_PER_SECOND * 1e3);
623
633
  return Math.min(GOOGLECHAT_MEDIA_TIMEOUT_GRACE_MS + transferMs, GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS);
624
634
  }
625
635
  async function readGoogleChatJsonResponse(response, label) {
626
- const bytes = await readResponseWithLimit(response, GOOGLECHAT_JSON_RESPONSE_MAX_BYTES, {
636
+ return readProviderJsonResponse(response, label, {
637
+ maxBytes: GOOGLECHAT_JSON_RESPONSE_MAX_BYTES,
627
638
  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`)
639
+ onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`${label}: response body stalled after ${chunkTimeoutMs}ms`)
630
640
  });
631
- try {
632
- return JSON.parse(new TextDecoder().decode(bytes));
633
- } catch (cause) {
634
- throw new Error(`${label}: malformed JSON response`, { cause });
635
- }
636
641
  }
637
642
  async function readGoogleChatErrorResponse(response, label) {
638
- return await readResponseTextSnippet(response, {
643
+ return redactToolPayloadText(await readResponseTextSnippet(response, {
639
644
  maxBytes: GOOGLECHAT_ERROR_BODY_MAX_BYTES,
640
645
  maxChars: GOOGLECHAT_ERROR_BODY_MAX_BYTES,
641
646
  chunkTimeoutMs: GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS,
642
647
  onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`${label} error response stalled after ${chunkTimeoutMs}ms`)
643
- }) ?? "";
648
+ }) ?? "");
644
649
  }
645
650
  const headersToObject = (headers) => headers instanceof Headers ? Object.fromEntries(headers.entries()) : Array.isArray(headers) ? Object.fromEntries(headers) : headers || {};
646
651
  async function withGoogleChatResponse(params) {
@@ -661,7 +666,7 @@ async function withGoogleChatResponse(params) {
661
666
  try {
662
667
  if (!response.ok) {
663
668
  const text = await readGoogleChatErrorResponse(response, errorPrefix);
664
- throw new Error(`${errorPrefix} ${response.status}: ${text || response.statusText}`);
669
+ throw new GoogleChatApiError(response.status, `${errorPrefix} ${response.status}: ${text || response.statusText}`);
665
670
  }
666
671
  return await handleResponse(response);
667
672
  } finally {
@@ -705,27 +710,40 @@ async function fetchBuffer(account, url, init, options) {
705
710
  const lengthHeader = res.headers.get("content-length");
706
711
  if (lengthHeader) {
707
712
  const length = parseMediaContentLength(lengthHeader);
708
- if (length !== null && length > maxBytes) throw new Error(`Google Chat media exceeds max bytes (${maxBytes})`);
713
+ if (length !== null && length > maxBytes) throw new MediaFetchError("max_bytes", `Google Chat media exceeds max bytes (${maxBytes})`);
709
714
  }
710
715
  return {
711
716
  buffer: await readResponseWithLimit(res, maxBytes, {
712
717
  chunkTimeoutMs: GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS,
713
- onOverflow: () => /* @__PURE__ */ new Error(`Google Chat media exceeds max bytes (${maxBytes})`)
718
+ onOverflow: () => new MediaFetchError("max_bytes", `Google Chat media exceeds max bytes (${maxBytes})`)
714
719
  }),
715
720
  contentType: res.headers.get("content-type") ?? void 0
716
721
  };
717
722
  }
718
723
  });
719
724
  }
725
+ /**
726
+ * A Google Chat `thread` must be a `spaces/{space}/threads/{thread}` resource
727
+ * name that belongs to the target space. Reply routing sometimes yields other
728
+ * shapes — a bare id, a `spaces/{space}/messages/{message}` name, or a thread
729
+ * from a different (or wrongly-cased) space — and passing any of those makes the
730
+ * Chat API reject the whole send with `400 INVALID_ARGUMENT`. Accept only a
731
+ * well-formed, same-space thread name; callers drop the rest so the message
732
+ * still delivers to the space (as a new thread) instead of failing outright.
733
+ */
734
+ function isUsableGoogleChatThreadName(thread, space) {
735
+ return /^spaces\/[^/]+\/threads\/[^/]+$/.test(thread) && thread.startsWith(`${space}/threads/`);
736
+ }
720
737
  async function sendGoogleChatMessage(params) {
721
738
  const { account, space, text, thread, cardsV2 } = params;
739
+ const usableThread = thread && isUsableGoogleChatThreadName(thread, space) ? thread : void 0;
722
740
  if (text && (!cardsV2 || cardsV2.length === 0) && shouldSuppressGoogleChatManualExecApprovalFollowupText(text)) return null;
723
741
  const body = {};
724
742
  if (text) body.text = text;
725
743
  if (cardsV2 && cardsV2.length > 0) body.cardsV2 = cardsV2;
726
- if (thread) body.thread = { name: thread };
744
+ if (usableThread) body.thread = { name: usableThread };
727
745
  const urlObj = new URL(`${CHAT_API_BASE}/${space}/messages`);
728
- if (thread) urlObj.searchParams.set("messageReplyOption", "REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD");
746
+ if (usableThread) urlObj.searchParams.set("messageReplyOption", "REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD");
729
747
  const result = await fetchJson(account, urlObj.toString(), {
730
748
  method: "POST",
731
749
  body: JSON.stringify(body)
@@ -958,16 +976,18 @@ function projectGoogleChatLinkLabels(ir) {
958
976
  } : ir;
959
977
  }
960
978
  function markGoogleChatBulletLists(ir, markerToken) {
961
- let text = ir.text;
979
+ let characters;
962
980
  for (const item of ir.listItems ?? []) {
963
981
  const marker = item.listMarker;
964
- if (item.kind !== "bullet" || !marker || text.slice(marker.start, marker.end) !== "• ") continue;
965
- text = `${text.slice(0, marker.start)}${markerToken}${text.slice(marker.end)}`;
982
+ if (item.kind !== "bullet" || !marker || marker.end !== marker.start + 2 || ir.text[marker.start] !== "•" || ir.text[marker.start + 1] !== " ") continue;
983
+ characters ??= ir.text.split("");
984
+ characters[marker.start] = markerToken[0] ?? "";
985
+ characters[marker.start + 1] = markerToken[1] ?? "";
966
986
  }
967
- return text === ir.text ? ir : {
987
+ return characters ? {
968
988
  ...ir,
969
- text
970
- };
989
+ text: characters.join("")
990
+ } : ir;
971
991
  }
972
992
  function projectUnsafeCodeFallbacks(ir) {
973
993
  let text = ir.text;
@@ -1159,7 +1179,7 @@ function resolveGoogleChatGroupRequireMention(params) {
1159
1179
  }
1160
1180
  //#endregion
1161
1181
  //#region extensions/googlechat/src/channel.adapters.ts
1162
- const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-BbwE9vOC.js"), "googleChatChannelRuntime");
1182
+ const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-CU_z4ppv.js"), "googleChatChannelRuntime");
1163
1183
  function createGoogleChatSendReceipt(params) {
1164
1184
  const messageId = params.messageId?.trim();
1165
1185
  return createMessageReceiptFromOutboundResults({
@@ -1169,11 +1189,11 @@ function createGoogleChatSendReceipt(params) {
1169
1189
  chatId: params.chatId,
1170
1190
  conversationId: params.chatId
1171
1191
  }] : [],
1172
- threadId: params.chatId,
1192
+ threadId: params.threadId,
1173
1193
  kind: params.kind
1174
1194
  });
1175
1195
  }
1176
- const collectGoogleChatSecurityWarnings = composeAccountWarningCollectors(createAllowlistProviderOpenWarningCollector({
1196
+ const collectGoogleChatGroupPolicyWarnings = createAllowlistProviderOpenWarningCollector({
1177
1197
  providerConfigPresent: (cfg) => cfg.channels?.googlechat !== void 0,
1178
1198
  resolveGroupPolicy: (account) => account.config.groupPolicy,
1179
1199
  buildOpenWarning: {
@@ -1181,7 +1201,14 @@ const collectGoogleChatSecurityWarnings = composeAccountWarningCollectors(create
1181
1201
  openBehavior: "allows any space to trigger (mention-gated)",
1182
1202
  remediation: "Set channels.googlechat.groupPolicy=\"allowlist\" and configure channels.googlechat.groups"
1183
1203
  }
1184
- }), (account) => account.config.dmPolicy === "open" && "- Google Chat DMs are open to anyone. Set channels.googlechat.dmPolicy=\"pairing\" or \"allowlist\".");
1204
+ });
1205
+ const collectGoogleChatOpenGroupFindings = createConditionalWarningCollector.findings({
1206
+ collectWarnings: collectGoogleChatGroupPolicyWarnings,
1207
+ checkId: "channels.googlechat.groups.open",
1208
+ severity: "critical",
1209
+ title: "Google Chat security warning"
1210
+ });
1211
+ const collectGoogleChatSecurityWarnings = (params) => [...collectGoogleChatOpenGroupFindings(params), ...params.account.config.dmPolicy === "open" ? ["- Google Chat DMs are open to anyone. Set channels.googlechat.dmPolicy=\"pairing\" or \"allowlist\"."] : []];
1185
1212
  const googlechatGroupsAdapter = { resolveRequireMention: resolveGoogleChatGroupRequireMention };
1186
1213
  const googlechatDirectoryAdapter = createChannelDirectoryAdapter({
1187
1214
  listPeers: async (params) => listResolvedDirectoryUserEntriesFromAllowFrom({
@@ -1293,18 +1320,20 @@ const googlechatOutboundAdapter = {
1293
1320
  });
1294
1321
  const thread = typeof threadId === "number" ? String(threadId) : threadId ?? replyToId ?? void 0;
1295
1322
  const { sendGoogleChatMessage } = await loadGoogleChatChannelRuntime();
1296
- const messageId = (await sendGoogleChatMessage({
1323
+ const result = await sendGoogleChatMessage({
1297
1324
  account,
1298
1325
  space,
1299
1326
  text,
1300
1327
  thread
1301
- }))?.messageName ?? "";
1328
+ });
1329
+ const messageId = result?.messageName ?? "";
1302
1330
  return {
1303
1331
  messageId,
1304
1332
  chatId: space,
1305
1333
  receipt: createGoogleChatSendReceipt({
1306
1334
  messageId,
1307
1335
  chatId: space,
1336
+ threadId: result?.threadName ?? thread,
1308
1337
  kind: "text"
1309
1338
  })
1310
1339
  };
@@ -1321,4 +1350,4 @@ const googlechatMessageAdapter = defineChannelMessageAdapter({
1321
1350
  send: { text: googlechatOutboundAdapter.attachedResults.sendText }
1322
1351
  });
1323
1352
  //#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 };
1353
+ 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,18 +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-FZq5jdkN.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-AECosdcm.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";
16
+ import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
17
+ import { parseDateStringTimestampMs } from "openclaw/plugin-sdk/number-runtime";
14
18
  import { resolveApprovalOverGateway } from "openclaw/plugin-sdk/approval-gateway-runtime";
15
- import { channelIngressRoutes, createChannelIngressResolver, defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
19
+ import { channelIngressRoutes, createChannelIngressResolver, createStandardRawEventIngressMonitor, defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
16
20
  import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
17
21
  //#region extensions/googlechat/src/approval-terminal-card.ts
18
22
  const GOOGLECHAT_APPROVAL_CARD_ID = "openclaw-approval";
@@ -128,8 +132,9 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
128
132
  approvalId: consumed.approvalId,
129
133
  approvalKind: consumed.approvalKind,
130
134
  decision: consumed.decision,
131
- senderId: actor,
132
- clientDisplayName: `Google Chat approval (${actor?.trim() || "unknown"})`
135
+ channel: "googlechat",
136
+ accountId: params.target.account.accountId,
137
+ senderId: actor
133
138
  });
134
139
  await updateGoogleChatMessage({
135
140
  account: params.target.account,
@@ -137,6 +142,11 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
137
142
  cardsV2: buildGoogleChatCanonicalApprovalTerminalCards(result)
138
143
  });
139
144
  } catch (error) {
145
+ if (isApprovalNotFoundError(error)) {
146
+ completeGoogleChatApprovalCardBinding(token);
147
+ logIgnored(params.target, `approval expired or no longer exists id=${consumed.approvalId}`);
148
+ return true;
149
+ }
140
150
  releaseGoogleChatApprovalCardBinding(token);
141
151
  throw error;
142
152
  }
@@ -332,6 +342,7 @@ async function applyGoogleChatInboundAccessPolicy(params) {
332
342
  kind: isGroup ? "group" : "direct",
333
343
  id: spaceId
334
344
  },
345
+ contextBinding: params.contextBinding,
335
346
  route,
336
347
  allowFrom: rawConfigAllowFrom,
337
348
  groupAllowFrom,
@@ -424,6 +435,7 @@ async function applyGoogleChatInboundAccessPolicy(params) {
424
435
  }
425
436
  return {
426
437
  ok: true,
438
+ channelIngress: resolvedAccess,
427
439
  commandAuthorized,
428
440
  effectiveWasMentioned,
429
441
  groupBotLoopProtection: groupEntry?.botLoopProtection,
@@ -513,9 +525,6 @@ function parseGoogleChatInboundPayload(raw) {
513
525
  }
514
526
  //#endregion
515
527
  //#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
528
  const GoogleChatIngressPermanentError = createChannelIngressError("GoogleChatIngressPermanentError", { withReason: true });
520
529
  function requiredString(value, field) {
521
530
  if (typeof value === "string" && value.trim()) return value.trim();
@@ -584,63 +593,60 @@ function createGoogleChatIngressMonitor(options) {
584
593
  if (typeof serialized !== "string") throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope cannot be serialized.");
585
594
  return serialized;
586
595
  };
587
- const monitor = createChannelIngressMonitor({
596
+ return createStandardRawEventIngressMonitor({
588
597
  queue: options.queue ?? (() => getGoogleChatRuntime().state.openChannelIngressQueue({ accountId: options.accountId })),
589
598
  inspect: (rawEvent) => inspectGoogleChatIngressEvent(rawEvent),
590
599
  payload: {
591
- storage: "raw-event",
592
- version: GOOGLECHAT_INGRESS_PAYLOAD_VERSION,
593
600
  serialize: serializeForIngress,
594
601
  deserialize: (rawEvent, { claim }) => deserializeGoogleChatIngressEvent(rawEvent, claim.id),
595
602
  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
603
  },
597
604
  deliver: (rawEvent, lifecycle, claim) => options.dispatch(normalizeClaimedGoogleChatEvent(rawEvent, claim.id), lifecycle),
598
- pollIntervalMs: options.pollIntervalMs ?? GOOGLECHAT_INGRESS_POLL_INTERVAL_MS,
599
- retention: "standard",
605
+ pollIntervalMs: options.pollIntervalMs,
600
606
  drain: {
601
607
  resolveNonRetryableFailure: resolveGoogleChatIngressNonRetryableFailure,
602
- startLimit: GOOGLECHAT_INGRESS_MAX_CONCURRENT_DELIVERIES,
603
608
  ...options.adoptionStallTimeoutMs === void 0 ? {} : { adoptionStallTimeoutMs: options.adoptionStallTimeoutMs },
604
609
  onLog: (message) => options.runtime.error?.(`googlechat: ${message}`)
605
610
  },
606
611
  ...options.abortSignal ? { abortSignal: options.abortSignal } : {},
607
- admissionMode: "while-running",
608
612
  createStoppedError: () => /* @__PURE__ */ new Error("Google Chat ingress is stopped."),
609
- onError: (error) => options.runtime.error?.(`googlechat ingress drain failed: ${formatErrorMessage(error)}`)
613
+ onError: (error) => options.runtime.error?.(`googlechat ingress drain failed: ${formatErrorMessage(error)}`),
614
+ classifyAdmissionError: (error) => error instanceof GoogleChatIngressPermanentError ? error.message : void 0
610
615
  });
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
616
  }
633
617
  //#endregion
634
618
  //#region extensions/googlechat/src/monitor-reply-delivery.ts
619
+ function createGoogleChatTypingMessage(params) {
620
+ const name = params.messageName.trim();
621
+ const requestedThreadName = params.requestedThreadName?.trim();
622
+ if (!requestedThreadName) return {
623
+ placement: "top-level",
624
+ name
625
+ };
626
+ return {
627
+ placement: "thread",
628
+ name,
629
+ requestedThreadName,
630
+ deliveredThreadName: params.deliveredThreadName?.trim() || requestedThreadName
631
+ };
632
+ }
635
633
  async function deliverGoogleChatReply(params) {
636
634
  const { payload, account, spaceId, runtime, core, config, statusSink } = params;
637
635
  let typingMessage = params.typingMessage;
638
636
  const replyThreadName = payload.replyToId?.trim() || void 0;
639
- const typingMessageThreadName = typingMessage?.thread?.trim() || void 0;
640
637
  const reply = resolveSendableOutboundReplyParts(payload);
641
- const text = reply.text;
642
- let firstTextChunk = true;
643
- if (typingMessage && typingMessageThreadName !== replyThreadName) {
638
+ let deliveryThreadName = replyThreadName;
639
+ const acceptedText = [];
640
+ const runTextOperation = async (operation) => await operation.catch((error) => {
641
+ if (acceptedText.length === 0) throw error;
642
+ throw createChannelPartialDeliveryError(error, {
643
+ messageIds: acceptedText.flatMap(({ id }) => id ? [id] : []),
644
+ content: acceptedText.map(({ text }) => text).join("\n"),
645
+ visibleReplySent: true
646
+ });
647
+ });
648
+ const typingMatchesReply = typingMessage?.placement === "thread" ? typingMessage.requestedThreadName === replyThreadName : typingMessage?.placement === "top-level" ? replyThreadName === void 0 : false;
649
+ if (typingMessage && !typingMatchesReply) {
644
650
  try {
645
651
  await deleteGoogleChatMessage({
646
652
  account,
@@ -650,7 +656,7 @@ async function deliverGoogleChatReply(params) {
650
656
  runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
651
657
  }
652
658
  typingMessage = void 0;
653
- }
659
+ } else if (typingMessage?.placement === "thread") deliveryThreadName = typingMessage.deliveredThreadName;
654
660
  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
661
  if (reply.hasMedia && !reply.hasText) {
656
662
  try {
@@ -661,7 +667,10 @@ async function deliverGoogleChatReply(params) {
661
667
  } catch (err) {
662
668
  runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
663
669
  }
664
- throw new Error("Google Chat outbound attachments require user OAuth and no text fallback is available.");
670
+ throw new PlatformMessageNotDispatchedError("Google Chat outbound attachments require user OAuth and no text fallback is available.", {
671
+ cause: void 0,
672
+ retryable: false
673
+ });
665
674
  }
666
675
  const chunkLimit = account.config.textChunkLimit ?? 4e3;
667
676
  const chunkMode = core.channel.text.resolveChunkMode(config, "googlechat", account.accountId);
@@ -673,35 +682,42 @@ async function deliverGoogleChatReply(params) {
673
682
  }
674
683
  };
675
684
  const sendTextMessage = async (chunk) => {
676
- await sendGoogleChatMessage({
685
+ const sent = await runTextOperation(sendGoogleChatMessage({
677
686
  account,
678
687
  space: spaceId,
679
688
  text: chunk,
680
- thread: replyThreadName
689
+ thread: deliveryThreadName
690
+ }));
691
+ if (sent) acceptedText.push({
692
+ id: sent.messageName?.trim() || void 0,
693
+ text: chunk
681
694
  });
695
+ if (replyThreadName) deliveryThreadName = sent?.threadName?.trim() || deliveryThreadName;
682
696
  };
683
- const chunks = core.channel.text.chunkMarkdownTextWithMode(text, chunkLimit, chunkMode);
697
+ const chunks = core.channel.text.chunkMarkdownTextWithMode(reply.text, chunkLimit, chunkMode);
684
698
  for (const chunk of chunks) {
685
699
  if (!chunk) continue;
686
- if (firstTextChunk && typingMessage) {
700
+ if (typingMessage) {
687
701
  try {
688
- await updateGoogleChatMessage({
702
+ const updated = await updateGoogleChatMessage({
689
703
  account,
690
704
  messageName: typingMessage.name,
691
705
  text: chunk
692
706
  });
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;
707
+ acceptedText.push({
708
+ id: updated.messageName?.trim() || typingMessage.name,
709
+ text: chunk
710
+ });
711
+ } catch (error) {
712
+ if (!(error instanceof GoogleChatApiError) || error.status !== 404) throw error;
713
+ runtime.error?.(`Google Chat typing update failed: ${String(error)}`);
714
+ await sendTextMessage(chunk);
701
715
  }
716
+ typingMessage = void 0;
717
+ recordOutboundStatus();
718
+ continue;
702
719
  }
703
720
  await sendTextMessage(chunk);
704
- firstTextChunk = false;
705
721
  recordOutboundStatus();
706
722
  }
707
723
  }
@@ -781,7 +797,7 @@ function warnAppPrincipalMisconfiguration(params) {
781
797
  }
782
798
  function createGoogleChatWebhookRequestHandler(params) {
783
799
  return async (req, res) => {
784
- const path = normalizeWebhookPath(new URL(req.url ?? "/", "http://localhost").pathname);
800
+ const path = canonicalizeWebhookRouteKey(new URL(req.url ?? "/", "http://localhost").pathname);
785
801
  const config = params.webhookTargets.get(path)?.[0]?.config;
786
802
  const clientIp = resolveRequestClientIp(req, config?.gateway?.trustedProxies, config?.gateway?.allowRealIpFallback === true) ?? "unknown";
787
803
  return await withResolvedWebhookRequestPipeline({
@@ -913,6 +929,7 @@ function registerGoogleChatWebhookTarget(target) {
913
929
  source: "googlechat-webhook",
914
930
  accountId: target.account.accountId,
915
931
  log: target.runtime.log,
932
+ throwOnFailure: true,
916
933
  handler: async (req, res) => {
917
934
  if (!await handleGoogleChatWebhookRequest(req, res) && !res.headersSent) {
918
935
  res.statusCode = 404;
@@ -937,11 +954,6 @@ function normalizeAudienceType(value) {
937
954
  if (normalized === "app-url" || normalized === "app_url" || normalized === "app") return "app-url";
938
955
  if (normalized === "project-number" || normalized === "project_number" || normalized === "project") return "project-number";
939
956
  }
940
- function resolveGoogleChatTimestampMs(eventTime) {
941
- if (!eventTime) return;
942
- const parsed = Date.parse(eventTime);
943
- return Number.isFinite(parsed) ? parsed : void 0;
944
- }
945
957
  function resolveGoogleChatBotLoopProtection(params) {
946
958
  if (!params.allowBots || !params.isBotSender || !params.senderId || params.senderId === params.appUserId) return;
947
959
  return {
@@ -952,7 +964,7 @@ function resolveGoogleChatBotLoopProtection(params) {
952
964
  config: params.config,
953
965
  defaultsConfig: params.defaultsConfig,
954
966
  defaultEnabled: true,
955
- nowMs: resolveGoogleChatTimestampMs(params.eventTime)
967
+ nowMs: parseDateStringTimestampMs(params.eventTime)
956
968
  };
957
969
  }
958
970
  function resolveGoogleChatBotLoopProtectionConfig(params) {
@@ -995,7 +1007,7 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle) {
995
1007
  function resolveBotDisplayName(params) {
996
1008
  const { accountName, agentId, config } = params;
997
1009
  if (accountName?.trim()) return accountName.trim();
998
- const agent = config.agents?.list?.find((a) => a.id === agentId);
1010
+ const agent = resolveAgentConfig(config, agentId);
999
1011
  if (agent?.name?.trim()) return agent.name.trim();
1000
1012
  return "OpenClaw";
1001
1013
  }
@@ -1026,8 +1038,17 @@ async function processMessageWithPipeline(params) {
1026
1038
  }
1027
1039
  const messageText = (message.argumentText ?? message.text ?? "").trim();
1028
1040
  const attachments = message.attachment ?? [];
1029
- const rawBody = messageText;
1041
+ let rawBody = messageText;
1030
1042
  if (!rawBody && attachments.length === 0) return;
1043
+ const { route, buildEnvelope } = resolveChannelInboundRouteEnvelope({
1044
+ cfg: config,
1045
+ channel: "googlechat",
1046
+ accountId: account.accountId,
1047
+ peer: {
1048
+ kind: isGroup ? "group" : "direct",
1049
+ id: spaceId
1050
+ }
1051
+ });
1031
1052
  const access = await applyGoogleChatInboundAccessPolicy({
1032
1053
  account,
1033
1054
  config,
@@ -1039,6 +1060,12 @@ async function processMessageWithPipeline(params) {
1039
1060
  senderName,
1040
1061
  senderEmail,
1041
1062
  rawBody,
1063
+ contextBinding: {
1064
+ agentId: route.agentId,
1065
+ sessionKey: route.sessionKey,
1066
+ ...message.name ? { messageId: message.name } : {},
1067
+ inboundEventKind: "user_request"
1068
+ },
1042
1069
  statusSink,
1043
1070
  logVerbose: (messageLocal) => logVerbose(core, runtime, messageLocal)
1044
1071
  });
@@ -1062,28 +1089,27 @@ async function processMessageWithPipeline(params) {
1062
1089
  core,
1063
1090
  runtime
1064
1091
  })) 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
1092
  const mediaInputs = attachments.map((attachment) => ({ contentType: attachment.contentType }));
1075
1093
  const first = attachments.at(0);
1076
- if (first) {
1094
+ if (first) try {
1077
1095
  const attachmentData = await downloadAttachment(first, account, mediaMaxMb, core);
1078
1096
  if (attachmentData) mediaInputs[0] = {
1079
1097
  path: attachmentData.path,
1080
1098
  url: attachmentData.path,
1081
1099
  contentType: attachmentData.contentType ?? first.contentType
1082
1100
  };
1101
+ } catch (error) {
1102
+ if (!(error instanceof MediaFetchError) || error.code !== "max_bytes") throw error;
1103
+ const notice = `[Google Chat attachment too large; maximum ${mediaMaxMb} MB]`;
1104
+ rawBody = formatInboundMediaUnavailableText({
1105
+ body: rawBody,
1106
+ notice
1107
+ });
1108
+ runtime.error?.(`[${account.accountId}] ${notice} Increase channels.googlechat.mediaMaxMb to process larger attachments.`);
1083
1109
  }
1084
- const media = await toInboundMediaFactsWithMetadata(mediaInputs);
1110
+ const media = mediaInputs.length === 0 ? [] : await toInboundMediaFactsWithMetadata(mediaInputs);
1085
1111
  const fromLabel = isGroup ? space.displayName || `space:${spaceId}` : senderName || `user:${senderId}`;
1086
- const timestampMs = resolveGoogleChatTimestampMs(event.eventTime);
1112
+ const timestampMs = parseDateStringTimestampMs(event.eventTime);
1087
1113
  const body = buildEnvelope({
1088
1114
  channel: "Google Chat",
1089
1115
  from: fromLabel,
@@ -1092,6 +1118,7 @@ async function processMessageWithPipeline(params) {
1092
1118
  });
1093
1119
  const replyThreadName = isGroup ? message.thread?.name : void 0;
1094
1120
  const ctxPayload = core.channel.inbound.buildContext({
1121
+ channelIngress: access.channelIngress,
1095
1122
  channel: "googlechat",
1096
1123
  accountId: route.accountId,
1097
1124
  messageId: message.name,
@@ -1155,10 +1182,11 @@ async function processMessageWithPipeline(params) {
1155
1182
  })} is typing..._`,
1156
1183
  thread: typingMessageThreadName
1157
1184
  });
1158
- if (result?.messageName) typingMessage = {
1159
- name: result.messageName,
1160
- thread: typingMessageThreadName
1161
- };
1185
+ if (result?.messageName) typingMessage = createGoogleChatTypingMessage({
1186
+ messageName: result.messageName,
1187
+ requestedThreadName: typingMessageThreadName,
1188
+ deliveredThreadName: result.threadName
1189
+ });
1162
1190
  } catch (err) {
1163
1191
  runtime.error?.(`Failed sending typing message: ${String(err)}`);
1164
1192
  }
@@ -1248,6 +1276,16 @@ async function monitorGoogleChatProvider(options) {
1248
1276
  }
1249
1277
  const audienceType = normalizeAudienceType(options.account.config.audienceType);
1250
1278
  const audience = options.account.config.audience?.trim();
1279
+ if (!audienceType || !audience) {
1280
+ const error = "Google Chat webhook authentication requires channels.googlechat.audienceType and channels.googlechat.audience.";
1281
+ options.runtime.error?.(`[${options.account.accountId}] ${error}`);
1282
+ options.statusSink?.(channelBlockedPatch(error, {
1283
+ running: true,
1284
+ connected: false,
1285
+ webhookPath: void 0
1286
+ }));
1287
+ return async () => {};
1288
+ }
1251
1289
  const mediaMaxMb = options.account.config.mediaMaxMb ?? 20;
1252
1290
  warnAppPrincipalMisconfiguration({
1253
1291
  accountId: options.account.accountId,
@@ -1279,6 +1317,7 @@ async function monitorGoogleChatProvider(options) {
1279
1317
  let unregisterTarget;
1280
1318
  try {
1281
1319
  unregisterTarget = registerGoogleChatWebhookTarget(target);
1320
+ options.statusSink?.(channelReadyPatch());
1282
1321
  } catch (error) {
1283
1322
  await ingress.stop();
1284
1323
  throw error;
@@ -1296,7 +1335,7 @@ function resolveGoogleChatWebhookPath(params) {
1296
1335
  webhookPath: params.account.config.webhookPath,
1297
1336
  webhookUrl: params.account.config.webhookUrl,
1298
1337
  defaultPath: "/googlechat"
1299
- }) ?? "/googlechat";
1338
+ });
1300
1339
  }
1301
1340
  //#endregion
1302
1341
  //#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-FZq5jdkN.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.3",
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.3"
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.3"
133
138
  },
134
139
  "build": {
135
- "openclawVersion": "2026.7.2-beta.7"
140
+ "openclawVersion": "2026.8.1-beta.3"
136
141
  },
137
142
  "release": {
138
143
  "publishToClawHub": true,