@the-17/agentsecrets 1.0.0

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.
Files changed (2) hide show
  1. package/bin/agentsecrets.js +123 -0
  2. package/package.json +33 -0
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env node
2
+
3
+ const os = require('os');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { spawn } = require('child_process');
7
+ const https = require('https');
8
+ const zlib = require('zlib');
9
+ const tar = require('tar');
10
+
11
+ const VERSION = "1.0.0";
12
+ const GITHUB_REPO = "The-17/agentsecrets";
13
+
14
+ function getPlatformInfo() {
15
+ const platform = os.platform();
16
+ const arch = os.arch();
17
+
18
+ let osName = platform;
19
+ if (platform === 'win32') osName = 'windows';
20
+ if (platform === 'darwin') osName = 'darwin';
21
+ if (platform === 'linux') osName = 'linux';
22
+
23
+ let archName = 'amd64';
24
+ if (arch === 'x64') archName = 'amd64';
25
+ if (arch === 'arm64') archName = 'arm64';
26
+ if (arch === 'ia32') archName = '386';
27
+
28
+ return { osName, archName };
29
+ }
30
+
31
+ async function downloadFile(url, dest) {
32
+ return new Promise((resolve, reject) => {
33
+ const file = fs.createWriteStream(dest);
34
+ https.get(url, (response) => {
35
+ if (response.statusCode === 302 || response.statusCode === 301) {
36
+ downloadFile(response.headers.location, dest).then(resolve).catch(reject);
37
+ return;
38
+ }
39
+ if (response.statusCode !== 200) {
40
+ reject(new Error(`Failed to download: ${response.statusCode}`));
41
+ return;
42
+ }
43
+ response.pipe(file);
44
+ file.on('finish', () => {
45
+ file.close(resolve);
46
+ });
47
+ }).on('error', (err) => {
48
+ fs.unlink(dest, () => reject(err));
49
+ });
50
+ });
51
+ }
52
+
53
+ async function ensureBinary() {
54
+ const { osName, archName } = getPlatformInfo();
55
+ const baseDir = path.join(os.homedir(), '.agentsecrets', 'bin');
56
+ if (!fs.existsSync(baseDir)) {
57
+ fs.mkdirSync(baseDir, { recursive: true });
58
+ }
59
+
60
+ let binaryName = 'agentsecrets';
61
+ if (osName === 'windows') binaryName += '.exe';
62
+
63
+ const binaryPath = path.join(baseDir, `${binaryName}_${VERSION}`);
64
+
65
+ if (fs.existsSync(binaryPath)) {
66
+ return binaryPath;
67
+ }
68
+
69
+ process.stderr.write(`AgentSecrets binary not found. Downloading version ${VERSION} for ${osName}/${archName}...\n`);
70
+
71
+ const ext = osName === 'windows' ? 'zip' : 'tar.gz';
72
+ const assetName = `agentsecrets_${VERSION}_${osName}_${archName}.${ext}`;
73
+ const url = `https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${assetName}`;
74
+
75
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsecrets-'));
76
+ const archivePath = path.join(tmpDir, assetName);
77
+
78
+ try {
79
+ await downloadFile(url, archivePath);
80
+
81
+ if (ext === 'tar.gz') {
82
+ await tar.x({
83
+ file: archivePath,
84
+ cwd: tmpDir
85
+ });
86
+ } 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
+ if (osName === 'windows') {
92
+ throw new Error("Automatic zip extraction for Windows not yet implemented in zero-dep script. Please install via Go or pip.");
93
+ }
94
+ }
95
+
96
+ const extractedBinary = path.join(tmpDir, binaryName);
97
+ fs.copyFileSync(extractedBinary, binaryPath);
98
+ fs.chmodSync(binaryPath, 0o755);
99
+
100
+ // Cleanup
101
+ fs.rmSync(tmpDir, { recursive: true, force: true });
102
+
103
+ return binaryPath;
104
+ } catch (err) {
105
+ throw new Error(`Failed to download AgentSecrets binary: ${err.message}`);
106
+ }
107
+ }
108
+
109
+ async function main() {
110
+ try {
111
+ const binaryPath = await ensureBinary();
112
+ const args = process.argv.slice(2);
113
+ const child = spawn(binaryPath, args, { stdio: 'inherit' });
114
+ child.on('exit', (code) => {
115
+ process.exit(code);
116
+ });
117
+ } catch (err) {
118
+ process.stderr.write(`Error: ${err.message}\n`);
119
+ process.exit(1);
120
+ }
121
+ }
122
+
123
+ main();
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@the-17/agentsecrets",
3
+ "version": "1.0.0",
4
+ "description": "AI-native zero-knowledge secrets manager (CLI wrapper)",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "agentsecrets": "bin/agentsecrets.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [
13
+ "ai",
14
+ "agents",
15
+ "secrets",
16
+ "security",
17
+ "credentials",
18
+ "cli"
19
+ ],
20
+ "author": "The Seventeen <hello@theseventeen.co>",
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/The-17/agentsecrets.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/The-17/agentsecrets/issues"
28
+ },
29
+ "homepage": "https://github.com/The-17/agentsecrets#readme",
30
+ "engines": {
31
+ "node": ">=14.0.0"
32
+ }
33
+ }