Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge upstream main (v0.1.154) into feat/fish-live3
Nathaniel2e123310c368
diff --cc src/components/LiveProviderSettings.tsxindex 393eaebcd6,8ad94baf8a..b20bcc1cc2--- a/src/components/LiveProviderSettings.tsx+++ b/src/components/LiveProviderSettings.tsx@@@ -4,13 -4,13 +4,14 @@@ import { t } from "@/lib/i18n"import { api, useStore } from "@/state/store";import type { LiveProvider, LiveSettings } from "../../shared/wire";import { Select } from "./Select";+ import { KEY_FIELD } from "./keys/KeyRow";-type ProviderPatch = Partial<Pick<LiveSettings, "provider" | "azureEndpoint" | "azureDeployment">>;+type ProviderPatch = Partial<Pick<LiveSettings, "provider" | "azureEndpoint" | "azureDeployment" | "fishAgentId">>;- const FIELD = "w-full rounded-lg border border-hairline bg-inset px-2.5 py-1.5 text-[13px] text-ink outline-none focus:border-accent/60";+ const FIELD = KEY_FIELD;-export function LiveProviderSettings() {+/** `locked` holds the provider, Azure endpoint and Fish agent while a key save is pending; `onSaving` reports a pending change to them. */+export function LiveProviderSettings({ locked = false, onSaving }: { locked?: boolean; onSaving?: (saving: boolean) => void } = {}) {const { state, dispatch } = useStore();const live: LiveSettings = state.config?.live ?? { configured: false, voice: "", readTypedReplies: true, idleMinutes: 5 };const provider: LiveProvider = live.provider ?? "openai";@@@ -90,39 -84,8 +91,39 @@@{azureChanged && (<buttontype="submit"- disabled={saving}+ disabled={saving || locked}- className="self-start rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50"++ className="ui-button ui-button-md self-end rounded-full"+ >+ {t("common.save")}+ </button>+ )}+ </form>+ )}+ {provider === "fish" && (+ <form+ className="flex flex-col gap-2"+ onSubmit={(event) => {+ event.preventDefault();+ void save({ fishAgentId: agentId.trim() });+ }}+ >- <label className="flex flex-col gap-1">- <span className="text-[12px] text-ink-secondary">{t("call.live.fishAgentId")}</span>++ <label className="flex flex-col gap-1.5">++ <span className="text-[13px] font-medium leading-[18px] text-ink">{t("call.live.fishAgentId")}</span>+ <input+ type="text"+ autoComplete="off"+ spellCheck={false}+ value={agentId}+ onChange={(event) => setAgentId(event.target.value)}+ className={FIELD}+ />+ </label>- <div className="text-[12px] text-ink-tertiary">{t("call.live.fishHint")}</div>++ <div className="text-[12px] leading-4 text-ink-secondary">{t("call.live.fishHint")}</div>+ {agentChanged && (+ <button+ type="submit"+ disabled={saving || locked}- className="self-start rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50"+ className="ui-button ui-button-md self-end rounded-full">{t("common.save")}</button>diff --cc src/components/keys/KeysPage.tsxindex a1c29eee38,e0f08bfd18..27f700ffa7--- a/src/components/keys/KeysPage.tsx+++ b/src/components/keys/KeysPage.tsx@@@ -149,10 -152,11 +152,11 @@@ export function KeysPage({ bare = falsereturn () => window.cancelAnimationFrame(frame);}, [focus]);- // With Azure chosen, Live calls do not use the OpenAI key that row points at.- const azureLive = state.config?.live?.provider === "azure";- const rows = KEY_CATALOG.filter((entry) => keyMatches(entry, q) && !(azureLive && entry.id === "liveCalls"));+ // With Azure or Fish Audio chosen, Live calls do not use the OpenAI key that row points at.+ const azureLive = state.config?.live?.provider === "azure" || state.config?.live?.provider === "fish";+ const rows = KEY_CATALOG.filter((entry) => keyMatches(entry, q, state.config) && !(azureLive && entry.id === "liveCalls"));- const sections = KEY_SECTIONS.flatMap((section) => {+ const asked = focus ? KEY_CATALOG.find((entry) => entry.id === focus.row)?.section : undefined;+ const sections = KEY_SECTIONS.filter((section) => !exclude.includes(section.id) || section.id === asked).flatMap((section) => {const own = rows.filter((entry) => entry.section === section.id);return own.length > 0 ? [{ id: section.id, rows: own }] : [];});diff --cc src/components/settings/SettingsWindow.tsxindex 0000000000,2a17dd2a55..4fdf73c775mode 000000,100644..100644--- a/src/components/settings/SettingsWindow.tsx+++ b/src/components/settings/SettingsWindow.tsx@@@ -1,0 -1,210 +1,210 @@@+ import { useEffect, useMemo, useRef, useState } from "react";+ import { ChevronLeft, X } from "lucide-react";+ import { cn } from "@/lib/cn";+ import { t } from "@/lib/i18n";+ import { glassPopupFrameStyle, glassPopupTopInset, GLASS_POPUP_GUTTER } from "@/lib/glass-popup";+ import { scrollWithin } from "@/lib/scroll-within";+ import { useMediaQuery } from "@/lib/use-media-query";+ import { setAdvancedMode } from "@/lib/interface-mode";+ import { api, useStore, type ConfigStatus } from "@/state/store";+ import { useIsTopLayer } from "../Layer";+ import { LicenseExpiryBanner } from "../LicenseExpiryBanner";+ import { shortcutLabel } from "../ShortcutHint";+ import { SettingsLook } from "../SettingsPrimitives";+ import { SettingsPageBody } from "./pages/SettingsPageBody";+ import { useSwitchToComputer } from "./inert";+ import { KEY_CATALOG, keyMatches, type KeyEntry } from "../keys/key-catalog";+ import { openKeySettings } from "../keys/key-focus";+ import { useSettingsContext, useSettingsPlace } from "./settings-context";+ import { needsAdvanced, pageById, resolveSettingsTarget, searchSettings, visiblePages, type SearchHit, type SettingsPageId } from "./settings-index";+ import { SettingsShellContext, type SettingsShell } from "./settings-shell";+ import { SettingsNav, hitLabel, pageLabel } from "./SettingsNav";+ import { SettingsPageHeader } from "./SettingsPageHeader";+ import { SettingsSkeletonCard, SettingsUnreachable } from "./SettingsStates";++ const NARROW = "(max-width: 767.98px)";+ const FOCUSABLE = 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])';+ const OPENED = "omb-settings-opened";++ function markOpened(): void {+ try { if (!localStorage.getItem(OPENED)) localStorage.setItem(OPENED, String(Date.now())); } catch { /* storage may be blocked */ }+ }++ /** Opening a found row: scroll the pane (only the pane) to it, focus its control and mark it for a moment. */+ export function revealAnchor(scroller: HTMLElement | null, anchor: string | null): void {+ if (!scroller || !anchor) return;+ const block = scroller.querySelector<HTMLElement>(`[data-settings-block="${CSS.escape(anchor)}"]`);+ if (!block) return;+ // A row (a block drawn as `contents` has no box of its own) lands a third of the way down the pane, focused and lit.+ const target = getComputedStyle(block).display === "contents" ? block.firstElementChild as HTMLElement | null ?? block : block;+ const header = scroller.querySelector<HTMLElement>("[data-settings-header]");+ const isRow = target !== block || block.matches("[data-setting-row], [data-setting-row] *");+ if (isRow) {+ const top = target.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;+ scroller.scrollTop = Math.max(0, top - scroller.clientHeight / 3);+ target.querySelector<HTMLElement>("input, select, textarea, button")?.focus({ preventScroll: true });+ } else scrollWithin(scroller, block, "start", (header?.offsetHeight ?? 96) + 8);+ target.setAttribute("data-settings-highlight", "");+ window.setTimeout(() => target.removeAttribute("data-settings-highlight"), 1200);+ }++ export function SettingsWindow() {+ const isTop = useIsTopLayer();+ const { state, dispatch } = useStore();+ const ctx = useSettingsContext();+ const place = useSettingsPlace();+ const narrow = useMediaQuery(NARROW, false);+ const target = resolveSettingsTarget(state.appSettingsSection, ctx);+ const [anchor, setAnchor] = useState<string | null>(target.anchor ?? null);+ const [narrowPage, setNarrowPage] = useState(state.appSettingsSection !== "overview");+ const [query, setQuery] = useState("");+ const [scrolled, setScrolled] = useState(false);+ const pages = visiblePages(ctx);+ const page = pageById(target.page);+ const dialogRef = useRef<HTMLDivElement>(null);+ const scrollRef = useRef<HTMLDivElement>(null);++ useEffect(() => { setAnchor(target.anchor ?? null); setNarrowPage((open) => open || state.appSettingsSection !== "overview"); }, [state.appSettingsSection, target.anchor]);+ useEffect(() => {+ const frame = window.requestAnimationFrame(() => {+ if (anchor) revealAnchor(scrollRef.current, anchor);+ else if (scrollRef.current) scrollRef.current.scrollTop = 0;+ });+ return () => window.cancelAnimationFrame(frame);+ }, [anchor, target.page]);+ // A link, a notice or a search result that asks for what only Advanced mode shows turns Advanced on and lands there.+ useEffect(() => { if (target.advanced) setAdvancedMode(true); }, [target.advanced]);+ useEffect(() => window.ogb?.onOpenAppSettings?.(() => setQuery("")), []);+ useEffect(markOpened, []);++ const hits = useMemo(() => searchSettings(query, ctx, (entry) => hitLabel({ entry, elsewhere: false, score: 0 }, place, ctx.desktop),+ (candidate) => pageLabel(candidate, place, ctx.desktop)), [query, ctx, place]);+- const keyHits = useMemo(() => (ctx.client || !query.trim() ? [] : KEY_CATALOG.filter((entry) => keyMatches(entry, query.trim().toLowerCase())).slice(0, 8)), [ctx.client, query]);++ const keyHits = useMemo(() => (ctx.client || !query.trim() ? [] : KEY_CATALOG.filter((entry) => keyMatches(entry, query.trim().toLowerCase(), state.config)).slice(0, 8)), [ctx.client, query, state.config]);+ const openKey = (entry: KeyEntry) => { setQuery(""); setNarrowPage(true); dispatch(entry.uses ? openKeySettings(entry.uses, entry.id) : openKeySettings(entry.id)); };+ const computer = useSwitchToComputer();+ const close = () => dispatch({ type: "toggleAppSettings", open: false });+ const go = (next: SettingsPageId, nextAnchor?: string) => {+ setNarrowPage(true);+ if (next === target.page) setAnchor(nextAnchor ?? null);+ dispatch({ type: "toggleAppSettings", open: true, section: next });+ if (nextAnchor) window.setTimeout(() => setAnchor(nextAnchor), 0);+ };+ const openHit = (hit: SearchHit) => {+ const entry = hit.entry;+ if (entry.jump === "apps") { close(); dispatch({ type: "togglePlugins", open: true }); return; }+ if (entry.jump === "automations") { close(); dispatch({ type: "showRoutines", view: "list" }); return; }+ if (entry.jump === "shortcuts") { close(); dispatch({ type: "toggleShortcuts", open: true }); return; }+ if (entry.jump === "bot") { close(); return; }+ if (hit.elsewhere) { computer.open?.(); return; }+ if (hit.advanced || needsAdvanced({ page: entry.page, anchor: entry.anchor }, ctx)) setAdvancedMode(true);+ go(entry.page, entry.anchor);+ };+ /** Turning Advanced off on a page Simple doesn't show lands on the place's Overview; anywhere else it stays put. */+ const setAdvanced = (on: boolean) => {+ if (!on && !pageById(target.page).when({ ...ctx, advanced: false })) dispatch({ type: "toggleAppSettings", open: true, section: "overview" });+ setAdvancedMode(on);+ };++ useEffect(() => {+ const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;+ const dialog = dialogRef.current;+ const search = dialog?.querySelector<HTMLInputElement>("[data-settings-search]");+ if (search?.checkVisibility()) search.focus({ preventScroll: true });+ else dialog?.focus();+ const onKey = (event: KeyboardEvent) => {+ if (!isTop() || !dialog) return;+ if (event.defaultPrevented || [...dialog.querySelectorAll<HTMLElement>('[role="dialog"], [role="alertdialog"]')].some((child) => child.getClientRects().length)) return;+ const field = dialog.querySelector<HTMLInputElement>("[data-settings-search]");+ const typing = document.activeElement instanceof HTMLInputElement || document.activeElement instanceof HTMLTextAreaElement+ || (document.activeElement as HTMLElement | null)?.isContentEditable;+ if (field && ((event.key === "/" && !typing) || (event.key.toLowerCase() === "f" && (event.metaKey || event.ctrlKey)))) {+ event.preventDefault();+ field.focus();+ field.select();+ return;+ }+ if (event.key === "Escape") { event.preventDefault(); close(); return; }+ if (event.key !== "Tab") return;+ const focusable = [...dialog.querySelectorAll<HTMLElement>(FOCUSABLE)].filter((element) => element.checkVisibility());+ if (focusable.length === 0) { event.preventDefault(); dialog.focus(); return; }+ const first = focusable[0]!, last = focusable[focusable.length - 1]!;+ if (event.shiftKey && (document.activeElement === first || !dialog.contains(document.activeElement))) { event.preventDefault(); last.focus(); }+ else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }+ };+ window.addEventListener("keydown", onKey);+ return () => { window.removeEventListener("keydown", onKey); previousFocus?.focus(); };+ }, [dispatch, isTop]);++ const shell: SettingsShell = { ctx, place, page: target.page, anchor, go };+ const missing = target.missing ? pageLabel(pageById(target.missing), place, ctx.desktop) : undefined;+ const showList = narrow && !narrowPage;+ // Narrow header: the back label and the centred page title share 48 px of height; when the pair can't fit (half the+ // width each side of the centre), the back button keeps only its chevron.+ const compactBack = narrow && typeof window !== "undefined"+ && window.innerWidth / 2 - 16 - (30 + t("settings.title").length * 7) < (pageLabel(page, place, ctx.desktop).length * 9) / 2;+ const closeButton = (+ <button type="button" onClick={close} aria-label={t("settings.close")} title={`${t("settings.close")} (${shortcutLabel("close-panel")})`}+ className={cn("ui-icon-button z-20 size-8 shrink-0 cursor-pointer rounded-full text-ink-secondary hover:bg-menu-hover hover:text-ink", !narrow && "absolute right-3 top-3")}>+ <X size={16} aria-hidden="true" />+ </button>+ );++ return (+ <SettingsLook.Provider value={true}>+ <SettingsShellContext.Provider value={shell}>+ <div className="glass-popup-frame" data-settings-sheet data-settings-look="simple" style={{ ...glassPopupFrameStyle(), ["--settings-narrow-top" as string]: `${glassPopupTopInset() === GLASS_POPUP_GUTTER ? 12 : glassPopupTopInset()}px` }} onMouseDown={(event) => event.target === event.currentTarget && close()}>+ <div aria-hidden="true" className="glass-scrim pointer-events-none absolute inset-0" />+ <div ref={dialogRef} role="dialog" aria-modal="true" aria-labelledby="app-settings-title" tabIndex={-1} style={{ outline: "none" }}+ data-settings-page-open={target.page} data-settings-advanced={ctx.advanced ? "" : undefined}+ className="glass-surface glass-popup animate-pop-in relative flex flex-col overflow-hidden text-ink">+ <span id="app-settings-title" className="sr-only">{t("settings.title")}</span>+ {narrow && (+ <div className="flex shrink-0 flex-col">+ <span aria-hidden="true" className="mx-auto mt-2 h-1 w-8 rounded-full bg-ink/15" />+ <div className="relative flex h-12 items-center justify-between gap-2 px-2">+ {showList ? <h2 className="flex-1 px-2 text-[16px] font-semibold leading-[22px] text-ink">{t("settings.title")}</h2> : (+ <>+ {/* "‹ Settings" when it fits beside the centred title; a longer pair (German, a long page name) keeps the+ chevron alone, so the title stays centred and clear of the close button. */}+ <button type="button" data-settings-back="" aria-label={compactBack ? t("settings.backTo") : undefined} onClick={() => { setNarrowPage(false); setQuery(""); }}+ className={cn("flex h-8 shrink-0 cursor-pointer items-center gap-0.5 rounded-full text-[13px] font-medium leading-5 text-ink-secondary hover:bg-menu-hover hover:text-ink", compactBack ? "w-8 justify-center" : "pl-1 pr-2")}>+ <ChevronLeft size={16} aria-hidden="true" className="rtl:-scale-x-100" />{!compactBack && t("settings.title")}+ </button>+ <h2 className={cn("pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 truncate text-center text-[16px] font-semibold leading-[22px] text-ink", compactBack ? "max-w-[calc(100%-96px)]" : "max-w-[calc(100%-224px)]")}>{pageLabel(page, place, ctx.desktop)}</h2>+ </>+ )}+ {closeButton}+ </div>+ </div>+ )}+ <div className="flex min-h-0 flex-1">+ {(!narrow || showList) && (+ <SettingsNav ctx={ctx} place={place} pages={pages} current={narrow ? null : target.page} query={query} hits={hits} narrow={narrow}+ onQuery={setQuery} onOpen={(next) => go(next)} onHit={openHit} keyHits={keyHits} onKey={openKey} onClose={close} onAdvanced={setAdvanced} />+ )}+ {(!narrow || !showList) && (+ <div className="relative flex min-h-0 min-w-0 flex-1 flex-col">+ {!narrow && closeButton}+ <div ref={scrollRef} data-settings-scroll data-settings-content="" onScroll={(event) => setScrolled(event.currentTarget.scrollTop > 0)}+ className={cn("settings-scroll min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]", narrow ? "pb-12" : "px-8 pb-12")}>+ <div className={cn("flex max-w-[640px] flex-col", narrow && "max-w-none")}>+ <SettingsPageHeader page={page} ctx={ctx} place={place} scrolled={scrolled} narrow={narrow} missing={missing} />+ <div key={target.page} data-settings-page-body={target.page} className={cn("flex flex-col gap-6", narrow && "px-4")}>+ <LicenseExpiryBanner config={state.config} />+ {page.owner === "place" && state.config === null+ ? state.error ? <SettingsUnreachable place={place.name} onRetry={() => void api<ConfigStatus>("/api/config").then((config) => dispatch({ type: "configStatus", config })).catch(() => {})} />+ : <><SettingsSkeletonCard place={place.name} /><SettingsSkeletonCard place={place.name} /></>+ : <SettingsPageBody page={target.page} />}+ </div>+ </div>+ </div>+ </div>+ )}+ </div>+ </div>+ </div>+ </SettingsShellContext.Provider>+ </SettingsLook.Provider>+ );+ }