agentscm 0.1.0-alpha.3 → 0.1.0-alpha.6
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/README.md +13 -3
- package/SHA256SUMS +5 -5
- package/THIRD_PARTY_NOTICES.md +2623 -312
- package/lib/install.js +56 -16
- package/package.json +1 -1
package/lib/install.js
CHANGED
|
@@ -3,18 +3,24 @@ const crypto = require('node:crypto');
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const os = require('node:os');
|
|
5
5
|
const path = require('node:path');
|
|
6
|
-
const {
|
|
6
|
+
const { spawnSync } = require('node:child_process');
|
|
7
7
|
|
|
8
8
|
const REPO = 'counterbranch/agentscm';
|
|
9
9
|
const SUMS_MAX = 64 * 1024;
|
|
10
10
|
const BINARY_MAX = 200 * 1024 * 1024;
|
|
11
|
+
const VERIFY_OUTPUT_MAX = 1024 * 1024;
|
|
11
12
|
const BUDGET_MS = 600_000; // overall, for both downloads
|
|
12
13
|
|
|
13
14
|
const NOTICE_TEXT = `npx agentscm downloads the AgentSCM release binary for your platform from
|
|
14
15
|
GitHub Releases, verifies its SHA-256 checksum and build provenance, and then
|
|
15
|
-
starts the setup guide. It does not run install scripts
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
starts the setup guide. It does not run install scripts. After verification it
|
|
17
|
+
marks that binary invocation as a verified install; the binary records one
|
|
18
|
+
installation indicator only after setup explains pseudonymous product telemetry
|
|
19
|
+
and the configured choice permits it. Disable this before any send with
|
|
20
|
+
\`--no-telemetry\`, \`AGENTSCM_TELEMETRY=off\`, or \`DO_NOT_TRACK=1\`.
|
|
21
|
+
The setup guide previews repository, hook and Hub changes; \`agentscm uninstall\`
|
|
22
|
+
reverses setup. Manage usage reporting with \`agentscm telemetry status\` and
|
|
23
|
+
\`agentscm telemetry off\`.`;
|
|
18
24
|
|
|
19
25
|
const TARGETS = {
|
|
20
26
|
'linux/x64': 'x86_64-unknown-linux-musl',
|
|
@@ -43,6 +49,11 @@ const TOP_LEVEL_FLAGS = new Set(['--version', '-V', '--help', '-h']);
|
|
|
43
49
|
const launchArgs = (args) =>
|
|
44
50
|
args.length === 0 || (args[0].startsWith('-') && !TOP_LEVEL_FLAGS.has(args[0])) ? ['quickstart', ...args] : args;
|
|
45
51
|
|
|
52
|
+
const verifiedInstallEnv = (environment = process.env) => ({
|
|
53
|
+
...environment,
|
|
54
|
+
AGENTSCM_VERIFIED_INSTALL: '1',
|
|
55
|
+
});
|
|
56
|
+
|
|
46
57
|
// Strict: every line must be `<64 lowercase hex> agentscm-<target>[.exe]`, and the asset appears exactly once.
|
|
47
58
|
function parseSums(text, target) {
|
|
48
59
|
const hashes = [];
|
|
@@ -104,22 +115,46 @@ function provenanceGap(run = spawnSync) {
|
|
|
104
115
|
return null;
|
|
105
116
|
}
|
|
106
117
|
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
const verboseInstall = () => process.env.AGENTSCM_INSTALL_VERBOSE === '1';
|
|
119
|
+
|
|
120
|
+
function showVerifyOutput(result) {
|
|
121
|
+
for (const output of [result.stdout, result.stderr]) {
|
|
122
|
+
if (output && output.trim()) console.error(output.trimEnd());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Throws if the attestation does not verify. Returns whether provenance was verified.
|
|
127
|
+
// gh output is captured so its success report and upgrade notices do not bury the setup prompt.
|
|
128
|
+
function checkProvenance(file, version, gap = provenanceGap(), run = spawnSync) {
|
|
109
129
|
if (gap) {
|
|
110
130
|
if (process.env.AGENTSCM_REQUIRE_PROVENANCE === '1') throw new Error(`AGENTSCM_REQUIRE_PROVENANCE=1 but ${gap}`);
|
|
111
|
-
|
|
112
|
-
return;
|
|
131
|
+
return false;
|
|
113
132
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
133
|
+
const result = run('gh', ghVerifyArgs(file, version), {
|
|
134
|
+
encoding: 'utf8',
|
|
135
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
136
|
+
maxBuffer: VERIFY_OUTPUT_MAX,
|
|
137
|
+
});
|
|
138
|
+
if (result.error || result.status !== 0) {
|
|
139
|
+
showVerifyOutput(result);
|
|
117
140
|
throw new Error('build provenance verification failed; not running the binary');
|
|
118
141
|
}
|
|
142
|
+
if (verboseInstall()) showVerifyOutput(result);
|
|
143
|
+
return true;
|
|
119
144
|
}
|
|
120
145
|
|
|
146
|
+
// The one-line report of what was actually checked.
|
|
147
|
+
const provenanceLine = (gap) => gap
|
|
148
|
+
? `Checked the SHA-256 checksum (provenance not checked: ${gap}).`
|
|
149
|
+
: 'Verified provenance with GitHub attestations. Set AGENTSCM_INSTALL_VERBOSE=1 for details.';
|
|
150
|
+
|
|
121
151
|
async function main(args) {
|
|
122
152
|
const version = require('../package.json').version;
|
|
153
|
+
// The package installs exactly its own version, so this matches the binary without a download.
|
|
154
|
+
if (args[0] === '--version' || args[0] === '-V') {
|
|
155
|
+
console.log(`agentscm ${version}`);
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
123
158
|
console.log(`${NOTICE_TEXT}\n`);
|
|
124
159
|
const target = targetFor(process.platform, process.arch);
|
|
125
160
|
if (!target) {
|
|
@@ -137,9 +172,9 @@ async function main(args) {
|
|
|
137
172
|
const parts = [];
|
|
138
173
|
await download(urlFor(version, 'SHA256SUMS'), SUMS_MAX, (c) => parts.push(c), signal);
|
|
139
174
|
sums = Buffer.concat(parts).toString('utf8');
|
|
140
|
-
console.log('Checksums from the GitHub release.');
|
|
175
|
+
if (verboseInstall()) console.log('Checksums from the GitHub release.');
|
|
141
176
|
} else {
|
|
142
|
-
console.log('Checksums from the npm package.');
|
|
177
|
+
if (verboseInstall()) console.log('Checksums from the npm package.');
|
|
143
178
|
}
|
|
144
179
|
const expected = parseSums(sums, target);
|
|
145
180
|
|
|
@@ -156,7 +191,7 @@ async function main(args) {
|
|
|
156
191
|
if (fs.existsSync(binary)) {
|
|
157
192
|
if (!matches(binary, expected)) throw new Error(`${binary} does not match the release checksum; delete it and retry`);
|
|
158
193
|
checkProvenance(binary, version, gap);
|
|
159
|
-
console.log(`Using the verified ${binary}`);
|
|
194
|
+
if (verboseInstall()) console.log(`Using the verified ${binary}`);
|
|
160
195
|
} else {
|
|
161
196
|
const tmp = path.join(dir, `.agentscm-${version}-${rand}.tmp`);
|
|
162
197
|
try {
|
|
@@ -192,9 +227,14 @@ async function main(args) {
|
|
|
192
227
|
}
|
|
193
228
|
}
|
|
194
229
|
|
|
195
|
-
|
|
230
|
+
console.log(provenanceLine(gap));
|
|
231
|
+
|
|
232
|
+
// This process-only assertion comes from the verified installer. The binary records an
|
|
233
|
+
// installation only after its disclosure/choice gates are effective; HTTP stays detached.
|
|
234
|
+
const env = verifiedInstallEnv();
|
|
235
|
+
const r = spawnSync(binary, launchArgs(args), { stdio: 'inherit', env });
|
|
196
236
|
if (r.error) throw r.error;
|
|
197
237
|
return r.status ?? 128 + (os.constants.signals[r.signal] ?? 0);
|
|
198
238
|
}
|
|
199
239
|
|
|
200
|
-
module.exports = { NOTICE_TEXT, targetFor, assetNameFor, installNames, urlFor, launchArgs, parseSums, sha256File, matches, localSums, ghVerifyArgs, provenanceGap, checkProvenance, main };
|
|
240
|
+
module.exports = { NOTICE_TEXT, targetFor, assetNameFor, installNames, urlFor, launchArgs, verifiedInstallEnv, parseSums, sha256File, matches, localSums, ghVerifyArgs, provenanceGap, checkProvenance, provenanceLine, main };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentscm",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"description": "Downloads, verifies and starts the AgentSCM release binary.",
|
|
5
5
|
"license": "FSL-1.1-ALv2",
|
|
6
6
|
"repository": {"type": "git", "url": "git+https://github.com/counterbranch/agentscm.git"},
|