@openclaw/googlechat 2026.10.10-beta.5 → 2026.11.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{actions-CSE3qGrO.mjs → actions-DNDmJvwi.mjs} +16 -15
- package/dist/.setup/{approval-auth-DH1sJm7S.mjs → approval-auth-AkJ2Rg0h.mjs} +3 -4
- package/dist/.setup/{approval-card-text-BKg_4mXq.mjs → approval-card-text-9o-Dfr9Z.mjs} +1 -2
- package/dist/.setup/{approval-handler.runtime-Bx0dTqDd.mjs → approval-handler.runtime-CKuHeY6y.mjs} +5 -6
- package/dist/.setup/{channel-BBRTocXs.mjs → channel-WKI4stP3.mjs} +84 -98
- package/dist/.setup/{channel-base-sWlG7EP1.mjs → channel-base-DjVHuLDF.mjs} +17 -22
- package/dist/.setup/{channel.adapters--OFb3A2Y.mjs → channel.adapters-C9mflxGl.mjs} +271 -334
- package/dist/.setup/{channel.runtime-uaSH6k2d.mjs → channel.runtime-CBwK8353.mjs} +305 -357
- package/dist/.setup/{doctor-contract-BzoaiFSD.mjs → doctor-contract-WrFOPxEj.mjs} +6 -12
- package/dist/.setup/{runtime-C5OOOlaP.mjs → runtime-zEzHA5rr.mjs} +1 -2
- package/dist/.setup/{secret-contract-api-BG_8yVjr.mjs → secret-contract-api-CLRweErW.mjs} +1 -1
- package/dist/.setup/{secret-contract-D7KjX374.mjs → secret-contract-h2P-4VpL.mjs} +1 -2
- package/dist/.setup/setup-plugin-api-Bz3mVqQ5.mjs +2 -0
- package/dist/.source-module-urls/974ffefea973cf3ea18e1534d25b091bcf1b68760a2b9eda0cd9bd9392096c64.json +1 -1
- package/dist/api.js +2 -2
- package/dist/channel-config-api.js +1 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +2 -3
- package/dist/doctor-contract-api.js +1 -1
- package/dist/index.js +1 -2
- package/dist/runtime-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -4
- package/dist/setup-plugin-api.js +1 -1
- 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/setup-plugin-api-CFDZH0Qp.mjs +0 -2
- 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-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,12 +17,12 @@ 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";
|
|
26
27
|
const GOOGLECHAT_APPROVAL_ACTION_PARAM = "openclaw_action";
|
|
27
28
|
const GOOGLECHAT_APPROVAL_TOKEN_PARAM = "token";
|
|
@@ -42,14 +43,10 @@ function buildGoogleChatApprovalActionParameters(token) {
|
|
|
42
43
|
value: token
|
|
43
44
|
}];
|
|
44
45
|
}
|
|
45
|
-
function
|
|
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,13 +108,12 @@ 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
|
|
111
|
+
function shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload) {
|
|
115
112
|
const text = payload.text?.trim();
|
|
116
113
|
if (!text || hasStructuredPayloadPart(payload)) return false;
|
|
117
|
-
return shouldSuppressGoogleChatManualExecApprovalFollowupText(text
|
|
114
|
+
return shouldSuppressGoogleChatManualExecApprovalFollowupText(text);
|
|
118
115
|
}
|
|
119
|
-
|
|
120
|
-
//#region extensions/googlechat/src/google-auth.runtime.ts
|
|
116
|
+
// extensions/googlechat/src/google-auth.runtime.ts
|
|
121
117
|
const GOOGLE_AUTH_POLICY = buildHostnameAllowlistPolicyFromSuffixAllowlist(["accounts.google.com", "googleapis.com"]);
|
|
122
118
|
const GOOGLE_AUTH_FETCH_TIMEOUT_MS = 3e4;
|
|
123
119
|
const GOOGLE_AUTH_URI = "https://accounts.google.com/o/oauth2/auth";
|
|
@@ -127,10 +123,6 @@ const GOOGLE_AUTH_UNIVERSE_DOMAIN = "googleapis.com";
|
|
|
127
123
|
const GOOGLE_CLIENT_CERTS_URL_PREFIX = "https://www.googleapis.com/robot/v1/metadata/x509/";
|
|
128
124
|
const MAX_GOOGLE_AUTH_RESPONSE_BYTES = 1048576;
|
|
129
125
|
let googleAuthRuntimePromise = null;
|
|
130
|
-
function normalizeGoogleAuthHeaders(value) {
|
|
131
|
-
if (!(value.headers instanceof Headers)) value.headers = new Headers(value.headers);
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
126
|
function hasProxyAgentShape(value) {
|
|
135
127
|
const record = asNullableObjectRecord(value);
|
|
136
128
|
return record !== null && record.proxy instanceof URL;
|
|
@@ -139,19 +131,15 @@ function hasTlsAgentShape(value) {
|
|
|
139
131
|
const record = asNullableObjectRecord(value);
|
|
140
132
|
return record !== null && asNullableObjectRecord(record.options) !== null;
|
|
141
133
|
}
|
|
142
|
-
function resolveGoogleAuthAgent(init, url) {
|
|
143
|
-
return typeof init.agent === "function" ? init.agent(url) : init.agent;
|
|
144
|
-
}
|
|
145
134
|
function hasTlsOptions(options) {
|
|
146
135
|
return options.cert !== void 0 || options.key !== void 0;
|
|
147
136
|
}
|
|
148
|
-
function resolveGoogleAuthTlsOptions(init,
|
|
137
|
+
function resolveGoogleAuthTlsOptions(init, agent) {
|
|
149
138
|
const explicit = {
|
|
150
139
|
cert: init.cert,
|
|
151
140
|
key: init.key
|
|
152
141
|
};
|
|
153
142
|
if (hasTlsOptions(explicit)) return explicit;
|
|
154
|
-
const agent = resolveGoogleAuthAgent(init, url);
|
|
155
143
|
if (hasProxyAgentShape(agent)) return {
|
|
156
144
|
cert: agent.connectOpts?.cert,
|
|
157
145
|
key: agent.connectOpts?.key
|
|
@@ -162,40 +150,6 @@ function resolveGoogleAuthTlsOptions(init, url) {
|
|
|
162
150
|
};
|
|
163
151
|
return {};
|
|
164
152
|
}
|
|
165
|
-
function resolveGoogleAuthEnvProxyUrl(protocol) {
|
|
166
|
-
const httpProxy = normalizeOptionalString(process.env.HTTP_PROXY) ?? normalizeOptionalString(process.env.http_proxy);
|
|
167
|
-
const httpsProxy = normalizeOptionalString(process.env.HTTPS_PROXY) ?? normalizeOptionalString(process.env.https_proxy);
|
|
168
|
-
if (protocol === "https") return httpsProxy ?? httpProxy ?? void 0;
|
|
169
|
-
return httpProxy ?? void 0;
|
|
170
|
-
}
|
|
171
|
-
function collectGoogleAuthNoProxyRules(noProxy = []) {
|
|
172
|
-
const rules = [...noProxy];
|
|
173
|
-
const envRules = (process.env.NO_PROXY ?? process.env.no_proxy)?.split(",") ?? [];
|
|
174
|
-
for (const rule of envRules) {
|
|
175
|
-
const trimmed = rule.trim();
|
|
176
|
-
if (trimmed.length > 0) rules.push(trimmed);
|
|
177
|
-
}
|
|
178
|
-
return rules;
|
|
179
|
-
}
|
|
180
|
-
function shouldBypassGoogleAuthProxy(url, noProxy = []) {
|
|
181
|
-
for (const rule of collectGoogleAuthNoProxyRules(noProxy)) {
|
|
182
|
-
if (rule instanceof RegExp) {
|
|
183
|
-
if (rule.test(url.toString())) return true;
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
if (rule instanceof URL) {
|
|
187
|
-
if (rule.origin === url.origin) return true;
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
if (rule.startsWith("*.") || rule.startsWith(".")) {
|
|
191
|
-
const cleanedRule = rule.replace(/^\*\./, ".");
|
|
192
|
-
if (url.hostname.endsWith(cleanedRule)) return true;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (rule === url.origin || rule === url.hostname || rule === url.href) return true;
|
|
196
|
-
}
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
153
|
function readOptionalTrimmedString(record, fieldName) {
|
|
200
154
|
const value = record[fieldName];
|
|
201
155
|
if (value === void 0 || value === null) return;
|
|
@@ -279,30 +233,24 @@ function resolveGoogleAuthDispatcherPolicy(input, init) {
|
|
|
279
233
|
const requestUrl = input instanceof Request ? new URL(input.url) : new URL(typeof input === "string" ? input : input.toString());
|
|
280
234
|
const nextInit = sanitizeGoogleAuthInit(init);
|
|
281
235
|
const googleAuthInit = init ?? {};
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
const explicitProxy = (googleAuthInit.proxy instanceof URL ? googleAuthInit.proxy.toString() : normalizeOptionalString(googleAuthInit.proxy)) ?? (hasProxyAgentShape(agent) ? agent.proxy.toString() : void 0);
|
|
286
|
-
const proxyUrl = proxyBypassed ? void 0 : explicitProxy ?? resolveGoogleAuthEnvProxyUrl(requestUrl.protocol === "http:" ? "http" : "https");
|
|
287
|
-
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 {
|
|
288
239
|
dispatcherPolicy: {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
} : { mode: "env-proxy" },
|
|
294
|
-
...hasTlsOptions(tlsOptions) ? { proxyTls: { ...tlsOptions } } : {}
|
|
240
|
+
allowPrivateProxy: true,
|
|
241
|
+
mode: "explicit-proxy",
|
|
242
|
+
proxyUrl: agent.proxy.toString(),
|
|
243
|
+
...hasTlsOptions(tlsOptions) ? { proxyTls: tlsOptions } : {}
|
|
295
244
|
},
|
|
296
245
|
init: nextInit
|
|
297
246
|
};
|
|
298
|
-
|
|
247
|
+
return {
|
|
299
248
|
dispatcherPolicy: {
|
|
300
|
-
|
|
301
|
-
|
|
249
|
+
mode: "direct",
|
|
250
|
+
...hasTlsOptions(tlsOptions) ? { connect: tlsOptions } : {}
|
|
302
251
|
},
|
|
303
252
|
init: nextInit
|
|
304
253
|
};
|
|
305
|
-
return { init: nextInit };
|
|
306
254
|
}
|
|
307
255
|
async function googleAuthFetch(input, init) {
|
|
308
256
|
const url = input instanceof Request ? input.url : String(input);
|
|
@@ -347,18 +295,14 @@ async function loadGoogleAuthRuntime() {
|
|
|
347
295
|
}
|
|
348
296
|
async function getGoogleAuthTransport() {
|
|
349
297
|
const { gaxios } = await loadGoogleAuthRuntime();
|
|
350
|
-
|
|
351
|
-
transport.interceptors.request.add({ resolved: async (config) => normalizeGoogleAuthHeaders(config) });
|
|
352
|
-
transport.interceptors.response.add({ resolved: async (response) => normalizeGoogleAuthHeaders(response) });
|
|
353
|
-
return transport;
|
|
298
|
+
return new gaxios.Gaxios({ fetchImplementation: googleAuthFetch });
|
|
354
299
|
}
|
|
355
300
|
async function resolveValidatedGoogleChatCredentials(account) {
|
|
356
301
|
if (account.credentials) return validateGoogleChatServiceAccountCredentials(account.credentials);
|
|
357
302
|
if (account.credentialsFile) return validateGoogleChatServiceAccountCredentials(await readCredentialsFile(account.credentialsFile));
|
|
358
303
|
return null;
|
|
359
304
|
}
|
|
360
|
-
|
|
361
|
-
//#region extensions/googlechat/src/auth.ts
|
|
305
|
+
// extensions/googlechat/src/auth.ts
|
|
362
306
|
const CHAT_SCOPE = "https://www.googleapis.com/auth/chat.bot";
|
|
363
307
|
const CHAT_ISSUER = "chat@system.gserviceaccount.com";
|
|
364
308
|
const ADDON_ISSUER_PATTERN = /^service-\d+@gcp-sa-gsuiteaddons\.iam\.gserviceaccount\.com$/;
|
|
@@ -485,8 +429,7 @@ async function verifyGoogleChatRequest(params) {
|
|
|
485
429
|
};
|
|
486
430
|
}
|
|
487
431
|
}
|
|
488
|
-
|
|
489
|
-
//#region extensions/googlechat/src/api.ts
|
|
432
|
+
// extensions/googlechat/src/api.ts
|
|
490
433
|
const CHAT_API_BASE = "https://chat.googleapis.com/v1";
|
|
491
434
|
const GOOGLECHAT_API_TIMEOUT_MS = 3e4;
|
|
492
435
|
const GOOGLECHAT_MEDIA_TIMEOUT_GRACE_MS = 3e4;
|
|
@@ -495,7 +438,6 @@ const GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS = 9e5;
|
|
|
495
438
|
const GOOGLECHAT_RESPONSE_READ_IDLE_TIMEOUT_MS = 3e4;
|
|
496
439
|
const GOOGLECHAT_JSON_RESPONSE_MAX_BYTES = 16777216;
|
|
497
440
|
const GOOGLECHAT_ERROR_BODY_MAX_BYTES = 16384;
|
|
498
|
-
const GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES = 20971520;
|
|
499
441
|
var GoogleChatApiError = class extends Error {
|
|
500
442
|
constructor(status, message) {
|
|
501
443
|
super(message);
|
|
@@ -504,7 +446,6 @@ var GoogleChatApiError = class extends Error {
|
|
|
504
446
|
}
|
|
505
447
|
};
|
|
506
448
|
function resolveGoogleChatMediaTimeoutMs(maxBytes) {
|
|
507
|
-
if (!maxBytes) return GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS;
|
|
508
449
|
const transferMs = Math.ceil(maxBytes / GOOGLECHAT_MEDIA_MIN_BYTES_PER_SECOND * 1e3);
|
|
509
450
|
return Math.min(GOOGLECHAT_MEDIA_TIMEOUT_GRACE_MS + transferMs, GOOGLECHAT_MEDIA_MAX_TIMEOUT_MS);
|
|
510
451
|
}
|
|
@@ -567,14 +508,13 @@ async function fetchJson(account, url, init, hooks) {
|
|
|
567
508
|
});
|
|
568
509
|
}
|
|
569
510
|
async function downloadGoogleChatMedia(params) {
|
|
570
|
-
const { account, resourceName, maxBytes
|
|
511
|
+
const { account, resourceName, maxBytes } = params;
|
|
571
512
|
return await withGoogleChatResponse({
|
|
572
513
|
account,
|
|
573
514
|
url: `${CHAT_API_BASE}/media/${resourceName}?alt=media`,
|
|
574
515
|
auditContext: "googlechat.api.buffer",
|
|
575
|
-
timeoutMs: resolveGoogleChatMediaTimeoutMs(
|
|
516
|
+
timeoutMs: resolveGoogleChatMediaTimeoutMs(maxBytes),
|
|
576
517
|
handleResponse: async (res) => {
|
|
577
|
-
const maxBytes = requestedMaxBytes ?? GOOGLE_CHAT_MEDIA_RESPONSE_MAX_BYTES;
|
|
578
518
|
const lengthHeader = res.headers.get("content-length");
|
|
579
519
|
if (lengthHeader) {
|
|
580
520
|
const length = parseMediaContentLength(lengthHeader);
|
|
@@ -644,7 +584,7 @@ async function findGoogleChatDirectMessage(params) {
|
|
|
644
584
|
return await fetchJson(account, url.toString(), { method: "GET" }, { assertDirectAdapterHandoff: params.assertDirectAdapterHandoff });
|
|
645
585
|
}
|
|
646
586
|
async function getGoogleChatSpace(params) {
|
|
647
|
-
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 });
|
|
648
588
|
}
|
|
649
589
|
async function probeGoogleChat(account) {
|
|
650
590
|
try {
|
|
@@ -659,8 +599,7 @@ async function probeGoogleChat(account) {
|
|
|
659
599
|
};
|
|
660
600
|
}
|
|
661
601
|
}
|
|
662
|
-
|
|
663
|
-
//#region extensions/googlechat/src/targets.ts
|
|
602
|
+
// extensions/googlechat/src/targets.ts
|
|
664
603
|
function normalizeGoogleChatTarget(raw) {
|
|
665
604
|
const trimmed = raw?.trim();
|
|
666
605
|
if (!trimmed) return;
|
|
@@ -722,7 +661,8 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
|
|
|
722
661
|
});
|
|
723
662
|
const resolvedSpace = await resolveGoogleChatOutboundSpaceDetails({
|
|
724
663
|
account,
|
|
725
|
-
target: params.target
|
|
664
|
+
target: params.target,
|
|
665
|
+
assertDirectAdapterHandoff: params.assertDirectAdapterHandoff
|
|
726
666
|
});
|
|
727
667
|
const spaceName = resolvedSpace.name;
|
|
728
668
|
if (!isGoogleChatSpaceTarget(spaceName)) return null;
|
|
@@ -730,7 +670,8 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
|
|
|
730
670
|
if (!chatType) try {
|
|
731
671
|
chatType = resolveGoogleChatSpaceChatType(await getGoogleChatSpace({
|
|
732
672
|
account,
|
|
733
|
-
spaceName
|
|
673
|
+
spaceName,
|
|
674
|
+
assertDirectAdapterHandoff: params.assertDirectAdapterHandoff
|
|
734
675
|
}));
|
|
735
676
|
} catch {
|
|
736
677
|
return null;
|
|
@@ -751,8 +692,7 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
|
|
|
751
692
|
to: spaceName
|
|
752
693
|
});
|
|
753
694
|
}
|
|
754
|
-
|
|
755
|
-
//#region extensions/googlechat/src/format.ts
|
|
695
|
+
// extensions/googlechat/src/format.ts
|
|
756
696
|
const GOOGLE_CHAT_FORMAT_PROFILE = FormatCapabilityProfile.define({
|
|
757
697
|
mechanism: "markdown",
|
|
758
698
|
constructs: {
|
|
@@ -782,247 +722,241 @@ const GOOGLE_CHAT_LITERAL_FALLBACKS = /* @__PURE__ */ new Map([
|
|
|
782
722
|
["-", "-"],
|
|
783
723
|
["|", "|"]
|
|
784
724
|
]);
|
|
785
|
-
function createGoogleChatMarkers(text) {
|
|
786
|
-
const used = /* @__PURE__ */ new Set();
|
|
787
|
-
let candidate = 0;
|
|
788
|
-
const rangeSize = 6400;
|
|
789
|
-
const nextMarker = () => {
|
|
790
|
-
while (true) {
|
|
791
|
-
const marker = String.fromCharCode(57344 + Math.floor(candidate / rangeSize), 57344 + candidate % rangeSize);
|
|
792
|
-
candidate += 1;
|
|
793
|
-
if (!used.has(marker) && !text.includes(marker)) {
|
|
794
|
-
used.add(marker);
|
|
795
|
-
return marker;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
return {
|
|
800
|
-
list: nextMarker(),
|
|
801
|
-
blockquoteOpen: nextMarker(),
|
|
802
|
-
blockquoteClose: nextMarker()
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
725
|
/** Removes unsafe HTML and internal scaffolding while retaining source Markdown for chunking. */
|
|
806
726
|
function sanitizeGoogleChatText(text) {
|
|
807
727
|
return sanitizeForPlainText(sanitizeAssistantVisibleText(text), { style: "markdown" });
|
|
808
728
|
}
|
|
809
|
-
function
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
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");
|
|
815
740
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
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)}`;
|
|
829
758
|
}
|
|
830
|
-
|
|
759
|
+
return !unsafe;
|
|
760
|
+
});
|
|
761
|
+
ir = styles.length === ir.styles.length ? ir : {
|
|
762
|
+
...ir,
|
|
763
|
+
styles,
|
|
764
|
+
text: codeText
|
|
765
|
+
};
|
|
831
766
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
text:
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
let characters;
|
|
839
|
-
for (const item of ir.listItems ?? []) {
|
|
840
|
-
const marker = item.listMarker;
|
|
841
|
-
if (item.kind !== "bullet" || !marker || marker.end !== marker.start + 2 || ir.text[marker.start] !== "•" || ir.text[marker.start + 1] !== " ") continue;
|
|
842
|
-
characters ??= ir.text.split("");
|
|
843
|
-
characters[marker.start] = markerToken[0] ?? "";
|
|
844
|
-
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
|
+
};
|
|
845
773
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
return !unsafe;
|
|
861
|
-
});
|
|
862
|
-
return styles.length === ir.styles.length ? ir : {
|
|
863
|
-
...ir,
|
|
864
|
-
styles,
|
|
865
|
-
text
|
|
866
|
-
};
|
|
867
|
-
}
|
|
868
|
-
function projectGoogleChatPlainLiterals(ir) {
|
|
869
|
-
const codeRanges = ir.styles.filter((span) => span.style === "code" || span.style === "code_block");
|
|
870
|
-
const inCode = (index) => codeRanges.some((span) => index >= span.start && index < span.end);
|
|
871
|
-
const inLink = (index) => ir.links.some((span) => index >= span.start && index < span.end);
|
|
872
|
-
const styleDelimiter = /* @__PURE__ */ new Map([
|
|
873
|
-
["~", "strikethrough"],
|
|
874
|
-
["_", "italic"],
|
|
875
|
-
["*", "bold"],
|
|
876
|
-
["`", "code"]
|
|
877
|
-
]);
|
|
878
|
-
const characters = ir.text.split("");
|
|
879
|
-
let lineStart = 0;
|
|
880
|
-
while (lineStart < characters.length) {
|
|
881
|
-
const nextNewline = characters.indexOf("\n", lineStart);
|
|
882
|
-
const lineEnd = nextNewline < 0 ? characters.length : nextNewline;
|
|
883
|
-
for (const delimiter of [
|
|
884
|
-
"~",
|
|
885
|
-
"_",
|
|
886
|
-
"*",
|
|
887
|
-
"`"
|
|
888
|
-
]) {
|
|
889
|
-
const indexes = [];
|
|
890
|
-
for (let index = lineStart; index < lineEnd; index += 1) if (characters[index] === delimiter && !inCode(index) && !inLink(index)) indexes.push(index);
|
|
891
|
-
if (indexes.length === 0) continue;
|
|
892
|
-
const renderedStyle = styleDelimiter.get(delimiter);
|
|
893
|
-
const lineAddsDelimiter = ir.styles.some((span) => span.style === renderedStyle && span.start < lineEnd && span.end > lineStart);
|
|
894
|
-
if (indexes.length >= 2 || lineAddsDelimiter) for (const index of indexes) characters[index] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(delimiter) ?? delimiter;
|
|
895
|
-
}
|
|
896
|
-
let firstTextIndex = lineStart;
|
|
897
|
-
while (firstTextIndex < lineEnd && characters[firstTextIndex] === " ") firstTextIndex += 1;
|
|
898
|
-
if (!inCode(firstTextIndex)) {
|
|
899
|
-
const character = characters[firstTextIndex];
|
|
900
|
-
if ((character === "*" || character === "-") && characters[firstTextIndex + 1] === " " || character === ">") characters[firstTextIndex] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character;
|
|
901
|
-
}
|
|
902
|
-
const line = characters.slice(lineStart, lineEnd).join("");
|
|
903
|
-
for (const match of line.matchAll(/<[^<>\n]*\|[^<>\n]*>/gu)) {
|
|
904
|
-
const open = lineStart + (match.index ?? 0);
|
|
905
|
-
const close = open + match[0].length - 1;
|
|
906
|
-
if (!inCode(open) && !inCode(close) && !inLink(open) && !inLink(close)) {
|
|
907
|
-
characters[open] = "<";
|
|
908
|
-
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
|
+
}
|
|
909
788
|
}
|
|
910
789
|
}
|
|
911
|
-
|
|
790
|
+
ir = changed ? {
|
|
791
|
+
...ir,
|
|
792
|
+
text: characters.join("")
|
|
793
|
+
} : ir;
|
|
912
794
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
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;
|
|
943
839
|
}
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
840
|
+
const literalText = characters.join("");
|
|
841
|
+
ir = literalText === ir.text ? ir : {
|
|
842
|
+
...ir,
|
|
843
|
+
text: literalText
|
|
844
|
+
};
|
|
948
845
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
})))));
|
|
959
|
-
const markers = createGoogleChatMarkers(ir.text);
|
|
960
|
-
return {
|
|
961
|
-
ir: markGoogleChatBulletLists(ir, markers.list),
|
|
962
|
-
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
|
+
}
|
|
963
855
|
};
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
close: "~"
|
|
979
|
-
},
|
|
980
|
-
code: {
|
|
981
|
-
open: "`",
|
|
982
|
-
close: "`"
|
|
983
|
-
},
|
|
984
|
-
code_block: {
|
|
985
|
-
open: "```\n",
|
|
986
|
-
close: "```"
|
|
987
|
-
},
|
|
988
|
-
blockquote: {
|
|
989
|
-
open: markers.blockquoteOpen,
|
|
990
|
-
close: markers.blockquoteClose
|
|
991
|
-
}
|
|
992
|
-
},
|
|
993
|
-
escapeText: (value) => value,
|
|
994
|
-
buildLink: (link, value, context) => {
|
|
995
|
-
if (context.origin === "linkify") return null;
|
|
996
|
-
const href = link.href.trim();
|
|
997
|
-
const label = value.slice(link.start, link.end);
|
|
998
|
-
if (!href || !label) return null;
|
|
999
|
-
const labelHasStyles = ir.styles.some((span) => span.start < link.end && span.end > link.start);
|
|
1000
|
-
return /[<>|]/u.test(href) || /[<>|*_~`]/u.test(label) || labelHasStyles ? {
|
|
1001
|
-
start: link.end,
|
|
1002
|
-
end: link.end,
|
|
1003
|
-
open: "",
|
|
1004
|
-
close: ` (${href})`
|
|
1005
|
-
} : {
|
|
1006
|
-
start: link.start,
|
|
1007
|
-
end: link.end,
|
|
1008
|
-
open: `<${href}|`,
|
|
1009
|
-
close: ">"
|
|
1010
|
-
};
|
|
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] ?? "";
|
|
1011
870
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
871
|
+
ir = characters ? {
|
|
872
|
+
...ir,
|
|
873
|
+
text: characters.join("")
|
|
874
|
+
} : ir;
|
|
875
|
+
}
|
|
1017
876
|
return renderMarkdownIRChunksWithinLimit({
|
|
1018
|
-
ir
|
|
877
|
+
ir,
|
|
1019
878
|
limit: Math.min(limit, GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit),
|
|
1020
879
|
measureRendered: (rendered) => Buffer.byteLength(rendered, "utf8"),
|
|
1021
|
-
renderChunk: (
|
|
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
|
+
}
|
|
1022
957
|
}).map((chunk) => chunk.rendered);
|
|
1023
958
|
}
|
|
1024
|
-
|
|
1025
|
-
//#region extensions/googlechat/src/group-policy.ts
|
|
959
|
+
// extensions/googlechat/src/group-policy.ts
|
|
1026
960
|
function buildGoogleChatGroupPolicyScope(params) {
|
|
1027
961
|
const matchKey = params.groupId && Object.hasOwn(params.tree.scopes, params.groupId) ? params.groupId : void 0;
|
|
1028
962
|
return {
|
|
@@ -1037,41 +971,36 @@ function resolveGoogleChatGroupRequireMention(params) {
|
|
|
1037
971
|
groupId: params.groupId
|
|
1038
972
|
}));
|
|
1039
973
|
}
|
|
1040
|
-
|
|
1041
|
-
//#region extensions/googlechat/src/ingress-identity.ts
|
|
974
|
+
// extensions/googlechat/src/ingress-identity.ts
|
|
1042
975
|
function normalizeGoogleChatUserId(raw) {
|
|
1043
976
|
const trimmed = normalizeOptionalString(raw) ?? "";
|
|
1044
977
|
return normalizeLowercaseStringOrEmpty(trimmed.replace(/^users\//i, ""));
|
|
1045
978
|
}
|
|
1046
|
-
const GOOGLECHAT_EMAIL_KIND = "plugin:googlechat-email";
|
|
1047
|
-
function normalizeGoogleChatStableEntry(entry) {
|
|
1048
|
-
const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
|
|
1049
|
-
if (!withoutProvider) return null;
|
|
1050
|
-
return withoutProvider.startsWith("users/") ? normalizeGoogleChatUserId(withoutProvider) : withoutProvider;
|
|
1051
|
-
}
|
|
1052
|
-
function normalizeGoogleChatEmailEntry(entry) {
|
|
1053
|
-
const withoutProvider = normalizeLowercaseStringOrEmpty(entry).replace(/^(googlechat|google-chat|gchat):/i, "");
|
|
1054
|
-
if (withoutProvider.startsWith("users/")) return null;
|
|
1055
|
-
return withoutProvider.includes("@") ? withoutProvider : null;
|
|
1056
|
-
}
|
|
1057
979
|
const googleChatIngressIdentity = defineStableChannelIngressIdentity({
|
|
1058
980
|
key: "sender-id",
|
|
1059
981
|
authentication: "verified",
|
|
1060
|
-
normalizeEntry
|
|
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
|
+
},
|
|
1061
987
|
normalizeSubject: normalizeGoogleChatUserId,
|
|
1062
988
|
aliases: [{
|
|
1063
989
|
key: "email",
|
|
1064
|
-
kind:
|
|
1065
|
-
normalizeEntry
|
|
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
|
+
},
|
|
1066
996
|
normalizeSubject: normalizeLowercaseStringOrEmpty,
|
|
1067
997
|
authentication: "mutable"
|
|
1068
998
|
}],
|
|
1069
999
|
isWildcardEntry: (entry) => normalizeLowercaseStringOrEmpty(entry) === "*",
|
|
1070
1000
|
resolveEntryId: ({ entryIndex, fieldKey }) => fieldKey === "stableId" ? `entry-${entryIndex + 1}:user` : `entry-${entryIndex + 1}:${fieldKey}`
|
|
1071
1001
|
});
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-uaSH6k2d.mjs"), "googleChatChannelRuntime");
|
|
1002
|
+
// extensions/googlechat/src/channel.adapters.ts
|
|
1003
|
+
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-CBwK8353.mjs"), "googleChatChannelRuntime");
|
|
1075
1004
|
const collectGoogleChatGroupPolicyWarnings = createAllowlistProviderOpenWarningCollector({
|
|
1076
1005
|
providerConfigPresent: (cfg) => cfg.channels?.googlechat !== void 0,
|
|
1077
1006
|
resolveGroupPolicy: (account) => account.config.groupPolicy,
|
|
@@ -1164,7 +1093,15 @@ const googlechatOutboundAdapter = {
|
|
|
1164
1093
|
chunkerMode: "markdown",
|
|
1165
1094
|
textChunkLimit: GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit,
|
|
1166
1095
|
sanitizeText: ({ text }) => sanitizeGoogleChatText(text),
|
|
1167
|
-
normalizePayload: ({ 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
|
+
},
|
|
1168
1105
|
resolveTarget: ({ to }) => {
|
|
1169
1106
|
const normalized = normalizeGoogleChatTarget(to);
|
|
1170
1107
|
return normalized ? {
|
|
@@ -1221,10 +1158,10 @@ const googlechatMessageAdapter = defineChannelMessageAdapter({
|
|
|
1221
1158
|
id: "googlechat",
|
|
1222
1159
|
durableFinal: { capabilities: {
|
|
1223
1160
|
text: true,
|
|
1161
|
+
media: true,
|
|
1224
1162
|
thread: true,
|
|
1225
1163
|
messageSendingHooks: true
|
|
1226
1164
|
} },
|
|
1227
1165
|
send: { text: googlechatOutboundAdapter.attachedResults.sendText }
|
|
1228
1166
|
});
|
|
1229
|
-
|
|
1230
|
-
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 };
|