@actagent/googlechat 2026.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +11 -0
  2. package/actagent.plugin.json +17 -0
  3. package/api.ts +4 -0
  4. package/channel-config-api.ts +2 -0
  5. package/channel-plugin-api.ts +2 -0
  6. package/config-api.ts +3 -0
  7. package/contract-api.ts +6 -0
  8. package/directory-contract-api.ts +7 -0
  9. package/doctor-contract-api.ts +2 -0
  10. package/index.ts +21 -0
  11. package/npm-shrinkwrap.json +314 -0
  12. package/package.json +88 -0
  13. package/runtime-api.ts +61 -0
  14. package/secret-contract-api.ts +6 -0
  15. package/setup-entry.ts +14 -0
  16. package/setup-plugin-api.ts +3 -0
  17. package/src/accounts.ts +185 -0
  18. package/src/actions.test.ts +312 -0
  19. package/src/actions.ts +228 -0
  20. package/src/api.ts +346 -0
  21. package/src/approval-auth.test.ts +25 -0
  22. package/src/approval-auth.ts +38 -0
  23. package/src/approval-card-actions.test.ts +113 -0
  24. package/src/approval-card-actions.ts +307 -0
  25. package/src/approval-card-click.test.ts +279 -0
  26. package/src/approval-card-click.ts +94 -0
  27. package/src/approval-handler.runtime.test.ts +388 -0
  28. package/src/approval-handler.runtime.ts +413 -0
  29. package/src/approval-native.test.ts +399 -0
  30. package/src/approval-native.ts +246 -0
  31. package/src/auth.ts +219 -0
  32. package/src/channel-base.ts +123 -0
  33. package/src/channel-config.test.ts +174 -0
  34. package/src/channel.adapters.ts +363 -0
  35. package/src/channel.deps.runtime.ts +30 -0
  36. package/src/channel.runtime.ts +18 -0
  37. package/src/channel.setup.ts +7 -0
  38. package/src/channel.test.ts +845 -0
  39. package/src/channel.ts +214 -0
  40. package/src/config-schema.test.ts +32 -0
  41. package/src/config-schema.ts +4 -0
  42. package/src/doctor-contract.test.ts +76 -0
  43. package/src/doctor-contract.ts +181 -0
  44. package/src/doctor.ts +58 -0
  45. package/src/gateway.ts +84 -0
  46. package/src/google-auth.runtime.test.ts +571 -0
  47. package/src/google-auth.runtime.ts +570 -0
  48. package/src/group-policy.ts +18 -0
  49. package/src/monitor-access.test.ts +492 -0
  50. package/src/monitor-access.ts +466 -0
  51. package/src/monitor-durable.test.ts +40 -0
  52. package/src/monitor-durable.ts +24 -0
  53. package/src/monitor-reply-delivery.ts +162 -0
  54. package/src/monitor-routing.ts +66 -0
  55. package/src/monitor-types.ts +34 -0
  56. package/src/monitor-webhook.test.ts +670 -0
  57. package/src/monitor-webhook.ts +361 -0
  58. package/src/monitor.reply-delivery.test.ts +145 -0
  59. package/src/monitor.test.ts +389 -0
  60. package/src/monitor.ts +530 -0
  61. package/src/monitor.webhook-routing.test.ts +258 -0
  62. package/src/runtime.ts +10 -0
  63. package/src/secret-contract.test.ts +61 -0
  64. package/src/secret-contract.ts +162 -0
  65. package/src/setup-core.ts +41 -0
  66. package/src/setup-surface.ts +244 -0
  67. package/src/setup.test.ts +620 -0
  68. package/src/targets.test.ts +562 -0
  69. package/src/targets.ts +67 -0
  70. package/src/types.config.ts +4 -0
  71. package/src/types.ts +139 -0
  72. package/test-api.ts +3 -0
  73. package/tsconfig.json +16 -0
package/src/auth.ts ADDED
@@ -0,0 +1,219 @@
1
+ // Googlechat plugin module implements auth behavior.
2
+ import { normalizeLowercaseStringOrEmpty } from "actagent/plugin-sdk/string-coerce-runtime";
3
+ import { fetchWithSsrFGuard } from "../runtime-api.js";
4
+ import type { ResolvedGoogleChatAccount } from "./accounts.js";
5
+ import {
6
+ testing as googleAuthRuntimeTesting,
7
+ getGoogleAuthTransport,
8
+ loadGoogleAuthRuntime,
9
+ resolveValidatedGoogleChatCredentials,
10
+ } from "./google-auth.runtime.js";
11
+
12
+ const CHAT_SCOPE = "https://www.googleapis.com/auth/chat.bot";
13
+ const CHAT_ISSUER = "chat@system.gserviceaccount.com";
14
+ // Google Workspace Add-ons use a different service account pattern
15
+ const ADDON_ISSUER_PATTERN = /^service-\d+@gcp-sa-gsuiteaddons\.iam\.gserviceaccount\.com$/;
16
+ const CHAT_CERTS_URL =
17
+ "https://www.googleapis.com/service_accounts/v1/metadata/x509/chat@system.gserviceaccount.com";
18
+
19
+ async function readGoogleChatCertsResponse(response: Response): Promise<Record<string, string>> {
20
+ try {
21
+ return (await response.json()) as Record<string, string>;
22
+ } catch (cause) {
23
+ throw new Error("Google Chat cert fetch failed: malformed JSON response", { cause });
24
+ }
25
+ }
26
+
27
+ // Size-capped to prevent unbounded growth in long-running deployments (#4948)
28
+ const MAX_AUTH_CACHE_SIZE = 32;
29
+ type GoogleAuthModule = typeof import("google-auth-library");
30
+ type GoogleAuthRuntime = {
31
+ GoogleAuth: GoogleAuthModule["GoogleAuth"];
32
+ OAuth2Client: GoogleAuthModule["OAuth2Client"];
33
+ };
34
+ type GoogleAuthInstance = InstanceType<GoogleAuthRuntime["GoogleAuth"]>;
35
+ type GoogleAuthOptions = ConstructorParameters<GoogleAuthRuntime["GoogleAuth"]>[0];
36
+ type GoogleAuthTransport = NonNullable<GoogleAuthOptions>["clientOptions"] extends {
37
+ transporter?: infer T;
38
+ }
39
+ ? T
40
+ : never;
41
+ type OAuth2ClientInstance = InstanceType<GoogleAuthRuntime["OAuth2Client"]>;
42
+
43
+ const authCache = new Map<string, { key: string; auth: GoogleAuthInstance }>();
44
+
45
+ let cachedCerts: { fetchedAt: number; certs: Record<string, string> } | null = null;
46
+ let verifyClientPromise: Promise<OAuth2ClientInstance> | null = null;
47
+
48
+ async function getVerifyClient(): Promise<OAuth2ClientInstance> {
49
+ if (!verifyClientPromise) {
50
+ verifyClientPromise = (async () => {
51
+ try {
52
+ const { OAuth2Client } = await loadGoogleAuthRuntime();
53
+ // google-auth-library types its transporter through gaxios' CJS surface,
54
+ // while the plugin imports the ESM entrypoint directly.
55
+ const transporter = (await getGoogleAuthTransport()) as unknown as GoogleAuthTransport;
56
+ return new OAuth2Client({ transporter });
57
+ } catch (error) {
58
+ verifyClientPromise = null;
59
+ throw error;
60
+ }
61
+ })();
62
+ }
63
+ return await verifyClientPromise;
64
+ }
65
+
66
+ function buildAuthKey(account: ResolvedGoogleChatAccount): string {
67
+ if (account.credentialsFile) {
68
+ return `file:${account.credentialsFile}`;
69
+ }
70
+ if (account.credentials) {
71
+ return `inline:${JSON.stringify(account.credentials)}`;
72
+ }
73
+ return "none";
74
+ }
75
+
76
+ async function getAuthInstance(account: ResolvedGoogleChatAccount): Promise<GoogleAuthInstance> {
77
+ const key = buildAuthKey(account);
78
+ const cached = authCache.get(account.accountId);
79
+ if (cached && cached.key === key) {
80
+ return cached.auth;
81
+ }
82
+ const [{ GoogleAuth }, rawTransporter, credentials] = await Promise.all([
83
+ loadGoogleAuthRuntime(),
84
+ getGoogleAuthTransport(),
85
+ resolveValidatedGoogleChatCredentials(account),
86
+ ]);
87
+ const transporter = rawTransporter as unknown as GoogleAuthTransport;
88
+
89
+ const evictOldest = () => {
90
+ if (authCache.size > MAX_AUTH_CACHE_SIZE) {
91
+ const oldest = authCache.keys().next().value;
92
+ if (oldest !== undefined) {
93
+ authCache.delete(oldest);
94
+ }
95
+ }
96
+ };
97
+
98
+ const auth = new GoogleAuth({
99
+ ...(credentials ? { credentials } : {}),
100
+ clientOptions: { transporter },
101
+ scopes: [CHAT_SCOPE],
102
+ });
103
+ authCache.set(account.accountId, { key, auth });
104
+ evictOldest();
105
+ return auth;
106
+ }
107
+
108
+ export async function getGoogleChatAccessToken(
109
+ account: ResolvedGoogleChatAccount,
110
+ ): Promise<string> {
111
+ const auth = await getAuthInstance(account);
112
+ const client = await auth.getClient();
113
+ const access = await client.getAccessToken();
114
+ const token = typeof access === "string" ? access : access?.token;
115
+ if (!token) {
116
+ throw new Error("Missing Google Chat access token");
117
+ }
118
+ return token;
119
+ }
120
+
121
+ async function fetchChatCerts(): Promise<Record<string, string>> {
122
+ const now = Date.now();
123
+ if (cachedCerts && now - cachedCerts.fetchedAt < 10 * 60 * 1000) {
124
+ return cachedCerts.certs;
125
+ }
126
+ const { response, release } = await fetchWithSsrFGuard({
127
+ url: CHAT_CERTS_URL,
128
+ auditContext: "googlechat.auth.certs",
129
+ });
130
+ try {
131
+ if (!response.ok) {
132
+ throw new Error(`Failed to fetch Chat certs (${response.status})`);
133
+ }
134
+ const certs = await readGoogleChatCertsResponse(response);
135
+ cachedCerts = { fetchedAt: now, certs };
136
+ return certs;
137
+ } finally {
138
+ await release();
139
+ }
140
+ }
141
+
142
+ export type GoogleChatAudienceType = "app-url" | "project-number";
143
+
144
+ export async function verifyGoogleChatRequest(params: {
145
+ bearer?: string | null;
146
+ audienceType?: GoogleChatAudienceType | null;
147
+ audience?: string | null;
148
+ expectedAddOnPrincipal?: string | null;
149
+ }): Promise<{ ok: boolean; reason?: string }> {
150
+ const bearer = params.bearer?.trim();
151
+ if (!bearer) {
152
+ return { ok: false, reason: "missing token" };
153
+ }
154
+ const audience = params.audience?.trim();
155
+ if (!audience) {
156
+ return { ok: false, reason: "missing audience" };
157
+ }
158
+ const audienceType = params.audienceType ?? null;
159
+
160
+ if (audienceType === "app-url") {
161
+ try {
162
+ const verifyClient = await getVerifyClient();
163
+ const ticket = await verifyClient.verifyIdToken({
164
+ idToken: bearer,
165
+ audience,
166
+ });
167
+ const payload = ticket.getPayload();
168
+ const email = normalizeLowercaseStringOrEmpty(payload?.email ?? "");
169
+ if (!payload?.email_verified) {
170
+ return { ok: false, reason: "email not verified" };
171
+ }
172
+ if (email === CHAT_ISSUER) {
173
+ return { ok: true };
174
+ }
175
+ if (!ADDON_ISSUER_PATTERN.test(email)) {
176
+ return { ok: false, reason: `invalid issuer: ${email}` };
177
+ }
178
+ const expectedAddOnPrincipal = normalizeLowercaseStringOrEmpty(
179
+ params.expectedAddOnPrincipal ?? "",
180
+ );
181
+ if (!expectedAddOnPrincipal) {
182
+ return { ok: false, reason: "missing add-on principal binding" };
183
+ }
184
+ const tokenPrincipal = normalizeLowercaseStringOrEmpty(payload?.sub ?? "");
185
+ if (!tokenPrincipal || tokenPrincipal !== expectedAddOnPrincipal) {
186
+ return {
187
+ ok: false,
188
+ reason: `unexpected add-on principal: ${tokenPrincipal || "<missing>"}`,
189
+ };
190
+ }
191
+ return { ok: true };
192
+ } catch (err) {
193
+ return { ok: false, reason: err instanceof Error ? err.message : "invalid token" };
194
+ }
195
+ }
196
+
197
+ if (audienceType === "project-number") {
198
+ try {
199
+ const verifyClient = await getVerifyClient();
200
+ const certs = await fetchChatCerts();
201
+ await verifyClient.verifySignedJwtWithCertsAsync(bearer, certs, audience, [CHAT_ISSUER]);
202
+ return { ok: true };
203
+ } catch (err) {
204
+ return { ok: false, reason: err instanceof Error ? err.message : "invalid token" };
205
+ }
206
+ }
207
+
208
+ return { ok: false, reason: "unsupported audience type" };
209
+ }
210
+
211
+ export const testing = {
212
+ resetGoogleChatAuthForTests(): void {
213
+ authCache.clear();
214
+ cachedCerts = null;
215
+ verifyClientPromise = null;
216
+ googleAuthRuntimeTesting.resetGoogleAuthRuntimeForTests();
217
+ },
218
+ };
219
+ export { testing as __testing };
@@ -0,0 +1,123 @@
1
+ // Googlechat plugin module implements channel base behavior.
2
+ import { describeAccountSnapshot } from "actagent/plugin-sdk/account-helpers";
3
+ import { formatNormalizedAllowFromEntries } from "actagent/plugin-sdk/allow-from";
4
+ import {
5
+ adaptScopedAccountAccessor,
6
+ createScopedChannelConfigAdapter,
7
+ } from "actagent/plugin-sdk/channel-config-helpers";
8
+ import type { ChannelPlugin } from "actagent/plugin-sdk/channel-core";
9
+ import { normalizeLowercaseStringOrEmpty } from "actagent/plugin-sdk/string-coerce-runtime";
10
+ import {
11
+ type GoogleChatConfigAccessorAccount,
12
+ listGoogleChatAccountIds,
13
+ resolveDefaultGoogleChatAccountId,
14
+ resolveGoogleChatConfigAccessorAccount,
15
+ resolveGoogleChatAccount,
16
+ type ResolvedGoogleChatAccount,
17
+ } from "./accounts.js";
18
+ import { googlechatSetupAdapter } from "./setup-core.js";
19
+ import { googlechatSetupWizard } from "./setup-surface.js";
20
+
21
+ export const GOOGLECHAT_CHANNEL_ID = "googlechat" as const;
22
+
23
+ export const googlechatMeta = {
24
+ id: GOOGLECHAT_CHANNEL_ID,
25
+ label: "Google Chat",
26
+ selectionLabel: "Google Chat (Chat API)",
27
+ docsPath: "/channels/googlechat",
28
+ docsLabel: "googlechat",
29
+ blurb: "Google Workspace Chat app with HTTP webhook.",
30
+ aliases: ["gchat", "google-chat"],
31
+ order: 55,
32
+ detailLabel: "Google Chat",
33
+ systemImage: "message.badge",
34
+ markdownCapable: true,
35
+ };
36
+
37
+ export const formatGoogleChatAllowFromEntry = (entry: string) =>
38
+ normalizeLowercaseStringOrEmpty(
39
+ entry
40
+ .trim()
41
+ .replace(/^(googlechat|google-chat|gchat):/i, "")
42
+ .replace(/^user:/i, "")
43
+ .replace(/^users\//i, ""),
44
+ );
45
+
46
+ const googleChatConfigAdapter = createScopedChannelConfigAdapter<
47
+ ResolvedGoogleChatAccount,
48
+ GoogleChatConfigAccessorAccount
49
+ >({
50
+ sectionKey: GOOGLECHAT_CHANNEL_ID,
51
+ listAccountIds: listGoogleChatAccountIds,
52
+ resolveAccount: adaptScopedAccountAccessor(resolveGoogleChatAccount),
53
+ resolveAccessorAccount: resolveGoogleChatConfigAccessorAccount,
54
+ defaultAccountId: resolveDefaultGoogleChatAccountId,
55
+ clearBaseFields: [
56
+ "serviceAccount",
57
+ "serviceAccountFile",
58
+ "audienceType",
59
+ "audience",
60
+ "webhookPath",
61
+ "webhookUrl",
62
+ "botUser",
63
+ "name",
64
+ ],
65
+ resolveAllowFrom: (account) => account.config.dm?.allowFrom,
66
+ formatAllowFrom: (allowFrom) =>
67
+ formatNormalizedAllowFromEntries({
68
+ allowFrom,
69
+ normalizeEntry: formatGoogleChatAllowFromEntry,
70
+ }),
71
+ resolveDefaultTo: (account) => account.config.defaultTo,
72
+ });
73
+
74
+ type GoogleChatPluginBase = Pick<
75
+ ChannelPlugin<ResolvedGoogleChatAccount>,
76
+ | "id"
77
+ | "meta"
78
+ | "setup"
79
+ | "setupWizard"
80
+ | "capabilities"
81
+ | "streaming"
82
+ | "reload"
83
+ | "configSchema"
84
+ | "config"
85
+ >;
86
+
87
+ export function createGoogleChatPluginBase(
88
+ params: {
89
+ configSchema?: ChannelPlugin<ResolvedGoogleChatAccount>["configSchema"];
90
+ } = {},
91
+ ): GoogleChatPluginBase {
92
+ return {
93
+ id: GOOGLECHAT_CHANNEL_ID,
94
+ meta: { ...googlechatMeta },
95
+ setup: googlechatSetupAdapter,
96
+ setupWizard: googlechatSetupWizard,
97
+ capabilities: {
98
+ chatTypes: ["direct", "group", "thread"],
99
+ reactions: true,
100
+ threads: true,
101
+ media: true,
102
+ nativeCommands: false,
103
+ blockStreaming: true,
104
+ },
105
+ streaming: {
106
+ blockStreamingCoalesceDefaults: { minChars: 1500, idleMs: 1000 },
107
+ },
108
+ reload: { configPrefixes: ["channels.googlechat"] },
109
+ ...(params.configSchema ? { configSchema: params.configSchema } : {}),
110
+ config: {
111
+ ...googleChatConfigAdapter,
112
+ isConfigured: (account) => account.credentialSource !== "none",
113
+ describeAccount: (account) =>
114
+ describeAccountSnapshot({
115
+ account,
116
+ configured: account.credentialSource !== "none",
117
+ extra: {
118
+ credentialSource: account.credentialSource,
119
+ },
120
+ }),
121
+ },
122
+ };
123
+ }
@@ -0,0 +1,174 @@
1
+ // Googlechat tests cover channel config plugin behavior.
2
+ import type { ChannelOutboundPayloadHint } from "actagent/plugin-sdk/channel-contract";
3
+ import type { ACTAgentConfig } from "actagent/plugin-sdk/config-contracts";
4
+ import type { ReplyPayload } from "actagent/plugin-sdk/reply-runtime";
5
+ import { beforeEach, describe, expect, it } from "vitest";
6
+ import {
7
+ clearGoogleChatApprovalCardBindingsForTest,
8
+ registerGoogleChatApprovalCardBinding,
9
+ } from "./approval-card-actions.js";
10
+ import { googlechatPlugin } from "./channel.js";
11
+ import { googlechatSetupPlugin } from "./channel.setup.js";
12
+
13
+ describe("googlechatPlugin config adapter", () => {
14
+ beforeEach(() => {
15
+ clearGoogleChatApprovalCardBindingsForTest();
16
+ });
17
+
18
+ it("keeps setup metadata aligned with the runtime plugin", () => {
19
+ expect(googlechatSetupPlugin.id).toBe(googlechatPlugin.id);
20
+ expect(googlechatSetupPlugin.meta).toEqual(googlechatPlugin.meta);
21
+ expect(googlechatSetupPlugin.capabilities?.chatTypes).toEqual(
22
+ googlechatPlugin.capabilities?.chatTypes,
23
+ );
24
+ });
25
+
26
+ it("registers an exec-capable native approval runtime", () => {
27
+ expect(googlechatPlugin.approvalCapability?.nativeRuntime?.eventKinds).toContain("exec");
28
+ });
29
+
30
+ it("keeps read-only accessors from resolving service account SecretRefs", () => {
31
+ const cfg = {
32
+ secrets: {
33
+ providers: {
34
+ google_chat_service_account: {
35
+ source: "file",
36
+ path: "/tmp/actagent-missing-google-chat-service-account",
37
+ mode: "singleValue",
38
+ },
39
+ },
40
+ },
41
+ channels: {
42
+ googlechat: {
43
+ serviceAccount: {
44
+ source: "file",
45
+ provider: "google_chat_service_account",
46
+ id: "value",
47
+ },
48
+ dm: {
49
+ allowFrom: ["users/123"],
50
+ },
51
+ defaultTo: "spaces/AAA",
52
+ },
53
+ },
54
+ } as ACTAgentConfig;
55
+
56
+ expect(googlechatPlugin.config.resolveAllowFrom?.({ cfg, accountId: "default" })).toEqual([
57
+ "users/123",
58
+ ]);
59
+ expect(googlechatPlugin.config.resolveDefaultTo?.({ cfg, accountId: "default" })).toBe(
60
+ "spaces/AAA",
61
+ );
62
+ });
63
+
64
+ it("wires native exec approval suppression through the outbound adapter", () => {
65
+ const cfg = {
66
+ approvals: { exec: { enabled: true } },
67
+ channels: {
68
+ googlechat: {
69
+ serviceAccount: {
70
+ type: "service_account",
71
+ client_email: "bot@example.com",
72
+ private_key: "test-key",
73
+ token_uri: "https://oauth2.googleapis.com/token",
74
+ },
75
+ audienceType: "app-url",
76
+ audience: "https://chat-app.example.test/googlechat",
77
+ dm: { allowFrom: ["users/123"] },
78
+ },
79
+ },
80
+ } as ACTAgentConfig;
81
+ const payload: ReplyPayload = {
82
+ channelData: {
83
+ execApproval: {
84
+ approvalId: "12345678-1234-1234-1234-123456789012",
85
+ approvalSlug: "12345678",
86
+ approvalKind: "exec",
87
+ agentId: "dev",
88
+ sessionKey: "agent:dev:main",
89
+ },
90
+ },
91
+ };
92
+ const hint: ChannelOutboundPayloadHint = {
93
+ kind: "approval-pending",
94
+ approvalKind: "exec",
95
+ nativeRouteActive: true,
96
+ };
97
+
98
+ expect(
99
+ googlechatPlugin.outbound?.shouldSuppressLocalPayloadPrompt?.({
100
+ cfg,
101
+ payload,
102
+ hint,
103
+ }),
104
+ ).toBe(true);
105
+ });
106
+
107
+ it("drops duplicate manual exec approval follow-up text after a native card is registered", () => {
108
+ const approvalId = "12345678-1234-1234-1234-123456789012";
109
+ registerGoogleChatApprovalCardBinding({
110
+ token: "token-1",
111
+ accountId: "default",
112
+ approvalId,
113
+ approvalKind: "exec",
114
+ decision: "allow-once",
115
+ allowedDecisions: ["allow-once", "deny"],
116
+ spaceName: "spaces/AAA",
117
+ messageName: "spaces/AAA/messages/msg-1",
118
+ expiresAtMs: Date.now() + 60_000,
119
+ });
120
+ const payload: ReplyPayload = {
121
+ text: `I need approval.\nReply with:\n/approve ${approvalId.slice(0, 8)} allow-once`,
122
+ };
123
+
124
+ expect(
125
+ googlechatPlugin.outbound?.normalizePayload?.({
126
+ cfg: {} as ACTAgentConfig,
127
+ payload,
128
+ }),
129
+ ).toBeNull();
130
+ });
131
+
132
+ it("keeps unrelated or sendable structured approval-looking payloads visible", () => {
133
+ const approvalId = "12345678-1234-1234-1234-123456789012";
134
+ registerGoogleChatApprovalCardBinding({
135
+ token: "token-1",
136
+ accountId: "default",
137
+ approvalId,
138
+ approvalKind: "exec",
139
+ decision: "allow-once",
140
+ allowedDecisions: ["allow-once", "deny"],
141
+ spaceName: "spaces/AAA",
142
+ messageName: "spaces/AAA/messages/msg-1",
143
+ expiresAtMs: Date.now() + 60_000,
144
+ });
145
+ const unrelatedPayload: ReplyPayload = { text: "/approve deadbeef allow-once" };
146
+ const metadataPayload: ReplyPayload = {
147
+ text: `/approve ${approvalId.slice(0, 8)} allow-once`,
148
+ channelData: { execApproval: { approvalId } },
149
+ };
150
+ const structuredPayload: ReplyPayload = {
151
+ text: `/approve ${approvalId.slice(0, 8)} allow-once`,
152
+ presentation: { blocks: [] },
153
+ };
154
+
155
+ expect(
156
+ googlechatPlugin.outbound?.normalizePayload?.({
157
+ cfg: {} as ACTAgentConfig,
158
+ payload: unrelatedPayload,
159
+ }),
160
+ ).toBe(unrelatedPayload);
161
+ expect(
162
+ googlechatPlugin.outbound?.normalizePayload?.({
163
+ cfg: {} as ACTAgentConfig,
164
+ payload: metadataPayload,
165
+ }),
166
+ ).toBeNull();
167
+ expect(
168
+ googlechatPlugin.outbound?.normalizePayload?.({
169
+ cfg: {} as ACTAgentConfig,
170
+ payload: structuredPayload,
171
+ }),
172
+ ).toBe(structuredPayload);
173
+ });
174
+ });