feat(types): CommandDef, CommandManifest, slash command socket events (#174)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #174.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
import type {
|
||||
CommandManifestPayload,
|
||||
SlashCommandPayload,
|
||||
SlashCommandResultPayload,
|
||||
SystemReloadPayload,
|
||||
} from '../commands/index.js';
|
||||
|
||||
export interface MessageAckPayload {
|
||||
conversationId: string;
|
||||
messageId: string;
|
||||
@@ -92,6 +99,9 @@ export interface ServerToClientEvents {
|
||||
'agent:tool:start': (payload: ToolStartPayload) => void;
|
||||
'agent:tool:end': (payload: ToolEndPayload) => void;
|
||||
'session:info': (payload: SessionInfoPayload) => void;
|
||||
'commands:manifest': (payload: CommandManifestPayload) => void;
|
||||
'command:result': (payload: SlashCommandResultPayload) => void;
|
||||
'system:reload': (payload: SystemReloadPayload) => void;
|
||||
error: (payload: ErrorPayload) => void;
|
||||
}
|
||||
|
||||
@@ -99,4 +109,5 @@ export interface ServerToClientEvents {
|
||||
export interface ClientToServerEvents {
|
||||
message: (data: ChatMessagePayload) => void;
|
||||
'set:thinking': (data: SetThinkingPayload) => void;
|
||||
'command:execute': (data: SlashCommandPayload) => void;
|
||||
}
|
||||
|
||||
85
packages/types/src/commands/index.ts
Normal file
85
packages/types/src/commands/index.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/** Argument definition for a slash command */
|
||||
export interface CommandArgDef {
|
||||
name: string;
|
||||
type: 'string' | 'enum';
|
||||
optional: boolean;
|
||||
/** For enum type, the allowed values */
|
||||
values?: string[];
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/** A single command definition served by the gateway */
|
||||
export interface CommandDef {
|
||||
/** Command name without slash prefix, e.g. "model" */
|
||||
name: string;
|
||||
/** Short aliases, e.g. ["m"] */
|
||||
aliases: string[];
|
||||
/** Human-readable description */
|
||||
description: string;
|
||||
/** Argument schema */
|
||||
args?: CommandArgDef[];
|
||||
/** Nested subcommands (e.g. provider → login, logout) */
|
||||
subcommands?: CommandDef[];
|
||||
/** Origin of this command */
|
||||
scope: 'core' | 'agent' | 'skill' | 'plugin' | 'admin';
|
||||
/** Where the command executes */
|
||||
execution: 'local' | 'socket' | 'rest' | 'hybrid';
|
||||
/** Whether this command is currently available */
|
||||
available: boolean;
|
||||
}
|
||||
|
||||
/** Full command manifest pushed from gateway to TUI */
|
||||
export interface CommandManifest {
|
||||
commands: CommandDef[];
|
||||
skills: SkillCommandDef[];
|
||||
/** Manifest version — TUI compares to detect changes */
|
||||
version: number;
|
||||
}
|
||||
|
||||
/** Skill registered as /skill:name */
|
||||
export interface SkillCommandDef {
|
||||
/** Skill name (used as /skill:{name}) */
|
||||
name: string;
|
||||
description: string;
|
||||
/** Whether the skill is currently loaded and available */
|
||||
available: boolean;
|
||||
}
|
||||
|
||||
/** Payload for commands:manifest event */
|
||||
export interface CommandManifestPayload {
|
||||
manifest: CommandManifest;
|
||||
}
|
||||
|
||||
/** Payload for system:reload broadcast */
|
||||
export interface SystemReloadPayload {
|
||||
commands: CommandDef[];
|
||||
skills: SkillCommandDef[];
|
||||
providers: string[];
|
||||
message: string;
|
||||
}
|
||||
|
||||
/** Client request to execute a slash command via socket */
|
||||
export interface SlashCommandPayload {
|
||||
conversationId: string;
|
||||
command: string;
|
||||
args?: string;
|
||||
}
|
||||
|
||||
/** Server response to a slash command */
|
||||
export interface SlashCommandResultPayload {
|
||||
conversationId: string;
|
||||
command: string;
|
||||
success: boolean;
|
||||
message?: string;
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/** Parsed slash command (TUI-side, not a socket type) */
|
||||
export interface ParsedCommand {
|
||||
/** Command name without slash, e.g. "model", "skill:brave-search" */
|
||||
command: string;
|
||||
/** Arguments string or null */
|
||||
args: string | null;
|
||||
/** Full raw input string */
|
||||
raw: string;
|
||||
}
|
||||
@@ -4,3 +4,4 @@ export * from './chat/index.js';
|
||||
export * from './agent/index.js';
|
||||
export * from './provider/index.js';
|
||||
export * from './routing/index.js';
|
||||
export * from './commands/index.js';
|
||||
|
||||
Reference in New Issue
Block a user