mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 01:02:03 +03:00
Commands: add commands.allowFrom config
This commit is contained in:
@@ -306,6 +306,7 @@ const FIELD_LABELS: Record<string, string> = {
|
||||
"commands.restart": "Allow Restart",
|
||||
"commands.useAccessGroups": "Use Access Groups",
|
||||
"commands.ownerAllowFrom": "Command Owners",
|
||||
"commands.allowFrom": "Command Access Allowlist",
|
||||
"ui.seamColor": "Accent Color",
|
||||
"ui.assistant.name": "Assistant Name",
|
||||
"ui.assistant.avatar": "Assistant Avatar",
|
||||
@@ -675,6 +676,8 @@ const FIELD_HELP: Record<string, string> = {
|
||||
"commands.useAccessGroups": "Enforce access-group allowlists/policies for commands.",
|
||||
"commands.ownerAllowFrom":
|
||||
"Explicit owner allowlist for owner-only tools/commands. Use channel-native IDs (optionally prefixed like \"whatsapp:+15551234567\"). '*' is ignored.",
|
||||
"commands.allowFrom":
|
||||
'Per-provider allowlist restricting who can use slash commands. If set, overrides the channel\'s allowFrom for command authorization. Use \'*\' key for global default; provider-specific keys (e.g. \'discord\') override the global. Example: { "*": ["user1"], "discord": ["user:123"] }.',
|
||||
"session.dmScope":
|
||||
'DM session scoping: "main" keeps continuity; "per-peer", "per-channel-peer", or "per-account-channel-peer" isolates DM history (recommended for shared inboxes/multi-account).',
|
||||
"session.identityLinks":
|
||||
|
||||
@@ -88,6 +88,13 @@ export type MessagesConfig = {
|
||||
|
||||
export type NativeCommandsSetting = boolean | "auto";
|
||||
|
||||
/**
|
||||
* Per-provider allowlist for command authorization.
|
||||
* Keys are channel IDs (e.g., "discord", "whatsapp") or "*" for global default.
|
||||
* Values are arrays of sender IDs allowed to use commands on that channel.
|
||||
*/
|
||||
export type CommandAllowFrom = Record<string, Array<string | number>>;
|
||||
|
||||
export type CommandsConfig = {
|
||||
/** Enable native command registration when supported (default: "auto"). */
|
||||
native?: NativeCommandsSetting;
|
||||
@@ -109,6 +116,13 @@ export type CommandsConfig = {
|
||||
useAccessGroups?: boolean;
|
||||
/** Explicit owner allowlist for owner-only tools/commands (channel-native IDs). */
|
||||
ownerAllowFrom?: Array<string | number>;
|
||||
/**
|
||||
* Per-provider allowlist restricting who can use slash commands.
|
||||
* If set, overrides the channel's allowFrom for command authorization.
|
||||
* Use "*" key for global default, provider-specific keys override the global.
|
||||
* Example: { "*": ["user1"], discord: ["user:123"] }
|
||||
*/
|
||||
allowFrom?: CommandAllowFrom;
|
||||
};
|
||||
|
||||
export type ProviderCommandsConfig = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { z } from "zod";
|
||||
import { parseByteSize } from "../cli/parse-bytes.js";
|
||||
import { parseDurationMs } from "../cli/parse-duration.js";
|
||||
import { ElevatedAllowFromSchema } from "./zod-schema.agent-runtime.js";
|
||||
import {
|
||||
GroupChatSchema,
|
||||
InboundDebounceSchema,
|
||||
@@ -158,6 +159,7 @@ export const CommandsSchema = z
|
||||
restart: z.boolean().optional(),
|
||||
useAccessGroups: z.boolean().optional(),
|
||||
ownerAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
allowFrom: ElevatedAllowFromSchema.optional(),
|
||||
})
|
||||
.strict()
|
||||
.optional()
|
||||
|
||||
Reference in New Issue
Block a user