Commands: add dynamic arg menus

This commit is contained in:
Shadow
2026-01-15 01:13:36 -06:00
committed by Peter Steinberger
parent 7e1e7ba2d8
commit 74bc5bfd7c
10 changed files with 1262 additions and 241 deletions

View File

@@ -2,12 +2,51 @@ import type { ClawdbotConfig } from "../config/types.js";
export type CommandScope = "text" | "native" | "both";
export type CommandArgType = "string" | "number" | "boolean";
export type CommandArgChoiceContext = {
cfg?: ClawdbotConfig;
provider?: string;
model?: string;
command: ChatCommandDefinition;
arg: CommandArgDefinition;
};
export type CommandArgChoicesProvider = (context: CommandArgChoiceContext) => string[];
export type CommandArgDefinition = {
name: string;
description: string;
type: CommandArgType;
required?: boolean;
choices?: string[] | CommandArgChoicesProvider;
captureRemaining?: boolean;
};
export type CommandArgMenuSpec = {
arg: string;
title?: string;
};
export type CommandArgValues = Record<string, unknown>;
export type CommandArgs = {
raw?: string;
values?: CommandArgValues;
};
export type CommandArgsParsing = "none" | "positional";
export type ChatCommandDefinition = {
key: string;
nativeName?: string;
description: string;
textAliases: string[];
acceptsArgs?: boolean;
args?: CommandArgDefinition[];
argsParsing?: CommandArgsParsing;
formatArgs?: (values: CommandArgValues) => string | undefined;
argsMenu?: CommandArgMenuSpec | "auto";
scope: CommandScope;
};
@@ -15,6 +54,7 @@ export type NativeCommandSpec = {
name: string;
description: string;
acceptsArgs: boolean;
args?: CommandArgDefinition[];
};
export type CommandNormalizeOptions = {