@dalmasonto/taskflow-mcp 1.0.35 → 2.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.
Files changed (101) hide show
  1. package/README.md +138 -193
  2. package/dist/attachment-download.d.ts +74 -0
  3. package/dist/attachment-download.js +193 -0
  4. package/dist/attachment-download.js.map +1 -0
  5. package/dist/attachments.d.ts +23 -0
  6. package/dist/attachments.js +66 -0
  7. package/dist/attachments.js.map +1 -0
  8. package/dist/client.d.ts +206 -0
  9. package/dist/client.js +279 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/config.d.ts +137 -18
  12. package/dist/config.js +187 -106
  13. package/dist/config.js.map +1 -0
  14. package/dist/connect.d.ts +89 -0
  15. package/dist/connect.js +269 -0
  16. package/dist/connect.js.map +1 -0
  17. package/dist/doctor.d.ts +24 -0
  18. package/dist/doctor.js +120 -0
  19. package/dist/doctor.js.map +1 -0
  20. package/dist/events.d.ts +186 -0
  21. package/dist/events.js +407 -0
  22. package/dist/events.js.map +1 -0
  23. package/dist/index.d.ts +7 -1
  24. package/dist/index.js +121 -218
  25. package/dist/index.js.map +1 -0
  26. package/dist/instructions.d.ts +12 -0
  27. package/dist/instructions.js +114 -0
  28. package/dist/instructions.js.map +1 -0
  29. package/dist/mint.d.ts +62 -0
  30. package/dist/mint.js +135 -0
  31. package/dist/mint.js.map +1 -0
  32. package/dist/mirror.d.ts +68 -0
  33. package/dist/mirror.js +103 -0
  34. package/dist/mirror.js.map +1 -0
  35. package/dist/pane-queue.d.ts +29 -0
  36. package/dist/pane-queue.js +35 -0
  37. package/dist/pane-queue.js.map +1 -0
  38. package/dist/prompts.d.ts +79 -0
  39. package/dist/prompts.js +211 -0
  40. package/dist/prompts.js.map +1 -0
  41. package/dist/resolve.d.ts +72 -0
  42. package/dist/resolve.js +89 -0
  43. package/dist/resolve.js.map +1 -0
  44. package/dist/runtime.d.ts +54 -0
  45. package/dist/runtime.js +321 -0
  46. package/dist/runtime.js.map +1 -0
  47. package/dist/server.d.ts +56 -0
  48. package/dist/server.js +793 -0
  49. package/dist/server.js.map +1 -0
  50. package/dist/session-identifier.d.ts +48 -0
  51. package/dist/session-identifier.js +44 -0
  52. package/dist/session-identifier.js.map +1 -0
  53. package/dist/sessions-store.d.ts +38 -0
  54. package/dist/sessions-store.js +88 -0
  55. package/dist/sessions-store.js.map +1 -0
  56. package/dist/tmux.d.ts +200 -0
  57. package/dist/tmux.js +580 -0
  58. package/dist/tmux.js.map +1 -0
  59. package/hooks/metadata.mjs +99 -0
  60. package/hooks/permission-prompt.mjs +100 -0
  61. package/hooks/taskflow-hook.mjs +499 -0
  62. package/hooks/tool-logging.mjs +63 -0
  63. package/package.json +38 -29
  64. package/dist/agent-registry.d.ts +0 -28
  65. package/dist/agent-registry.js +0 -158
  66. package/dist/db.d.ts +0 -5
  67. package/dist/db.js +0 -220
  68. package/dist/helpers.d.ts +0 -21
  69. package/dist/helpers.js +0 -27
  70. package/dist/resources.d.ts +0 -2
  71. package/dist/resources.js +0 -89
  72. package/dist/retry.d.ts +0 -34
  73. package/dist/retry.js +0 -94
  74. package/dist/sse.d.ts +0 -10
  75. package/dist/sse.js +0 -824
  76. package/dist/tmux-bridge.d.ts +0 -13
  77. package/dist/tmux-bridge.js +0 -217
  78. package/dist/tools/activity.d.ts +0 -39
  79. package/dist/tools/activity.js +0 -152
  80. package/dist/tools/agent-inbox.d.ts +0 -12
  81. package/dist/tools/agent-inbox.js +0 -272
  82. package/dist/tools/agent.d.ts +0 -14
  83. package/dist/tools/agent.js +0 -168
  84. package/dist/tools/analytics.d.ts +0 -21
  85. package/dist/tools/analytics.js +0 -191
  86. package/dist/tools/checkpoint.d.ts +0 -27
  87. package/dist/tools/checkpoint.js +0 -105
  88. package/dist/tools/notifications.d.ts +0 -31
  89. package/dist/tools/notifications.js +0 -59
  90. package/dist/tools/projects.d.ts +0 -55
  91. package/dist/tools/projects.js +0 -112
  92. package/dist/tools/settings.d.ts +0 -19
  93. package/dist/tools/settings.js +0 -73
  94. package/dist/tools/tasks.d.ts +0 -105
  95. package/dist/tools/tasks.js +0 -403
  96. package/dist/tools/terminal.d.ts +0 -4
  97. package/dist/tools/terminal.js +0 -98
  98. package/dist/tools/timer.d.ts +0 -37
  99. package/dist/tools/timer.js +0 -154
  100. package/dist/types.d.ts +0 -83
  101. package/dist/types.js +0 -30
package/dist/resources.js DELETED
@@ -1,89 +0,0 @@
1
- import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { getDb } from './db.js';
3
- import { getAgentInstructions } from './tools/agent.js';
4
- export function registerResources(server) {
5
- // ─── Agent Instructions Resource ────────────────────────────────────
6
- // Auto-loaded by MCP clients on connection — ensures rules are always present
7
- server.resource('agent-instructions', 'taskflow://instructions', { description: 'TaskFlow agent onboarding instructions — rules, workflow, and live project context', mimeType: 'application/json' }, async (uri) => {
8
- const instructions = await getAgentInstructions();
9
- return {
10
- contents: [{
11
- uri: uri.href,
12
- text: JSON.stringify(instructions, null, 2),
13
- mimeType: 'application/json',
14
- }],
15
- };
16
- });
17
- // ─── Projects Resource ──────────────────────────────────────────────
18
- server.resource('projects', new ResourceTemplate('taskflow://projects/{id}', {
19
- list: async () => {
20
- const db = getDb();
21
- const projects = db.prepare('SELECT * FROM projects ORDER BY updated_at DESC').all();
22
- return {
23
- resources: projects.map(p => ({
24
- uri: `taskflow://projects/${p.id}`,
25
- name: p.name,
26
- description: p.description ?? undefined,
27
- mimeType: 'application/json',
28
- })),
29
- };
30
- },
31
- }), { description: 'TaskFlow projects', mimeType: 'application/json' }, async (uri, variables) => {
32
- const db = getDb();
33
- const id = Number(variables.id);
34
- const project = db.prepare('SELECT * FROM projects WHERE id = ?').get(id);
35
- if (!project) {
36
- return { contents: [{ uri: uri.href, text: JSON.stringify({ error: 'Project not found' }), mimeType: 'application/json' }] };
37
- }
38
- // Include task count and recent tasks
39
- const taskCount = db.prepare('SELECT COUNT(*) as count FROM tasks WHERE project_id = ?').get(id);
40
- const recentTasks = db.prepare('SELECT id, title, status, priority FROM tasks WHERE project_id = ? ORDER BY updated_at DESC LIMIT 10').all(id);
41
- return {
42
- contents: [{
43
- uri: uri.href,
44
- text: JSON.stringify({ ...project, task_count: taskCount.count, recent_tasks: recentTasks }, null, 2),
45
- mimeType: 'application/json',
46
- }],
47
- };
48
- });
49
- // ─── Tasks Resource ─────────────────────────────────────────────────
50
- server.resource('tasks', new ResourceTemplate('taskflow://tasks/{id}', {
51
- list: async () => {
52
- const db = getDb();
53
- // List active tasks (not done) for discoverability
54
- const tasks = db.prepare("SELECT * FROM tasks WHERE status != 'done' ORDER BY updated_at DESC LIMIT 50").all();
55
- return {
56
- resources: tasks.map(t => ({
57
- uri: `taskflow://tasks/${t.id}`,
58
- name: `[${t.status}] ${t.title}`,
59
- description: t.description?.slice(0, 100) ?? undefined,
60
- mimeType: 'application/json',
61
- })),
62
- };
63
- },
64
- }), { description: 'TaskFlow tasks', mimeType: 'application/json' }, async (uri, variables) => {
65
- const db = getDb();
66
- const id = Number(variables.id);
67
- const task = db.prepare('SELECT * FROM tasks WHERE id = ?').get(id);
68
- if (!task) {
69
- return { contents: [{ uri: uri.href, text: JSON.stringify({ error: 'Task not found' }), mimeType: 'application/json' }] };
70
- }
71
- // Include time tracking and dependencies
72
- const sessions = db.prepare('SELECT * FROM sessions WHERE task_id = ? ORDER BY start DESC LIMIT 5').all(id);
73
- const totalTime = db.prepare('SELECT SUM(CASE WHEN end IS NOT NULL THEN (julianday(end) - julianday(start)) * 86400000 ELSE 0 END) as total FROM sessions WHERE task_id = ?').get(id);
74
- const deps = db.prepare('SELECT dependency_id FROM task_dependencies WHERE task_id = ?').all(id);
75
- return {
76
- contents: [{
77
- uri: uri.href,
78
- text: JSON.stringify({
79
- ...task,
80
- tags: task.tags ? JSON.parse(task.tags) : [],
81
- total_time_ms: totalTime.total ?? 0,
82
- recent_sessions: sessions,
83
- dependencies: deps.map(d => d.dependency_id),
84
- }, null, 2),
85
- mimeType: 'application/json',
86
- }],
87
- };
88
- });
89
- }
package/dist/retry.d.ts DELETED
@@ -1,34 +0,0 @@
1
- /**
2
- * Retry policy engine for TaskFlow.
3
- * Provides exponential backoff with jitter for network/external calls.
4
- */
5
- export interface RetryPolicy {
6
- maxRetries: number;
7
- initialBackoffMs: number;
8
- maxBackoffMs: number;
9
- }
10
- export declare const DEFAULT_RETRY_POLICY: RetryPolicy;
11
- /** Thrown when an HTTP response has a retryable status code */
12
- export declare class RetryableHttpError extends Error {
13
- readonly status: number;
14
- constructor(status: number, message: string);
15
- }
16
- /** Thrown when all retry attempts are exhausted */
17
- export declare class RetriesExhaustedError extends Error {
18
- readonly attempts: number;
19
- readonly lastError: unknown;
20
- constructor(attempts: number, lastError: unknown);
21
- }
22
- /**
23
- * Execute `fn` with automatic retry on transient errors.
24
- *
25
- * @param label Short description for activity log entries (e.g. "relay push")
26
- * @param fn Async function to execute. Should throw RetryableHttpError for bad HTTP responses.
27
- * @param policy Retry configuration (defaults to DEFAULT_RETRY_POLICY)
28
- */
29
- export declare function withRetry<T>(label: string, fn: () => Promise<T>, policy?: RetryPolicy): Promise<T>;
30
- /**
31
- * Wrapper around fetch() that throws RetryableHttpError for transient HTTP failures.
32
- * Drop-in for fetch() calls that should participate in retry logic.
33
- */
34
- export declare function fetchWithRetry(label: string, url: string, options?: RequestInit, policy?: RetryPolicy): Promise<Response>;
package/dist/retry.js DELETED
@@ -1,94 +0,0 @@
1
- /**
2
- * Retry policy engine for TaskFlow.
3
- * Provides exponential backoff with jitter for network/external calls.
4
- */
5
- import { logActivity } from './helpers.js';
6
- export const DEFAULT_RETRY_POLICY = {
7
- maxRetries: 2,
8
- initialBackoffMs: 200,
9
- maxBackoffMs: 2000,
10
- };
11
- /** HTTP status codes considered transient and safe to retry */
12
- const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504]);
13
- /** Classify whether an error is worth retrying */
14
- function isRetryable(err) {
15
- if (err instanceof RetriesExhaustedError)
16
- return false;
17
- if (err instanceof TypeError)
18
- return true; // network failure, DNS, ECONNREFUSED
19
- if (err instanceof RetryableHttpError)
20
- return true;
21
- return false;
22
- }
23
- /** Thrown when an HTTP response has a retryable status code */
24
- export class RetryableHttpError extends Error {
25
- status;
26
- constructor(status, message) {
27
- super(message);
28
- this.status = status;
29
- this.name = 'RetryableHttpError';
30
- }
31
- }
32
- /** Thrown when all retry attempts are exhausted */
33
- export class RetriesExhaustedError extends Error {
34
- attempts;
35
- lastError;
36
- constructor(attempts, lastError) {
37
- const cause = lastError instanceof Error ? lastError.message : String(lastError);
38
- super(`Retries exhausted after ${attempts} attempt(s): ${cause}`);
39
- this.attempts = attempts;
40
- this.lastError = lastError;
41
- this.name = 'RetriesExhaustedError';
42
- }
43
- }
44
- /**
45
- * Compute the next backoff delay with full jitter.
46
- * delay = min(initial * 2^attempt, max) * random(0.5, 1.0)
47
- */
48
- function backoffMs(policy, attempt) {
49
- const base = Math.min(policy.initialBackoffMs * Math.pow(2, attempt), policy.maxBackoffMs);
50
- return Math.floor(base * (0.5 + Math.random() * 0.5));
51
- }
52
- function sleep(ms) {
53
- return new Promise((resolve) => setTimeout(resolve, ms));
54
- }
55
- /**
56
- * Execute `fn` with automatic retry on transient errors.
57
- *
58
- * @param label Short description for activity log entries (e.g. "relay push")
59
- * @param fn Async function to execute. Should throw RetryableHttpError for bad HTTP responses.
60
- * @param policy Retry configuration (defaults to DEFAULT_RETRY_POLICY)
61
- */
62
- export async function withRetry(label, fn, policy = DEFAULT_RETRY_POLICY) {
63
- let lastError;
64
- for (let attempt = 0; attempt <= policy.maxRetries; attempt++) {
65
- try {
66
- return await fn();
67
- }
68
- catch (err) {
69
- lastError = err;
70
- if (!isRetryable(err) || attempt === policy.maxRetries) {
71
- break;
72
- }
73
- const delay = backoffMs(policy, attempt);
74
- logActivity('debug_log', `[retry] ${label} — attempt ${attempt + 1} failed, retrying in ${delay}ms`, {
75
- entityType: 'system',
76
- });
77
- await sleep(delay);
78
- }
79
- }
80
- throw new RetriesExhaustedError(policy.maxRetries + 1, lastError);
81
- }
82
- /**
83
- * Wrapper around fetch() that throws RetryableHttpError for transient HTTP failures.
84
- * Drop-in for fetch() calls that should participate in retry logic.
85
- */
86
- export async function fetchWithRetry(label, url, options, policy) {
87
- return withRetry(label, async () => {
88
- const res = await fetch(url, options);
89
- if (RETRYABLE_STATUS_CODES.has(res.status)) {
90
- throw new RetryableHttpError(res.status, `${label}: HTTP ${res.status}`);
91
- }
92
- return res;
93
- }, policy);
94
- }
package/dist/sse.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export declare function startSSEServer(): Promise<void>;
2
- export declare function markSSEActive(): void;
3
- /**
4
- * Broadcast an SSE event. If this process owns the SSE server, send directly.
5
- * Otherwise, relay via HTTP to the process that does.
6
- * Also pushes to the remote relay server if configured.
7
- */
8
- export declare function broadcast(event: string, data: object): void;
9
- /** Returns the port the SSE server is actively using */
10
- export declare function getActivePort(): number;