@nyex/nyex 0.1.2-beta

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 ADDED
@@ -0,0 +1,30 @@
1
+ # NYEX Commercial / Proprietary License
2
+
3
+ **Status:** Private Beta / Production Beta
4
+
5
+ NYEX is **not open source** at this time. Permission is granted only to approved users under the NYEX Terms of Use and any applicable Order Form.
6
+
7
+ ## Grant of license (summary)
8
+
9
+ Subject to your Subscription (if any) and compliance with the Terms of Use, you may download, install, and use NYEX for your internal business purposes during the term of your access.
10
+
11
+ ## Restrictions (summary)
12
+
13
+ You must not (and must not allow others to):
14
+
15
+ - reverse engineer, decompile, disassemble, or attempt to discover source code or underlying structure (except to the extent permitted by law)
16
+ - modify, translate, adapt, or create derivative works
17
+ - distribute, sublicense, rent, lease, sell, resell, or provide NYEX as a service bureau/managed service
18
+ - remove proprietary notices
19
+ - use NYEX to develop or improve a competing product or service
20
+ - bypass security, licensing, or approval controls
21
+
22
+ ## Governing terms
23
+
24
+ Your use of NYEX is governed by the **NYEX Terms of Use** in `TERMS_OF_USE.md` (and any referenced policies / Order Forms).
25
+
26
+ If there is any conflict between this summary and the Terms of Use, the Terms of Use control.
27
+
28
+ ---
29
+
30
+ AIC Pty Ltd (ACN 082 378 256) © NYEX AI Platform. All rights reserved.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # NYEX — AI Engineering Platform (Windows-first)
2
+
3
+ NYEX is a Windows-first AI Engineering CLI/TUI designed for serious builders who want **role-aware model routing**, **governed workflows**, and **local-first memory**—without turning your dev environment into a SaaS dependency.
4
+
5
+ This repo is currently in **private beta**.
6
+
7
+ ## Why NYEX exists
8
+
9
+ Most “AI coding tools” optimize for a single chat loop. NYEX is different: it treats AI like a **multi-role engineering team** (primary, intent, planner, tool_exec, summarizer) and gives you **control** over identity, routing, cost, and memory.
10
+
11
+ ## Key capabilities
12
+
13
+ - **NYEX Account gate (private beta)**
14
+ Register → Pending → Admin approval → Use NYEX.
15
+ - **Role-aware routing**
16
+ Route different tasks to different providers/models.
17
+ - **Local-first memory (lite backend)**
18
+ Built-in lightweight store for structured notes; future backends can be added.
19
+ - **Doctor / status diagnostics**
20
+ Validates real reachability (HTTP + JSON sanity) for critical endpoints.
21
+ - **Admin Control Panel**
22
+ Approve/disable users, revoke sessions, view activity, review private beta requests.
23
+ - **Security posture**
24
+ Rate-limited health endpoint, minimized public metadata, no secret leaks in logs, bypass hardened (release ignores bypass).
25
+
26
+ ## Install (private beta)
27
+
28
+ You’ll receive the installer/package via private distribution. Public install instructions are intentionally omitted.
29
+
30
+ ## First run (mental model)
31
+
32
+ NYEX has **two different auth layers**:
33
+
34
+ 1. **NYEX account** (platform identity and access control)
35
+ 2. **Provider access** (ChatGPT / API keys / Claude / Gemini) for the model provider you choose
36
+
37
+ NYEX will first ask you to **sign in / create a NYEX account**, then guide you to provider setup.
38
+
39
+ ## Configuration
40
+
41
+ NYEX uses `NYEX_HOME` as the only home directory.
42
+
43
+ - **Windows default**: `%USERPROFILE%\.nyex`
44
+ - You can override via env: `NYEX_HOME=E:\Nyex\_home`
45
+
46
+ Auth URL precedence (highest wins):
47
+
48
+ 1. `--nyex-auth-url` CLI flag
49
+ 2. `NYEX_AUTH_URL` env var
50
+ 3. `NYEX_HOME\config.toml` (`[nyex_auth].url`)
51
+ 4. Build-time default (`NYEX_DEFAULT_AUTH_URL`)
52
+ 5. Fallback: `http://localhost:8787`
53
+
54
+ ## Legal
55
+
56
+ - **Terms of Use**: see `TERMS_OF_USE.md`
57
+ - **License**: see `LICENSE.md`
58
+
59
+ ## Security disclosure
60
+
61
+ If you find a security issue, please report it privately (do not open a public issue). Contact details will be provided to testers.
62
+
63
+ ## Repo structure (high level)
64
+
65
+ - `core-rs/` — Rust CLI + TUI
66
+ - `auth-server/` — NYEX auth backend
67
+
68
+ ## Contributing
69
+
70
+ This is a private beta repo. Contributions are by invitation only. If you’re an approved tester and want to contribute, ask for access/branching rules.
71
+
72
+ ---
73
+
74
+ AIC Pty Ltd (ACN 082 378 256) © NYEX AI Platform. All rights reserved.
@@ -0,0 +1,294 @@
1
+ # TERMS OF USE – NYEX AI PLATFORM
2
+ **Effective date: 1 March 2026**
3
+
4
+ These Terms of Use (“Terms”) govern access to and use of the NYEX AI Platform, including any related software, installers, updates, documentation, websites, and services we provide (collectively, the “Platform”).
5
+
6
+ By clicking “Accept”, downloading, installing, accessing, or using the Platform, you agree to these Terms. If you do not agree, do not use the Platform.
7
+
8
+ If you are using the Platform on behalf of a company or organisation, you represent that you have authority to bind that organisation, and “you” and “Customer” refers to that organisation.
9
+
10
+ ## 1. Definitions
11
+
12
+ In these Terms:
13
+
14
+ “NYEX”, “NYEX AI”, “we”, “us”, or “our” means AIC Pty Ltd (ACN 082 378 256), a company duly incorporated and registered in New South Wales, Australia, trading as Digilabs Company and operating the NYEX AI Platform.
15
+
16
+ “Digilabs Company” is the business division and trading name under which AIC Pty Ltd develops and operates the NYEX AI Platform.
17
+
18
+ “Customer”, “you”, “your” means the person or organisation using the Platform.
19
+
20
+ “Authorised Users” means your employees, contractors, and consultants who you allow to use the Platform under your account and within your licence limits.
21
+
22
+ “Order Form” means an order form, statement of work, online checkout, or similar purchasing document that references these Terms.
23
+
24
+ “Customer Data” means data, content, files, prompts, instructions, and information provided by you or your Authorised Users through or in connection with the Platform, including configuration and workflow definitions, and any data received via Third Party Services at your direction.
25
+
26
+ “Outputs” means content generated by AI technologies via the Platform, including responses, summaries, code, recommendations, or actions taken based on your instructions.
27
+
28
+ “Third Party Services” means third-party services, models, APIs, tools, connectors, and providers you connect to or use with the Platform (including foundation LLM providers and other software/services).
29
+
30
+ “Subscription” means a paid plan, licence, or entitlement that allows use of certain Platform features.
31
+
32
+ ## 2. Our Relationship and Scope
33
+
34
+ 2.1 What we provide. The Platform is an AI engineering environment designed to help users build workflows, automation, and memory-enabled systems. The Platform may support local processing and optional connections to Third Party Services.
35
+
36
+ 2.2 Local-first architecture. Depending on your configuration, the Platform may store Customer Data locally on your systems (including local vector databases). You are responsible for your local environment, storage, and security controls (see Section 7).
37
+
38
+ 2.3 Third Party Services. If you connect the Platform to Third Party Services (including foundation LLM providers), you are contracting directly with those providers, and your use is subject to their terms, policies, and pricing.
39
+
40
+ ## 3. Eligibility, Authority, and Account Security
41
+
42
+ 3.1 Authority to use and share data. You represent and warrant that you have all rights, permissions, and authority necessary to:
43
+
44
+ (a) access and use the Platform; and (b) upload, submit, transmit, or otherwise provide Customer Data to the Platform and to any Third Party Services you connect.
45
+
46
+ ### 3.2 Account security. You are responsible for:
47
+
48
+ maintaining the confidentiality of access credentials and licence keys;
49
+
50
+ all activity under your account; and
51
+
52
+ ensuring Authorised Users comply with these Terms.
53
+
54
+ Notify us promptly if you suspect unauthorised access.
55
+
56
+ 3.3 Suspension for security or misuse. We may suspend or restrict access to the Platform (in whole or part) if we reasonably believe:
57
+
58
+ there is unauthorised access, security risk, or malware;
59
+
60
+ your use breaches these Terms or applicable law; or
61
+
62
+ suspension is needed to protect you, other customers, or the integrity of the Platform. We will take reasonable steps to notify you and restore access once the issue is resolved.
63
+
64
+ ## 4. Licence Grant and Restrictions
65
+
66
+ 4.1 Licence. Subject to your Subscription and these Terms, we grant you a limited, non-exclusive, non-transferable, non-sublicensable licence to download, install, and use the Platform during the Term for your internal business purposes.
67
+
68
+ 4.2 Authorised Users. You may permit Authorised Users to use the Platform solely on your behalf and within your Subscription limits. You remain responsible for their acts and omissions.
69
+
70
+ ### 4.3 Restrictions. You must not (and must not allow others to):
71
+
72
+ (a) reverse engineer, decompile, disassemble, or attempt to discover source code, algorithms, or underlying structure of the Platform (except to the extent permitted by law and only after giving us notice); (b) modify, translate, adapt, or create derivative works of the Platform; (c) rent, lease, sell, resell, distribute, or provide the Platform to third parties as a service bureau, managed service, or time-sharing arrangement (unless expressly agreed in writing); (d) remove or obscure proprietary notices; (e) use the Platform to develop or improve a competing product or service; (f) interfere with or disrupt the Platform, including attempting to bypass security or licensing controls; (g) use the Platform in a way that violates applicable law, infringes rights, or facilitates unlawful, harmful, or deceptive activity.
73
+
74
+ 4.4 Open source. The Platform may include open-source components governed by their own licences. To the extent there is a conflict, the open-source licence applies to those components.
75
+
76
+ ## 5. Orders, Subscriptions, and Payments
77
+
78
+ 5.1 Order Forms. If you purchase a Subscription, the Order Form sets out your plan, fees, term, and entitlements. Order Forms are incorporated into these Terms.
79
+
80
+ ### 5.2 Fees. You must pay all fees when due. Unless otherwise stated, fees are in [AUD/USD] and exclude taxes.
81
+
82
+ 5.3 Non-cancellable; non-refundable. Subscription fees are non-cancellable and non-refundable except where required by law or expressly stated in an Order Form.
83
+
84
+ ### 5.4 Late payments. Overdue amounts may accrue interest at the lesser of:
85
+
86
+ (a) 1.5% per month; or (b) the maximum amount permitted by law.
87
+
88
+ 5.5 Taxes. You are responsible for all taxes and duties associated with your purchase (including VAT/GST/sales tax), except taxes on our net income.
89
+
90
+ 5.6 Price changes. We may change pricing for renewal terms by giving at least 30 days’ notice before renewal, unless your Order Form states otherwise.
91
+
92
+ ## 6. Customer Data, Privacy, and Local Storage
93
+
94
+ ### 6.1 Customer Data ownership. As between you and NYEX, you retain all rights in Customer Data.
95
+
96
+ 6.2 Licence to process Customer Data. You grant NYEX a limited, worldwide, non-exclusive, royalty-free licence to process Customer Data only to:
97
+
98
+ (a) provide, maintain, secure, and support the Platform; (b) respond to support requests; (c) improve and develop the Platform; and (d) create Aggregated Data (see 6.3).
99
+
100
+ 6.3 Aggregated Data. We may create aggregated and/or de-identified data derived from Platform usage (for analytics, security, performance, and product improvement). Aggregated Data does not identify you or your users and is not Customer Data.
101
+
102
+ 6.4 Local-first responsibility. Where Customer Data is stored locally (including local vector databases), you are responsible for:
103
+
104
+ access controls and permissions;
105
+
106
+ backups and disaster recovery;
107
+
108
+ endpoint security and patching;
109
+
110
+ compliance with your internal policies and applicable law.
111
+
112
+ 6.5 Privacy. Our collection and handling of personal information is described in our Privacy Policy, which forms part of these Terms.
113
+
114
+ ## 7. Third Party Services (Including Foundation LLM Providers)
115
+
116
+ 7.1 Your relationship with Third Party Services. Third Party Services are provided under separate terms between you and the third party. You are responsible for reviewing and complying with those terms, including pricing, data use, retention, and security practices.
117
+
118
+ 7.2 No responsibility for third parties. We do not control Third Party Services and are not responsible for their availability, accuracy, security, data handling, or outages. You use them at your own risk.
119
+
120
+ 7.3 Data sent to Third Party Services. If you configure the Platform to send prompts, context, or data to a Third Party Service, you instruct the Platform to do so. You are responsible for deciding what data is shared and ensuring you have permission to share it.
121
+
122
+ ## 8. AI Outputs, Human Oversight, and Safety
123
+
124
+ 8.1 Outputs may be incorrect. Outputs may be inaccurate, incomplete, biased, non-unique, or unsuitable for your purposes. You must evaluate Outputs before relying on them.
125
+
126
+ 8.2 No professional advice. The Platform and Outputs are not legal, medical, financial, or other professional advice. You should obtain appropriate professional advice before acting.
127
+
128
+ 8.3 Safety and responsible use. You must not use the Platform to generate or distribute unlawful, harmful, deceptive, or infringing content, or to violate rights of others.
129
+
130
+ 8.4 Monitoring and audit. The Platform may provide traceability, memory inspection, and governance controls. You are responsible for configuring and using those controls appropriately.
131
+
132
+ ## 9. Support, Updates, and Availability
133
+
134
+ 9.1 Support. Support levels (if any) depend on your Subscription or Order Form. Free or trial use may include limited or community support.
135
+
136
+ 9.2 Updates. We may provide updates, patches, new features, and improvements. Some updates may be required to maintain security or compatibility.
137
+
138
+ 9.3 Availability. We aim to provide reliable access, but the Platform may be unavailable due to maintenance, updates, or events beyond our reasonable control. Scheduled maintenance may be notified in advance where reasonably practicable.
139
+
140
+ ## 10. Intellectual Property
141
+
142
+ 10.1 Our IP. We own all rights, title, and interest in the Platform, including software, design, trademarks, and related intellectual property, except for third-party and open-source components.
143
+
144
+ ### 10.2 No implied rights. Except as expressly granted, no rights are transferred to you.
145
+
146
+ 10.3 Your IP. You own your Customer Data and your internal workflows/content you create using the Platform, subject to third-party rights and these Terms.
147
+
148
+ ## 11. Confidentiality
149
+
150
+ 11.1 Confidential Information. Confidential Information includes non-public information disclosed by one party to the other, including business plans, pricing, technology, security information, and product roadmaps.
151
+
152
+ ### 11.2 Obligations. The receiving party must:
153
+
154
+ use Confidential Information only to perform under these Terms;
155
+
156
+ protect it with at least reasonable care; and
157
+
158
+ disclose it only to personnel/advisers who need to know and are bound by confidentiality obligations.
159
+
160
+ ### 11.3 Exclusions. Confidential Information does not include information that is:
161
+
162
+ publicly available through no breach;
163
+
164
+ independently developed without use of Confidential Information; or
165
+
166
+ received lawfully from a third party without restriction.
167
+
168
+ 11.4 Required disclosures. If disclosure is required by law, the receiving party will (where legally permitted) give notice and cooperate to limit disclosure.
169
+
170
+ ## 12. Warranties and Disclaimers
171
+
172
+ 12.1 Platform provided “as is.” Except as expressly stated in these Terms or an Order Form, the Platform is provided “as is” and we disclaim all implied warranties to the extent permitted by law.
173
+
174
+ 12.2 Consumer guarantees. If you are an Australian consumer and the Australian Consumer Law applies, you may have non-excludable rights. Nothing in these Terms excludes those rights.
175
+
176
+ 12.3 No guarantee of uninterrupted service. We do not guarantee the Platform will be error-free, uninterrupted, or completely secure.
177
+
178
+ ## 13. Limitation of Liability
179
+
180
+ 13.1 No indirect loss. To the maximum extent permitted by law, neither party is liable for indirect or consequential loss (including loss of profits, revenue, goodwill, or data).
181
+
182
+ 13.2 Liability cap. To the maximum extent permitted by law, each party’s total liability for all claims relating to the Platform or these Terms is limited to the fees paid (and payable) by you to NYEX in the 12 months before the event giving rise to the claim.
183
+
184
+ ### 13.3 Exceptions. The liability cap does not apply to:
185
+
186
+ your payment obligations;
187
+
188
+ your breach of confidentiality;
189
+
190
+ your infringement/misuse;
191
+
192
+ liability that cannot be excluded by law.
193
+
194
+ ## 14. Indemnities
195
+
196
+ 14.1 Our indemnity. We will indemnify you against third-party claims that the Platform infringes third-party intellectual property rights, provided you:
197
+
198
+ notify us promptly;
199
+
200
+ allow us to control the defence and settlement; and
201
+
202
+ cooperate reasonably.
203
+
204
+ This does not apply to claims arising from your modifications, your combination with other items, or your misuse.
205
+
206
+ ### 14.2 Your indemnity. You indemnify us against third-party claims arising from:
207
+
208
+ your Customer Data;
209
+
210
+ your breach of these Terms;
211
+
212
+ your use of Third Party Services;
213
+
214
+ unlawful or infringing use by you or your Authorised Users.
215
+
216
+ ### 14.3 Infringement response. If a claim suggests the Platform may infringe, we may:
217
+
218
+ (a) obtain the right for you to continue using it; (b) modify/replace it; or (c) terminate the affected part and refund prepaid unused fees for that part (if any), unless prohibited by your breach.
219
+
220
+ ## 15. Term and Termination
221
+
222
+ 15.1 Term. These Terms start on acceptance and continue for the Subscription term in your Order Form (including any trial), renewing as stated in the Order Form or plan unless either party gives required notice.
223
+
224
+ ### 15.2 Termination for convenience (trials). Either party may terminate a free trial at any time by notice.
225
+
226
+ 15.3 Termination for breach. Either party may terminate if the other materially breaches these Terms and fails to cure within 30 days of notice (or immediately if the breach cannot be cured).
227
+
228
+ ### 15.4 Effect of termination. On termination:
229
+
230
+ your licence ends;
231
+
232
+ you must stop using the Platform;
233
+
234
+ any unpaid fees become immediately due;
235
+
236
+ confidentiality obligations continue.
237
+
238
+ 15.5 Data on termination. Because Customer Data may be stored locally, you remain responsible for managing and deleting local data. If we hold any Customer Data (e.g., account details/support records), we will handle it in accordance with our Privacy Policy and applicable law.
239
+
240
+ ## 16. Force Majeure (Detailed)
241
+
242
+ 16.1 What it means. A Force Majeure Event is an event beyond a party’s reasonable control that prevents or materially delays that party from performing its obligations, despite that party taking reasonable steps to avoid or mitigate the effect.
243
+
244
+ ### 16.2 Examples. Force Majeure Events may include:
245
+
246
+ natural disasters (fire, flood, cyclone, earthquake);
247
+
248
+ acts of war, terrorism, civil unrest, sabotage;
249
+
250
+ epidemics/pandemics and related government restrictions;
251
+
252
+ government actions, laws, or orders that prevent performance;
253
+
254
+ widespread power, telecommunications, or internet outages not caused by the affected party;
255
+
256
+ failures of third-party hosting, distribution networks, or critical suppliers outside the affected party’s control;
257
+
258
+ cyberattacks or security incidents not caused by the affected party’s failure to implement reasonable security measures;
259
+
260
+ labour disputes not limited to the affected party’s own staff.
261
+
262
+ ### 16.3 What the affected party must do. The party affected by a Force Majeure Event must:
263
+
264
+ (a) notify the other party as soon as reasonably practicable, describing the event and expected impact; (b) use reasonable efforts to mitigate and resume performance; and (c) keep the other party reasonably informed of progress.
265
+
266
+ 16.4 Effect on obligations. While the Force Majeure Event continues, the affected party’s performance obligations are suspended to the extent they are impacted. The other party must still perform obligations that are not affected.
267
+
268
+ 16.5 Payments. Force majeure does not excuse payment obligations for services already provided, but it may affect delivery timelines for future services. If the Platform is unavailable due to a Force Majeure Event, we will use reasonable efforts to restore service.
269
+
270
+ 16.6 Extended force majeure termination right. If a Force Majeure Event continues for more than 60 consecutive days and materially prevents performance, either party may terminate the affected Order Form by written notice. Where permitted, we will refund any prepaid fees for the unused portion of the affected Subscription, excluding amounts relating to work performed or third-party costs already incurred.
271
+
272
+ ## 17. Compliance with Laws, Export Controls, and Sanctions
273
+
274
+ You must comply with all applicable laws, including privacy, cyber security, and intellectual property laws. You must not use the Platform in breach of export control or sanctions laws applicable to you or to us.
275
+
276
+ ## 18. General Terms
277
+
278
+ 18.1 Severability. If any provision is unenforceable, it will be read down to the minimum extent necessary, and the remainder remains in effect.
279
+
280
+ ### 18.2 No waiver. A failure to enforce a right is not a waiver.
281
+
282
+ 18.3 Assignment. Neither party may assign these Terms without the other’s consent, except to a successor in a merger or sale of substantially all assets.
283
+
284
+ 18.4 Notices. Notices must be in writing and sent to the contact details in your Order Form or account records. Email notices are effective when sent, provided no delivery failure notice is received.
285
+
286
+ ### 18.5 Entire agreement. These Terms and any Order Forms are the entire agreement and replace prior discussions.
287
+
288
+ ### 18.6 Order of precedence. If there is a conflict: (1) Order Form, then (2) these Terms, then (3) referenced policies.
289
+
290
+ ## 19. Governing Law and Jurisdiction (New South Wales, Australia)
291
+
292
+ These Terms are governed by the laws of New South Wales, Australia, and the Commonwealth of Australia.
293
+
294
+ Each party submits to the exclusive jurisdiction of the courts of New South Wales and the Commonwealth courts of Australia located in New South Wales.
package/bin/nyex.js ADDED
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+ const crypto = require("crypto");
7
+ const { spawn, execSync } = require("child_process");
8
+ const pkg = require("../package.json");
9
+
10
+ function candidateGlobalNodeModuleDirs() {
11
+ const dirs = [];
12
+ const prefix =
13
+ process.env.npm_config_prefix ||
14
+ process.env.NPM_CONFIG_PREFIX ||
15
+ process.env.PREFIX;
16
+ if (prefix) {
17
+ dirs.push(path.join(prefix, "node_modules"));
18
+ }
19
+ // Common user-level global install location on Windows.
20
+ if (process.platform === "win32" && process.env.APPDATA) {
21
+ dirs.push(path.join(process.env.APPDATA, "npm", "node_modules"));
22
+ }
23
+
24
+ // When users install the platform package globally as a sibling (common during
25
+ // local `.tgz` testing), Node resolution won't see it as a dependency of the
26
+ // meta package. Fall back to npm's global root.
27
+ try {
28
+ const npmRoot = execSync("npm root -g", { encoding: "utf8" })
29
+ .trim()
30
+ .replace(/\r?\n/g, "");
31
+ if (npmRoot) dirs.push(npmRoot);
32
+ } catch (_err) {
33
+ // ignore
34
+ }
35
+ return dirs;
36
+ }
37
+
38
+ function formatInstallHelp({ platform, arch, expectedPackage }) {
39
+ const lines = [];
40
+ lines.push("NYEX launcher could not find a prebuilt binary to run.");
41
+ lines.push("");
42
+ lines.push(`Detected platform: ${platform}-${arch}`);
43
+ lines.push(`Expected package: ${expectedPackage}`);
44
+ lines.push("");
45
+ lines.push("How to fix:");
46
+ lines.push(" 1) Reinstall the meta package (this should pull the platform binary automatically):");
47
+ lines.push(" npm i -g @corpai/nyex@alpha");
48
+ lines.push(" 2) If that still doesn't install the platform binary, install it explicitly:");
49
+ lines.push(` npm i -g ${expectedPackage}@alpha`);
50
+ lines.push("");
51
+ lines.push("If you are testing local .tgz files:");
52
+ lines.push(" 1) Install the platform .tgz first");
53
+ lines.push(" 2) Then install the @corpai/nyex .tgz");
54
+ return lines.join("\n");
55
+ }
56
+
57
+ function scopedPackageJsonPath(nodeModulesDir, expectedPackage) {
58
+ const parts = expectedPackage.split("/");
59
+ return path.join(nodeModulesDir, ...parts, "package.json");
60
+ }
61
+
62
+ function resolveBinary() {
63
+ const platform = process.platform;
64
+ const arch = process.arch;
65
+
66
+ if (platform === "win32" && arch === "x64") {
67
+ const expectedPackage = "@corpai/nyex-win32-x64-msvc";
68
+ const candidatePkgJsonPaths = [];
69
+
70
+ // First, try normal Node resolution (works when the platform package is an optionalDependency).
71
+ try {
72
+ candidatePkgJsonPaths.push(
73
+ require.resolve(`${expectedPackage}/package.json`)
74
+ );
75
+ } catch (_err) {
76
+ // ignore
77
+ }
78
+
79
+ // Next, check known global install locations directly. This is necessary when users install
80
+ // the platform package as a sibling global package (common for local `.tgz` validation).
81
+ for (const nodeModulesDir of candidateGlobalNodeModuleDirs()) {
82
+ const pkgJson = scopedPackageJsonPath(nodeModulesDir, expectedPackage);
83
+ if (fs.existsSync(pkgJson)) {
84
+ candidatePkgJsonPaths.push(pkgJson);
85
+ }
86
+ }
87
+
88
+ for (const pkgPath of candidatePkgJsonPaths) {
89
+ try {
90
+ const pkgDir = path.dirname(pkgPath);
91
+ const binPath = path.join(pkgDir, "bin", "nyex.exe");
92
+ if (!fs.existsSync(binPath)) {
93
+ throw new Error(
94
+ `Platform package is installed but binary is missing: ${binPath}`
95
+ );
96
+ }
97
+ verifyBinaryIntegrity({
98
+ expectedPackage,
99
+ binPath,
100
+ shaPath: path.join(pkgDir, "bin", "nyex.exe.sha256"),
101
+ });
102
+ return binPath;
103
+ } catch (err) {
104
+ if (err && err.nyex_fatal) throw err;
105
+ // continue
106
+ }
107
+ }
108
+ throw new Error(formatInstallHelp({ platform, arch, expectedPackage }));
109
+ }
110
+
111
+ throw new Error(
112
+ [
113
+ `NYEX does not yet ship a prebuilt binary for ${platform}-${arch}.`,
114
+ "",
115
+ "Supported in this release: win32-x64 only.",
116
+ ].join("\n")
117
+ );
118
+ }
119
+
120
+ function verifyBinaryIntegrity({ expectedPackage, binPath, shaPath }) {
121
+ if (!fs.existsSync(shaPath)) {
122
+ const err = new Error(
123
+ [
124
+ "NYEX platform binary integrity file is missing.",
125
+ "",
126
+ `Expected: ${shaPath}`,
127
+ "",
128
+ "How to fix:",
129
+ ` npm uninstall -g ${expectedPackage}`,
130
+ " npm i -g @corpai/nyex@alpha",
131
+ "",
132
+ "If you are testing local .tgz files, re-run the staging script then reinstall:",
133
+ " scripts\\npm\\stage-windows-binary.ps1 ...",
134
+ ].join("\n")
135
+ );
136
+ // Recoverable: a sibling global platform install may still be valid.
137
+ err.nyex_fatal = false;
138
+ throw err;
139
+ }
140
+
141
+ const expected = fs.readFileSync(shaPath, "utf8").trim().toLowerCase();
142
+ const actual = crypto
143
+ .createHash("sha256")
144
+ .update(fs.readFileSync(binPath))
145
+ .digest("hex")
146
+ .toLowerCase();
147
+
148
+ if (!expected || expected.length < 16) {
149
+ const err = new Error(
150
+ [
151
+ "NYEX platform binary integrity file is invalid.",
152
+ "",
153
+ `Path: ${shaPath}`,
154
+ "",
155
+ "How to fix:",
156
+ ` npm uninstall -g ${expectedPackage}`,
157
+ " npm i -g @corpai/nyex@alpha",
158
+ ].join("\n")
159
+ );
160
+ // Recoverable: a sibling global platform install may still be valid.
161
+ err.nyex_fatal = false;
162
+ throw err;
163
+ }
164
+
165
+ if (expected !== actual) {
166
+ const err = new Error(
167
+ [
168
+ "NYEX binary integrity check failed. Refusing to execute nyex.exe.",
169
+ "",
170
+ `Binary: ${binPath}`,
171
+ `Expected: ${expected}`,
172
+ `Actual: ${actual}`,
173
+ "",
174
+ "Remediation:",
175
+ ` npm uninstall -g ${expectedPackage} @corpai/nyex`,
176
+ " npm cache clean --force",
177
+ " npm i -g @corpai/nyex@alpha",
178
+ ].join("\n")
179
+ );
180
+ // Fatal: we found a binary + checksum pair that disagree.
181
+ err.nyex_fatal = true;
182
+ throw err;
183
+ }
184
+ }
185
+
186
+ function main() {
187
+ const args = process.argv.slice(2);
188
+
189
+ let binPath;
190
+ try {
191
+ binPath = resolveBinary();
192
+ } catch (err) {
193
+ console.error(err.message);
194
+ process.exit(1);
195
+ }
196
+
197
+ // Make `nyex --version` reflect the npm distribution version, but still
198
+ // enforce binary integrity checks before reporting success.
199
+ if (args.includes("--version") || args.includes("-V")) {
200
+ process.stdout.write(`nyex ${pkg.version}\n`);
201
+ process.exit(0);
202
+ }
203
+
204
+ const child = spawn(binPath, args, { stdio: "inherit" });
205
+ child.on("exit", code => process.exit(code ?? 1));
206
+ child.on("error", err => {
207
+ console.error(err.message);
208
+ process.exit(1);
209
+ });
210
+ }
211
+
212
+ main();
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@nyex/nyex",
3
+ "version": "0.1.2-beta",
4
+ "description": "Nyex CLI (private beta)",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "homepage": "https://nyex.ai",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rinfa0108/nyex.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/rinfa0108/nyex/issues"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "bin": {
18
+ "nyex": "bin/nyex.js"
19
+ },
20
+ "optionalDependencies": {
21
+ "@nyex/nyex-win32-x64-msvc": "0.1.2-beta"
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "files": [
27
+ "bin/nyex.js",
28
+ "LICENSE",
29
+ "TERMS_OF_USE.md",
30
+ "README.md",
31
+ "package.json"
32
+ ]
33
+ }