一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
36 行
993 B
TypeScript
36 行
993 B
TypeScript
import { _ } from '../../../../locale';
|
|
import Note from '../../../../models/Note';
|
|
import { ToolError } from '../types';
|
|
import buildTool from '../utils/buildTool';
|
|
|
|
interface Input {
|
|
id?: string;
|
|
}
|
|
|
|
const tool = buildTool({
|
|
id: 'delete_note',
|
|
userDescription: () => _('Deleted note'),
|
|
description: 'Move a note to the trash. The note is not permanently removed and the user can restore it from the trash.',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', description: 'The note id to trash.' },
|
|
},
|
|
required: ['id'],
|
|
},
|
|
handler: async (input: Input) => {
|
|
if (!input.id) throw new ToolError('Missing "id" parameter');
|
|
|
|
const existing = await Note.load(input.id);
|
|
if (!existing || existing.is_conflict || (existing.deleted_time && existing.deleted_time > 0)) {
|
|
throw new ToolError(`Note not found: ${input.id}`);
|
|
}
|
|
|
|
await Note.batchDelete([input.id], { toTrash: true });
|
|
|
|
return { id: input.id, trashed: true };
|
|
},
|
|
});
|
|
|
|
export default tool;
|