UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

66 lines (65 loc) • 2.57 kB
import { Et as _enum, Fn as object, Jn as string, Lt as boolean, Pn as number, Zt as email, or as union, sr as unknown, xn as literal } from "./schemas-Cy6abvsu.mjs"; import { t as GUARD_RULES_MAX_CHARS } from "./guard-1Rt7U6rs.mjs"; //#region extensions/reef/src/config-schema.ts const HandleSchema = string().regex(/^[a-z0-9][a-z0-9_-]{0,62}$/); const GuardRuleTextSchema = string().max(GUARD_RULES_MAX_CHARS).regex(/\S/, "rules text must not be blank"); const RelayUrlSchema = string().regex(/^[hH][tT][tT][pP][sS]?:\/\/[^\\/?#@]+\/?$/, "Reef relay URL must be an HTTP(S) origin without credentials, path, query, or hash").url(); const OpenAiOAuthProfileIdSchema = string().regex(/^openai:[^\s:/][^\s/]*$/); const GuardCommonSchema = { pinnedModel: string().min(1), policyVersion: string().min(1), timeoutMs: number().int().min(100).max(12e4), rules: object({ outbound: GuardRuleTextSchema.optional(), inbound: GuardRuleTextSchema.optional() }).strict().optional() }; const GuardSchema = union([object({ provider: literal("openai"), authMode: literal("oauth"), authProfileId: OpenAiOAuthProfileIdSchema, ...GuardCommonSchema }).strict(), object({ provider: _enum(["anthropic", "openai"]), authMode: literal("api-key").optional(), apiKeyEnv: string().regex(/^[A-Z_][A-Z0-9_]*$/), ...GuardCommonSchema }).strict()]); const ReefChannelConfigSchema = object({ enabled: boolean().default(true), configWrites: boolean().optional(), relayUrl: RelayUrlSchema.default("https://reefwire.ai"), handle: HandleSchema.optional(), email: email().optional(), guard: GuardSchema.optional(), stateDir: string().min(1).optional(), requestPolicy: _enum([ "code-only", "friends-of-friends", "open" ]).default("code-only"), friends: unknown().optional() }).strict(); function resolveReefConfig(e) { return ReefChannelConfigSchema.parse(e.channels?.reef ?? {}); } function normalizeReefTarget(e) { const t = e.trim().replace(/^(reef:|@)/i, "").toLowerCase(); return HandleSchema.safeParse(t).success ? t : void 0; } function parseReefRelayUrl(e) { return new URL(RelayUrlSchema.parse(e)).origin; } function autonomyBudget(e) { return { notifyOnly: e === "notify-only", botLoopProtection: { enabled: true, maxEventsPerWindow: e === "extended" ? 12 : e === "bounded" ? 3 : 1, windowSeconds: e === "extended" ? 3600 : 86400, cooldownSeconds: 86400 } }; } //#endregion export { parseReefRelayUrl as a, normalizeReefTarget as i, ReefChannelConfigSchema as n, resolveReefConfig as o, autonomyBudget as r, OpenAiOAuthProfileIdSchema as t };