UNPKG

pyb-ts

Version:

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

89 lines (88 loc) 6.66 kB
import React from "react"; import { Text, Box } from "ink"; import { getModelManager } from "@utils/model"; import { getGlobalConfig } from "@utils/config"; import { useExitOnCtrlCD } from "@hooks/useExitOnCtrlCD"; import { getTheme } from "@utils/theme"; import { LIST_ITEM } from "@constants/figures"; function ModelStatusDisplay({ onClose }) { const theme = getTheme(); const exitState = useExitOnCtrlCD(onClose); try { const modelManager = getModelManager(); const config = getGlobalConfig(); const pointers = ["main", "task", "reasoning", "quick"]; return /* @__PURE__ */ React.createElement( Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.secondaryBorder, paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React.createElement(Text, { bold: true }, "\u{1F4CA} Current Model Status", " ", exitState.pending ? `(press ${exitState.keyName} again to exit)` : ""), /* @__PURE__ */ React.createElement(Text, null, " "), pointers.map((pointer) => { try { const model = modelManager.getModel(pointer); if (model && model.name && model.provider) { return /* @__PURE__ */ React.createElement(Box, { key: pointer, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, null, "\u{1F3AF}", " ", /* @__PURE__ */ React.createElement(Text, { bold: true, color: theme.pyb }, pointer.toUpperCase()), " ", LIST_ITEM, model.name), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "Provider: ", model.provider), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "Model: ", model.modelName || "unknown"), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "Context:", " ", model.contextLength ? Math.round(model.contextLength / 1e3) : "unknown", "k tokens"), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "Active: ", model.isActive ? "[ON]" : "[OFF]")); } else { return /* @__PURE__ */ React.createElement(Box, { key: pointer, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, null, "\u{1F3AF}", " ", /* @__PURE__ */ React.createElement(Text, { bold: true, color: theme.pyb }, pointer.toUpperCase()), " ", LIST_ITEM, /* @__PURE__ */ React.createElement(Text, { color: theme.error }, LIST_ITEM, "Not configured"))); } } catch (pointerError) { return /* @__PURE__ */ React.createElement(Box, { key: pointer, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, null, "\u{1F3AF}", " ", /* @__PURE__ */ React.createElement(Text, { bold: true, color: theme.pyb }, pointer.toUpperCase()), " ", "\u2192", " ", /* @__PURE__ */ React.createElement(Text, { color: theme.error }, LIST_ITEM, "Error: ", String(pointerError)))); } }), /* @__PURE__ */ React.createElement(Text, null, " "), /* @__PURE__ */ React.createElement(Text, { bold: true }, "\u{1F4DA} Available Models:"), (() => { try { const availableModels = modelManager.getAvailableModels() || []; if (availableModels.length === 0) { return /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " No models configured"); } return availableModels.map((model, index) => { try { const isInUse = pointers.some((p) => { try { return modelManager.getModel(p)?.modelName === model.modelName; } catch { return false; } }); return /* @__PURE__ */ React.createElement(Box, { key: index, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, null, " ", isInUse ? "[RUN]" : "[IDLE]", " ", model.name || "Unnamed", " ", /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, "(", model.provider || "unknown", ")")), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "Model: ", model.modelName || "unknown"), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "Context:", " ", model.contextLength ? Math.round(model.contextLength / 1e3) : "unknown", "k tokens"), model.lastUsed && /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "Last used: ", new Date(model.lastUsed).toLocaleString())); } catch (modelError) { return /* @__PURE__ */ React.createElement(Box, { key: index, flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { color: theme.error }, " ", LIST_ITEM, "Model error: ", String(modelError))); } }); } catch (availableModelsError) { return /* @__PURE__ */ React.createElement(Text, { color: theme.error }, LIST_ITEM, "Error loading available models:", " ", String(availableModelsError)); } })(), /* @__PURE__ */ React.createElement(Text, null, " "), /* @__PURE__ */ React.createElement(Text, { bold: true }, "\u{1F527} Debug Info:"), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "ModelProfiles: ", config.modelProfiles?.length || 0, " configured"), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "DefaultModelId: ", config.defaultModelId || "not set"), config.modelPointers && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", "ModelPointers configured:", " ", Object.keys(config.modelPointers).length > 0 ? "Yes" : "No"), Object.entries(config.modelPointers).map(([pointer, modelId]) => /* @__PURE__ */ React.createElement(React.Fragment, { key: pointer }, /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, " ", pointer, ": ", modelId || "not set")))) ); } catch (error) { return /* @__PURE__ */ React.createElement( Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.error, paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React.createElement(Text, { bold: true }, "\u{1F4CA} Model Status Error", " ", exitState.pending ? `(press ${exitState.keyName} again to exit)` : ""), /* @__PURE__ */ React.createElement(Text, { color: theme.error }, LIST_ITEM, "Error reading model status: ", String(error)) ); } } export { ModelStatusDisplay }; //# sourceMappingURL=ModelStatusDisplay.js.map