ambivalence 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ // Runs the platform binary, fetching it first if postinstall did not run (ignore-scripts).
3
+ const fs = require("fs");
4
+ const { spawnSync } = require("child_process");
5
+ const { install, dest } = require("./install.cjs");
6
+
7
+ (async () => {
8
+ if (!fs.existsSync(dest)) await install();
9
+ const r = spawnSync(dest, process.argv.slice(2), { stdio: "inherit" });
10
+ if (r.error) throw r.error;
11
+ process.exit(r.status === null ? 1 : r.status);
12
+ })().catch((e) => {
13
+ console.error("ambivalence: " + e.message);
14
+ process.exit(1);
15
+ });
package/install.cjs ADDED
@@ -0,0 +1,51 @@
1
+ // Downloads the ambivalence binary for this platform from the GitHub release named by
2
+ // binaryVersion and checks it against the release's checksums.txt. Runs at postinstall and,
3
+ // when install scripts are disabled, on the first `ambivalence` run (see cli.cjs).
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const crypto = require("crypto");
7
+ const https = require("https");
8
+
9
+ const version = require("./package.json").binaryVersion;
10
+ const os = { linux: "linux", darwin: "darwin", win32: "windows" }[process.platform];
11
+ const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
12
+ if (!os || !arch) throw new Error(`ambivalence has no binary for ${process.platform}/${process.arch}`);
13
+ const asset = `ambivalence-${os}-${arch}${os === "windows" ? ".exe" : ""}`;
14
+ const base = `https://github.com/Microck/ambivalence/releases/download/v${version}/`;
15
+ const dest = path.join(__dirname, "bin", os === "windows" ? "ambivalence.exe" : "ambivalence");
16
+
17
+ function get(url, redirects = 5) {
18
+ return new Promise((resolve, reject) => {
19
+ https.get(url, { headers: { "User-Agent": "ambivalence-npm" } }, (res) => {
20
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location && redirects > 0) {
21
+ res.resume();
22
+ return resolve(get(res.headers.location, redirects - 1));
23
+ }
24
+ if (res.statusCode !== 200) return reject(new Error(`GET ${url}: HTTP ${res.statusCode}`));
25
+ const chunks = [];
26
+ res.on("data", (c) => chunks.push(c));
27
+ res.on("end", () => resolve(Buffer.concat(chunks)));
28
+ }).on("error", reject);
29
+ });
30
+ }
31
+
32
+ async function install() {
33
+ const sums = (await get(base + "checksums.txt")).toString();
34
+ const line = sums.split("\n").find((l) => l.trim().endsWith(" " + asset));
35
+ if (!line) throw new Error(`${asset} is not listed in checksums.txt`);
36
+ const bin = await get(base + asset);
37
+ const got = crypto.createHash("sha256").update(bin).digest("hex");
38
+ if (got !== line.split(/\s+/)[0]) throw new Error(`checksum mismatch for ${asset}`);
39
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
40
+ fs.writeFileSync(dest + ".tmp", bin, { mode: 0o755 });
41
+ fs.renameSync(dest + ".tmp", dest); // never leave a half-written binary behind
42
+ }
43
+
44
+ module.exports = { install, dest };
45
+
46
+ if (require.main === module) {
47
+ install().catch((e) => {
48
+ console.error("ambivalence: install failed: " + e.message);
49
+ process.exit(1);
50
+ });
51
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "ambivalence",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
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": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Microck/ambivalence.git"
10
+ },
11
+ "keywords": [
12
+ "mcp",
13
+ "model-context-protocol",
14
+ "ai-agents",
15
+ "camera",
16
+ "phone",
17
+ "cli"
18
+ ],
19
+ "bin": {
20
+ "ambivalence": "cli.cjs"
21
+ },
22
+ "scripts": {
23
+ "postinstall": "node install.cjs"
24
+ },
25
+ "files": [
26
+ "cli.cjs",
27
+ "install.cjs"
28
+ ],
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "os": [
33
+ "linux",
34
+ "darwin",
35
+ "win32"
36
+ ],
37
+ "cpu": [
38
+ "x64",
39
+ "arm64"
40
+ ],
41
+ "binaryVersion": "0.1.0"
42
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.