niuma-codex 0.0.0-stage → 0.0.1-beta.10

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,69 @@
1
- # Temporary Holding Version
1
+ # niuma-codex
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
+ Niuma 的本机 CLI 和后台 daemon,用于将本机 Codex 会话连接到远程客户端。包发布状态以 npm registry 为准。
4
+
5
+ ## 使用条件
6
+
7
+ - macOS;Node.js 18.20.5 或更新版本(Node 18 使用 npm 10)。
8
+ - 本机已有可供 Niuma 访问并配置认证的 Codex:支持仅安装独立 Codex CLI,也支持桌面应用内置 CLI。优先使用受支持的 ChatGPT/Codex 桌面应用入口,未找到时按启动进程的 `PATH` 查找 `codex`。
9
+ - 配对使用兼容 QR/Pairing V5 的 Niuma 客户端;Relay 需要可用的网络服务。
10
+
11
+ Windows 源码与隔离验收要求 Node.js 24.19 或更新版本,且内置 libuv 不低于 1.52.1;旧版本存在文件身份或回收兼容问题,会在 CLI 派发前提示升级。正式 npm 包目前仍只声明 macOS,不能将 Windows 实验产物视为正式发布。
12
+
13
+ 仅 CLI 安装可执行 `npm install -g @openai/codex`,并在启动 Niuma 的同一环境确认 `codex --version` 可用。Niuma 不自动安装 Codex,也不加载交互式 shell 配置;nvm/Homebrew 安装需把对应目录加入启动进程的 `PATH`。
14
+
15
+ 未找到任何 Codex 入口时返回 `CODEX_NOT_FOUND` 和安装/`PATH` 提示;不可执行、版本探测或 App Server 初始化失败有独立原因,后台启动也会传回本次错误并写本机日志。无桌面 IPC 不阻止 daemon 启动,但桌面端会话的实时控制仍需桌面应用运行;仅 CLI 环境由 App Server 承载 Niuma 新建的会话。
16
+
17
+ ```bash
18
+ # 启动或复用 daemon,打开本机配对页。
19
+ npx niuma-codex@latest
20
+ # 查看帮助或后台状态。
21
+ npx niuma-codex@latest --help
22
+ npx niuma-codex@latest daemon-status
23
+ # 同版本下显式重启以载入配置变化;会中断当前连接与执行中的服务请求。
24
+ npx niuma-codex@latest --background --restart
25
+ # 停止 daemon。
26
+ npx niuma-codex@latest daemon-stop
27
+ ```
28
+
29
+ 关闭终端或配对网页不会停止后台 daemon。启动时同时核对当前发布版本与 Relay 地址:两者一致才复用 daemon;版本不同、旧实例未报告版本或地址不一致时,自动停止旧后台服务,等待退出后使用本次版本与配置启动。根网页、后台与终端二维码入口均执行此规则;这会中断当前连接与请求。同版本内修改配置时仍须显式重启。可用 `npx niuma-codex@<version> daemon-status --json` 查看 `release_version`,确认后台实际运行的发布版本。不要在后台服务运行期间手动删除它所在的 npm 缓存目录。
30
+
31
+ 发布入口不读取工作目录或开发仓库的 `.env`。Relay 地址按本次 `--relay-origin`、`NIUMA_RELAY_ORIGIN`、`NIUMA_RELAY_PUBLIC_URL` 的顺序选择;均未配置时默认使用 `https://relay.niumacoding.com`。源码开发的兜底地址仍是本机 Server。启动和重启都不读取历史地址缓存,也不继承旧 daemon 的地址。自建服务须在启动时保留显式参数或环境配置。地址相同时不会因连接失败自动重启或切换服务。服务可用性独立于 npm 包安装。
32
+
33
+ Push 地址独立于 Relay:`NIUMA_PUSH_SERVER_ORIGIN` 非空时优先使用该值,未设置或为空白时,发布包默认使用 `https://api.niumacoding.com`;源码开发仍使用本机 Server。推送登记要求 HTTPS,服务故障不自动切换地址。自建服务须显式配置 Push 地址,并与 Server 的同名配置一致,该地址参与请求和绑定证明的签名校验。同版本内修改 Push 配置后,需要使用 `--background --restart` 载入配置;运行不同发布版本时自动重启载入新版默认值。推送失败本身不会触发重启。
34
+
35
+ iOS 配对成功不等于推送登记成功:进入已认证的会话页面后,需完成通知授权、APNs Token 注册和设备接收关系登记,实际签名环境须由 Server 支持。已有 iOS 推送登记不会随 Desktop 默认地址改变而自动迁移。
36
+
37
+ 旧实例若仍连接错误的本机地址,可在无运行任务时显式执行 `npx niuma-codex@latest --background --restart --relay-origin https://relay.niumacoding.com`,再刷新配对页。二维码要求 Relay 完成认证且支持 Relay v2 / Pairing V5;仅安装 Codex CLI 不会安装本机 Niuma Server。
38
+
39
+ 设备身份保存在 `~/Library/Application Support/Niuma/desktop-identity.json`,权限为 `0600`。身份和配对状态不放在 npm 安装目录中。不要将身份文件、配对二维码或调试日志公开。
40
+
41
+ 本包包含本机服务和配对/Control 网页,不包含远程 Server、独立 Web 或 iOS 应用,也不负责安装 Codex 或提供其账号授权。Niuma 是独立项目,不代表 OpenAI 官方产品。
42
+
43
+ ## 许可证
44
+
45
+ 本包自有代码采用 Apache-2.0,见 LICENSE。第三方组件保留各自许可证,见 THIRD_PARTY_NOTICES 及依赖包的许可文件。
46
+
47
+
48
+ ## macOS 登录自启动
49
+
50
+ 发布版本支持 CLI 管理:
51
+
52
+ ```bash
53
+ # 开启并启动一次;之后登录自动运行,不打开配对网页。
54
+ npx niuma-codex@<版本> autostart enable
55
+ # 查询注册与 daemon 实际状态。
56
+ npx niuma-codex@<版本> autostart status --json
57
+ # 取消以后登录时的启动,当前服务继续运行。
58
+ npx niuma-codex@<版本> autostart disable
59
+ ```
60
+
61
+ 也可在本机配对页面左侧导航打开“设置”,在右侧详情页切换“登录后自动启动 Niuma”。首次开启下载当前运行的精确发布版本及依赖;页面显示处理中,关闭或刷新网页不会取消已受理的操作。安装、注册失败可重试;设置操作不取消配对或关闭其他业务通道。源码页面显示不支持注册,需运行包含该功能的正式发布包。
62
+
63
+ 使用当前用户 LaunchAgent,不需要 sudo,属于登录后启动,不保证登录前或注销后持续运行,也不持续保活。`daemon-stop` 后不会立即拉起,下次登录仍启动;取消自启动不停止现有 daemon,需要时另行执行 `daemon-stop`。
64
+
65
+ 运行文件保存在 `~/Library/Application Support/Niuma/autostart/`,旧版本不自动删除;系统注册为 `~/Library/LaunchAgents/com.niuma.desktop.plist`。日志位于自启动目录的 stdout.log/stderr.log,目前不自动轮转。注册记录 Node 绝对路径;删除对应 nvm/Node 版本后需使用有效 Node 重新 enable。
66
+
67
+ 普通 npx 启动不更新自启动版本。升级后要同步登录版本,应使用目标版本重新 enable;CLI 注册的版本或 Relay 地址与当前后台不同时,沿用现有后台换代规则,可能中断当前连接。网页仅注册本次后台版本及配置,检测到后台变化时要求刷新后重试。
68
+
69
+ 首次安装需要 npm 可用及网络。登录时直接运行固定安装,不再访问 npm registry。支持 `enable --relay-origin <origin>`;保存已校验 Relay/Push、HTTP 监听、PATH 和需要时的 CODEX_HOME,不复制全部环境或 npm 认证信息。已有文件权限异常或非 Niuma 同名启动项不会被覆盖。
@@ -0,0 +1,10 @@
1
+ 本包自有代码按 Apache License 2.0 分发。
2
+
3
+ 配对页面包含 Phosphor 图标,许可和版权声明保留在
4
+ dist/assets/pairing-web/PHOSPHOR-LICENSE.txt。
5
+
6
+ 第三方 JavaScript 与原生运行库作为 npm dependencies 单独安装,未合并到
7
+ 自有 JavaScript 产物中。各库适用其随包提供的许可证和版权声明,包括:
8
+ @noble/curves、canonicalize、dotenv、bootstrap、chart.js、
9
+ mdast-util-from-markdown、qrcode、qrcode-terminal、sharp、ws、zod。
10
+ 其传递依赖同样保留各自许可证;本包的 Apache-2.0 不替代这些许可。
package/bin/niuma.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // 统一发布入口也供后台 worker 使用。
3
+ await import("../dist/cli.js");