@agiletortoise/drafts-mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Agile Tortoise
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,404 @@
1
+ # Drafts MCP Server
2
+
3
+ A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that enables AI assistants to interact with the [Drafts](https://getdrafts.com) app on macOS through AppleScript.
4
+
5
+ ## Features
6
+
7
+ - 📝 **Draft Management**: Create, read, update, and search drafts
8
+ - 🏷️ **Tags**: Add and manage tags on drafts
9
+ - 📂 **Workspaces**: List and query drafts from specific workspaces
10
+ - ⚡ **Actions**: Run Drafts actions programmatically
11
+ - 🔍 **Search**: Full-text search across all drafts
12
+ - 🚩 **Flags & Archive**: Flag, archive, or trash drafts
13
+
14
+ ## Requirements
15
+
16
+ - macOS (AppleScript is macOS-only)
17
+ - [Drafts](https://getdrafts.com) app v50.0.2 or greater installed
18
+ - Node.js 18 or higher
19
+
20
+ ## Installation
21
+
22
+ ### Quick Start (After Publishing to npm)
23
+
24
+ Once published, use with `npx` - no installation needed:
25
+
26
+ ```bash
27
+ npx @agiletortoise/drafts-mcp-server
28
+ ```
29
+
30
+ ### Global Installation
31
+
32
+ ```bash
33
+ npm install -g @agiletortoise/drafts-mcp-server
34
+ ```
35
+
36
+ ### Local Development/Testing
37
+
38
+ Before publishing, test locally:
39
+
40
+ ```bash
41
+ # Clone or extract the package
42
+ cd drafts-mcp-server
43
+
44
+ # Install dependencies
45
+ npm install
46
+
47
+ # Build
48
+ npm run build
49
+
50
+ # Test with MCP Inspector
51
+ npm run inspector
52
+
53
+ # Or run directly
54
+ node dist/index.js
55
+ ```
56
+
57
+ ### Configuration for Claude Desktop
58
+
59
+ **After publishing to npm**, add to your Claude Desktop config file (`~/Library/Application Support/Claude/claude_desktop_config.json`):
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "drafts": {
65
+ "command": "npx",
66
+ "args": ["@agiletortoise/drafts-mcp-server"]
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ **For local development/testing** (before publishing), use:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "drafts": {
78
+ "command": "node",
79
+ "args": ["/absolute/path/to/drafts-mcp-server/dist/index.js"]
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ Or if globally installed:
86
+
87
+ ```json
88
+ {
89
+ "mcpServers": {
90
+ "drafts": {
91
+ "command": "drafts-mcp-server"
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ### Configuration for Cursor
98
+
99
+ **After publishing to npm**, add to your Cursor MCP settings (`.cursor/mcp.json` in your project or global settings):
100
+
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "drafts": {
105
+ "command": "npx",
106
+ "args": ["@agiletortoise/drafts-mcp-server"]
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ **For local development/testing**, use:
113
+
114
+ ```json
115
+ {
116
+ "mcpServers": {
117
+ "drafts": {
118
+ "command": "node",
119
+ "args": ["/absolute/path/to/drafts-mcp-server/dist/index.js"]
120
+ }
121
+ }
122
+ }
123
+ ```
124
+
125
+ ### Configuration for Claude Code
126
+
127
+ Claude Code (the CLI tool) can be configured using the `/mcp` command or by editing the settings file directly.
128
+
129
+ **Using the CLI:**
130
+
131
+ ```bash
132
+ claude mcp add drafts -- npx @agiletortoise/drafts-mcp-server
133
+ ```
134
+
135
+ **For local development/testing**, use:
136
+
137
+ ```bash
138
+ claude mcp add drafts -- node /absolute/path/to/drafts-mcp-server/dist/index.js
139
+ ```
140
+
141
+ After adding, restart Claude Code or start a new session for the MCP server to be available.
142
+
143
+ ## Permissions
144
+
145
+ The first time the server runs, macOS will ask for permissions:
146
+
147
+ 1. **System Preferences** > **Security & Privacy** > **Privacy** > **Automation**
148
+ 2. Allow the MCP host (e.g., Claude Desktop, Claude Code, Cursor) to control **Drafts**
149
+
150
+ ## Available Tools
151
+
152
+ ### Workspace Management
153
+
154
+ #### `drafts_list_workspaces`
155
+ List all workspaces in Drafts.
156
+
157
+ ```typescript
158
+ // No parameters required
159
+ ```
160
+
161
+ ### Draft Operations
162
+
163
+ #### `drafts_get_drafts`
164
+ Get drafts from a specific workspace with optional filtering.
165
+
166
+ ```typescript
167
+ {
168
+ workspaceName: string; // Required: Name of the workspace
169
+ query?: string; // Optional: Query string to filter drafts
170
+ }
171
+ ```
172
+
173
+ #### `drafts_create_draft`
174
+ Create a new draft with content and optional tags.
175
+
176
+ ```typescript
177
+ {
178
+ content: string; // Required: Draft content
179
+ tags?: string[]; // Optional: Array of tag names
180
+ flagged?: boolean; // Optional: Flag the draft
181
+ }
182
+ ```
183
+
184
+ #### `drafts_get_draft`
185
+ Retrieve a specific draft by UUID.
186
+
187
+ ```typescript
188
+ {
189
+ uuid: string; // Required: UUID of the draft
190
+ }
191
+ ```
192
+
193
+ #### `drafts_update_draft`
194
+ Update the content of an existing draft.
195
+
196
+ ```typescript
197
+ {
198
+ uuid: string; // Required: UUID of the draft
199
+ content: string; // Required: New content
200
+ }
201
+ ```
202
+
203
+ #### `drafts_search`
204
+ Search for drafts across all workspaces.
205
+
206
+ ```typescript
207
+ {
208
+ query: string; // Required: Search query
209
+ }
210
+ ```
211
+
212
+ ### Tags
213
+
214
+ #### `drafts_add_tags`
215
+ Add tags to an existing draft.
216
+
217
+ ```typescript
218
+ {
219
+ uuid: string; // Required: UUID of the draft
220
+ tags: string[]; // Required: Array of tag names to add
221
+ }
222
+ ```
223
+
224
+ ### Actions
225
+
226
+ #### `drafts_list_actions`
227
+ List all available Drafts actions.
228
+
229
+ ```typescript
230
+ // No parameters required
231
+ ```
232
+
233
+ #### `drafts_run_action`
234
+ Run a Drafts action on a specific draft.
235
+
236
+ ```typescript
237
+ {
238
+ draftUuid: string; // Required: UUID of the draft
239
+ actionName: string; // Required: Name of the action to run
240
+ }
241
+ ```
242
+
243
+ ### Draft Status
244
+
245
+ #### `drafts_flag`
246
+ Flag or unflag a draft.
247
+
248
+ ```typescript
249
+ {
250
+ uuid: string; // Required: UUID of the draft
251
+ flagged: boolean; // Required: true to flag, false to unflag
252
+ }
253
+ ```
254
+
255
+ #### `drafts_archive`
256
+ Archive a draft.
257
+
258
+ ```typescript
259
+ {
260
+ uuid: string; // Required: UUID of the draft to archive
261
+ }
262
+ ```
263
+
264
+ #### `drafts_trash`
265
+ Move a draft to trash.
266
+
267
+ ```typescript
268
+ {
269
+ uuid: string; // Required: UUID of the draft to trash
270
+ }
271
+ ```
272
+
273
+ ## Example Usage
274
+
275
+ Here are some example prompts you can use with Claude or other AI assistants:
276
+
277
+ ### Basic Operations
278
+
279
+ ```
280
+ "Show me all my workspaces in Drafts"
281
+
282
+ "Get all drafts from my 'Work' workspace"
283
+
284
+ "Create a new draft with the content 'Meeting notes for Q1 planning'"
285
+
286
+ "Search for drafts containing 'budget'"
287
+ ```
288
+
289
+ ### Advanced Operations
290
+
291
+ ```
292
+ "Create a draft with content 'Todo: Review PR #123' and tag it with 'work' and 'urgent'"
293
+
294
+ "Find the draft about the marketing campaign and run the 'Send to Email' action on it"
295
+
296
+ "Flag all drafts in my Inbox workspace that contain 'follow up'"
297
+
298
+ "Archive all drafts tagged 'completed'"
299
+ ```
300
+
301
+ ### Workflow Integration
302
+
303
+ ```
304
+ "Get all drafts from my 'Daily Notes' workspace from the last week,
305
+ then create a summary draft tagged 'weekly-review'"
306
+
307
+ "Search for all drafts tagged 'meeting-notes', extract action items,
308
+ and create a new draft with all the action items combined"
309
+ ```
310
+
311
+ ## Development
312
+
313
+ ### Setup
314
+
315
+ ```bash
316
+ # Clone the repository
317
+ git clone https://github.com/agiletortoise/drafts-mcp-server.git
318
+ cd drafts-mcp-server
319
+
320
+ # Install dependencies
321
+ npm install
322
+
323
+ # Build
324
+ npm run build
325
+
326
+ # Test with MCP Inspector
327
+ npm run inspector
328
+ ```
329
+
330
+ ### Project Structure
331
+
332
+ ```
333
+ drafts-mcp-server/
334
+ ├── src/
335
+ │ ├── index.ts # Main MCP server implementation
336
+ │ ├── drafts.ts # Drafts-specific operations
337
+ │ └── applescript.ts # AppleScript execution utilities
338
+ ├── dist/ # Compiled JavaScript (generated)
339
+ ├── package.json
340
+ ├── tsconfig.json
341
+ └── README.md
342
+ ```
343
+
344
+ ### Testing
345
+
346
+ Use the [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) to test the server:
347
+
348
+ ```bash
349
+ npm run inspector
350
+ ```
351
+
352
+ This opens a web interface where you can test each tool interactively.
353
+
354
+ ## Troubleshooting
355
+
356
+ ### "Drafts got an error: Can't get workspace..."
357
+
358
+ Make sure you've spelled the workspace name exactly as it appears in Drafts. Workspace names are case-sensitive.
359
+
360
+ ### Permission Errors
361
+
362
+ 1. Check **System Preferences** > **Security & Privacy** > **Privacy** > **Automation**
363
+ 2. Ensure your MCP client (Claude Desktop, Cursor, etc.) has permission to control Drafts
364
+ 3. You may need to restart the client after granting permissions
365
+
366
+ ### Script Execution Errors
367
+
368
+ 1. Ensure Drafts is installed and has been launched at least once
369
+ 2. Try running a simple AppleScript manually to verify permissions:
370
+ ```bash
371
+ osascript -e 'tell application "Drafts" to get name of first workspace'
372
+ ```
373
+
374
+ ### No Workspaces/Drafts Returned
375
+
376
+ This might indicate that AppleScript dictionary access isn't working. Check that:
377
+ - You're using the latest version of Drafts
378
+ - Your AppleScript dictionary is properly exposed in Drafts
379
+
380
+ ## Contributing
381
+
382
+ Contributions are welcome! Please feel free to submit a Pull Request.
383
+
384
+ 1. Fork the repository
385
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
386
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
387
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
388
+ 5. Open a Pull Request
389
+
390
+ ## License
391
+
392
+ MIT License - see the [LICENSE](LICENSE) file for details.
393
+
394
+ ## Related Projects
395
+
396
+ - [Model Context Protocol](https://modelcontextprotocol.io) - The protocol specification
397
+ - [Drafts](https://getdrafts.com) - Where text starts
398
+ - [Claude Desktop](https://claude.ai/download) - AI assistant with MCP support
399
+
400
+ ## Support
401
+
402
+ - **Issues**: [GitHub Issues](https://github.com/agiletortoise/drafts-mcp-server/issues)
403
+ - **Drafts Support**: [Drafts Community](https://forums.getdrafts.com)
404
+ - **MCP Documentation**: [MCP Docs](https://modelcontextprotocol.io/docs)
@@ -0,0 +1,26 @@
1
+ export interface AppleScriptError extends Error {
2
+ code?: number;
3
+ stderr?: string;
4
+ }
5
+ /**
6
+ * Execute AppleScript code and return the result
7
+ */
8
+ export declare function executeAppleScript(script: string): Promise<string>;
9
+ /**
10
+ * Execute compiled AppleScript (.scpt) file
11
+ */
12
+ export declare function executeCompiledScript(scriptPath: string, args?: string[]): Promise<string>;
13
+ /**
14
+ * Escape a string for safe use in AppleScript
15
+ */
16
+ export declare function escapeAppleScriptString(str: string): string;
17
+ /**
18
+ * Parse AppleScript list output (e.g., "item1, item2, item3")
19
+ */
20
+ export declare function parseAppleScriptList(output: string): string[];
21
+ /**
22
+ * Parse AppleScript record output to JSON
23
+ * Limited implementation - handles simple records
24
+ */
25
+ export declare function parseAppleScriptRecord(output: string): Record<string, any>;
26
+ //# sourceMappingURL=applescript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applescript.d.ts","sourceRoot":"","sources":["../src/applescript.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqCxE;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAkCpG;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAY1E"}
@@ -0,0 +1,105 @@
1
+ import { spawn } from 'child_process';
2
+ /**
3
+ * Execute AppleScript code and return the result
4
+ */
5
+ export async function executeAppleScript(script) {
6
+ return new Promise((resolve, reject) => {
7
+ const child = spawn('osascript', ['-']);
8
+ let stdout = '';
9
+ let stderr = '';
10
+ child.stdout.on('data', (data) => {
11
+ stdout += data.toString();
12
+ });
13
+ child.stderr.on('data', (data) => {
14
+ stderr += data.toString();
15
+ });
16
+ child.on('close', (code) => {
17
+ if (stderr) {
18
+ console.error('AppleScript stderr:', stderr);
19
+ }
20
+ if (code !== 0) {
21
+ const error = new Error(`AppleScript execution failed: ${stderr || 'unknown error'}`);
22
+ error.code = code ?? undefined;
23
+ error.stderr = stderr;
24
+ reject(error);
25
+ }
26
+ else {
27
+ resolve(stdout.trim());
28
+ }
29
+ });
30
+ child.on('error', (err) => {
31
+ reject(new Error(`Failed to spawn osascript: ${err.message}`));
32
+ });
33
+ child.stdin.write(script);
34
+ child.stdin.end();
35
+ });
36
+ }
37
+ /**
38
+ * Execute compiled AppleScript (.scpt) file
39
+ */
40
+ export async function executeCompiledScript(scriptPath, args = []) {
41
+ return new Promise((resolve, reject) => {
42
+ const child = spawn('osascript', [scriptPath, ...args]);
43
+ let stdout = '';
44
+ let stderr = '';
45
+ child.stdout.on('data', (data) => {
46
+ stdout += data.toString();
47
+ });
48
+ child.stderr.on('data', (data) => {
49
+ stderr += data.toString();
50
+ });
51
+ child.on('close', (code) => {
52
+ if (stderr) {
53
+ console.error('Compiled script stderr:', stderr);
54
+ }
55
+ if (code !== 0) {
56
+ const error = new Error(`Compiled script execution failed: ${stderr || 'unknown error'}`);
57
+ error.code = code ?? undefined;
58
+ error.stderr = stderr;
59
+ reject(error);
60
+ }
61
+ else {
62
+ resolve(stdout.trim());
63
+ }
64
+ });
65
+ child.on('error', (err) => {
66
+ reject(new Error(`Failed to spawn osascript: ${err.message}`));
67
+ });
68
+ });
69
+ }
70
+ /**
71
+ * Escape a string for safe use in AppleScript
72
+ */
73
+ export function escapeAppleScriptString(str) {
74
+ return str
75
+ .replace(/\\/g, '\\\\')
76
+ .replace(/"/g, '\\"')
77
+ .replace(/\n/g, '\\n')
78
+ .replace(/\r/g, '\\r')
79
+ .replace(/\t/g, '\\t');
80
+ }
81
+ /**
82
+ * Parse AppleScript list output (e.g., "item1, item2, item3")
83
+ */
84
+ export function parseAppleScriptList(output) {
85
+ if (!output || output.trim() === '') {
86
+ return [];
87
+ }
88
+ return output.split(', ').map(item => item.trim());
89
+ }
90
+ /**
91
+ * Parse AppleScript record output to JSON
92
+ * Limited implementation - handles simple records
93
+ */
94
+ export function parseAppleScriptRecord(output) {
95
+ const result = {};
96
+ // Very basic parser for simple key:value records
97
+ const matches = output.matchAll(/(\w+):([^,}]+)/g);
98
+ for (const match of matches) {
99
+ const key = match[1].trim();
100
+ const value = match[2].trim();
101
+ result[key] = value;
102
+ }
103
+ return result;
104
+ }
105
+ //# sourceMappingURL=applescript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applescript.js","sourceRoot":"","sources":["../src/applescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAOtC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAc;IACrD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAExC,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAC/B,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAC/B,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;YAC/C,CAAC;YAED,IAAI,IAAI,KAAK,CAAC,EAAE,CAA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EAAE,CAAC;QACpC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,MAAM,MAAM,GAAwB,EAAE,CAAC;IAEvC,iDAAiD;IACjD,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACnD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,106 @@
1
+ export interface Workspace {
2
+ name: string;
3
+ uuid?: string;
4
+ }
5
+ export interface Draft {
6
+ id: string;
7
+ title: string;
8
+ content: string;
9
+ flagged: boolean;
10
+ folder: 'inbox' | 'archive' | 'trash';
11
+ tags: string[];
12
+ /** ISO 8601 date string */
13
+ creationDate: string;
14
+ /** ISO 8601 date string */
15
+ modificationDate: string;
16
+ /** ISO 8601 date string */
17
+ accessDate: string;
18
+ permalink: string;
19
+ creationLatitude: number;
20
+ creationLongitude: number;
21
+ modificationLatitude: number;
22
+ modificationLongitude: number;
23
+ }
24
+ export interface Action {
25
+ name: string;
26
+ uuid?: string;
27
+ }
28
+ export interface DraftFilter {
29
+ query?: string;
30
+ folder?: 'inbox' | 'archive' | 'trash';
31
+ tag?: string;
32
+ flagged?: boolean;
33
+ createdAfter?: string;
34
+ createdBefore?: string;
35
+ modifiedAfter?: string;
36
+ modifiedBefore?: string;
37
+ }
38
+ /**
39
+ * List all workspaces in Drafts
40
+ */
41
+ export declare function listWorkspaces(): Promise<Workspace[]>;
42
+ /**
43
+ * Get the current workspace
44
+ */
45
+ export declare function getCurrentWorkspace(): Promise<Workspace>;
46
+ /**
47
+ * Get the current draft
48
+ */
49
+ export declare function getCurrentDraft(): Promise<Draft | null>;
50
+ /**
51
+ * Get drafts from a specific workspace
52
+ */
53
+ export declare function getWorkspaceDrafts(workspaceName: string, folder?: 'inbox' | 'archive' | 'trash'): Promise<Draft[]>;
54
+ /**
55
+ * Get drafts with flexible filtering
56
+ */
57
+ export declare function getDrafts(filter: DraftFilter): Promise<Draft[]>;
58
+ /**
59
+ * Create a new draft
60
+ */
61
+ export declare function createDraft(content: string, tags?: string[], flagged?: boolean): Promise<string>;
62
+ /**
63
+ * Get a specific draft by UUID
64
+ */
65
+ export declare function getDraft(uuid: string): Promise<Draft | null>;
66
+ /**
67
+ * Update a draft's content
68
+ */
69
+ export declare function updateDraft(uuid: string, content: string): Promise<boolean>;
70
+ /**
71
+ * Add tags to a draft
72
+ */
73
+ export declare function addTagsToDraft(uuid: string, tags: string[]): Promise<boolean>;
74
+ /**
75
+ * Run an action on a draft
76
+ */
77
+ export declare function runAction(draftUuid: string, actionName: string): Promise<boolean>;
78
+ /**
79
+ * List available actions
80
+ */
81
+ export declare function listActions(): Promise<Action[]>;
82
+ /**
83
+ * Search for drafts
84
+ */
85
+ export declare function searchDrafts(query: string): Promise<Draft[]>;
86
+ /**
87
+ * Flag or unflag a draft
88
+ */
89
+ export declare function setDraftFlagged(uuid: string, flagged: boolean): Promise<boolean>;
90
+ /**
91
+ * Archive a draft
92
+ */
93
+ export declare function archiveDraft(uuid: string): Promise<boolean>;
94
+ /**
95
+ * Move a draft to inbox
96
+ */
97
+ export declare function inboxDraft(uuid: string): Promise<boolean>;
98
+ /**
99
+ * Trash a draft
100
+ */
101
+ export declare function trashDraft(uuid: string): Promise<boolean>;
102
+ /**
103
+ * Open a draft in the Drafts editor
104
+ */
105
+ export declare function openDraft(uuid: string): Promise<boolean>;
106
+ //# sourceMappingURL=drafts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drafts.d.ts","sourceRoot":"","sources":["../src/drafts.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IACtC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED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