@chorus-im/chorus 0.14.2
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/LICENSE +201 -0
- package/README.md +62 -0
- package/bin/chorus +24 -0
- package/bin/chorus-server +21 -0
- package/install.js +204 -0
- package/package.json +44 -0
- package/sha256s.json +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend, and
|
|
172
|
+
hold each Contributor harmless for any liability incurred by, or
|
|
173
|
+
claims asserted against, such Contributor by reason of your accepting
|
|
174
|
+
any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Chorus contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions
|
|
201
|
+
and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @chorus-im/chorus
|
|
2
|
+
|
|
3
|
+
npm distribution of the [Chorus](https://github.com/Fullstop000/Chorus) CLI + bridge daemon. Installs the matching prebuilt native binaries from the project's GitHub release; ships no compiled code itself.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
Run without installing globally:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx -y @chorus-im/chorus@latest bridge --host chorus.example.com --token chrs_bridge_…
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or install into a project / globally:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm i -g @chorus-im/chorus
|
|
17
|
+
chorus --help
|
|
18
|
+
chorus-server --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What you get
|
|
22
|
+
|
|
23
|
+
Two binaries, dropped under this package's `bin/` directory after `postinstall`:
|
|
24
|
+
|
|
25
|
+
- `chorus` — CLI + bridge daemon (run agents on this machine, talk to a remote platform).
|
|
26
|
+
- `chorus-server` — platform server (HTTP API + embedded UI).
|
|
27
|
+
|
|
28
|
+
## Supported platforms
|
|
29
|
+
|
|
30
|
+
The release matrix ships:
|
|
31
|
+
|
|
32
|
+
- Linux x64 (musl)
|
|
33
|
+
- Linux arm64 (musl)
|
|
34
|
+
- macOS arm64 (Apple Silicon)
|
|
35
|
+
|
|
36
|
+
Intel macOS and Windows are not in the matrix. On those targets the installer prints a build-from-source hint and exits non-zero.
|
|
37
|
+
|
|
38
|
+
## Versioning
|
|
39
|
+
|
|
40
|
+
The npm package version always matches a `v<version>` GitHub release tag. `npm i @chorus-im/chorus@0.14.1` downloads the binaries from `v0.14.1`.
|
|
41
|
+
|
|
42
|
+
## Publishing
|
|
43
|
+
|
|
44
|
+
Publishing is automated via [`.github/workflows/release.yml`](../.github/workflows/release.yml) — when a `v*` tag is pushed, the workflow builds the native release tarballs, attaches them to the GitHub release, then rewrites `npm/package.json`'s version from the tag and `npm publish --access public --provenance`. No hand-publish needed for ordinary releases.
|
|
45
|
+
|
|
46
|
+
One-time setup (operator):
|
|
47
|
+
|
|
48
|
+
1. Reserve the `@chorus-im` scope on npmjs.com (publish a first version manually if the scope is new).
|
|
49
|
+
2. Create an npm Automation token with publish permissions on the scope.
|
|
50
|
+
3. Add it to GitHub repo secrets as `NPM_TOKEN`.
|
|
51
|
+
|
|
52
|
+
Manual fallback (e.g. recovering from a workflow failure):
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cd npm
|
|
56
|
+
npm version 0.14.x --no-git-tag-version # match a published GH tag
|
|
57
|
+
npm publish --access public
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
Apache 2.0 — see [LICENSE](./LICENSE).
|
package/bin/chorus
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Shim — re-exec the native `chorus` binary that postinstall dropped
|
|
3
|
+
// next to this file. Splitting the npm-side name (`chorus`) from the
|
|
4
|
+
// native name (`chorus-native`) means npm's `bin` symlinks land on this
|
|
5
|
+
// JS file, and the JS file knows where the actual binary lives without
|
|
6
|
+
// guessing.
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const path = require('node:path');
|
|
11
|
+
const { spawnSync } = require('node:child_process');
|
|
12
|
+
const fs = require('node:fs');
|
|
13
|
+
|
|
14
|
+
const bin = path.join(__dirname, 'chorus-native');
|
|
15
|
+
if (!fs.existsSync(bin)) {
|
|
16
|
+
console.error(
|
|
17
|
+
'chorus: native binary missing. The postinstall step probably did not run.\n' +
|
|
18
|
+
'Try: npm rebuild @chorus-im/chorus (or pass --foreground-scripts on install)',
|
|
19
|
+
);
|
|
20
|
+
process.exit(127);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const r = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
24
|
+
process.exit(r.status ?? 1);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Shim — re-exec the native `chorus-server` binary dropped by
|
|
3
|
+
// postinstall. See bin/chorus for the design notes.
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const { spawnSync } = require('node:child_process');
|
|
9
|
+
const fs = require('node:fs');
|
|
10
|
+
|
|
11
|
+
const bin = path.join(__dirname, 'chorus-server-native');
|
|
12
|
+
if (!fs.existsSync(bin)) {
|
|
13
|
+
console.error(
|
|
14
|
+
'chorus-server: native binary missing. The postinstall step probably did not run.\n' +
|
|
15
|
+
'Try: npm rebuild @chorus-im/chorus (or pass --foreground-scripts on install)',
|
|
16
|
+
);
|
|
17
|
+
process.exit(127);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const r = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
21
|
+
process.exit(r.status ?? 1);
|
package/install.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Postinstall: pull the matching Chorus release tarball from GitHub,
|
|
3
|
+
// verify SHA-256, and drop the native binaries next to this script.
|
|
4
|
+
// The bin/ shims in this package re-exec those native binaries.
|
|
5
|
+
//
|
|
6
|
+
// Mirrors the platform matching of install.sh:
|
|
7
|
+
// Linux x64 → x86_64-unknown-linux-musl
|
|
8
|
+
// Linux arm64 → aarch64-unknown-linux-musl
|
|
9
|
+
// macOS arm64 → aarch64-apple-darwin
|
|
10
|
+
// Everything else errors with a build-from-source hint.
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const fs = require('node:fs');
|
|
15
|
+
const path = require('node:path');
|
|
16
|
+
const https = require('node:https');
|
|
17
|
+
const crypto = require('node:crypto');
|
|
18
|
+
const { execFileSync } = require('node:child_process');
|
|
19
|
+
const os = require('node:os');
|
|
20
|
+
|
|
21
|
+
const REPO = 'Fullstop000/Chorus';
|
|
22
|
+
const pkg = require('./package.json');
|
|
23
|
+
const VERSION = pkg.version;
|
|
24
|
+
const TAG = `v${VERSION}`;
|
|
25
|
+
|
|
26
|
+
function targetTriple() {
|
|
27
|
+
const p = process.platform;
|
|
28
|
+
const a = process.arch;
|
|
29
|
+
if (p === 'linux' && a === 'x64') return 'x86_64-unknown-linux-musl';
|
|
30
|
+
if (p === 'linux' && a === 'arm64') return 'aarch64-unknown-linux-musl';
|
|
31
|
+
if (p === 'darwin' && a === 'arm64') return 'aarch64-apple-darwin';
|
|
32
|
+
if (p === 'darwin' && a === 'x64') {
|
|
33
|
+
console.error(
|
|
34
|
+
'Intel macOS is not in the Chorus release matrix. Install from source:\n' +
|
|
35
|
+
` cargo install --git https://github.com/${REPO} --bin chorus --bin chorus-server\n`,
|
|
36
|
+
);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
console.error(`Unsupported platform: ${p} ${a}. Browse releases: https://github.com/${REPO}/releases/latest`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Cap redirect depth to defend against a malicious / misconfigured
|
|
44
|
+
// upstream returning an infinite 30x chain (stack overflow → ugly
|
|
45
|
+
// install failure). GH → S3 is one hop in practice; 10 is generous.
|
|
46
|
+
const MAX_REDIRECTS = 10;
|
|
47
|
+
|
|
48
|
+
function fetchToFileOnce(url, destPath, redirectsLeft = MAX_REDIRECTS) {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
const req = https.get(url, { headers: { 'user-agent': `@chorus-im/chorus@${VERSION}` } }, (res) => {
|
|
51
|
+
// Follow GitHub's `releases/download/...` redirect chain to S3.
|
|
52
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
53
|
+
res.resume();
|
|
54
|
+
if (redirectsLeft <= 0) {
|
|
55
|
+
reject(new Error(`too many redirects fetching ${url}`));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
fetchToFileOnce(res.headers.location, destPath, redirectsLeft - 1).then(resolve, reject);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (res.statusCode !== 200) {
|
|
62
|
+
res.resume();
|
|
63
|
+
reject(new Error(`GET ${url} → HTTP ${res.statusCode}`));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const out = fs.createWriteStream(destPath);
|
|
67
|
+
res.pipe(out);
|
|
68
|
+
out.on('finish', () => out.close((err) => (err ? reject(err) : resolve())));
|
|
69
|
+
out.on('error', reject);
|
|
70
|
+
res.on('error', reject);
|
|
71
|
+
});
|
|
72
|
+
req.on('error', reject);
|
|
73
|
+
req.setTimeout(30_000, () => req.destroy(new Error('request timed out')));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Real-world postinstall hits transient network blips (corporate
|
|
78
|
+
// proxies, flaky WiFi, GH/S3 hiccups). One failed GET shouldn't poison
|
|
79
|
+
// the whole install, so retry with backoff on connection-level errors.
|
|
80
|
+
async function fetchToFile(url, destPath, { tries = 4, baseMs = 750 } = {}) {
|
|
81
|
+
let lastErr;
|
|
82
|
+
for (let attempt = 1; attempt <= tries; attempt++) {
|
|
83
|
+
try {
|
|
84
|
+
await fetchToFileOnce(url, destPath);
|
|
85
|
+
return;
|
|
86
|
+
} catch (err) {
|
|
87
|
+
lastErr = err;
|
|
88
|
+
const retryable =
|
|
89
|
+
err.code === 'ECONNRESET' ||
|
|
90
|
+
err.code === 'ETIMEDOUT' ||
|
|
91
|
+
err.code === 'EAI_AGAIN' ||
|
|
92
|
+
/timed out|socket hang up/i.test(err.message);
|
|
93
|
+
if (!retryable || attempt === tries) break;
|
|
94
|
+
const delay = baseMs * 2 ** (attempt - 1);
|
|
95
|
+
console.error(`@chorus-im/chorus: GET ${url} failed (${err.message}); retry ${attempt}/${tries - 1} in ${delay}ms`);
|
|
96
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
throw lastErr;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function sha256File(p) {
|
|
103
|
+
const h = crypto.createHash('sha256');
|
|
104
|
+
h.update(fs.readFileSync(p));
|
|
105
|
+
return h.digest('hex');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Load the embedded {asset_filename: sha256_hex} map. The release
|
|
109
|
+
// workflow writes this file at npm-publish time so the expected hash
|
|
110
|
+
// is anchored by `npm publish --provenance`. Absent file = misbuilt
|
|
111
|
+
// publish; bail rather than silently fall back to fetching .sha256
|
|
112
|
+
// from the same release (the weaker mode that lets a GH-release
|
|
113
|
+
// tamper-and-swap succeed).
|
|
114
|
+
function loadEmbeddedShaMap() {
|
|
115
|
+
const p = path.join(__dirname, 'sha256s.json');
|
|
116
|
+
if (!fs.existsSync(p)) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
'sha256s.json is missing — this @chorus-im/chorus build was not ' +
|
|
119
|
+
'produced by the release workflow. Refusing to install. ' +
|
|
120
|
+
'Report at https://github.com/Fullstop000/Chorus/issues',
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
return JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
125
|
+
} catch (err) {
|
|
126
|
+
throw new Error(`failed to parse bundled sha256s.json: ${err.message}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function main() {
|
|
131
|
+
const target = targetTriple();
|
|
132
|
+
const asset = `chorus-${TAG}-${target}.tar.gz`;
|
|
133
|
+
const baseUrl = `https://github.com/${REPO}/releases/download/${TAG}/${asset}`;
|
|
134
|
+
|
|
135
|
+
const pkgDir = __dirname;
|
|
136
|
+
const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'chorus-npm-'));
|
|
137
|
+
const tarballPath = path.join(tmpRoot, asset);
|
|
138
|
+
const shaPath = `${tarballPath}.sha256`;
|
|
139
|
+
const binDest = path.join(pkgDir, 'bin');
|
|
140
|
+
fs.mkdirSync(binDest, { recursive: true });
|
|
141
|
+
|
|
142
|
+
// SHA-256 is sourced from `sha256s.json` bundled inside this npm
|
|
143
|
+
// package, written at npm-publish time by the release workflow
|
|
144
|
+
// BEFORE the package was pushed to the registry. This means the
|
|
145
|
+
// expected hash is anchored by `npm publish --provenance` — an
|
|
146
|
+
// attacker who later swaps GH release assets can't also swap the
|
|
147
|
+
// hash, because the hash lives inside the immutable npm artifact.
|
|
148
|
+
// Old behavior (fetch sibling .sha256 from the same release) would
|
|
149
|
+
// happily verify a coordinated swap.
|
|
150
|
+
const shaMap = loadEmbeddedShaMap();
|
|
151
|
+
const declared = shaMap[asset];
|
|
152
|
+
if (!declared) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
`no embedded SHA-256 for ${asset}; refusing to install. ` +
|
|
155
|
+
`This npm release was published for a different binary set.`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
console.log(`@chorus-im/chorus ${VERSION}: fetching ${target} from ${baseUrl}`);
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
await fetchToFile(baseUrl, tarballPath);
|
|
163
|
+
|
|
164
|
+
const actual = sha256File(tarballPath);
|
|
165
|
+
if (declared.toLowerCase() !== actual.toLowerCase()) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`SHA-256 mismatch for ${asset}: embedded=${declared} actual=${actual}. ` +
|
|
168
|
+
`Refusing to install — GH release may have been tampered with.`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Use the system `tar` — pulling in a JS tar library would balloon
|
|
173
|
+
// the install size for what's a one-time extraction.
|
|
174
|
+
const extractDir = path.join(tmpRoot, 'extract');
|
|
175
|
+
fs.mkdirSync(extractDir, { recursive: true });
|
|
176
|
+
execFileSync('tar', ['-xzf', tarballPath, '-C', extractDir, '--strip-components=1'], {
|
|
177
|
+
stdio: ['ignore', 'ignore', 'inherit'],
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
for (const name of ['chorus', 'chorus-server']) {
|
|
181
|
+
const src = path.join(extractDir, name);
|
|
182
|
+
const dst = path.join(binDest, `${name}-native`);
|
|
183
|
+
if (!fs.existsSync(src)) {
|
|
184
|
+
throw new Error(`tarball missing expected binary: ${name}`);
|
|
185
|
+
}
|
|
186
|
+
fs.copyFileSync(src, dst);
|
|
187
|
+
fs.chmodSync(dst, 0o755);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
console.log(`@chorus-im/chorus ${VERSION}: installed ${target} binaries`);
|
|
191
|
+
} finally {
|
|
192
|
+
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// CI environments sometimes set `npm_config_ignore_scripts=true`. In that
|
|
197
|
+
// case postinstall doesn't run; surface a clear message if the bin is
|
|
198
|
+
// invoked without the native binary present. The shims handle the user-
|
|
199
|
+
// facing path; here we just attempt install and let errors propagate.
|
|
200
|
+
main().catch((err) => {
|
|
201
|
+
console.error(`@chorus-im/chorus install failed: ${err.message}`);
|
|
202
|
+
console.error(`Browse releases manually: https://github.com/${REPO}/releases/tag/${TAG}`);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chorus-im/chorus",
|
|
3
|
+
"version": "0.14.2",
|
|
4
|
+
"description": "Chorus CLI + bridge daemon — agent collaboration platform. Installs prebuilt native binaries from GitHub releases.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"chorus": "bin/chorus",
|
|
7
|
+
"chorus-server": "bin/chorus-server"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node install.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"install.js",
|
|
15
|
+
"sha256s.json",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"os": [
|
|
23
|
+
"linux",
|
|
24
|
+
"darwin"
|
|
25
|
+
],
|
|
26
|
+
"cpu": [
|
|
27
|
+
"x64",
|
|
28
|
+
"arm64"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/Fullstop000/Chorus.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/Fullstop000/Chorus",
|
|
35
|
+
"bugs": "https://github.com/Fullstop000/Chorus/issues",
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"keywords": [
|
|
38
|
+
"chorus",
|
|
39
|
+
"agents",
|
|
40
|
+
"ai",
|
|
41
|
+
"cli",
|
|
42
|
+
"bridge"
|
|
43
|
+
]
|
|
44
|
+
}
|
package/sha256s.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chorus-v0.14.2-x86_64-unknown-linux-musl.tar.gz": "27948620664fc21513b5cdc487e5bf46566a22a55319f2716d88d7d682b37319",
|
|
3
|
+
"chorus-v0.14.2-aarch64-unknown-linux-musl.tar.gz": "6399bd87bfb2eeba24810cd6a3fb9abeef02e40e7f0d959a3f6ea233dff53c20",
|
|
4
|
+
"chorus-v0.14.2-aarch64-apple-darwin.tar.gz": "b31a4a1b8b154ab6255196687710301b08e1fcda46d02d585dc32b0392002892"
|
|
5
|
+
}
|