MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / registerWorkspacesRoutes

Function registerWorkspacesRoutes

packages/server/src/routes/workspaces.ts:54–164  ·  view source on GitHub ↗
(
  app: WorkspaceRouteHost,
  ix: IInstantiationService,
)

Source from the content-addressed store, hash-verified

52}
53
54export function registerWorkspacesRoutes(
55 app: WorkspaceRouteHost,
56 ix: IInstantiationService,
57): void {
58
59 const listRoute = defineRoute(
60 {
61 method: 'GET',
62 path: '/workspaces',
63 success: { data: listWorkspacesResponseSchema },
64 description: 'List registered workspaces',
65 tags: ['workspaces'],
66 },
67 async (req, reply) => {
68 try {
69 const items = await ix.invokeFunction((a) => a.get(IWorkspaceRegistry).list());
70 reply.send(okEnvelope({ items }, req.id));
71 } catch (err) {
72 sendMappedError(reply, req.id, err);
73 }
74 },
75 );
76
77 app.get(
78 listRoute.path,
79 listRoute.options,
80 listRoute.handler as Parameters<WorkspaceRouteHost['get']>[2],
81 );
82
83 const createRoute = defineRoute(
84 {
85 method: 'POST',
86 path: '/workspaces',
87 body: createWorkspaceRequestSchema,
88 success: { data: createWorkspaceResponseSchema },
89 description: 'Register a workspace (idempotent on root)',
90 tags: ['workspaces'],
91 },
92 async (req, reply) => {
93 try {
94 const ws = await ix.invokeFunction((a) =>
95 a.get(IWorkspaceRegistry).createOrTouch(req.body.root, req.body.name),
96 );
97 reply.send(okEnvelope(ws, req.id));
98 } catch (err) {
99 sendMappedError(reply, req.id, err);
100 }
101 },
102 );
103
104 app.post(
105 createRoute.path,
106 createRoute.options,
107 createRoute.handler as Parameters<WorkspaceRouteHost['post']>[2],
108 );
109
110 const updateRoute = defineRoute(
111 {

Callers 1

registerApiV1RoutesFunction · 0.90

Calls 12

defineRouteFunction · 0.90
okEnvelopeFunction · 0.90
sendMappedErrorFunction · 0.70
invokeFunctionMethod · 0.65
listMethod · 0.65
getMethod · 0.65
sendMethod · 0.65
createOrTouchMethod · 0.65
postMethod · 0.65
updateMethod · 0.65
patchMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected