Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
1.7 kB · 68 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import type { ThinkingLevel } from "@earendil-works/pi-agent-core";import { Container, type SelectItem, SelectList, type SelectListLayoutOptions } from "@earendil-works/pi-tui";import { getSelectListTheme } from "../theme/theme.js";import { DynamicBorder } from "./dynamic-border.js";
const THINKING_SELECT_LIST_LAYOUT: SelectListLayoutOptions = { minPrimaryColumnWidth: 12, maxPrimaryColumnWidth: 32,};
const LEVEL_DESCRIPTIONS: Record<ThinkingLevel, string> = { off: "No reasoning", minimal: "Very brief reasoning", low: "Light reasoning", medium: "Moderate reasoning", high: "Deep reasoning", xhigh: "Very deep reasoning", max: "Maximum reasoning",};
export class ThinkingSelectorComponent extends Container { private selectList: SelectList;
constructor( currentLevel: ThinkingLevel, availableLevels: ThinkingLevel[], onSelect: (level: ThinkingLevel) => void, onCancel: () => void, ) { super();
const thinkingLevels: SelectItem[] = availableLevels.map((level) => ({ value: level, label: level, description: LEVEL_DESCRIPTIONS[level], }));
this.addChild(new DynamicBorder());
this.selectList = new SelectList( thinkingLevels, thinkingLevels.length, getSelectListTheme(), THINKING_SELECT_LIST_LAYOUT, );
const currentIndex = thinkingLevels.findIndex((item) => item.value === currentLevel); if (currentIndex !== -1) { this.selectList.setSelectedIndex(currentIndex); }
this.selectList.onSelect = (item) => { onSelect(item.value as ThinkingLevel); };
this.selectList.onCancel = () => { onCancel(); };
this.addChild(this.selectList);
this.addChild(new DynamicBorder()); }
getSelectList(): SelectList { return this.selectList; }}