@openclaw/googlechat 2026.10.10 → 2026.11.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/.setup/{actions-uo0lf5AI.mjs → actions-DNDmJvwi.mjs} +15 -13
  2. package/dist/.setup/{approval-auth-CKF1wHai.mjs → approval-auth-AkJ2Rg0h.mjs} +2 -2
  3. package/dist/.setup/{approval-handler.runtime-wYtTR6as.mjs → approval-handler.runtime-CKuHeY6y.mjs} +3 -3
  4. package/dist/.setup/{channel-ZbGyNgH9.mjs → channel-WKI4stP3.mjs} +78 -87
  5. package/dist/.setup/{channel-base-BFV0cGQ2.mjs → channel-base-DjVHuLDF.mjs} +13 -14
  6. package/dist/.setup/{channel.adapters-5rr8crHQ.mjs → channel.adapters-C9mflxGl.mjs} +262 -316
  7. package/dist/.setup/{channel.runtime-DkrekcGA.mjs → channel.runtime-CBwK8353.mjs} +295 -335
  8. package/dist/.setup/setup-plugin-api-Bz3mVqQ5.mjs +2 -0
  9. package/dist/.source-module-urls/974ffefea973cf3ea18e1534d25b091bcf1b68760a2b9eda0cd9bd9392096c64.json +1 -1
  10. package/dist/api.js +2 -2
  11. package/dist/channel-plugin-api.js +1 -1
  12. package/dist/directory-contract-api.js +1 -1
  13. package/dist/setup-entry.js +1 -1
  14. package/dist/setup-plugin-api.js +1 -1
  15. package/node_modules/google-auth-library/build/src/auth/authclient.js.map +1 -0
  16. package/node_modules/google-auth-library/build/src/auth/awsclient.js.map +1 -0
  17. package/node_modules/google-auth-library/build/src/auth/awsrequestsigner.js.map +1 -0
  18. package/node_modules/google-auth-library/build/src/auth/baseexternalclient.js.map +1 -0
  19. package/node_modules/google-auth-library/build/src/auth/certificatesubjecttokensupplier.js.map +1 -0
  20. package/node_modules/google-auth-library/build/src/auth/computeclient.js.map +1 -0
  21. package/node_modules/google-auth-library/build/src/auth/credentials.js.map +1 -0
  22. package/node_modules/google-auth-library/build/src/auth/defaultawssecuritycredentialssupplier.js.map +1 -0
  23. package/node_modules/google-auth-library/build/src/auth/downscopedclient.js.map +1 -0
  24. package/node_modules/google-auth-library/build/src/auth/envDetect.js.map +1 -0
  25. package/node_modules/google-auth-library/build/src/auth/executable-response.js.map +1 -0
  26. package/node_modules/google-auth-library/build/src/auth/externalAccountAuthorizedUserClient.js.map +1 -0
  27. package/node_modules/google-auth-library/build/src/auth/externalclient.js.map +1 -0
  28. package/node_modules/google-auth-library/build/src/auth/filesubjecttokensupplier.js.map +1 -0
  29. package/node_modules/google-auth-library/build/src/auth/gdchclient.js.map +1 -0
  30. package/node_modules/google-auth-library/build/src/auth/googleauth.js.map +1 -0
  31. package/node_modules/google-auth-library/build/src/auth/iam.js.map +1 -0
  32. package/node_modules/google-auth-library/build/src/auth/identitypoolclient.js.map +1 -0
  33. package/node_modules/google-auth-library/build/src/auth/idtokenclient.js.map +1 -0
  34. package/node_modules/google-auth-library/build/src/auth/impersonated.js.map +1 -0
  35. package/node_modules/google-auth-library/build/src/auth/jwtaccess.js.map +1 -0
  36. package/node_modules/google-auth-library/build/src/auth/jwtclient.js.map +1 -0
  37. package/node_modules/google-auth-library/build/src/auth/loginticket.js.map +1 -0
  38. package/node_modules/google-auth-library/build/src/auth/oauth2client.js.map +1 -0
  39. package/node_modules/google-auth-library/build/src/auth/oauth2common.js.map +1 -0
  40. package/node_modules/google-auth-library/build/src/auth/passthrough.js.map +1 -0
  41. package/node_modules/google-auth-library/build/src/auth/pluggable-auth-client.js.map +1 -0
  42. package/node_modules/google-auth-library/build/src/auth/pluggable-auth-handler.js.map +1 -0
  43. package/node_modules/google-auth-library/build/src/auth/refreshclient.js.map +1 -0
  44. package/node_modules/google-auth-library/build/src/auth/stscredentials.js.map +1 -0
  45. package/node_modules/google-auth-library/build/src/auth/urlsubjecttokensupplier.js.map +1 -0
  46. package/node_modules/google-auth-library/build/src/crypto/browser/crypto.js.map +1 -0
  47. package/node_modules/google-auth-library/build/src/crypto/crypto.js.map +1 -0
  48. package/node_modules/google-auth-library/build/src/crypto/node/crypto.js.map +1 -0
  49. package/node_modules/google-auth-library/build/src/crypto/shared.js.map +1 -0
  50. package/node_modules/google-auth-library/build/src/gtoken/errorWithCode.js.map +1 -0
  51. package/node_modules/google-auth-library/build/src/gtoken/getCredentials.js.map +1 -0
  52. package/node_modules/google-auth-library/build/src/gtoken/getToken.js.map +1 -0
  53. package/node_modules/google-auth-library/build/src/gtoken/googleToken.js.map +1 -0
  54. package/node_modules/google-auth-library/build/src/gtoken/jwsSign.js.map +1 -0
  55. package/node_modules/google-auth-library/build/src/gtoken/revokeToken.js.map +1 -0
  56. package/node_modules/google-auth-library/build/src/gtoken/tokenHandler.js.map +1 -0
  57. package/node_modules/google-auth-library/build/src/gtoken/tokenOptions.js.map +1 -0
  58. package/node_modules/google-auth-library/build/src/index.js.map +1 -0
  59. package/node_modules/google-auth-library/build/src/shared.cjs.map +1 -0
  60. package/node_modules/google-auth-library/build/src/util.js.map +1 -0
  61. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/gaxios.js +166 -5
  62. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/gaxios.js.map +1 -1
  63. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/retry.js +12 -2
  64. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/retry.js.map +1 -1
  65. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/gaxios.js +167 -6
  66. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/gaxios.js.map +1 -1
  67. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/retry.js +12 -2
  68. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/retry.js.map +1 -1
  69. package/node_modules/google-auth-library/node_modules/gaxios/package.json +32 -25
  70. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js +14 -1
  71. package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js.map +1 -1
  72. package/node_modules/google-auth-library/node_modules/gcp-metadata/package.json +19 -20
  73. package/node_modules/google-auth-library/node_modules/google-logging-utils/package.json +2 -2
  74. package/node_modules/google-auth-library/package.json +7 -9
  75. package/node_modules/zod/package.json +1 -1
  76. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  77. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  78. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  79. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  80. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  81. package/node_modules/zod/src/v4/core/util.ts +13 -0
  82. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  83. package/node_modules/zod/v4/core/compile.cjs +8 -0
  84. package/node_modules/zod/v4/core/compile.js +8 -0
  85. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  86. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  87. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  88. package/node_modules/zod/v4/core/schemas.js +30 -0
  89. package/node_modules/zod/v4/core/util.cjs +15 -0
  90. package/node_modules/zod/v4/core/util.d.cts +2 -0
  91. package/node_modules/zod/v4/core/util.d.ts +2 -0
  92. package/node_modules/zod/v4/core/util.js +14 -0
  93. package/node_modules/zod/v4/core/versions.cjs +1 -1
  94. package/node_modules/zod/v4/core/versions.js +1 -1
  95. package/openclaw.plugin.json +0 -30
  96. package/package.json +6 -6
  97. package/dist/.setup/setup-plugin-api-Dru1eW9z.mjs +0 -2
  98. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.d.ts +0 -1
  99. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.js +0 -109
  100. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.js.map +0 -1
  101. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.d.ts +0 -1
  102. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.js +0 -81
  103. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.js.map +0 -1
  104. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.d.ts +0 -1
  105. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.js +0 -128
  106. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.js.map +0 -1
  107. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.d.ts +0 -1
  108. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.js +0 -1510
  109. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.js.map +0 -1
  110. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.d.ts +0 -1
  111. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.js +0 -61
  112. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.js.map +0 -1
  113. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.d.ts +0 -1
  114. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.js +0 -367
  115. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.js.map +0 -1
  116. package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  117. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.d.ts +0 -1
  118. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.js +0 -71
  119. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.js.map +0 -1
  120. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.d.ts +0 -1
  121. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.js +0 -76
  122. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.js.map +0 -1
  123. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.d.ts +0 -1
  124. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.js +0 -123
  125. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.js.map +0 -1
  126. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.d.ts +0 -1
  127. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.js +0 -1472
  128. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.js.map +0 -1
  129. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.d.ts +0 -1
  130. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.js +0 -23
  131. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.js.map +0 -1
  132. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.d.ts +0 -1
  133. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.js +0 -362
  134. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.js.map +0 -1
  135. package/node_modules/google-auth-library/node_modules/gaxios/build/esm/tsconfig.tsbuildinfo +0 -1
@@ -1,5 +1,6 @@
1
- import { l as resolveGoogleChatAccount, n as formatGoogleChatAllowFromEntry, u as MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES } from "./channel-base-BFV0cGQ2.mjs";
1
+ import { l as resolveGoogleChatAccount, n as formatGoogleChatAllowFromEntry, u as MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES } from "./channel-base-DjVHuLDF.mjs";
2
2
  import { buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/channel-core";
3
+ import { createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
3
4
  import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
4
5
  import { asNullableObjectRecord, isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
6
  import { resolveUserPath } from "openclaw/plugin-sdk/text-utility-runtime";
@@ -16,10 +17,10 @@ import { readFileHandleBounded } from "openclaw/plugin-sdk/file-access-runtime";
16
17
  import { adaptScopedAccountAccessor } from "openclaw/plugin-sdk/channel-config-helpers";
17
18
  import { missingTargetError } from "openclaw/plugin-sdk/channel-feedback";
18
19
  import { defineStableChannelIngressIdentity, identityEntryAuthenticationClassifier } from "openclaw/plugin-sdk/channel-ingress-runtime";
19
- import { createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
20
20
  import { buildChannelGroupsScopeTree, createAllowlistProviderOpenWarningCollector, createConditionalWarningCollector, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
21
21
  import { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
22
22
  import { createChannelDirectoryAdapter, listResolvedDirectoryGroupEntriesFromMapKeys, listResolvedDirectoryUserEntriesFromAllowFrom } from "openclaw/plugin-sdk/directory-runtime";
23
+ import { formatTextWithAttachmentLinks, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
23
24
  import { FormatCapabilityProfile, markdownToIR, renderMarkdownIRChunksWithinLimit, renderMarkdownWithMarkers, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
24
25
  // extensions/googlechat/src/approval-card-actions.ts
25
26
  const GOOGLECHAT_APPROVAL_ACTION = "openclaw.approval";
@@ -42,14 +43,10 @@ function buildGoogleChatApprovalActionParameters(token) {
42
43
  value: token
43
44
  }];
44
45
  }
45
- function collectEventParameters(event) {
46
+ function readGoogleChatApprovalActionToken(event) {
46
47
  const params = {};
47
48
  for (const source of [event.common?.parameters, event.commonEventObject?.parameters]) for (const [key, value] of Object.entries(source ?? {})) if (typeof value === "string") params[key] = value;
48
49
  for (const item of event.action?.parameters ?? []) if (typeof item.key === "string" && typeof item.value === "string") params[item.key] = item.value;
49
- return params;
50
- }
51
- function readGoogleChatApprovalActionToken(event) {
52
- const params = collectEventParameters(event);
53
50
  if (params[GOOGLECHAT_APPROVAL_ACTION_PARAM] !== GOOGLECHAT_APPROVAL_ACTION_VALUE) return null;
54
51
  const actionName = normalizeOptionalString(event.action?.actionMethodName) ?? normalizeOptionalString(event.common?.invokedFunction) ?? normalizeOptionalString(event.commonEventObject?.invokedFunction);
55
52
  if (actionName && actionName !== "openclaw.approval" && !actionName.startsWith("https://")) return null;
@@ -111,10 +108,10 @@ function shouldSuppressGoogleChatManualExecApprovalFollowupText(text, nowMs = Da
111
108
  function hasStructuredPayloadPart(payload) {
112
109
  return Boolean(payload.mediaUrl?.trim() || payload.mediaUrls?.some((url) => url.trim()) || payload.presentation || payload.interactive || payload.btw || payload.spokenText || payload.ttsSupplement);
113
110
  }
114
- function shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload, nowMs = Date.now()) {
111
+ function shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload) {
115
112
  const text = payload.text?.trim();
116
113
  if (!text || hasStructuredPayloadPart(payload)) return false;
117
- return shouldSuppressGoogleChatManualExecApprovalFollowupText(text, nowMs);
114
+ return shouldSuppressGoogleChatManualExecApprovalFollowupText(text);
118
115
  }
119
116
  // extensions/googlechat/src/google-auth.runtime.ts
120
117
  const GOOGLE_AUTH_POLICY = buildHostnameAllowlistPolicyFromSuffixAllowlist(["accounts.google.com", "googleapis.com"]);
@@ -126,10 +123,6 @@ const GOOGLE_AUTH_UNIVERSE_DOMAIN = "googleapis.com";
126
123
  const GOOGLE_CLIENT_CERTS_URL_PREFIX = "https://www.googleapis.com/robot/v1/metadata/x509/";
127
124
  const MAX_GOOGLE_AUTH_RESPONSE_BYTES = 1048576;
128
125
  let googleAuthRuntimePromise = null;
129
- function normalizeGoogleAuthHeaders(value) {
130
- if (!(value.headers instanceof Headers)) value.headers = new Headers(value.headers);
131
- return value;
132
- }
133
126
  function hasProxyAgentShape(value) {
134
127
  const record = asNullableObjectRecord(value);
135
128
  return record !== null && record.proxy instanceof URL;
@@ -138,19 +131,15 @@ function hasTlsAgentShape(value) {
138
131
  const record = asNullableObjectRecord(value);
139
132
  return record !== null && asNullableObjectRecord(record.options) !== null;
140
133
  }
141
- function resolveGoogleAuthAgent(init, url) {
142
- return typeof init.agent === "function" ? init.agent(url) : init.agent;
143
- }
144
134
  function hasTlsOptions(options) {
145
135
  return options.cert !== void 0 || options.key !== void 0;
146
136
  }
147
- function resolveGoogleAuthTlsOptions(init, url) {
137
+ function resolveGoogleAuthTlsOptions(init, agent) {
148
138
  const explicit = {
149
139
  cert: init.cert,
150
140
  key: init.key
151
141
  };
152
142
  if (hasTlsOptions(explicit)) return explicit;
153
- const agent = resolveGoogleAuthAgent(init, url);
154
143
  if (hasProxyAgentShape(agent)) return {
155
144
  cert: agent.connectOpts?.cert,
156
145
  key: agent.connectOpts?.key
@@ -161,40 +150,6 @@ function resolveGoogleAuthTlsOptions(init, url) {
161
150
  };
162
151
  return {};
163
152
  }
164
- function resolveGoogleAuthEnvProxyUrl(protocol) {
165
- const httpProxy = normalizeOptionalString(process.env.HTTP_PROXY) ?? normalizeOptionalString(process.env.http_proxy);
166
- const httpsProxy = normalizeOptionalString(process.env.HTTPS_PROXY) ?? normalizeOptionalString(process.env.https_proxy);
167
- if (protocol === "https") return httpsProxy ?? httpProxy ?? void 0;
168
- return httpProxy ?? void 0;
169
- }
170
- function collectGoogleAuthNoProxyRules(noProxy = []) {
171
- const rules = [...noProxy];
172
- const envRules = (process.env.NO_PROXY ?? process.env.no_proxy)?.split(",") ?? [];
173
- for (const rule of envRules) {
174
- const trimmed = rule.trim();
175
- if (trimmed.length > 0) rules.push(trimmed);
176
- }
177
- return rules;
178
- }
179
- function shouldBypassGoogleAuthProxy(url, noProxy = []) {
180
- for (const rule of collectGoogleAuthNoProxyRules(noProxy)) {
181
- if (rule instanceof RegExp) {
182
- if (rule.test(url.toString())) return true;
183
- continue;
184
- }
185
- if (rule instanceof URL) {
186
- if (rule.origin === url.origin) return true;
187
- continue;
188
- }
189
- if (rule.startsWith("*.") || rule.startsWith(".")) {
190
- const cleanedRule = rule.replace(/^\*\./, ".");
191
- if (url.hostname.endsWith(cleanedRule)) return true;
192
- continue;
193
- }
194
- if (rule === url.origin || rule === url.hostname || rule === url.href) return true;
195
- }
196
- return false;
197
- }
198
153
  function readOptionalTrimmedString(record, fieldName) {
199
154
  const value = record[fieldName];
200
155
  if (value === void 0 || value === null) return;
@@ -278,30 +233,24 @@ function resolveGoogleAuthDispatcherPolicy(input, init) {
278
233
  const requestUrl = input instanceof Request ? new URL(input.url) : new URL(typeof input === "string" ? input : input.toString());
279
234
  const nextInit = sanitizeGoogleAuthInit(init);
280
235
  const googleAuthInit = init ?? {};
281
- const tlsOptions = resolveGoogleAuthTlsOptions(googleAuthInit, requestUrl);
282
- const proxyBypassed = shouldBypassGoogleAuthProxy(requestUrl, Array.isArray(googleAuthInit.noProxy) ? googleAuthInit.noProxy : []);
283
- const agent = resolveGoogleAuthAgent(googleAuthInit, requestUrl);
284
- const explicitProxy = (googleAuthInit.proxy instanceof URL ? googleAuthInit.proxy.toString() : normalizeOptionalString(googleAuthInit.proxy)) ?? (hasProxyAgentShape(agent) ? agent.proxy.toString() : void 0);
285
- const proxyUrl = proxyBypassed ? void 0 : explicitProxy ?? resolveGoogleAuthEnvProxyUrl(requestUrl.protocol === "http:" ? "http" : "https");
286
- if (proxyUrl) return {
236
+ const agent = typeof googleAuthInit.agent === "function" ? googleAuthInit.agent(requestUrl) : googleAuthInit.agent;
237
+ const tlsOptions = resolveGoogleAuthTlsOptions(googleAuthInit, agent);
238
+ if (hasProxyAgentShape(agent)) return {
287
239
  dispatcherPolicy: {
288
- ...explicitProxy ? {
289
- allowPrivateProxy: true,
290
- mode: "explicit-proxy",
291
- proxyUrl
292
- } : { mode: "env-proxy" },
293
- ...hasTlsOptions(tlsOptions) ? { proxyTls: { ...tlsOptions } } : {}
240
+ allowPrivateProxy: true,
241
+ mode: "explicit-proxy",
242
+ proxyUrl: agent.proxy.toString(),
243
+ ...hasTlsOptions(tlsOptions) ? { proxyTls: tlsOptions } : {}
294
244
  },
295
245
  init: nextInit
296
246
  };
297
- if (hasTlsOptions(tlsOptions)) return {
247
+ return {
298
248
  dispatcherPolicy: {
299
- connect: { ...tlsOptions },
300
- mode: "direct"
249
+ mode: "direct",
250
+ ...hasTlsOptions(tlsOptions) ? { connect: tlsOptions } : {}
301
251
  },
302
252
  init: nextInit
303
253
  };
304
- return { init: nextInit };
305
254
  }
306
255
  async function googleAuthFetch(input, init) {
307
256
  const url = input instanceof Request ? input.url : String(input);
@@ -346,10 +295,7 @@ async function loadGoogleAuthRuntime() {
346
295
  }
347
296
  async function getGoogleAuthTransport() {
348
297
  const { gaxios } = await loadGoogleAuthRuntime();
349
- const transport = new gaxios.Gaxios({ fetchImplementation: googleAuthFetch });
350
- transport.interceptors.request.add({ resolved: async (config) => normalizeGoogleAuthHeaders(config) });
351
- transport.interceptors.response.add({ resolved: async (response) => normalizeGoogleAuthHeaders(response) });
352
- return transport;
298
+ return new gaxios.Gaxios({ fetchImplementation: googleAuthFetch });
353
299
  }
354
300
  async function resolveValidatedGoogleChatCredentials(account) {
355
301
  if (account.credentials) return validateGoogleChatServiceAccountCredentials(account.credentials);
@@ -492,7 +438,6 @@ const GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS = 9e5;
492
438
  const GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS = 3e4;
493
439
  const GOOGLECHAT_JSON_RESPONSE_MAX_BYTES = 16777216;
494
440
  const GOOGLECHAT_ERROR_BODY_MAX_BYTES = 16384;
495
- const GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES = 20971520;
496
441
  var GoogleChatApiError = class extends Error {
497
442
  constructor(status, message) {
498
443
  super(message);
@@ -501,7 +446,6 @@ var GoogleChatApiError = class extends Error {
501
446
  }
502
447
  };
503
448
  function resolveGoogleChatMediaTimeoutMs(maxBytes) {
504
- if (!maxBytes) return GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS;
505
449
  const transferMs = Math.ceil(maxBytes / GOOGLECHAT_MEDIA_MIN_BYTES_PER_SECOND * 1e3);
506
450
  return Math.min(GOOGLECHAT_MEDIA_TIMEOUT_GRACE_MS + transferMs, GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS);
507
451
  }
@@ -564,14 +508,13 @@ async function fetchJson(account, url, init, hooks) {
564
508
  });
565
509
  }
566
510
  async function downloadGoogleChatMedia(params) {
567
- const { account, resourceName, maxBytes: requestedMaxBytes } = params;
511
+ const { account, resourceName, maxBytes } = params;
568
512
  return await withGoogleChatResponse({
569
513
  account,
570
514
  url: `${CHAT_API_BASE}/media/${resourceName}?alt=media`,
571
515
  auditContext: "googlechat.api.buffer",
572
- timeoutMs: resolveGoogleChatMediaTimeoutMs(requestedMaxBytes),
516
+ timeoutMs: resolveGoogleChatMediaTimeoutMs(maxBytes),
573
517
  handleResponse: async (res) => {
574
- const maxBytes = requestedMaxBytes ?? GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES;
575
518
  const lengthHeader = res.headers.get("content-length");
576
519
  if (lengthHeader) {
577
520
  const length = parseMediaContentLength(lengthHeader);
@@ -641,7 +584,7 @@ async function findGoogleChatDirectMessage(params) {
641
584
  return await fetchJson(account, url.toString(), { method: "GET" }, { assertDirectAdapterHandoff: params.assertDirectAdapterHandoff });
642
585
  }
643
586
  async function getGoogleChatSpace(params) {
644
- return await fetchJson(params.account, `${CHAT_API_BASE}/${params.spaceName}`, { method: "GET" });
587
+ return await fetchJson(params.account, `${CHAT_API_BASE}/${params.spaceName}`, { method: "GET" }, { assertDirectAdapterHandoff: params.assertDirectAdapterHandoff });
645
588
  }
646
589
  async function probeGoogleChat(account) {
647
590
  try {
@@ -718,7 +661,8 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
718
661
  });
719
662
  const resolvedSpace = await resolveGoogleChatOutboundSpaceDetails({
720
663
  account,
721
- target: params.target
664
+ target: params.target,
665
+ assertDirectAdapterHandoff: params.assertDirectAdapterHandoff
722
666
  });
723
667
  const spaceName = resolvedSpace.name;
724
668
  if (!isGoogleChatSpaceTarget(spaceName)) return null;
@@ -726,7 +670,8 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
726
670
  if (!chatType) try {
727
671
  chatType = resolveGoogleChatSpaceChatType(await getGoogleChatSpace({
728
672
  account,
729
- spaceName
673
+ spaceName,
674
+ assertDirectAdapterHandoff: params.assertDirectAdapterHandoff
730
675
  }));
731
676
  } catch {
732
677
  return null;
@@ -777,243 +722,238 @@ const GOOGLE_CHAT_LITERAL_FALLBACKS = /* @__PURE__ */ new Map([
777
722
  ["-", "-"],
778
723
  ["|", "|"]
779
724
  ]);
780
- function createGoogleChatMarkers(text) {
781
- const used = /* @__PURE__ */ new Set();
782
- let candidate = 0;
783
- const rangeSize = 6400;
784
- const nextMarker = () => {
785
- while (true) {
786
- const marker = String.fromCharCode(57344 + Math.floor(candidate / rangeSize), 57344 + candidate % rangeSize);
787
- candidate += 1;
788
- if (!used.has(marker) && !text.includes(marker)) {
789
- used.add(marker);
790
- return marker;
791
- }
792
- }
793
- };
794
- return {
795
- list: nextMarker(),
796
- blockquoteOpen: nextMarker(),
797
- blockquoteClose: nextMarker()
798
- };
799
- }
800
725
  /** Removes unsafe HTML and internal scaffolding while retaining source Markdown for chunking. */
801
726
  function sanitizeGoogleChatText(text) {
802
727
  return sanitizeForPlainText(sanitizeAssistantVisibleText(text), { style: "markdown" });
803
728
  }
804
- function projectDecodedGoogleChatResources(ir) {
805
- const text = ir.text.replace(/<(?:users|customEmojis)\/[^<>\s]+>/giu, (match) => `<${match.slice(1, -1)}>`);
806
- return text === ir.text ? ir : {
807
- ...ir,
808
- text
809
- };
729
+ function formatGoogleChatMediaText(text, mediaUrls) {
730
+ const remoteUrls = mediaUrls.filter((value) => {
731
+ if (value.split("").some((character) => character <= " " || character === "") || !/^https?:\/\//iu.test(value)) return false;
732
+ try {
733
+ return Boolean(new URL(value).hostname);
734
+ } catch {
735
+ return false;
736
+ }
737
+ });
738
+ if (remoteUrls.length !== mediaUrls.length) throw new Error("Google Chat outbound attachments require remote HTTP(S) URLs.");
739
+ return [text, formatTextWithAttachmentLinks(void 0, remoteUrls)].filter(Boolean).join("\n\n");
810
740
  }
811
- function projectGoogleChatLinkLabels(ir) {
812
- const characters = ir.links.length > 0 ? ir.text.split("") : [];
813
- let changed = false;
814
- for (const link of ir.links) {
815
- const label = ir.text.slice(link.start, link.end);
816
- const comparableHref = link.href.startsWith("mailto:") ? link.href.slice(7) : link.href;
817
- if (label === link.href || label === comparableHref) continue;
818
- for (let index = link.start; index < link.end; index += 1) {
819
- const character = characters[index] ?? "";
820
- const fallback = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character);
821
- if (fallback && /[<>|*_~`]/u.test(character)) {
822
- characters[index] = fallback;
823
- changed = true;
741
+ /** Renders CommonMark into byte-bounded Google Chat app-message chunks. */
742
+ function formatGoogleChatTextChunks(text, limit = GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit) {
743
+ const sanitized = sanitizeGoogleChatText(text);
744
+ let ir = markdownToIR(sanitized, {
745
+ enableSpoilers: true,
746
+ enableTaskLists: true,
747
+ headingStyle: "rich",
748
+ tableMode: "bullets"
749
+ });
750
+ {
751
+ let codeText = ir.text;
752
+ const styles = ir.styles.filter((span) => {
753
+ const content = ir.text.slice(span.start, span.end);
754
+ const unsafe = span.style === "code" && content.includes("`") || span.style === "code_block" && content.includes("```");
755
+ if (unsafe) {
756
+ const replacement = content.split("").map((character) => GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character).join("");
757
+ codeText = `${codeText.slice(0, span.start)}${replacement}${codeText.slice(span.end)}`;
824
758
  }
825
- }
759
+ return !unsafe;
760
+ });
761
+ ir = styles.length === ir.styles.length ? ir : {
762
+ ...ir,
763
+ styles,
764
+ text: codeText
765
+ };
826
766
  }
827
- return changed ? {
828
- ...ir,
829
- text: characters.join("")
830
- } : ir;
831
- }
832
- function markGoogleChatBulletLists(ir, markerToken) {
833
- let characters;
834
- for (const item of ir.listItems ?? []) {
835
- const marker = item.listMarker;
836
- if (item.kind !== "bullet" || !marker || marker.end !== marker.start + 2 || ir.text[marker.start] !== "•" || ir.text[marker.start + 1] !== " ") continue;
837
- characters ??= ir.text.split("");
838
- characters[marker.start] = markerToken[0] ?? "";
839
- characters[marker.start + 1] = markerToken[1] ?? "";
767
+ {
768
+ const decodedText = ir.text.replace(/<(?:users|customEmojis)\/[^<>\s]+>/giu, (match) => `<${match.slice(1, -1)}>`);
769
+ ir = decodedText === ir.text ? ir : {
770
+ ...ir,
771
+ text: decodedText
772
+ };
840
773
  }
841
- return characters ? {
842
- ...ir,
843
- text: characters.join("")
844
- } : ir;
845
- }
846
- function projectUnsafeCodeFallbacks(ir) {
847
- let text = ir.text;
848
- const styles = ir.styles.filter((span) => {
849
- const content = ir.text.slice(span.start, span.end);
850
- const unsafe = span.style === "code" && content.includes("`") || span.style === "code_block" && content.includes("```");
851
- if (unsafe) {
852
- const replacement = content.split("").map((character) => GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character).join("");
853
- text = `${text.slice(0, span.start)}${replacement}${text.slice(span.end)}`;
854
- }
855
- return !unsafe;
856
- });
857
- return styles.length === ir.styles.length ? ir : {
858
- ...ir,
859
- styles,
860
- text
861
- };
862
- }
863
- function projectGoogleChatPlainLiterals(ir) {
864
- const codeRanges = ir.styles.filter((span) => span.style === "code" || span.style === "code_block");
865
- const inCode = (index) => codeRanges.some((span) => index >= span.start && index < span.end);
866
- const inLink = (index) => ir.links.some((span) => index >= span.start && index < span.end);
867
- const styleDelimiter = /* @__PURE__ */ new Map([
868
- ["~", "strikethrough"],
869
- ["_", "italic"],
870
- ["*", "bold"],
871
- ["`", "code"]
872
- ]);
873
- const characters = ir.text.split("");
874
- let lineStart = 0;
875
- while (lineStart < characters.length) {
876
- const nextNewline = characters.indexOf("\n", lineStart);
877
- const lineEnd = nextNewline < 0 ? characters.length : nextNewline;
878
- for (const delimiter of [
879
- "~",
880
- "_",
881
- "*",
882
- "`"
883
- ]) {
884
- const indexes = [];
885
- for (let index = lineStart; index < lineEnd; index += 1) if (characters[index] === delimiter && !inCode(index) && !inLink(index)) indexes.push(index);
886
- if (indexes.length === 0) continue;
887
- const renderedStyle = styleDelimiter.get(delimiter);
888
- const lineAddsDelimiter = ir.styles.some((span) => span.style === renderedStyle && span.start < lineEnd && span.end > lineStart);
889
- if (indexes.length >= 2 || lineAddsDelimiter) for (const index of indexes) characters[index] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(delimiter) ?? delimiter;
890
- }
891
- let firstTextIndex = lineStart;
892
- while (firstTextIndex < lineEnd && characters[firstTextIndex] === " ") firstTextIndex += 1;
893
- if (!inCode(firstTextIndex)) {
894
- const character = characters[firstTextIndex];
895
- if ((character === "*" || character === "-") && characters[firstTextIndex + 1] === " " || character === ">") characters[firstTextIndex] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character;
896
- }
897
- const line = characters.slice(lineStart, lineEnd).join("");
898
- for (const match of line.matchAll(/<[^<>\n]*\|[^<>\n]*>/gu)) {
899
- const open = lineStart + (match.index ?? 0);
900
- const close = open + match[0].length - 1;
901
- if (!inCode(open) && !inCode(close) && !inLink(open) && !inLink(close)) {
902
- characters[open] = "<";
903
- characters[close] = ">";
774
+ {
775
+ const characters = ir.links.length > 0 ? ir.text.split("") : [];
776
+ let changed = false;
777
+ for (const link of ir.links) {
778
+ const label = ir.text.slice(link.start, link.end);
779
+ const comparableHref = link.href.startsWith("mailto:") ? link.href.slice(7) : link.href;
780
+ if (label === link.href || label === comparableHref) continue;
781
+ for (let index = link.start; index < link.end; index += 1) {
782
+ const character = characters[index] ?? "";
783
+ const fallback = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character);
784
+ if (fallback && /[<>|*_~`]/u.test(character)) {
785
+ characters[index] = fallback;
786
+ changed = true;
787
+ }
904
788
  }
905
789
  }
906
- lineStart = lineEnd + 1;
790
+ ir = changed ? {
791
+ ...ir,
792
+ text: characters.join("")
793
+ } : ir;
907
794
  }
908
- const text = characters.join("");
909
- return text === ir.text ? ir : {
910
- ...ir,
911
- text
912
- };
913
- }
914
- function emitGoogleChatLists(text, markerToken) {
915
- return text.split("\n").map((line) => {
916
- const markerIndex = line.indexOf(markerToken);
917
- if (markerIndex < 0) return line;
918
- const prefix = line.slice(0, markerIndex);
919
- const quote = /^(?:> )*/u.exec(prefix)?.[0] ?? "";
920
- const indent = prefix.slice(quote.length);
921
- return `${quote}${" ".repeat(indent.length * 2)}* ${line.slice(markerIndex + markerToken.length)}`;
922
- }).join("\n");
923
- }
924
- function emitGoogleChatBlockquotes(text, markers) {
925
- let depth = 0;
926
- let lineStart = true;
927
- let rendered = "";
928
- for (let index = 0; index < text.length; index += 1) {
929
- if (text.startsWith(markers.blockquoteOpen, index)) {
930
- depth += 1;
931
- index += markers.blockquoteOpen.length - 1;
932
- continue;
933
- }
934
- if (text.startsWith(markers.blockquoteClose, index)) {
935
- depth = Math.max(0, depth - 1);
936
- index += markers.blockquoteClose.length - 1;
937
- continue;
795
+ {
796
+ const codeRanges = ir.styles.filter((span) => span.style === "code" || span.style === "code_block");
797
+ const inCode = (index) => codeRanges.some((span) => index >= span.start && index < span.end);
798
+ const inLink = (index) => ir.links.some((span) => index >= span.start && index < span.end);
799
+ const styleDelimiter = /* @__PURE__ */ new Map([
800
+ ["~", "strikethrough"],
801
+ ["_", "italic"],
802
+ ["*", "bold"],
803
+ ["`", "code"]
804
+ ]);
805
+ const characters = ir.text.split("");
806
+ let lineStart = 0;
807
+ while (lineStart < characters.length) {
808
+ const nextNewline = characters.indexOf("\n", lineStart);
809
+ const lineEnd = nextNewline < 0 ? characters.length : nextNewline;
810
+ for (const delimiter of [
811
+ "~",
812
+ "_",
813
+ "*",
814
+ "`"
815
+ ]) {
816
+ const indexes = [];
817
+ for (let index = lineStart; index < lineEnd; index += 1) if (characters[index] === delimiter && !inCode(index) && !inLink(index)) indexes.push(index);
818
+ if (indexes.length === 0) continue;
819
+ const renderedStyle = styleDelimiter.get(delimiter);
820
+ const lineAddsDelimiter = ir.styles.some((span) => span.style === renderedStyle && span.start < lineEnd && span.end > lineStart);
821
+ if (indexes.length >= 2 || lineAddsDelimiter) for (const index of indexes) characters[index] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(delimiter) ?? delimiter;
822
+ }
823
+ let firstTextIndex = lineStart;
824
+ while (firstTextIndex < lineEnd && characters[firstTextIndex] === " ") firstTextIndex += 1;
825
+ if (!inCode(firstTextIndex)) {
826
+ const character = characters[firstTextIndex];
827
+ if ((character === "*" || character === "-") && characters[firstTextIndex + 1] === " " || character === ">") characters[firstTextIndex] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character;
828
+ }
829
+ const line = characters.slice(lineStart, lineEnd).join("");
830
+ for (const match of line.matchAll(/<[^<>\n]*\|[^<>\n]*>/gu)) {
831
+ const open = lineStart + (match.index ?? 0);
832
+ const close = open + match[0].length - 1;
833
+ if (!inCode(open) && !inCode(close) && !inLink(open) && !inLink(close)) {
834
+ characters[open] = "<";
835
+ characters[close] = ">";
836
+ }
837
+ }
838
+ lineStart = lineEnd + 1;
938
839
  }
939
- const character = text[index] ?? "";
940
- if (lineStart && depth > 0) rendered += "> ".repeat(depth);
941
- rendered += character;
942
- lineStart = character === "\n";
840
+ const literalText = characters.join("");
841
+ ir = literalText === ir.text ? ir : {
842
+ ...ir,
843
+ text: literalText
844
+ };
943
845
  }
944
- return rendered;
945
- }
946
- function prepareGoogleChatIR(text) {
947
- const sanitized = sanitizeGoogleChatText(text);
948
- const ir = projectGoogleChatPlainLiterals(projectGoogleChatLinkLabels(projectDecodedGoogleChatResources(projectUnsafeCodeFallbacks(markdownToIR(sanitized, {
949
- enableSpoilers: true,
950
- enableTaskLists: true,
951
- headingStyle: "rich",
952
- tableMode: "bullets"
953
- })))));
954
- const markers = createGoogleChatMarkers(ir.text);
955
- return {
956
- ir: markGoogleChatBulletLists(ir, markers.list),
957
- markers
846
+ const markerText = ir.text;
847
+ let candidate = 0;
848
+ const rangeSize = 6400;
849
+ const nextMarker = () => {
850
+ while (true) {
851
+ const marker = String.fromCharCode(57344 + Math.floor(candidate / rangeSize), 57344 + candidate % rangeSize);
852
+ candidate += 1;
853
+ if (!markerText.includes(marker)) return marker;
854
+ }
958
855
  };
959
- }
960
- function renderGoogleChatIR(ir, markers) {
961
- return emitGoogleChatLists(emitGoogleChatBlockquotes(renderMarkdownWithMarkers(ir, {
962
- styleMarkers: {
963
- bold: {
964
- open: "*",
965
- close: "*"
966
- },
967
- italic: {
968
- open: "_",
969
- close: "_"
970
- },
971
- strikethrough: {
972
- open: "~",
973
- close: "~"
974
- },
975
- code: {
976
- open: "`",
977
- close: "`"
978
- },
979
- code_block: {
980
- open: "```\n",
981
- close: "```"
982
- },
983
- blockquote: {
984
- open: markers.blockquoteOpen,
985
- close: markers.blockquoteClose
986
- }
987
- },
988
- escapeText: (value) => value,
989
- buildLink: (link, value, context) => {
990
- if (context.origin === "linkify") return null;
991
- const href = link.href.trim();
992
- const label = value.slice(link.start, link.end);
993
- if (!href || !label) return null;
994
- const labelHasStyles = ir.styles.some((span) => span.start < link.end && span.end > link.start);
995
- return /[<>|]/u.test(href) || /[<>|*_~`]/u.test(label) || labelHasStyles ? {
996
- start: link.end,
997
- end: link.end,
998
- open: "",
999
- close: ` (${href})`
1000
- } : {
1001
- start: link.start,
1002
- end: link.end,
1003
- open: `<${href}|`,
1004
- close: ">"
1005
- };
856
+ const markers = {
857
+ list: nextMarker(),
858
+ blockquoteOpen: nextMarker(),
859
+ blockquoteClose: nextMarker()
860
+ };
861
+ {
862
+ const markerToken = markers.list;
863
+ let characters;
864
+ for (const item of ir.listItems ?? []) {
865
+ const marker = item.listMarker;
866
+ if (item.kind !== "bullet" || !marker || marker.end !== marker.start + 2 || ir.text[marker.start] !== "•" || ir.text[marker.start + 1] !== " ") continue;
867
+ characters ??= ir.text.split("");
868
+ characters[marker.start] = markerToken[0] ?? "";
869
+ characters[marker.start + 1] = markerToken[1] ?? "";
1006
870
  }
1007
- }, GOOGLE_CHAT_FORMAT_PROFILE), markers), markers.list);
1008
- }
1009
- /** Renders CommonMark into byte-bounded Google Chat app-message chunks. */
1010
- function formatGoogleChatTextChunks(text, limit = GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit) {
1011
- const prepared = prepareGoogleChatIR(text);
871
+ ir = characters ? {
872
+ ...ir,
873
+ text: characters.join("")
874
+ } : ir;
875
+ }
1012
876
  return renderMarkdownIRChunksWithinLimit({
1013
- ir: prepared.ir,
877
+ ir,
1014
878
  limit: Math.min(limit, GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit),
1015
879
  measureRendered: (rendered) => Buffer.byteLength(rendered, "utf8"),
1016
- renderChunk: (chunk) => renderGoogleChatIR(chunk, prepared.markers)
880
+ renderChunk: (chunkIr) => {
881
+ const rendered = renderMarkdownWithMarkers(chunkIr, {
882
+ styleMarkers: {
883
+ bold: {
884
+ open: "*",
885
+ close: "*"
886
+ },
887
+ italic: {
888
+ open: "_",
889
+ close: "_"
890
+ },
891
+ strikethrough: {
892
+ open: "~",
893
+ close: "~"
894
+ },
895
+ code: {
896
+ open: "`",
897
+ close: "`"
898
+ },
899
+ code_block: {
900
+ open: "```\n",
901
+ close: "```"
902
+ },
903
+ blockquote: {
904
+ open: markers.blockquoteOpen,
905
+ close: markers.blockquoteClose
906
+ }
907
+ },
908
+ escapeText: (value) => value,
909
+ buildLink: (link, value, context) => {
910
+ if (context.origin === "linkify") return null;
911
+ const href = link.href.trim();
912
+ const label = value.slice(link.start, link.end);
913
+ if (!href || !label) return null;
914
+ const labelHasStyles = chunkIr.styles.some((span) => span.start < link.end && span.end > link.start);
915
+ return /[<>|]/u.test(href) || /[<>|*_~`]/u.test(label) || labelHasStyles ? {
916
+ start: link.end,
917
+ end: link.end,
918
+ open: "",
919
+ close: ` (${href})`
920
+ } : {
921
+ start: link.start,
922
+ end: link.end,
923
+ open: `<${href}|`,
924
+ close: ">"
925
+ };
926
+ }
927
+ }, GOOGLE_CHAT_FORMAT_PROFILE);
928
+ let depth = 0;
929
+ let lineStart = true;
930
+ let blockquoteText = "";
931
+ for (let index = 0; index < rendered.length; index += 1) {
932
+ if (rendered.startsWith(markers.blockquoteOpen, index)) {
933
+ depth += 1;
934
+ index += markers.blockquoteOpen.length - 1;
935
+ continue;
936
+ }
937
+ if (rendered.startsWith(markers.blockquoteClose, index)) {
938
+ depth = Math.max(0, depth - 1);
939
+ index += markers.blockquoteClose.length - 1;
940
+ continue;
941
+ }
942
+ const character = rendered[index] ?? "";
943
+ if (lineStart && depth > 0) blockquoteText += "> ".repeat(depth);
944
+ blockquoteText += character;
945
+ lineStart = character === "\n";
946
+ }
947
+ const markerToken = markers.list;
948
+ return blockquoteText.split("\n").map((line) => {
949
+ const markerIndex = line.indexOf(markerToken);
950
+ if (markerIndex < 0) return line;
951
+ const prefix = line.slice(0, markerIndex);
952
+ const quote = /^(?:> )*/u.exec(prefix)?.[0] ?? "";
953
+ const indent = prefix.slice(quote.length);
954
+ return `${quote}${" ".repeat(indent.length * 2)}* ${line.slice(markerIndex + markerToken.length)}`;
955
+ }).join("\n");
956
+ }
1017
957
  }).map((chunk) => chunk.rendered);
1018
958
  }
1019
959
  // extensions/googlechat/src/group-policy.ts
@@ -1036,26 +976,23 @@ function normalizeGoogleChatUserId(raw) {
1036
976
  const trimmed = normalizeOptionalString(raw) ?? "";
1037
977
  return normalizeLowercaseStringOrEmpty(trimmed.replace(/^users\//i, ""));
1038
978
  }
1039
- const GOOGLECHAT_EMAIL_KIND = "plugin:googlechat-email";
1040
- function normalizeGoogleChatStableEntry(entry) {
1041
- const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
1042
- if (!withoutProvider) return null;
1043
- return withoutProvider.startsWith("users/") ? normalizeGoogleChatUserId(withoutProvider) : withoutProvider;
1044
- }
1045
- function normalizeGoogleChatEmailEntry(entry) {
1046
- const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
1047
- if (withoutProvider.startsWith("users/")) return null;
1048
- return withoutProvider.includes("@") ? withoutProvider : null;
1049
- }
1050
979
  const googleChatIngressIdentity = defineStableChannelIngressIdentity({
1051
980
  key: "sender-id",
1052
981
  authentication: "verified",
1053
- normalizeEntry: normalizeGoogleChatStableEntry,
982
+ normalizeEntry(entry) {
983
+ const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
984
+ if (!withoutProvider) return null;
985
+ return withoutProvider.startsWith("users/") ? normalizeGoogleChatUserId(withoutProvider) : withoutProvider;
986
+ },
1054
987
  normalizeSubject: normalizeGoogleChatUserId,
1055
988
  aliases: [{
1056
989
  key: "email",
1057
- kind: GOOGLECHAT_EMAIL_KIND,
1058
- normalizeEntry: normalizeGoogleChatEmailEntry,
990
+ kind: "plugin:googlechat-email",
991
+ normalizeEntry(entry) {
992
+ const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
993
+ if (withoutProvider.startsWith("users/")) return null;
994
+ return withoutProvider.includes("@") ? withoutProvider : null;
995
+ },
1059
996
  normalizeSubject: normalizeLowercaseStringOrEmpty,
1060
997
  authentication: "mutable"
1061
998
  }],
@@ -1063,7 +1000,7 @@ const googleChatIngressIdentity = defineStableChannelIngressIdentity({
1063
1000
  resolveEntryId: ({ entryIndex, fieldKey }) => fieldKey === "stableId" ? `entry-${entryIndex + 1}:user` : `entry-${entryIndex + 1}:${fieldKey}`
1064
1001
  });
1065
1002
  // extensions/googlechat/src/channel.adapters.ts
1066
- const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-DkrekcGA.mjs"), "googleChatChannelRuntime");
1003
+ const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-CBwK8353.mjs"), "googleChatChannelRuntime");
1067
1004
  const collectGoogleChatGroupPolicyWarnings = createAllowlistProviderOpenWarningCollector({
1068
1005
  providerConfigPresent: (cfg) => cfg.channels?.googlechat !== void 0,
1069
1006
  resolveGroupPolicy: (account) => account.config.groupPolicy,
@@ -1156,7 +1093,15 @@ const googlechatOutboundAdapter = {
1156
1093
  chunkerMode: "markdown",
1157
1094
  textChunkLimit: GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit,
1158
1095
  sanitizeText: ({ text }) => sanitizeGoogleChatText(text),
1159
- normalizePayload: ({ payload }) => shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload) ? null : payload,
1096
+ normalizePayload: ({ payload }) => {
1097
+ if (shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload)) return null;
1098
+ const reply = resolveSendableOutboundReplyParts(payload);
1099
+ const { mediaUrl: _mediaUrl, mediaUrls: _mediaUrls, ...rest } = payload;
1100
+ return {
1101
+ ...rest,
1102
+ text: formatGoogleChatMediaText(reply.text, reply.mediaUrls)
1103
+ };
1104
+ },
1160
1105
  resolveTarget: ({ to }) => {
1161
1106
  const normalized = normalizeGoogleChatTarget(to);
1162
1107
  return normalized ? {
@@ -1213,9 +1158,10 @@ const googlechatMessageAdapter = defineChannelMessageAdapter({
1213
1158
  id: "googlechat",
1214
1159
  durableFinal: { capabilities: {
1215
1160
  text: true,
1161
+ media: true,
1216
1162
  thread: true,
1217
1163
  messageSendingHooks: true
1218
1164
  } },
1219
1165
  send: { text: googlechatOutboundAdapter.attachedResults.sendText }
1220
1166
  });
1221
- export { registerGoogleChatManualApprovalFollowupSuppression as A, updateGoogleChatMessage as C, googleChatApprovalControls as D, buildGoogleChatApprovalActionParameters as E, readGoogleChatApprovalActionToken as O, sendGoogleChatMessage as S, GOOGLECHAT_APPROVAL_ACTION as T, resolveGoogleChatOutboundSpace as _, googlechatPairingTextAdapter as a, downloadGoogleChatMedia as b, googleChatIngressIdentity as c, formatGoogleChatTextChunks as d, isGoogleChatGroupSpace as f, resolveGoogleChatOutboundSessionRoute as g, normalizeGoogleChatTarget as h, googlechatOutboundAdapter as i, unregisterGoogleChatManualApprovalFollowupSuppression as j, registerGoogleChatApprovalCardBinding as k, normalizeGoogleChatUserId as l, isGoogleChatUserTarget as m, googlechatGroupsAdapter as n, googlechatSecurityAdapter as o, isGoogleChatSpaceTarget as p, googlechatMessageAdapter as r, googlechatThreadingAdapter as s, googlechatDirectoryAdapter as t, buildGoogleChatGroupPolicyScope as u, GoogleChatApiError as v, verifyGoogleChatRequest as w, probeGoogleChat as x, deleteGoogleChatMessage as y };
1167
+ export { registerGoogleChatApprovalCardBinding as A, sendGoogleChatMessage as C, buildGoogleChatApprovalActionParameters as D, GOOGLECHAT_APPROVAL_ACTION as E, unregisterGoogleChatManualApprovalFollowupSuppression as M, googleChatApprovalControls as O, probeGoogleChat as S, verifyGoogleChatRequest as T, resolveGoogleChatOutboundSessionRoute as _, googlechatPairingTextAdapter as a, deleteGoogleChatMessage as b, googleChatIngressIdentity as c, formatGoogleChatMediaText as d, formatGoogleChatTextChunks as f, normalizeGoogleChatTarget as g, isGoogleChatUserTarget as h, googlechatOutboundAdapter as i, registerGoogleChatManualApprovalFollowupSuppression as j, readGoogleChatApprovalActionToken as k, normalizeGoogleChatUserId as l, isGoogleChatSpaceTarget as m, googlechatGroupsAdapter as n, googlechatSecurityAdapter as o, isGoogleChatGroupSpace as p, googlechatMessageAdapter as r, googlechatThreadingAdapter as s, googlechatDirectoryAdapter as t, buildGoogleChatGroupPolicyScope as u, resolveGoogleChatOutboundSpace as v, updateGoogleChatMessage as w, downloadGoogleChatMedia as x, GoogleChatApiError as y };