@openclaw/googlechat 2026.6.1 → 2026.6.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.
@@ -0,0 +1,388 @@
1
+ import { c as resolveDefaultGoogleChatAccountId, l as resolveGoogleChatAccount, n as createGoogleChatPluginBase, s as listGoogleChatAccountIds, t as GOOGLECHAT_CHANNEL_ID } from "./channel-base-Qh87GFW_.js";
2
+ import { a as googlechatPairingTextAdapter, c as isGoogleChatSpaceTarget, i as googlechatOutboundAdapter, l as isGoogleChatUserTarget, n as googlechatGroupsAdapter, o as googlechatSecurityAdapter, r as googlechatMessageAdapter, s as googlechatThreadingAdapter, t as googlechatDirectoryAdapter, u as normalizeGoogleChatTarget } from "./channel.adapters-BQoq1F4R.js";
3
+ import { a as buildChannelConfigSchema, r as GoogleChatConfigSchema, t as DEFAULT_ACCOUNT_ID } from "./runtime-api-BbVoWRxq.js";
4
+ import { n as googleChatApprovalAuth, r as normalizeGoogleChatApproverId, t as getGoogleChatApprovalApprovers } from "./approval-auth-C-vWY4bY.js";
5
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BcEqUZ4j.js";
6
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-lCMHqumt.js";
7
+ import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
8
+ import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
9
+ import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
10
+ import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
11
+ import { extractToolSend } from "openclaw/plugin-sdk/tool-send";
12
+ import { createApproverRestrictedNativeApprovalCapability, splitChannelApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
13
+ import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY, createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
14
+ import { createChannelApproverDmTargetResolver, createChannelNativeOriginTargetResolver, createNativeApprovalChannelRouteGates, shouldSuppressLocalNativeExecApprovalPrompt } from "openclaw/plugin-sdk/approval-native-runtime";
15
+ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
16
+ import { createAccountStatusSink, runPassiveAccountLifecycle } from "openclaw/plugin-sdk/channel-outbound";
17
+ import { createDangerousNameMatchingMutableAllowlistWarningCollector } from "openclaw/plugin-sdk/channel-policy";
18
+ import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
19
+ //#region extensions/googlechat/src/approval-native.ts
20
+ const DEFAULT_APPROVAL_FORWARDING_MODE = "session";
21
+ function isGoogleChatAccountConfigured(params) {
22
+ const account = resolveGoogleChatAccount(params);
23
+ return account.enabled && account.credentialSource !== "none";
24
+ }
25
+ function hasGoogleChatWebhookApprovalAuthConfig(params) {
26
+ const account = resolveGoogleChatAccount(params).config;
27
+ if (!normalizeOptionalString(account.audience)) return false;
28
+ if (account.audienceType === "project-number") return true;
29
+ return account.audienceType === "app-url";
30
+ }
31
+ function isGoogleChatApprovalTransportEnabled(params) {
32
+ return isGoogleChatAccountConfigured(params) && hasGoogleChatWebhookApprovalAuthConfig(params);
33
+ }
34
+ function normalizeGoogleChatForwardTarget(target) {
35
+ if (normalizeLowercaseStringOrEmpty(target.channel) !== "googlechat") return null;
36
+ const to = normalizeGoogleChatTarget(target.to);
37
+ return to ? {
38
+ to,
39
+ accountId: normalizeOptionalString(target.accountId),
40
+ threadId: target.threadId ?? null
41
+ } : null;
42
+ }
43
+ function resolveTurnSourceGoogleChatOriginTarget(request) {
44
+ if (normalizeLowercaseStringOrEmpty(request.request.turnSourceChannel) !== "googlechat") return null;
45
+ const target = normalizeGoogleChatTarget(request.request.turnSourceTo ?? "");
46
+ if (!target || !isGoogleChatSpaceTarget(target)) return null;
47
+ return {
48
+ to: target,
49
+ accountId: normalizeOptionalString(request.request.turnSourceAccountId),
50
+ threadId: request.request.turnSourceThreadId ?? null
51
+ };
52
+ }
53
+ const googleChatApprovalRouteGates = createNativeApprovalChannelRouteGates({
54
+ channel: "googlechat",
55
+ defaultForwardingMode: DEFAULT_APPROVAL_FORWARDING_MODE,
56
+ isTransportEnabled: isGoogleChatApprovalTransportEnabled,
57
+ listAccountIds: listGoogleChatAccountIds,
58
+ resolveDefaultAccountId: resolveDefaultGoogleChatAccountId,
59
+ normalizeForwardTarget: normalizeGoogleChatForwardTarget,
60
+ resolveTurnSourceTarget: resolveTurnSourceGoogleChatOriginTarget
61
+ });
62
+ function isGoogleChatNativeApprovalClientEnabled(params) {
63
+ return googleChatApprovalRouteGates.canAnyApprovalPotentiallyRouteToChannel({
64
+ ...params,
65
+ nativeSessionOnly: true
66
+ }) && getGoogleChatApprovalApprovers(params).length > 0;
67
+ }
68
+ function resolveSessionGoogleChatOriginTarget(sessionTarget) {
69
+ const target = normalizeGoogleChatTarget(sessionTarget.to);
70
+ return target && isGoogleChatSpaceTarget(target) ? {
71
+ to: target,
72
+ threadId: sessionTarget.threadId ?? null
73
+ } : null;
74
+ }
75
+ function shouldHandleGoogleChatNativeApprovalRequest(params) {
76
+ return googleChatApprovalRouteGates.shouldHandleApprovalRequest(params) && getGoogleChatApprovalApprovers(params).length > 0 && Boolean(resolveTurnSourceGoogleChatOriginTarget(params.request));
77
+ }
78
+ function shouldSuppressLocalGoogleChatExecApprovalPrompt(params) {
79
+ return shouldSuppressLocalNativeExecApprovalPrompt({
80
+ ...params,
81
+ isNativeDeliveryEnabled: isGoogleChatNativeApprovalClientEnabled
82
+ });
83
+ }
84
+ const googleChatApprovalCapability = createApproverRestrictedNativeApprovalCapability({
85
+ channel: "googlechat",
86
+ channelLabel: "Google Chat",
87
+ describeExecApprovalSetup: ({ accountId }) => {
88
+ const prefix = accountId && accountId !== "default" ? `channels.googlechat.accounts.${accountId}` : "channels.googlechat";
89
+ return `Approve it from the Web UI or terminal UI for now. Google Chat supports native approvals for this account when the webhook and service account are configured. Configure \`${prefix}.dm.allowFrom\` or \`${prefix}.defaultTo\` with numeric \`users/{id}\` approvers.`;
90
+ },
91
+ listAccountIds: listGoogleChatAccountIds,
92
+ hasApprovers: ({ cfg, accountId }) => getGoogleChatApprovalApprovers({
93
+ cfg,
94
+ accountId
95
+ }).length > 0,
96
+ isExecAuthorizedSender: ({ cfg, accountId, senderId }) => googleChatApprovalAuth.authorizeActorAction?.({
97
+ cfg,
98
+ accountId,
99
+ senderId,
100
+ action: "approve",
101
+ approvalKind: "exec"
102
+ })?.authorized ?? false,
103
+ isPluginAuthorizedSender: ({ cfg, accountId, senderId }) => googleChatApprovalAuth.authorizeActorAction?.({
104
+ cfg,
105
+ accountId,
106
+ senderId,
107
+ action: "approve",
108
+ approvalKind: "plugin"
109
+ })?.authorized ?? false,
110
+ isNativeDeliveryEnabled: isGoogleChatNativeApprovalClientEnabled,
111
+ resolveNativeDeliveryMode: () => "channel",
112
+ requireMatchingTurnSourceChannel: true,
113
+ resolveSuppressionAccountId: ({ target, request }) => normalizeOptionalString(target.accountId) ?? normalizeOptionalString(request.request.turnSourceAccountId),
114
+ resolveOriginTarget: createChannelNativeOriginTargetResolver({
115
+ channel: "googlechat",
116
+ shouldHandleRequest: shouldHandleGoogleChatNativeApprovalRequest,
117
+ resolveTurnSourceTarget: resolveTurnSourceGoogleChatOriginTarget,
118
+ resolveSessionTarget: resolveSessionGoogleChatOriginTarget
119
+ }),
120
+ resolveApproverDmTargets: createChannelApproverDmTargetResolver({
121
+ shouldHandleRequest: shouldHandleGoogleChatNativeApprovalRequest,
122
+ resolveApprovers: getGoogleChatApprovalApprovers,
123
+ mapApprover: (approver, params) => {
124
+ const to = normalizeGoogleChatApproverId(approver);
125
+ return to ? {
126
+ to,
127
+ accountId: normalizeOptionalString(params.accountId)
128
+ } : null;
129
+ }
130
+ }),
131
+ nativeRuntime: createLazyChannelApprovalNativeRuntimeAdapter({
132
+ eventKinds: ["exec", "plugin"],
133
+ isConfigured: ({ cfg, accountId }) => isGoogleChatNativeApprovalClientEnabled({
134
+ cfg,
135
+ accountId
136
+ }),
137
+ shouldHandle: ({ cfg, accountId, request }) => shouldHandleGoogleChatNativeApprovalRequest({
138
+ cfg,
139
+ accountId,
140
+ request
141
+ }),
142
+ load: async () => (await import("./approval-handler.runtime-CWeVJAQF.js")).googleChatApprovalNativeRuntime
143
+ })
144
+ });
145
+ splitChannelApprovalCapability(googleChatApprovalCapability);
146
+ //#endregion
147
+ //#region extensions/googlechat/src/doctor.ts
148
+ function asObjectRecord(value) {
149
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
150
+ }
151
+ function isGoogleChatMutableAllowEntry(raw) {
152
+ const text = raw.trim();
153
+ if (!text || text === "*") return false;
154
+ const withoutPrefix = text.replace(/^(googlechat|google-chat|gchat):/i, "").trim();
155
+ if (!withoutPrefix) return false;
156
+ return withoutPrefix.replace(/^users\//i, "").includes("@");
157
+ }
158
+ const collectGoogleChatMutableAllowlistWarnings = createDangerousNameMatchingMutableAllowlistWarningCollector({
159
+ channel: "googlechat",
160
+ detector: isGoogleChatMutableAllowEntry,
161
+ collectLists: (scope) => {
162
+ const lists = [{
163
+ pathLabel: `${scope.prefix}.groupAllowFrom`,
164
+ list: scope.account.groupAllowFrom
165
+ }];
166
+ const dm = asObjectRecord(scope.account.dm);
167
+ if (dm) lists.push({
168
+ pathLabel: `${scope.prefix}.dm.allowFrom`,
169
+ list: dm.allowFrom
170
+ });
171
+ const groups = asObjectRecord(scope.account.groups);
172
+ if (groups) for (const [groupKey, groupRaw] of Object.entries(groups)) {
173
+ const group = asObjectRecord(groupRaw);
174
+ if (!group) continue;
175
+ lists.push({
176
+ pathLabel: `${scope.prefix}.groups.${groupKey}.users`,
177
+ list: group.users
178
+ });
179
+ }
180
+ return lists;
181
+ }
182
+ });
183
+ //#endregion
184
+ //#region extensions/googlechat/src/gateway.ts
185
+ const loadGoogleChatChannelRuntime$1 = createLazyRuntimeNamedExport(() => import("./channel.runtime-CbSK_Zox.js"), "googleChatChannelRuntime");
186
+ async function startGoogleChatGatewayAccount(ctx) {
187
+ const account = ctx.account;
188
+ const statusSink = createAccountStatusSink({
189
+ accountId: account.accountId,
190
+ setStatus: ctx.setStatus
191
+ });
192
+ ctx.log?.info?.(`[${account.accountId}] starting Google Chat webhook`);
193
+ const { resolveGoogleChatWebhookPath, startGoogleChatMonitor } = await loadGoogleChatChannelRuntime$1();
194
+ statusSink({
195
+ running: true,
196
+ lastStartAt: Date.now(),
197
+ webhookPath: resolveGoogleChatWebhookPath({ account }),
198
+ audienceType: account.config.audienceType,
199
+ audience: account.config.audience
200
+ });
201
+ if (isGoogleChatNativeApprovalClientEnabled({
202
+ cfg: ctx.cfg,
203
+ accountId: account.accountId
204
+ })) registerChannelRuntimeContext({
205
+ channelRuntime: ctx.channelRuntime,
206
+ channelId: "googlechat",
207
+ accountId: account.accountId,
208
+ capability: CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY,
209
+ context: { account },
210
+ abortSignal: ctx.abortSignal
211
+ });
212
+ await runPassiveAccountLifecycle({
213
+ abortSignal: ctx.abortSignal,
214
+ start: async () => await startGoogleChatMonitor({
215
+ account,
216
+ config: ctx.cfg,
217
+ runtime: ctx.runtime,
218
+ abortSignal: ctx.abortSignal,
219
+ webhookPath: account.config.webhookPath,
220
+ webhookUrl: account.config.webhookUrl,
221
+ statusSink
222
+ }),
223
+ stop: async (unregister) => {
224
+ unregister?.();
225
+ },
226
+ onStop: async () => {
227
+ statusSink({
228
+ running: false,
229
+ lastStopAt: Date.now()
230
+ });
231
+ }
232
+ });
233
+ }
234
+ //#endregion
235
+ //#region extensions/googlechat/src/channel.ts
236
+ const loadGoogleChatChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-CbSK_Zox.js"), "googleChatChannelRuntime");
237
+ const googlechatActions = {
238
+ describeMessageTool: ({ cfg, accountId }) => {
239
+ const accounts = accountId ? [resolveGoogleChatAccount({
240
+ cfg,
241
+ accountId
242
+ })].filter((account) => account.enabled && account.credentialSource !== "none") : listGoogleChatAccountIds(cfg).map((id) => resolveGoogleChatAccount({
243
+ cfg,
244
+ accountId: id
245
+ })).filter((account) => account.enabled && account.credentialSource !== "none");
246
+ if (accounts.length === 0) return null;
247
+ const actions = new Set(["send", "upload-file"]);
248
+ if (accounts.some((account) => account.config.actions?.reactions !== false)) {
249
+ actions.add("react");
250
+ actions.add("reactions");
251
+ }
252
+ return { actions: Array.from(actions) };
253
+ },
254
+ extractToolSend: ({ args }) => extractToolSend(args, "sendMessage"),
255
+ handleAction: async (ctx) => {
256
+ const { googlechatMessageActions } = await import("./actions-DvYC089V.js");
257
+ if (!googlechatMessageActions.handleAction) throw new Error("Google Chat actions are not available.");
258
+ return await googlechatMessageActions.handleAction(ctx);
259
+ }
260
+ };
261
+ const googlechatPlugin = createChatChannelPlugin({
262
+ base: {
263
+ ...createGoogleChatPluginBase({ configSchema: buildChannelConfigSchema(GoogleChatConfigSchema) }),
264
+ approvalCapability: googleChatApprovalCapability,
265
+ secrets: {
266
+ secretTargetRegistryEntries,
267
+ collectRuntimeConfigAssignments
268
+ },
269
+ groups: googlechatGroupsAdapter,
270
+ messaging: {
271
+ targetPrefixes: [
272
+ "googlechat",
273
+ "google-chat",
274
+ "gchat"
275
+ ],
276
+ normalizeTarget: normalizeGoogleChatTarget,
277
+ targetResolver: {
278
+ looksLikeId: (raw, normalized) => {
279
+ const value = normalized ?? raw.trim();
280
+ return isGoogleChatSpaceTarget(value) || isGoogleChatUserTarget(value);
281
+ },
282
+ hint: "<spaces/{space}|users/{user}>"
283
+ }
284
+ },
285
+ directory: googlechatDirectoryAdapter,
286
+ message: googlechatMessageAdapter,
287
+ resolver: { resolveTargets: async ({ inputs, kind }) => {
288
+ return inputs.map((input) => {
289
+ const normalized = normalizeGoogleChatTarget(input);
290
+ if (!normalized) return {
291
+ input,
292
+ resolved: false,
293
+ note: "empty target"
294
+ };
295
+ if (kind === "user" && isGoogleChatUserTarget(normalized)) return {
296
+ input,
297
+ resolved: true,
298
+ id: normalized
299
+ };
300
+ if (kind === "group" && isGoogleChatSpaceTarget(normalized)) return {
301
+ input,
302
+ resolved: true,
303
+ id: normalized
304
+ };
305
+ return {
306
+ input,
307
+ resolved: false,
308
+ note: "use spaces/{space} or users/{user}"
309
+ };
310
+ });
311
+ } },
312
+ actions: googlechatActions,
313
+ doctor: {
314
+ dmAllowFromMode: "nestedOnly",
315
+ groupModel: "route",
316
+ groupAllowFromFallbackToAllowFrom: false,
317
+ warnOnEmptyGroupSenderAllowlist: false,
318
+ legacyConfigRules,
319
+ normalizeCompatibilityConfig,
320
+ collectMutableAllowlistWarnings: collectGoogleChatMutableAllowlistWarnings
321
+ },
322
+ status: createComputedAccountStatusAdapter({
323
+ defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID),
324
+ collectStatusIssues: (accounts) => accounts.flatMap((entry) => {
325
+ const accountId = entry.accountId ?? DEFAULT_ACCOUNT_ID;
326
+ const enabled = entry.enabled !== false;
327
+ const configured = entry.configured === true;
328
+ if (!enabled || !configured) return [];
329
+ const issues = [];
330
+ if (!entry.audience) issues.push({
331
+ channel: GOOGLECHAT_CHANNEL_ID,
332
+ accountId,
333
+ kind: "config",
334
+ message: "Google Chat audience is missing (set channels.googlechat.audience).",
335
+ fix: "Set channels.googlechat.audienceType and channels.googlechat.audience."
336
+ });
337
+ if (!entry.audienceType) issues.push({
338
+ channel: GOOGLECHAT_CHANNEL_ID,
339
+ accountId,
340
+ kind: "config",
341
+ message: "Google Chat audienceType is missing (app-url or project-number).",
342
+ fix: "Set channels.googlechat.audienceType and channels.googlechat.audience."
343
+ });
344
+ return issues;
345
+ }),
346
+ buildChannelSummary: ({ snapshot }) => buildPassiveProbedChannelStatusSummary(snapshot, {
347
+ credentialSource: snapshot.credentialSource ?? "none",
348
+ audienceType: snapshot.audienceType ?? null,
349
+ audience: snapshot.audience ?? null,
350
+ webhookPath: snapshot.webhookPath ?? null,
351
+ webhookUrl: snapshot.webhookUrl ?? null
352
+ }),
353
+ probeAccount: async ({ account }) => (await loadGoogleChatChannelRuntime()).probeGoogleChat(account),
354
+ resolveAccountSnapshot: ({ account }) => ({
355
+ accountId: account.accountId,
356
+ name: account.name,
357
+ enabled: account.enabled,
358
+ configured: account.credentialSource !== "none",
359
+ extra: {
360
+ credentialSource: account.credentialSource,
361
+ audienceType: account.config.audienceType,
362
+ audience: account.config.audience,
363
+ webhookPath: account.config.webhookPath,
364
+ webhookUrl: account.config.webhookUrl,
365
+ dmPolicy: account.config.dm?.policy ?? "pairing"
366
+ }
367
+ })
368
+ }),
369
+ gateway: { startAccount: startGoogleChatGatewayAccount }
370
+ },
371
+ pairing: { text: googlechatPairingTextAdapter },
372
+ security: googlechatSecurityAdapter,
373
+ threading: googlechatThreadingAdapter,
374
+ outbound: {
375
+ ...googlechatOutboundAdapter,
376
+ base: {
377
+ ...googlechatOutboundAdapter.base,
378
+ shouldSuppressLocalPayloadPrompt: ({ cfg, accountId, payload, hint }) => shouldSuppressLocalGoogleChatExecApprovalPrompt({
379
+ cfg,
380
+ accountId,
381
+ payload,
382
+ hint
383
+ })
384
+ }
385
+ }
386
+ });
387
+ //#endregion
388
+ export { isGoogleChatNativeApprovalClientEnabled as n, shouldHandleGoogleChatNativeApprovalRequest as r, googlechatPlugin as t };
@@ -396,4 +396,4 @@ function createGoogleChatPluginBase(params = {}) {
396
396
  };
397
397
  }
398
398
  //#endregion
399
- export { googlechatSetupAdapter as a, resolveGoogleChatAccount as c, googlechatSetupWizard as i, createGoogleChatPluginBase as n, listEnabledGoogleChatAccounts as o, formatGoogleChatAllowFromEntry as r, listGoogleChatAccountIds as s, GOOGLECHAT_CHANNEL_ID as t };
399
+ export { googlechatSetupAdapter as a, resolveDefaultGoogleChatAccountId as c, googlechatSetupWizard as i, resolveGoogleChatAccount as l, createGoogleChatPluginBase as n, listEnabledGoogleChatAccounts as o, formatGoogleChatAllowFromEntry as r, listGoogleChatAccountIds as s, GOOGLECHAT_CHANNEL_ID as t };
@@ -1,2 +1,2 @@
1
- import { t as googlechatPlugin } from "./channel-DxHy0I-n.js";
1
+ import { t as googlechatPlugin } from "./channel-BY9hwCh2.js";
2
2
  export { googlechatPlugin };