deepdebug-local-agent 1.0.16 → 1.0.17
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/package.json +1 -1
- package/src/server.js +35 -7
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -850,18 +850,45 @@ app.post("/workspace/open", async (req, res) => {
|
|
|
850
850
|
res.json({ ok: true, root: abs, workspaceId: wsId, mode: "local", meta, port });
|
|
851
851
|
});
|
|
852
852
|
|
|
853
|
+
|
|
854
|
+
|
|
853
855
|
/**
|
|
854
856
|
* POST /workspace/clone
|
|
855
857
|
* Clones a git repository into the local filesystem, then opens it as workspace.
|
|
856
858
|
* Body: { gitUrl, targetPath, workspaceId? }
|
|
857
859
|
*/
|
|
858
860
|
app.post("/workspace/clone", async (req, res) => {
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
861
|
+
const body = req.body || {};
|
|
862
|
+
// Accept both naming conventions:
|
|
863
|
+
// - gitUrl + targetPath (local agent format)
|
|
864
|
+
// - repoUrl + targetDir (cloud format)
|
|
865
|
+
const gitUrl = body.gitUrl || body.repoUrl;
|
|
866
|
+
const targetPath = body.targetPath || body.targetDir;
|
|
867
|
+
const workspaceId = body.workspaceId;
|
|
868
|
+
const gitToken = body.gitToken;
|
|
869
|
+
const branch = body.branch;
|
|
870
|
+
|
|
871
|
+
if (!gitUrl) return res.status(400).json({ ok: false, error: "gitUrl is required" });
|
|
872
|
+
|
|
873
|
+
// If targetPath not provided, derive from repo name
|
|
874
|
+
const repoName = gitUrl.split('/').pop().replace('.git', '');
|
|
875
|
+
const resolvedTarget = targetPath
|
|
876
|
+
? path.resolve(targetPath)
|
|
877
|
+
: path.join(process.env.HOME || '/home/deepdebug', 'DeepDebug', repoName);
|
|
878
|
+
|
|
879
|
+
// If gitToken provided and not already embedded in URL, embed it
|
|
880
|
+
let authenticatedUrl = gitUrl;
|
|
881
|
+
if (gitToken && gitUrl.startsWith('https://') && !gitUrl.includes('@')) {
|
|
882
|
+
if (gitUrl.includes('bitbucket.org')) {
|
|
883
|
+
authenticatedUrl = gitUrl.replace('https://', `https://x-token-auth:${gitToken}@`);
|
|
884
|
+
} else if (gitUrl.includes('gitlab.com')) {
|
|
885
|
+
authenticatedUrl = gitUrl.replace('https://', `https://oauth2:${gitToken}@`);
|
|
886
|
+
} else {
|
|
887
|
+
authenticatedUrl = gitUrl.replace('https://', `https://x-access-token:${gitToken}@`);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
863
890
|
|
|
864
|
-
const absTarget =
|
|
891
|
+
const absTarget = resolvedTarget;
|
|
865
892
|
console.log(` Clone request: ${gitUrl} -> ${absTarget}`);
|
|
866
893
|
|
|
867
894
|
try {
|
|
@@ -878,8 +905,9 @@ app.post("/workspace/clone", async (req, res) => {
|
|
|
878
905
|
const { stdout } = await execAsync('git pull', { cwd: absTarget, timeout: 120000 });
|
|
879
906
|
console.log(` git pull: ${stdout.trim()}`);
|
|
880
907
|
} else {
|
|
881
|
-
|
|
882
|
-
|
|
908
|
+
const safeLog = authenticatedUrl.replace(/x-token-auth:[^@]+@/g, 'x-token-auth:***@').replace(/oauth2:[^@]+@/g, 'oauth2:***@').replace(/x-access-token:[^@]+@/g, 'x-access-token:***@');
|
|
909
|
+
console.log(` Running: git clone "${safeLog}" "${absTarget}"`);
|
|
910
|
+
await execAsync(`git clone "${authenticatedUrl}" "${absTarget}"`, { timeout: 300000 });
|
|
883
911
|
console.log(` Clone complete: ${absTarget}`);
|
|
884
912
|
}
|
|
885
913
|
|