feat: add 'sessions health' CLI command for diagnosing tool pairing issues

This commit is contained in:
Kastrah 2026-01-28 04:43:51 +01:00
parent 085c411a26
commit fae8c7141c

View File

@ -1,6 +1,6 @@
import type { Command } from "commander"; import type { Command } from "commander";
import { healthCommand } from "../../commands/health.js"; import { healthCommand } from "../../commands/health.js";
import { sessionsCommand } from "../../commands/sessions.js"; import { sessionsCommand, sessionsHealthCommand } from "../../commands/sessions.js";
import { statusCommand } from "../../commands/status.js"; import { statusCommand } from "../../commands/status.js";
import { setVerbose } from "../../globals.js"; import { setVerbose } from "../../globals.js";
import { defaultRuntime } from "../../runtime.js"; import { defaultRuntime } from "../../runtime.js";
@ -143,4 +143,36 @@ export function registerStatusHealthSessionsCommands(program: Command) {
defaultRuntime, defaultRuntime,
); );
}); });
program
.command("sessions health")
.description("Check session health for tool call/result pairing issues")
.option("--verbose", "Show diagnostics for all sessions", false)
.option("--session-id <id>", "Check a specific session by ID")
.option("--store <path>", "Path to session store (default: resolved from config)")
.addHelpText(
"after",
() =>
`\n${theme.heading("Examples:")}\n${formatHelpExamples([
["moltbot sessions health", "Check all sessions for tool pairing issues."],
["moltbot sessions health --verbose", "Show detailed diagnostics."],
["moltbot sessions health --session-id abc123", "Check specific session."],
])}`,
)
.addHelpText(
"after",
() =>
`\n${theme.muted("Docs:")} ${formatDocsLink("/cli/sessions-health", "docs.molt.bot/cli/sessions-health")}\n`,
)
.action(async (opts) => {
setVerbose(Boolean(opts.verbose));
await sessionsHealthCommand(
{
sessionId: opts.sessionId as string | undefined,
verbose: Boolean(opts.verbose),
store: opts.store as string | undefined,
},
defaultRuntime,
);
});
} }