@openclaw/googlechat 2026.11.3 → 2026.11.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{actions-CTuBGHVR.mjs → actions-UltP4TmA.mjs} +3 -3
- package/dist/.setup/{approval-auth-Dd-6ne22.mjs → approval-auth-C-AJm9xZ.mjs} +2 -2
- package/dist/.setup/{approval-handler.runtime-ZJkCErV1.mjs → approval-handler.runtime-dh__rR4O.mjs} +3 -3
- package/dist/.setup/{channel-p2FLMhYl.mjs → channel-DHpMDrjU.mjs} +78 -88
- package/dist/.setup/{channel-base-sWlG7EP1.mjs → channel-base-DZs1uOyW.mjs} +13 -14
- package/dist/.setup/{channel.adapters-CLzwB-5-.mjs → channel.adapters-BVT76qsz.mjs} +239 -315
- package/dist/.setup/{channel.runtime-Dlp4xvi9.mjs → channel.runtime-I9jyPEzh.mjs} +294 -343
- package/dist/.setup/secret-contract-api-BG_8yVjr.mjs +2 -0
- package/dist/.setup/setup-plugin-api-DW0Pq8Dd.mjs +2 -0
- package/dist/.source-module-urls/974ffefea973cf3ea18e1534d25b091bcf1b68760a2b9eda0cd9bd9392096c64.json +1 -0
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -2
- package/dist/runtime-api.js +1 -2
- package/dist/secret-contract-api.js +1 -2
- package/dist/setup-entry.js +2 -2
- package/dist/setup-plugin-api.js +1 -2
- package/node_modules/google-auth-library/build/src/auth/authclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/awsclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/awsrequestsigner.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/baseexternalclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/certificatesubjecttokensupplier.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/computeclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/credentials.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/defaultawssecuritycredentialssupplier.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/downscopedclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/envDetect.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/executable-response.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/externalAccountAuthorizedUserClient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/externalclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/filesubjecttokensupplier.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/gdchclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/googleauth.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/iam.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/identitypoolclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/idtokenclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/impersonated.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/jwtaccess.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/jwtclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/loginticket.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/oauth2client.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/oauth2common.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/passthrough.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/pluggable-auth-client.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/pluggable-auth-handler.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/refreshclient.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/stscredentials.js.map +1 -0
- package/node_modules/google-auth-library/build/src/auth/urlsubjecttokensupplier.js.map +1 -0
- package/node_modules/google-auth-library/build/src/crypto/browser/crypto.js.map +1 -0
- package/node_modules/google-auth-library/build/src/crypto/crypto.js.map +1 -0
- package/node_modules/google-auth-library/build/src/crypto/node/crypto.js.map +1 -0
- package/node_modules/google-auth-library/build/src/crypto/shared.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/errorWithCode.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/getCredentials.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/getToken.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/googleToken.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/jwsSign.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/revokeToken.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/tokenHandler.js.map +1 -0
- package/node_modules/google-auth-library/build/src/gtoken/tokenOptions.js.map +1 -0
- package/node_modules/google-auth-library/build/src/index.js.map +1 -0
- package/node_modules/google-auth-library/build/src/shared.cjs.map +1 -0
- package/node_modules/google-auth-library/build/src/util.js.map +1 -0
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/gaxios.js +166 -5
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/gaxios.js.map +1 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/retry.js +12 -2
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/src/retry.js.map +1 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/gaxios.js +167 -6
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/gaxios.js.map +1 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/retry.js +12 -2
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/src/retry.js.map +1 -1
- package/node_modules/google-auth-library/node_modules/gaxios/package.json +32 -25
- package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js +14 -1
- package/node_modules/google-auth-library/node_modules/gcp-metadata/build/src/index.js.map +1 -1
- package/node_modules/google-auth-library/node_modules/gcp-metadata/package.json +19 -20
- package/node_modules/google-auth-library/node_modules/google-logging-utils/package.json +2 -2
- package/node_modules/google-auth-library/package.json +7 -9
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +0 -30
- package/package.json +6 -6
- package/dist/.setup/secret-contract-api-Dx8QYxoR.mjs +0 -3
- package/dist/.setup/setup-plugin-api-yGEtLeXV.mjs +0 -3
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.js +0 -109
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/browser-test-runner.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.js +0 -81
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/browser-test/test.browser.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.js +0 -128
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/system-test/test.install.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.js +0 -1510
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.getch.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.js +0 -61
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.index.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.js +0 -367
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/test/test.retry.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/cjs/tsconfig.cjs.tsbuildinfo +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.js +0 -71
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/browser-test-runner.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.js +0 -76
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/browser-test/test.browser.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.js +0 -123
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/system-test/test.install.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.js +0 -1472
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.getch.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.js +0 -23
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.index.js.map +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.d.ts +0 -1
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.js +0 -362
- package/node_modules/google-auth-library/node_modules/gaxios/build/esm/test/test.retry.js.map +0 -1
- 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-
|
|
1
|
+
import { l as resolveGoogleChatAccount, n as formatGoogleChatAllowFromEntry, u as MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES } from "./channel-base-DZs1uOyW.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,7 +17,6 @@ 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";
|
|
@@ -43,14 +43,10 @@ function buildGoogleChatApprovalActionParameters(token) {
|
|
|
43
43
|
value: token
|
|
44
44
|
}];
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function readGoogleChatApprovalActionToken(event) {
|
|
47
47
|
const params = {};
|
|
48
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;
|
|
49
49
|
for (const item of event.action?.parameters ?? []) if (typeof item.key === "string" && typeof item.value === "string") params[item.key] = item.value;
|
|
50
|
-
return params;
|
|
51
|
-
}
|
|
52
|
-
function readGoogleChatApprovalActionToken(event) {
|
|
53
|
-
const params = collectEventParameters(event);
|
|
54
50
|
if (params[GOOGLECHAT_APPROVAL_ACTION_PARAM] !== GOOGLECHAT_APPROVAL_ACTION_VALUE) return null;
|
|
55
51
|
const actionName = normalizeOptionalString(event.action?.actionMethodName) ?? normalizeOptionalString(event.common?.invokedFunction) ?? normalizeOptionalString(event.commonEventObject?.invokedFunction);
|
|
56
52
|
if (actionName && actionName !== "openclaw.approval" && !actionName.startsWith("https://")) return null;
|
|
@@ -112,10 +108,10 @@ function shouldSuppressGoogleChatManualExecApprovalFollowupText(text, nowMs = Da
|
|
|
112
108
|
function hasStructuredPayloadPart(payload) {
|
|
113
109
|
return Boolean(payload.mediaUrl?.trim() || payload.mediaUrls?.some((url) => url.trim()) || payload.presentation || payload.interactive || payload.btw || payload.spokenText || payload.ttsSupplement);
|
|
114
110
|
}
|
|
115
|
-
function shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload
|
|
111
|
+
function shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload) {
|
|
116
112
|
const text = payload.text?.trim();
|
|
117
113
|
if (!text || hasStructuredPayloadPart(payload)) return false;
|
|
118
|
-
return shouldSuppressGoogleChatManualExecApprovalFollowupText(text
|
|
114
|
+
return shouldSuppressGoogleChatManualExecApprovalFollowupText(text);
|
|
119
115
|
}
|
|
120
116
|
//#endregion
|
|
121
117
|
//#region extensions/googlechat/src/google-auth.runtime.ts
|
|
@@ -128,10 +124,6 @@ const GOOGLE_AUTH_UNIVERSE_DOMAIN = "googleapis.com";
|
|
|
128
124
|
const GOOGLE_CLIENT_CERTS_URL_PREFIX = "https://www.googleapis.com/robot/v1/metadata/x509/";
|
|
129
125
|
const MAX_GOOGLE_AUTH_RESPONSE_BYTES = 1048576;
|
|
130
126
|
let googleAuthRuntimePromise = null;
|
|
131
|
-
function normalizeGoogleAuthHeaders(value) {
|
|
132
|
-
if (!(value.headers instanceof Headers)) value.headers = new Headers(value.headers);
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
127
|
function hasProxyAgentShape(value) {
|
|
136
128
|
const record = asNullableObjectRecord(value);
|
|
137
129
|
return record !== null && record.proxy instanceof URL;
|
|
@@ -140,19 +132,15 @@ function hasTlsAgentShape(value) {
|
|
|
140
132
|
const record = asNullableObjectRecord(value);
|
|
141
133
|
return record !== null && asNullableObjectRecord(record.options) !== null;
|
|
142
134
|
}
|
|
143
|
-
function resolveGoogleAuthAgent(init, url) {
|
|
144
|
-
return typeof init.agent === "function" ? init.agent(url) : init.agent;
|
|
145
|
-
}
|
|
146
135
|
function hasTlsOptions(options) {
|
|
147
136
|
return options.cert !== void 0 || options.key !== void 0;
|
|
148
137
|
}
|
|
149
|
-
function resolveGoogleAuthTlsOptions(init,
|
|
138
|
+
function resolveGoogleAuthTlsOptions(init, agent) {
|
|
150
139
|
const explicit = {
|
|
151
140
|
cert: init.cert,
|
|
152
141
|
key: init.key
|
|
153
142
|
};
|
|
154
143
|
if (hasTlsOptions(explicit)) return explicit;
|
|
155
|
-
const agent = resolveGoogleAuthAgent(init, url);
|
|
156
144
|
if (hasProxyAgentShape(agent)) return {
|
|
157
145
|
cert: agent.connectOpts?.cert,
|
|
158
146
|
key: agent.connectOpts?.key
|
|
@@ -163,40 +151,6 @@ function resolveGoogleAuthTlsOptions(init, url) {
|
|
|
163
151
|
};
|
|
164
152
|
return {};
|
|
165
153
|
}
|
|
166
|
-
function resolveGoogleAuthEnvProxyUrl(protocol) {
|
|
167
|
-
const httpProxy = normalizeOptionalString(process.env.HTTP_PROXY) ?? normalizeOptionalString(process.env.http_proxy);
|
|
168
|
-
const httpsProxy = normalizeOptionalString(process.env.HTTPS_PROXY) ?? normalizeOptionalString(process.env.https_proxy);
|
|
169
|
-
if (protocol === "https") return httpsProxy ?? httpProxy ?? void 0;
|
|
170
|
-
return httpProxy ?? void 0;
|
|
171
|
-
}
|
|
172
|
-
function collectGoogleAuthNoProxyRules(noProxy = []) {
|
|
173
|
-
const rules = [...noProxy];
|
|
174
|
-
const envRules = (process.env.NO_PROXY ?? process.env.no_proxy)?.split(",") ?? [];
|
|
175
|
-
for (const rule of envRules) {
|
|
176
|
-
const trimmed = rule.trim();
|
|
177
|
-
if (trimmed.length > 0) rules.push(trimmed);
|
|
178
|
-
}
|
|
179
|
-
return rules;
|
|
180
|
-
}
|
|
181
|
-
function shouldBypassGoogleAuthProxy(url, noProxy = []) {
|
|
182
|
-
for (const rule of collectGoogleAuthNoProxyRules(noProxy)) {
|
|
183
|
-
if (rule instanceof RegExp) {
|
|
184
|
-
if (rule.test(url.toString())) return true;
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
if (rule instanceof URL) {
|
|
188
|
-
if (rule.origin === url.origin) return true;
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
if (rule.startsWith("*.") || rule.startsWith(".")) {
|
|
192
|
-
const cleanedRule = rule.replace(/^\*\./, ".");
|
|
193
|
-
if (url.hostname.endsWith(cleanedRule)) return true;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
if (rule === url.origin || rule === url.hostname || rule === url.href) return true;
|
|
197
|
-
}
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
154
|
function readOptionalTrimmedString(record, fieldName) {
|
|
201
155
|
const value = record[fieldName];
|
|
202
156
|
if (value === void 0 || value === null) return;
|
|
@@ -280,30 +234,24 @@ function resolveGoogleAuthDispatcherPolicy(input, init) {
|
|
|
280
234
|
const requestUrl = input instanceof Request ? new URL(input.url) : new URL(typeof input === "string" ? input : input.toString());
|
|
281
235
|
const nextInit = sanitizeGoogleAuthInit(init);
|
|
282
236
|
const googleAuthInit = init ?? {};
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
const explicitProxy = (googleAuthInit.proxy instanceof URL ? googleAuthInit.proxy.toString() : normalizeOptionalString(googleAuthInit.proxy)) ?? (hasProxyAgentShape(agent) ? agent.proxy.toString() : void 0);
|
|
287
|
-
const proxyUrl = proxyBypassed ? void 0 : explicitProxy ?? resolveGoogleAuthEnvProxyUrl(requestUrl.protocol === "http:" ? "http" : "https");
|
|
288
|
-
if (proxyUrl) return {
|
|
237
|
+
const agent = typeof googleAuthInit.agent === "function" ? googleAuthInit.agent(requestUrl) : googleAuthInit.agent;
|
|
238
|
+
const tlsOptions = resolveGoogleAuthTlsOptions(googleAuthInit, agent);
|
|
239
|
+
if (hasProxyAgentShape(agent)) return {
|
|
289
240
|
dispatcherPolicy: {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
} : { mode: "env-proxy" },
|
|
295
|
-
...hasTlsOptions(tlsOptions) ? { proxyTls: { ...tlsOptions } } : {}
|
|
241
|
+
allowPrivateProxy: true,
|
|
242
|
+
mode: "explicit-proxy",
|
|
243
|
+
proxyUrl: agent.proxy.toString(),
|
|
244
|
+
...hasTlsOptions(tlsOptions) ? { proxyTls: tlsOptions } : {}
|
|
296
245
|
},
|
|
297
246
|
init: nextInit
|
|
298
247
|
};
|
|
299
|
-
|
|
248
|
+
return {
|
|
300
249
|
dispatcherPolicy: {
|
|
301
|
-
|
|
302
|
-
|
|
250
|
+
mode: "direct",
|
|
251
|
+
...hasTlsOptions(tlsOptions) ? { connect: tlsOptions } : {}
|
|
303
252
|
},
|
|
304
253
|
init: nextInit
|
|
305
254
|
};
|
|
306
|
-
return { init: nextInit };
|
|
307
255
|
}
|
|
308
256
|
async function googleAuthFetch(input, init) {
|
|
309
257
|
const url = input instanceof Request ? input.url : String(input);
|
|
@@ -348,10 +296,7 @@ async function loadGoogleAuthRuntime() {
|
|
|
348
296
|
}
|
|
349
297
|
async function getGoogleAuthTransport() {
|
|
350
298
|
const { gaxios } = await loadGoogleAuthRuntime();
|
|
351
|
-
|
|
352
|
-
transport.interceptors.request.add({ resolved: async (config) => normalizeGoogleAuthHeaders(config) });
|
|
353
|
-
transport.interceptors.response.add({ resolved: async (response) => normalizeGoogleAuthHeaders(response) });
|
|
354
|
-
return transport;
|
|
299
|
+
return new gaxios.Gaxios({ fetchImplementation: googleAuthFetch });
|
|
355
300
|
}
|
|
356
301
|
async function resolveValidatedGoogleChatCredentials(account) {
|
|
357
302
|
if (account.credentials) return validateGoogleChatServiceAccountCredentials(account.credentials);
|
|
@@ -496,7 +441,6 @@ const GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS = 9e5;
|
|
|
496
441
|
const GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS = 3e4;
|
|
497
442
|
const GOOGLECHAT_JSON_RESPONSE_MAX_BYTES = 16777216;
|
|
498
443
|
const GOOGLECHAT_ERROR_BODY_MAX_BYTES = 16384;
|
|
499
|
-
const GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES = 20971520;
|
|
500
444
|
var GoogleChatApiError = class extends Error {
|
|
501
445
|
constructor(status, message) {
|
|
502
446
|
super(message);
|
|
@@ -505,7 +449,6 @@ var GoogleChatApiError = class extends Error {
|
|
|
505
449
|
}
|
|
506
450
|
};
|
|
507
451
|
function resolveGoogleChatMediaTimeoutMs(maxBytes) {
|
|
508
|
-
if (!maxBytes) return GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS;
|
|
509
452
|
const transferMs = Math.ceil(maxBytes / GOOGLECHAT_MEDIA_MIN_BYTES_PER_SECOND * 1e3);
|
|
510
453
|
return Math.min(GOOGLECHAT_MEDIA_TIMEOUT_GRACE_MS + transferMs, GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS);
|
|
511
454
|
}
|
|
@@ -568,14 +511,13 @@ async function fetchJson(account, url, init, hooks) {
|
|
|
568
511
|
});
|
|
569
512
|
}
|
|
570
513
|
async function downloadGoogleChatMedia(params) {
|
|
571
|
-
const { account, resourceName, maxBytes
|
|
514
|
+
const { account, resourceName, maxBytes } = params;
|
|
572
515
|
return await withGoogleChatResponse({
|
|
573
516
|
account,
|
|
574
517
|
url: `${CHAT_API_BASE}/media/${resourceName}?alt=media`,
|
|
575
518
|
auditContext: "googlechat.api.buffer",
|
|
576
|
-
timeoutMs: resolveGoogleChatMediaTimeoutMs(
|
|
519
|
+
timeoutMs: resolveGoogleChatMediaTimeoutMs(maxBytes),
|
|
577
520
|
handleResponse: async (res) => {
|
|
578
|
-
const maxBytes = requestedMaxBytes ?? GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES;
|
|
579
521
|
const lengthHeader = res.headers.get("content-length");
|
|
580
522
|
if (lengthHeader) {
|
|
581
523
|
const length = parseMediaContentLength(lengthHeader);
|
|
@@ -645,7 +587,7 @@ async function findGoogleChatDirectMessage(params) {
|
|
|
645
587
|
return await fetchJson(account, url.toString(), { method: "GET" }, { assertDirectAdapterHandoff: params.assertDirectAdapterHandoff });
|
|
646
588
|
}
|
|
647
589
|
async function getGoogleChatSpace(params) {
|
|
648
|
-
return await fetchJson(params.account, `${CHAT_API_BASE}/${params.spaceName}`, { method: "GET" });
|
|
590
|
+
return await fetchJson(params.account, `${CHAT_API_BASE}/${params.spaceName}`, { method: "GET" }, { assertDirectAdapterHandoff: params.assertDirectAdapterHandoff });
|
|
649
591
|
}
|
|
650
592
|
async function probeGoogleChat(account) {
|
|
651
593
|
try {
|
|
@@ -723,7 +665,8 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
|
|
|
723
665
|
});
|
|
724
666
|
const resolvedSpace = await resolveGoogleChatOutboundSpaceDetails({
|
|
725
667
|
account,
|
|
726
|
-
target: params.target
|
|
668
|
+
target: params.target,
|
|
669
|
+
assertDirectAdapterHandoff: params.assertDirectAdapterHandoff
|
|
727
670
|
});
|
|
728
671
|
const spaceName = resolvedSpace.name;
|
|
729
672
|
if (!isGoogleChatSpaceTarget(spaceName)) return null;
|
|
@@ -731,7 +674,8 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
|
|
|
731
674
|
if (!chatType) try {
|
|
732
675
|
chatType = resolveGoogleChatSpaceChatType(await getGoogleChatSpace({
|
|
733
676
|
account,
|
|
734
|
-
spaceName
|
|
677
|
+
spaceName,
|
|
678
|
+
assertDirectAdapterHandoff: params.assertDirectAdapterHandoff
|
|
735
679
|
}));
|
|
736
680
|
} catch {
|
|
737
681
|
return null;
|
|
@@ -783,26 +727,6 @@ const GOOGLE_CHAT_LITERAL_FALLBACKS = /* @__PURE__ */ new Map([
|
|
|
783
727
|
["-", "-"],
|
|
784
728
|
["|", "|"]
|
|
785
729
|
]);
|
|
786
|
-
function createGoogleChatMarkers(text) {
|
|
787
|
-
const used = /* @__PURE__ */ new Set();
|
|
788
|
-
let candidate = 0;
|
|
789
|
-
const rangeSize = 6400;
|
|
790
|
-
const nextMarker = () => {
|
|
791
|
-
while (true) {
|
|
792
|
-
const marker = String.fromCharCode(57344 + Math.floor(candidate / rangeSize), 57344 + candidate % rangeSize);
|
|
793
|
-
candidate += 1;
|
|
794
|
-
if (!used.has(marker) && !text.includes(marker)) {
|
|
795
|
-
used.add(marker);
|
|
796
|
-
return marker;
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
};
|
|
800
|
-
return {
|
|
801
|
-
list: nextMarker(),
|
|
802
|
-
blockquoteOpen: nextMarker(),
|
|
803
|
-
blockquoteClose: nextMarker()
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
730
|
/** Removes unsafe HTML and internal scaffolding while retaining source Markdown for chunking. */
|
|
807
731
|
function sanitizeGoogleChatText(text) {
|
|
808
732
|
return sanitizeForPlainText(sanitizeAssistantVisibleText(text), { style: "markdown" });
|
|
@@ -819,219 +743,222 @@ function formatGoogleChatMediaText(text, mediaUrls) {
|
|
|
819
743
|
if (remoteUrls.length !== mediaUrls.length) throw new Error("Google Chat outbound attachments require remote HTTP(S) URLs.");
|
|
820
744
|
return [text, formatTextWithAttachmentLinks(void 0, remoteUrls)].filter(Boolean).join("\n\n");
|
|
821
745
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
if (fallback && /[<>|*_~`]/u.test(character)) {
|
|
840
|
-
characters[index] = fallback;
|
|
841
|
-
changed = true;
|
|
746
|
+
/** Renders CommonMark into byte-bounded Google Chat app-message chunks. */
|
|
747
|
+
function formatGoogleChatTextChunks(text, limit = GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit) {
|
|
748
|
+
const sanitized = sanitizeGoogleChatText(text);
|
|
749
|
+
let ir = markdownToIR(sanitized, {
|
|
750
|
+
enableSpoilers: true,
|
|
751
|
+
enableTaskLists: true,
|
|
752
|
+
headingStyle: "rich",
|
|
753
|
+
tableMode: "bullets"
|
|
754
|
+
});
|
|
755
|
+
{
|
|
756
|
+
let codeText = ir.text;
|
|
757
|
+
const styles = ir.styles.filter((span) => {
|
|
758
|
+
const content = ir.text.slice(span.start, span.end);
|
|
759
|
+
const unsafe = span.style === "code" && content.includes("`") || span.style === "code_block" && content.includes("```");
|
|
760
|
+
if (unsafe) {
|
|
761
|
+
const replacement = content.split("").map((character) => GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character).join("");
|
|
762
|
+
codeText = `${codeText.slice(0, span.start)}${replacement}${codeText.slice(span.end)}`;
|
|
842
763
|
}
|
|
843
|
-
|
|
764
|
+
return !unsafe;
|
|
765
|
+
});
|
|
766
|
+
ir = styles.length === ir.styles.length ? ir : {
|
|
767
|
+
...ir,
|
|
768
|
+
styles,
|
|
769
|
+
text: codeText
|
|
770
|
+
};
|
|
844
771
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
text:
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
let characters;
|
|
852
|
-
for (const item of ir.listItems ?? []) {
|
|
853
|
-
const marker = item.listMarker;
|
|
854
|
-
if (item.kind !== "bullet" || !marker || marker.end !== marker.start + 2 || ir.text[marker.start] !== "•" || ir.text[marker.start + 1] !== " ") continue;
|
|
855
|
-
characters ??= ir.text.split("");
|
|
856
|
-
characters[marker.start] = markerToken[0] ?? "";
|
|
857
|
-
characters[marker.start + 1] = markerToken[1] ?? "";
|
|
772
|
+
{
|
|
773
|
+
const decodedText = ir.text.replace(/<(?:users|customEmojis)\/[^<>\s]+>/giu, (match) => `<${match.slice(1, -1)}>`);
|
|
774
|
+
ir = decodedText === ir.text ? ir : {
|
|
775
|
+
...ir,
|
|
776
|
+
text: decodedText
|
|
777
|
+
};
|
|
858
778
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
return !unsafe;
|
|
874
|
-
});
|
|
875
|
-
return styles.length === ir.styles.length ? ir : {
|
|
876
|
-
...ir,
|
|
877
|
-
styles,
|
|
878
|
-
text
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
function projectGoogleChatPlainLiterals(ir) {
|
|
882
|
-
const codeRanges = ir.styles.filter((span) => span.style === "code" || span.style === "code_block");
|
|
883
|
-
const inCode = (index) => codeRanges.some((span) => index >= span.start && index < span.end);
|
|
884
|
-
const inLink = (index) => ir.links.some((span) => index >= span.start && index < span.end);
|
|
885
|
-
const styleDelimiter = /* @__PURE__ */ new Map([
|
|
886
|
-
["~", "strikethrough"],
|
|
887
|
-
["_", "italic"],
|
|
888
|
-
["*", "bold"],
|
|
889
|
-
["`", "code"]
|
|
890
|
-
]);
|
|
891
|
-
const characters = ir.text.split("");
|
|
892
|
-
let lineStart = 0;
|
|
893
|
-
while (lineStart < characters.length) {
|
|
894
|
-
const nextNewline = characters.indexOf("\n", lineStart);
|
|
895
|
-
const lineEnd = nextNewline < 0 ? characters.length : nextNewline;
|
|
896
|
-
for (const delimiter of [
|
|
897
|
-
"~",
|
|
898
|
-
"_",
|
|
899
|
-
"*",
|
|
900
|
-
"`"
|
|
901
|
-
]) {
|
|
902
|
-
const indexes = [];
|
|
903
|
-
for (let index = lineStart; index < lineEnd; index += 1) if (characters[index] === delimiter && !inCode(index) && !inLink(index)) indexes.push(index);
|
|
904
|
-
if (indexes.length === 0) continue;
|
|
905
|
-
const renderedStyle = styleDelimiter.get(delimiter);
|
|
906
|
-
const lineAddsDelimiter = ir.styles.some((span) => span.style === renderedStyle && span.start < lineEnd && span.end > lineStart);
|
|
907
|
-
if (indexes.length >= 2 || lineAddsDelimiter) for (const index of indexes) characters[index] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(delimiter) ?? delimiter;
|
|
908
|
-
}
|
|
909
|
-
let firstTextIndex = lineStart;
|
|
910
|
-
while (firstTextIndex < lineEnd && characters[firstTextIndex] === " ") firstTextIndex += 1;
|
|
911
|
-
if (!inCode(firstTextIndex)) {
|
|
912
|
-
const character = characters[firstTextIndex];
|
|
913
|
-
if ((character === "*" || character === "-") && characters[firstTextIndex + 1] === " " || character === ">") characters[firstTextIndex] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character;
|
|
914
|
-
}
|
|
915
|
-
const line = characters.slice(lineStart, lineEnd).join("");
|
|
916
|
-
for (const match of line.matchAll(/<[^<>\n]*\|[^<>\n]*>/gu)) {
|
|
917
|
-
const open = lineStart + (match.index ?? 0);
|
|
918
|
-
const close = open + match[0].length - 1;
|
|
919
|
-
if (!inCode(open) && !inCode(close) && !inLink(open) && !inLink(close)) {
|
|
920
|
-
characters[open] = "<";
|
|
921
|
-
characters[close] = ">";
|
|
779
|
+
{
|
|
780
|
+
const characters = ir.links.length > 0 ? ir.text.split("") : [];
|
|
781
|
+
let changed = false;
|
|
782
|
+
for (const link of ir.links) {
|
|
783
|
+
const label = ir.text.slice(link.start, link.end);
|
|
784
|
+
const comparableHref = link.href.startsWith("mailto:") ? link.href.slice(7) : link.href;
|
|
785
|
+
if (label === link.href || label === comparableHref) continue;
|
|
786
|
+
for (let index = link.start; index < link.end; index += 1) {
|
|
787
|
+
const character = characters[index] ?? "";
|
|
788
|
+
const fallback = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character);
|
|
789
|
+
if (fallback && /[<>|*_~`]/u.test(character)) {
|
|
790
|
+
characters[index] = fallback;
|
|
791
|
+
changed = true;
|
|
792
|
+
}
|
|
922
793
|
}
|
|
923
794
|
}
|
|
924
|
-
|
|
795
|
+
ir = changed ? {
|
|
796
|
+
...ir,
|
|
797
|
+
text: characters.join("")
|
|
798
|
+
} : ir;
|
|
925
799
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
800
|
+
{
|
|
801
|
+
const codeRanges = ir.styles.filter((span) => span.style === "code" || span.style === "code_block");
|
|
802
|
+
const inCode = (index) => codeRanges.some((span) => index >= span.start && index < span.end);
|
|
803
|
+
const inLink = (index) => ir.links.some((span) => index >= span.start && index < span.end);
|
|
804
|
+
const styleDelimiter = /* @__PURE__ */ new Map([
|
|
805
|
+
["~", "strikethrough"],
|
|
806
|
+
["_", "italic"],
|
|
807
|
+
["*", "bold"],
|
|
808
|
+
["`", "code"]
|
|
809
|
+
]);
|
|
810
|
+
const characters = ir.text.split("");
|
|
811
|
+
let lineStart = 0;
|
|
812
|
+
while (lineStart < characters.length) {
|
|
813
|
+
const nextNewline = characters.indexOf("\n", lineStart);
|
|
814
|
+
const lineEnd = nextNewline < 0 ? characters.length : nextNewline;
|
|
815
|
+
for (const delimiter of [
|
|
816
|
+
"~",
|
|
817
|
+
"_",
|
|
818
|
+
"*",
|
|
819
|
+
"`"
|
|
820
|
+
]) {
|
|
821
|
+
const indexes = [];
|
|
822
|
+
for (let index = lineStart; index < lineEnd; index += 1) if (characters[index] === delimiter && !inCode(index) && !inLink(index)) indexes.push(index);
|
|
823
|
+
if (indexes.length === 0) continue;
|
|
824
|
+
const renderedStyle = styleDelimiter.get(delimiter);
|
|
825
|
+
const lineAddsDelimiter = ir.styles.some((span) => span.style === renderedStyle && span.start < lineEnd && span.end > lineStart);
|
|
826
|
+
if (indexes.length >= 2 || lineAddsDelimiter) for (const index of indexes) characters[index] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(delimiter) ?? delimiter;
|
|
827
|
+
}
|
|
828
|
+
let firstTextIndex = lineStart;
|
|
829
|
+
while (firstTextIndex < lineEnd && characters[firstTextIndex] === " ") firstTextIndex += 1;
|
|
830
|
+
if (!inCode(firstTextIndex)) {
|
|
831
|
+
const character = characters[firstTextIndex];
|
|
832
|
+
if ((character === "*" || character === "-") && characters[firstTextIndex + 1] === " " || character === ">") characters[firstTextIndex] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character;
|
|
833
|
+
}
|
|
834
|
+
const line = characters.slice(lineStart, lineEnd).join("");
|
|
835
|
+
for (const match of line.matchAll(/<[^<>\n]*\|[^<>\n]*>/gu)) {
|
|
836
|
+
const open = lineStart + (match.index ?? 0);
|
|
837
|
+
const close = open + match[0].length - 1;
|
|
838
|
+
if (!inCode(open) && !inCode(close) && !inLink(open) && !inLink(close)) {
|
|
839
|
+
characters[open] = "<";
|
|
840
|
+
characters[close] = ">";
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
lineStart = lineEnd + 1;
|
|
956
844
|
}
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
845
|
+
const literalText = characters.join("");
|
|
846
|
+
ir = literalText === ir.text ? ir : {
|
|
847
|
+
...ir,
|
|
848
|
+
text: literalText
|
|
849
|
+
};
|
|
961
850
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
})))));
|
|
972
|
-
const markers = createGoogleChatMarkers(ir.text);
|
|
973
|
-
return {
|
|
974
|
-
ir: markGoogleChatBulletLists(ir, markers.list),
|
|
975
|
-
markers
|
|
851
|
+
const markerText = ir.text;
|
|
852
|
+
let candidate = 0;
|
|
853
|
+
const rangeSize = 6400;
|
|
854
|
+
const nextMarker = () => {
|
|
855
|
+
while (true) {
|
|
856
|
+
const marker = String.fromCharCode(57344 + Math.floor(candidate / rangeSize), 57344 + candidate % rangeSize);
|
|
857
|
+
candidate += 1;
|
|
858
|
+
if (!markerText.includes(marker)) return marker;
|
|
859
|
+
}
|
|
976
860
|
};
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
close: "~"
|
|
992
|
-
},
|
|
993
|
-
code: {
|
|
994
|
-
open: "`",
|
|
995
|
-
close: "`"
|
|
996
|
-
},
|
|
997
|
-
code_block: {
|
|
998
|
-
open: "```\n",
|
|
999
|
-
close: "```"
|
|
1000
|
-
},
|
|
1001
|
-
blockquote: {
|
|
1002
|
-
open: markers.blockquoteOpen,
|
|
1003
|
-
close: markers.blockquoteClose
|
|
1004
|
-
}
|
|
1005
|
-
},
|
|
1006
|
-
escapeText: (value) => value,
|
|
1007
|
-
buildLink: (link, value, context) => {
|
|
1008
|
-
if (context.origin === "linkify") return null;
|
|
1009
|
-
const href = link.href.trim();
|
|
1010
|
-
const label = value.slice(link.start, link.end);
|
|
1011
|
-
if (!href || !label) return null;
|
|
1012
|
-
const labelHasStyles = ir.styles.some((span) => span.start < link.end && span.end > link.start);
|
|
1013
|
-
return /[<>|]/u.test(href) || /[<>|*_~`]/u.test(label) || labelHasStyles ? {
|
|
1014
|
-
start: link.end,
|
|
1015
|
-
end: link.end,
|
|
1016
|
-
open: "",
|
|
1017
|
-
close: ` (${href})`
|
|
1018
|
-
} : {
|
|
1019
|
-
start: link.start,
|
|
1020
|
-
end: link.end,
|
|
1021
|
-
open: `<${href}|`,
|
|
1022
|
-
close: ">"
|
|
1023
|
-
};
|
|
861
|
+
const markers = {
|
|
862
|
+
list: nextMarker(),
|
|
863
|
+
blockquoteOpen: nextMarker(),
|
|
864
|
+
blockquoteClose: nextMarker()
|
|
865
|
+
};
|
|
866
|
+
{
|
|
867
|
+
const markerToken = markers.list;
|
|
868
|
+
let characters;
|
|
869
|
+
for (const item of ir.listItems ?? []) {
|
|
870
|
+
const marker = item.listMarker;
|
|
871
|
+
if (item.kind !== "bullet" || !marker || marker.end !== marker.start + 2 || ir.text[marker.start] !== "•" || ir.text[marker.start + 1] !== " ") continue;
|
|
872
|
+
characters ??= ir.text.split("");
|
|
873
|
+
characters[marker.start] = markerToken[0] ?? "";
|
|
874
|
+
characters[marker.start + 1] = markerToken[1] ?? "";
|
|
1024
875
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
876
|
+
ir = characters ? {
|
|
877
|
+
...ir,
|
|
878
|
+
text: characters.join("")
|
|
879
|
+
} : ir;
|
|
880
|
+
}
|
|
1030
881
|
return renderMarkdownIRChunksWithinLimit({
|
|
1031
|
-
ir
|
|
882
|
+
ir,
|
|
1032
883
|
limit: Math.min(limit, GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit),
|
|
1033
884
|
measureRendered: (rendered) => Buffer.byteLength(rendered, "utf8"),
|
|
1034
|
-
renderChunk: (
|
|
885
|
+
renderChunk: (chunkIr) => {
|
|
886
|
+
const rendered = renderMarkdownWithMarkers(chunkIr, {
|
|
887
|
+
styleMarkers: {
|
|
888
|
+
bold: {
|
|
889
|
+
open: "*",
|
|
890
|
+
close: "*"
|
|
891
|
+
},
|
|
892
|
+
italic: {
|
|
893
|
+
open: "_",
|
|
894
|
+
close: "_"
|
|
895
|
+
},
|
|
896
|
+
strikethrough: {
|
|
897
|
+
open: "~",
|
|
898
|
+
close: "~"
|
|
899
|
+
},
|
|
900
|
+
code: {
|
|
901
|
+
open: "`",
|
|
902
|
+
close: "`"
|
|
903
|
+
},
|
|
904
|
+
code_block: {
|
|
905
|
+
open: "```\n",
|
|
906
|
+
close: "```"
|
|
907
|
+
},
|
|
908
|
+
blockquote: {
|
|
909
|
+
open: markers.blockquoteOpen,
|
|
910
|
+
close: markers.blockquoteClose
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
escapeText: (value) => value,
|
|
914
|
+
buildLink: (link, value, context) => {
|
|
915
|
+
if (context.origin === "linkify") return null;
|
|
916
|
+
const href = link.href.trim();
|
|
917
|
+
const label = value.slice(link.start, link.end);
|
|
918
|
+
if (!href || !label) return null;
|
|
919
|
+
const labelHasStyles = chunkIr.styles.some((span) => span.start < link.end && span.end > link.start);
|
|
920
|
+
return /[<>|]/u.test(href) || /[<>|*_~`]/u.test(label) || labelHasStyles ? {
|
|
921
|
+
start: link.end,
|
|
922
|
+
end: link.end,
|
|
923
|
+
open: "",
|
|
924
|
+
close: ` (${href})`
|
|
925
|
+
} : {
|
|
926
|
+
start: link.start,
|
|
927
|
+
end: link.end,
|
|
928
|
+
open: `<${href}|`,
|
|
929
|
+
close: ">"
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
}, GOOGLE_CHAT_FORMAT_PROFILE);
|
|
933
|
+
let depth = 0;
|
|
934
|
+
let lineStart = true;
|
|
935
|
+
let blockquoteText = "";
|
|
936
|
+
for (let index = 0; index < rendered.length; index += 1) {
|
|
937
|
+
if (rendered.startsWith(markers.blockquoteOpen, index)) {
|
|
938
|
+
depth += 1;
|
|
939
|
+
index += markers.blockquoteOpen.length - 1;
|
|
940
|
+
continue;
|
|
941
|
+
}
|
|
942
|
+
if (rendered.startsWith(markers.blockquoteClose, index)) {
|
|
943
|
+
depth = Math.max(0, depth - 1);
|
|
944
|
+
index += markers.blockquoteClose.length - 1;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
const character = rendered[index] ?? "";
|
|
948
|
+
if (lineStart && depth > 0) blockquoteText += "> ".repeat(depth);
|
|
949
|
+
blockquoteText += character;
|
|
950
|
+
lineStart = character === "\n";
|
|
951
|
+
}
|
|
952
|
+
const markerToken = markers.list;
|
|
953
|
+
return blockquoteText.split("\n").map((line) => {
|
|
954
|
+
const markerIndex = line.indexOf(markerToken);
|
|
955
|
+
if (markerIndex < 0) return line;
|
|
956
|
+
const prefix = line.slice(0, markerIndex);
|
|
957
|
+
const quote = /^(?:> )*/u.exec(prefix)?.[0] ?? "";
|
|
958
|
+
const indent = prefix.slice(quote.length);
|
|
959
|
+
return `${quote}${" ".repeat(indent.length * 2)}* ${line.slice(markerIndex + markerToken.length)}`;
|
|
960
|
+
}).join("\n");
|
|
961
|
+
}
|
|
1035
962
|
}).map((chunk) => chunk.rendered);
|
|
1036
963
|
}
|
|
1037
964
|
//#endregion
|
|
@@ -1056,26 +983,23 @@ function normalizeGoogleChatUserId(raw) {
|
|
|
1056
983
|
const trimmed = normalizeOptionalString(raw) ?? "";
|
|
1057
984
|
return normalizeLowercaseStringOrEmpty(trimmed.replace(/^users\//i, ""));
|
|
1058
985
|
}
|
|
1059
|
-
const GOOGLECHAT_EMAIL_KIND = "plugin:googlechat-email";
|
|
1060
|
-
function normalizeGoogleChatStableEntry(entry) {
|
|
1061
|
-
const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
|
|
1062
|
-
if (!withoutProvider) return null;
|
|
1063
|
-
return withoutProvider.startsWith("users/") ? normalizeGoogleChatUserId(withoutProvider) : withoutProvider;
|
|
1064
|
-
}
|
|
1065
|
-
function normalizeGoogleChatEmailEntry(entry) {
|
|
1066
|
-
const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
|
|
1067
|
-
if (withoutProvider.startsWith("users/")) return null;
|
|
1068
|
-
return withoutProvider.includes("@") ? withoutProvider : null;
|
|
1069
|
-
}
|
|
1070
986
|
const googleChatIngressIdentity = defineStableChannelIngressIdentity({
|
|
1071
987
|
key: "sender-id",
|
|
1072
988
|
authentication: "verified",
|
|
1073
|
-
normalizeEntry
|
|
989
|
+
normalizeEntry(entry) {
|
|
990
|
+
const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
|
|
991
|
+
if (!withoutProvider) return null;
|
|
992
|
+
return withoutProvider.startsWith("users/") ? normalizeGoogleChatUserId(withoutProvider) : withoutProvider;
|
|
993
|
+
},
|
|
1074
994
|
normalizeSubject: normalizeGoogleChatUserId,
|
|
1075
995
|
aliases: [{
|
|
1076
996
|
key: "email",
|
|
1077
|
-
kind:
|
|
1078
|
-
normalizeEntry
|
|
997
|
+
kind: "plugin:googlechat-email",
|
|
998
|
+
normalizeEntry(entry) {
|
|
999
|
+
const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
|
|
1000
|
+
if (withoutProvider.startsWith("users/")) return null;
|
|
1001
|
+
return withoutProvider.includes("@") ? withoutProvider : null;
|
|
1002
|
+
},
|
|
1079
1003
|
normalizeSubject: normalizeLowercaseStringOrEmpty,
|
|
1080
1004
|
authentication: "mutable"
|
|
1081
1005
|
}],
|
|
@@ -1084,7 +1008,7 @@ const googleChatIngressIdentity = defineStableChannelIngressIdentity({
|
|
|
1084
1008
|
});
|
|
1085
1009
|
//#endregion
|
|
1086
1010
|
//#region extensions/googlechat/src/channel.adapters.ts
|
|
1087
|
-
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-
|
|
1011
|
+
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-I9jyPEzh.mjs"), "googleChatChannelRuntime");
|
|
1088
1012
|
const collectGoogleChatGroupPolicyWarnings = createAllowlistProviderOpenWarningCollector({
|
|
1089
1013
|
providerConfigPresent: (cfg) => cfg.channels?.googlechat !== void 0,
|
|
1090
1014
|
resolveGroupPolicy: (account) => account.config.groupPolicy,
|