UNPKG

pyb-ts

Version:

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

96 lines (95 loc) 5.63 kB
import { Box, Text } from "ink"; import * as React from "react"; import { getTheme } from "@utils/theme"; import { PRODUCT_NAME } from "@constants/product"; import { LIST_ITEM } from "@constants/figures"; import { getAnthropicApiKey, getGlobalConfig } from "@utils/config"; import { getCwd } from "@utils/state"; import { getModelManager } from "@utils/model"; import { MACRO } from "@constants/macros"; const MIN_LOGO_WIDTH = 50; const DEFAULT_UPDATE_COMMANDS = [ "bun add -g @shareai-lab/pyb@latest", "npm install -g @shareai-lab/pyb@latest" ]; function Logo({ mcpClients, isDefaultModel = false, updateBannerVersion, updateBannerCommands }) { const width = Math.max(MIN_LOGO_WIDTH, getCwd().length + 12); const theme = getTheme(); const config = getGlobalConfig(); const modelManager = getModelManager(); const mainModelName = modelManager.getModelName("main"); const currentModel = mainModelName || "No model configured"; const apiKey = getAnthropicApiKey(); const hasOverrides = Boolean( process.env.ANTHROPIC_API_KEY || process.env.DISABLE_PROMPT_CACHING || process.env.API_TIMEOUT_MS || process.env.MAX_THINKING_TOKENS ); return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement( Box, { borderColor: theme.pyb, borderStyle: "round", flexDirection: "column", gap: 1, paddingLeft: 1, marginRight: 2, width }, updateBannerVersion ? /* @__PURE__ */ React.createElement(Box, { flexDirection: "column" }, /* @__PURE__ */ React.createElement(Text, { color: "yellow" }, "New version available: ", updateBannerVersion, " (current: ", MACRO.VERSION, ")"), /* @__PURE__ */ React.createElement(Text, null, "Run the following command to update:"), /* @__PURE__ */ React.createElement(Text, null, " ", updateBannerCommands?.[1] ?? DEFAULT_UPDATE_COMMANDS[1]), process.platform !== "win32" && /* @__PURE__ */ React.createElement(Text, { dimColor: true }, 'Note: you may need to prefix with "sudo" on macOS/Linux.')) : null, /* @__PURE__ */ React.createElement(Text, null, /* @__PURE__ */ React.createElement(Text, { color: theme.pyb }, "\u273B"), " Welcome to", " ", /* @__PURE__ */ React.createElement(Text, { bold: true }, PRODUCT_NAME), " ", /* @__PURE__ */ React.createElement(Text, null, "AI")), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, { paddingLeft: 2, flexDirection: "column", gap: 1 }, /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText, italic: true }, "/help for help"), /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, "cwd: ", getCwd())), hasOverrides && /* @__PURE__ */ React.createElement( Box, { borderColor: theme.secondaryBorder, borderStyle: "single", borderBottom: false, borderLeft: false, borderRight: false, borderTop: true, flexDirection: "column", marginLeft: 2, marginRight: 1, paddingTop: 1 }, /* @__PURE__ */ React.createElement(Box, { marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, "Overrides (via env):")), process.env.ANTHROPIC_API_KEY && apiKey ? /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, LIST_ITEM, "API Key:", " ", /* @__PURE__ */ React.createElement(Text, { bold: true }, "sk-ant-\u2026", apiKey.slice(-width + 25))) : null, process.env.DISABLE_PROMPT_CACHING ? /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, LIST_ITEM, "Prompt caching:", " ", /* @__PURE__ */ React.createElement(Text, { color: theme.error, bold: true }, "off")) : null, process.env.API_TIMEOUT_MS ? /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, LIST_ITEM, "API timeout:", " ", /* @__PURE__ */ React.createElement(Text, { bold: true }, process.env.API_TIMEOUT_MS, "ms")) : null, process.env.MAX_THINKING_TOKENS ? /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, LIST_ITEM, "Max thinking tokens:", " ", /* @__PURE__ */ React.createElement(Text, { bold: true }, process.env.MAX_THINKING_TOKENS)) : null, process.env.ANTHROPIC_BASE_URL ? /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, LIST_ITEM, "API Base URL:", " ", /* @__PURE__ */ React.createElement(Text, { bold: true }, process.env.ANTHROPIC_BASE_URL)) : null )), mcpClients.length ? /* @__PURE__ */ React.createElement( Box, { borderColor: theme.secondaryBorder, borderStyle: "single", borderBottom: false, borderLeft: false, borderRight: false, borderTop: true, flexDirection: "column", marginLeft: 2, marginRight: 1, paddingTop: 1 }, /* @__PURE__ */ React.createElement(Box, { marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, "MCP Servers:")), mcpClients.map((client, idx) => /* @__PURE__ */ React.createElement(Box, { key: idx, width: width - 6 }, /* @__PURE__ */ React.createElement(Text, { color: theme.secondaryText }, LIST_ITEM, client.name), /* @__PURE__ */ React.createElement(Box, { flexGrow: 1 }), /* @__PURE__ */ React.createElement( Text, { bold: true, color: client.type === "connected" ? theme.success : theme.error }, client.type === "connected" ? "connected" : "failed" ))) ) : null )); } export { Logo, MIN_LOGO_WIDTH }; //# sourceMappingURL=Logo.js.map