* feat(desktop): open existing agents from links Register a stable agent deep link and route it through the existing Desktop window. Add a matching CLI command that resolves the local server and activates the requested agent without creating or messaging it. * fix(desktop): recover agent link delivery
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { parseAgentDeepLink, type AgentDeepLinkTarget } from "@getpaseo/protocol/agent-deep-link";
|
|
|
|
export function parseAgentDeepLinkFromArgv(argv: string[]): AgentDeepLinkTarget | null {
|
|
for (const arg of argv) {
|
|
const target = parseAgentDeepLink(arg);
|
|
if (target) {
|
|
return target;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export class AgentNavigationInbox {
|
|
private readonly readyWindows = new Set<number>();
|
|
private readonly pendingByWindow = new Map<number, AgentDeepLinkTarget>();
|
|
|
|
windowLoading(webContentsId: number): void {
|
|
this.readyWindows.delete(webContentsId);
|
|
}
|
|
|
|
windowReady(webContentsId: number): AgentDeepLinkTarget | null {
|
|
this.readyWindows.add(webContentsId);
|
|
const pending = this.pendingByWindow.get(webContentsId) ?? null;
|
|
this.pendingByWindow.delete(webContentsId);
|
|
return pending;
|
|
}
|
|
|
|
deliverOrQueue(webContentsId: number, target: AgentDeepLinkTarget): AgentDeepLinkTarget | null {
|
|
if (this.readyWindows.has(webContentsId)) {
|
|
return target;
|
|
}
|
|
this.pendingByWindow.set(webContentsId, target);
|
|
return null;
|
|
}
|
|
|
|
removeWindow(webContentsId: number): void {
|
|
this.readyWindows.delete(webContentsId);
|
|
this.pendingByWindow.delete(webContentsId);
|
|
}
|
|
}
|