feat: expand skill command registration

This commit is contained in:
Peter Steinberger
2026-01-16 20:11:01 +00:00
parent 69761e8a51
commit 38b49aa0f6
21 changed files with 311 additions and 45 deletions

View File

@@ -0,0 +1,48 @@
import { describe, expect, it } from "vitest";
import { resolveNativeSkillsEnabled } from "./commands.js";
describe("resolveNativeSkillsEnabled", () => {
it("uses provider defaults for auto", () => {
expect(
resolveNativeSkillsEnabled({
providerId: "discord",
globalSetting: "auto",
}),
).toBe(true);
expect(
resolveNativeSkillsEnabled({
providerId: "telegram",
globalSetting: "auto",
}),
).toBe(true);
expect(
resolveNativeSkillsEnabled({
providerId: "slack",
globalSetting: "auto",
}),
).toBe(false);
expect(
resolveNativeSkillsEnabled({
providerId: "whatsapp",
globalSetting: "auto",
}),
).toBe(false);
});
it("honors explicit provider settings", () => {
expect(
resolveNativeSkillsEnabled({
providerId: "slack",
providerSetting: true,
globalSetting: "auto",
}),
).toBe(true);
expect(
resolveNativeSkillsEnabled({
providerId: "discord",
providerSetting: false,
globalSetting: true,
}),
).toBe(false);
});
});

View File

@@ -10,6 +10,18 @@ function resolveAutoDefault(providerId?: ChannelId): boolean {
return false;
}
export function resolveNativeSkillsEnabled(params: {
providerId: ChannelId;
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;
return resolveAutoDefault(providerId);
}
export function resolveNativeCommandsEnabled(params: {
providerId: ChannelId;
providerSetting?: NativeCommandsSetting;

View File

@@ -158,6 +158,7 @@ const FIELD_LABELS: Record<string, string> = {
"agents.defaults.humanDelay.maxMs": "Human Delay Max (ms)",
"agents.defaults.cliBackends": "CLI Backends",
"commands.native": "Native Commands",
"commands.nativeSkills": "Native Skill Commands",
"commands.text": "Text Commands",
"commands.bash": "Allow Bash Chat Command",
"commands.bashForegroundMs": "Bash Foreground Window (ms)",
@@ -323,6 +324,8 @@ const FIELD_HELP: Record<string, string> = {
"agents.defaults.humanDelay.maxMs": "Maximum delay in ms for custom humanDelay (default: 2500).",
"commands.native":
"Register native commands with channels that support it (Discord/Slack/Telegram).",
"commands.nativeSkills":
"Register native skill commands (user-invocable skills) with channels that support it.",
"commands.text": "Allow text command parsing (slash commands only).",
"commands.bash":
"Allow bash chat command (`!`; `/bash` alias) to run host shell commands (default: false; requires tools.elevated).",
@@ -349,8 +352,14 @@ const FIELD_HELP: Record<string, string> = {
"channels.msteams.configWrites":
"Allow Microsoft Teams to write config in response to channel events/commands (default: true).",
"channels.discord.commands.native": 'Override native commands for Discord (bool or "auto").',
"channels.discord.commands.nativeSkills":
'Override native skill commands for Discord (bool or "auto").',
"channels.telegram.commands.native": 'Override native commands for Telegram (bool or "auto").',
"channels.telegram.commands.nativeSkills":
'Override native skill commands for Telegram (bool or "auto").',
"channels.slack.commands.native": 'Override native commands for Slack (bool or "auto").',
"channels.slack.commands.nativeSkills":
'Override native skill commands for Slack (bool or "auto").',
"session.agentToAgent.maxPingPongTurns":
"Max reply-back turns between requester and target (05).",
"channels.telegram.customCommands":

View File

@@ -95,6 +95,8 @@ export type NativeCommandsSetting = boolean | "auto";
export type CommandsConfig = {
/** Enable native command registration when supported (default: "auto"). */
native?: NativeCommandsSetting;
/** Enable native skill command registration when supported (default: "auto"). */
nativeSkills?: NativeCommandsSetting;
/** Enable text command parsing (default: true). */
text?: boolean;
/** Allow bash chat command (`!`; `/bash` alias) (default: false). */
@@ -114,4 +116,6 @@ export type CommandsConfig = {
export type ProviderCommandsConfig = {
/** Override native command registration for this provider (bool or "auto"). */
native?: NativeCommandsSetting;
/** Override native skill command registration for this provider (bool or "auto"). */
nativeSkills?: NativeCommandsSetting;
};

View File

@@ -252,5 +252,6 @@ export const NativeCommandsSettingSchema = z.union([z.boolean(), z.literal("auto
export const ProviderCommandsSchema = z
.object({
native: NativeCommandsSettingSchema.optional(),
nativeSkills: NativeCommandsSettingSchema.optional(),
})
.optional();

View File

@@ -72,6 +72,7 @@ export const MessagesSchema = z
export const CommandsSchema = z
.object({
native: NativeCommandsSettingSchema.optional().default("auto"),
nativeSkills: NativeCommandsSettingSchema.optional().default("auto"),
text: z.boolean().optional(),
bash: z.boolean().optional(),
bashForegroundMs: z.number().int().min(0).max(30_000).optional(),
@@ -81,4 +82,4 @@ export const CommandsSchema = z
useAccessGroups: z.boolean().optional(),
})
.optional()
.default({ native: "auto" });
.default({ native: "auto", nativeSkills: "auto" });