@openclaw/googlechat 2026.7.2-beta.2 → 2026.7.2-beta.4
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/{actions-B4nbMjmi.js → actions-DBF3ImbA.js} +5 -5
- package/dist/api.js +2 -2
- package/dist/{approval-auth-B2m8ckdj.js → approval-auth-BztBRceh.js} +3 -3
- package/dist/{approval-handler.runtime-DH6QCsS8.js → approval-handler.runtime-CWoYapMp.js} +4 -4
- package/dist/{channel-CST-JKw9.js → channel-DMP6V9MO.js} +18 -17
- package/dist/{channel-base-fY2AAQj5.js → channel-base-BOLIr2sb.js} +138 -49
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.adapters-Dhy4lV4f.js → channel.adapters-X7Hlcajj.js} +305 -18
- package/dist/{channel.runtime-CE5zWkzP.js → channel.runtime-rGazhnxA.js} +306 -124
- package/dist/directory-contract-api.js +1 -1
- package/dist/{doctor-contract-CvhD0eoX.js → doctor-contract-CWlBAcKf.js} +38 -61
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{runtime-api-1v-DgldF.js → runtime-api-Dh0CNVS4.js} +1 -2
- package/dist/runtime-api.js +2 -2
- package/dist/{secret-contract-D__4IIu_.js → secret-contract-BFYyuE0F.js} +21 -25
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/gaxios/build/cjs/src/gaxios.js +1 -1
- package/node_modules/gaxios/build/cjs/src/gaxios.js.map +1 -1
- package/node_modules/gaxios/build/cjs/test/test.getch.js +66 -0
- package/node_modules/gaxios/build/cjs/test/test.getch.js.map +1 -1
- package/node_modules/gaxios/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/node_modules/gaxios/build/esm/src/gaxios.js +1 -1
- package/node_modules/gaxios/build/esm/src/gaxios.js.map +1 -1
- package/node_modules/gaxios/build/esm/test/test.getch.js +66 -0
- package/node_modules/gaxios/build/esm/test/test.getch.js.map +1 -1
- package/node_modules/gaxios/build/esm/tsconfig.tsbuildinfo +1 -1
- package/node_modules/gaxios/package.json +4 -4
- package/node_modules/google-logging-utils/build/src/colours.d.ts +1 -29
- package/node_modules/google-logging-utils/build/src/colours.js +13 -13
- package/node_modules/google-logging-utils/build/src/colours.js.map +1 -1
- package/node_modules/google-logging-utils/build/src/index.d.ts +1 -0
- package/node_modules/google-logging-utils/build/src/index.js +1 -1
- package/node_modules/google-logging-utils/build/src/index.js.map +1 -1
- package/node_modules/google-logging-utils/build/src/logging-utils.d.ts +2 -135
- package/node_modules/google-logging-utils/build/src/logging-utils.js +35 -58
- package/node_modules/google-logging-utils/build/src/logging-utils.js.map +1 -1
- package/node_modules/google-logging-utils/build/src/temporal.js +8 -8
- package/node_modules/google-logging-utils/build/src/temporal.js.map +1 -1
- package/node_modules/google-logging-utils/build/src/types.d.ts +78 -0
- package/node_modules/google-logging-utils/build/src/types.js +16 -0
- package/node_modules/google-logging-utils/build/src/types.js.map +1 -0
- package/node_modules/google-logging-utils/package.json +11 -9
- package/npm-shrinkwrap.json +9 -9
- package/openclaw.plugin.json +403 -499
- package/package.json +81 -22
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { l as resolveGoogleChatAccount, r as formatGoogleChatAllowFromEntry } from "./channel-base-
|
|
2
|
-
import { d as fetchWithSsrFGuard$1,
|
|
1
|
+
import { l as resolveGoogleChatAccount, r as formatGoogleChatAllowFromEntry, u as MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES } from "./channel-base-BOLIr2sb.js";
|
|
2
|
+
import { d as fetchWithSsrFGuard$1, m as missingTargetError, r as PAIRING_APPROVED_MESSAGE } from "./runtime-api-Dh0CNVS4.js";
|
|
3
3
|
import { buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/channel-core";
|
|
4
4
|
import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
|
|
5
5
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
+
import { resolveUserPath } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
6
7
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
7
8
|
import { parseMediaContentLength, readResponseTextSnippet } from "openclaw/plugin-sdk/media-runtime";
|
|
8
9
|
import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
@@ -11,9 +12,8 @@ import crypto from "node:crypto";
|
|
|
11
12
|
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
12
13
|
import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
13
14
|
import { createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
|
|
14
|
-
import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
15
|
+
import { markdownToIR, renderMarkdownIRChunksWithinLimit, renderMarkdownWithMarkers, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
15
16
|
import fs from "node:fs/promises";
|
|
16
|
-
import { resolveUserPath } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
17
17
|
import { adaptScopedAccountAccessor } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
18
18
|
import { buildChannelGroupsScopeTree, composeAccountWarningCollectors, createAllowlistProviderOpenWarningCollector, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
19
19
|
import { createChannelDirectoryAdapter, listResolvedDirectoryGroupEntriesFromMapKeys, listResolvedDirectoryUserEntriesFromAllowFrom } from "openclaw/plugin-sdk/directory-runtime";
|
|
@@ -175,7 +175,6 @@ const GOOGLE_AUTH_TOKEN_URI = "https://oauth2.googleapis.com/token";
|
|
|
175
175
|
const GOOGLE_AUTH_UNIVERSE_DOMAIN = "googleapis.com";
|
|
176
176
|
const GOOGLE_CLIENT_CERTS_URL_PREFIX = "https://www.googleapis.com/robot/v1/metadata/x509/";
|
|
177
177
|
const MAX_GOOGLE_AUTH_RESPONSE_BYTES = 1024 * 1024;
|
|
178
|
-
const MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES = 64 * 1024;
|
|
179
178
|
let googleAuthRuntimePromise = null;
|
|
180
179
|
function normalizeGoogleAuthPreparedRequestHeaders(config) {
|
|
181
180
|
if (!(config.headers instanceof Headers)) config.headers = new Headers(config.headers);
|
|
@@ -318,14 +317,14 @@ async function readCredentialsFile(filePath) {
|
|
|
318
317
|
try {
|
|
319
318
|
const stat = await handle.stat();
|
|
320
319
|
if (!stat.isFile()) throw new Error("Google Chat service account file must be a regular file.");
|
|
321
|
-
if (stat.size >
|
|
320
|
+
if (stat.size > 65536) throw new Error(`Google Chat service account file exceeds ${MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES} bytes.`);
|
|
322
321
|
let raw;
|
|
323
322
|
try {
|
|
324
323
|
raw = await handle.readFile({ encoding: "utf8" });
|
|
325
324
|
} catch {
|
|
326
325
|
throw new Error("Failed to load Google Chat service account file.");
|
|
327
326
|
}
|
|
328
|
-
if (Buffer.byteLength(raw, "utf8") >
|
|
327
|
+
if (Buffer.byteLength(raw, "utf8") > 65536) throw new Error(`Google Chat service account file exceeds ${MAX_GOOGLE_CHAT_SERVICE_ACCOUNT_FILE_BYTES} bytes.`);
|
|
329
328
|
let parsed;
|
|
330
329
|
try {
|
|
331
330
|
parsed = JSON.parse(raw);
|
|
@@ -533,7 +532,10 @@ async function fetchChatCerts() {
|
|
|
533
532
|
timeoutMs: GOOGLECHAT_CERT_FETCH_TIMEOUT_MS
|
|
534
533
|
});
|
|
535
534
|
try {
|
|
536
|
-
if (!response.ok)
|
|
535
|
+
if (!response.ok) {
|
|
536
|
+
await response.body?.cancel().catch(() => void 0);
|
|
537
|
+
throw new Error(`Failed to fetch Chat certs (${response.status})`);
|
|
538
|
+
}
|
|
537
539
|
const certs = await readGoogleChatCertsResponse(response);
|
|
538
540
|
cachedCerts = {
|
|
539
541
|
fetchedAt: now,
|
|
@@ -865,6 +867,291 @@ async function resolveGoogleChatOutboundSessionRoute(params) {
|
|
|
865
867
|
});
|
|
866
868
|
}
|
|
867
869
|
//#endregion
|
|
870
|
+
//#region extensions/googlechat/src/format.ts
|
|
871
|
+
const GOOGLE_CHAT_FORMAT_PROFILE = {
|
|
872
|
+
mechanism: "markdown",
|
|
873
|
+
constructs: {
|
|
874
|
+
bold: "native",
|
|
875
|
+
italic: "native",
|
|
876
|
+
underline: "fallback",
|
|
877
|
+
strikethrough: "native",
|
|
878
|
+
spoiler: "fallback",
|
|
879
|
+
codeInline: "native",
|
|
880
|
+
codeBlock: "native",
|
|
881
|
+
codeLanguage: "fallback",
|
|
882
|
+
linkLabel: "native",
|
|
883
|
+
heading: "fallback",
|
|
884
|
+
bulletList: "native",
|
|
885
|
+
orderedList: "fallback",
|
|
886
|
+
taskList: "fallback",
|
|
887
|
+
table: "fallback",
|
|
888
|
+
blockquote: "native",
|
|
889
|
+
image: "fallback",
|
|
890
|
+
mention: "strip"
|
|
891
|
+
},
|
|
892
|
+
chunk: {
|
|
893
|
+
limit: 32e3,
|
|
894
|
+
unit: "bytes"
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
const GOOGLE_CHAT_LITERAL_FALLBACKS = /* @__PURE__ */ new Map([
|
|
898
|
+
["*", "*"],
|
|
899
|
+
["_", "_"],
|
|
900
|
+
["~", "~"],
|
|
901
|
+
["`", "`"],
|
|
902
|
+
["<", "<"],
|
|
903
|
+
[">", ">"],
|
|
904
|
+
["\\", "\"],
|
|
905
|
+
["-", "-"],
|
|
906
|
+
["|", "|"]
|
|
907
|
+
]);
|
|
908
|
+
function createPrivateMarkerGenerator(text) {
|
|
909
|
+
const used = /* @__PURE__ */ new Set();
|
|
910
|
+
let candidate = 0;
|
|
911
|
+
const rangeSize = 6400;
|
|
912
|
+
return () => {
|
|
913
|
+
while (true) {
|
|
914
|
+
const marker = String.fromCharCode(57344 + Math.floor(candidate / rangeSize), 57344 + candidate % rangeSize);
|
|
915
|
+
candidate += 1;
|
|
916
|
+
if (!used.has(marker) && !text.includes(marker)) {
|
|
917
|
+
used.add(marker);
|
|
918
|
+
return marker;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function createGoogleChatMarkers(text) {
|
|
924
|
+
const nextMarker = createPrivateMarkerGenerator(text);
|
|
925
|
+
return {
|
|
926
|
+
list: nextMarker(),
|
|
927
|
+
blockquoteOpen: nextMarker(),
|
|
928
|
+
blockquoteClose: nextMarker()
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
/** Removes unsafe HTML and internal scaffolding while retaining source Markdown for chunking. */
|
|
932
|
+
function sanitizeGoogleChatText(text) {
|
|
933
|
+
return sanitizeForPlainText(sanitizeAssistantVisibleText(text), { style: "markdown" });
|
|
934
|
+
}
|
|
935
|
+
function projectDecodedGoogleChatResources(ir) {
|
|
936
|
+
const characters = ir.text.split("");
|
|
937
|
+
let changed = false;
|
|
938
|
+
for (const match of ir.text.matchAll(/<(?:users|customEmojis)\/[^<>\s]+>/giu)) {
|
|
939
|
+
const start = match.index ?? 0;
|
|
940
|
+
characters[start] = "<";
|
|
941
|
+
characters[start + match[0].length - 1] = ">";
|
|
942
|
+
changed = true;
|
|
943
|
+
}
|
|
944
|
+
return changed ? {
|
|
945
|
+
...ir,
|
|
946
|
+
text: characters.join("")
|
|
947
|
+
} : ir;
|
|
948
|
+
}
|
|
949
|
+
function projectGoogleChatLinkLabels(ir) {
|
|
950
|
+
const characters = ir.text.split("");
|
|
951
|
+
let changed = false;
|
|
952
|
+
for (const link of ir.links) {
|
|
953
|
+
const label = ir.text.slice(link.start, link.end);
|
|
954
|
+
const comparableHref = link.href.startsWith("mailto:") ? link.href.slice(7) : link.href;
|
|
955
|
+
if (label === link.href || label === comparableHref) continue;
|
|
956
|
+
for (let index = link.start; index < link.end; index += 1) {
|
|
957
|
+
const character = characters[index] ?? "";
|
|
958
|
+
const fallback = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character);
|
|
959
|
+
if (fallback && /[<>|*_~`]/u.test(character)) {
|
|
960
|
+
characters[index] = fallback;
|
|
961
|
+
changed = true;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return changed ? {
|
|
966
|
+
...ir,
|
|
967
|
+
text: characters.join("")
|
|
968
|
+
} : ir;
|
|
969
|
+
}
|
|
970
|
+
function markGoogleChatBulletLists(ir, markerToken) {
|
|
971
|
+
let text = ir.text;
|
|
972
|
+
for (const item of ir.listItems ?? []) {
|
|
973
|
+
const marker = item.listMarker;
|
|
974
|
+
if (item.kind !== "bullet" || !marker || text.slice(marker.start, marker.end) !== "• ") continue;
|
|
975
|
+
text = `${text.slice(0, marker.start)}${markerToken}${text.slice(marker.end)}`;
|
|
976
|
+
}
|
|
977
|
+
return text === ir.text ? ir : {
|
|
978
|
+
...ir,
|
|
979
|
+
text
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
function projectUnsafeCodeFallbacks(ir) {
|
|
983
|
+
let text = ir.text;
|
|
984
|
+
const styles = ir.styles.filter((span) => {
|
|
985
|
+
const content = ir.text.slice(span.start, span.end);
|
|
986
|
+
const unsafe = span.style === "code" && content.includes("`") || span.style === "code_block" && content.includes("```");
|
|
987
|
+
if (unsafe) {
|
|
988
|
+
const replacement = content.split("").map((character) => GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character).join("");
|
|
989
|
+
text = `${text.slice(0, span.start)}${replacement}${text.slice(span.end)}`;
|
|
990
|
+
}
|
|
991
|
+
return !unsafe;
|
|
992
|
+
});
|
|
993
|
+
return styles.length === ir.styles.length ? ir : {
|
|
994
|
+
...ir,
|
|
995
|
+
styles,
|
|
996
|
+
text
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
function projectGoogleChatPlainLiterals(ir) {
|
|
1000
|
+
const codeRanges = ir.styles.filter((span) => span.style === "code" || span.style === "code_block");
|
|
1001
|
+
const inCode = (index) => codeRanges.some((span) => index >= span.start && index < span.end);
|
|
1002
|
+
const inLink = (index) => ir.links.some((span) => index >= span.start && index < span.end);
|
|
1003
|
+
const styleDelimiter = /* @__PURE__ */ new Map([
|
|
1004
|
+
["~", "strikethrough"],
|
|
1005
|
+
["_", "italic"],
|
|
1006
|
+
["*", "bold"],
|
|
1007
|
+
["`", "code"]
|
|
1008
|
+
]);
|
|
1009
|
+
const characters = ir.text.split("");
|
|
1010
|
+
let lineStart = 0;
|
|
1011
|
+
while (lineStart < characters.length) {
|
|
1012
|
+
const nextNewline = characters.indexOf("\n", lineStart);
|
|
1013
|
+
const lineEnd = nextNewline < 0 ? characters.length : nextNewline;
|
|
1014
|
+
for (const delimiter of [
|
|
1015
|
+
"~",
|
|
1016
|
+
"_",
|
|
1017
|
+
"*",
|
|
1018
|
+
"`"
|
|
1019
|
+
]) {
|
|
1020
|
+
const indexes = [];
|
|
1021
|
+
for (let index = lineStart; index < lineEnd; index += 1) if (characters[index] === delimiter && !inCode(index) && !inLink(index)) indexes.push(index);
|
|
1022
|
+
if (indexes.length === 0) continue;
|
|
1023
|
+
const renderedStyle = styleDelimiter.get(delimiter);
|
|
1024
|
+
const lineAddsDelimiter = ir.styles.some((span) => span.style === renderedStyle && span.start < lineEnd && span.end > lineStart);
|
|
1025
|
+
if (indexes.length >= 2 || lineAddsDelimiter) for (const index of indexes) characters[index] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(delimiter) ?? delimiter;
|
|
1026
|
+
}
|
|
1027
|
+
let firstTextIndex = lineStart;
|
|
1028
|
+
while (firstTextIndex < lineEnd && characters[firstTextIndex] === " ") firstTextIndex += 1;
|
|
1029
|
+
if (firstTextIndex >= lineStart && !inCode(firstTextIndex)) {
|
|
1030
|
+
const character = characters[firstTextIndex];
|
|
1031
|
+
if ((character === "*" || character === "-") && characters[firstTextIndex + 1] === " " || character === ">") characters[firstTextIndex] = GOOGLE_CHAT_LITERAL_FALLBACKS.get(character) ?? character;
|
|
1032
|
+
}
|
|
1033
|
+
const line = characters.slice(lineStart, lineEnd).join("");
|
|
1034
|
+
for (const match of line.matchAll(/<[^<>\n]*\|[^<>\n]*>/gu)) {
|
|
1035
|
+
const open = lineStart + (match.index ?? 0);
|
|
1036
|
+
const close = open + match[0].length - 1;
|
|
1037
|
+
if (!inCode(open) && !inCode(close) && !inLink(open) && !inLink(close)) {
|
|
1038
|
+
characters[open] = "<";
|
|
1039
|
+
characters[close] = ">";
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
lineStart = lineEnd + 1;
|
|
1043
|
+
}
|
|
1044
|
+
const text = characters.join("");
|
|
1045
|
+
return text === ir.text ? ir : {
|
|
1046
|
+
...ir,
|
|
1047
|
+
text
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
function emitGoogleChatLists(text, markerToken) {
|
|
1051
|
+
return text.split("\n").map((line) => {
|
|
1052
|
+
const markerIndex = line.indexOf(markerToken);
|
|
1053
|
+
if (markerIndex < 0) return line;
|
|
1054
|
+
const prefix = line.slice(0, markerIndex);
|
|
1055
|
+
const quote = /^(?:> )*/u.exec(prefix)?.[0] ?? "";
|
|
1056
|
+
const indent = prefix.slice(quote.length);
|
|
1057
|
+
return `${quote}${" ".repeat(indent.length * 2)}* ${line.slice(markerIndex + markerToken.length)}`;
|
|
1058
|
+
}).join("\n");
|
|
1059
|
+
}
|
|
1060
|
+
function emitGoogleChatBlockquotes(text, markers) {
|
|
1061
|
+
let depth = 0;
|
|
1062
|
+
let lineStart = true;
|
|
1063
|
+
let rendered = "";
|
|
1064
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
1065
|
+
if (text.startsWith(markers.blockquoteOpen, index)) {
|
|
1066
|
+
depth += 1;
|
|
1067
|
+
index += markers.blockquoteOpen.length - 1;
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
if (text.startsWith(markers.blockquoteClose, index)) {
|
|
1071
|
+
depth = Math.max(0, depth - 1);
|
|
1072
|
+
index += markers.blockquoteClose.length - 1;
|
|
1073
|
+
continue;
|
|
1074
|
+
}
|
|
1075
|
+
const character = text[index] ?? "";
|
|
1076
|
+
if (lineStart && depth > 0) rendered += "> ".repeat(depth);
|
|
1077
|
+
rendered += character;
|
|
1078
|
+
lineStart = character === "\n";
|
|
1079
|
+
}
|
|
1080
|
+
return rendered;
|
|
1081
|
+
}
|
|
1082
|
+
function prepareGoogleChatIR(text) {
|
|
1083
|
+
const ir = projectGoogleChatPlainLiterals(projectGoogleChatLinkLabels(projectDecodedGoogleChatResources(projectUnsafeCodeFallbacks(markdownToIR(sanitizeGoogleChatText(text), {
|
|
1084
|
+
enableSpoilers: true,
|
|
1085
|
+
enableTaskLists: true,
|
|
1086
|
+
headingStyle: "rich",
|
|
1087
|
+
tableMode: "bullets"
|
|
1088
|
+
})))));
|
|
1089
|
+
const markers = createGoogleChatMarkers(ir.text);
|
|
1090
|
+
return {
|
|
1091
|
+
ir: markGoogleChatBulletLists(ir, markers.list),
|
|
1092
|
+
markers
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
function renderGoogleChatIR(ir, markers) {
|
|
1096
|
+
return emitGoogleChatLists(emitGoogleChatBlockquotes(renderMarkdownWithMarkers(ir, {
|
|
1097
|
+
styleMarkers: {
|
|
1098
|
+
bold: {
|
|
1099
|
+
open: "*",
|
|
1100
|
+
close: "*"
|
|
1101
|
+
},
|
|
1102
|
+
italic: {
|
|
1103
|
+
open: "_",
|
|
1104
|
+
close: "_"
|
|
1105
|
+
},
|
|
1106
|
+
strikethrough: {
|
|
1107
|
+
open: "~",
|
|
1108
|
+
close: "~"
|
|
1109
|
+
},
|
|
1110
|
+
code: {
|
|
1111
|
+
open: "`",
|
|
1112
|
+
close: "`"
|
|
1113
|
+
},
|
|
1114
|
+
code_block: {
|
|
1115
|
+
open: "```\n",
|
|
1116
|
+
close: "```"
|
|
1117
|
+
},
|
|
1118
|
+
blockquote: {
|
|
1119
|
+
open: markers.blockquoteOpen,
|
|
1120
|
+
close: markers.blockquoteClose
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
escapeText: (value) => value,
|
|
1124
|
+
buildLink: (link, value, context) => {
|
|
1125
|
+
if (context.origin === "linkify") return null;
|
|
1126
|
+
const href = link.href.trim();
|
|
1127
|
+
const label = value.slice(link.start, link.end);
|
|
1128
|
+
if (!href || !label) return null;
|
|
1129
|
+
const labelHasStyles = ir.styles.some((span) => span.start < link.end && span.end > link.start);
|
|
1130
|
+
return /[<>|]/u.test(href) || /[<>|*_~`]/u.test(label) || labelHasStyles ? {
|
|
1131
|
+
start: link.start,
|
|
1132
|
+
end: link.end,
|
|
1133
|
+
open: "",
|
|
1134
|
+
close: ` (${href})`
|
|
1135
|
+
} : {
|
|
1136
|
+
start: link.start,
|
|
1137
|
+
end: link.end,
|
|
1138
|
+
open: `<${href}|`,
|
|
1139
|
+
close: ">"
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
}, GOOGLE_CHAT_FORMAT_PROFILE), markers), markers.list);
|
|
1143
|
+
}
|
|
1144
|
+
/** Renders CommonMark into byte-bounded Google Chat app-message chunks. */
|
|
1145
|
+
function formatGoogleChatTextChunks(text, limit = GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit) {
|
|
1146
|
+
const prepared = prepareGoogleChatIR(text);
|
|
1147
|
+
return renderMarkdownIRChunksWithinLimit({
|
|
1148
|
+
ir: prepared.ir,
|
|
1149
|
+
limit: Math.min(limit, GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit),
|
|
1150
|
+
measureRendered: (rendered) => new TextEncoder().encode(rendered).byteLength,
|
|
1151
|
+
renderChunk: (chunk) => renderGoogleChatIR(chunk, prepared.markers)
|
|
1152
|
+
}).map((chunk) => chunk.rendered);
|
|
1153
|
+
}
|
|
1154
|
+
//#endregion
|
|
868
1155
|
//#region extensions/googlechat/src/group-policy.ts
|
|
869
1156
|
function buildGoogleChatGroupPolicyScope(params) {
|
|
870
1157
|
const matchKey = params.groupId && Object.hasOwn(params.tree.scopes, params.groupId) ? params.groupId : void 0;
|
|
@@ -882,7 +1169,7 @@ function resolveGoogleChatGroupRequireMention(params) {
|
|
|
882
1169
|
}
|
|
883
1170
|
//#endregion
|
|
884
1171
|
//#region extensions/googlechat/src/channel.adapters.ts
|
|
885
|
-
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-
|
|
1172
|
+
const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-rGazhnxA.js"), "googleChatChannelRuntime");
|
|
886
1173
|
function createGoogleChatSendReceipt(params) {
|
|
887
1174
|
const messageId = params.messageId?.trim();
|
|
888
1175
|
return createMessageReceiptFromOutboundResults({
|
|
@@ -904,13 +1191,13 @@ const collectGoogleChatSecurityWarnings = composeAccountWarningCollectors(create
|
|
|
904
1191
|
openBehavior: "allows any space to trigger (mention-gated)",
|
|
905
1192
|
remediation: "Set channels.googlechat.groupPolicy=\"allowlist\" and configure channels.googlechat.groups"
|
|
906
1193
|
}
|
|
907
|
-
}), (account) => account.config.
|
|
1194
|
+
}), (account) => account.config.dmPolicy === "open" && "- Google Chat DMs are open to anyone. Set channels.googlechat.dmPolicy=\"pairing\" or \"allowlist\".");
|
|
908
1195
|
const googlechatGroupsAdapter = { resolveRequireMention: resolveGoogleChatGroupRequireMention };
|
|
909
1196
|
const googlechatDirectoryAdapter = createChannelDirectoryAdapter({
|
|
910
1197
|
listPeers: async (params) => listResolvedDirectoryUserEntriesFromAllowFrom({
|
|
911
1198
|
...params,
|
|
912
1199
|
resolveAccount: adaptScopedAccountAccessor(resolveGoogleChatAccount),
|
|
913
|
-
resolveAllowFrom: (account) => account.config.
|
|
1200
|
+
resolveAllowFrom: (account) => account.config.allowFrom,
|
|
914
1201
|
normalizeId: (entry) => normalizeGoogleChatTarget(entry) ?? entry
|
|
915
1202
|
}),
|
|
916
1203
|
listGroups: async (params) => listResolvedDirectoryGroupEntriesFromMapKeys({
|
|
@@ -922,9 +1209,9 @@ const googlechatDirectoryAdapter = createChannelDirectoryAdapter({
|
|
|
922
1209
|
const googlechatSecurityAdapter = {
|
|
923
1210
|
dm: {
|
|
924
1211
|
channelKey: "googlechat",
|
|
925
|
-
resolvePolicy: (account) => account.config.
|
|
926
|
-
resolveAllowFrom: (account) => account.config.
|
|
927
|
-
allowFromPathSuffix: "
|
|
1212
|
+
resolvePolicy: (account) => account.config.dmPolicy,
|
|
1213
|
+
resolveAllowFrom: (account) => account.config.allowFrom,
|
|
1214
|
+
allowFromPathSuffix: "",
|
|
928
1215
|
normalizeEntry: (raw) => formatGoogleChatAllowFromEntry(raw)
|
|
929
1216
|
},
|
|
930
1217
|
collectWarnings: collectGoogleChatSecurityWarnings
|
|
@@ -962,7 +1249,7 @@ const googlechatPairingTextAdapter = {
|
|
|
962
1249
|
cfg,
|
|
963
1250
|
accountId
|
|
964
1251
|
});
|
|
965
|
-
if (account.credentialSource === "none") return;
|
|
1252
|
+
if (account.credentialSource === "none" || account.tokenStatus === "configured_unavailable") return;
|
|
966
1253
|
const user = normalizeGoogleChatTarget(id) ?? id;
|
|
967
1254
|
const space = await resolveGoogleChatOutboundSpace({
|
|
968
1255
|
account,
|
|
@@ -979,10 +1266,10 @@ const googlechatPairingTextAdapter = {
|
|
|
979
1266
|
const googlechatOutboundAdapter = {
|
|
980
1267
|
base: {
|
|
981
1268
|
deliveryMode: "direct",
|
|
982
|
-
chunker:
|
|
1269
|
+
chunker: (text, limit) => formatGoogleChatTextChunks(text, limit),
|
|
983
1270
|
chunkerMode: "markdown",
|
|
984
|
-
textChunkLimit:
|
|
985
|
-
sanitizeText: ({ text }) =>
|
|
1271
|
+
textChunkLimit: GOOGLE_CHAT_FORMAT_PROFILE.chunk.limit,
|
|
1272
|
+
sanitizeText: ({ text }) => sanitizeGoogleChatText(text),
|
|
986
1273
|
normalizePayload: ({ payload }) => shouldSuppressGoogleChatManualExecApprovalFollowupPayload(payload) ? null : payload,
|
|
987
1274
|
resolveTarget: ({ to }) => {
|
|
988
1275
|
const trimmed = normalizeOptionalString(to) ?? "";
|