UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

179 lines (178 loc) • 7.18 kB
//#region src/plugin-sdk/channel-config-ui-hints.ts function createChannelDmPolicyUiHints(e) { const t = { label: `${e.channelLabel} DM Policy`, help: `Direct message access control ("pairing" recommended). "open" requires channels.${e.channelKey}.allowFrom=["*"].` }; const n = { "dm.policy": { label: t.label, help: `${t.help.slice(0, -1)} (legacy: channels.${e.channelKey}.dm.allowFrom).` } }; if (!e.includeLegacyNestedPolicy) return { dmPolicy: t }; return e.legacyNestedPolicyOrder === "after" ? { dmPolicy: t, ...n } : { ...n, dmPolicy: t }; } function createChannelConfigWritesUiHint(e) { return { configWrites: { label: `${e} Config Writes`, help: `Allow ${e} to write config in response to channel events/commands (default: true).` } }; } function createChannelMentionPatternUiHints(e) { const t = e.policyNote ? ` ${e.policyNote}` : ""; const n = e.denyNote ? ` ${e.denyNote}` : ""; return { mentionPatterns: { label: `${e.channelLabel} Mention Pattern Policy`, help: `Scopes configured groupChat mentionPatterns to selected ${e.policyTargetDescription ?? e.targetDescription}.${t}` }, "mentionPatterns.mode": { label: `${e.channelLabel} Mention Pattern Mode`, help: "\"allow\" enables configured regex mention patterns unless denyIn matches; \"deny\" disables them unless allowIn matches." }, "mentionPatterns.allowIn": { label: `${e.channelLabel} Mention Pattern Allowlist`, help: `${e.targetDescription} where configured regex mention patterns are enabled when mode is deny.` }, "mentionPatterns.denyIn": { label: `${e.channelLabel} Mention Pattern Denylist`, help: `${e.targetDescription} where configured regex mention patterns are disabled.${n}` } }; } function createChannelNativeCommandUiHints(e) { return { "commands.native": { label: `${e} Native Commands`, help: `Override native commands for ${e} (bool or "auto").` }, "commands.nativeSkills": { label: `${e} Native Skill Commands`, help: `Override native skill commands for ${e} (bool or "auto").` } }; } function createChannelImplicitMentionsUiHints(e) { return { implicitMentions: { label: `${e} Implicit Mentions`, help: `Control which ${e} reply, quote, and thread-participation signals count as mentions. Unset flags preserve the channel defaults.` }, "implicitMentions.replyToBot": { label: `${e} Replies to Bot`, help: "Treat replies to the bot's own messages as implicit mentions when the channel reports that signal." }, "implicitMentions.quotedBot": { label: `${e} Quoted Bot Messages`, help: "Treat messages quoting the bot as implicit mentions when the channel reports that signal." }, "implicitMentions.threadParticipation": { label: `${e} Thread Participation`, help: "Treat follow-ups in threads where the bot participated as implicit mentions when the channel reports that signal." } }; } function createChannelProgressUiHints(e) { const t = e.channelLabel; const n = { "streaming.progress.commentary": { label: `${t} Progress Commentary`, help: "Show assistant commentary/preamble text in the temporary progress draft. Final answer delivery is unchanged." } }; return { "streaming.progress.label": { label: `${t} Progress Label`, help: `Initial progress ${e.titleWording ? "title" : "draft title"}. Use "auto" for built-in single-word labels, a custom string, or false to hide the title.` }, "streaming.progress.labels": { label: `${t} Progress Label Pool`, help: e.labels === "openclaw" ? "Candidate labels for streaming.progress.label=\"auto\". Leave unset to use OpenClaw built-in progress labels." : "Candidate labels for streaming.progress.label=\"auto\". Leave unset to use the built-in \"Working\" label." }, "streaming.progress.maxLines": { label: `${t} Progress Max Lines`, help: `Maximum number of compact progress lines to keep below the ${e.titleWording ? "progress title" : "draft label"} (default: 8).` }, "streaming.progress.maxLineChars": { label: `${t} Progress Max Line Chars`, help: "Maximum characters per compact progress line before truncation (default: 120). Prose cuts at word boundaries; commands and paths keep useful suffixes." }, "streaming.progress.toolProgress": { label: `${t} Progress Tool Lines`, help: "Show individual tool activity, including intermediate failures, in progress drafts (default: false). Quiet drafts retain plans, approval requests, and authored progress text. Terminal task errors remain visible." }, ...e.includeCommentary && e.commentaryOrder !== "after-command" ? n : {}, "streaming.progress.commandText": { label: `${t} Progress Command Text`, help: `Command/exec detail in progress${e.titleWording ? "" : " draft"} lines: "status" is the safe default; "raw" opts into command text.` }, ...e.includeCommentary && e.commentaryOrder === "after-command" ? n : {} }; } const STREAMING_HINT_LABELS = { "": "Streaming Mode", mode: "Streaming Mode", chunkMode: "Chunk Mode", "block.enabled": "Block Streaming Enabled", "block.coalesce": "Block Streaming Coalesce", nativeTransport: "Native Streaming", "preview.chunk.minChars": "Draft Chunk Min Chars", "preview.chunk.maxChars": "Draft Chunk Max Chars", "preview.chunk.breakPreference": "Draft Chunk Break Preference", "preview.toolProgress": "Draft Tool Progress", "preview.commandText": "Draft Command Text", "progress.style": "Progress Style", "progress.nativeTaskCards": "Native Progress Task Cards" }; function createChannelStreamingUiHints(e, t) { return Object.fromEntries(Object.entries(t).map(([t, n]) => [t ? `streaming.${t}` : "streaming", typeof n === "string" ? { label: `${e} ${STREAMING_HINT_LABELS[t]}`, help: n } : n])); } function createChannelRetryUiHints(e) { return { "retry.attempts": { label: `${e} Retry Attempts`, help: `Max retry attempts for outbound ${e} API calls (default: 3).` }, "retry.minDelayMs": { label: `${e} Retry Min Delay (ms)`, help: `Minimum retry delay in ms for ${e} outbound calls.` }, "retry.maxDelayMs": { label: `${e} Retry Max Delay (ms)`, help: `Maximum retry delay cap in ms for ${e} outbound calls.` }, "retry.jitter": { label: `${e} Retry Jitter`, help: `Jitter factor (0-1) applied to ${e} retry delays.` } }; } function createChannelConfigUiHints(e) { return { ...e.dmPolicy ? createChannelDmPolicyUiHints({ channelLabel: e.channelLabel, ...e.dmPolicy }) : {}, ...e.configWrites ? createChannelConfigWritesUiHint(e.channelLabel) : {}, ...e.mentionPatterns ? createChannelMentionPatternUiHints({ channelLabel: e.channelLabel, ...e.mentionPatterns }) : {}, ...e.nativeCommands ? createChannelNativeCommandUiHints(e.channelLabel) : {}, ...e.implicitMentions ? createChannelImplicitMentionsUiHints(e.channelLabel) : {}, ...e.streaming ? createChannelStreamingUiHints(e.channelLabel, e.streaming) : {}, ...e.progress ? createChannelProgressUiHints({ channelLabel: e.channelLabel, ...e.progress }) : {}, ...e.retry ? createChannelRetryUiHints(e.channelLabel) : {} }; } //#endregion export { createChannelConfigUiHints as t };