diff --git a/lib/index.js b/lib/index.js index 76b2961..1d3867c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,15 +12,17 @@ import { CloudClient } from "./api.js"; import { Reporter } from "./reporter.js"; import { createRoutes } from "./routes.js"; -import { SettingsStore } from "./store.js"; +import { join } from 'node:path'; +import { SettingsStore, dshHome } from "./store.js"; import { SkillSync } from "./skill-sync.js"; +import { SkillAdmin, skillsHoldingDir, skillsTrashDir } from "./skill-admin.js"; import { createMemoryTools, createSkillTools } from "./tools.js"; /** Package name; also the client bundle id. */ export const name = 'dsh-cloud-memory'; /** Services required before `apply` runs. */ export const inject = ['webServer']; /** Version reported by the status card. */ -const VERSION = '0.3.0'; +const VERSION = '0.4.0'; /** How often the skill directory is reconciled with the cloud center. */ const SKILL_SYNC_INTERVAL_MS = 15 * 60_000; /** How often queued reports are retried. */ @@ -52,6 +54,15 @@ export function apply(ctx, config) { skillsDir: settings().skillsDir, }), log: (message) => logger.info(message), + holdingDir: () => skillsHoldingDir(), + }); + const skillAdmin = new SkillAdmin({ + skillsRoot: () => skillSync.skillsRoot(), + holdingDir: () => skillsHoldingDir(), + trashDir: () => skillsTrashDir(), + syncStatePath: () => join(dshHome(), 'cloud-memory-skills.json'), + syncRunning: () => skillSync.stats().running, + log: (message) => logger.info(message), }); // Announce at most once per activation so a missing token is obvious in logs. const effective = settings(); @@ -96,7 +107,7 @@ export function apply(ctx, config) { logger.warn('webServer service unavailable; the configuration page stays disabled'); } else { - const routes = createRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats() }); + const routes = createRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats(), admin: skillAdmin }); for (const route of routes) { ctx.effect(() => webServer.register(route), `dsh-cloud-memory: route ${route.path}`); }