omarion-sek 0.0.0-stage → 3.0.71

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,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,58 @@
1
- # Temporary Holding Version
1
+ # OmarionSek CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ AI coding assistant in your terminal — autonomous agent that edits files, runs
4
+ commands, browses the web, and more.
5
+
6
+ This package ships **only a precompiled binary**. There is no JavaScript
7
+ source code, no build step, and no Bun/Node runtime requirement beyond the thin
8
+ `bin/omarion-sek` resolver that ships with npm.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install -g omarion-sek
14
+ ```
15
+
16
+ The `omarion-sek` command is placed on your `PATH` by npm automatically — no
17
+ manual environment setup, no portable folder to manage.
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ omarion-sek # start in act mode
23
+ omarion-sek "fix the tests" # start with a prompt
24
+ omarion-sek --version
25
+ omarion-sek --help
26
+ ```
27
+
28
+ Hub (local daemon) management:
29
+
30
+ ```bash
31
+ omarion-sek hub start
32
+ omarion-sek hub status
33
+ omarion-sek hub stop
34
+ ```
35
+
36
+ ## Supported platforms
37
+
38
+ | Platform | Package |
39
+ | --- | --- |
40
+ | Linux x64 | `omarion-sek-linux-x64` |
41
+ | Linux arm64 | `omarion-sek-linux-arm64` |
42
+ | macOS x64 | `omarion-sek-darwin-x64` |
43
+ | macOS arm64 | `omarion-sek-darwin-arm64` |
44
+ | Windows x64 | `omarion-sek-windows-x64` |
45
+ | Windows arm64 | `omarion-sek-windows-arm64` |
46
+
47
+ Platform binaries are pulled in automatically as `optionalDependencies`; npm
48
+ installs only the one matching your machine.
49
+
50
+ ## Uninstall
51
+
52
+ ```bash
53
+ npm uninstall -g omarion-sek
54
+ ```
55
+
56
+ ## License
57
+
58
+ Apache-2.0
@@ -0,0 +1,281 @@
1
+ // Auto-discovery of OS trust anchors for the OmarionSek CLI.
2
+ //
3
+ // Bun does not read the OS trust store, so the 3.x CLI cannot see corporate
4
+ // MITM / self-signed CAs out of the box. This runs in the Node `bin/omarion-sek`
5
+ // wrapper (not Bun), reads the full OS store via tls.getCACertificates("system")
6
+ // (Node >= 22, no --use-system-ca flag), and hands the certs to the Bun child
7
+ // via NODE_EXTRA_CA_CERTS, which both runtimes honor. Mirrors the JetBrains
8
+ // plugin's configureCertificates(), sourcing from the OS instead of the IDE.
9
+ //
10
+ // Dependency-free CommonJS with injectable modules so it is unit-testable and
11
+ // ships verbatim in the published wrapper package.
12
+
13
+ const PEM_MARKER = "-----BEGIN CERTIFICATE-----";
14
+ const CERT_BLOCK =
15
+ /-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g;
16
+
17
+ /**
18
+ * Returns only the complete certificate blocks from PEM text, or null when
19
+ * there are none. User files may also hold private keys (combined cert+key
20
+ * PEMs) or other sections, which must never be copied into the managed
21
+ * bundle. Files that contain nothing but certificates pass through verbatim
22
+ * so unchanged bundles keep hash-skipping the rewrite.
23
+ */
24
+ function sanitizePem(text) {
25
+ const blocks = text.match(CERT_BLOCK) ?? [];
26
+ if (blocks.length === 0) {
27
+ return null;
28
+ }
29
+ const rest = text.replace(CERT_BLOCK, "");
30
+ if (/^\s*$/.test(rest)) {
31
+ return text;
32
+ }
33
+ return `${blocks.join("\n")}\n`;
34
+ }
35
+
36
+ /**
37
+ * Returns OS-trusted certificates as PEM strings, or [] when unavailable.
38
+ * tls.getCACertificates("system") requires Node >= 22.
39
+ */
40
+ function harvestSystemCerts(tlsModule) {
41
+ try {
42
+ const tls = tlsModule || require("node:tls");
43
+ if (typeof tls.getCACertificates !== "function") {
44
+ return [];
45
+ }
46
+ const certs = tls.getCACertificates("system");
47
+ if (!Array.isArray(certs)) {
48
+ return [];
49
+ }
50
+ return certs.filter(
51
+ (cert) => typeof cert === "string" && cert.includes(PEM_MARKER),
52
+ );
53
+ } catch {
54
+ return [];
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Returns the file's certificate blocks as PEM text, or null when missing,
60
+ * unreadable, or holding no complete certificate block.
61
+ */
62
+ function readUserBundle(fsModule, userPath) {
63
+ if (!userPath) {
64
+ return null;
65
+ }
66
+ try {
67
+ const fs = fsModule || require("node:fs");
68
+ const stat = fs.statSync(userPath, { throwIfNoEntry: false });
69
+ if (!stat || !stat.isFile()) {
70
+ return null;
71
+ }
72
+ // Binary DER would not have loaded in the runtime either; require PEM.
73
+ return sanitizePem(fs.readFileSync(userPath, "utf8"));
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Reads the user's NODE_EXTRA_CA_CERTS value into PEM strings. Node treats the
81
+ * value as a single file, but some users set an OS-path-delimited list; the
82
+ * whole value is tried as one file first, then split.
83
+ * The managed bundle is excluded so reading it back never re-appends its certs.
84
+ */
85
+ function readUserCerts(fsModule, pathModule, value, managedPath) {
86
+ if (!value) {
87
+ return [];
88
+ }
89
+ const fs = fsModule || require("node:fs");
90
+ const path = pathModule || require("node:path");
91
+ const candidates = [];
92
+ const whole = readUserBundle(fs, value);
93
+ if (whole) {
94
+ candidates.push({ filePath: value, pem: whole });
95
+ } else if (value.includes(path.delimiter)) {
96
+ for (const segment of value.split(path.delimiter)) {
97
+ const trimmed = segment.trim();
98
+ if (!trimmed) {
99
+ continue;
100
+ }
101
+ const pem = readUserBundle(fs, trimmed);
102
+ if (pem) {
103
+ candidates.push({ filePath: trimmed, pem });
104
+ }
105
+ }
106
+ }
107
+ const pems = [];
108
+ for (const candidate of candidates) {
109
+ const isManaged =
110
+ managedPath &&
111
+ path.resolve(candidate.filePath) === path.resolve(managedPath);
112
+ if (!isManaged) {
113
+ pems.push(candidate.pem);
114
+ }
115
+ }
116
+ return pems;
117
+ }
118
+
119
+ /**
120
+ * Concatenates the user PEMs (if any) and the system certificates into one
121
+ * bundle. A separating newline is inserted between parts so adjacent END/BEGIN
122
+ * markers cannot fuse into one invalid line.
123
+ */
124
+ function buildBundle({ systemCerts, userPems }) {
125
+ const parts = [...(userPems ?? []), ...systemCerts];
126
+ return parts
127
+ .map((part) => (part.endsWith("\n") ? part : `${part}\n`))
128
+ .join("");
129
+ }
130
+
131
+ /** Counts individual PEM certificates across the given bundle strings. */
132
+ function countCerts(pems) {
133
+ let count = 0;
134
+ for (const pem of pems) {
135
+ count += pem.split(PEM_MARKER).length - 1;
136
+ }
137
+ return count;
138
+ }
139
+
140
+ function readFileIfExists(fs, filePath) {
141
+ try {
142
+ return fs.readFileSync(filePath, "utf8");
143
+ } catch {
144
+ return null;
145
+ }
146
+ }
147
+
148
+ function resolveOmarionSekDir(env, os, path) {
149
+ return env.OMARION_SEK_DIR?.trim() || path.join(os.homedir(), ".omarion-sek");
150
+ }
151
+
152
+ /**
153
+ * True when the api-unavailable warning should print. Stamped per Node version
154
+ * in the omarion-sek dir so the nudge shows once rather than on every command; a
155
+ * version change (upgrade that still falls short, or downgrade) re-arms it.
156
+ * When the stamp cannot be read or written, warn — bookkeeping failures must
157
+ * never suppress a real diagnostic.
158
+ */
159
+ function shouldWarnApiUnavailable(env, deps = {}) {
160
+ const fs = deps.fs || require("node:fs");
161
+ const os = deps.os || require("node:os");
162
+ const path = deps.path || require("node:path");
163
+ const version = deps.nodeVersion || process.versions.node;
164
+ const dir = resolveOmarionSekDir(env, os, path);
165
+ const stamp = path.join(dir, `.ca-api-warned-${version}`);
166
+ try {
167
+ if (fs.existsSync(stamp)) {
168
+ return false;
169
+ }
170
+ fs.mkdirSync(dir, { recursive: true });
171
+ fs.writeFileSync(stamp, "", { mode: 0o600 });
172
+ return true;
173
+ } catch {
174
+ return true;
175
+ }
176
+ }
177
+
178
+ /** Atomically writes [content] to [target]; returns true on success. */
179
+ function writeBundle(fs, dir, target, content) {
180
+ const tmp = `${target}.${process.pid}.${Date.now()}.tmp`;
181
+ try {
182
+ fs.mkdirSync(dir, { recursive: true });
183
+ // Owner read/write: the bundle holds public CA material, not secrets,
184
+ // but there is no reason to make it world-writable.
185
+ fs.writeFileSync(tmp, content, { mode: 0o600 });
186
+ try {
187
+ fs.renameSync(tmp, target);
188
+ } catch {
189
+ // Windows can reject rename over a file a concurrent child holds open.
190
+ fs.rmSync(target, { force: true });
191
+ fs.renameSync(tmp, target);
192
+ }
193
+ return true;
194
+ } catch {
195
+ // Never leave a partial temp file behind (e.g. ENOSPC mid-write).
196
+ try {
197
+ fs.rmSync(tmp, { force: true });
198
+ } catch {
199
+ // Ignore: best-effort cleanup.
200
+ }
201
+ return false;
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Harvests OS trust anchors, merges them with any user NODE_EXTRA_CA_CERTS, and
207
+ * points env.NODE_EXTRA_CA_CERTS at a single managed PEM bundle. Mutates `env`
208
+ * in place. Returns an outcome the caller can log; `action` is one of
209
+ * "unchanged" | "written" | "write-failed-reused" | "write-failed" |
210
+ * "no-system-certs" | "api-unavailable".
211
+ */
212
+ function configureNodeExtraCaCerts(env, deps = {}) {
213
+ const fs = deps.fs || require("node:fs");
214
+ const os = deps.os || require("node:os");
215
+ const path = deps.path || require("node:path");
216
+ const tls = deps.tls || require("node:tls");
217
+
218
+ // tls.getCACertificates("system") needs Node >= 22.15; on older Nodes the
219
+ // harvest cannot run at all, which the caller should surface to the user.
220
+ if (typeof tls.getCACertificates !== "function") {
221
+ return {
222
+ action: "api-unavailable",
223
+ path: null,
224
+ systemCertCount: 0,
225
+ userCertCount: 0,
226
+ };
227
+ }
228
+
229
+ const systemCerts = harvestSystemCerts(tls);
230
+ if (systemCerts.length === 0) {
231
+ // Nothing to add: leave any user-provided NODE_EXTRA_CA_CERTS untouched
232
+ // and let the runtime fall back to its bundled CAs.
233
+ return {
234
+ action: "no-system-certs",
235
+ path: null,
236
+ systemCertCount: 0,
237
+ userCertCount: 0,
238
+ };
239
+ }
240
+
241
+ const managedDir = resolveOmarionSekDir(env, os, path);
242
+ const managedPath = path.join(managedDir, "cli-node-extra-ca-certs.pem");
243
+ const userValue = (env.NODE_EXTRA_CA_CERTS || "").trim() || null;
244
+ const userPems = readUserCerts(fs, path, userValue, managedPath);
245
+ const bundle = buildBundle({ systemCerts, userPems });
246
+ const base = {
247
+ path: managedPath,
248
+ systemCertCount: systemCerts.length,
249
+ userCertCount: countCerts(userPems),
250
+ };
251
+
252
+ // Skip the rewrite when the bundle is already current. Avoids per-launch I/O
253
+ // and the concurrent-rename race in the steady state.
254
+ if (readFileIfExists(fs, managedPath) === bundle) {
255
+ env.NODE_EXTRA_CA_CERTS = managedPath;
256
+ return { ...base, action: "unchanged" };
257
+ }
258
+
259
+ if (writeBundle(fs, managedDir, managedPath, bundle)) {
260
+ env.NODE_EXTRA_CA_CERTS = managedPath;
261
+ return { ...base, action: "written" };
262
+ }
263
+
264
+ // Write failed: fall back to a previously-written bundle if one exists.
265
+ if (readFileIfExists(fs, managedPath)) {
266
+ env.NODE_EXTRA_CA_CERTS = managedPath;
267
+ return { ...base, action: "write-failed-reused" };
268
+ }
269
+ return { ...base, path: null, action: "write-failed" };
270
+ }
271
+
272
+ module.exports = {
273
+ harvestSystemCerts,
274
+ sanitizePem,
275
+ readUserBundle,
276
+ readUserCerts,
277
+ buildBundle,
278
+ countCerts,
279
+ configureNodeExtraCaCerts,
280
+ shouldWarnApiUnavailable,
281
+ };
@@ -0,0 +1,190 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Binary resolver for OmarionSek CLI.
4
+ //
5
+ // This script runs with Node.js (available everywhere npm is) and finds the
6
+ // correct platform-specific compiled binary to execute. The compiled binary
7
+ // has Bun embedded, so users don't need Bun installed.
8
+ //
9
+ // Resolution order:
10
+ // 1. OMARION_SEK_BIN_PATH env var override
11
+ // 2. Cached binary at bin/.omarion-sek (created by postinstall)
12
+ // 3. Walk up node_modules to find the platform-specific package
13
+
14
+ const childProcess = require("child_process");
15
+ const fs = require("fs");
16
+ const path = require("path");
17
+ const os = require("os");
18
+
19
+ const scriptPath = fs.realpathSync(__filename);
20
+ const scriptDir = path.dirname(scriptPath);
21
+ const childEnv = {
22
+ ...process.env,
23
+ OMARION_SEK_WRAPPER_PATH: scriptPath,
24
+ };
25
+
26
+ // Auto-discover OS trust anchors and pass them to the Bun child via
27
+ // NODE_EXTRA_CA_CERTS. The Bun runtime does not read the OS store on its own,
28
+ // so corporate/self-signed CAs would otherwise fail. This wrapper runs on
29
+ // Node, which can read the full store here.
30
+ try {
31
+ const caCerts = require("./ca-certs.cjs");
32
+ const outcome = caCerts.configureNodeExtraCaCerts(childEnv);
33
+ const debug =
34
+ process.env.OMARION_SEK_DEBUG === "1" || process.env.OMARION_SEK_DEBUG === "true";
35
+ // Not debug-gated: on old Nodes the harvest silently doing nothing is
36
+ // indistinguishable from a broken corporate proxy. Stamped per Node
37
+ // version so the nudge shows once, not on every command.
38
+ if (
39
+ outcome &&
40
+ outcome.action === "api-unavailable" &&
41
+ !childEnv.NODE_EXTRA_CA_CERTS &&
42
+ caCerts.shouldWarnApiUnavailable(childEnv)
43
+ ) {
44
+ console.warn(
45
+ `[omarion-sek] Node ${process.versions.node} cannot read the OS trust store (needs >= 22.15); ` +
46
+ "corporate or self-signed CAs may fail TLS. Upgrade Node or set NODE_EXTRA_CA_CERTS.",
47
+ );
48
+ }
49
+ if (debug && outcome) {
50
+ if (outcome.action === "no-system-certs") {
51
+ console.warn(
52
+ "[omarion-sek] No OS trust anchors found; relying on the runtime's bundled CAs.",
53
+ );
54
+ } else if (outcome.action === "write-failed") {
55
+ console.warn(
56
+ "[omarion-sek] Could not write the managed CA bundle; relying on the runtime's bundled CAs.",
57
+ );
58
+ } else {
59
+ console.warn(
60
+ `[omarion-sek] Trust: ${outcome.systemCertCount} OS + ${outcome.userCertCount} user CAs (${outcome.action}) -> ${outcome.path}`,
61
+ );
62
+ }
63
+ }
64
+ } catch {
65
+ // Best effort: fall back to the runtime's default trust on any failure.
66
+ }
67
+
68
+ function run(target) {
69
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
70
+ stdio: "inherit",
71
+ env: childEnv,
72
+ });
73
+ if (result.error) {
74
+ console.error(result.error.message);
75
+ // Windows application control (Smart App Control, WDAC, AppLocker)
76
+ // blocks the child exe at launch, which Node surfaces only as an
77
+ // opaque "spawnSync ... UNKNOWN" error. Point users at the real cause.
78
+ const code = result.error.code;
79
+ if (
80
+ os.platform() === "win32" &&
81
+ (code === "UNKNOWN" || code === "EACCES" || code === "EPERM")
82
+ ) {
83
+ console.error(
84
+ "\nWindows refused to start the OmarionSek binary:\n " +
85
+ target +
86
+ "\n\n" +
87
+ "This usually means an application control policy (Smart App Control,\n" +
88
+ "WDAC, or AppLocker) or antivirus blocked the executable. To confirm,\n" +
89
+ "run the path above directly in a terminal and check the error Windows\n" +
90
+ "reports, or inspect its signature with:\n\n" +
91
+ ' Get-AuthenticodeSignature "' +
92
+ target +
93
+ '"\n\n' +
94
+ "If it was blocked by policy, allow the file or ask your administrator\n" +
95
+ "to trust it. See https://github.com/omarion-sek/omarion-sek/issues for known issues.",
96
+ );
97
+ }
98
+ process.exit(1);
99
+ }
100
+ if (typeof result.status === "number") {
101
+ process.exit(result.status);
102
+ }
103
+ if (result.signal) {
104
+ process.kill(process.pid, result.signal);
105
+ process.exit(128);
106
+ }
107
+ process.exit(1);
108
+ }
109
+
110
+ // 1. Check env var override
111
+ const envPath = process.env.OMARION_SEK_BIN_PATH;
112
+ if (envPath) {
113
+ run(envPath);
114
+ }
115
+
116
+ // 2. Check cached binary
117
+ const cached = path.join(scriptDir, ".omarion-sek");
118
+ if (fs.existsSync(cached)) {
119
+ run(cached);
120
+ }
121
+
122
+ // 3. Detect platform and architecture
123
+ const platformMap = {
124
+ darwin: "darwin",
125
+ linux: "linux",
126
+ win32: "windows",
127
+ };
128
+ const archMap = {
129
+ x64: "x64",
130
+ arm64: "arm64",
131
+ };
132
+
133
+ let platform = platformMap[os.platform()];
134
+ if (!platform) {
135
+ platform = os.platform();
136
+ }
137
+ let arch = archMap[os.arch()];
138
+ if (!arch) {
139
+ arch = os.arch();
140
+ }
141
+
142
+ const base = "omarion-sek-" + platform + "-" + arch;
143
+ const binary = platform === "windows" ? "omarion-sek.exe" : "omarion-sek";
144
+
145
+ // Build fallback chain of package names to try. The legacy scoped names are
146
+ // kept as a fallback so existing installs keep resolving during a rename.
147
+ const names = [base, "@omarion-sek/cli-" + platform + "-" + arch];
148
+
149
+ function findBinary(startDir) {
150
+ let current = startDir;
151
+ for (;;) {
152
+ const modules = path.join(current, "node_modules");
153
+ if (fs.existsSync(modules)) {
154
+ for (const name of names) {
155
+ // Unscoped package: omarion-sek-linux-x64 lives at
156
+ // node_modules/omarion-sek-linux-x64. Scoped packages
157
+ // (@omarion-sek/cli-*) attach the scope as a subdirectory,
158
+ // which path.join handles identically.
159
+ const candidate = path.join(modules, name, "bin", binary);
160
+ if (fs.existsSync(candidate)) return candidate;
161
+ }
162
+ }
163
+ const parent = path.dirname(current);
164
+ if (parent === current) {
165
+ return undefined;
166
+ }
167
+ current = parent;
168
+ }
169
+ }
170
+
171
+ const resolved = findBinary(scriptDir);
172
+ if (!resolved) {
173
+ console.error(
174
+ "Could not find the OmarionSek CLI binary for your platform.\n" +
175
+ "Your platform: " +
176
+ os.platform() +
177
+ " " +
178
+ os.arch() +
179
+ "\n" +
180
+ "Looked for: " +
181
+ names.map(function (n) {
182
+ return '"' + n + '"';
183
+ }).join(" or ") +
184
+ "\n\n" +
185
+ "Try reinstalling: npm install -g omarion-sek",
186
+ );
187
+ process.exit(1);
188
+ }
189
+
190
+ run(resolved);
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "omarion-sek",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.0.71",
4
+ "description": "Autonomous coding agent CLI - capable of creating/editing files, running commands, using the browser, and more",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "omarion-sek",
8
+ "claude",
9
+ "dev",
10
+ "mcp",
11
+ "openrouter",
12
+ "coding",
13
+ "agent",
14
+ "autonomous",
15
+ "chatgpt",
16
+ "sonnet",
17
+ "ai",
18
+ "llama",
19
+ "cli"
20
+ ],
21
+ "author": {
22
+ "name": "Омарион СЕК"
23
+ },
24
+ "homepage": "https://omarion-sek",
25
+ "bugs": {
26
+ "url": "https://github.com/omarion-sek/omarion-sek/issues"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/omarion-sek/omarion-sek.git",
31
+ "directory": "apps/cli"
32
+ },
33
+ "bin": {
34
+ "omarion-sek": "./bin/omarion-sek",
35
+ "omarionSek": "./bin/omarion-sek"
36
+ },
37
+ "scripts": {
38
+ "postinstall": "node ./postinstall.mjs || true"
39
+ },
40
+ "dependencies": {},
41
+ "optionalDependencies": {
42
+ "omarion-sek-linux-x64": "3.0.71",
43
+ "omarion-sek-darwin-x64": "3.0.71",
44
+ "omarion-sek-windows-arm64": "3.0.71",
45
+ "omarion-sek-darwin-arm64": "3.0.71",
46
+ "omarion-sek-linux-arm64": "3.0.71",
47
+ "omarion-sek-windows-x64": "3.0.71"
48
+ }
49
+ }
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Post-install script for OmarionSek CLI.
4
+ //
5
+ // Creates a hard link (or copy fallback) from the platform-specific binary
6
+ // to bin/.omarion-sek for fast startup on subsequent runs.
7
+ //
8
+ // This script must use only Node.js APIs (no Bun) since it runs via
9
+ // "node script/postinstall.mjs" in the npm lifecycle.
10
+
11
+ import fs from "node:fs";
12
+ import { createRequire } from "node:module";
13
+ import os from "node:os";
14
+ import path from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+
17
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
18
+ const require = createRequire(import.meta.url);
19
+
20
+ // CLI versions <= 3.0.54 restart the hub daemon after a background
21
+ // auto-update even while it is serving live sessions, killing those sessions
22
+ // mid-turn — and their build-fingerprint check then rejects every replacement
23
+ // hub, bricking the running TUI. That restart code is the *old* version's, so
24
+ // it cannot be patched here; but it bails out harmlessly when no hub
25
+ // discovery record exists, and it runs only after this install (and this
26
+ // script) completes. Setting the record aside protects any attached clients:
27
+ // a running hub keeps serving its established connections, clients that share
28
+ // its build fingerprint rebuild the record from a port probe, and the next
29
+ // fresh launch retires stale hubs regardless of the record.
30
+ function shieldRunningHubDiscovery() {
31
+ const explicitPath = process.env.OMARION_SEK_HUB_DISCOVERY_PATH?.trim();
32
+ const dataDir =
33
+ process.env.OMARION_SEK_DATA_DIR?.trim() ||
34
+ path.join(
35
+ process.env.OMARION_SEK_DIR?.trim() || path.join(os.homedir(), ".omarion-sek"),
36
+ "data",
37
+ );
38
+ const recordPath =
39
+ explicitPath || path.join(dataDir, "locks", "hub", "production.json");
40
+ if (!fs.existsSync(recordPath)) {
41
+ return;
42
+ }
43
+ const asidePath = `${recordPath}.superseded`;
44
+ fs.rmSync(asidePath, { force: true });
45
+ fs.renameSync(recordPath, asidePath);
46
+ console.log("Set aside hub discovery record for the updated CLI");
47
+ }
48
+
49
+ function main() {
50
+ if (os.platform() === "win32") {
51
+ // On Windows, npm creates .cmd shims from the bin field.
52
+ // The resolver script handles binary lookup at runtime.
53
+ console.log("Windows detected: skipping binary cache setup");
54
+ return;
55
+ }
56
+
57
+ const platformMap = {
58
+ darwin: "darwin",
59
+ linux: "linux",
60
+ };
61
+ const platform = platformMap[os.platform()] || os.platform();
62
+ const arch = os.arch();
63
+ const packageName = `omarion-sek-${platform}-${arch}`;
64
+ const binaryName = "omarion-sek";
65
+
66
+ let binaryPath;
67
+ try {
68
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
69
+ const packageDir = path.dirname(packageJsonPath);
70
+ binaryPath = path.join(packageDir, "bin", binaryName);
71
+
72
+ if (!fs.existsSync(binaryPath)) {
73
+ throw new Error(`Binary not found at ${binaryPath}`);
74
+ }
75
+ } catch (_error) {
76
+ // Platform package not available. The resolver script will find
77
+ // it at runtime by walking node_modules. This is expected on
78
+ // platforms we don't ship binaries for.
79
+ console.log(`Note: ${packageName} not found, skipping binary cache`);
80
+ return;
81
+ }
82
+
83
+ const binDir =
84
+ path.basename(__dirname) === "script"
85
+ ? path.join(__dirname, "..", "bin")
86
+ : path.join(__dirname, "bin");
87
+ const target = path.join(binDir, ".omarion-sek");
88
+
89
+ // Ensure bin directory exists
90
+ if (!fs.existsSync(binDir)) {
91
+ fs.mkdirSync(binDir, { recursive: true });
92
+ }
93
+
94
+ // Remove existing cached binary
95
+ if (fs.existsSync(target)) {
96
+ fs.unlinkSync(target);
97
+ }
98
+
99
+ // Hard link preferred (shares disk space), copy as fallback
100
+ // (hard links fail on some filesystems like NFS or cross-device)
101
+ try {
102
+ fs.linkSync(binaryPath, target);
103
+ } catch {
104
+ fs.copyFileSync(binaryPath, target);
105
+ }
106
+
107
+ fs.chmodSync(target, 0o755);
108
+ console.log(`Cached omarion-sek binary at ${target}`);
109
+ }
110
+
111
+ try {
112
+ shieldRunningHubDiscovery();
113
+ } catch (error) {
114
+ // Best-effort: without the shield the worst case is the pre-3.0.55
115
+ // restart-while-busy behavior, never a broken install.
116
+ console.error(`postinstall: hub discovery shield skipped: ${error.message}`);
117
+ }
118
+
119
+ try {
120
+ main();
121
+ } catch (error) {
122
+ // postinstall failures should never block npm install.
123
+ // The resolver script will find the binary at runtime.
124
+ console.error(`postinstall: ${error.message}`);
125
+ process.exit(0);
126
+ }