@beyondidentity/ceros-cli 0.1.941
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.txt +6 -0
- package/README.md +53 -0
- package/THIRD_PARTY_LICENSES.txt +201 -0
- package/bin/ceros.js +20 -0
- package/index.js +85 -0
- package/install.js +415 -0
- package/package.json +35 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Beyond Identity Proprietary License
|
|
2
|
+
Copyright © 2026 Beyond Identity. All rights reserved.
|
|
3
|
+
|
|
4
|
+
Usage Terms: Your use of this software binary is governed by the SaaS agreement accessible at: https://www.company.com/terms-and-conditions
|
|
5
|
+
|
|
6
|
+
Important Note: This software is proprietary and is not licensed under any open-source license. You may not redistribute, reverse engineer, or modify this binary without express written permission.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @beyondidentity/ceros-cli
|
|
2
|
+
|
|
3
|
+
Beyond Identity Ceros CLI - unified command-line interface for AI agent operations.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Proxy Management** (`ceros proxy`): Start, stop, and manage the local proxy service
|
|
8
|
+
- **Auth Flow** (`ceros auth`): Beyond Identity authentication helper
|
|
9
|
+
- **Launch** (`ceros launch`): Launch programs with auth configured
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install globally
|
|
15
|
+
npm install -g @beyondidentity/ceros-cli
|
|
16
|
+
|
|
17
|
+
# Or use directly with npx
|
|
18
|
+
npx @beyondidentity/ceros-cli --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Show all commands
|
|
25
|
+
ceros --help
|
|
26
|
+
|
|
27
|
+
# Proxy commands
|
|
28
|
+
ceros proxy start # Start local proxy
|
|
29
|
+
ceros proxy info # Show proxy status
|
|
30
|
+
ceros proxy stop # Stop local proxy
|
|
31
|
+
|
|
32
|
+
# Auth flow
|
|
33
|
+
ceros auth --help
|
|
34
|
+
|
|
35
|
+
# Launch programs
|
|
36
|
+
ceros launch --help
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Platform Support
|
|
40
|
+
|
|
41
|
+
Supports macOS (Intel/ARM), Linux (x64/ARM64), and Windows (x64).
|
|
42
|
+
|
|
43
|
+
## Architecture
|
|
44
|
+
|
|
45
|
+
This shim package automatically installs the correct platform binary via npm's `optionalDependencies` mechanism. Platform-specific binaries are published as separate packages:
|
|
46
|
+
|
|
47
|
+
- `@beyondidentity/ceros-cli-darwin-arm64`
|
|
48
|
+
- `@beyondidentity/ceros-cli-darwin-x64`
|
|
49
|
+
- `@beyondidentity/ceros-cli-linux-x64`
|
|
50
|
+
- `@beyondidentity/ceros-cli-linux-arm64`
|
|
51
|
+
- `@beyondidentity/ceros-cli-win32-x64`
|
|
52
|
+
|
|
53
|
+
If `optionalDependencies` installation fails, a postinstall script will attempt to download the binary as a fallback.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
THIRD-PARTY SOFTWARE LICENSES
|
|
2
|
+
|
|
3
|
+
This software includes the following third-party components:
|
|
4
|
+
|
|
5
|
+
================================================================================
|
|
6
|
+
OpenSSL 3.x
|
|
7
|
+
================================================================================
|
|
8
|
+
|
|
9
|
+
Copyright (c) 1998-2024 The OpenSSL Project Authors
|
|
10
|
+
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
|
11
|
+
All rights reserved.
|
|
12
|
+
|
|
13
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
you may not use this file except in compliance with the License.
|
|
15
|
+
You may obtain a copy of the License at
|
|
16
|
+
|
|
17
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
|
|
19
|
+
Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
See the License for the specific language governing permissions and
|
|
23
|
+
limitations under the License.
|
|
24
|
+
|
|
25
|
+
--------------------------------------------------------------------------------
|
|
26
|
+
Apache License
|
|
27
|
+
Version 2.0, January 2004
|
|
28
|
+
http://www.apache.org/licenses/
|
|
29
|
+
|
|
30
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
31
|
+
|
|
32
|
+
1. Definitions.
|
|
33
|
+
|
|
34
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
35
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
36
|
+
|
|
37
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
38
|
+
the copyright owner that is granting the License.
|
|
39
|
+
|
|
40
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
41
|
+
other entities that control, are controlled by, or are under common
|
|
42
|
+
control with that entity. For the purposes of this definition,
|
|
43
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
44
|
+
direction or management of such entity, whether by contract or
|
|
45
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
46
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
47
|
+
|
|
48
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
49
|
+
exercising permissions granted by this License.
|
|
50
|
+
|
|
51
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
52
|
+
including but not limited to software source code, documentation
|
|
53
|
+
source, and configuration files.
|
|
54
|
+
|
|
55
|
+
"Object" form shall mean any form resulting from mechanical
|
|
56
|
+
transformation or translation of a Source form, including but
|
|
57
|
+
not limited to compiled object code, generated documentation,
|
|
58
|
+
and conversions to other media types.
|
|
59
|
+
|
|
60
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
61
|
+
Object form, made available under the License, as indicated by a
|
|
62
|
+
copyright notice that is included in or attached to the work
|
|
63
|
+
(an example is provided in the Appendix below).
|
|
64
|
+
|
|
65
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
66
|
+
form, that is based on (or derived from) the Work and for which the
|
|
67
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
68
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
69
|
+
of this License, Derivative Works shall not include works that remain
|
|
70
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
71
|
+
the Work and Derivative Works thereof.
|
|
72
|
+
|
|
73
|
+
"Contribution" shall mean any work of authorship, including
|
|
74
|
+
the original version of the Work and any modifications or additions
|
|
75
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
76
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
77
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
78
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
79
|
+
means any form of electronic, verbal, or written communication sent
|
|
80
|
+
to the Licensor or its representatives, including but not limited to
|
|
81
|
+
communication on electronic mailing lists, source code control systems,
|
|
82
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
83
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
84
|
+
excluding communication that is conspicuously marked or otherwise
|
|
85
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
86
|
+
|
|
87
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
88
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
89
|
+
subsequently incorporated within the Work.
|
|
90
|
+
|
|
91
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
92
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
93
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
94
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
95
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
96
|
+
Work and such Derivative Works in Source or Object form.
|
|
97
|
+
|
|
98
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
99
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
100
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
101
|
+
(except as stated in this section) patent license to make, have made,
|
|
102
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
103
|
+
where such license applies only to those patent claims licensable
|
|
104
|
+
by such Contributor that are necessarily infringed by their
|
|
105
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
106
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
107
|
+
institute patent litigation against any entity (including a
|
|
108
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
109
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
110
|
+
or contributory patent infringement, then any patent licenses
|
|
111
|
+
granted to You under this License for that Work shall terminate
|
|
112
|
+
as of the date such litigation is filed.
|
|
113
|
+
|
|
114
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
115
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
116
|
+
modifications, and in Source or Object form, provided that You
|
|
117
|
+
meet the following conditions:
|
|
118
|
+
|
|
119
|
+
(a) You must give any other recipients of the Work or
|
|
120
|
+
Derivative Works a copy of this License; and
|
|
121
|
+
|
|
122
|
+
(b) You must cause any modified files to carry prominent notices
|
|
123
|
+
stating that You changed the files; and
|
|
124
|
+
|
|
125
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
126
|
+
that You distribute, all copyright, patent, trademark, and
|
|
127
|
+
attribution notices from the Source form of the Work,
|
|
128
|
+
excluding those notices that do not pertain to any part of
|
|
129
|
+
the Derivative Works; and
|
|
130
|
+
|
|
131
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
132
|
+
distribution, then any Derivative Works that You distribute must
|
|
133
|
+
include a readable copy of the attribution notices contained
|
|
134
|
+
within such NOTICE file, excluding those notices that do not
|
|
135
|
+
pertain to any part of the Derivative Works, in at least one
|
|
136
|
+
of the following places: within a NOTICE text file distributed
|
|
137
|
+
as part of the Derivative Works; within the Source form or
|
|
138
|
+
documentation, if provided along with the Derivative Works; or,
|
|
139
|
+
within a display generated by the Derivative Works, if and
|
|
140
|
+
wherever such third-party notices normally appear. The contents
|
|
141
|
+
of the NOTICE file are for informational purposes only and
|
|
142
|
+
do not modify the License. You may add Your own attribution
|
|
143
|
+
notices within Derivative Works that You distribute, alongside
|
|
144
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
145
|
+
that such additional attribution notices cannot be construed
|
|
146
|
+
as modifying the License.
|
|
147
|
+
|
|
148
|
+
You may add Your own copyright statement to Your modifications and
|
|
149
|
+
may provide additional or different license terms and conditions
|
|
150
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
151
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
152
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
153
|
+
the conditions stated in this License.
|
|
154
|
+
|
|
155
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
156
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
157
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
158
|
+
this License, without any additional terms or conditions.
|
|
159
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
160
|
+
the terms of any separate license agreement you may have executed
|
|
161
|
+
with Licensor regarding such Contributions.
|
|
162
|
+
|
|
163
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
164
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
165
|
+
except as required for reasonable and customary use in describing the
|
|
166
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
167
|
+
|
|
168
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
169
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
170
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
171
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
172
|
+
implied, including, without limitation, any warranties or conditions
|
|
173
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
174
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
175
|
+
appropriateness of using or redistributing the Work and assume any
|
|
176
|
+
risks associated with Your exercise of permissions under this License.
|
|
177
|
+
|
|
178
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
179
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
180
|
+
unless required by applicable law (such as deliberate and grossly
|
|
181
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
182
|
+
liable to You for damages, including any direct, indirect, special,
|
|
183
|
+
incidental, or consequential damages of any character arising as a
|
|
184
|
+
result of this License or out of the use or inability to use the
|
|
185
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
186
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
187
|
+
other commercial damages or losses), even if such Contributor
|
|
188
|
+
has been advised of the possibility of such damages.
|
|
189
|
+
|
|
190
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
191
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
192
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
193
|
+
or other liability obligations and/or rights consistent with this
|
|
194
|
+
License. However, in accepting such obligations, You may act only
|
|
195
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
196
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
197
|
+
defend, and hold each Contributor harmless for any liability
|
|
198
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
199
|
+
of your accepting any such warranty or additional liability.
|
|
200
|
+
|
|
201
|
+
END OF TERMS AND CONDITIONS
|
package/bin/ceros.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Execute the binary via index.js
|
|
4
|
+
const { getBinaryPath } = require("../index.js");
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
const binaryPath = getBinaryPath();
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
|
|
10
|
+
// Execute binary directly - blocks until process exits
|
|
11
|
+
require("child_process").execFileSync(binaryPath, args, {
|
|
12
|
+
stdio: "inherit",
|
|
13
|
+
});
|
|
14
|
+
} catch (error) {
|
|
15
|
+
// Print error message if it's not from execFileSync
|
|
16
|
+
if (!error.status) {
|
|
17
|
+
console.error(error.message);
|
|
18
|
+
}
|
|
19
|
+
process.exit(error.status || 1);
|
|
20
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { existsSync } = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
// Detect current platform
|
|
6
|
+
function getPlatform() {
|
|
7
|
+
const platform = process.platform;
|
|
8
|
+
const arch = process.arch;
|
|
9
|
+
|
|
10
|
+
const platformMap = {
|
|
11
|
+
darwin: "darwin",
|
|
12
|
+
linux: "linux",
|
|
13
|
+
win32: "win32",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const archMap = {
|
|
17
|
+
x64: "x64",
|
|
18
|
+
arm64: "arm64",
|
|
19
|
+
arm: "arm",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const mappedPlatform = platformMap[platform];
|
|
23
|
+
const mappedArch = archMap[arch];
|
|
24
|
+
|
|
25
|
+
if (!mappedPlatform || !mappedArch) {
|
|
26
|
+
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return `${mappedPlatform}-${mappedArch}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Get binary path
|
|
33
|
+
function getBinaryPath() {
|
|
34
|
+
const platform = getPlatform();
|
|
35
|
+
const binaryName = process.platform === "win32" ? "ceros.exe" : "ceros";
|
|
36
|
+
|
|
37
|
+
// Strategy 1: Try platform-specific package (installed as optionalDependency)
|
|
38
|
+
const platformPackage = `@beyondidentity/ai-cli-${platform}`;
|
|
39
|
+
try {
|
|
40
|
+
const platformPath = require.resolve(`${platformPackage}/bin/${binaryName}`);
|
|
41
|
+
if (existsSync(platformPath)) {
|
|
42
|
+
return platformPath;
|
|
43
|
+
}
|
|
44
|
+
} catch (e) {
|
|
45
|
+
// Platform package not found, try fallback
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Strategy 2: Try fallback binary (downloaded by postinstall script)
|
|
49
|
+
const fallbackPath = path.join(__dirname, "bin", binaryName);
|
|
50
|
+
if (existsSync(fallbackPath)) {
|
|
51
|
+
return fallbackPath;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Neither strategy worked
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Could not find binary for platform ${platform}.\n` +
|
|
57
|
+
`Tried:\n` +
|
|
58
|
+
` 1. Platform package: ${platformPackage}\n` +
|
|
59
|
+
` 2. Fallback download: ${fallbackPath}\n` +
|
|
60
|
+
`Make sure optionalDependencies are enabled or postinstall script ran successfully.\n` +
|
|
61
|
+
`For more information, contact Beyond Identity support.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Export for programmatic use
|
|
66
|
+
module.exports = { getBinaryPath, getPlatform };
|
|
67
|
+
|
|
68
|
+
// Execute if run directly
|
|
69
|
+
if (require.main === module) {
|
|
70
|
+
try {
|
|
71
|
+
const binaryPath = getBinaryPath();
|
|
72
|
+
const args = process.argv.slice(2);
|
|
73
|
+
|
|
74
|
+
// Execute binary directly - blocks until process exits
|
|
75
|
+
require("child_process").execFileSync(binaryPath, args, {
|
|
76
|
+
stdio: "inherit",
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
// Print error message if it's not from execFileSync
|
|
80
|
+
if (!error.status) {
|
|
81
|
+
console.error(error.message);
|
|
82
|
+
}
|
|
83
|
+
process.exit(error.status || 1);
|
|
84
|
+
}
|
|
85
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const https = require("https");
|
|
6
|
+
const http = require("http");
|
|
7
|
+
const zlib = require("zlib");
|
|
8
|
+
const { execSync } = require("child_process");
|
|
9
|
+
|
|
10
|
+
// Check if running in CI environment
|
|
11
|
+
const isCI = process.env.CI === "true" || process.env.CI === "1";
|
|
12
|
+
|
|
13
|
+
// Logging helpers
|
|
14
|
+
function log(...args) {
|
|
15
|
+
if (!isCI) {
|
|
16
|
+
console.log(...args);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function logProgress(message) {
|
|
21
|
+
if (!isCI) {
|
|
22
|
+
process.stdout.write(`\r${message}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Detect current platform
|
|
27
|
+
function getPlatform() {
|
|
28
|
+
const platform = process.platform;
|
|
29
|
+
const arch = process.arch;
|
|
30
|
+
|
|
31
|
+
const platformMap = {
|
|
32
|
+
darwin: "darwin",
|
|
33
|
+
linux: "linux",
|
|
34
|
+
win32: "win32",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const archMap = {
|
|
38
|
+
x64: "x64",
|
|
39
|
+
arm64: "arm64",
|
|
40
|
+
arm: "arm",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const mappedPlatform = platformMap[platform];
|
|
44
|
+
const mappedArch = archMap[arch];
|
|
45
|
+
|
|
46
|
+
if (!mappedPlatform || !mappedArch) {
|
|
47
|
+
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return `${mappedPlatform}-${mappedArch}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check if optional dependency is already installed
|
|
54
|
+
function checkOptionalDependency(platformPackage, binaryName) {
|
|
55
|
+
try {
|
|
56
|
+
const platformPath = require.resolve(`${platformPackage}/bin/${binaryName}`);
|
|
57
|
+
if (fs.existsSync(platformPath)) {
|
|
58
|
+
log(`✓ Platform package ${platformPackage} already installed`);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// Platform package not found
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Check if fallback binary already exists and is valid
|
|
68
|
+
function checkFallbackBinary(binaryPath) {
|
|
69
|
+
if (fs.existsSync(binaryPath)) {
|
|
70
|
+
try {
|
|
71
|
+
fs.accessSync(binaryPath, fs.constants.X_OK);
|
|
72
|
+
log("✓ Fallback binary already exists and is executable");
|
|
73
|
+
return true;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
// Binary exists but not executable, re-download
|
|
76
|
+
log("Existing fallback binary is invalid, re-downloading...");
|
|
77
|
+
fs.unlinkSync(binaryPath);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Check write permissions for bin directory
|
|
84
|
+
function checkWritePermissions() {
|
|
85
|
+
const binDir = path.join(__dirname, "bin");
|
|
86
|
+
try {
|
|
87
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
88
|
+
const testFile = path.join(binDir, ".write-test");
|
|
89
|
+
fs.writeFileSync(testFile, "test");
|
|
90
|
+
fs.unlinkSync(testFile);
|
|
91
|
+
return true;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (error.code === "EACCES") {
|
|
94
|
+
console.warn("⚠ Warning: No write permissions for bin/ directory");
|
|
95
|
+
console.warn("Run with appropriate permissions or contact your system administrator");
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Construct download URL based on registry
|
|
103
|
+
function constructDownloadUrl(packageName, version, registryUrl) {
|
|
104
|
+
// Extract package name without scope for tarball filename
|
|
105
|
+
const tarballName = packageName.split("/").pop();
|
|
106
|
+
|
|
107
|
+
return `${registryUrl}/${packageName}/-/${tarballName}-${version}.tgz`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Download file with progress indication
|
|
111
|
+
function downloadBinary(url, destPath, options = {}) {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
const protocol = url.startsWith("https") ? https : http;
|
|
114
|
+
|
|
115
|
+
log(`Downloading from: ${url}`);
|
|
116
|
+
|
|
117
|
+
const requestOptions = {
|
|
118
|
+
headers: options.headers || {},
|
|
119
|
+
timeout: options.timeout || 30000,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const request = protocol.get(url, requestOptions, response => {
|
|
123
|
+
// Handle redirects
|
|
124
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
125
|
+
log(`Following redirect to: ${response.headers.location}`);
|
|
126
|
+
return downloadBinary(response.headers.location, destPath, options).then(resolve).catch(reject);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Handle authentication errors
|
|
130
|
+
if (response.statusCode === 401 || response.statusCode === 403) {
|
|
131
|
+
return reject(
|
|
132
|
+
new Error(
|
|
133
|
+
"Authentication required. Package not found in public registry.\n" +
|
|
134
|
+
"This package may be in a private registry. Use npm/pnpm/yarn for installation,\n" +
|
|
135
|
+
"which will handle authentication automatically via your .npmrc configuration."
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (response.statusCode !== 200) {
|
|
141
|
+
return reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const totalBytes = parseInt(response.headers["content-length"], 10);
|
|
145
|
+
let downloadedBytes = 0;
|
|
146
|
+
|
|
147
|
+
// Progress logging
|
|
148
|
+
response.on("data", chunk => {
|
|
149
|
+
downloadedBytes += chunk.length;
|
|
150
|
+
if (totalBytes) {
|
|
151
|
+
const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
|
|
152
|
+
logProgress(`Downloading: ${percent}% (${downloadedBytes}/${totalBytes} bytes)`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const fileStream = fs.createWriteStream(destPath);
|
|
157
|
+
response.pipe(fileStream);
|
|
158
|
+
|
|
159
|
+
fileStream.on("finish", () => {
|
|
160
|
+
fileStream.close();
|
|
161
|
+
if (!isCI) {
|
|
162
|
+
process.stdout.write("\n");
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Verify download completeness
|
|
166
|
+
if (totalBytes && downloadedBytes !== totalBytes) {
|
|
167
|
+
fs.unlinkSync(destPath);
|
|
168
|
+
return reject(new Error(`Incomplete download: ${downloadedBytes}/${totalBytes} bytes`));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
log("✓ Download complete");
|
|
172
|
+
resolve();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
fileStream.on("error", err => {
|
|
176
|
+
fs.unlinkSync(destPath);
|
|
177
|
+
reject(err);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
request.on("error", reject);
|
|
182
|
+
request.on("timeout", () => {
|
|
183
|
+
request.destroy();
|
|
184
|
+
reject(new Error("Download timeout"));
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Download with retry logic
|
|
190
|
+
async function downloadWithRetry(url, destPath, options = {}, maxRetries = 3) {
|
|
191
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
192
|
+
try {
|
|
193
|
+
await downloadBinary(url, destPath, options);
|
|
194
|
+
return;
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (attempt === maxRetries) {
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
const delay = Math.pow(2, attempt) * 1000; // 2s, 4s, 8s
|
|
200
|
+
console.warn(`\n⚠ Download failed (attempt ${attempt}/${maxRetries}): ${error.message}`);
|
|
201
|
+
console.warn(`Retrying in ${delay / 1000}s...`);
|
|
202
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Extract a specific file from a tar.gz archive
|
|
208
|
+
// Implements manual tar parsing to avoid external dependencies
|
|
209
|
+
// Tar format: 512-byte blocks, alternating header and data blocks
|
|
210
|
+
function extractFileFromTarball(tarballBuffer, targetFilename) {
|
|
211
|
+
const BLOCK_SIZE = 512;
|
|
212
|
+
let offset = 0;
|
|
213
|
+
|
|
214
|
+
while (offset < tarballBuffer.length) {
|
|
215
|
+
// Read header block
|
|
216
|
+
const header = tarballBuffer.slice(offset, offset + BLOCK_SIZE);
|
|
217
|
+
|
|
218
|
+
// Check if we've reached the end (two zero blocks)
|
|
219
|
+
if (header.every(byte => byte === 0)) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Extract filename (bytes 0-99, null-terminated)
|
|
224
|
+
const filenameBuffer = header.slice(0, 100);
|
|
225
|
+
const nullIndex = filenameBuffer.indexOf(0);
|
|
226
|
+
const filename = filenameBuffer.slice(0, nullIndex > 0 ? nullIndex : 100).toString("utf8");
|
|
227
|
+
|
|
228
|
+
// Extract file size (bytes 124-135, octal string)
|
|
229
|
+
const sizeStr = header.slice(124, 136).toString("utf8").trim().replace(/\0/g, "");
|
|
230
|
+
const fileSize = parseInt(sizeStr, 8) || 0;
|
|
231
|
+
|
|
232
|
+
// Move to data blocks
|
|
233
|
+
offset += BLOCK_SIZE;
|
|
234
|
+
|
|
235
|
+
// Check if this is the file we're looking for
|
|
236
|
+
if (filename === targetFilename || filename.endsWith("/" + targetFilename)) {
|
|
237
|
+
// Extract file data
|
|
238
|
+
const fileData = tarballBuffer.slice(offset, offset + fileSize);
|
|
239
|
+
return fileData;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Skip to next header (file data is padded to 512-byte boundary)
|
|
243
|
+
const dataBlocks = Math.ceil(fileSize / BLOCK_SIZE);
|
|
244
|
+
offset += dataBlocks * BLOCK_SIZE;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Download using npm pack (uses npm's authentication)
|
|
251
|
+
function downloadViaPackageManager(platformPackage, binaryName) {
|
|
252
|
+
log("Using package manager to download platform package...");
|
|
253
|
+
|
|
254
|
+
const npmExecPath = process.env.npm_execpath;
|
|
255
|
+
if (!npmExecPath) {
|
|
256
|
+
throw new Error("npm executable path not found");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
try {
|
|
260
|
+
// Use npm pack to download the tarball
|
|
261
|
+
// npm pack automatically uses .npmrc authentication
|
|
262
|
+
log(`Running: npm pack ${platformPackage}`);
|
|
263
|
+
|
|
264
|
+
const output = execSync(`"${npmExecPath}" pack ${platformPackage}`, {
|
|
265
|
+
encoding: "utf8",
|
|
266
|
+
cwd: __dirname,
|
|
267
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// npm pack outputs the tarball filename
|
|
271
|
+
const tarballFilename = output.trim().split("\n").pop();
|
|
272
|
+
const tarballPath = path.join(__dirname, tarballFilename);
|
|
273
|
+
|
|
274
|
+
if (!fs.existsSync(tarballPath)) {
|
|
275
|
+
throw new Error(`Tarball not found: ${tarballPath}`);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
log(`✓ Downloaded: ${tarballFilename}`);
|
|
279
|
+
|
|
280
|
+
// Extract the binary
|
|
281
|
+
extractBinary(tarballPath, binaryName);
|
|
282
|
+
|
|
283
|
+
return true;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
throw new Error(`npm pack failed: ${error.message}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Extract binary from tarball
|
|
290
|
+
function extractBinary(tarballPath, binaryName) {
|
|
291
|
+
const extractDir = path.join(__dirname, "bin");
|
|
292
|
+
|
|
293
|
+
try {
|
|
294
|
+
// Create bin directory
|
|
295
|
+
fs.mkdirSync(extractDir, { recursive: true });
|
|
296
|
+
|
|
297
|
+
log("Extracting tarball...");
|
|
298
|
+
|
|
299
|
+
// Read and decompress the .tgz file
|
|
300
|
+
const compressedData = fs.readFileSync(tarballPath);
|
|
301
|
+
const tarData = zlib.gunzipSync(compressedData);
|
|
302
|
+
|
|
303
|
+
// Platform packages have structure: package/bin/{binary-name}
|
|
304
|
+
const targetPath = `package/bin/${binaryName}`;
|
|
305
|
+
|
|
306
|
+
// Extract the binary from the tar archive
|
|
307
|
+
const binaryData = extractFileFromTarball(tarData, targetPath);
|
|
308
|
+
|
|
309
|
+
if (!binaryData) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`Binary '${binaryName}' not found in downloaded package.\n` +
|
|
312
|
+
`Expected at: ${targetPath}\n` +
|
|
313
|
+
`This may indicate a packaging issue.`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Write binary to final location
|
|
318
|
+
const destBinary = path.join(extractDir, binaryName);
|
|
319
|
+
fs.writeFileSync(destBinary, binaryData);
|
|
320
|
+
|
|
321
|
+
// Set executable permissions
|
|
322
|
+
fs.chmodSync(destBinary, 0o755);
|
|
323
|
+
|
|
324
|
+
log(`✓ Binary extracted to: ${destBinary}`);
|
|
325
|
+
|
|
326
|
+
// Cleanup tarball
|
|
327
|
+
fs.unlinkSync(tarballPath);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
// Cleanup on error
|
|
330
|
+
if (fs.existsSync(tarballPath)) {
|
|
331
|
+
fs.unlinkSync(tarballPath);
|
|
332
|
+
}
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Main installation logic
|
|
338
|
+
async function main() {
|
|
339
|
+
try {
|
|
340
|
+
const platform = getPlatform();
|
|
341
|
+
const binaryName = process.platform === "win32" ? "ceros.exe" : "ceros";
|
|
342
|
+
const platformPackage = `@beyondidentity/ai-cli-${platform}`;
|
|
343
|
+
|
|
344
|
+
// Check if optionalDependency already installed
|
|
345
|
+
if (checkOptionalDependency(platformPackage, binaryName)) {
|
|
346
|
+
process.exit(0);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Check if fallback binary already exists
|
|
350
|
+
const fallbackBinaryPath = path.join(__dirname, "bin", binaryName);
|
|
351
|
+
if (checkFallbackBinary(fallbackBinaryPath)) {
|
|
352
|
+
process.exit(0);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
log(`Platform package ${platformPackage} not found, attempting fallback download...`);
|
|
356
|
+
|
|
357
|
+
// Check write permissions
|
|
358
|
+
if (!checkWritePermissions()) {
|
|
359
|
+
process.exit(0);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Strategy 1: If npm is available, use npm pack (handles auth automatically)
|
|
363
|
+
if (process.env.npm_execpath) {
|
|
364
|
+
log("Detected npm package manager");
|
|
365
|
+
try {
|
|
366
|
+
downloadViaPackageManager(platformPackage, binaryName);
|
|
367
|
+
log("✓ Fallback installation complete via npm");
|
|
368
|
+
process.exit(0);
|
|
369
|
+
} catch (npmError) {
|
|
370
|
+
console.warn(`\n⚠ npm pack failed: ${npmError.message}`);
|
|
371
|
+
console.warn("Falling back to direct HTTPS download...");
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
log("npm not detected, using direct HTTPS download");
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Strategy 2: Direct HTTPS download (for non-npm package managers)
|
|
378
|
+
const pkgJson = require("./package.json");
|
|
379
|
+
const version = pkgJson.version;
|
|
380
|
+
const registryUrl = pkgJson.registryUrl || process.env.NPM_REGISTRY_URL || "https://registry.npmjs.org";
|
|
381
|
+
|
|
382
|
+
log(`Registry: ${registryUrl}`);
|
|
383
|
+
log(`Version: ${version}`);
|
|
384
|
+
|
|
385
|
+
// Construct download URL
|
|
386
|
+
const downloadUrl = constructDownloadUrl(platformPackage, version, registryUrl);
|
|
387
|
+
|
|
388
|
+
// Download tarball (assumes public registry, no auth needed)
|
|
389
|
+
const tarballPath = path.join(__dirname, `.temp-${platform}.tgz`);
|
|
390
|
+
await downloadWithRetry(downloadUrl, tarballPath);
|
|
391
|
+
|
|
392
|
+
// Extract binary (synchronous)
|
|
393
|
+
extractBinary(tarballPath, binaryName);
|
|
394
|
+
|
|
395
|
+
log("✓ Fallback installation complete via HTTPS");
|
|
396
|
+
process.exit(0);
|
|
397
|
+
} catch (error) {
|
|
398
|
+
console.warn("\n⚠ Warning: Fallback binary download failed");
|
|
399
|
+
console.warn(`Error: ${error.message}`);
|
|
400
|
+
console.warn("\nThe package may not work correctly on this platform.");
|
|
401
|
+
console.warn("Please ensure optionalDependencies are enabled in your package manager.");
|
|
402
|
+
console.warn("For more information, see the README or visit:");
|
|
403
|
+
console.warn("https://gitlab.byndid.com/ai/ai-agents");
|
|
404
|
+
|
|
405
|
+
// Don't fail the install - just warn
|
|
406
|
+
process.exit(0);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Run if executed directly
|
|
411
|
+
if (require.main === module) {
|
|
412
|
+
main();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
module.exports = { getPlatform, constructDownloadUrl, extractFileFromTarball };
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beyondidentity/ceros-cli",
|
|
3
|
+
"version": "0.1.941+b6c0354d",
|
|
4
|
+
"description": "Beyond Identity Ceros CLI - unified command interface to the Ceros Platform",
|
|
5
|
+
"keywords": ["beyondidentity", "ai", "cli", "ceros"],
|
|
6
|
+
"license": "SEE LICENSE in LICENSE.txt",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ceros": "./bin/ceros.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "./index.js",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"postinstall": "node install.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.js",
|
|
16
|
+
"install.js",
|
|
17
|
+
"bin/ceros.js",
|
|
18
|
+
"LICENSE.txt",
|
|
19
|
+
"THIRD_PARTY_LICENSES.txt"
|
|
20
|
+
],
|
|
21
|
+
"optionalDependencies": {
|
|
22
|
+
"@beyondidentity/ceros-cli-linux-x64": "0.1.941+b6c0354d",
|
|
23
|
+
"@beyondidentity/ceros-cli-darwin-arm64": "0.1.941+b6c0354d",
|
|
24
|
+
"@beyondidentity/ceros-cli-darwin-x64": "0.1.941+b6c0354d"
|
|
25
|
+
},
|
|
26
|
+
"_commentedOutPlatforms": {
|
|
27
|
+
"_note": "These platforms are not yet supported but reserved for future use",
|
|
28
|
+
"_linux-arm64": "@beyondidentity/ceros-cli-linux-arm64",
|
|
29
|
+
"_win32-x64": "@beyondidentity/ceros-cli-win32-x64"
|
|
30
|
+
},
|
|
31
|
+
"registryUrl": "https://npm.cloudsmith.io/beyond-identity/ai-agents-npm",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
}
|
|
35
|
+
}
|