openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
113 lines (112 loc) • 5.87 kB
JavaScript
import { At as boolean, Et as array, Nn as record, Rn as string, Tn as object, Xn as union, dn as literal, wn as number, yt as _enum } from "./schemas-zxit8y5H.js";
import "./zod-schema.agent-runtime-BB0ECdB0.js";
import { C as ReplyToModeSchema, _ as MentionPatternsPolicySchema, a as ContextVisibilityModeSchema, g as MarkdownConfigSchema, i as ChannelStreamingBlockSchema, k as TextChunkModeSchema, o as DmConfigSchema, r as ChannelDeliveryStreamingConfigSchema, s as DmPolicySchema, t as BlockStreamingChunkSchema, u as GroupPolicySchema } from "./zod-schema.core-D6k6NKKA.js";
import "./config-schema-C6z2p1z2.js";
import { a as NativeExecApprovalEnableModeSchema, o as ChannelHealthMonitorSchema, s as ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels-config-atVR1nln.js";
//#region src/config/zod-schema.channel-messaging-common.ts
const UnifiedStreamingModeSchema = _enum([
"off",
"partial",
"block",
"progress"
]);
const ChannelStreamingPreviewSchema = object({
chunk: BlockStreamingChunkSchema.optional(),
toolProgress: boolean().optional(),
commandText: _enum(["raw", "status"]).optional()
}).strict();
const ChannelStreamingProgressSchema = object({
label: union([string(), literal(false)]).optional(),
labels: array(string()).optional(),
maxLines: number().int().positive().optional(),
maxLineChars: number().int().positive().optional(),
toolProgress: boolean().optional(),
commandText: _enum(["raw", "status"]).optional(),
commentary: boolean().optional(),
narration: boolean().optional()
}).strict();
const ChannelPreviewStreamingConfigSchema = object({
mode: UnifiedStreamingModeSchema.optional(),
chunkMode: TextChunkModeSchema.optional(),
preview: ChannelStreamingPreviewSchema.optional(),
progress: ChannelStreamingProgressSchema.optional(),
block: ChannelStreamingBlockSchema.optional()
}).strict();
const CommonCapabilitiesSchema = array(string()).optional();
const CommonIdListSchema = array(union([string(), number()])).optional();
const CommonDefaultToSchema = string().optional();
const CommonMentionPatternsSchema = MentionPatternsPolicySchema.optional();
const CommonStreamingSchema = ChannelDeliveryStreamingConfigSchema.optional();
const CommonMediaMaxMbSchema = number().positive().optional();
const CommonReplyToModeSchema = ReplyToModeSchema.optional();
const ChannelAccountPolicyDefaults = {
dmPolicy: DmPolicySchema.optional().default("pairing"),
groupPolicy: GroupPolicySchema.optional().default("allowlist")
};
function createCommonChannelAccountShape(options) {
return {
name: string().optional(),
capabilities: options.capabilities ?? CommonCapabilitiesSchema,
markdown: MarkdownConfigSchema,
configWrites: boolean().optional(),
enabled: boolean().optional(),
dmPolicy: DmPolicySchema.optional(),
allowFrom: options.allowFrom ?? CommonIdListSchema,
defaultTo: options.defaultTo ?? CommonDefaultToSchema,
groupAllowFrom: options.groupAllowFrom ?? CommonIdListSchema,
groupPolicy: GroupPolicySchema.optional(),
mentionPatterns: options.mentionPatterns ?? CommonMentionPatternsSchema,
contextVisibility: ContextVisibilityModeSchema.optional(),
historyLimit: number().int().min(0).optional(),
dmHistoryLimit: number().int().min(0).optional(),
dms: record(string(), DmConfigSchema.optional()).optional(),
textChunkLimit: number().int().positive().optional(),
streaming: options.streaming ?? CommonStreamingSchema,
heartbeatVisibility: ChannelHeartbeatVisibilitySchema,
healthMonitor: ChannelHealthMonitorSchema,
responsePrefix: string().optional(),
mediaMaxMb: options.mediaMaxMb ?? CommonMediaMaxMbSchema,
replyToMode: options.replyToMode ?? CommonReplyToModeSchema
};
}
/** Build optional account leaves and separate root-only policy defaults. */
function buildChannelAccountSchemaParts(options = {}) {
const shape = createCommonChannelAccountShape(options);
const omitted = new Set(options.omit ?? []);
return {
accountShape: Object.fromEntries(Object.entries(shape).filter(([key]) => !omitted.has(key))),
rootPolicyShape: ChannelAccountPolicyDefaults
};
}
const ChannelDangerouslyAllowNameMatchingSchema = boolean().optional();
const ChannelSendReadReceiptsSchema = boolean().optional();
/** Build the shared allowBots leaf without widening boolean-only channels. */
function buildChannelAllowBotsSchema(options) {
return options?.allowMentions ? union([boolean(), literal("mentions")]).optional() : boolean().optional();
}
/** Build native exec-approval routing with channel-specific approver ids and extras. */
function buildChannelExecApprovalsSchema(approverSchema, extraShape) {
return object({
enabled: NativeExecApprovalEnableModeSchema.optional(),
approvers: array(approverSchema).optional(),
agentFilter: array(string()).optional(),
sessionFilter: array(string()).optional(),
target: _enum([
"dm",
"channel",
"both"
]).optional(),
...extraShape ?? {}
}).strict().optional();
}
/** Build the repeated reaction leaves while retaining each channel's exact enum. */
function buildChannelReactionShape(options) {
return {
...options.notificationModes ? { reactionNotifications: _enum(options.notificationModes).optional() } : {},
...options.reactionAllowlist ? { reactionAllowlist: array(union([string(), number()])).optional() } : {},
...options.reactionLevels ? { reactionLevel: _enum(options.reactionLevels).optional() } : {},
...options.ackReaction ? { ackReaction: options.ackReaction } : {}
};
}
//#endregion
export { ChannelStreamingProgressSchema as a, buildChannelAllowBotsSchema as c, ChannelStreamingPreviewSchema as i, buildChannelExecApprovalsSchema as l, ChannelPreviewStreamingConfigSchema as n, UnifiedStreamingModeSchema as o, ChannelSendReadReceiptsSchema as r, buildChannelAccountSchemaParts as s, ChannelDangerouslyAllowNameMatchingSchema as t, buildChannelReactionShape as u };