@vibe-forge/mcp 0.11.0 → 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/AGENTS.md +2 -1
- package/__tests__/sync.spec.ts +23 -0
- package/__tests__/task-manager.spec.ts +319 -1
- package/__tests__/task-tool.spec.ts +130 -0
- package/package.json +8 -8
- package/src/command.ts +2 -1
- package/src/sync.ts +7 -1
- package/src/tools/task/index.ts +22 -78
- package/src/tools/task/manager.ts +493 -69
- package/src/tools/task/permission-recovery.ts +172 -0
- package/src/tools/task/permission-state.ts +200 -0
- package/src/tools/task/presentation.ts +95 -0
- package/src/tools/task/register-task-runtime-tools.ts +145 -0
package/src/tools/task/index.ts
CHANGED
|
@@ -8,6 +8,15 @@ import { createChildSession, getParentSessionId } from '#~/sync.js'
|
|
|
8
8
|
import type { McpManagedTaskInput } from '../../types'
|
|
9
9
|
import { defineRegister } from '../types'
|
|
10
10
|
import { TaskManager } from './manager'
|
|
11
|
+
import {
|
|
12
|
+
SESSION_PERMISSION_MODES,
|
|
13
|
+
START_TASKS_DESCRIPTION,
|
|
14
|
+
TASK_BACKGROUND_DESCRIPTION,
|
|
15
|
+
TASK_PERMISSION_MODE_DESCRIPTION,
|
|
16
|
+
resolveInheritedPermissionMode,
|
|
17
|
+
serializeTaskInfo
|
|
18
|
+
} from './presentation'
|
|
19
|
+
import { registerTaskRuntimeTools } from './register-task-runtime-tools'
|
|
11
20
|
|
|
12
21
|
export const createTaskRegister = () => {
|
|
13
22
|
const taskManager = new TaskManager()
|
|
@@ -17,7 +26,7 @@ export const createTaskRegister = () => {
|
|
|
17
26
|
'StartTasks',
|
|
18
27
|
{
|
|
19
28
|
title: 'Start Tasks',
|
|
20
|
-
description:
|
|
29
|
+
description: START_TASKS_DESCRIPTION,
|
|
21
30
|
inputSchema: z.object({
|
|
22
31
|
tasks: z
|
|
23
32
|
.array(
|
|
@@ -41,14 +50,12 @@ export const createTaskRegister = () => {
|
|
|
41
50
|
.describe('The adapter to use for the task (e.g. claude-code)')
|
|
42
51
|
.optional(),
|
|
43
52
|
permissionMode: z
|
|
44
|
-
.enum(
|
|
45
|
-
.describe(
|
|
53
|
+
.enum(SESSION_PERMISSION_MODES)
|
|
54
|
+
.describe(TASK_PERMISSION_MODE_DESCRIPTION)
|
|
46
55
|
.optional(),
|
|
47
56
|
background: z
|
|
48
57
|
.boolean()
|
|
49
|
-
.describe(
|
|
50
|
-
'Whether to run in background (default: true). If false, waits for completion and returns logs.'
|
|
51
|
-
)
|
|
58
|
+
.describe(TASK_BACKGROUND_DESCRIPTION)
|
|
52
59
|
.optional()
|
|
53
60
|
})
|
|
54
61
|
)
|
|
@@ -56,11 +63,13 @@ export const createTaskRegister = () => {
|
|
|
56
63
|
})
|
|
57
64
|
},
|
|
58
65
|
async ({ tasks }) => {
|
|
66
|
+
const inheritedPermissionMode = resolveInheritedPermissionMode()
|
|
59
67
|
const resolvedTasks = tasks.map((task): McpManagedTaskInput & {
|
|
60
68
|
taskId: string
|
|
61
69
|
type: NonNullable<McpManagedTaskInput['type']>
|
|
62
70
|
} => ({
|
|
63
71
|
...task,
|
|
72
|
+
permissionMode: task.permissionMode ?? inheritedPermissionMode,
|
|
64
73
|
type: task.type ?? 'default',
|
|
65
74
|
taskId: uuid()
|
|
66
75
|
}))
|
|
@@ -76,7 +85,8 @@ export const createTaskRegister = () => {
|
|
|
76
85
|
createChildSession({
|
|
77
86
|
id: task.taskId,
|
|
78
87
|
title: task.name ?? task.description,
|
|
79
|
-
parentSessionId
|
|
88
|
+
parentSessionId,
|
|
89
|
+
permissionMode: task.permissionMode
|
|
80
90
|
})
|
|
81
91
|
))
|
|
82
92
|
: []
|
|
@@ -93,84 +103,18 @@ export const createTaskRegister = () => {
|
|
|
93
103
|
type: 'text',
|
|
94
104
|
text: JSON.stringify(results.map((r, idx) => {
|
|
95
105
|
const { taskId, description } = resolvedTasks[idx]
|
|
96
|
-
|
|
97
|
-
const { session, onStop, serverSync, createdAt, ...safeInfo } = info ?? {}
|
|
98
|
-
return {
|
|
106
|
+
return serializeTaskInfo({
|
|
99
107
|
taskId,
|
|
100
108
|
description,
|
|
101
|
-
status:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
109
|
+
status: r.status === 'rejected' ? 'failed' : 'running',
|
|
110
|
+
info: taskManager.getTask(taskId)
|
|
111
|
+
})
|
|
105
112
|
}))
|
|
106
113
|
}]
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
)
|
|
110
117
|
|
|
111
|
-
server
|
|
112
|
-
'GetTaskInfo',
|
|
113
|
-
{
|
|
114
|
-
title: 'Get Task Info',
|
|
115
|
-
description: 'Get the status and logs of a specific task',
|
|
116
|
-
inputSchema: z.object({
|
|
117
|
-
taskId: z.string().describe('The ID of the task to check')
|
|
118
|
-
})
|
|
119
|
-
},
|
|
120
|
-
async ({ taskId }) => {
|
|
121
|
-
const task = taskManager.getTask(taskId)
|
|
122
|
-
if (!task) {
|
|
123
|
-
return {
|
|
124
|
-
content: [{ type: 'text', text: `Task ${taskId} not found.` }],
|
|
125
|
-
isError: true
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const { session, onStop, serverSync, createdAt, ...safeTask } = task
|
|
129
|
-
return {
|
|
130
|
-
content: [{
|
|
131
|
-
type: 'text',
|
|
132
|
-
text: JSON.stringify([safeTask])
|
|
133
|
-
}]
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
server.registerTool(
|
|
139
|
-
'StopTask',
|
|
140
|
-
{
|
|
141
|
-
title: 'Stop Task',
|
|
142
|
-
description: 'Stop a running task',
|
|
143
|
-
inputSchema: z.object({
|
|
144
|
-
taskId: z.string().describe('The ID of the task to stop')
|
|
145
|
-
})
|
|
146
|
-
},
|
|
147
|
-
async ({ taskId }) => {
|
|
148
|
-
const success = taskManager.stopTask(taskId)
|
|
149
|
-
return {
|
|
150
|
-
content: [{
|
|
151
|
-
type: 'text',
|
|
152
|
-
text: success ? `Task ${taskId} stopped.` : `Failed to stop task ${taskId} (not found or already stopped).`
|
|
153
|
-
}]
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
server.registerTool(
|
|
159
|
-
'ListTasks',
|
|
160
|
-
{
|
|
161
|
-
title: 'List Tasks',
|
|
162
|
-
description: 'List all managed tasks',
|
|
163
|
-
inputSchema: z.object({})
|
|
164
|
-
},
|
|
165
|
-
async () => {
|
|
166
|
-
const tasks = taskManager.getAllTasks()
|
|
167
|
-
return {
|
|
168
|
-
content: [{
|
|
169
|
-
type: 'text',
|
|
170
|
-
text: JSON.stringify(tasks.map(({ session, onStop, serverSync, createdAt, ...task }) => task))
|
|
171
|
-
}]
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
)
|
|
118
|
+
registerTaskRuntimeTools(server, taskManager)
|
|
175
119
|
})
|
|
176
120
|
}
|