Files
openmotion/shared/browser.ts
open-design-crew[bot] 74a3d1e79d
Some checks failed
Motion standalone checks / Template library policy (push) Has been cancelled
Motion standalone checks / Maintainability report (push) Has been cancelled
Motion standalone checks / Source checks (push) Has been cancelled
Motion standalone checks / Workspace reliability (macos-15) (push) Has been cancelled
Motion standalone checks / Workspace reliability (windows-2025) (push) Has been cancelled
Motion standalone checks / Studio regression (1/2) (push) Has been cancelled
Motion standalone checks / Studio regression (2/2) (push) Has been cancelled
Motion standalone checks / Distribution browser regression (push) Has been cancelled
Motion standalone checks / Distribution regression (push) Has been cancelled
Motion standalone checks / standalone (push) Has been cancelled
DSH integration / Optional DSH plugin (push) Has been cancelled
Motion release controls / controls (push) Has been cancelled
Update README star history / refresh (push) Has been cancelled
Revert "feat(super-agent): add Super Agent workspace, Artifact Viewer, unified resource hub, and Agent Runtimes (#808)" (#877)
Reverts commit 216e12abfe on main while keeping #808 (and follow-up #848) intact on the next branch for continued local/desktop Super Agent development.

Preserves subsequent main commits (#844, #847, #849, #851, #854, #856) outside the reverted #808 surface and restores the pre-#808 /mcp routing expectation in tests/server.test.ts.

Co-authored-by: 罗高 <luogao@users.noreply.github.com>
2026-11-23 17:53:30 +08:00

15 lines
1023 B
TypeScript

export type WebPageState = { url: string; title: string; canGoBack: boolean; canGoForward: boolean; loading: boolean; error?: string };
export type BrowserInput =
| { type: 'pointer'; event: 'move' | 'down' | 'up'; x: number; y: number; button: 'left' | 'middle' | 'right'; clickCount?: number }
| { type: 'wheel'; x: number; y: number; deltaX: number; deltaY: number }
| { type: 'text'; text: string }
| { type: 'key'; key: string; modifiers: number };
export function webAddress(value: unknown): string {
if (typeof value !== 'string' || !value.trim() || value.length > 8192) throw new Error('请输入有效的 HTTP 或 HTTPS 网址');
const input = value.trim();
const url = new URL(/^https?:\/\//i.test(input) ? input : /^[a-z][\w+.-]*:/i.test(input) && !/^[\w.-]+:\d+(?:\/|$)/.test(input) ? input : `https://${input}`);
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || !url.hostname) throw new Error('请输入有效的 HTTP 或 HTTPS 网址');
return url.href;
}