MCPcopy Create free account
hub / github.com/agent-tower/core / workspaceRoutes

Function workspaceRoutes

packages/server/src/routes/workspaces.ts:70–352  ·  view source on GitHub ↗
(app: FastifyInstance)

Source from the content-addressed store, hash-verified

68}
69
70export async function workspaceRoutes(app: FastifyInstance) {
71 const workspaceService = new WorkspaceService();
72
73 // ── 错误处理钩子 ────────────────────────────────────────────────────────────
74
75 app.setErrorHandler((error, _request, reply) => {
76 // ServiceError(业务错误)
77 if (error instanceof ServiceError) {
78 reply.code(error.statusCode);
79 return errorResponse(error.message, error.code);
80 }
81
82 // MergeConflictError → 409 with conflict details
83 if (error instanceof MergeConflictError) {
84 reply.code(409);
85 return {
86 error: error.message,
87 code: error.code,
88 conflictedFiles: error.conflictedFiles,
89 conflictOp: error.conflictOp,
90 mergeAborted: error.mergeAborted,
91 mergeStrategy: error.mergeStrategy,
92 sourceBranch: error.sourceBranch,
93 targetBranch: error.targetBranch,
94 sourceWorktreePath: error.sourceWorktreePath,
95 targetWorktreePath: error.targetWorktreePath,
96 sourceWorkspaceId: error.sourceWorkspaceId,
97 targetWorkspaceId: error.targetWorkspaceId,
98 };
99 }
100
101 // RebaseInProgressError → 409
102 if (error instanceof RebaseInProgressError) {
103 reply.code(409);
104 return errorResponse(error.message, error.code);
105 }
106
107 // GitError(Git 操作错误)
108 if (error instanceof GitError) {
109 reply.code(400);
110 return errorResponse(error.message, error.code);
111 }
112
113 // Zod 校验错误
114 if (error.name === 'ZodError') {
115 reply.code(400);
116 return errorResponse(error.message, 'VALIDATION_ERROR');
117 }
118
119 // 未知错误
120 app.log.error(error);
121 reply.code(500);
122 return errorResponse('Internal server error', 'INTERNAL_ERROR');
123 });
124
125 // ── 创建工作空间 ────────────────────────────────────────────────────────────
126
127 app.post<{ Params: { taskId: string } }>(

Callers

nothing calls this directly

Calls 15

createMethod · 0.95
findByTaskIdMethod · 0.95
findByIdMethod · 0.95
getDiffMethod · 0.95
listVerdictsMethod · 0.95
recordVerdictMethod · 0.95
mergeMethod · 0.95
archiveMethod · 0.95
deleteMethod · 0.95
rebaseMethod · 0.95
getGitStatusMethod · 0.95

Tested by

no test coverage detected