feat: add beta googlechat channel
This commit is contained in:
committed by
Peter Steinberger
parent
60661441b1
commit
b76cd6695d
@@ -1,4 +1,5 @@
|
||||
import type { DiscordConfig } from "./types.discord.js";
|
||||
import type { GoogleChatConfig } from "./types.googlechat.js";
|
||||
import type { IMessageConfig } from "./types.imessage.js";
|
||||
import type { MSTeamsConfig } from "./types.msteams.js";
|
||||
import type { SignalConfig } from "./types.signal.js";
|
||||
@@ -27,6 +28,7 @@ export type ChannelsConfig = {
|
||||
whatsapp?: WhatsAppConfig;
|
||||
telegram?: TelegramConfig;
|
||||
discord?: DiscordConfig;
|
||||
googlechat?: GoogleChatConfig;
|
||||
slack?: SlackConfig;
|
||||
signal?: SignalConfig;
|
||||
imessage?: IMessageConfig;
|
||||
|
||||
97
src/config/types.googlechat.ts
Normal file
97
src/config/types.googlechat.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import type {
|
||||
BlockStreamingCoalesceConfig,
|
||||
DmPolicy,
|
||||
GroupPolicy,
|
||||
ReplyToMode,
|
||||
} from "./types.base.js";
|
||||
import type { DmConfig } from "./types.messages.js";
|
||||
|
||||
export type GoogleChatDmConfig = {
|
||||
/** If false, ignore all incoming Google Chat DMs. Default: true. */
|
||||
enabled?: boolean;
|
||||
/** Direct message access policy (default: pairing). */
|
||||
policy?: DmPolicy;
|
||||
/** Allowlist for DM senders (user ids or emails). */
|
||||
allowFrom?: Array<string | number>;
|
||||
};
|
||||
|
||||
export type GoogleChatGroupConfig = {
|
||||
/** If false, disable the bot in this space. (Alias for allow: false.) */
|
||||
enabled?: boolean;
|
||||
/** Legacy allow toggle; prefer enabled. */
|
||||
allow?: boolean;
|
||||
/** Require mentioning the bot to trigger replies. */
|
||||
requireMention?: boolean;
|
||||
/** Allowlist of users that can invoke the bot in this space. */
|
||||
users?: Array<string | number>;
|
||||
/** Optional system prompt for this space. */
|
||||
systemPrompt?: string;
|
||||
};
|
||||
|
||||
export type GoogleChatActionConfig = {
|
||||
reactions?: boolean;
|
||||
};
|
||||
|
||||
export type GoogleChatAccountConfig = {
|
||||
/** Optional display name for this account (used in CLI/UI lists). */
|
||||
name?: string;
|
||||
/** Optional provider capability tags used for agent/runtime guidance. */
|
||||
capabilities?: string[];
|
||||
/** Allow channel-initiated config writes (default: true). */
|
||||
configWrites?: boolean;
|
||||
/** If false, do not start this Google Chat account. Default: true. */
|
||||
enabled?: boolean;
|
||||
/** Allow bot-authored messages to trigger replies (default: false). */
|
||||
allowBots?: boolean;
|
||||
/** Default mention requirement for space messages (default: true). */
|
||||
requireMention?: boolean;
|
||||
/**
|
||||
* Controls how space messages are handled:
|
||||
* - "open": spaces bypass allowlists; mention-gating applies
|
||||
* - "disabled": block all space messages
|
||||
* - "allowlist": only allow spaces present in channels.googlechat.groups
|
||||
*/
|
||||
groupPolicy?: GroupPolicy;
|
||||
/** Optional allowlist for space senders (user ids or emails). */
|
||||
groupAllowFrom?: Array<string | number>;
|
||||
/** Per-space configuration keyed by space id or name. */
|
||||
groups?: Record<string, GoogleChatGroupConfig>;
|
||||
/** Service account JSON (inline string or object). */
|
||||
serviceAccount?: string | Record<string, unknown>;
|
||||
/** Service account JSON file path. */
|
||||
serviceAccountFile?: string;
|
||||
/** Webhook audience type (app-url or project-number). */
|
||||
audienceType?: "app-url" | "project-number";
|
||||
/** Audience value (app URL or project number). */
|
||||
audience?: string;
|
||||
/** Google Chat webhook path (default: /googlechat). */
|
||||
webhookPath?: string;
|
||||
/** Google Chat webhook URL (used to derive the path). */
|
||||
webhookUrl?: string;
|
||||
/** Optional bot user resource name (users/...). */
|
||||
botUser?: string;
|
||||
/** Max space messages to keep as history context (0 disables). */
|
||||
historyLimit?: number;
|
||||
/** Max DM turns to keep as history context. */
|
||||
dmHistoryLimit?: number;
|
||||
/** Per-DM config overrides keyed by user id. */
|
||||
dms?: Record<string, DmConfig>;
|
||||
/** Outbound text chunk size (chars). Default: 4000. */
|
||||
textChunkLimit?: number;
|
||||
blockStreaming?: boolean;
|
||||
/** Merge streamed block replies before sending. */
|
||||
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
||||
mediaMaxMb?: number;
|
||||
/** Control reply threading when reply tags are present (off|first|all). */
|
||||
replyToMode?: ReplyToMode;
|
||||
/** Per-action tool gating (default: true for all). */
|
||||
actions?: GoogleChatActionConfig;
|
||||
dm?: GoogleChatDmConfig;
|
||||
};
|
||||
|
||||
export type GoogleChatConfig = {
|
||||
/** Optional per-account Google Chat configuration (multi-account). */
|
||||
accounts?: Record<string, GoogleChatAccountConfig>;
|
||||
/** Optional default account id when multiple accounts are configured. */
|
||||
defaultAccount?: string;
|
||||
} & GoogleChatAccountConfig;
|
||||
@@ -23,6 +23,7 @@ export type HookMappingConfig = {
|
||||
| "whatsapp"
|
||||
| "telegram"
|
||||
| "discord"
|
||||
| "googlechat"
|
||||
| "slack"
|
||||
| "signal"
|
||||
| "imessage"
|
||||
|
||||
@@ -12,6 +12,7 @@ export type QueueModeByProvider = {
|
||||
whatsapp?: QueueMode;
|
||||
telegram?: QueueMode;
|
||||
discord?: QueueMode;
|
||||
googlechat?: QueueMode;
|
||||
slack?: QueueMode;
|
||||
signal?: QueueMode;
|
||||
imessage?: QueueMode;
|
||||
|
||||
@@ -10,6 +10,7 @@ export * from "./types.channels.js";
|
||||
export * from "./types.clawdbot.js";
|
||||
export * from "./types.cron.js";
|
||||
export * from "./types.discord.js";
|
||||
export * from "./types.googlechat.js";
|
||||
export * from "./types.gateway.js";
|
||||
export * from "./types.hooks.js";
|
||||
export * from "./types.imessage.js";
|
||||
|
||||
@@ -260,6 +260,75 @@ export const DiscordConfigSchema = DiscordAccountSchema.extend({
|
||||
accounts: z.record(z.string(), DiscordAccountSchema.optional()).optional(),
|
||||
});
|
||||
|
||||
export const GoogleChatDmSchema = z
|
||||
.object({
|
||||
enabled: z.boolean().optional(),
|
||||
policy: DmPolicySchema.optional().default("pairing"),
|
||||
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
})
|
||||
.strict()
|
||||
.superRefine((value, ctx) => {
|
||||
requireOpenAllowFrom({
|
||||
policy: value.policy,
|
||||
allowFrom: value.allowFrom,
|
||||
ctx,
|
||||
path: ["allowFrom"],
|
||||
message:
|
||||
'channels.googlechat.dm.policy="open" requires channels.googlechat.dm.allowFrom to include "*"',
|
||||
});
|
||||
});
|
||||
|
||||
export const GoogleChatGroupSchema = z
|
||||
.object({
|
||||
enabled: z.boolean().optional(),
|
||||
allow: z.boolean().optional(),
|
||||
requireMention: z.boolean().optional(),
|
||||
users: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
systemPrompt: z.string().optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GoogleChatAccountSchema = z
|
||||
.object({
|
||||
name: z.string().optional(),
|
||||
capabilities: z.array(z.string()).optional(),
|
||||
enabled: z.boolean().optional(),
|
||||
configWrites: z.boolean().optional(),
|
||||
allowBots: z.boolean().optional(),
|
||||
requireMention: z.boolean().optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
groups: z.record(z.string(), GoogleChatGroupSchema.optional()).optional(),
|
||||
serviceAccount: z.union([z.string(), z.record(z.string(), z.unknown())]).optional(),
|
||||
serviceAccountFile: z.string().optional(),
|
||||
audienceType: z.enum(["app-url", "project-number"]).optional(),
|
||||
audience: z.string().optional(),
|
||||
webhookPath: z.string().optional(),
|
||||
webhookUrl: z.string().optional(),
|
||||
botUser: z.string().optional(),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
textChunkLimit: z.number().int().positive().optional(),
|
||||
blockStreaming: z.boolean().optional(),
|
||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||
mediaMaxMb: z.number().positive().optional(),
|
||||
replyToMode: ReplyToModeSchema.optional(),
|
||||
actions: z
|
||||
.object({
|
||||
reactions: z.boolean().optional(),
|
||||
})
|
||||
.strict()
|
||||
.optional(),
|
||||
dm: GoogleChatDmSchema.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GoogleChatConfigSchema = GoogleChatAccountSchema.extend({
|
||||
accounts: z.record(z.string(), GoogleChatAccountSchema.optional()).optional(),
|
||||
defaultAccount: z.string().optional(),
|
||||
});
|
||||
|
||||
export const SlackDmSchema = z
|
||||
.object({
|
||||
enabled: z.boolean().optional(),
|
||||
|
||||
@@ -3,6 +3,7 @@ import { z } from "zod";
|
||||
import {
|
||||
BlueBubblesConfigSchema,
|
||||
DiscordConfigSchema,
|
||||
GoogleChatConfigSchema,
|
||||
IMessageConfigSchema,
|
||||
MSTeamsConfigSchema,
|
||||
SignalConfigSchema,
|
||||
@@ -29,6 +30,7 @@ export const ChannelsSchema = z
|
||||
whatsapp: WhatsAppConfigSchema.optional(),
|
||||
telegram: TelegramConfigSchema.optional(),
|
||||
discord: DiscordConfigSchema.optional(),
|
||||
googlechat: GoogleChatConfigSchema.optional(),
|
||||
slack: SlackConfigSchema.optional(),
|
||||
signal: SignalConfigSchema.optional(),
|
||||
imessage: IMessageConfigSchema.optional(),
|
||||
|
||||
Reference in New Issue
Block a user