cyrus-config-updater 0.2.0-rc
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/LICENSE +674 -0
- package/dist/ConfigUpdater.d.ts +48 -0
- package/dist/ConfigUpdater.d.ts.map +1 -0
- package/dist/ConfigUpdater.js +116 -0
- package/dist/ConfigUpdater.js.map +1 -0
- package/dist/handlers/checkGh.d.ts +10 -0
- package/dist/handlers/checkGh.d.ts.map +1 -0
- package/dist/handlers/checkGh.js +54 -0
- package/dist/handlers/checkGh.js.map +1 -0
- package/dist/handlers/configureMcp.d.ts +7 -0
- package/dist/handlers/configureMcp.d.ts.map +1 -0
- package/dist/handlers/configureMcp.js +104 -0
- package/dist/handlers/configureMcp.js.map +1 -0
- package/dist/handlers/cyrusConfig.d.ts +11 -0
- package/dist/handlers/cyrusConfig.d.ts.map +1 -0
- package/dist/handlers/cyrusConfig.js +161 -0
- package/dist/handlers/cyrusConfig.js.map +1 -0
- package/dist/handlers/cyrusEnv.d.ts +7 -0
- package/dist/handlers/cyrusEnv.d.ts.map +1 -0
- package/dist/handlers/cyrusEnv.js +113 -0
- package/dist/handlers/cyrusEnv.js.map +1 -0
- package/dist/handlers/repository.d.ts +9 -0
- package/dist/handlers/repository.d.ts.map +1 -0
- package/dist/handlers/repository.js +123 -0
- package/dist/handlers/repository.js.map +1 -0
- package/dist/handlers/testMcp.d.ts +10 -0
- package/dist/handlers/testMcp.d.ts.map +1 -0
- package/dist/handlers/testMcp.js +74 -0
- package/dist/handlers/testMcp.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +111 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +37 -0
- package/src/ConfigUpdater.ts +156 -0
- package/src/handlers/checkGh.ts +59 -0
- package/src/handlers/configureMcp.ts +127 -0
- package/src/handlers/cyrusConfig.ts +185 -0
- package/src/handlers/cyrusEnv.ts +132 -0
- package/src/handlers/repository.ts +137 -0
- package/src/handlers/testMcp.ts +82 -0
- package/src/index.ts +2 -0
- package/src/types.ts +111 -0
- package/test/handlers/checkGh.test.ts +144 -0
- package/test-scripts/test-check-gh.js +56 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { FastifyInstance } from "fastify";
|
|
2
|
+
/**
|
|
3
|
+
* ConfigUpdater registers configuration update routes with a Fastify server
|
|
4
|
+
* Handles: cyrus-config, cyrus-env, repository, test-mcp, configure-mcp, check-gh endpoints
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConfigUpdater {
|
|
7
|
+
private fastify;
|
|
8
|
+
private cyrusHome;
|
|
9
|
+
private apiKey;
|
|
10
|
+
constructor(fastify: FastifyInstance, cyrusHome: string, apiKey: string);
|
|
11
|
+
/**
|
|
12
|
+
* Register all configuration update routes with the Fastify instance
|
|
13
|
+
*/
|
|
14
|
+
register(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Register a route with authentication
|
|
17
|
+
*/
|
|
18
|
+
private registerRoute;
|
|
19
|
+
/**
|
|
20
|
+
* Verify Bearer token authentication
|
|
21
|
+
*/
|
|
22
|
+
private verifyAuth;
|
|
23
|
+
/**
|
|
24
|
+
* Handle cyrus-config update
|
|
25
|
+
*/
|
|
26
|
+
private handleCyrusConfigRoute;
|
|
27
|
+
/**
|
|
28
|
+
* Handle cyrus-env update
|
|
29
|
+
*/
|
|
30
|
+
private handleCyrusEnvRoute;
|
|
31
|
+
/**
|
|
32
|
+
* Handle repository clone/verify
|
|
33
|
+
*/
|
|
34
|
+
private handleRepositoryRoute;
|
|
35
|
+
/**
|
|
36
|
+
* Handle MCP connection test
|
|
37
|
+
*/
|
|
38
|
+
private handleTestMcpRoute;
|
|
39
|
+
/**
|
|
40
|
+
* Handle MCP server configuration
|
|
41
|
+
*/
|
|
42
|
+
private handleConfigureMcpRoute;
|
|
43
|
+
/**
|
|
44
|
+
* Handle GitHub CLI check
|
|
45
|
+
*/
|
|
46
|
+
private handleCheckGhRoute;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ConfigUpdater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigUpdater.d.ts","sourceRoot":"","sources":["../src/ConfigUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAiB/C;;;GAGG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMvE;;OAEG;IACH,QAAQ,IAAI,IAAI;IAUhB;;OAEG;IACH,OAAO,CAAC,aAAa;IA4BrB;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB;;OAEG;YACW,sBAAsB;IAapC;;OAEG;YACW,mBAAmB;IAajC;;OAEG;YACW,qBAAqB;IAMnC;;OAEG;YACW,kBAAkB;IAMhC;;OAEG;YACW,uBAAuB;IAMrC;;OAEG;YACW,kBAAkB;CAKhC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { handleCheckGh } from "./handlers/checkGh.js";
|
|
2
|
+
import { handleConfigureMcp } from "./handlers/configureMcp.js";
|
|
3
|
+
import { handleCyrusConfig } from "./handlers/cyrusConfig.js";
|
|
4
|
+
import { handleCyrusEnv } from "./handlers/cyrusEnv.js";
|
|
5
|
+
import { handleRepository } from "./handlers/repository.js";
|
|
6
|
+
import { handleTestMcp } from "./handlers/testMcp.js";
|
|
7
|
+
/**
|
|
8
|
+
* ConfigUpdater registers configuration update routes with a Fastify server
|
|
9
|
+
* Handles: cyrus-config, cyrus-env, repository, test-mcp, configure-mcp, check-gh endpoints
|
|
10
|
+
*/
|
|
11
|
+
export class ConfigUpdater {
|
|
12
|
+
fastify;
|
|
13
|
+
cyrusHome;
|
|
14
|
+
apiKey;
|
|
15
|
+
constructor(fastify, cyrusHome, apiKey) {
|
|
16
|
+
this.fastify = fastify;
|
|
17
|
+
this.cyrusHome = cyrusHome;
|
|
18
|
+
this.apiKey = apiKey;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Register all configuration update routes with the Fastify instance
|
|
22
|
+
*/
|
|
23
|
+
register() {
|
|
24
|
+
// Register all routes with authentication
|
|
25
|
+
this.registerRoute("/api/update/cyrus-config", this.handleCyrusConfigRoute);
|
|
26
|
+
this.registerRoute("/api/update/cyrus-env", this.handleCyrusEnvRoute);
|
|
27
|
+
this.registerRoute("/api/update/repository", this.handleRepositoryRoute);
|
|
28
|
+
this.registerRoute("/api/test-mcp", this.handleTestMcpRoute);
|
|
29
|
+
this.registerRoute("/api/configure-mcp", this.handleConfigureMcpRoute);
|
|
30
|
+
this.registerRoute("/api/check-gh", this.handleCheckGhRoute);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Register a route with authentication
|
|
34
|
+
*/
|
|
35
|
+
registerRoute(path, handler) {
|
|
36
|
+
this.fastify.post(path, async (request, reply) => {
|
|
37
|
+
// Verify authentication
|
|
38
|
+
const authHeader = request.headers.authorization;
|
|
39
|
+
if (!this.verifyAuth(authHeader)) {
|
|
40
|
+
return reply.status(401).send({
|
|
41
|
+
success: false,
|
|
42
|
+
error: "Unauthorized",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const response = await handler.call(this, request.body);
|
|
47
|
+
const statusCode = response.success ? 200 : 400;
|
|
48
|
+
return reply.status(statusCode).send(response);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return reply.status(500).send({
|
|
52
|
+
success: false,
|
|
53
|
+
error: "Internal server error",
|
|
54
|
+
details: error instanceof Error ? error.message : String(error),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Verify Bearer token authentication
|
|
61
|
+
*/
|
|
62
|
+
verifyAuth(authHeader) {
|
|
63
|
+
if (!authHeader || !this.apiKey) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const expectedAuth = `Bearer ${this.apiKey}`;
|
|
67
|
+
return authHeader === expectedAuth;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Handle cyrus-config update
|
|
71
|
+
*/
|
|
72
|
+
async handleCyrusConfigRoute(payload) {
|
|
73
|
+
const response = await handleCyrusConfig(payload, this.cyrusHome);
|
|
74
|
+
// Emit restart event if requested
|
|
75
|
+
if (response.success && response.data?.restartCyrus) {
|
|
76
|
+
this.fastify.log.info("Config update requested Cyrus restart");
|
|
77
|
+
}
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Handle cyrus-env update
|
|
82
|
+
*/
|
|
83
|
+
async handleCyrusEnvRoute(payload) {
|
|
84
|
+
const response = await handleCyrusEnv(payload, this.cyrusHome);
|
|
85
|
+
// Emit restart event if requested
|
|
86
|
+
if (response.success && response.data?.restartCyrus) {
|
|
87
|
+
this.fastify.log.info("Env update requested Cyrus restart");
|
|
88
|
+
}
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Handle repository clone/verify
|
|
93
|
+
*/
|
|
94
|
+
async handleRepositoryRoute(payload) {
|
|
95
|
+
return handleRepository(payload, this.cyrusHome);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Handle MCP connection test
|
|
99
|
+
*/
|
|
100
|
+
async handleTestMcpRoute(payload) {
|
|
101
|
+
return handleTestMcp(payload);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Handle MCP server configuration
|
|
105
|
+
*/
|
|
106
|
+
async handleConfigureMcpRoute(payload) {
|
|
107
|
+
return handleConfigureMcp(payload, this.cyrusHome);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Handle GitHub CLI check
|
|
111
|
+
*/
|
|
112
|
+
async handleCheckGhRoute(payload) {
|
|
113
|
+
return handleCheckGh(payload, this.cyrusHome);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=ConfigUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigUpdater.js","sourceRoot":"","sources":["../src/ConfigUpdater.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAWtD;;;GAGG;AACH,MAAM,OAAO,aAAa;IACjB,OAAO,CAAkB;IACzB,SAAS,CAAS;IAClB,MAAM,CAAS;IAEvB,YAAY,OAAwB,EAAE,SAAiB,EAAE,MAAc;QACtE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,QAAQ;QACP,0CAA0C;QAC1C,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC5E,IAAI,CAAC,aAAa,CAAC,uBAAuB,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACtE,IAAI,CAAC,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC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uB;QAEvB,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,uBAAuB,CACpC,OAA4B;QAE5B,OAAO,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,kBAAkB,CAC/B,OAAuB;QAEvB,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;CACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ApiResponse, CheckGhPayload } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Check if GitHub CLI (gh) is installed and authenticated
|
|
4
|
+
*
|
|
5
|
+
* @param _payload - Empty payload (no parameters needed)
|
|
6
|
+
* @param _cyrusHome - Cyrus home directory (not used)
|
|
7
|
+
* @returns ApiResponse with installation and authentication status
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleCheckGh(_payload: CheckGhPayload, _cyrusHome: string): Promise<ApiResponse>;
|
|
10
|
+
//# sourceMappingURL=checkGh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkGh.d.ts","sourceRoot":"","sources":["../../src/handlers/checkGh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAe,cAAc,EAAE,MAAM,aAAa,CAAC;AAI5E;;;;;;GAMG;AACH,wBAAsB,aAAa,CAClC,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC,CA0CtB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const execAsync = promisify(exec);
|
|
4
|
+
/**
|
|
5
|
+
* Check if GitHub CLI (gh) is installed and authenticated
|
|
6
|
+
*
|
|
7
|
+
* @param _payload - Empty payload (no parameters needed)
|
|
8
|
+
* @param _cyrusHome - Cyrus home directory (not used)
|
|
9
|
+
* @returns ApiResponse with installation and authentication status
|
|
10
|
+
*/
|
|
11
|
+
export async function handleCheckGh(_payload, _cyrusHome) {
|
|
12
|
+
try {
|
|
13
|
+
// Check if gh is installed
|
|
14
|
+
let isInstalled = false;
|
|
15
|
+
try {
|
|
16
|
+
await execAsync("gh --version");
|
|
17
|
+
isInstalled = true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// gh command not found
|
|
21
|
+
isInstalled = false;
|
|
22
|
+
}
|
|
23
|
+
// Check if gh is authenticated (only if installed)
|
|
24
|
+
let isAuthenticated = false;
|
|
25
|
+
if (isInstalled) {
|
|
26
|
+
try {
|
|
27
|
+
// Run 'gh auth status' and check exit code
|
|
28
|
+
await execAsync("gh auth status");
|
|
29
|
+
isAuthenticated = true;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// gh auth status failed (not authenticated)
|
|
33
|
+
isAuthenticated = false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const data = {
|
|
37
|
+
isInstalled,
|
|
38
|
+
isAuthenticated,
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
message: "GitHub CLI check completed",
|
|
43
|
+
data,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
success: false,
|
|
49
|
+
error: "Failed to check GitHub CLI status",
|
|
50
|
+
details: error instanceof Error ? error.message : String(error),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=checkGh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkGh.js","sourceRoot":"","sources":["../../src/handlers/checkGh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,QAAwB,EACxB,UAAkB;IAElB,IAAI,CAAC;QACJ,2BAA2B;QAC3B,IAAI,WAAW,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC;YACJ,MAAM,SAAS,CAAC,cAAc,CAAC,CAAC;YAChC,WAAW,GAAG,IAAI,CAAC;QACpB,CAAC;QAAC,MAAM,CAAC;YACR,uBAAuB;YACvB,WAAW,GAAG,KAAK,CAAC;QACrB,CAAC;QAED,mDAAmD;QACnD,IAAI,eAAe,GAAG,KAAK,CAAC;QAC5B,IAAI,WAAW,EAAE,CAAC;YACjB,IAAI,CAAC;gBACJ,2CAA2C;gBAC3C,MAAM,SAAS,CAAC,gBAAgB,CAAC,CAAC;gBAClC,eAAe,GAAG,IAAI,CAAC;YACxB,CAAC;YAAC,MAAM,CAAC;gBACR,4CAA4C;gBAC5C,eAAe,GAAG,KAAK,CAAC;YACzB,CAAC;QACF,CAAC;QAED,MAAM,IAAI,GAAgB;YACzB,WAAW;YACX,eAAe;SACf,CAAC;QAEF,OAAO;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,4BAA4B;YACrC,IAAI;SACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO;YACN,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,mCAAmC;YAC1C,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC/D,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApiResponse, ConfigureMcpPayload } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Handle MCP server configuration
|
|
4
|
+
* Writes individual MCP config files to ~/.cyrus/mcp-{slug}.json
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleConfigureMcp(payload: ConfigureMcpPayload, cyrusHome: string): Promise<ApiResponse>;
|
|
7
|
+
//# sourceMappingURL=configureMcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureMcp.d.ts","sourceRoot":"","sources":["../../src/handlers/configureMcp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEpE;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,mBAAmB,EAC5B,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CA2EtB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Handle MCP server configuration
|
|
5
|
+
* Writes individual MCP config files to ~/.cyrus/mcp-{slug}.json
|
|
6
|
+
*/
|
|
7
|
+
export async function handleConfigureMcp(payload, cyrusHome) {
|
|
8
|
+
try {
|
|
9
|
+
// Validate payload
|
|
10
|
+
if (!payload.mcpServers || typeof payload.mcpServers !== "object") {
|
|
11
|
+
return {
|
|
12
|
+
success: false,
|
|
13
|
+
error: "MCP configuration requires server definitions",
|
|
14
|
+
details: "The mcpServers field must be an object containing server configurations.",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const serverSlugs = Object.keys(payload.mcpServers);
|
|
18
|
+
if (serverSlugs.length === 0) {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
error: "No MCP servers to configure",
|
|
22
|
+
details: "At least one MCP server configuration must be provided.",
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Ensure the .cyrus directory exists
|
|
26
|
+
if (!existsSync(cyrusHome)) {
|
|
27
|
+
mkdirSync(cyrusHome, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
const mcpFilesWritten = [];
|
|
30
|
+
// Write each MCP server configuration to its own file
|
|
31
|
+
for (const slug of serverSlugs) {
|
|
32
|
+
const serverConfig = payload.mcpServers[slug];
|
|
33
|
+
const mcpFilePath = join(cyrusHome, `mcp-${slug}.json`);
|
|
34
|
+
// Perform environment variable substitution
|
|
35
|
+
const processedConfig = performEnvSubstitution(serverConfig);
|
|
36
|
+
// Write the config file
|
|
37
|
+
try {
|
|
38
|
+
const configData = {
|
|
39
|
+
mcpServers: {
|
|
40
|
+
[slug]: processedConfig,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
writeFileSync(mcpFilePath, JSON.stringify(configData, null, 2), "utf-8");
|
|
44
|
+
mcpFilesWritten.push(mcpFilePath);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
success: false,
|
|
49
|
+
error: `Failed to save MCP server configuration for "${slug}"`,
|
|
50
|
+
details: `Could not write to ${mcpFilePath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
message: "MCP configuration files written successfully",
|
|
57
|
+
data: {
|
|
58
|
+
mcpFilesWritten,
|
|
59
|
+
serversConfigured: serverSlugs,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
error: "MCP server configuration failed",
|
|
67
|
+
details: error instanceof Error ? error.message : String(error),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Perform environment variable substitution on a config object
|
|
73
|
+
* Replaces ${VAR_NAME} placeholders with values from the env map
|
|
74
|
+
*/
|
|
75
|
+
function performEnvSubstitution(config) {
|
|
76
|
+
if (!config)
|
|
77
|
+
return config;
|
|
78
|
+
// Get environment variables from the config
|
|
79
|
+
const env = config.env || {};
|
|
80
|
+
// Deep clone the config to avoid mutations
|
|
81
|
+
const processed = JSON.parse(JSON.stringify(config));
|
|
82
|
+
// Recursively process all string values
|
|
83
|
+
function processValue(value) {
|
|
84
|
+
if (typeof value === "string") {
|
|
85
|
+
// Replace ${VAR_NAME} with the actual value from env
|
|
86
|
+
return value.replace(/\$\{([^}]+)\}/g, (match, varName) => {
|
|
87
|
+
return env[varName] || match;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
return value.map(processValue);
|
|
92
|
+
}
|
|
93
|
+
if (typeof value === "object" && value !== null) {
|
|
94
|
+
const result = {};
|
|
95
|
+
for (const key of Object.keys(value)) {
|
|
96
|
+
result[key] = processValue(value[key]);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
return processValue(processed);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=configureMcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureMcp.js","sourceRoot":"","sources":["../../src/handlers/configureMcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,OAA4B,EAC5B,SAAiB;IAEjB,IAAI,CAAC;QACJ,mBAAmB;QACnB,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YACnE,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,+CAA+C;gBACtD,OAAO,EACN,0EAA0E;aAC3E,CAAC;QACH,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,C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CAAC;YACvB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtC,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,MAAM,CAAC;QACf,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ApiResponse, CyrusConfigPayload } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Handle Cyrus configuration update
|
|
4
|
+
* Updates the ~/.cyrus/config.json file with the provided configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleCyrusConfig(payload: CyrusConfigPayload, cyrusHome: string): Promise<ApiResponse>;
|
|
7
|
+
/**
|
|
8
|
+
* Read current Cyrus configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function readCyrusConfig(cyrusHome: string): any;
|
|
11
|
+
//# sourceMappingURL=cyrusConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cyrusConfig.d.ts","sourceRoot":"","sources":["../../src/handlers/cyrusConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CA2JtB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAatD"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Handle Cyrus configuration update
|
|
5
|
+
* Updates the ~/.cyrus/config.json file with the provided configuration
|
|
6
|
+
*/
|
|
7
|
+
export async function handleCyrusConfig(payload, cyrusHome) {
|
|
8
|
+
try {
|
|
9
|
+
// Validate payload
|
|
10
|
+
if (!payload.repositories || !Array.isArray(payload.repositories)) {
|
|
11
|
+
return {
|
|
12
|
+
success: false,
|
|
13
|
+
error: "Configuration update requires repositories array",
|
|
14
|
+
details: "The repositories field must be provided as an array, even if empty.",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
// Validate each repository has required fields
|
|
18
|
+
for (const repo of payload.repositories) {
|
|
19
|
+
if (!repo.id || !repo.name || !repo.repositoryPath || !repo.baseBranch) {
|
|
20
|
+
const missingFields = [];
|
|
21
|
+
if (!repo.id)
|
|
22
|
+
missingFields.push("id");
|
|
23
|
+
if (!repo.name)
|
|
24
|
+
missingFields.push("name");
|
|
25
|
+
if (!repo.repositoryPath)
|
|
26
|
+
missingFields.push("repositoryPath");
|
|
27
|
+
if (!repo.baseBranch)
|
|
28
|
+
missingFields.push("baseBranch");
|
|
29
|
+
return {
|
|
30
|
+
success: false,
|
|
31
|
+
error: "Repository configuration is incomplete",
|
|
32
|
+
details: `Repository "${repo.name || "unknown"}" is missing required fields: ${missingFields.join(", ")}`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const configPath = join(cyrusHome, "config.json");
|
|
37
|
+
// Ensure the .cyrus directory exists
|
|
38
|
+
const configDir = dirname(configPath);
|
|
39
|
+
if (!existsSync(configDir)) {
|
|
40
|
+
mkdirSync(configDir, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
// Build the config object with repositories and optional settings
|
|
43
|
+
const repositories = payload.repositories.map((repo) => {
|
|
44
|
+
const repoConfig = {
|
|
45
|
+
id: repo.id,
|
|
46
|
+
name: repo.name,
|
|
47
|
+
repositoryPath: repo.repositoryPath,
|
|
48
|
+
baseBranch: repo.baseBranch,
|
|
49
|
+
};
|
|
50
|
+
// Add optional Linear fields
|
|
51
|
+
if (repo.linearWorkspaceId) {
|
|
52
|
+
repoConfig.linearWorkspaceId = repo.linearWorkspaceId;
|
|
53
|
+
}
|
|
54
|
+
if (repo.linearToken) {
|
|
55
|
+
repoConfig.linearToken = repo.linearToken;
|
|
56
|
+
}
|
|
57
|
+
// Set workspaceBaseDir (use provided or default to ~/.cyrus/workspaces)
|
|
58
|
+
repoConfig.workspaceBaseDir =
|
|
59
|
+
repo.workspaceBaseDir || join(cyrusHome, "workspaces");
|
|
60
|
+
// Set isActive (defaults to true)
|
|
61
|
+
repoConfig.isActive = repo.isActive !== false;
|
|
62
|
+
// Optional arrays and objects
|
|
63
|
+
if (repo.allowedTools && repo.allowedTools.length > 0) {
|
|
64
|
+
repoConfig.allowedTools = repo.allowedTools;
|
|
65
|
+
}
|
|
66
|
+
if (repo.mcpConfigPath && repo.mcpConfigPath.length > 0) {
|
|
67
|
+
repoConfig.mcpConfigPath = repo.mcpConfigPath;
|
|
68
|
+
}
|
|
69
|
+
if (repo.teamKeys) {
|
|
70
|
+
repoConfig.teamKeys = repo.teamKeys;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
repoConfig.teamKeys = [];
|
|
74
|
+
}
|
|
75
|
+
if (repo.labelPrompts && Object.keys(repo.labelPrompts).length > 0) {
|
|
76
|
+
repoConfig.labelPrompts = repo.labelPrompts;
|
|
77
|
+
}
|
|
78
|
+
return repoConfig;
|
|
79
|
+
});
|
|
80
|
+
// Build complete config
|
|
81
|
+
const config = {
|
|
82
|
+
repositories,
|
|
83
|
+
};
|
|
84
|
+
// Add optional global settings
|
|
85
|
+
if (payload.disallowedTools && payload.disallowedTools.length > 0) {
|
|
86
|
+
config.disallowedTools = payload.disallowedTools;
|
|
87
|
+
}
|
|
88
|
+
if (payload.ngrokAuthToken) {
|
|
89
|
+
config.ngrokAuthToken = payload.ngrokAuthToken;
|
|
90
|
+
}
|
|
91
|
+
if (payload.stripeCustomerId) {
|
|
92
|
+
config.stripeCustomerId = payload.stripeCustomerId;
|
|
93
|
+
}
|
|
94
|
+
if (payload.defaultModel) {
|
|
95
|
+
config.defaultModel = payload.defaultModel;
|
|
96
|
+
}
|
|
97
|
+
if (payload.defaultFallbackModel) {
|
|
98
|
+
config.defaultFallbackModel = payload.defaultFallbackModel;
|
|
99
|
+
}
|
|
100
|
+
if (payload.global_setup_script) {
|
|
101
|
+
config.global_setup_script = payload.global_setup_script;
|
|
102
|
+
}
|
|
103
|
+
// Backup existing config if requested
|
|
104
|
+
if (payload.backupConfig && existsSync(configPath)) {
|
|
105
|
+
try {
|
|
106
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
107
|
+
const backupPath = join(cyrusHome, `config.backup-${timestamp}.json`);
|
|
108
|
+
const existingConfig = readFileSync(configPath, "utf-8");
|
|
109
|
+
writeFileSync(backupPath, existingConfig, "utf-8");
|
|
110
|
+
}
|
|
111
|
+
catch (backupError) {
|
|
112
|
+
// Log but don't fail - backup is not critical
|
|
113
|
+
console.warn(`Failed to backup config: ${backupError instanceof Error ? backupError.message : String(backupError)}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Write config file
|
|
117
|
+
try {
|
|
118
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
119
|
+
return {
|
|
120
|
+
success: true,
|
|
121
|
+
message: "Cyrus configuration updated successfully",
|
|
122
|
+
data: {
|
|
123
|
+
configPath,
|
|
124
|
+
repositoriesCount: repositories.length,
|
|
125
|
+
restartCyrus: payload.restartCyrus || false,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return {
|
|
131
|
+
success: false,
|
|
132
|
+
error: "Failed to save configuration file",
|
|
133
|
+
details: `Could not write configuration to ${configPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
error: "Configuration update failed",
|
|
141
|
+
details: error instanceof Error ? error.message : String(error),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Read current Cyrus configuration
|
|
147
|
+
*/
|
|
148
|
+
export function readCyrusConfig(cyrusHome) {
|
|
149
|
+
const configPath = join(cyrusHome, "config.json");
|
|
150
|
+
if (!existsSync(configPath)) {
|
|
151
|
+
return { repositories: [] };
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const data = readFileSync(configPath, "utf-8");
|
|
155
|
+
return JSON.parse(data);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return { repositories: [] };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=cyrusConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cyrusConfig.js","sourceRoot":"","sources":["../../src/handlers/cyrusConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,OAA2B,EAC3B,SAAiB;IAEjB,IAAI,CAAC;QACJ,mBAAmB;QACnB,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACnE,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,kDAAkD;gBACzD,OAAO,EACN,qEAAqE;aACtE,CAAC;QACH,CAAC;QAED,+CAA+C;QAC/C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzC,IAAI,CAAC,IAAI,CAAC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,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC7B,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApiResponse, CyrusEnvPayload } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Handle Cyrus environment variables update
|
|
4
|
+
* Primarily used to update/provide the Claude API token
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleCyrusEnv(payload: CyrusEnvPayload, cyrusHome: string): Promise<ApiResponse>;
|
|
7
|
+
//# sourceMappingURL=cyrusEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cyrusEnv.d.ts","sourceRoot":"","sources":["../../src/handlers/cyrusEnv.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE;;;GAGG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,eAAe,EACxB,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAwHtB"}
|