feat: auto native commands defaults

This commit is contained in:
Peter Steinberger
2026-01-12 21:49:44 +00:00
parent 99fea64823
commit 26d5cca97c
13 changed files with 121 additions and 21 deletions

35
src/config/commands.ts Normal file
View File

@@ -0,0 +1,35 @@
import type { NativeCommandsSetting } from "./types.js";
import { normalizeProviderId } from "../providers/registry.js";
import type { ProviderId } from "../providers/plugins/types.js";
function resolveAutoDefault(providerId?: ProviderId): boolean {
const id = normalizeProviderId(providerId);
if (!id) return false;
if (id === "discord" || id === "telegram") return true;
if (id === "slack") return false;
return false;
}
export function resolveNativeCommandsEnabled(params: {
providerId: ProviderId;
providerSetting?: NativeCommandsSetting;
globalSetting?: NativeCommandsSetting;
}): boolean {
const { providerId, providerSetting, globalSetting } = params;
const setting =
providerSetting === undefined ? globalSetting : providerSetting;
if (setting === true) return true;
if (setting === false) return false;
// auto or undefined -> heuristic
return resolveAutoDefault(providerId);
}
export function isNativeCommandsExplicitlyDisabled(params: {
providerSetting?: NativeCommandsSetting;
globalSetting?: NativeCommandsSetting;
}): boolean {
const { providerSetting, globalSetting } = params;
if (providerSetting === false) return true;
if (providerSetting === undefined) return globalSetting === false;
return false;
}

View File

@@ -283,6 +283,12 @@ const FIELD_HELP: Record<string, string> = {
"Allow /restart and gateway restart tool actions (default: false).",
"commands.useAccessGroups":
"Enforce access-group allowlists/policies for commands.",
"discord.commands.native":
'Override native commands for Discord (bool or "auto").',
"telegram.commands.native":
'Override native commands for Telegram (bool or "auto").',
"slack.commands.native":
'Override native commands for Slack (bool or "auto").',
"session.agentToAgent.maxPingPongTurns":
"Max reply-back turns between requester and target (05).",
"messages.ackReaction":

View File

@@ -359,6 +359,8 @@ export type TelegramAccountConfig = {
name?: string;
/** Optional provider capability tags used for agent/runtime guidance. */
capabilities?: string[];
/** Override native command registration for Telegram (bool or "auto"). */
commands?: ProviderCommandsConfig;
/**
* Controls how Telegram direct chats (DMs) are handled:
* - "pairing" (default): unknown senders get a pairing code; owner must approve
@@ -510,6 +512,8 @@ export type DiscordAccountConfig = {
name?: string;
/** Optional provider capability tags used for agent/runtime guidance. */
capabilities?: string[];
/** Override native command registration for Discord (bool or "auto"). */
commands?: ProviderCommandsConfig;
/** If false, do not start this Discord account. Default: true. */
enabled?: boolean;
token?: string;
@@ -621,6 +625,8 @@ export type SlackAccountConfig = {
name?: string;
/** Optional provider capability tags used for agent/runtime guidance. */
capabilities?: string[];
/** Override native command registration for Slack (bool or "auto"). */
commands?: ProviderCommandsConfig;
/** If false, do not start this Slack account. Default: true. */
enabled?: boolean;
botToken?: string;
@@ -1209,9 +1215,11 @@ export type MessagesConfig = {
removeAckAfterReply?: boolean;
};
export type NativeCommandsSetting = boolean | "auto";
export type CommandsConfig = {
/** Enable native command registration when supported (default: false). */
native?: boolean;
/** Enable native command registration when supported (default: "auto"). */
native?: NativeCommandsSetting;
/** Enable text command parsing (default: true). */
text?: boolean;
/** Allow /config command (default: false). */
@@ -1224,6 +1232,11 @@ export type CommandsConfig = {
useAccessGroups?: boolean;
};
export type ProviderCommandsConfig = {
/** Override native command registration for this provider (bool or "auto"). */
native?: NativeCommandsSetting;
};
export type BridgeBindMode = "auto" | "lan" | "tailnet" | "loopback";
export type BridgeConfig = {

View File

@@ -269,6 +269,7 @@ const TelegramAccountSchemaBase = z.object({
name: z.string().optional(),
capabilities: z.array(z.string()).optional(),
enabled: z.boolean().optional(),
commands: ProviderCommandsSchema,
dmPolicy: DmPolicySchema.optional().default("pairing"),
botToken: z.string().optional(),
tokenFile: z.string().optional(),
@@ -367,6 +368,7 @@ const DiscordAccountSchema = z.object({
name: z.string().optional(),
capabilities: z.array(z.string()).optional(),
enabled: z.boolean().optional(),
commands: ProviderCommandsSchema,
token: z.string().optional(),
allowBots: z.boolean().optional(),
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
@@ -440,6 +442,7 @@ const SlackAccountSchema = z.object({
name: z.string().optional(),
capabilities: z.array(z.string()).optional(),
enabled: z.boolean().optional(),
commands: ProviderCommandsSchema,
botToken: z.string().optional(),
appToken: z.string().optional(),
allowBots: z.boolean().optional(),
@@ -709,16 +712,28 @@ const MessagesSchema = z
})
.optional();
const NativeCommandsSettingSchema = z.union([
z.boolean(),
z.literal("auto"),
]);
const ProviderCommandsSchema = z
.object({
native: NativeCommandsSettingSchema.optional(),
})
.optional();
const CommandsSchema = z
.object({
native: z.boolean().optional(),
native: NativeCommandsSettingSchema.optional().default("auto"),
text: z.boolean().optional(),
config: z.boolean().optional(),
debug: z.boolean().optional(),
restart: z.boolean().optional(),
useAccessGroups: z.boolean().optional(),
})
.optional();
.optional()
.default({ native: "auto" });
const HeartbeatSchema = z
.object({