Merge 6b379bc423 into 4583f88626
This commit is contained in:
commit
7e51af2cea
@ -19,4 +19,13 @@ describe("tui slash commands", () => {
|
|||||||
expect(commands.some((command) => command.name === "context")).toBe(true);
|
expect(commands.some((command) => command.name === "context")).toBe(true);
|
||||||
expect(commands.some((command) => command.name === "commands")).toBe(true);
|
expect(commands.some((command) => command.name === "commands")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("offers reasoning stream mode", () => {
|
||||||
|
const commands = getSlashCommands({});
|
||||||
|
const reasoning = commands.find((command) => command.name === "reasoning");
|
||||||
|
expect(reasoning).toBeTruthy();
|
||||||
|
expect(reasoning?.getArgumentCompletions?.("")).toEqual(
|
||||||
|
expect.arrayContaining([{ value: "stream", label: "stream" }]),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { formatThinkingLevels, listThinkingLevelLabels } from "../auto-reply/thi
|
|||||||
import type { MoltbotConfig } from "../config/types.js";
|
import type { MoltbotConfig } from "../config/types.js";
|
||||||
|
|
||||||
const VERBOSE_LEVELS = ["on", "off"];
|
const VERBOSE_LEVELS = ["on", "off"];
|
||||||
const REASONING_LEVELS = ["on", "off"];
|
const REASONING_LEVELS = ["on", "off", "stream"];
|
||||||
const ELEVATED_LEVELS = ["on", "off", "ask", "full"];
|
const ELEVATED_LEVELS = ["on", "off", "ask", "full"];
|
||||||
const ACTIVATION_LEVELS = ["mention", "always"];
|
const ACTIVATION_LEVELS = ["mention", "always"];
|
||||||
const USAGE_FOOTER_LEVELS = ["off", "tokens", "full"];
|
const USAGE_FOOTER_LEVELS = ["off", "tokens", "full"];
|
||||||
@ -68,7 +68,7 @@ export function getSlashCommands(options: SlashCommandOptions = {}): SlashComman
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "reasoning",
|
name: "reasoning",
|
||||||
description: "Set reasoning on/off",
|
description: "Set reasoning visibility",
|
||||||
getArgumentCompletions: (prefix) =>
|
getArgumentCompletions: (prefix) =>
|
||||||
REASONING_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
REASONING_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
||||||
value,
|
value,
|
||||||
|
|||||||
@ -44,4 +44,43 @@ describe("tui command handlers", () => {
|
|||||||
);
|
);
|
||||||
expect(requestRender).toHaveBeenCalled();
|
expect(requestRender).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("normalizes /reasoning streaming to stream", async () => {
|
||||||
|
const patchSession = vi.fn().mockResolvedValue(undefined);
|
||||||
|
const addUser = vi.fn();
|
||||||
|
const addSystem = vi.fn();
|
||||||
|
const requestRender = vi.fn();
|
||||||
|
const refreshSessionInfo = vi.fn().mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
const { handleCommand } = createCommandHandlers({
|
||||||
|
client: { patchSession } as never,
|
||||||
|
chatLog: { addUser, addSystem } as never,
|
||||||
|
tui: { requestRender } as never,
|
||||||
|
opts: {},
|
||||||
|
state: {
|
||||||
|
currentSessionKey: "agent:main:main",
|
||||||
|
activeChatRunId: null,
|
||||||
|
sessionInfo: {},
|
||||||
|
} as never,
|
||||||
|
deliverDefault: false,
|
||||||
|
openOverlay: vi.fn(),
|
||||||
|
closeOverlay: vi.fn(),
|
||||||
|
refreshSessionInfo,
|
||||||
|
loadHistory: vi.fn(),
|
||||||
|
setSession: vi.fn(),
|
||||||
|
refreshAgents: vi.fn(),
|
||||||
|
abortActive: vi.fn(),
|
||||||
|
setActivityStatus: vi.fn(),
|
||||||
|
formatSessionKey: vi.fn(),
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleCommand("/reasoning streaming");
|
||||||
|
|
||||||
|
expect(patchSession).toHaveBeenCalledWith({
|
||||||
|
key: "agent:main:main",
|
||||||
|
reasoningLevel: "stream",
|
||||||
|
});
|
||||||
|
expect(addSystem).toHaveBeenCalledWith("reasoning set to stream");
|
||||||
|
expect(refreshSessionInfo).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import type { Component, TUI } from "@mariozechner/pi-tui";
|
import type { Component, TUI } from "@mariozechner/pi-tui";
|
||||||
import {
|
import {
|
||||||
formatThinkingLevels,
|
formatThinkingLevels,
|
||||||
|
normalizeReasoningLevel,
|
||||||
normalizeUsageDisplay,
|
normalizeUsageDisplay,
|
||||||
resolveResponseUsageMode,
|
resolveResponseUsageMode,
|
||||||
} from "../auto-reply/thinking.js";
|
} from "../auto-reply/thinking.js";
|
||||||
@ -333,15 +334,20 @@ export function createCommandHandlers(context: CommandHandlerContext) {
|
|||||||
break;
|
break;
|
||||||
case "reasoning":
|
case "reasoning":
|
||||||
if (!args) {
|
if (!args) {
|
||||||
chatLog.addSystem("usage: /reasoning <on|off>");
|
chatLog.addSystem("usage: /reasoning <on|off|stream>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
const normalized = normalizeReasoningLevel(args);
|
||||||
|
if (!normalized) {
|
||||||
|
chatLog.addSystem("usage: /reasoning <on|off|stream>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
await client.patchSession({
|
await client.patchSession({
|
||||||
key: state.currentSessionKey,
|
key: state.currentSessionKey,
|
||||||
reasoningLevel: args,
|
reasoningLevel: normalized,
|
||||||
});
|
});
|
||||||
chatLog.addSystem(`reasoning set to ${args}`);
|
chatLog.addSystem(`reasoning set to ${normalized}`);
|
||||||
await refreshSessionInfo();
|
await refreshSessionInfo();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
chatLog.addSystem(`reasoning failed: ${String(err)}`);
|
chatLog.addSystem(`reasoning failed: ${String(err)}`);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user