@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.
- package/README.md +11 -0
- package/actagent.plugin.json +17 -0
- package/api.ts +4 -0
- package/channel-config-api.ts +2 -0
- package/channel-plugin-api.ts +2 -0
- package/config-api.ts +3 -0
- package/contract-api.ts +6 -0
- package/directory-contract-api.ts +7 -0
- package/doctor-contract-api.ts +2 -0
- package/index.ts +21 -0
- package/npm-shrinkwrap.json +314 -0
- package/package.json +88 -0
- package/runtime-api.ts +61 -0
- package/secret-contract-api.ts +6 -0
- package/setup-entry.ts +14 -0
- package/setup-plugin-api.ts +3 -0
- package/src/accounts.ts +185 -0
- package/src/actions.test.ts +312 -0
- package/src/actions.ts +228 -0
- package/src/api.ts +346 -0
- package/src/approval-auth.test.ts +25 -0
- package/src/approval-auth.ts +38 -0
- package/src/approval-card-actions.test.ts +113 -0
- package/src/approval-card-actions.ts +307 -0
- package/src/approval-card-click.test.ts +279 -0
- package/src/approval-card-click.ts +94 -0
- package/src/approval-handler.runtime.test.ts +388 -0
- package/src/approval-handler.runtime.ts +413 -0
- package/src/approval-native.test.ts +399 -0
- package/src/approval-native.ts +246 -0
- package/src/auth.ts +219 -0
- package/src/channel-base.ts +123 -0
- package/src/channel-config.test.ts +174 -0
- package/src/channel.adapters.ts +363 -0
- package/src/channel.deps.runtime.ts +30 -0
- package/src/channel.runtime.ts +18 -0
- package/src/channel.setup.ts +7 -0
- package/src/channel.test.ts +845 -0
- package/src/channel.ts +214 -0
- package/src/config-schema.test.ts +32 -0
- package/src/config-schema.ts +4 -0
- package/src/doctor-contract.test.ts +76 -0
- package/src/doctor-contract.ts +181 -0
- package/src/doctor.ts +58 -0
- package/src/gateway.ts +84 -0
- package/src/google-auth.runtime.test.ts +571 -0
- package/src/google-auth.runtime.ts +570 -0
- package/src/group-policy.ts +18 -0
- package/src/monitor-access.test.ts +492 -0
- package/src/monitor-access.ts +466 -0
- package/src/monitor-durable.test.ts +40 -0
- package/src/monitor-durable.ts +24 -0
- package/src/monitor-reply-delivery.ts +162 -0
- package/src/monitor-routing.ts +66 -0
- package/src/monitor-types.ts +34 -0
- package/src/monitor-webhook.test.ts +670 -0
- package/src/monitor-webhook.ts +361 -0
- package/src/monitor.reply-delivery.test.ts +145 -0
- package/src/monitor.test.ts +389 -0
- package/src/monitor.ts +530 -0
- package/src/monitor.webhook-routing.test.ts +258 -0
- package/src/runtime.ts +10 -0
- package/src/secret-contract.test.ts +61 -0
- package/src/secret-contract.ts +162 -0
- package/src/setup-core.ts +41 -0
- package/src/setup-surface.ts +244 -0
- package/src/setup.test.ts +620 -0
- package/src/targets.test.ts +562 -0
- package/src/targets.ts +67 -0
- package/src/types.config.ts +4 -0
- package/src/types.ts +139 -0
- package/test-api.ts +3 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Googlechat plugin module implements monitor routing behavior.
|
|
2
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
import {
|
|
4
|
+
createFixedWindowRateLimiter,
|
|
5
|
+
WEBHOOK_RATE_LIMIT_DEFAULTS,
|
|
6
|
+
} from "actagent/plugin-sdk/webhook-ingress";
|
|
7
|
+
import { createWebhookInFlightLimiter } from "actagent/plugin-sdk/webhook-request-guards";
|
|
8
|
+
import { registerWebhookTargetWithPluginRoute } from "actagent/plugin-sdk/webhook-targets";
|
|
9
|
+
import type { WebhookTarget } from "./monitor-types.js";
|
|
10
|
+
import { createGoogleChatWebhookRequestHandler } from "./monitor-webhook.js";
|
|
11
|
+
import type { GoogleChatEvent } from "./types.js";
|
|
12
|
+
|
|
13
|
+
type ProcessGoogleChatEvent = (event: GoogleChatEvent, target: WebhookTarget) => Promise<void>;
|
|
14
|
+
|
|
15
|
+
const webhookTargets = new Map<string, WebhookTarget[]>();
|
|
16
|
+
const webhookRateLimiter = createFixedWindowRateLimiter({
|
|
17
|
+
windowMs: WEBHOOK_RATE_LIMIT_DEFAULTS.windowMs,
|
|
18
|
+
maxRequests: WEBHOOK_RATE_LIMIT_DEFAULTS.maxRequests,
|
|
19
|
+
maxTrackedKeys: WEBHOOK_RATE_LIMIT_DEFAULTS.maxTrackedKeys,
|
|
20
|
+
});
|
|
21
|
+
const webhookInFlightLimiter = createWebhookInFlightLimiter();
|
|
22
|
+
|
|
23
|
+
let processGoogleChatEvent: ProcessGoogleChatEvent = async () => {};
|
|
24
|
+
|
|
25
|
+
export function setGoogleChatWebhookEventProcessor(processEvent: ProcessGoogleChatEvent): void {
|
|
26
|
+
processGoogleChatEvent = processEvent;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const googleChatWebhookRequestHandler = createGoogleChatWebhookRequestHandler({
|
|
30
|
+
webhookTargets,
|
|
31
|
+
webhookRateLimiter,
|
|
32
|
+
webhookInFlightLimiter,
|
|
33
|
+
processEvent: async (event, target) => {
|
|
34
|
+
await processGoogleChatEvent(event, target);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export function registerGoogleChatWebhookTarget(target: WebhookTarget): () => void {
|
|
39
|
+
return registerWebhookTargetWithPluginRoute({
|
|
40
|
+
targetsByPath: webhookTargets,
|
|
41
|
+
target,
|
|
42
|
+
route: {
|
|
43
|
+
auth: "plugin",
|
|
44
|
+
match: "exact",
|
|
45
|
+
pluginId: "googlechat",
|
|
46
|
+
source: "googlechat-webhook",
|
|
47
|
+
accountId: target.account.accountId,
|
|
48
|
+
log: target.runtime.log,
|
|
49
|
+
handler: async (req, res) => {
|
|
50
|
+
const handled = await handleGoogleChatWebhookRequest(req, res);
|
|
51
|
+
if (!handled && !res.headersSent) {
|
|
52
|
+
res.statusCode = 404;
|
|
53
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
54
|
+
res.end("Not Found");
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}).unregister;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function handleGoogleChatWebhookRequest(
|
|
62
|
+
req: IncomingMessage,
|
|
63
|
+
res: ServerResponse,
|
|
64
|
+
): Promise<boolean> {
|
|
65
|
+
return await googleChatWebhookRequestHandler(req, res);
|
|
66
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Googlechat plugin module implements monitor types behavior.
|
|
2
|
+
import type { ACTAgentConfig } from "actagent/plugin-sdk/core";
|
|
3
|
+
import type { ResolvedGoogleChatAccount } from "./accounts.js";
|
|
4
|
+
import type { GoogleChatAudienceType } from "./auth.js";
|
|
5
|
+
import type { getGoogleChatRuntime } from "./runtime.js";
|
|
6
|
+
|
|
7
|
+
export type GoogleChatRuntimeEnv = {
|
|
8
|
+
log?: (message: string) => void;
|
|
9
|
+
error?: (message: string) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type GoogleChatMonitorOptions = {
|
|
13
|
+
account: ResolvedGoogleChatAccount;
|
|
14
|
+
config: ACTAgentConfig;
|
|
15
|
+
runtime: GoogleChatRuntimeEnv;
|
|
16
|
+
abortSignal: AbortSignal;
|
|
17
|
+
webhookPath?: string;
|
|
18
|
+
webhookUrl?: string;
|
|
19
|
+
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type GoogleChatCoreRuntime = ReturnType<typeof getGoogleChatRuntime>;
|
|
23
|
+
|
|
24
|
+
export type WebhookTarget = {
|
|
25
|
+
account: ResolvedGoogleChatAccount;
|
|
26
|
+
config: ACTAgentConfig;
|
|
27
|
+
runtime: GoogleChatRuntimeEnv;
|
|
28
|
+
core: GoogleChatCoreRuntime;
|
|
29
|
+
path: string;
|
|
30
|
+
audienceType?: GoogleChatAudienceType;
|
|
31
|
+
audience?: string;
|
|
32
|
+
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void;
|
|
33
|
+
mediaMaxMb: number;
|
|
34
|
+
};
|