Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

1.7 KB
Raw Blame
import { intlLocale, t } from "@/lib/i18n";
import type { LocaleKey } from "@/locales";

const ACTIONS: Record<string, LocaleKey> = {
  list_files: "lending.action.listFiles",
  read_file: "lending.action.readFile",
  write_file: "lending.action.writeFile",
  edit_file: "lending.action.writeFile",
  append_file: "lending.action.writeFile",
  delete_file: "lending.action.deleteFile",
  run_command: "lending.action.runCommand",
  computer_tools: "lending.action.screenTools",
  computer_call: "lending.action.screen",
  invalid: "lending.action.invalid",
  internet: "lending.action.website",
  chrome: "lending.action.chrome",
};

/** Security: Electron main keeps this record; a server cannot write to it. */
export function LendingActivityList({ entries }: { entries: DesktopLendingActivity[] | null }) {
  return <div className="flex flex-col gap-2">
    <p className="font-medium text-ink">{t("lending.activity.title")}</p>
    {entries && entries.length === 0 && <p className="text-[12px] text-ink-secondary">{t("lending.activity.empty")}</p>}
    {entries && entries.length > 0 && <ul aria-label={t("lending.activity.title")} className="flex max-h-56 flex-col gap-1 overflow-y-auto text-[12px]">
      {entries.map((entry, index) => <li key={`${entry.at}-${index}`} className="flex flex-wrap gap-x-2 text-ink-secondary">
        <time dateTime={new Date(entry.at).toISOString()} className="shrink-0 tabular-nums">{new Date(entry.at).toLocaleString(intlLocale())}</time>
        <span className={entry.ok ? "text-ink" : "text-danger"}>{t(ACTIONS[entry.action] ?? "lending.action.other")}{entry.ok ? "" : ` · ${t("lending.activity.refused")}`}</span>
        {entry.detail && <span dir="auto" className="min-w-0 break-all">{entry.detail}</span>}
      </li>)}
    </ul>}
  </div>;
}