feat: expand skill command registration
This commit is contained in:
48
src/config/commands.test.ts
Normal file
48
src/config/commands.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
|
||||
@@ -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 (0–5).",
|
||||
"channels.telegram.customCommands":
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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" });
|
||||
|
||||
Reference in New Issue
Block a user