feat(slash-commands): usage footer modes
This commit is contained in:
@@ -5,7 +5,7 @@ const VERBOSE_LEVELS = ["on", "off"];
|
||||
const REASONING_LEVELS = ["on", "off"];
|
||||
const ELEVATED_LEVELS = ["on", "off"];
|
||||
const ACTIVATION_LEVELS = ["mention", "always"];
|
||||
const TOGGLE = ["on", "off"];
|
||||
const USAGE_FOOTER_LEVELS = ["off", "tokens", "full"];
|
||||
|
||||
export type ParsedCommand = {
|
||||
name: string;
|
||||
@@ -73,10 +73,10 @@ export function getSlashCommands(options: SlashCommandOptions = {}): SlashComman
|
||||
})),
|
||||
},
|
||||
{
|
||||
name: "cost",
|
||||
name: "usage",
|
||||
description: "Toggle per-response usage line",
|
||||
getArgumentCompletions: (prefix) =>
|
||||
TOGGLE.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
||||
USAGE_FOOTER_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
||||
value,
|
||||
label: value,
|
||||
})),
|
||||
@@ -129,7 +129,7 @@ export function helpText(options: SlashCommandOptions = {}): string {
|
||||
`/think <${thinkLevels}>`,
|
||||
"/verbose <on|off>",
|
||||
"/reasoning <on|off>",
|
||||
"/cost <on|off>",
|
||||
"/usage <off|tokens|full>",
|
||||
"/elevated <on|off>",
|
||||
"/elev <on|off>",
|
||||
"/activation <mention|always>",
|
||||
|
||||
@@ -52,7 +52,7 @@ export type GatewaySessionList = {
|
||||
inputTokens?: number | null;
|
||||
outputTokens?: number | null;
|
||||
totalTokens?: number | null;
|
||||
responseUsage?: "on" | "off";
|
||||
responseUsage?: "on" | "off" | "tokens" | "full";
|
||||
modelProvider?: string;
|
||||
label?: string;
|
||||
displayName?: string;
|
||||
|
||||
@@ -317,23 +317,30 @@ export function createCommandHandlers(context: CommandHandlerContext) {
|
||||
chatLog.addSystem(`reasoning failed: ${String(err)}`);
|
||||
}
|
||||
break;
|
||||
case "cost": {
|
||||
case "usage": {
|
||||
const normalized = args ? normalizeUsageDisplay(args) : undefined;
|
||||
if (args && !normalized) {
|
||||
chatLog.addSystem("usage: /cost <on|off>");
|
||||
chatLog.addSystem("usage: /usage <off|tokens|full>");
|
||||
break;
|
||||
}
|
||||
const current = state.sessionInfo.responseUsage === "on" ? "on" : "off";
|
||||
const next = normalized ?? (current === "on" ? "off" : "on");
|
||||
const currentRaw = state.sessionInfo.responseUsage;
|
||||
const current =
|
||||
currentRaw === "full"
|
||||
? "full"
|
||||
: currentRaw === "tokens" || currentRaw === "on"
|
||||
? "tokens"
|
||||
: "off";
|
||||
const next =
|
||||
normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
|
||||
try {
|
||||
await client.patchSession({
|
||||
key: state.currentSessionKey,
|
||||
responseUsage: next === "off" ? null : next,
|
||||
});
|
||||
chatLog.addSystem(next === "on" ? "usage line enabled" : "usage line disabled");
|
||||
chatLog.addSystem(`usage footer: ${next}`);
|
||||
await refreshSessionInfo();
|
||||
} catch (err) {
|
||||
chatLog.addSystem(`cost failed: ${String(err)}`);
|
||||
chatLog.addSystem(`usage failed: ${String(err)}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export type SessionInfo = {
|
||||
inputTokens?: number | null;
|
||||
outputTokens?: number | null;
|
||||
totalTokens?: number | null;
|
||||
responseUsage?: "on" | "off";
|
||||
responseUsage?: "on" | "off" | "tokens" | "full";
|
||||
updatedAt?: number | null;
|
||||
displayName?: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user