@the-17/agentsecrets 1.1.2 → 1.1.3
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/bin/agentsecrets.js +54 -26
- package/package.json +3 -2
package/bin/agentsecrets.js
CHANGED
|
@@ -5,10 +5,8 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const { spawn } = require('child_process');
|
|
7
7
|
const https = require('https');
|
|
8
|
-
const zlib = require('zlib');
|
|
9
8
|
const tar = require('tar');
|
|
10
9
|
|
|
11
|
-
const VERSION = "1.0.4";
|
|
12
10
|
const GITHUB_REPO = "The-17/agentsecrets";
|
|
13
11
|
|
|
14
12
|
function getPlatformInfo() {
|
|
@@ -28,10 +26,33 @@ function getPlatformInfo() {
|
|
|
28
26
|
return { osName, archName };
|
|
29
27
|
}
|
|
30
28
|
|
|
29
|
+
function httpsGet(url) {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
https.get(url, { headers: { 'User-Agent': 'agentsecrets-npm' } }, (res) => {
|
|
32
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
33
|
+
return httpsGet(res.headers.location).then(resolve).catch(reject);
|
|
34
|
+
}
|
|
35
|
+
let data = '';
|
|
36
|
+
res.on('data', chunk => data += chunk);
|
|
37
|
+
res.on('end', () => resolve({ statusCode: res.statusCode, body: data }));
|
|
38
|
+
}).on('error', reject);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function getLatestVersion() {
|
|
43
|
+
try {
|
|
44
|
+
const { body } = await httpsGet(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`);
|
|
45
|
+
const release = JSON.parse(body);
|
|
46
|
+
return release.tag_name.replace(/^v/, '');
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
async function downloadFile(url, dest) {
|
|
32
53
|
return new Promise((resolve, reject) => {
|
|
33
54
|
const file = fs.createWriteStream(dest);
|
|
34
|
-
https.get(url, (response) => {
|
|
55
|
+
https.get(url, { headers: { 'User-Agent': 'agentsecrets-npm' } }, (response) => {
|
|
35
56
|
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
36
57
|
downloadFile(response.headers.location, dest).then(resolve).catch(reject);
|
|
37
58
|
return;
|
|
@@ -41,9 +62,7 @@ async function downloadFile(url, dest) {
|
|
|
41
62
|
return;
|
|
42
63
|
}
|
|
43
64
|
response.pipe(file);
|
|
44
|
-
file.on('finish', () =>
|
|
45
|
-
file.close(resolve);
|
|
46
|
-
});
|
|
65
|
+
file.on('finish', () => file.close(resolve));
|
|
47
66
|
}).on('error', (err) => {
|
|
48
67
|
fs.unlink(dest, () => reject(err));
|
|
49
68
|
});
|
|
@@ -60,17 +79,37 @@ async function ensureBinary() {
|
|
|
60
79
|
let binaryName = 'agentsecrets';
|
|
61
80
|
if (osName === 'windows') binaryName += '.exe';
|
|
62
81
|
|
|
63
|
-
|
|
82
|
+
// Check GitHub for the latest version
|
|
83
|
+
process.stderr.write('Checking for latest AgentSecrets version...\n');
|
|
84
|
+
const latestVersion = await getLatestVersion();
|
|
85
|
+
|
|
86
|
+
if (!latestVersion) {
|
|
87
|
+
// Offline or GitHub unreachable — fall back to any existing binary
|
|
88
|
+
const existing = fs.readdirSync(baseDir).find(f => f.startsWith(binaryName));
|
|
89
|
+
if (existing) {
|
|
90
|
+
process.stderr.write('Could not reach GitHub. Using cached binary.\n');
|
|
91
|
+
return path.join(baseDir, existing);
|
|
92
|
+
}
|
|
93
|
+
throw new Error('No cached binary and could not reach GitHub to download one.');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const binaryPath = path.join(baseDir, `${binaryName}_${latestVersion}`);
|
|
64
97
|
|
|
65
98
|
if (fs.existsSync(binaryPath)) {
|
|
66
|
-
return binaryPath;
|
|
99
|
+
return binaryPath; // Already on latest
|
|
67
100
|
}
|
|
68
101
|
|
|
69
|
-
|
|
102
|
+
// Delete old binaries
|
|
103
|
+
const oldBinaries = fs.readdirSync(baseDir).filter(f => f.startsWith(binaryName));
|
|
104
|
+
for (const old of oldBinaries) {
|
|
105
|
+
fs.unlinkSync(path.join(baseDir, old));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
process.stderr.write(`Downloading AgentSecrets v${latestVersion} for ${osName}/${archName}...\n`);
|
|
70
109
|
|
|
71
110
|
const ext = osName === 'windows' ? 'zip' : 'tar.gz';
|
|
72
|
-
const assetName = `agentsecrets_${
|
|
73
|
-
const url = `https://github.com/${GITHUB_REPO}/releases/download/v${
|
|
111
|
+
const assetName = `agentsecrets_${latestVersion}_${osName}_${archName}.${ext}`;
|
|
112
|
+
const url = `https://github.com/${GITHUB_REPO}/releases/download/v${latestVersion}/${assetName}`;
|
|
74
113
|
|
|
75
114
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsecrets-'));
|
|
76
115
|
const archivePath = path.join(tmpDir, assetName);
|
|
@@ -79,25 +118,16 @@ async function ensureBinary() {
|
|
|
79
118
|
await downloadFile(url, archivePath);
|
|
80
119
|
|
|
81
120
|
if (ext === 'tar.gz') {
|
|
82
|
-
await tar.x({
|
|
83
|
-
file: archivePath,
|
|
84
|
-
cwd: tmpDir
|
|
85
|
-
});
|
|
121
|
+
await tar.x({ file: archivePath, cwd: tmpDir });
|
|
86
122
|
} else {
|
|
87
|
-
// For zip, we'd need a library like adm-zip or similar,
|
|
88
|
-
// but to keep it zero-dep, we can assume Linux/Mac for npx mostly,
|
|
89
|
-
// or use powershell/unzip if available.
|
|
90
|
-
// For now, let's focus on tar.gz and provide a hint for windows.
|
|
91
123
|
if (osName === 'windows') {
|
|
92
|
-
throw new Error(
|
|
124
|
+
throw new Error('Automatic zip extraction for Windows not yet implemented.');
|
|
93
125
|
}
|
|
94
126
|
}
|
|
95
127
|
|
|
96
128
|
const extractedBinary = path.join(tmpDir, binaryName);
|
|
97
129
|
fs.copyFileSync(extractedBinary, binaryPath);
|
|
98
130
|
fs.chmodSync(binaryPath, 0o755);
|
|
99
|
-
|
|
100
|
-
// Cleanup
|
|
101
131
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
102
132
|
|
|
103
133
|
return binaryPath;
|
|
@@ -111,13 +141,11 @@ async function main() {
|
|
|
111
141
|
const binaryPath = await ensureBinary();
|
|
112
142
|
const args = process.argv.slice(2);
|
|
113
143
|
const child = spawn(binaryPath, args, { stdio: 'inherit' });
|
|
114
|
-
child.on('exit', (code) =>
|
|
115
|
-
process.exit(code);
|
|
116
|
-
});
|
|
144
|
+
child.on('exit', (code) => process.exit(code));
|
|
117
145
|
} catch (err) {
|
|
118
146
|
process.stderr.write(`Error: ${err.message}\n`);
|
|
119
147
|
process.exit(1);
|
|
120
148
|
}
|
|
121
149
|
}
|
|
122
150
|
|
|
123
|
-
main();
|
|
151
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@the-17/agentsecrets",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "AI-native zero-knowledge secrets manager (CLI wrapper)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"secrets",
|
|
16
16
|
"security",
|
|
17
17
|
"credentials",
|
|
18
|
-
"cli"
|
|
18
|
+
"cli",
|
|
19
|
+
"ai-secrets-management"
|
|
19
20
|
],
|
|
20
21
|
"author": "The Seventeen <hello@theseventeen.co>",
|
|
21
22
|
"license": "MIT",
|