@agent-journal/cli 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/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # @agent-journal/cli
2
+
3
+ NPM wrapper for the Agent Journal member CLI.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @agent-journal/cli
9
+ ```
10
+
11
+ If global install fails with `EACCES`, configure npm to use a user-owned prefix
12
+ and add its `bin` directory to `PATH` instead of using `sudo npm install`.
13
+
14
+ ## Use
15
+
16
+ ```bash
17
+ agent-journal init --base-url https://your-service.example <invite_code>
18
+ agent-journal start
19
+ agent-journal status
20
+ ```
21
+
22
+ For local debugging:
23
+
24
+ ```bash
25
+ agent-journal run
26
+ ```
27
+
28
+ To stop and remove the background agent:
29
+
30
+ ```bash
31
+ agent-journal uninstall
32
+ ```
33
+
34
+ After a manual npm upgrade, restart the background service so it points at the
35
+ managed runtime under `~/.agent-journal/current`:
36
+
37
+ ```bash
38
+ npm install -g @agent-journal/cli@latest
39
+ agent-journal restart
40
+ agent-journal status
41
+ ```
42
+
43
+ To check or apply a managed update published by the service:
44
+
45
+ ```bash
46
+ agent-journal update --check
47
+ agent-journal update --apply
48
+ ```
49
+
50
+ `--apply` downloads the selected artifact, verifies its sha256 and signature,
51
+ installs it under `~/.agent-journal/versions/<version>`, switches
52
+ `~/.agent-journal/current`, and restarts the managed service when one is
53
+ installed.
54
+
55
+ If the service rollout has auto apply disabled, the background agent records the
56
+ available update and `agent-journal status` prints the target version; it will
57
+ not download or execute the artifact until `agent-journal update --apply` runs.
58
+
59
+ ## Publishing
60
+
61
+ The production publishing path is GitHub Actions Trusted Publishing. Configure
62
+ the npm package trusted publisher with:
63
+
64
+ - Package: `@agent-journal/cli`
65
+ - Publisher: GitHub Actions
66
+ - Repository owner: `Bloomingg`
67
+ - Repository name: `agent-journal`
68
+ - Workflow filename: `client-release.yml`
69
+ - Environment: empty unless the workflow is later bound to a GitHub environment
70
+
71
+ Then manually run the `Client Release` workflow. The workflow builds the
72
+ vendored binaries with `AGENT_JOURNAL_UPDATE_PUBLIC_KEY`, generates the signed
73
+ service release manifest with `AGENT_JOURNAL_UPDATE_PRIVATE_KEY_PEM`, publishes
74
+ the npm package through OIDC, uploads update artifacts, and registers release
75
+ metadata with the Agent Journal service.
76
+
77
+ The npm package is only the first-install bootstrap. After CI registers a
78
+ release, use Admin Release Center to publish it to `dev`, `beta`, or `stable`
79
+ and control rollout percentage, auto apply, forced update, pause, and rollback.
80
+
81
+ Local commands are for dry-run checks only:
82
+
83
+ ```bash
84
+ set -a
85
+ source ../../.env.update-signing
86
+ set +a
87
+ unset AGENT_JOURNAL_UPDATE_PRIVATE_KEY_PEM
88
+ npm test
89
+ npm run build:binaries
90
+ npm pack --dry-run --ignore-scripts
91
+ ```
92
+
93
+ The npm package only needs `AGENT_JOURNAL_UPDATE_PUBLIC_KEY`. Do not leave
94
+ `AGENT_JOURNAL_UPDATE_PRIVATE_KEY_PEM` in the environment for `npm publish`;
95
+ the private key is only needed when generating a signed service release
96
+ manifest.
97
+
98
+ The CI publish step uses `npm publish --ignore-scripts` after a single explicit
99
+ binary build. This avoids `prepack` rebuilding the npm package binaries after
100
+ the signed release artifacts have already been generated.
101
+
102
+ Set `AGENT_JOURNAL_UPDATE_PUBLIC_KEY` when building release binaries so managed
103
+ updates can verify service-provided artifact signatures:
104
+
105
+ ```bash
106
+ AGENT_JOURNAL_UPDATE_PUBLIC_KEY="<base64-ed25519-public-key>" npm run build:binaries
107
+ ```
108
+
109
+ After uploading the built binaries to release storage, generate the service
110
+ registration payload:
111
+
112
+ ```bash
113
+ set -a
114
+ source ../../.env.update-signing
115
+ set +a
116
+ AGENT_JOURNAL_ARTIFACT_BASE_URL="https://updates.example.com/agent-journal/0.1.0" \
117
+ npm run release:manifest
118
+ ```
119
+
120
+ The generated `dist/release-manifest.json` can be POSTed to
121
+ `/api/v1/admin/client-releases`. The script also copies release-named binaries
122
+ to `dist/artifacts/` so CI can upload files whose names match the manifest URLs.
123
+
124
+ `release:local` runs the npm wrapper tests, builds the vendored binaries with package version, git commit, UTC build time metadata, and the optional update public key, then performs an `npm pack --dry-run`.
125
+
126
+ The package includes binaries for macOS arm64/x64, Windows x64, and Linux x64.
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const { spawnSync } = require("node:child_process");
7
+ const { targetFor } = require("../lib/platform");
8
+
9
+ function binaryPath() {
10
+ const target = targetFor();
11
+ return path.join(__dirname, "..", "vendor", target.dir, target.exe);
12
+ }
13
+
14
+ const bin = binaryPath();
15
+ if (!fs.existsSync(bin)) {
16
+ console.error(`agent-journal binary is missing for ${process.platform}/${process.arch}: ${bin}`);
17
+ console.error("Reinstall the npm package, or run `npm run build:binaries` before packing/publishing.");
18
+ process.exit(1);
19
+ }
20
+
21
+ const result = spawnSync(bin, process.argv.slice(2), {
22
+ stdio: "inherit",
23
+ env: process.env,
24
+ windowsHide: false
25
+ });
26
+
27
+ if (result.error) {
28
+ console.error(result.error.message);
29
+ process.exit(1);
30
+ }
31
+ if (result.signal) {
32
+ process.kill(process.pid, result.signal);
33
+ }
34
+ process.exit(result.status ?? 1);
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ const SUPPORTED_TARGETS = [
4
+ { nodePlatform: "darwin", nodeArch: "arm64", goos: "darwin", goarch: "arm64", dir: "darwin-arm64", exe: "agent-journal" },
5
+ { nodePlatform: "darwin", nodeArch: "x64", goos: "darwin", goarch: "amd64", dir: "darwin-x64", exe: "agent-journal" },
6
+ { nodePlatform: "win32", nodeArch: "x64", goos: "windows", goarch: "amd64", dir: "win32-x64", exe: "agent-journal.exe" },
7
+ { nodePlatform: "linux", nodeArch: "x64", goos: "linux", goarch: "amd64", dir: "linux-x64", exe: "agent-journal" }
8
+ ];
9
+
10
+ function targetFor(platform = process.platform, arch = process.arch) {
11
+ const target = SUPPORTED_TARGETS.find((item) => item.nodePlatform === platform && item.nodeArch === arch);
12
+ if (!target) {
13
+ const supported = SUPPORTED_TARGETS.map((item) => `${item.nodePlatform}/${item.nodeArch}`).join(", ");
14
+ throw new Error(`Unsupported platform ${platform}/${arch}. Supported: ${supported}`);
15
+ }
16
+ return target;
17
+ }
18
+
19
+ module.exports = {
20
+ SUPPORTED_TARGETS,
21
+ targetFor
22
+ };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@agent-journal/cli",
3
+ "version": "0.1.0",
4
+ "description": "Agent Journal member CLI",
5
+ "license": "UNLICENSED",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Bloomingg/agent-journal.git",
9
+ "directory": "packages/agent-journal"
10
+ },
11
+ "bin": {
12
+ "agent-journal": "bin/agent-journal.js"
13
+ },
14
+ "files": [
15
+ "bin/",
16
+ "lib/",
17
+ "scripts/postinstall.js",
18
+ "vendor/",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build:binaries": "node scripts/build-binaries.js",
23
+ "prepack": "npm test && npm run build:binaries",
24
+ "postinstall": "node scripts/postinstall.js",
25
+ "prepack:dry-run": "npm pack --dry-run --ignore-scripts",
26
+ "release:manifest": "node scripts/create-release-manifest.js",
27
+ "release:local": "npm test && npm run build:binaries && npm pack --dry-run --ignore-scripts",
28
+ "test": "node scripts/test.js"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "engines": {
34
+ "node": ">=18"
35
+ }
36
+ }
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("node:fs");
5
+ const os = require("node:os");
6
+ const path = require("node:path");
7
+ const { targetFor } = require("../lib/platform");
8
+
9
+ const target = targetFor();
10
+ const bin = path.join(__dirname, "..", "vendor", target.dir, target.exe);
11
+
12
+ if (!fs.existsSync(bin)) {
13
+ console.error(`Missing agent-journal binary for ${process.platform}/${process.arch}.`);
14
+ console.error(`Expected: ${bin}`);
15
+ console.error("This package must be published after running `npm run build:binaries`.");
16
+ process.exit(1);
17
+ }
18
+
19
+ if (process.platform !== "win32") {
20
+ fs.chmodSync(bin, 0o755);
21
+ }
22
+
23
+ const home = os.homedir();
24
+ const launchAgent = path.join(home, "Library", "LaunchAgents", "com.agent-journal.agent.plist");
25
+ if (process.platform === "darwin" && fs.existsSync(launchAgent)) {
26
+ console.warn("agent-journal: background service detected.");
27
+ console.warn("agent-journal: run `agent-journal restart` after this npm update to switch the service to the installed version.");
28
+ }
29
+ if (process.platform === "win32") {
30
+ console.warn("agent-journal: if the background task is already installed, run `agent-journal restart` after this npm update.");
31
+ }
Binary file
Binary file