@sudocode-ai/local-server 0.1.10 → 0.1.12
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/dist/execution/executors/agent-executor-wrapper.d.ts.map +1 -1
- package/dist/execution/executors/agent-executor-wrapper.js +57 -2
- package/dist/execution/executors/agent-executor-wrapper.js.map +1 -1
- package/dist/execution/process/builders/claude.d.ts.map +1 -1
- package/dist/execution/process/builders/claude.js +32 -1
- package/dist/execution/process/builders/claude.js.map +1 -1
- package/dist/execution/worktree/git-cli.d.ts +48 -0
- package/dist/execution/worktree/git-cli.d.ts.map +1 -1
- package/dist/execution/worktree/git-cli.js +81 -0
- package/dist/execution/worktree/git-cli.js.map +1 -1
- package/dist/execution/worktree/git-sync-cli.d.ts +28 -1
- package/dist/execution/worktree/git-sync-cli.d.ts.map +1 -1
- package/dist/execution/worktree/git-sync-cli.js +65 -2
- package/dist/execution/worktree/git-sync-cli.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/public/assets/index-CLIkhhGD.js +824 -0
- package/dist/public/assets/index-CLIkhhGD.js.map +1 -0
- package/dist/public/assets/index-p0337DGd.css +1 -0
- package/dist/public/assets/{react-vendor-DiL5hC7l.js → react-vendor-5f1Wq1qs.js} +5 -5
- package/dist/public/assets/{react-vendor-DiL5hC7l.js.map → react-vendor-5f1Wq1qs.js.map} +1 -1
- package/dist/public/assets/{ui-vendor-B4WMPEfa.js → ui-vendor-BDDPoYki.js} +2 -2
- package/dist/public/assets/{ui-vendor-B4WMPEfa.js.map → ui-vendor-BDDPoYki.js.map} +1 -1
- package/dist/public/index.html +4 -4
- package/dist/routes/workflows.d.ts +8 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +1729 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/services/execution-event-callbacks.d.ts +73 -0
- package/dist/services/execution-event-callbacks.d.ts.map +1 -0
- package/dist/services/execution-event-callbacks.js +82 -0
- package/dist/services/execution-event-callbacks.js.map +1 -0
- package/dist/services/execution-lifecycle.d.ts +36 -0
- package/dist/services/execution-lifecycle.d.ts.map +1 -1
- package/dist/services/execution-lifecycle.js +87 -0
- package/dist/services/execution-lifecycle.js.map +1 -1
- package/dist/services/execution-service.d.ts +31 -3
- package/dist/services/execution-service.d.ts.map +1 -1
- package/dist/services/execution-service.js +161 -34
- package/dist/services/execution-service.js.map +1 -1
- package/dist/services/executions.d.ts +1 -0
- package/dist/services/executions.d.ts.map +1 -1
- package/dist/services/executions.js +4 -0
- package/dist/services/executions.js.map +1 -1
- package/dist/services/project-context.d.ts +25 -0
- package/dist/services/project-context.d.ts.map +1 -1
- package/dist/services/project-context.js +53 -3
- package/dist/services/project-context.js.map +1 -1
- package/dist/services/project-manager.d.ts +7 -0
- package/dist/services/project-manager.d.ts.map +1 -1
- package/dist/services/project-manager.js +90 -1
- package/dist/services/project-manager.js.map +1 -1
- package/dist/services/websocket.d.ts +10 -2
- package/dist/services/websocket.d.ts.map +1 -1
- package/dist/services/websocket.js +18 -0
- package/dist/services/websocket.js.map +1 -1
- package/dist/services/workflow-broadcast-service.d.ts +43 -0
- package/dist/services/workflow-broadcast-service.d.ts.map +1 -0
- package/dist/services/workflow-broadcast-service.js +155 -0
- package/dist/services/workflow-broadcast-service.js.map +1 -0
- package/dist/services/worktree-sync-service.d.ts +40 -1
- package/dist/services/worktree-sync-service.d.ts.map +1 -1
- package/dist/services/worktree-sync-service.js +189 -16
- package/dist/services/worktree-sync-service.js.map +1 -1
- package/dist/workflow/base-workflow-engine.d.ts +186 -0
- package/dist/workflow/base-workflow-engine.d.ts.map +1 -0
- package/dist/workflow/base-workflow-engine.js +549 -0
- package/dist/workflow/base-workflow-engine.js.map +1 -0
- package/dist/workflow/dependency-analyzer.d.ts +78 -0
- package/dist/workflow/dependency-analyzer.d.ts.map +1 -0
- package/dist/workflow/dependency-analyzer.js +264 -0
- package/dist/workflow/dependency-analyzer.js.map +1 -0
- package/dist/workflow/engines/orchestrator-engine.d.ts +237 -0
- package/dist/workflow/engines/orchestrator-engine.d.ts.map +1 -0
- package/dist/workflow/engines/orchestrator-engine.js +749 -0
- package/dist/workflow/engines/orchestrator-engine.js.map +1 -0
- package/dist/workflow/engines/sequential-engine.d.ts +276 -0
- package/dist/workflow/engines/sequential-engine.d.ts.map +1 -0
- package/dist/workflow/engines/sequential-engine.js +1110 -0
- package/dist/workflow/engines/sequential-engine.js.map +1 -0
- package/dist/workflow/index.d.ts +15 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +22 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/mcp/api-client.d.ts +103 -0
- package/dist/workflow/mcp/api-client.d.ts.map +1 -0
- package/dist/workflow/mcp/api-client.js +193 -0
- package/dist/workflow/mcp/api-client.js.map +1 -0
- package/dist/workflow/mcp/index.d.ts +16 -0
- package/dist/workflow/mcp/index.d.ts.map +1 -0
- package/dist/workflow/mcp/index.js +114 -0
- package/dist/workflow/mcp/index.js.map +1 -0
- package/dist/workflow/mcp/server.d.ts +85 -0
- package/dist/workflow/mcp/server.d.ts.map +1 -0
- package/dist/workflow/mcp/server.js +520 -0
- package/dist/workflow/mcp/server.js.map +1 -0
- package/dist/workflow/mcp/tools/escalation.d.ts +36 -0
- package/dist/workflow/mcp/tools/escalation.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/escalation.js +47 -0
- package/dist/workflow/mcp/tools/escalation.js.map +1 -0
- package/dist/workflow/mcp/tools/execution.d.ts +59 -0
- package/dist/workflow/mcp/tools/execution.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/execution.js +67 -0
- package/dist/workflow/mcp/tools/execution.js.map +1 -0
- package/dist/workflow/mcp/tools/inspection.d.ts +82 -0
- package/dist/workflow/mcp/tools/inspection.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/inspection.js +57 -0
- package/dist/workflow/mcp/tools/inspection.js.map +1 -0
- package/dist/workflow/mcp/tools/workflow.d.ts +59 -0
- package/dist/workflow/mcp/tools/workflow.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/workflow.js +40 -0
- package/dist/workflow/mcp/tools/workflow.js.map +1 -0
- package/dist/workflow/mcp/types.d.ts +345 -0
- package/dist/workflow/mcp/types.d.ts.map +1 -0
- package/dist/workflow/mcp/types.js +7 -0
- package/dist/workflow/mcp/types.js.map +1 -0
- package/dist/workflow/services/prompt-builder.d.ts +36 -0
- package/dist/workflow/services/prompt-builder.d.ts.map +1 -0
- package/dist/workflow/services/prompt-builder.js +329 -0
- package/dist/workflow/services/prompt-builder.js.map +1 -0
- package/dist/workflow/services/wakeup-service.d.ts +262 -0
- package/dist/workflow/services/wakeup-service.d.ts.map +1 -0
- package/dist/workflow/services/wakeup-service.js +809 -0
- package/dist/workflow/services/wakeup-service.js.map +1 -0
- package/dist/workflow/workflow-engine.d.ts +221 -0
- package/dist/workflow/workflow-engine.d.ts.map +1 -0
- package/dist/workflow/workflow-engine.js +94 -0
- package/dist/workflow/workflow-engine.js.map +1 -0
- package/dist/workflow/workflow-event-emitter.d.ts +278 -0
- package/dist/workflow/workflow-event-emitter.d.ts.map +1 -0
- package/dist/workflow/workflow-event-emitter.js +259 -0
- package/dist/workflow/workflow-event-emitter.js.map +1 -0
- package/package.json +8 -6
- package/dist/public/assets/index-CQoCSnhl.css +0 -1
- package/dist/public/assets/index-iWE3gSYw.js +0 -758
- package/dist/public/assets/index-iWE3gSYw.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/workflow/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EACV,kBAAkB,EAYnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAyBpD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B;AAiSD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,SAAS,CAAqC;gBAE1C,OAAO,EAAE,wBAAwB;IAqC7C;;OAEG;IACH,OAAO,CAAC,aAAa;IAiDrB;;OAEG;YACW,cAAc;YAiDd,oBAAoB;YAIpB,sBAAsB;YAUtB,kBAAkB;YAiBlB,qBAAqB;YASrB,qBAAqB;YAUrB,yBAAyB;YAUzB,sBAAsB;YAUtB,oBAAoB;YAWpB,gBAAgB;YAUhB,iBAAiB;YAYjB,iBAAiB;IAoB/B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B;;OAEG;IACH,UAAU,IAAI,kBAAkB;CAGjC"}
|
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow MCP Server
|
|
3
|
+
*
|
|
4
|
+
* MCP server that provides workflow control tools to the orchestrator agent.
|
|
5
|
+
* Spawned as a subprocess with workflow-id, server-url, project-id, and repo-path arguments.
|
|
6
|
+
* All communication with the main server goes through the HTTP API client.
|
|
7
|
+
*/
|
|
8
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
10
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
11
|
+
import { WorkflowAPIClient } from "./api-client.js";
|
|
12
|
+
// Tool implementations
|
|
13
|
+
import { handleWorkflowStatus, handleWorkflowComplete, } from "./tools/workflow.js";
|
|
14
|
+
import { handleExecuteIssue, handleExecutionStatus, handleExecutionCancel, } from "./tools/execution.js";
|
|
15
|
+
import { handleExecutionTrajectory, handleExecutionChanges, } from "./tools/inspection.js";
|
|
16
|
+
import { handleEscalateToUser, handleNotifyUser, } from "./tools/escalation.js";
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// Tool Definitions
|
|
19
|
+
// =============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* All available workflow MCP tools.
|
|
22
|
+
* Tool handlers are implemented in ./tools/*.ts
|
|
23
|
+
*/
|
|
24
|
+
const TOOL_DEFINITIONS = [
|
|
25
|
+
// Workflow control tools
|
|
26
|
+
{
|
|
27
|
+
name: "workflow_status",
|
|
28
|
+
description: "Get current workflow state including steps, active executions, and ready issues. " +
|
|
29
|
+
"Use this to understand what work is pending, in progress, or completed.",
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: {},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "workflow_complete",
|
|
37
|
+
description: "Mark workflow as complete or failed with a summary. " +
|
|
38
|
+
"Call this when all work is done or if the workflow cannot continue.",
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
summary: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description: "Summary of work completed or reason for failure",
|
|
45
|
+
},
|
|
46
|
+
status: {
|
|
47
|
+
type: "string",
|
|
48
|
+
enum: ["completed", "failed"],
|
|
49
|
+
description: "Final status (default: completed)",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ["summary"],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
// Execution tools
|
|
56
|
+
{
|
|
57
|
+
name: "execute_issue",
|
|
58
|
+
description: "Start an execution for an issue. Returns immediately with execution ID. " +
|
|
59
|
+
"Use execution_status to check progress.",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
issue_id: {
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "Issue ID to execute (e.g., i-abc123)",
|
|
66
|
+
},
|
|
67
|
+
agent_type: {
|
|
68
|
+
type: "string",
|
|
69
|
+
enum: ["claude-code", "codex", "copilot", "cursor"],
|
|
70
|
+
description: "Agent type to use (default: from workflow config)",
|
|
71
|
+
},
|
|
72
|
+
model: {
|
|
73
|
+
type: "string",
|
|
74
|
+
description: "Model override for the agent",
|
|
75
|
+
},
|
|
76
|
+
worktree_mode: {
|
|
77
|
+
type: "string",
|
|
78
|
+
enum: ["create_root", "use_root", "create_branch", "use_branch"],
|
|
79
|
+
description: "Worktree strategy: create_root (new workflow worktree), " +
|
|
80
|
+
"use_root (reuse workflow worktree), create_branch (parallel branch), " +
|
|
81
|
+
"use_branch (continue on existing branch)",
|
|
82
|
+
},
|
|
83
|
+
worktree_id: {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "Execution ID to reuse worktree from (required for use_root/use_branch)",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
required: ["issue_id", "worktree_mode"],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "execution_status",
|
|
93
|
+
description: "Get status of an execution including exit code, summary, and files changed.",
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: "object",
|
|
96
|
+
properties: {
|
|
97
|
+
execution_id: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "Execution ID to check",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
required: ["execution_id"],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "execution_cancel",
|
|
107
|
+
description: "Cancel a running execution.",
|
|
108
|
+
inputSchema: {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: {
|
|
111
|
+
execution_id: {
|
|
112
|
+
type: "string",
|
|
113
|
+
description: "Execution ID to cancel",
|
|
114
|
+
},
|
|
115
|
+
reason: {
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "Reason for cancellation",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ["execution_id"],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
// Inspection tools
|
|
124
|
+
{
|
|
125
|
+
name: "execution_trajectory",
|
|
126
|
+
description: "Get agent actions and tool calls from an execution. " +
|
|
127
|
+
"Useful for understanding what the agent did and debugging issues.",
|
|
128
|
+
inputSchema: {
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: {
|
|
131
|
+
execution_id: {
|
|
132
|
+
type: "string",
|
|
133
|
+
description: "Execution ID to inspect",
|
|
134
|
+
},
|
|
135
|
+
max_entries: {
|
|
136
|
+
type: "number",
|
|
137
|
+
description: "Maximum entries to return (default: 50)",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
required: ["execution_id"],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "execution_changes",
|
|
145
|
+
description: "Get code changes made by an execution including files modified and commits.",
|
|
146
|
+
inputSchema: {
|
|
147
|
+
type: "object",
|
|
148
|
+
properties: {
|
|
149
|
+
execution_id: {
|
|
150
|
+
type: "string",
|
|
151
|
+
description: "Execution ID to get changes for",
|
|
152
|
+
},
|
|
153
|
+
include_diff: {
|
|
154
|
+
type: "boolean",
|
|
155
|
+
description: "Include full diff content (default: false)",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
required: ["execution_id"],
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
// Escalation tools (Human-in-the-Loop)
|
|
162
|
+
{
|
|
163
|
+
name: "escalate_to_user",
|
|
164
|
+
description: "Request user input for a decision. Returns immediately with 'pending' status. " +
|
|
165
|
+
"Your session ends here - when the user responds, you'll receive a follow-up message. " +
|
|
166
|
+
"In full_auto mode, returns 'auto_approved' immediately without user interaction.",
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: {
|
|
170
|
+
message: {
|
|
171
|
+
type: "string",
|
|
172
|
+
description: "Message explaining what input is needed from the user",
|
|
173
|
+
},
|
|
174
|
+
options: {
|
|
175
|
+
type: "array",
|
|
176
|
+
items: { type: "string" },
|
|
177
|
+
description: "Optional predefined options for user to choose from",
|
|
178
|
+
},
|
|
179
|
+
context: {
|
|
180
|
+
type: "object",
|
|
181
|
+
description: "Additional context to include in the escalation (passed back in response)",
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
required: ["message"],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "notify_user",
|
|
189
|
+
description: "Send a non-blocking notification to the user. Does not wait for response. " +
|
|
190
|
+
"Use for progress updates and informational messages.",
|
|
191
|
+
inputSchema: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
message: {
|
|
195
|
+
type: "string",
|
|
196
|
+
description: "Notification message",
|
|
197
|
+
},
|
|
198
|
+
level: {
|
|
199
|
+
type: "string",
|
|
200
|
+
enum: ["info", "warning", "error"],
|
|
201
|
+
description: "Notification level (default: info)",
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
required: ["message"],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
// Git operations
|
|
208
|
+
{
|
|
209
|
+
name: "merge_branch",
|
|
210
|
+
description: "Merge a branch into the workflow's worktree. Use this to merge parallel execution branches " +
|
|
211
|
+
"back into the main workflow branch. Returns merge result with commit SHA or conflict info.",
|
|
212
|
+
inputSchema: {
|
|
213
|
+
type: "object",
|
|
214
|
+
properties: {
|
|
215
|
+
source_branch: {
|
|
216
|
+
type: "string",
|
|
217
|
+
description: "Branch name to merge from",
|
|
218
|
+
},
|
|
219
|
+
target_branch: {
|
|
220
|
+
type: "string",
|
|
221
|
+
description: "Branch to merge into (default: current workflow branch)",
|
|
222
|
+
},
|
|
223
|
+
strategy: {
|
|
224
|
+
type: "string",
|
|
225
|
+
enum: ["auto", "squash"],
|
|
226
|
+
description: "Merge strategy: auto (fast-forward if possible, else merge) or squash",
|
|
227
|
+
},
|
|
228
|
+
message: {
|
|
229
|
+
type: "string",
|
|
230
|
+
description: "Custom commit message for the merge",
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
required: ["source_branch"],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
// Pause and await tools
|
|
237
|
+
{
|
|
238
|
+
name: "await_events",
|
|
239
|
+
description: "Pause execution and wait for specific events. Your session will end here. " +
|
|
240
|
+
"When any of the specified events occur, you'll receive a follow-up with the event data. " +
|
|
241
|
+
"Use this instead of polling execution_status in a loop.",
|
|
242
|
+
inputSchema: {
|
|
243
|
+
type: "object",
|
|
244
|
+
properties: {
|
|
245
|
+
event_types: {
|
|
246
|
+
type: "array",
|
|
247
|
+
items: {
|
|
248
|
+
type: "string",
|
|
249
|
+
enum: [
|
|
250
|
+
"step_completed",
|
|
251
|
+
"step_failed",
|
|
252
|
+
"user_response",
|
|
253
|
+
"escalation_resolved",
|
|
254
|
+
"timeout",
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
description: "Event types to wait for. Wakeup triggers when ANY event occurs.",
|
|
258
|
+
},
|
|
259
|
+
execution_ids: {
|
|
260
|
+
type: "array",
|
|
261
|
+
items: { type: "string" },
|
|
262
|
+
description: "Optional: Only wake for events from these execution IDs",
|
|
263
|
+
},
|
|
264
|
+
timeout_seconds: {
|
|
265
|
+
type: "number",
|
|
266
|
+
description: "Optional: Maximum seconds to wait before auto-wakeup with timeout event",
|
|
267
|
+
},
|
|
268
|
+
message: {
|
|
269
|
+
type: "string",
|
|
270
|
+
description: "Optional: Message to show in UI while waiting",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
required: ["event_types"],
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
];
|
|
277
|
+
// =============================================================================
|
|
278
|
+
// WorkflowMCPServer
|
|
279
|
+
// =============================================================================
|
|
280
|
+
/**
|
|
281
|
+
* MCP server for workflow orchestration.
|
|
282
|
+
*
|
|
283
|
+
* Provides tools for the orchestrator agent to:
|
|
284
|
+
* - Check workflow status
|
|
285
|
+
* - Execute issues
|
|
286
|
+
* - Monitor execution progress
|
|
287
|
+
* - Inspect execution results
|
|
288
|
+
* - Complete the workflow
|
|
289
|
+
*
|
|
290
|
+
* All communication with the main server goes through the HTTP API client.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const server = new WorkflowMCPServer({
|
|
295
|
+
* workflowId: "wf-abc123",
|
|
296
|
+
* serverUrl: "http://localhost:3000",
|
|
297
|
+
* projectId: "proj-123",
|
|
298
|
+
* repoPath: "/path/to/repo",
|
|
299
|
+
* });
|
|
300
|
+
* await server.start();
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
export class WorkflowMCPServer {
|
|
304
|
+
server;
|
|
305
|
+
context;
|
|
306
|
+
transport = null;
|
|
307
|
+
constructor(options) {
|
|
308
|
+
// Create API client (use provided one for testing, otherwise create new)
|
|
309
|
+
const apiClient = options.apiClient ||
|
|
310
|
+
new WorkflowAPIClient({
|
|
311
|
+
serverUrl: options.serverUrl,
|
|
312
|
+
projectId: options.projectId,
|
|
313
|
+
workflowId: options.workflowId,
|
|
314
|
+
});
|
|
315
|
+
console.error(`[WorkflowMCPServer] Using API client: ${options.serverUrl}`);
|
|
316
|
+
// Build context for tool handlers
|
|
317
|
+
this.context = {
|
|
318
|
+
workflowId: options.workflowId,
|
|
319
|
+
apiClient,
|
|
320
|
+
repoPath: options.repoPath,
|
|
321
|
+
};
|
|
322
|
+
// Create MCP server
|
|
323
|
+
this.server = new Server({
|
|
324
|
+
name: "sudocode-workflow",
|
|
325
|
+
version: "0.1.0",
|
|
326
|
+
}, {
|
|
327
|
+
capabilities: {
|
|
328
|
+
tools: {},
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
this.setupHandlers();
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Set up MCP request handlers.
|
|
335
|
+
*/
|
|
336
|
+
setupHandlers() {
|
|
337
|
+
// List available tools
|
|
338
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
339
|
+
return {
|
|
340
|
+
tools: TOOL_DEFINITIONS,
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
// Handle tool calls
|
|
344
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
345
|
+
const { name, arguments: args } = request.params;
|
|
346
|
+
try {
|
|
347
|
+
const result = await this.handleToolCall(name, args || {});
|
|
348
|
+
return {
|
|
349
|
+
content: [
|
|
350
|
+
{
|
|
351
|
+
type: "text",
|
|
352
|
+
text: JSON.stringify(result, null, 2),
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
359
|
+
return {
|
|
360
|
+
content: [
|
|
361
|
+
{
|
|
362
|
+
type: "text",
|
|
363
|
+
text: JSON.stringify({
|
|
364
|
+
success: false,
|
|
365
|
+
error: message,
|
|
366
|
+
}, null, 2),
|
|
367
|
+
},
|
|
368
|
+
],
|
|
369
|
+
isError: true,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Handle a tool call by dispatching to the appropriate handler.
|
|
376
|
+
*/
|
|
377
|
+
async handleToolCall(name, args) {
|
|
378
|
+
// Tool handlers will be implemented in subsequent issues
|
|
379
|
+
// For now, return a placeholder response
|
|
380
|
+
switch (name) {
|
|
381
|
+
case "workflow_status":
|
|
382
|
+
return this.handleWorkflowStatus();
|
|
383
|
+
case "workflow_complete":
|
|
384
|
+
return this.handleWorkflowComplete(args);
|
|
385
|
+
case "execute_issue":
|
|
386
|
+
return this.handleExecuteIssue(args);
|
|
387
|
+
case "execution_status":
|
|
388
|
+
return this.handleExecutionStatus(args);
|
|
389
|
+
case "execution_cancel":
|
|
390
|
+
return this.handleExecutionCancel(args);
|
|
391
|
+
case "execution_trajectory":
|
|
392
|
+
return this.handleExecutionTrajectory(args);
|
|
393
|
+
case "execution_changes":
|
|
394
|
+
return this.handleExecutionChanges(args);
|
|
395
|
+
case "escalate_to_user":
|
|
396
|
+
return this.handleEscalateToUser(args);
|
|
397
|
+
case "notify_user":
|
|
398
|
+
return this.handleNotifyUser(args);
|
|
399
|
+
case "merge_branch":
|
|
400
|
+
return this.handleMergeBranch(args);
|
|
401
|
+
case "await_events":
|
|
402
|
+
return this.handleAwaitEvents(args);
|
|
403
|
+
default:
|
|
404
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
// ===========================================================================
|
|
408
|
+
// Tool Handler Stubs (to be implemented in tools/*.ts)
|
|
409
|
+
// ===========================================================================
|
|
410
|
+
async handleWorkflowStatus() {
|
|
411
|
+
return handleWorkflowStatus(this.context);
|
|
412
|
+
}
|
|
413
|
+
async handleWorkflowComplete(args) {
|
|
414
|
+
const params = {
|
|
415
|
+
summary: args.summary,
|
|
416
|
+
status: args.status,
|
|
417
|
+
};
|
|
418
|
+
return handleWorkflowComplete(this.context, params);
|
|
419
|
+
}
|
|
420
|
+
async handleExecuteIssue(args) {
|
|
421
|
+
const params = {
|
|
422
|
+
issue_id: args.issue_id,
|
|
423
|
+
agent_type: args.agent_type,
|
|
424
|
+
model: args.model,
|
|
425
|
+
worktree_mode: args.worktree_mode,
|
|
426
|
+
worktree_id: args.worktree_id,
|
|
427
|
+
};
|
|
428
|
+
return handleExecuteIssue(this.context, params);
|
|
429
|
+
}
|
|
430
|
+
async handleExecutionStatus(args) {
|
|
431
|
+
const params = {
|
|
432
|
+
execution_id: args.execution_id,
|
|
433
|
+
};
|
|
434
|
+
return handleExecutionStatus(this.context, params);
|
|
435
|
+
}
|
|
436
|
+
async handleExecutionCancel(args) {
|
|
437
|
+
const params = {
|
|
438
|
+
execution_id: args.execution_id,
|
|
439
|
+
reason: args.reason,
|
|
440
|
+
};
|
|
441
|
+
return handleExecutionCancel(this.context, params);
|
|
442
|
+
}
|
|
443
|
+
async handleExecutionTrajectory(args) {
|
|
444
|
+
const params = {
|
|
445
|
+
execution_id: args.execution_id,
|
|
446
|
+
max_entries: args.max_entries,
|
|
447
|
+
};
|
|
448
|
+
return handleExecutionTrajectory(this.context, params);
|
|
449
|
+
}
|
|
450
|
+
async handleExecutionChanges(args) {
|
|
451
|
+
const params = {
|
|
452
|
+
execution_id: args.execution_id,
|
|
453
|
+
include_diff: args.include_diff,
|
|
454
|
+
};
|
|
455
|
+
return handleExecutionChanges(this.context, params);
|
|
456
|
+
}
|
|
457
|
+
async handleEscalateToUser(args) {
|
|
458
|
+
const params = {
|
|
459
|
+
message: args.message,
|
|
460
|
+
options: args.options,
|
|
461
|
+
context: args.context,
|
|
462
|
+
};
|
|
463
|
+
return handleEscalateToUser(this.context, params);
|
|
464
|
+
}
|
|
465
|
+
async handleNotifyUser(args) {
|
|
466
|
+
const params = {
|
|
467
|
+
message: args.message,
|
|
468
|
+
level: args.level,
|
|
469
|
+
};
|
|
470
|
+
return handleNotifyUser(this.context, params);
|
|
471
|
+
}
|
|
472
|
+
async handleMergeBranch(args) {
|
|
473
|
+
const params = {
|
|
474
|
+
source_branch: args.source_branch,
|
|
475
|
+
target_branch: args.target_branch,
|
|
476
|
+
strategy: args.strategy,
|
|
477
|
+
message: args.message,
|
|
478
|
+
};
|
|
479
|
+
return this.context.apiClient.mergeBranch(params);
|
|
480
|
+
}
|
|
481
|
+
async handleAwaitEvents(args) {
|
|
482
|
+
const params = {
|
|
483
|
+
event_types: args.event_types,
|
|
484
|
+
execution_ids: args.execution_ids,
|
|
485
|
+
timeout_seconds: args.timeout_seconds,
|
|
486
|
+
message: args.message,
|
|
487
|
+
};
|
|
488
|
+
console.error(`[await_events] Orchestrator pausing for workflow ${this.context.workflowId}`, { eventTypes: params.event_types, timeout: params.timeout_seconds });
|
|
489
|
+
return this.context.apiClient.awaitEvents(params);
|
|
490
|
+
}
|
|
491
|
+
// ===========================================================================
|
|
492
|
+
// Lifecycle
|
|
493
|
+
// ===========================================================================
|
|
494
|
+
/**
|
|
495
|
+
* Start the MCP server with stdio transport.
|
|
496
|
+
*/
|
|
497
|
+
async start() {
|
|
498
|
+
this.transport = new StdioServerTransport();
|
|
499
|
+
await this.server.connect(this.transport);
|
|
500
|
+
// Log startup (to stderr so it doesn't interfere with MCP protocol)
|
|
501
|
+
console.error(`[WorkflowMCPServer] Started for workflow ${this.context.workflowId}`);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Stop the MCP server and clean up resources.
|
|
505
|
+
*/
|
|
506
|
+
async stop() {
|
|
507
|
+
if (this.transport) {
|
|
508
|
+
await this.server.close();
|
|
509
|
+
this.transport = null;
|
|
510
|
+
}
|
|
511
|
+
console.error(`[WorkflowMCPServer] Stopped`);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Get the context (for testing).
|
|
515
|
+
*/
|
|
516
|
+
getContext() {
|
|
517
|
+
return this.context;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/workflow/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAgB5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,uBAAuB;AACvB,OAAO,EACL,oBAA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,8EAA8E;IAE9E;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC5C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE1C,oEAAoE;QACpE,OAAO,CAAC,KAAK,CACX,4CAA4C,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CACtE,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escalation MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Implements escalate_to_user and notify_user tools for
|
|
5
|
+
* human-in-the-loop workflow orchestration.
|
|
6
|
+
*
|
|
7
|
+
* All operations go through the HTTP API client.
|
|
8
|
+
*/
|
|
9
|
+
import type { WorkflowMCPContext, EscalateToUserParams, EscalateToUserResult, NotifyUserParams, NotifyUserResult } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Handle escalate_to_user tool call.
|
|
12
|
+
*
|
|
13
|
+
* Creates an escalation request for user input. The orchestrator's session
|
|
14
|
+
* ends naturally after this call - no blocking wait.
|
|
15
|
+
*
|
|
16
|
+
* If autonomyLevel is "full_auto", immediately returns auto_approved
|
|
17
|
+
* without creating an actual escalation.
|
|
18
|
+
*
|
|
19
|
+
* @param context - Workflow MCP context
|
|
20
|
+
* @param params - Escalation parameters (message, options, context)
|
|
21
|
+
* @returns Escalation result with status and optional escalation_id
|
|
22
|
+
*/
|
|
23
|
+
export declare function handleEscalateToUser(context: WorkflowMCPContext, params: EscalateToUserParams): Promise<EscalateToUserResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Handle notify_user tool call.
|
|
26
|
+
*
|
|
27
|
+
* Sends a non-blocking notification to the user. Does not wait for
|
|
28
|
+
* acknowledgment or response. Useful for progress updates and informational
|
|
29
|
+
* messages.
|
|
30
|
+
*
|
|
31
|
+
* @param context - Workflow MCP context
|
|
32
|
+
* @param params - Notification parameters (message, level)
|
|
33
|
+
* @returns Notification result with success and delivered status
|
|
34
|
+
*/
|
|
35
|
+
export declare function handleNotifyUser(context: WorkflowMCPContext, params: NotifyUserParams): Promise<NotifyUserResult>;
|
|
36
|
+
//# sourceMappingURL=escalation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalation.d.ts","sourceRoot":"","sources":["../../../../src/workflow/mcp/tools/escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAMrB;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAQ/B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAU3B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escalation MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Implements escalate_to_user and notify_user tools for
|
|
5
|
+
* human-in-the-loop workflow orchestration.
|
|
6
|
+
*
|
|
7
|
+
* All operations go through the HTTP API client.
|
|
8
|
+
*/
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Tool Handlers
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Handle escalate_to_user tool call.
|
|
14
|
+
*
|
|
15
|
+
* Creates an escalation request for user input. The orchestrator's session
|
|
16
|
+
* ends naturally after this call - no blocking wait.
|
|
17
|
+
*
|
|
18
|
+
* If autonomyLevel is "full_auto", immediately returns auto_approved
|
|
19
|
+
* without creating an actual escalation.
|
|
20
|
+
*
|
|
21
|
+
* @param context - Workflow MCP context
|
|
22
|
+
* @param params - Escalation parameters (message, options, context)
|
|
23
|
+
* @returns Escalation result with status and optional escalation_id
|
|
24
|
+
*/
|
|
25
|
+
export async function handleEscalateToUser(context, params) {
|
|
26
|
+
const result = await context.apiClient.escalateToUser(params);
|
|
27
|
+
console.error(`[escalate_to_user] Escalation result for workflow ${context.workflowId}: ${result.status}`);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Handle notify_user tool call.
|
|
32
|
+
*
|
|
33
|
+
* Sends a non-blocking notification to the user. Does not wait for
|
|
34
|
+
* acknowledgment or response. Useful for progress updates and informational
|
|
35
|
+
* messages.
|
|
36
|
+
*
|
|
37
|
+
* @param context - Workflow MCP context
|
|
38
|
+
* @param params - Notification parameters (message, level)
|
|
39
|
+
* @returns Notification result with success and delivered status
|
|
40
|
+
*/
|
|
41
|
+
export async function handleNotifyUser(context, params) {
|
|
42
|
+
const { message, level = "info" } = params;
|
|
43
|
+
const result = await context.apiClient.notifyUser(params);
|
|
44
|
+
console.error(`[notify_user] [${level.toUpperCase()}] Workflow ${context.workflowId}: ${message}`);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=escalation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalation.js","sourceRoot":"","sources":["../../../../src/workflow/mcp/tools/escalation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA2B,EAC3B,MAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAE9D,OAAO,CAAC,KAAK,CACX,qDAAqD,OAAO,CAAC,UAAU,KAAK,MAAM,CAAC,MAAM,EAAE,CAC5F,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAA2B,EAC3B,MAAwB;IAExB,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IAE3C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO,CAAC,KAAK,CACX,kBAAkB,KAAK,CAAC,WAAW,EAAE,cAAc,OAAO,CAAC,UAAU,KAAK,OAAO,EAAE,CACpF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|