autodev-cli 1.4.9 → 1.4.10
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.
|
@@ -1,10 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.restoreAgentBackup = restoreAgentBackup;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
4
39
|
const archive_1 = require("./archive");
|
|
5
40
|
const layout_1 = require("./layout");
|
|
6
41
|
const sessionProviders_1 = require("./sessionProviders");
|
|
7
42
|
const manifest_1 = require("./manifest");
|
|
43
|
+
/**
|
|
44
|
+
* Identity/connection settings that belong to the DESTINATION agent, not the
|
|
45
|
+
* backed-up one. Restoring a backup must never overwrite these, or the restored
|
|
46
|
+
* agent would connect as the source agent (identity hijack).
|
|
47
|
+
*/
|
|
48
|
+
const IDENTITY_KEYS = ['wsUrl', 'serverBaseUrl', 'serverApiKey', 'webhookSlug', 'agentId'];
|
|
8
49
|
/**
|
|
9
50
|
* Restore an agent backup ZIP into a destination folder and wire up its
|
|
10
51
|
* session state so it resumes there. Mirrors {@link './export'} using the
|
|
@@ -20,8 +61,36 @@ async function restoreAgentBackup(zipPath, destRoot) {
|
|
|
20
61
|
if (!archive.entryPaths().some(p => p.startsWith(`${layout_1.TOP_FOLDER}/`))) {
|
|
21
62
|
throw new Error('Not an AutoDev agent backup (missing agent-export/ root).');
|
|
22
63
|
}
|
|
64
|
+
// Preserve THIS agent's identity/connection settings across the restore —
|
|
65
|
+
// the backup carries the source agent's settings.json (wsUrl/api_key/slug),
|
|
66
|
+
// which would otherwise hijack this agent's identity.
|
|
67
|
+
const destSettingsPath = path.join(destRoot, '.autodev', 'settings.json');
|
|
68
|
+
const preservedIdentity = {};
|
|
69
|
+
try {
|
|
70
|
+
if (fs.existsSync(destSettingsPath)) {
|
|
71
|
+
const cur = JSON.parse(fs.readFileSync(destSettingsPath, 'utf8'));
|
|
72
|
+
for (const k of IDENTITY_KEYS) {
|
|
73
|
+
if (cur[k] !== undefined) {
|
|
74
|
+
preservedIdentity[k] = cur[k];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch { /* no current settings — nothing to preserve */ }
|
|
23
80
|
// 1. Workspace state + root docs back into the destination folder.
|
|
24
81
|
const workspaceFiles = archive.extractDir(layout_1.ARCHIVE_PATHS.workspace, destRoot);
|
|
82
|
+
// Re-apply the preserved identity onto the restored settings.json.
|
|
83
|
+
if (Object.keys(preservedIdentity).length > 0) {
|
|
84
|
+
try {
|
|
85
|
+
const restored = fs.existsSync(destSettingsPath)
|
|
86
|
+
? JSON.parse(fs.readFileSync(destSettingsPath, 'utf8'))
|
|
87
|
+
: {};
|
|
88
|
+
Object.assign(restored, preservedIdentity);
|
|
89
|
+
fs.mkdirSync(path.dirname(destSettingsPath), { recursive: true });
|
|
90
|
+
fs.writeFileSync(destSettingsPath, JSON.stringify(restored, null, 2) + '\n', 'utf8');
|
|
91
|
+
}
|
|
92
|
+
catch { /* best effort */ }
|
|
93
|
+
}
|
|
25
94
|
// 2. Provider session traces into their host stores (Strategy).
|
|
26
95
|
const restoredByProvider = {};
|
|
27
96
|
for (const provider of sessionProviders_1.SESSION_BACKUP_PROVIDERS) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/agentBackup/import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/agentBackup/import.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,gDA4CC;AA3ED,uCAAyB;AACzB,2CAA6B;AAC7B,uCAA0C;AAC1C,qCAAqD;AACrD,yDAA8D;AAC9D,yCAA2C;AAE3C;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,CAAU,CAAC;AAUpG;;;;;;;;GAQG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAAe,EAAE,QAAgB;IACxE,MAAM,OAAO,GAAG,uBAAa,CAAC,IAAI,CA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