UNPKG

pyb-ts

Version:

PYB-CLI - Minimal AI Agent with multi-model support and CLI interface

56 lines (55 loc) 1.54 kB
import React, { useEffect, useState } from "react"; import { CACHE_PATHS } from "@utils/log"; import { LogSelector } from "@components/LogSelector"; import { loadLogList } from "@utils/log"; import { logError } from "@utils/log"; function LogList({ context, type, logNumber }) { const [logs, setLogs] = useState([]); const [didSelectLog, setDidSelectLog] = useState(false); useEffect(() => { loadLogList( type === "messages" ? CACHE_PATHS.messages() : CACHE_PATHS.errors() ).then((logs2) => { if (logNumber !== void 0) { const log = logs2[logNumber >= 0 ? logNumber : 0]; if (log) { console.log(JSON.stringify(log.messages, null, 2)); process.exit(0); } else { console.error("No log found at index", logNumber); process.exit(1); } } setLogs(logs2); }).catch((error) => { logError(error); if (logNumber !== void 0) { process.exit(1); } else { context.unmount?.(); } }); }, [context, type, logNumber]); function onSelect(index) { const log = logs[index]; if (!log) { return; } setDidSelectLog(true); setTimeout(() => { console.log(JSON.stringify(log.messages, null, 2)); process.exit(0); }, 100); } if (logNumber !== void 0) { return null; } if (didSelectLog) { return null; } return /* @__PURE__ */ React.createElement(LogSelector, { logs, onSelect }); } export { LogList }; //# sourceMappingURL=LogList.js.map