@openclaw/googlechat 2026.10.10 → 2026.11.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{actions-uo0lf5AI.mjs → actions-DNDmJvwi.mjs} +15 -13
- package/dist/.setup/{approval-auth-CKF1wHai.mjs → approval-auth-AkJ2Rg0h.mjs} +2 -2
- package/dist/.setup/{approval-handler.runtime-wYtTR6as.mjs → approval-handler.runtime-CKuHeY6y.mjs} +3 -3
- package/dist/.setup/{channel-ZbGyNgH9.mjs → channel-WKI4stP3.mjs} +78 -87
- package/dist/.setup/{channel-base-BFV0cGQ2.mjs → channel-base-DjVHuLDF.mjs} +13 -14
- package/dist/.setup/{channel.adapters-5rr8crHQ.mjs → channel.adapters-C9mflxGl.mjs} +262 -316
- package/dist/.setup/{channel.runtime-DkrekcGA.mjs → channel.runtime-CBwK8353.mjs} +295 -335
- 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-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- 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-Dru1eW9z.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,14 +1,16 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { n as googleChatApprovalAuth } from "./approval-auth-
|
|
1
|
+
import { C as sendGoogleChatMessage, O as googleChatApprovalControls, S as probeGoogleChat, T as verifyGoogleChatRequest, b as deleteGoogleChatMessage, c as googleChatIngressIdentity, d as formatGoogleChatMediaText, f as formatGoogleChatTextChunks, k as readGoogleChatApprovalActionToken, l as normalizeGoogleChatUserId, p as isGoogleChatGroupSpace, u as buildGoogleChatGroupPolicyScope, w as updateGoogleChatMessage, x as downloadGoogleChatMedia, y as GoogleChatApiError } from "./channel.adapters-C9mflxGl.mjs";
|
|
2
|
+
import { n as googleChatApprovalAuth } from "./approval-auth-AkJ2Rg0h.mjs";
|
|
3
3
|
import { t as getGoogleChatRuntime } from "./runtime-zEzHA5rr.mjs";
|
|
4
4
|
import { n as escapeGoogleChatApprovalCardText, t as buildGoogleChatApprovalTextWidget } from "./approval-card-text-9o-Dfr9Z.mjs";
|
|
5
|
+
import { createChannelIngressError } from "openclaw/plugin-sdk/channel-outbound";
|
|
6
|
+
import { channelBlockedPatch, channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
5
7
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
8
|
import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";
|
|
7
9
|
import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
8
10
|
import { MediaFetchError } from "openclaw/plugin-sdk/media-runtime";
|
|
11
|
+
import { formatApprovalDecisionLabel } from "openclaw/plugin-sdk/approval-runtime";
|
|
9
12
|
import { channelIngressRoutes, createStandardRawEventIngressMonitor } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
10
|
-
import {
|
|
11
|
-
import { channelBlockedPatch, channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
13
|
+
import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
12
14
|
import { isRecord as isRecord$1 } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
13
15
|
import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
14
16
|
import { createChannelInboundEnvelopeBuilderAsync, createChannelPartialDeliveryError, formatInboundMediaUnavailableText, recordChannelBotPairLoopAndCheckSuppression, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
@@ -20,19 +22,13 @@ import { resolveApprovalOverGateway } from "openclaw/plugin-sdk/approval-gateway
|
|
|
20
22
|
import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
|
|
21
23
|
import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
|
|
22
24
|
import { GROUP_POLICY_BLOCKED_LABEL, resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
23
|
-
import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
24
25
|
import { createWebhookInFlightLimiter, readJsonWebhookBodyOrReject, runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
25
26
|
import { registerWebhookTargetWithPluginRoute, resolveWebhookTargetWithAuthOrReject, withResolvedWebhookRequestPipeline } from "openclaw/plugin-sdk/webhook-targets";
|
|
26
|
-
// extensions/googlechat/src/approval-
|
|
27
|
+
// extensions/googlechat/src/approval-card-click.ts
|
|
27
28
|
const GOOGLECHAT_APPROVAL_CARD_ID = "openclaw-approval";
|
|
28
29
|
function formatCanonicalOutcome(approval) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
case "denied": return "Denied";
|
|
32
|
-
case "expired": return "Expired";
|
|
33
|
-
case "cancelled": return "Cancelled";
|
|
34
|
-
}
|
|
35
|
-
return "Unavailable";
|
|
30
|
+
if (approval.status === "allowed" || approval.status === "denied") return formatApprovalDecisionLabel(approval.decision);
|
|
31
|
+
return approval.status === "expired" ? "Expired" : approval.status === "cancelled" ? "Cancelled" : "Unavailable";
|
|
36
32
|
}
|
|
37
33
|
function buildSubjectSection(presentation) {
|
|
38
34
|
if (presentation.kind === "exec") return {
|
|
@@ -46,31 +42,6 @@ function buildSubjectSection(presentation) {
|
|
|
46
42
|
widgets: [buildGoogleChatApprovalTextWidget(requestText, "html")]
|
|
47
43
|
};
|
|
48
44
|
}
|
|
49
|
-
/** Render the canonical first-answer result without retaining any actionable buttons. */
|
|
50
|
-
function buildGoogleChatCanonicalApprovalTerminalCards(result) {
|
|
51
|
-
const { approval } = result;
|
|
52
|
-
const kindLabel = approval.presentation.kind === "plugin" ? "Plugin" : "Exec";
|
|
53
|
-
const detailLines = [
|
|
54
|
-
`<b>Approval ID:</b> ${escapeGoogleChatApprovalCardText(JSON.stringify(approval.id).slice(1, -1))}`,
|
|
55
|
-
`<b>Status:</b> ${escapeGoogleChatApprovalCardText(approval.status)}`,
|
|
56
|
-
...approval.status === "allowed" || approval.status === "denied" ? [`<b>Decision:</b> ${escapeGoogleChatApprovalCardText(approval.decision)}`] : [],
|
|
57
|
-
`<b>Reason:</b> ${escapeGoogleChatApprovalCardText(approval.reason)}`
|
|
58
|
-
];
|
|
59
|
-
return [{
|
|
60
|
-
cardId: GOOGLECHAT_APPROVAL_CARD_ID,
|
|
61
|
-
card: {
|
|
62
|
-
header: {
|
|
63
|
-
title: `${kindLabel} Approval: ${formatCanonicalOutcome(approval)}`,
|
|
64
|
-
subtitle: result.applied ? "Resolved by this action" : "Already resolved"
|
|
65
|
-
},
|
|
66
|
-
sections: [buildSubjectSection(approval.presentation), {
|
|
67
|
-
header: "Details",
|
|
68
|
-
widgets: [buildGoogleChatApprovalTextWidget(detailLines.join("<br>"), "html")]
|
|
69
|
-
}]
|
|
70
|
-
}
|
|
71
|
-
}];
|
|
72
|
-
}
|
|
73
|
-
// extensions/googlechat/src/approval-card-click.ts
|
|
74
45
|
function logIgnored(target, message) {
|
|
75
46
|
target.runtime.log?.(`[${target.account.accountId}] googlechat approval ignored: ${message}`);
|
|
76
47
|
}
|
|
@@ -120,10 +91,30 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
|
|
|
120
91
|
accountId: params.target.account.accountId,
|
|
121
92
|
senderId: actor
|
|
122
93
|
});
|
|
94
|
+
const { approval } = result;
|
|
95
|
+
const kindLabel = approval.presentation.kind === "plugin" ? "Plugin" : "Exec";
|
|
96
|
+
const detailLines = [
|
|
97
|
+
`<b>Approval ID:</b> ${escapeGoogleChatApprovalCardText(JSON.stringify(approval.id).slice(1, -1))}`,
|
|
98
|
+
`<b>Status:</b> ${escapeGoogleChatApprovalCardText(approval.status)}`,
|
|
99
|
+
...approval.status === "allowed" || approval.status === "denied" ? [`<b>Decision:</b> ${escapeGoogleChatApprovalCardText(approval.decision)}`] : [],
|
|
100
|
+
`<b>Reason:</b> ${escapeGoogleChatApprovalCardText(approval.reason)}`
|
|
101
|
+
];
|
|
123
102
|
await updateGoogleChatMessage({
|
|
124
103
|
account: params.target.account,
|
|
125
104
|
messageName: consumed.messageName,
|
|
126
|
-
cardsV2:
|
|
105
|
+
cardsV2: [{
|
|
106
|
+
cardId: GOOGLECHAT_APPROVAL_CARD_ID,
|
|
107
|
+
card: {
|
|
108
|
+
header: {
|
|
109
|
+
title: `${kindLabel} Approval: ${formatCanonicalOutcome(approval)}`,
|
|
110
|
+
subtitle: result.applied ? "Resolved by this action" : "Already resolved"
|
|
111
|
+
},
|
|
112
|
+
sections: [buildSubjectSection(approval.presentation), {
|
|
113
|
+
header: "Details",
|
|
114
|
+
widgets: [buildGoogleChatApprovalTextWidget(detailLines.join("<br>"), "html")]
|
|
115
|
+
}]
|
|
116
|
+
}
|
|
117
|
+
}]
|
|
127
118
|
});
|
|
128
119
|
return result;
|
|
129
120
|
});
|
|
@@ -138,36 +129,6 @@ async function maybeHandleGoogleChatApprovalCardClick(params) {
|
|
|
138
129
|
return true;
|
|
139
130
|
}
|
|
140
131
|
// extensions/googlechat/src/monitor-access.ts
|
|
141
|
-
function resolveGoogleChatGroupConfig(params) {
|
|
142
|
-
const { groupId, groupName, groups } = params;
|
|
143
|
-
const entries = groups ?? {};
|
|
144
|
-
const keys = Object.keys(entries);
|
|
145
|
-
if (keys.length === 0) return {
|
|
146
|
-
entry: void 0,
|
|
147
|
-
allowlistConfigured: false,
|
|
148
|
-
deprecatedNameMatch: false
|
|
149
|
-
};
|
|
150
|
-
const { "*": fallback, ...scopes } = entries;
|
|
151
|
-
const scope = buildGoogleChatGroupPolicyScope({
|
|
152
|
-
tree: {
|
|
153
|
-
defaults: fallback,
|
|
154
|
-
scopes
|
|
155
|
-
},
|
|
156
|
-
groupId
|
|
157
|
-
});
|
|
158
|
-
const entry = scope.matchKey ? entries[scope.matchKey] : void 0;
|
|
159
|
-
const normalizedGroupName = normalizeLowercaseStringOrEmpty(groupName ?? "");
|
|
160
|
-
const deprecatedNameMatch = !entry && Boolean(groupName && keys.some((key) => {
|
|
161
|
-
const trimmed = key.trim();
|
|
162
|
-
if (!trimmed || trimmed === "*" || /^spaces\//i.test(trimmed)) return false;
|
|
163
|
-
return trimmed === groupName || normalizeLowercaseStringOrEmpty(trimmed) === normalizedGroupName;
|
|
164
|
-
}));
|
|
165
|
-
return {
|
|
166
|
-
entry: deprecatedNameMatch ? void 0 : entry ?? fallback,
|
|
167
|
-
allowlistConfigured: true,
|
|
168
|
-
deprecatedNameMatch
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
132
|
function extractMentionInfo(annotations, botUser) {
|
|
172
133
|
const mentionAnnotations = annotations.filter((entry) => entry.type === "USER_MENTION");
|
|
173
134
|
const hasAnyMention = mentionAnnotations.length > 0;
|
|
@@ -184,21 +145,15 @@ function extractMentionInfo(annotations, botUser) {
|
|
|
184
145
|
}
|
|
185
146
|
const warnedDeprecatedUsersEmailAllowFrom = /* @__PURE__ */ new Set();
|
|
186
147
|
const warnedMutableGroupKeys = /* @__PURE__ */ new Set();
|
|
148
|
+
function markDeprecatedEntriesWarning(entries, warned) {
|
|
149
|
+
const key = entries.map((entry) => normalizeLowercaseStringOrEmpty(entry)).toSorted((a, b) => a.localeCompare(b)).join(",");
|
|
150
|
+
if (entries.length === 0 || warned.has(key)) return false;
|
|
151
|
+
warned.add(key);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
187
154
|
function warnDeprecatedUsersEmailEntries(logVerbose, entries) {
|
|
188
155
|
const deprecated = normalizeTrimmedStringList(entries).filter((v) => /^users\/.+@.+/i.test(v));
|
|
189
|
-
if (deprecated.
|
|
190
|
-
const key = deprecated.map((v) => normalizeLowercaseStringOrEmpty(v)).toSorted((a, b) => a.localeCompare(b)).join(",");
|
|
191
|
-
if (warnedDeprecatedUsersEmailAllowFrom.has(key)) return;
|
|
192
|
-
warnedDeprecatedUsersEmailAllowFrom.add(key);
|
|
193
|
-
logVerbose(`Deprecated allowFrom entry detected: "users/<email>" is no longer treated as an email allowlist. Use raw email (alice@example.com) or immutable user id (users/<id>). entries=${deprecated.join(", ")}`);
|
|
194
|
-
}
|
|
195
|
-
function warnMutableGroupKeysConfigured(logVerbose, groups) {
|
|
196
|
-
const mutableKeys = Object.keys(groups ?? {}).map((key) => key.trim()).filter((key) => key && key !== "*" && !/^spaces\//i.test(key));
|
|
197
|
-
if (mutableKeys.length === 0) return;
|
|
198
|
-
const warningKey = mutableKeys.map((key) => normalizeLowercaseStringOrEmpty(key)).toSorted((a, b) => a.localeCompare(b)).join(",");
|
|
199
|
-
if (warnedMutableGroupKeys.has(warningKey)) return;
|
|
200
|
-
warnedMutableGroupKeys.add(warningKey);
|
|
201
|
-
logVerbose(`Deprecated Google Chat group key detected: group routing now requires stable space ids (spaces/<spaceId>). Update channels.googlechat.groups keys: ${mutableKeys.join(", ")}`);
|
|
156
|
+
if (markDeprecatedEntriesWarning(deprecated, warnedDeprecatedUsersEmailAllowFrom)) logVerbose(`Deprecated allowFrom entry detected: "users/<email>" is no longer treated as an email allowlist. Use raw email (alice@example.com) or immutable user id (users/<id>). entries=${deprecated.join(", ")}`);
|
|
202
157
|
}
|
|
203
158
|
async function applyGoogleChatInboundAccessPolicy(params) {
|
|
204
159
|
const { account, config, core, space, message, isGroup, senderId, senderName, senderEmail, rawBody, statusSink, logVerbose } = params;
|
|
@@ -222,12 +177,39 @@ async function applyGoogleChatInboundAccessPolicy(params) {
|
|
|
222
177
|
blockedLabel: GROUP_POLICY_BLOCKED_LABEL.space,
|
|
223
178
|
log: logVerbose
|
|
224
179
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
180
|
+
const mutableKeys = Object.keys(account.config.groups ?? {}).map((key) => key.trim()).filter((key) => key && key !== "*" && !/^spaces\//i.test(key));
|
|
181
|
+
if (markDeprecatedEntriesWarning(mutableKeys, warnedMutableGroupKeys)) logVerbose(`Deprecated Google Chat group key detected: group routing now requires stable space ids (spaces/<spaceId>). Update channels.googlechat.groups keys: ${mutableKeys.join(", ")}`);
|
|
182
|
+
const groupName = space.displayName ?? null;
|
|
183
|
+
const groups = account.config.groups;
|
|
184
|
+
const groupConfigResolved = (() => {
|
|
185
|
+
const entries = groups ?? {};
|
|
186
|
+
const keys = Object.keys(entries);
|
|
187
|
+
if (keys.length === 0) return {
|
|
188
|
+
entry: void 0,
|
|
189
|
+
allowlistConfigured: false,
|
|
190
|
+
deprecatedNameMatch: false
|
|
191
|
+
};
|
|
192
|
+
const { "*": fallback, ...scopes } = entries;
|
|
193
|
+
const scope = buildGoogleChatGroupPolicyScope({
|
|
194
|
+
tree: {
|
|
195
|
+
defaults: fallback,
|
|
196
|
+
scopes
|
|
197
|
+
},
|
|
198
|
+
groupId: spaceId
|
|
199
|
+
});
|
|
200
|
+
const entry = scope.matchKey ? entries[scope.matchKey] : void 0;
|
|
201
|
+
const normalizedGroupName = normalizeLowercaseStringOrEmpty(groupName ?? "");
|
|
202
|
+
const deprecatedNameMatch = !entry && Boolean(groupName && keys.some((key) => {
|
|
203
|
+
const trimmed = key.trim();
|
|
204
|
+
if (!trimmed || trimmed === "*" || /^spaces\//i.test(trimmed)) return false;
|
|
205
|
+
return trimmed === groupName || normalizeLowercaseStringOrEmpty(trimmed) === normalizedGroupName;
|
|
206
|
+
}));
|
|
207
|
+
return {
|
|
208
|
+
entry: deprecatedNameMatch ? void 0 : entry ?? fallback,
|
|
209
|
+
allowlistConfigured: true,
|
|
210
|
+
deprecatedNameMatch
|
|
211
|
+
};
|
|
212
|
+
})();
|
|
231
213
|
const groupEntry = groupConfigResolved.entry;
|
|
232
214
|
const groupUsers = groupEntry?.users ?? account.config.groupAllowFrom ?? [];
|
|
233
215
|
let effectiveWasMentioned;
|
|
@@ -388,38 +370,10 @@ async function applyGoogleChatInboundAccessPolicy(params) {
|
|
|
388
370
|
groupSystemPrompt: normalizeOptionalString(groupEntry?.systemPrompt)
|
|
389
371
|
};
|
|
390
372
|
}
|
|
391
|
-
// extensions/googlechat/src/monitor-durable.ts
|
|
392
|
-
function resolveGoogleChatDurableReplyOptions(params) {
|
|
393
|
-
if (params.infoKind !== "final" || params.hasTypingMessage) return false;
|
|
394
|
-
const threadId = params.payload.replyToId?.trim() || void 0;
|
|
395
|
-
if (!threadId) return {
|
|
396
|
-
to: params.spaceId,
|
|
397
|
-
replyToId: null
|
|
398
|
-
};
|
|
399
|
-
return {
|
|
400
|
-
to: params.spaceId,
|
|
401
|
-
replyToId: threadId,
|
|
402
|
-
threadId
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
373
|
// extensions/googlechat/src/monitor-event.ts
|
|
406
|
-
var GoogleChatEventPayloadError = class extends Error {
|
|
407
|
-
constructor() {
|
|
408
|
-
super("invalid payload");
|
|
409
|
-
this.name = "GoogleChatEventPayloadError";
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
function recordParamsToActionParameters(params) {
|
|
413
|
-
if (!params) return;
|
|
414
|
-
const entries = Object.entries(params).filter((entry) => typeof entry[1] === "string").map(([key, value]) => ({
|
|
415
|
-
key,
|
|
416
|
-
value
|
|
417
|
-
}));
|
|
418
|
-
return entries.length > 0 ? entries : void 0;
|
|
419
|
-
}
|
|
420
374
|
/** Normalize only at authenticated dispatch; durable admission stores the untouched envelope. */
|
|
421
375
|
function parseGoogleChatInboundPayload(raw) {
|
|
422
|
-
if (!isRecord$1(raw)) throw new
|
|
376
|
+
if (!isRecord$1(raw)) throw new Error("invalid payload");
|
|
423
377
|
let eventPayload = raw;
|
|
424
378
|
const rawObj = raw;
|
|
425
379
|
const chat = rawObj.chat;
|
|
@@ -436,7 +390,12 @@ function parseGoogleChatInboundPayload(raw) {
|
|
|
436
390
|
const buttonClickedPayload = chatPayload?.buttonClickedPayload;
|
|
437
391
|
if (buttonClickedPayload) {
|
|
438
392
|
const invokedFunction = rawObj.commonEventObject.invokedFunction;
|
|
439
|
-
const
|
|
393
|
+
const parameters = rawObj.commonEventObject.parameters;
|
|
394
|
+
const entries = parameters ? Object.entries(parameters).filter((entry) => typeof entry[1] === "string").map(([key, value]) => ({
|
|
395
|
+
key,
|
|
396
|
+
value
|
|
397
|
+
})) : [];
|
|
398
|
+
const actionParameters = entries.length > 0 ? entries : void 0;
|
|
440
399
|
eventPayload = {
|
|
441
400
|
type: "CARD_CLICKED",
|
|
442
401
|
space: buttonClickedPayload.space,
|
|
@@ -456,10 +415,10 @@ function parseGoogleChatInboundPayload(raw) {
|
|
|
456
415
|
}
|
|
457
416
|
const event = eventPayload;
|
|
458
417
|
const eventType = event.type ?? event.eventType;
|
|
459
|
-
if (typeof eventType !== "string" || !isRecord$1(event.space)) throw new
|
|
418
|
+
if (typeof eventType !== "string" || !isRecord$1(event.space)) throw new Error("invalid payload");
|
|
460
419
|
if (eventType === "MESSAGE") {
|
|
461
|
-
if (!isRecord$1(event.message) || !event.space?.name?.trim() || !event.message?.name?.trim()) throw new
|
|
462
|
-
} else if (eventType === "CARD_CLICKED" && !isRecord$1(event.user)) throw new
|
|
420
|
+
if (!isRecord$1(event.message) || !event.space?.name?.trim() || !event.message?.name?.trim()) throw new Error("invalid payload");
|
|
421
|
+
} else if (eventType === "CARD_CLICKED" && !isRecord$1(event.user)) throw new Error("invalid payload");
|
|
463
422
|
return event;
|
|
464
423
|
}
|
|
465
424
|
// extensions/googlechat/src/monitor-ingress.ts
|
|
@@ -525,9 +484,7 @@ function createGoogleChatIngressMonitor(options) {
|
|
|
525
484
|
if (!isRecord$1(rawEvent)) throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope must be an object.");
|
|
526
485
|
const durableEvent = { ...rawEvent };
|
|
527
486
|
delete durableEvent.authorizationEventObject;
|
|
528
|
-
|
|
529
|
-
if (typeof serialized !== "string") throw new GoogleChatIngressPermanentError("invalid-event", "Google Chat webhook envelope cannot be serialized.");
|
|
530
|
-
return serialized;
|
|
487
|
+
return JSON.stringify(durableEvent);
|
|
531
488
|
};
|
|
532
489
|
return createStandardRawEventIngressMonitor({
|
|
533
490
|
queue: () => getGoogleChatRuntime().state.openChannelIngressQueue({ accountId: options.accountId }),
|
|
@@ -548,113 +505,6 @@ function createGoogleChatIngressMonitor(options) {
|
|
|
548
505
|
classifyAdmissionError: (error) => error instanceof GoogleChatIngressPermanentError ? error.message : void 0
|
|
549
506
|
});
|
|
550
507
|
}
|
|
551
|
-
// extensions/googlechat/src/monitor-reply-delivery.ts
|
|
552
|
-
function createGoogleChatTypingMessage(params) {
|
|
553
|
-
const name = params.messageName.trim();
|
|
554
|
-
const requestedThreadName = params.requestedThreadName?.trim();
|
|
555
|
-
if (!requestedThreadName) return {
|
|
556
|
-
placement: "top-level",
|
|
557
|
-
name
|
|
558
|
-
};
|
|
559
|
-
return {
|
|
560
|
-
placement: "thread",
|
|
561
|
-
name,
|
|
562
|
-
requestedThreadName,
|
|
563
|
-
deliveredThreadName: params.deliveredThreadName?.trim() || requestedThreadName
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
async function deliverGoogleChatReply(params) {
|
|
567
|
-
const { payload, account, spaceId, runtime, core, config, statusSink } = params;
|
|
568
|
-
let typingMessage = params.typingMessage;
|
|
569
|
-
const replyThreadName = payload.replyToId?.trim() || void 0;
|
|
570
|
-
const reply = resolveSendableOutboundReplyParts(payload);
|
|
571
|
-
let deliveryThreadName = replyThreadName;
|
|
572
|
-
const acceptedText = [];
|
|
573
|
-
const runTextOperation = async (operation) => await operation.catch((error) => {
|
|
574
|
-
if (acceptedText.length === 0) throw error;
|
|
575
|
-
throw createChannelPartialDeliveryError(error, {
|
|
576
|
-
messageIds: acceptedText.flatMap(({ id }) => id ? [id] : []),
|
|
577
|
-
content: acceptedText.map(({ text }) => text).join("\n"),
|
|
578
|
-
visibleReplySent: true
|
|
579
|
-
});
|
|
580
|
-
});
|
|
581
|
-
const typingMatchesReply = typingMessage?.placement === "thread" ? typingMessage.requestedThreadName === replyThreadName : typingMessage?.placement === "top-level" ? replyThreadName === void 0 : false;
|
|
582
|
-
if (typingMessage && !typingMatchesReply) {
|
|
583
|
-
try {
|
|
584
|
-
await deleteGoogleChatMessage({
|
|
585
|
-
account,
|
|
586
|
-
messageName: typingMessage.name
|
|
587
|
-
});
|
|
588
|
-
} catch (err) {
|
|
589
|
-
runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
|
|
590
|
-
}
|
|
591
|
-
typingMessage = void 0;
|
|
592
|
-
} else if (typingMessage?.placement === "thread") deliveryThreadName = typingMessage.deliveredThreadName;
|
|
593
|
-
if (reply.hasMedia) runtime.error?.("Google Chat outbound attachments require user OAuth and are not supported by this service-account channel; sending text fallback only.");
|
|
594
|
-
const chunkLimit = account.config.textChunkLimit ?? 4e3;
|
|
595
|
-
const chunkMode = core.channel.text.resolveChunkMode(config, "googlechat", account.accountId);
|
|
596
|
-
const chunks = formatGoogleChatTextChunks(reply.text, chunkLimit).flatMap((chunk) => core.channel.text.chunkMarkdownTextWithMode(chunk, chunkLimit, chunkMode));
|
|
597
|
-
const rejection = reply.hasMedia && !reply.hasText ? "Google Chat outbound attachments require user OAuth and no text fallback is available." : reply.hasText && !chunks.some((chunk) => chunk) ? "Google Chat reply has no visible text after formatting." : void 0;
|
|
598
|
-
if (rejection) {
|
|
599
|
-
try {
|
|
600
|
-
if (typingMessage) await deleteGoogleChatMessage({
|
|
601
|
-
account,
|
|
602
|
-
messageName: typingMessage.name
|
|
603
|
-
});
|
|
604
|
-
} catch (err) {
|
|
605
|
-
runtime.error?.(`Google Chat typing cleanup failed: ${String(err)}`);
|
|
606
|
-
}
|
|
607
|
-
throw new PlatformMessageNotDispatchedError(rejection, {
|
|
608
|
-
cause: void 0,
|
|
609
|
-
retryable: false
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
const recordOutboundStatus = () => {
|
|
613
|
-
try {
|
|
614
|
-
statusSink?.({ lastOutboundAt: Date.now() });
|
|
615
|
-
} catch (err) {
|
|
616
|
-
runtime.error?.(`Google Chat outbound status update failed: ${String(err)}`);
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
const sendTextMessage = async (chunk) => {
|
|
620
|
-
const sent = await runTextOperation(sendGoogleChatMessage({
|
|
621
|
-
account,
|
|
622
|
-
space: spaceId,
|
|
623
|
-
text: chunk,
|
|
624
|
-
thread: deliveryThreadName
|
|
625
|
-
}));
|
|
626
|
-
if (sent) acceptedText.push({
|
|
627
|
-
id: sent.messageName?.trim() || void 0,
|
|
628
|
-
text: chunk
|
|
629
|
-
});
|
|
630
|
-
if (replyThreadName) deliveryThreadName = sent?.threadName?.trim() || deliveryThreadName;
|
|
631
|
-
};
|
|
632
|
-
for (const chunk of chunks) {
|
|
633
|
-
if (!chunk) continue;
|
|
634
|
-
if (typingMessage) {
|
|
635
|
-
try {
|
|
636
|
-
const updated = await updateGoogleChatMessage({
|
|
637
|
-
account,
|
|
638
|
-
messageName: typingMessage.name,
|
|
639
|
-
text: chunk
|
|
640
|
-
});
|
|
641
|
-
acceptedText.push({
|
|
642
|
-
id: updated.messageName?.trim() || typingMessage.name,
|
|
643
|
-
text: chunk
|
|
644
|
-
});
|
|
645
|
-
} catch (error) {
|
|
646
|
-
if (!(error instanceof GoogleChatApiError) || error.status !== 404) throw error;
|
|
647
|
-
runtime.error?.(`Google Chat typing update failed: ${String(error)}`);
|
|
648
|
-
await sendTextMessage(chunk);
|
|
649
|
-
}
|
|
650
|
-
typingMessage = void 0;
|
|
651
|
-
recordOutboundStatus();
|
|
652
|
-
continue;
|
|
653
|
-
}
|
|
654
|
-
await sendTextMessage(chunk);
|
|
655
|
-
recordOutboundStatus();
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
508
|
// extensions/googlechat/src/monitor-reply-target.ts
|
|
659
509
|
/**
|
|
660
510
|
* Google Chat only accepts a thread resource (`spaces/x/threads/y`) as a reply
|
|
@@ -855,16 +705,23 @@ function registerGoogleChatWebhookTarget(target) {
|
|
|
855
705
|
}
|
|
856
706
|
// extensions/googlechat/src/monitor.ts
|
|
857
707
|
setGoogleChatWebhookEventProcessor(processGoogleChatEvent);
|
|
708
|
+
function createGoogleChatTypingMessage(params) {
|
|
709
|
+
const name = params.messageName.trim();
|
|
710
|
+
const requestedThreadName = params.requestedThreadName?.trim();
|
|
711
|
+
if (!requestedThreadName) return {
|
|
712
|
+
placement: "top-level",
|
|
713
|
+
name
|
|
714
|
+
};
|
|
715
|
+
return {
|
|
716
|
+
placement: "thread",
|
|
717
|
+
name,
|
|
718
|
+
requestedThreadName,
|
|
719
|
+
deliveredThreadName: params.deliveredThreadName?.trim() || requestedThreadName
|
|
720
|
+
};
|
|
721
|
+
}
|
|
858
722
|
function logVerbose(core, runtime, message) {
|
|
859
723
|
if (core.logging.shouldLogVerbose()) runtime.log?.(`[googlechat] ${message}`);
|
|
860
724
|
}
|
|
861
|
-
function resolveBotDisplayName(params) {
|
|
862
|
-
const { accountName, agentId, config } = params;
|
|
863
|
-
if (accountName?.trim()) return accountName.trim();
|
|
864
|
-
const agent = resolveAgentConfig(config, agentId);
|
|
865
|
-
if (agent?.name?.trim()) return agent.name.trim();
|
|
866
|
-
return agent?.identity?.name?.trim() || "OpenClaw";
|
|
867
|
-
}
|
|
868
725
|
async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, config = target.config) {
|
|
869
726
|
const eventType = event.type ?? event.eventType;
|
|
870
727
|
if (eventType === "CARD_CLICKED") {
|
|
@@ -885,7 +742,7 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
|
|
|
885
742
|
const sender = message.sender ?? event.user;
|
|
886
743
|
const senderId = sender?.name ?? "";
|
|
887
744
|
const senderName = sender?.displayName ?? "";
|
|
888
|
-
const senderEmail = sender?.email
|
|
745
|
+
const senderEmail = sender?.email;
|
|
889
746
|
const isBotSender = sender?.type?.toUpperCase() === "BOT";
|
|
890
747
|
const appUserId = account.config.botUser?.trim() || "users/app";
|
|
891
748
|
const allowBots = account.config.allowBots === true;
|
|
@@ -950,38 +807,28 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
|
|
|
950
807
|
}
|
|
951
808
|
}
|
|
952
809
|
const mediaInputs = attachments.map((attachment) => ({ contentType: attachment.contentType }));
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
path: attachmentData.path,
|
|
958
|
-
url: attachmentData.path,
|
|
959
|
-
contentType: attachmentData.contentType ?? first.contentType
|
|
960
|
-
};
|
|
961
|
-
else {
|
|
962
|
-
const notice = `[Google Chat attachment unavailable: ${first.driveDataRef ? "Google Drive files are not downloadable" : "unsupported attachment source"}; upload the file directly]`;
|
|
963
|
-
rawBody = formatInboundMediaUnavailableText({
|
|
964
|
-
body: rawBody,
|
|
965
|
-
notice
|
|
966
|
-
});
|
|
967
|
-
runtime.error?.(`[${account.accountId}] ${notice}`);
|
|
968
|
-
}
|
|
969
|
-
} catch (error) {
|
|
970
|
-
if (!(error instanceof MediaFetchError) || error.code !== "max_bytes") throw error;
|
|
971
|
-
const notice = `[Google Chat attachment too large; maximum ${mediaMaxMb} MB]`;
|
|
972
|
-
rawBody = formatInboundMediaUnavailableText({
|
|
973
|
-
body: rawBody,
|
|
974
|
-
notice
|
|
975
|
-
});
|
|
976
|
-
runtime.error?.(`[${account.accountId}] ${notice} Increase channels.googlechat.mediaMaxMb to process larger attachments.`);
|
|
977
|
-
}
|
|
978
|
-
const additionalCount = attachments.length - 1;
|
|
979
|
-
if (additionalCount > 0) {
|
|
980
|
-
const notice = `[Google Chat: ${additionalCount} additional ${additionalCount === 1 ? "attachment was" : "attachments were"} not processed; only the first attachment is supported]`;
|
|
810
|
+
const attachmentNotices = /* @__PURE__ */ new Set();
|
|
811
|
+
const reportAttachmentUnavailable = (notice, hint = "") => {
|
|
812
|
+
if (attachmentNotices.has(notice)) return;
|
|
813
|
+
attachmentNotices.add(notice);
|
|
981
814
|
rawBody = formatInboundMediaUnavailableText({
|
|
982
815
|
body: rawBody,
|
|
983
816
|
notice
|
|
984
817
|
});
|
|
818
|
+
runtime.error?.(`[${account.accountId}] ${notice}${hint}`);
|
|
819
|
+
};
|
|
820
|
+
for (const [index, attachment] of attachments.entries()) try {
|
|
821
|
+
const attachmentData = await downloadAttachment(attachment, account, mediaMaxMb, core);
|
|
822
|
+
if (attachmentData) mediaInputs[index] = {
|
|
823
|
+
path: attachmentData.path,
|
|
824
|
+
url: attachmentData.path,
|
|
825
|
+
contentType: attachmentData.contentType ?? attachment.contentType
|
|
826
|
+
};
|
|
827
|
+
else reportAttachmentUnavailable(`[Google Chat attachment unavailable: ${attachment.driveDataRef ? "Google Drive files are not downloadable" : "unsupported attachment source"}; upload the file directly]`);
|
|
828
|
+
} catch (error) {
|
|
829
|
+
const missing = error instanceof GoogleChatApiError && error.status === 404;
|
|
830
|
+
if (!missing && (!(error instanceof MediaFetchError) || error.code !== "max_bytes")) throw error;
|
|
831
|
+
reportAttachmentUnavailable(missing ? "[Google Chat attachment unavailable: file not found; upload the file directly]" : `[Google Chat attachment too large; maximum ${mediaMaxMb} MB]`, missing ? "" : " Increase channels.googlechat.mediaMaxMb to process larger attachments.");
|
|
985
832
|
}
|
|
986
833
|
const media = mediaInputs.length === 0 ? [] : await toInboundMediaFactsWithMetadata(mediaInputs);
|
|
987
834
|
const fromLabel = isGroup ? space.displayName || `space:${spaceId}` : senderName || `user:${senderId}`;
|
|
@@ -1040,7 +887,7 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
|
|
|
1040
887
|
WasMentioned: isGroup ? effectiveWasMentioned : void 0,
|
|
1041
888
|
CommandAuthorized: commandAuthorized,
|
|
1042
889
|
GroupSubject: void 0,
|
|
1043
|
-
GroupSpace: isGroup ? space.displayName
|
|
890
|
+
GroupSpace: isGroup ? space.displayName : void 0
|
|
1044
891
|
}
|
|
1045
892
|
});
|
|
1046
893
|
let typingIndicator = account.config.typingIndicator ?? "message";
|
|
@@ -1051,11 +898,14 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
|
|
|
1051
898
|
let typingMessage;
|
|
1052
899
|
const effectiveReplyThreadName = account.config.replyToMode && account.config.replyToMode !== "off" ? replyThreadName : void 0;
|
|
1053
900
|
if (typingIndicator === "message") try {
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
901
|
+
const accountName = account.config.name;
|
|
902
|
+
const agentId = route.agentId;
|
|
903
|
+
let botName;
|
|
904
|
+
if (accountName?.trim()) botName = accountName.trim();
|
|
905
|
+
else {
|
|
906
|
+
const agent = resolveAgentConfig(config, agentId);
|
|
907
|
+
botName = agent?.name?.trim() ? agent.name.trim() : agent?.identity?.name?.trim() || "OpenClaw";
|
|
908
|
+
}
|
|
1059
909
|
const result = await sendGoogleChatMessage({
|
|
1060
910
|
account,
|
|
1061
911
|
space: spaceId,
|
|
@@ -1070,76 +920,186 @@ async function processGoogleChatEvent(event, target, turnAdoptionLifecycle, conf
|
|
|
1070
920
|
} catch (err) {
|
|
1071
921
|
runtime.error?.(`Failed sending typing message: ${String(err)}`);
|
|
1072
922
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
923
|
+
const cleanupTypingMessage = async () => {
|
|
924
|
+
const placeholder = typingMessage;
|
|
925
|
+
typingMessage = void 0;
|
|
926
|
+
if (!placeholder) return;
|
|
927
|
+
try {
|
|
928
|
+
await deleteGoogleChatMessage({
|
|
929
|
+
account,
|
|
930
|
+
messageName: placeholder.name
|
|
931
|
+
});
|
|
932
|
+
} catch (error) {
|
|
933
|
+
runtime.error?.(`Google Chat typing cleanup failed: ${String(error)}`);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
let deferred = false;
|
|
937
|
+
const typingTurnLifecycle = typingMessage ? {
|
|
938
|
+
...turnAdoptionLifecycle,
|
|
939
|
+
onAdopted: () => turnAdoptionLifecycle?.onAdopted(),
|
|
940
|
+
onDeferred: () => {
|
|
941
|
+
turnAdoptionLifecycle?.onDeferred();
|
|
942
|
+
deferred = true;
|
|
943
|
+
},
|
|
944
|
+
onSettled: () => deferred ? cleanupTypingMessage() : void 0
|
|
945
|
+
} : turnAdoptionLifecycle;
|
|
946
|
+
try {
|
|
947
|
+
await core.channel.inbound.run({
|
|
948
|
+
channel: "googlechat",
|
|
949
|
+
accountId: route.accountId,
|
|
950
|
+
raw: message,
|
|
951
|
+
...typingTurnLifecycle ? { turnAdoptionLifecycle: typingTurnLifecycle } : {},
|
|
952
|
+
adapter: {
|
|
953
|
+
ingest: () => ({
|
|
954
|
+
id: message.name ?? spaceId,
|
|
955
|
+
timestamp: timestampMs,
|
|
956
|
+
rawText: rawBody,
|
|
957
|
+
textForAgent: rawBody,
|
|
958
|
+
textForCommands: rawBody,
|
|
959
|
+
raw: message
|
|
960
|
+
}),
|
|
961
|
+
resolveTurn: () => ({
|
|
962
|
+
cfg: config,
|
|
963
|
+
channel: "googlechat",
|
|
964
|
+
accountId: route.accountId,
|
|
965
|
+
route: {
|
|
966
|
+
agentId: route.agentId,
|
|
967
|
+
sessionKey: route.sessionKey
|
|
968
|
+
},
|
|
969
|
+
ctxPayload,
|
|
970
|
+
delivery: {
|
|
971
|
+
durable: (payload, info) => {
|
|
972
|
+
const normalizedPayload = normalizeGoogleChatReplyTarget({
|
|
1110
973
|
payload,
|
|
1111
974
|
sourceMessageName: message.name,
|
|
1112
975
|
replyThreadName: effectiveReplyThreadName
|
|
1113
|
-
})
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
976
|
+
});
|
|
977
|
+
if (info.kind !== "final" || Boolean(typingMessage)) return false;
|
|
978
|
+
const threadId = normalizedPayload.replyToId?.trim() || void 0;
|
|
979
|
+
if (!threadId) return {
|
|
980
|
+
to: spaceId,
|
|
981
|
+
replyToId: null
|
|
982
|
+
};
|
|
983
|
+
return {
|
|
984
|
+
to: spaceId,
|
|
985
|
+
replyToId: threadId,
|
|
986
|
+
threadId
|
|
987
|
+
};
|
|
988
|
+
},
|
|
989
|
+
deliver: async (payload) => {
|
|
990
|
+
const normalizedPayload = normalizeGoogleChatReplyTarget({
|
|
991
|
+
payload,
|
|
992
|
+
sourceMessageName: message.name,
|
|
993
|
+
replyThreadName: effectiveReplyThreadName
|
|
994
|
+
});
|
|
995
|
+
let deliveryTypingMessage = typingMessage;
|
|
996
|
+
const targetThreadName = normalizedPayload.replyToId?.trim() || void 0;
|
|
997
|
+
const reply = resolveSendableOutboundReplyParts(normalizedPayload);
|
|
998
|
+
let deliveryThreadName = targetThreadName;
|
|
999
|
+
const acceptedText = [];
|
|
1000
|
+
const runTextOperation = async (operation) => await operation.catch((error) => {
|
|
1001
|
+
if (acceptedText.length === 0) throw error;
|
|
1002
|
+
throw createChannelPartialDeliveryError(error, {
|
|
1003
|
+
messageIds: acceptedText.flatMap(({ id }) => id ? [id] : []),
|
|
1004
|
+
content: acceptedText.map(({ text }) => text).join("\n"),
|
|
1005
|
+
visibleReplySent: true
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
const typingMatchesReply = deliveryTypingMessage?.placement === "thread" ? deliveryTypingMessage.requestedThreadName === targetThreadName : deliveryTypingMessage?.placement === "top-level" ? targetThreadName === void 0 : false;
|
|
1009
|
+
if (deliveryTypingMessage && !typingMatchesReply) {
|
|
1010
|
+
await cleanupTypingMessage();
|
|
1011
|
+
deliveryTypingMessage = void 0;
|
|
1012
|
+
} else if (deliveryTypingMessage?.placement === "thread") deliveryThreadName = deliveryTypingMessage.deliveredThreadName;
|
|
1013
|
+
let text;
|
|
1014
|
+
try {
|
|
1015
|
+
text = formatGoogleChatMediaText(reply.text, reply.mediaUrls);
|
|
1016
|
+
} catch (cause) {
|
|
1017
|
+
await cleanupTypingMessage();
|
|
1018
|
+
throw new PlatformMessageNotDispatchedError(cause instanceof Error ? cause.message : String(cause), {
|
|
1019
|
+
cause,
|
|
1020
|
+
retryable: false
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
const chunkLimit = account.config.textChunkLimit ?? 4e3;
|
|
1024
|
+
const chunkMode = core.channel.text.resolveChunkMode(config, "googlechat", account.accountId);
|
|
1025
|
+
const chunks = formatGoogleChatTextChunks(text, chunkLimit).flatMap((chunk) => core.channel.text.chunkMarkdownTextWithMode(chunk, chunkLimit, chunkMode));
|
|
1026
|
+
const rejection = text && !chunks.some((chunk) => chunk) ? "Google Chat reply has no visible text after formatting." : void 0;
|
|
1027
|
+
if (rejection) {
|
|
1028
|
+
await cleanupTypingMessage();
|
|
1029
|
+
throw new PlatformMessageNotDispatchedError(rejection, {
|
|
1030
|
+
cause: void 0,
|
|
1031
|
+
retryable: false
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
const recordOutboundStatus = () => {
|
|
1035
|
+
try {
|
|
1036
|
+
statusSink?.({ lastOutboundAt: Date.now() });
|
|
1037
|
+
} catch (err) {
|
|
1038
|
+
runtime.error?.(`Google Chat outbound status update failed: ${String(err)}`);
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
const sendTextMessage = async (chunk) => {
|
|
1042
|
+
const sent = await runTextOperation(sendGoogleChatMessage({
|
|
1043
|
+
account,
|
|
1044
|
+
space: spaceId,
|
|
1045
|
+
text: chunk,
|
|
1046
|
+
thread: deliveryThreadName
|
|
1047
|
+
}));
|
|
1048
|
+
if (sent) acceptedText.push({
|
|
1049
|
+
id: sent.messageName?.trim() || void 0,
|
|
1050
|
+
text: chunk
|
|
1051
|
+
});
|
|
1052
|
+
if (targetThreadName) deliveryThreadName = sent?.threadName?.trim() || deliveryThreadName;
|
|
1053
|
+
};
|
|
1054
|
+
for (const chunk of chunks) {
|
|
1055
|
+
if (!chunk) continue;
|
|
1056
|
+
if (deliveryTypingMessage) {
|
|
1057
|
+
typingMessage = void 0;
|
|
1058
|
+
try {
|
|
1059
|
+
const updated = await updateGoogleChatMessage({
|
|
1060
|
+
account,
|
|
1061
|
+
messageName: deliveryTypingMessage.name,
|
|
1062
|
+
text: chunk
|
|
1063
|
+
});
|
|
1064
|
+
acceptedText.push({
|
|
1065
|
+
id: updated.messageName?.trim() || deliveryTypingMessage.name,
|
|
1066
|
+
text: chunk
|
|
1067
|
+
});
|
|
1068
|
+
} catch (error) {
|
|
1069
|
+
if (!(error instanceof GoogleChatApiError) || error.status !== 404) throw error;
|
|
1070
|
+
runtime.error?.(`Google Chat typing update failed: ${String(error)}`);
|
|
1071
|
+
await sendTextMessage(chunk);
|
|
1072
|
+
}
|
|
1073
|
+
deliveryTypingMessage = void 0;
|
|
1074
|
+
recordOutboundStatus();
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
await sendTextMessage(chunk);
|
|
1078
|
+
recordOutboundStatus();
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1081
|
+
onDelivered: () => {
|
|
1082
|
+
statusSink?.({ lastOutboundAt: Date.now() });
|
|
1083
|
+
},
|
|
1084
|
+
onError: (err, info) => {
|
|
1085
|
+
runtime.error?.(`[${account.accountId}] Google Chat ${info.kind} reply failed: ${String(err)}`);
|
|
1086
|
+
}
|
|
1126
1087
|
},
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
});
|
|
1088
|
+
replyPipeline: {},
|
|
1089
|
+
record: { onRecordError: (err) => {
|
|
1090
|
+
runtime.error?.(`googlechat: failed updating session meta: ${String(err)}`);
|
|
1091
|
+
} }
|
|
1092
|
+
})
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
} finally {
|
|
1096
|
+
if (!deferred) await cleanupTypingMessage();
|
|
1097
|
+
}
|
|
1138
1098
|
}
|
|
1139
1099
|
async function downloadAttachment(attachment, account, mediaMaxMb, core) {
|
|
1140
1100
|
const resourceName = attachment.attachmentDataRef?.resourceName;
|
|
1141
1101
|
if (!resourceName) return null;
|
|
1142
|
-
const maxBytes =
|
|
1102
|
+
const maxBytes = mediaMaxMb * 1024 * 1024;
|
|
1143
1103
|
const downloaded = await downloadGoogleChatMedia({
|
|
1144
1104
|
account,
|
|
1145
1105
|
resourceName,
|