Files
openclaw/ui/src/ui/controllers/debug.ts
Dan Guido 48aea87028 feat: add prek pre-commit hooks and dependabot (#1720)
* feat: add prek pre-commit hooks and dependabot

Pre-commit hooks (via prek):
- Basic hygiene: trailing-whitespace, end-of-file-fixer, check-yaml, check-added-large-files, check-merge-conflict
- Security: detect-secrets, zizmor (GitHub Actions audit)
- Linting: shellcheck, actionlint, oxlint, swiftlint
- Formatting: oxfmt, swiftformat

Dependabot:
- npm and GitHub Actions ecosystems
- Grouped updates (production/development/actions)
- 7-day cooldown for supply chain protection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: add prek install instruction to AGENTS.md

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:53:23 +00:00

57 lines
1.8 KiB
TypeScript

import type { GatewayBrowserClient } from "../gateway";
import type { HealthSnapshot, StatusSummary } from "../types";
export type DebugState = {
client: GatewayBrowserClient | null;
connected: boolean;
debugLoading: boolean;
debugStatus: StatusSummary | null;
debugHealth: HealthSnapshot | null;
debugModels: unknown[];
debugHeartbeat: unknown | null;
debugCallMethod: string;
debugCallParams: string;
debugCallResult: string | null;
debugCallError: string | null;
};
export async function loadDebug(state: DebugState) {
if (!state.client || !state.connected) return;
if (state.debugLoading) return;
state.debugLoading = true;
try {
const [status, health, models, heartbeat] = await Promise.all([
state.client.request("status", {}),
state.client.request("health", {}),
state.client.request("models.list", {}),
state.client.request("last-heartbeat", {}),
]);
state.debugStatus = status as StatusSummary;
state.debugHealth = health as HealthSnapshot;
const modelPayload = models as { models?: unknown[] } | undefined;
state.debugModels = Array.isArray(modelPayload?.models)
? modelPayload?.models
: [];
state.debugHeartbeat = heartbeat as unknown;
} catch (err) {
state.debugCallError = String(err);
} finally {
state.debugLoading = false;
}
}
export async function callDebugMethod(state: DebugState) {
if (!state.client || !state.connected) return;
state.debugCallError = null;
state.debugCallResult = null;
try {
const params = state.debugCallParams.trim()
? (JSON.parse(state.debugCallParams) as unknown)
: {};
const res = await state.client.request(state.debugCallMethod.trim(), params);
state.debugCallResult = JSON.stringify(res, null, 2);
} catch (err) {
state.debugCallError = String(err);
}
}