Files
paseo/packages/app/src/agent-skills/legacy-migration.tsx
T
Mohamed BoudraandGitHub 4108960709 Manage orchestration skills per host (#3451)
* feat(skills): manage orchestration skills per host

Agent skills execute on the daemon host, so their bundle, selection, and filesystem convergence must share that owner. Preserve the existing install semantics while letting every capable client manage the selected host and migrating the legacy desktop preference once.

* fix(client): keep skill management internal

Keep host skill management on the low-level daemon client used by the app. Do not expose daemon settings or the desktop-only compatibility migration through the shared Paseo API handed to plugins.

* fix(e2e): declare skills fixture dependencies

Use Playwright's required destructuring form for the test-scoped daemon sandbox fixture so CI can collect the real-host skills suite.

* test(skills): use native managed paths

Assert fixed skill targets relative to the daemon user's real home with platform-native path joining so the ownership contract holds on Windows and POSIX hosts.
2026-08-18 09:51:46 +02:00

51 lines
1.9 KiB
TypeScript

import { useEffect } from "react";
import type { AgentSkillSelection } from "@getpaseo/protocol/messages";
import { getDesktopDaemonStatus, shouldUseDesktopDaemon } from "@/desktop/daemon/desktop-daemon";
import {
deleteLegacySkillSelection,
readLegacySkillSelection,
} from "@/desktop/daemon/desktop-daemon";
import { getHostRuntimeStore } from "@/runtime/host-runtime";
import { useSessionStore } from "@/stores/session-store";
interface LegacySelectionClient {
importLegacyAgentSkillsSelection(selection: AgentSkillSelection): Promise<unknown>;
}
export async function migrateLegacyAgentSkillsSelection(
client: LegacySelectionClient,
read = readLegacySkillSelection,
remove = deleteLegacySkillSelection,
): Promise<boolean> {
const selection = await read();
if (!selection) return false;
await client.importLegacyAgentSkillsSelection(selection);
await remove();
return true;
}
// COMPAT(desktopSkillSelectionMigration): added in v0.4.0; remove after 2027-02-16.
export function LegacyAgentSkillsMigration() {
const connectedManagedHosts = useSessionStore((state) =>
Object.entries(state.sessions)
.filter(([, session]) => session.serverInfo?.desktopManaged === true)
.map(([serverId]) => serverId)
.sort()
.join(","),
);
useEffect(() => {
if (!shouldUseDesktopDaemon() || !connectedManagedHosts) return;
async function migrate(): Promise<void> {
const status = await getDesktopDaemonStatus();
if (status.status !== "running" || !status.desktopManaged) return;
const client = getHostRuntimeStore().getSnapshot(status.serverId)?.client;
if (!client) return;
await migrateLegacyAgentSkillsSelection(client);
}
void migrate().catch((error) => {
console.error("[Agent skills] Legacy selection migration failed; will retry", error);
});
}, [connectedManagedHosts]);
return null;
}