@cohesivity/init 0.3.2 → 0.3.4
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/cli.js +20 -6
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -34,14 +34,16 @@ const flag = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : u
|
|
|
34
34
|
if (has('--help') || has('-h')) { help(); process.exit(0); }
|
|
35
35
|
|
|
36
36
|
// ── config ──────────────────────────────────────────────────────────────────
|
|
37
|
-
const PKG_VERSION = '0.3.
|
|
37
|
+
const PKG_VERSION = '0.3.4';
|
|
38
38
|
const BASE = (flag('--base') || process.env.COHESIVITY_BASE || 'https://cohesivity.ai').replace(/\/+$/, '');
|
|
39
39
|
|
|
40
40
|
// Machine id: one per machine, stored outside any project. A project's
|
|
41
41
|
// .cohesivity is per project, so a machine that runs setup in several projects
|
|
42
42
|
// owns several tenants; this is what tells the server they came from one setup
|
|
43
43
|
// rather than several unrelated people. Sent on genesis; the server issues one
|
|
44
|
-
//
|
|
44
|
+
// whenever it cannot verify what we sent — none at all, or an id gone stale
|
|
45
|
+
// because the signing secret rotated or the file was corrupted — and whatever
|
|
46
|
+
// it issues replaces what is on disk. Steady state is written once and reused.
|
|
45
47
|
const MACHINE_ID_HEADER = 'X-Cohesivity-Machine-Id';
|
|
46
48
|
const MACHINE_ID_DIR = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'cohesivity');
|
|
47
49
|
const MACHINE_ID_FILE = join(MACHINE_ID_DIR, 'machine-id');
|
|
@@ -63,7 +65,13 @@ const GENERIC = new Set('cli index main app run dist build bin lib libexec src o
|
|
|
63
65
|
|
|
64
66
|
function inferHarness() {
|
|
65
67
|
let pid = process.ppid;
|
|
66
|
-
|
|
68
|
+
// `pid >= 1`, not `pid > 1`: pid 1 must be EXAMINED, not merely used as the
|
|
69
|
+
// stop condition. On a normal machine pid 1 is init/systemd and the denylist
|
|
70
|
+
// rejects it anyway, but inside a microVM sandbox pid 1 IS the supervising
|
|
71
|
+
// harness — Claude web runs `/process_api --firecracker-init` there and
|
|
72
|
+
// spawns each command directly from it, so skipping pid 1 made every such
|
|
73
|
+
// sandbox report "none". Pid 1 reports parent 0, so the walk still ends.
|
|
74
|
+
for (let i = 0; i < 20 && pid >= 1; i++) {
|
|
67
75
|
let argv, ppid;
|
|
68
76
|
try {
|
|
69
77
|
argv = readFileSync(`/proc/${pid}/cmdline`, 'utf8').split('\0').filter(Boolean);
|
|
@@ -186,8 +194,10 @@ async function ensureTenant() {
|
|
|
186
194
|
if (machineId) headers[MACHINE_ID_HEADER] = machineId;
|
|
187
195
|
const res = await fetch(`${BASE}/api/genesis`, { method: 'POST', headers });
|
|
188
196
|
body = await res.text();
|
|
189
|
-
//
|
|
190
|
-
//
|
|
197
|
+
// Returned on any request that MINTED an id, which is when we sent none
|
|
198
|
+
// *or* when the id we sent no longer verifies (secret rotated, file
|
|
199
|
+
// corrupted). It is not "non-null exactly when we sent none" — assuming
|
|
200
|
+
// that is what left a machine pinned to a dead id forever.
|
|
191
201
|
issuedMachineId = res.headers.get(MACHINE_ID_HEADER);
|
|
192
202
|
} catch (e) {
|
|
193
203
|
log(`no tenant created (network: ${e.message}). Re-run to retry. The command is idempotent.`);
|
|
@@ -199,7 +209,11 @@ async function ensureTenant() {
|
|
|
199
209
|
}
|
|
200
210
|
writeFileSync(dotfile, body);
|
|
201
211
|
ensureGitignore();
|
|
202
|
-
|
|
212
|
+
// Store whatever the server issued. Its presence already means "we minted
|
|
213
|
+
// this for you", so gating on `!machineId` as well dropped every replacement
|
|
214
|
+
// a machine with a stale id was handed: it re-minted on every genesis, kept
|
|
215
|
+
// none of them, and each project became its own machine row.
|
|
216
|
+
if (issuedMachineId) writeMachineId(issuedMachineId);
|
|
203
217
|
log('created an ephemeral tenant -> ./.cohesivity');
|
|
204
218
|
}
|
|
205
219
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cohesivity/init",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Set up Cohesivity in a project: install the agent skill, create a managed backend tenant, write the project config. Run with `npx @cohesivity/init`.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|