Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🗑️ feat: Expose Skill Deletion in Management API (#17005)
Dustin Healyec587c27aa21
diff --git a/api/server/routes/agents/__tests__/openapi.contract.spec.js b/api/server/routes/agents/__tests__/openapi.contract.spec.jsindex 7c44bae8d1..88e837b3bf 100644--- a/api/server/routes/agents/__tests__/openapi.contract.spec.js+++ b/api/server/routes/agents/__tests__/openapi.contract.spec.js@@ -266,6 +266,7 @@ describe('Agents OpenAPI actual HTTP contract', () => {fileHandlers.upload,);app.post('/api/agents/v1/skills', skillHandlers.create);+ app.delete('/api/agents/v1/skills/:id', skillHandlers.delete);app.put('/api/agents/v1/skills/:id/files/*relativePath', skillHandlers.updateFile);app.delete('/api/agents/v1/skills/:id/files/*relativePath', skillHandlers.deleteFile);app.get('/api/agents/v1/agents/:id', (_req, _res, next) =>@@ -357,7 +358,7 @@ describe('Agents OpenAPI actual HTTP contract', () => {expect(fs.readFileSync(diskPath, 'utf8')).toBe(content);});- it('documents and validates Skill creation and file deletion', async () => {+ it('documents and validates Skill creation, file deletion, and whole-Skill deletion', async () => {const created = await request(app).post('/api/agents/v1/skills').set('Authorization', `Bearer ${token}`)@@ -389,6 +390,18 @@ describe('Agents OpenAPI actual HTTP contract', () => {relativePath: 'references/delete-me.md',}).lean(),).toBeNull();++ const deletedSkill = await request(app)+ .delete(`/api/agents/v1/skills/${created.body.id.toUpperCase()}`)+ .set('Authorization', `Bearer ${token}`);+ expect(deletedSkill.status).toBe(200);+ expectResponseToMatchSpec(spec, 'deleteSkill', deletedSkill);+ expect(deletedSkill.body).toEqual({+ id: created.body.id,+ deleted: true,+ cleanupComplete: true,+ });+ expect(await mongoose.models.Skill.findById(created.body.id).lean()).toBeNull();});it('validates parser and normalized management errors against their documented JSON forms', async () => {diff --git a/api/server/routes/agents/__tests__/skills.spec.js b/api/server/routes/agents/__tests__/skills.spec.jsindex a17750443a..40fc5f1dd2 100644--- a/api/server/routes/agents/__tests__/skills.spec.js+++ b/api/server/routes/agents/__tests__/skills.spec.js@@ -17,6 +17,7 @@ jest.mock('@librechat/api', () => ({create: mockWrite,get: mockList,update: mockWrite,+ delete: mockWrite,listFiles: mockList,getFile: mockList,updateFile: mockWrite,@@ -70,3 +71,7 @@ it('keeps authentication ahead of management handlers', async () => {await request(app).get('/skills').expect(401);expect(mockList).not.toHaveBeenCalled();});+it('routes whole-Skill deletion through the authorized management handler', async () => {+ await request(app).delete('/skills/507f1f77bcf86cd799439011').expect(200);+ expect(mockWrite).toHaveBeenCalledTimes(1);+});diff --git a/api/server/routes/agents/skills.js b/api/server/routes/agents/skills.jsindex 509f11b2b1..5d5a55de53 100644--- a/api/server/routes/agents/skills.js+++ b/api/server/routes/agents/skills.js@@ -30,6 +30,7 @@ router.get('/', handlers.list);router.post('/', handlers.create);router.get('/:id', handlers.get);router.patch('/:id', handlers.update);+router.delete('/:id', handlers.delete);router.get('/:id/files', handlers.listFiles);router.get('/:id/files/*relativePath', handlers.getFile);router.put('/:id/files/*relativePath', handlers.updateFile);diff --git a/docs/skills-management-api.md b/docs/skills-management-api.mdindex 6bd5944301..170fb15350 100644--- a/docs/skills-management-api.md+++ b/docs/skills-management-api.md@@ -10,6 +10,7 @@ execution router and does not accept browser sessions or execution API keys as f| POST | `/api/agents/v1/skills` | Create an inline Skill || GET | `/api/agents/v1/skills/:id` | Read Skill metadata, body, and frontmatter || PATCH | `/api/agents/v1/skills/:id` | Update an inline Skill |+| DELETE | `/api/agents/v1/skills/:id` | Delete an inline Skill || GET | `/api/agents/v1/skills/:id/files` | List file metadata || GET | `/api/agents/v1/skills/:id/files/*relativePath` | Read a file as JSON || PUT | `/api/agents/v1/skills/:id/files/*relativePath` | Create or replace a text file |@@ -49,6 +50,11 @@ A stale version returns HTTP 409 with `error.code: "conflict"`; retrieve the curretrying. Skill reads require VIEW access; updates require EDIT and the Skills USE/CREATE rolepermissions. Inaccessible and cross-tenant IDs return the same 404 envelope.+Whole-Skill deletion requires DELETE access and the same Skills USE/CREATE role permissions as+other mutations. It returns `{ "id": "...", "deleted": true, "cleanupComplete": true }` on+complete cleanup. If the existing deletion handler removes the Skill but cannot finish dependent+cleanup, it returns `cleanupComplete: false`; that result does not promise an automatic retry.+Text-file writes accept `{ "content": "replacement text" }`, capped at 1 MiB of UTF-8 data.Use a relative path such as `references/guide.md`. Absolute paths, traversal, and NUL bytes arerejected. Delete the same path to remove the file. Update `SKILL.md` through the Skill's `body`diff --git a/packages/api/openapi/agents.openapi.json b/packages/api/openapi/agents.openapi.jsonindex b54c81e888..702acfe0d4 100644--- a/packages/api/openapi/agents.openapi.json+++ b/packages/api/openapi/agents.openapi.json@@ -1658,6 +1658,134 @@}}}+ },+ "delete": {+ "operationId": "deleteSkill",+ "summary": "Delete an inline skill",+ "tags": [+ "Skills"+ ],+ "security": [+ {+ "oidcBearer": []+ }+ ],+ "parameters": [+ {+ "in": "path",+ "name": "id",+ "description": "The skill id",+ "schema": {+ "type": "string"+ },+ "required": true+ }+ ],+ "responses": {+ "200": {+ "description": "The skill was deleted",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SkillDeleted"+ }+ }+ }+ },+ "400": {+ "description": "Invalid request, or a malformed JSON body",+ "content": {+ "application/json": {+ "schema": {+ "anyOf": [+ {+ "$ref": "#/components/schemas/Error"+ },+ {+ "$ref": "#/components/schemas/JsonParseError"+ }+ ]+ }+ }+ }+ },+ "401": {+ "description": "Authentication failed",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ErrorMessage"+ }+ }+ }+ },+ "403": {+ "description": "Permission denied, the caller is banned, or the request fails tenant isolation",+ "content": {+ "application/json": {+ "schema": {+ "anyOf": [+ {+ "$ref": "#/components/schemas/Error"+ },+ {+ "$ref": "#/components/schemas/MessageError"+ },+ {+ "$ref": "#/components/schemas/ErrorMessage"+ }+ ]+ }+ }+ }+ },+ "404": {+ "description": "Not found",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/Error"+ }+ }+ }+ },+ "409": {+ "description": "The bound account is being deleted",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/AccountDeletionConflict"+ }+ }+ }+ },+ "500": {+ "description": "Internal server error. Errors normalized by the route use JSON; the final application error controller sends a text body with the text/html media type.",+ "content": {+ "application/json": {+ "schema": {+ "anyOf": [+ {+ "$ref": "#/components/schemas/Error"+ },+ {+ "$ref": "#/components/schemas/ErrorMessage"+ }+ ]+ }+ },+ "text/html": {+ "schema": {+ "type": "string",+ "enum": [+ "An unknown error occurred.",+ "Processing error in ErrorController."+ ]+ }+ }+ }+ }+ }}},"/skills/{id}/files": {@@ -4283,6 +4411,27 @@"deleted"]},+ "SkillDeleted": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "pattern": "^[a-f\\d]{24}$"+ },+ "deleted": {+ "type": "boolean",+ "const": true+ },+ "cleanupComplete": {+ "type": "boolean"+ }+ },+ "required": [+ "id",+ "deleted",+ "cleanupComplete"+ ]+ },"ErrorMessage": {"type": "object","properties": {diff --git a/packages/api/src/openapi/skills.ts b/packages/api/src/openapi/skills.tsindex 6fa595fb68..1d12f726a1 100644--- a/packages/api/src/openapi/skills.ts+++ b/packages/api/src/openapi/skills.ts@@ -11,6 +11,7 @@ import {skillFileUpdateSchema,skillFrontmatterValueSchema,skillFileDeleteResponseSchema,+ skillDeleteResponseSchema,} from '../skills/management';import {errorMessageResponseSchema,@@ -52,6 +53,7 @@ export const skillComponentSchemas: Record<string, ZodTypeAny> = {SkillFileUpdateRequest: skillFileUpdateSchema,SkillFileUpdated: skillFileUpdatedSchema,SkillFileDeleted: skillFileDeleteResponseSchema,+ SkillDeleted: skillDeleteResponseSchema,};const errorResponses = [@@ -150,6 +152,19 @@ export const skillContracts: EndpointContract[] = [},],},+ {+ operationId: 'deleteSkill',+ method: 'delete',+ path: '/skills/{id}',+ tags: [TAG],+ summary: 'Delete an inline skill',+ security: SECURITY,+ pathParams: [{ name: 'id', description: 'The skill id' }],+ responses: [+ { status: 200, description: 'The skill was deleted', schema: skillDeleteResponseSchema },+ ...errorResponses,+ ],+ },{operationId: 'listSkillFiles',method: 'get',diff --git a/packages/api/src/skills/management.spec.ts b/packages/api/src/skills/management.spec.tsindex de4faddab7..83e94568eb 100644--- a/packages/api/src/skills/management.spec.ts+++ b/packages/api/src/skills/management.spec.ts@@ -9,6 +9,7 @@ import type { AllMethods, IRole, IUser } from '@librechat/data-schemas';import type { FiltersConfig } from 'librechat-data-provider';import type { RequestHandler } from 'express';import type { SkillManagementDeps } from './management';+import type { SkillsHandlers } from './handlers';import type { ServerRequest } from '~/types';import { createSkillManagementHandlers } from './management';import { createSkillsHandlers } from './handlers';@@ -21,6 +22,7 @@ let db: AllMethods;let app: express.Express;let skillId: string;let allowEdit: boolean;+let allowDelete: boolean;let allowView: boolean;let allowUse: boolean;let allowCreate: boolean;@@ -36,6 +38,7 @@ let publiclyAccessible: jest.Mock;let publicStatus: jest.Mock;let capabilityCheck: jest.Mock;let originalStrict: string | undefined;+let skillHandlers: SkillsHandlers;const inTenant = <T>(fn: () => T) => tenantStorage.run({ tenantId }, fn);beforeAll(async () => {@@ -55,6 +58,7 @@ afterAll(async () => {beforeEach(async () => {await mongoose.connection.dropDatabase();allowEdit = true;+ allowDelete = true;allowView = true;allowUse = true;allowCreate = true;@@ -83,7 +87,7 @@ beforeEach(async () => {publiclyAccessible = jest.fn(async () => []);publicStatus = jest.fn(async () => false);capabilityCheck = jest.fn(async () => canManage);- const handlers = createSkillsHandlers({+ skillHandlers = createSkillsHandlers({...db,findAccessibleResources: accessible,findPubliclyAccessibleResources: publiclyAccessible,@@ -93,7 +97,7 @@ beforeEach(async () => {isValidObjectIdString: (id) => typeof id === 'string' && /^[a-f\d]{24}$/i.test(id),});const management = createSkillManagementHandlers({- handlers,+ handlers: skillHandlers,beforeList,fileWriteLimiters: [uploadLimiter],getSkillById: db.getSkillById,@@ -108,6 +112,7 @@ beforeEach(async () => {}) as IRole,checkPermission: async ({ requiredPermission }) => {if (requiredPermission === PermissionBits.EDIT) return allowEdit;+ if (requiredPermission === PermissionBits.DELETE) return allowDelete;return allowView;},saveFile,@@ -132,6 +137,9 @@ beforeEach(async () => {app.patch('/skills/:id', async (req, res) => {await management.update(req, res);});+ app.delete('/skills/:id', async (req, res) => {+ await management.delete(req, res);+ });app.get('/skills/:id/files', async (req, res) => {await management.listFiles(req, res);});@@ -187,6 +195,44 @@ it('requires create capability for management mutations', async () => {.patch(`/skills/${skillId}`).send({ expectedVersion: 1, body: 'Denied' }).expect(403);+ await request(app).delete(`/skills/${skillId}`).expect(403);+});+it('deletes an inline Skill through the existing cleanup handler', async () => {+ const result = await request(app).delete(`/skills/${skillId.toUpperCase()}`).expect(200);+ expect(result.body).toEqual({ id: skillId, deleted: true, cleanupComplete: true });+ expect(await inTenant(() => db.getSkillById(skillId))).toBeNull();+ await request(app).delete(`/skills/${skillId}`).expect(404);+});+it('requires DELETE access and hides missing or cross-tenant Skills', async () => {+ allowDelete = false;+ await request(app).delete(`/skills/${skillId}`).expect(404);+ allowDelete = true;+ await request(app).delete(`/skills/${new Types.ObjectId()}`).expect(404);+ const { skill } = await tenantStorage.run({ tenantId: 'foreign' }, () =>+ db.createSkill({+ name: 'foreign',+ description: 'Foreign tenant Skill for deletion isolation tests.',+ body: 'secret',+ author,+ authorName: 'Foreign',+ tenantId: 'foreign',+ }),+ );+ await request(app).delete(`/skills/${skill._id}`).expect(404);+ expect(+ await tenantStorage.run({ tenantId: 'foreign' }, () => db.getSkillById(skill._id)),+ ).not.toBeNull();+});+it('preserves the existing incomplete-cleanup result without exposing storage details', async () => {+ jest+ .spyOn(skillHandlers, 'delete')+ .mockImplementationOnce(async (_req, res) =>+ res+ .status(200)+ .json({ id: skillId, deleted: true, cleanupComplete: false, storageKey: 'hidden' }),+ );+ const result = await request(app).delete(`/skills/${skillId}`).expect(200);+ expect(result.body).toEqual({ id: skillId, deleted: true, cleanupComplete: false });});it('lists and retrieves stable representations without ownership or storage internals', async () => {@@ -254,6 +300,7 @@ it.each([it('hides inaccessible and cross-tenant Skills, including on file writes', async () => {allowView = false;allowEdit = false;+ allowDelete = false;await request(app).get(`/skills/${skillId}`).expect(404);await request(app).patch(`/skills/${skillId}`)@@ -264,6 +311,7 @@ it('hides inaccessible and cross-tenant Skills, including on file writes', async.send({ content: 'x' }).expect(404);await request(app).delete(`/skills/${skillId}/files/reference.md`).expect(404);+ await request(app).delete(`/skills/${skillId}`).expect(404);expect(saveFile).not.toHaveBeenCalled();allowView = true;allowEdit = true;@@ -282,6 +330,7 @@ it('hides inaccessible and cross-tenant Skills, including on file writes', async.patch(`/skills/${skill._id}`).send({ expectedVersion: 1, body: 'x' }).expect(404);+ await request(app).delete(`/skills/${skill._id}`).expect(404);});it('allows viewing without allowing editing', async () => {allowEdit = false;@@ -312,6 +361,7 @@ it('keeps synchronized Skill content and files read-only', async () => {.send({ content: 'x' }).expect(403);await request(app).delete(`/skills/${skillId}/files/reference.md`).expect(403);+ await request(app).delete(`/skills/${skillId}`).expect(403);expect(saveFile).not.toHaveBeenCalled();});it('writes nested text files through existing storage and rejects unsafe paths', async () => {diff --git a/packages/api/src/skills/management.ts b/packages/api/src/skills/management.tsindex 9d0d9bec96..41c9774ea8 100644--- a/packages/api/src/skills/management.ts+++ b/packages/api/src/skills/management.ts@@ -9,6 +9,7 @@ import {import type {SkillFrontmatterValue,TCreateSkill,+ TDeleteSkillResponse,TDeleteSkillFileResponse,TSkill,TUpdateSkillPayload,@@ -130,6 +131,11 @@ export const skillFileDeleteResponseSchema: z.ZodType<TDeleteSkillFileResponse>relativePath: z.string(),deleted: z.literal(true),});+export const skillDeleteResponseSchema: z.ZodType<TDeleteSkillResponse> = z.object({+ id: idSchema,+ deleted: z.literal(true),+ cleanupComplete: z.boolean(),+});const listSchema = agentManagementListSchema;type ManagementRequest = Request &@@ -233,7 +239,15 @@ async function admitFileWrite(req: Request, res: Response, limiters: RequestHandexport function createSkillManagementHandlers(deps: SkillManagementDeps,): Record<- 'list' | 'create' | 'get' | 'update' | 'listFiles' | 'getFile' | 'updateFile' | 'deleteFile',+ | 'list'+ | 'create'+ | 'get'+ | 'update'+ | 'delete'+ | 'listFiles'+ | 'getFile'+ | 'updateFile'+ | 'deleteFile',(request: Request, res: Response) => Promise<Response>> {async function canManageSkills(req: ManagementRequest): Promise<boolean> {@@ -248,7 +262,7 @@ export function createSkillManagementHandlers(function wrap(permission: PermissionBits | undefined,operation: (req: ManagementRequest, res: Response) => Promise<Response>,- options: { mutation?: boolean } = {},+ options: { mutation?: boolean; canonicalizeId?: boolean } = {},) {return async (request: Request, res: Response): Promise<Response> => {const req = request as ManagementRequest;@@ -264,6 +278,7 @@ export function createSkillManagementHandlers(});if (!allowed) return sendError(res, 'permission_denied');if (permission !== undefined) {+ if (options.canonicalizeId) req.params.id = req.params.id.toLowerCase();if (!idSchema.safeParse(req.params.id).success) return sendError(res, 'not_found');const [skill, canManage] = await Promise.all([deps.getSkillById(req.params.id),@@ -368,6 +383,12 @@ export function createSkillManagementHandlers(},{ mutation: true },),+ delete: wrap(+ PermissionBits.DELETE,+ (req, res) =>+ runHandler(req, res, deps.handlers.delete, (body) => skillDeleteResponseSchema.parse(body)),+ { mutation: true, canonicalizeId: true },+ ),listFiles: wrap(PermissionBits.VIEW, (req, res) =>runHandler(req, res, deps.handlers.listFiles, (body) => ({object: 'list',diff --git a/packages/data-provider/src/types/skills.ts b/packages/data-provider/src/types/skills.tsindex 0a71fde2aa..8f1e732ebd 100644--- a/packages/data-provider/src/types/skills.ts+++ b/packages/data-provider/src/types/skills.ts@@ -400,7 +400,7 @@ export type TDeleteSkillResponse = {id: string;deleted: true;/** False when the Skill row is gone but a dependent cleanup step needs repair. */- cleanupComplete?: boolean;+ cleanupComplete: boolean;};/** Response from GET `/api/skills/:id/files`. */