A personal agent with a browser, terminal, files, and work that keeps going built with CopilotKit and AG-UI.
TypeScript
export function browserAddress(value: string): string {
const input = value.trim();
try {
const url = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(input) ? input : `https://${input}`);
if (
!["https:", "http:"].includes(url.protocol) ||
url.username ||
url.password ||
/\s/.test(input)
)
throw new Error("Invalid address");
return url.href;
} catch {
throw new Error("Enter a website address, like copilotkit.ai or https://news.ycombinator.com.");
}
}
export function browserSite(value: string): string {
try {
return new URL(value).hostname.replace(/^www\./, "") || "Browser";
} catch {
return "Browser";
}
}