feat(agents): 完成云智能体工作台与交互流程

This commit is contained in:
2026-09-10 19:25:12 +08:00
parent 46fbae9dec
commit 64a3cf4934
26 changed files with 1955 additions and 49 deletions

View File

@@ -4,7 +4,17 @@ export type NianCodeDeepLink = {
type: 'desktop-auth-callback';
requestId: string;
url: string;
};
} | { type: 'cloud-agent'; slug: string; url: string };
let pendingCloudAgentRoute: string | null = null;
export function queueCloudAgentLink(slug: string): void {
pendingCloudAgentRoute = '/cloud-agents/shared/' + slug;
}
export function takeCloudAgentRoute(): string | null {
const route = pendingCloudAgentRoute;
pendingCloudAgentRoute = null;
return route;
}
const SENSITIVE_QUERY_KEYS = new Set([
'access_token',
@@ -21,6 +31,10 @@ export function parseNianCodeDeepLinkUrl(rawUrl: string): NianCodeDeepLink | nul
return null;
}
if (url.protocol === `${NIANCODE_APP_PROTOCOL}:` && url.hostname === 'agents'
&& /^\/ml-[a-f0-9]{32}$/.test(url.pathname) && !url.username && !url.password && !url.port && !url.search && !url.hash) {
return { type: 'cloud-agent', slug: url.pathname.slice(1), url: rawUrl };
}
if (url.protocol !== `${NIANCODE_APP_PROTOCOL}:`) {
return null;
}

View File

@@ -29,6 +29,7 @@ import {
import {
findNianCodeDeepLinkUrl,
NIANCODE_APP_PROTOCOL,
queueCloudAgentLink,
parseNianCodeDeepLinkUrl,
} from './app-deep-link';
import { installMediaPermissionHandler } from './media-permissions';
@@ -355,7 +356,12 @@ function handleAppDeepLinkActivation(rawUrl: string): boolean {
return false;
}
logger.info(`Received Makelore app link: type=${deepLink.type}, request_id=${deepLink.requestId}`);
if (deepLink.type === 'cloud-agent') {
queueCloudAgentLink(deepLink.slug);
mainWindow?.webContents.send('cloud-agent-link');
} else {
logger.info(`Received Makelore app link: type=${deepLink.type}, request_id=${deepLink.requestId}`);
}
requestMainWindowFocus('app deep link');
return true;
}
@@ -365,10 +371,7 @@ function registerMakeloreProtocolClient(): void {
const registered = devEntrypoint
? app.setAsDefaultProtocolClient(NIANCODE_APP_PROTOCOL, process.execPath, [devEntrypoint])
: app.setAsDefaultProtocolClient(NIANCODE_APP_PROTOCOL);
if (!registered) {
logger.warn(`Failed to register ${NIANCODE_APP_PROTOCOL}:// protocol handler`);
}
if (!registered) logger.warn(`Failed to register ${NIANCODE_APP_PROTOCOL}:// protocol handler`);
}
function createMainWindow(): BrowserWindow {

View File

@@ -21,6 +21,7 @@ import {
import type { BackgroundLifecycleController, DesktopActivity } from './background-lifecycle';
import { collectPerformanceSnapshot } from './performance-diagnostics';
import type { HostApiContext } from '../api/context';
import { takeCloudAgentRoute } from './app-deep-link';
type UnifiedRequest = {
id?: string;
@@ -261,6 +262,7 @@ export function registerIpcHandlers(
ipcMain.handle('app:name', () => app.getName());
ipcMain.handle('app:platform', () => process.platform);
ipcMain.handle('app:getPath', (_event, name: Parameters<typeof app.getPath>[0]) => app.getPath(name));
ipcMain.handle('app:take-cloud-agent-link', () => takeCloudAgentRoute());
ipcMain.handle('app:quit', () => app.quit());
ipcMain.handle('app:relaunch', () => {
app.relaunch();