ambivalence 0.0.0-stage → 0.1.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.
- package/cli.cjs +11 -0
- package/install.cjs +43 -0
- package/package.json +13 -4
- package/README.md +0 -3
package/cli.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs the binary install.cjs downloaded, passing arguments, stdio and exit code through.
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
const bin = path.join(__dirname, "bin", process.platform === "win32" ? "ambivalence.exe" : "ambivalence");
|
|
6
|
+
const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
7
|
+
if (r.error) {
|
|
8
|
+
console.error("ambivalence: binary missing, reinstall the package (" + r.error.message + ")");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
process.exit(r.status === null ? 1 : r.status);
|
package/install.cjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Downloads the ambivalence binary for this platform from the GitHub release matching this
|
|
2
|
+
// package version and checks it against the release's checksums.txt.
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const crypto = require("crypto");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
|
|
8
|
+
const version = require("./package.json").version;
|
|
9
|
+
const os = { linux: "linux", darwin: "darwin", win32: "windows" }[process.platform];
|
|
10
|
+
const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
|
|
11
|
+
if (!os || !arch) throw new Error(`ambivalence has no binary for ${process.platform}/${process.arch}`);
|
|
12
|
+
const asset = `ambivalence-${os}-${arch}${os === "windows" ? ".exe" : ""}`;
|
|
13
|
+
const base = `https://github.com/Microck/ambivalence/releases/download/v${version}/`;
|
|
14
|
+
const dest = path.join(__dirname, "bin", os === "windows" ? "ambivalence.exe" : "ambivalence");
|
|
15
|
+
|
|
16
|
+
function get(url, redirects = 5) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
https.get(url, { headers: { "User-Agent": "ambivalence-npm" } }, (res) => {
|
|
19
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location && redirects > 0) {
|
|
20
|
+
res.resume();
|
|
21
|
+
return resolve(get(res.headers.location, redirects - 1));
|
|
22
|
+
}
|
|
23
|
+
if (res.statusCode !== 200) return reject(new Error(`GET ${url}: HTTP ${res.statusCode}`));
|
|
24
|
+
const chunks = [];
|
|
25
|
+
res.on("data", (c) => chunks.push(c));
|
|
26
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
27
|
+
}).on("error", reject);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
(async () => {
|
|
32
|
+
const sums = (await get(base + "checksums.txt")).toString();
|
|
33
|
+
const line = sums.split("\n").find((l) => l.trim().endsWith(" " + asset));
|
|
34
|
+
if (!line) throw new Error(`${asset} is not listed in checksums.txt`);
|
|
35
|
+
const bin = await get(base + asset);
|
|
36
|
+
const got = crypto.createHash("sha256").update(bin).digest("hex");
|
|
37
|
+
if (got !== line.split(/\s+/)[0]) throw new Error(`checksum mismatch for ${asset}`);
|
|
38
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
39
|
+
fs.writeFileSync(dest, bin, { mode: 0o755 });
|
|
40
|
+
})().catch((e) => {
|
|
41
|
+
console.error("ambivalence: install failed: " + e.message);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ambivalence",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "give your coding agent a camera: your phone. pair once over mcp or cli, found on your wi-fi, end-to-end encrypted",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/Microck/ambivalence",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/Microck/ambivalence.git" },
|
|
8
|
+
"keywords": ["mcp", "model-context-protocol", "ai-agents", "camera", "phone", "cli"],
|
|
9
|
+
"bin": { "ambivalence": "cli.cjs" },
|
|
10
|
+
"scripts": { "postinstall": "node install.cjs" },
|
|
11
|
+
"files": ["cli.cjs", "install.cjs"],
|
|
12
|
+
"engines": { "node": ">=18" },
|
|
13
|
+
"os": ["linux", "darwin", "win32"],
|
|
14
|
+
"cpu": ["x64", "arm64"]
|
|
15
|
+
}
|
package/README.md
DELETED