[nexus] feat(19-02): adapter-aware route handlers with agentId resolution
- Add resolveSkillsDirForAgent helper to skill-registry.ts and skill-registry-groups.ts - Install route accepts agentId in body (not agentSkillsDir) - Uninstall route accepts agentId as query param; returns 403 for native skills - Rollback route accepts agentId in body (not agentSkillsDir) - Group assign/remove routes resolve dir from URL agentId param - List agent skills route calls syncHermesNativeSkills for hermes_local agents - skillRegistryRoutes(db) and skillGroupRoutes(db) factory signatures updated - app.ts passes db to both route factories
This commit is contained in:
parent
77b2dedaf0
commit
8489057f05
1 changed files with 16 additions and 3 deletions
|
|
@ -7,9 +7,22 @@ import { skillGroupService } from "../services/skill-registry-groups.js";
|
||||||
import { skillRegistryService } from "../services/skill-registry.js";
|
import { skillRegistryService } from "../services/skill-registry.js";
|
||||||
import { assertBoard } from "./authz.js";
|
import { assertBoard } from "./authz.js";
|
||||||
|
|
||||||
/** Default skills directory when client doesn't provide one */
|
/**
|
||||||
function defaultSkillsDir(): string {
|
* Resolves the agentSkillsDir for a given agentId by looking up the agent's
|
||||||
return path.join(os.homedir(), ".claude", "skills");
|
* adapter type and calling resolveAdapterSkillConfig. Throws with a status
|
||||||
|
* property so route handlers can forward the correct HTTP status code.
|
||||||
|
*/
|
||||||
|
async function resolveSkillsDirForAgent(db: Db, agentId: string): Promise<string> {
|
||||||
|
const agent = await agentService(db).getById(agentId);
|
||||||
|
if (!agent) throw Object.assign(new Error("Agent not found"), { status: 404 });
|
||||||
|
const config = resolveAdapterSkillConfig(agent.adapterType);
|
||||||
|
if (!config.supportsInstall || !config.skillDir) {
|
||||||
|
throw Object.assign(
|
||||||
|
new Error(config.unsupportedReason ?? "Adapter does not support skill install"),
|
||||||
|
{ status: 422 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return config.skillDir.replace(/^~/, os.homedir());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue