niuma-codex 0.0.1-beta.15 → 0.0.1-beta.16
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/README.md +7 -3
- package/THIRD_PARTY_NOTICES +1 -1
- package/dist/assets/pairing-web/index.html +2 -2
- package/dist/assets/pairing-web/settings.js +20 -3
- package/dist/cli.js +2406 -1533
- package/dist/managed-tauri.js +90919 -0
- package/dist/managed.js +86306 -0
- package/package.json +3 -1
- package/resources/lite-release.json +23 -0
- package/resources/niuma-daemon-arm64.tgz +0 -0
- package/resources/niuma-lite-arm64.dmg +0 -0
package/README.md
CHANGED
|
@@ -15,8 +15,10 @@ Windows 源码与隔离验收要求 Node.js 24.19 或更新版本,且内置 li
|
|
|
15
15
|
未找到任何 Codex 入口时返回 `CODEX_NOT_FOUND` 和安装/`PATH` 提示;不可执行、版本探测或 App Server 初始化失败有独立原因,后台启动也会传回本次错误并写本机日志。无桌面 IPC 不阻止 daemon 启动,但桌面端会话的实时控制仍需桌面应用运行;仅 CLI 环境由 App Server 承载 Niuma 新建的会话。
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
#
|
|
18
|
+
# 普通启动,打开配对网页,不安装 App。
|
|
19
19
|
npx niuma-codex@latest
|
|
20
|
+
# 显式安装或打开 Niuma Lite(发行版本必须携带轻量资源)。
|
|
21
|
+
npx niuma-codex@latest install-app
|
|
20
22
|
# 查看帮助或后台状态。
|
|
21
23
|
npx niuma-codex@latest --help
|
|
22
24
|
npx niuma-codex@latest daemon-status
|
|
@@ -26,7 +28,7 @@ npx niuma-codex@latest --background --restart
|
|
|
26
28
|
npx niuma-codex@latest daemon-stop
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
install-app 入口安装/打开 Niuma Lite,使用独立目录中的 daemon,退出应用会停止其自有 daemon;缺少发行清单时明确提示暂不可安装。Electron 完整版仍独立提供。以下后台换代规则适用于普通配对入口(含无参数)与显式后台。关闭终端或配对网页不会停止独立后台 daemon。启动时同时核对当前发布版本与 Relay 地址:两者一致才复用 daemon;版本不同、旧实例未报告版本或地址不一致时,自动停止旧后台服务,等待退出后使用本次版本与配置启动。根网页、后台与终端二维码入口均执行此规则;这会中断当前连接与请求。同版本内修改配置时仍须显式重启。可用 `npx niuma-codex@<version> daemon-status --json` 查看 `release_version`,确认后台实际运行的发布版本。不要在后台服务运行期间手动删除它所在的 npm 缓存目录。
|
|
30
32
|
|
|
31
33
|
发布入口不读取工作目录或开发仓库的 `.env`。Relay 地址按本次 `--relay-origin`、`NIUMA_RELAY_ORIGIN`、`NIUMA_RELAY_PUBLIC_URL` 的顺序选择;均未配置时默认使用 `https://relay.niumacoding.com`。源码开发的兜底地址仍是本机 Server。启动和重启都不读取历史地址缓存,也不继承旧 daemon 的地址。自建服务须在启动时保留显式参数或环境配置。地址相同时不会因连接失败自动重启或切换服务。服务可用性独立于 npm 包安装。
|
|
32
34
|
|
|
@@ -64,8 +66,10 @@ npx niuma-codex@<版本> autostart disable
|
|
|
64
66
|
|
|
65
67
|
运行文件保存在 `~/Library/Application Support/Niuma/autostart/`,旧版本不自动删除;轻量 `Niuma.app` 保存在该目录的 `applications/<内容摘要>/` 下,包含固定版本入口和 Niuma 图标;系统通过 `com.niuma.npm-autostart.agent` 注册,登录项显示 Niuma。应用包使用本地 ad-hoc 签名,不需要用户的开发证书或 Xcode。旧版 `~/Library/LaunchAgents/com.niuma.desktop.plist` 在使用新版重新 enable 时迁移并移除,不影响其他 Node 启动项。日志位于自启动目录的 stdout.log/stderr.log,目前不自动轮转。注册记录 Node 绝对路径;删除对应 nvm/Node 版本后需使用有效 Node 重新 enable。
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
独立后台模式启动不更新 LaunchAgent 自启动版本;install-app 首次安装会在目标就绪且新登录项确认注册后迁移已开启的 npm 登录项,更新则保留应用设置。升级后要同步登录版本,应使用目标版本重新 enable;CLI 注册的版本或 Relay 地址与当前后台不同时,沿用现有后台换代规则,可能中断当前连接。网页仅注册本次后台版本及配置,检测到后台变化时要求刷新后重试。
|
|
68
70
|
|
|
69
71
|
首次安装需要 npm 可用及网络。登录时直接运行固定安装,不再访问 npm registry。支持 `enable --relay-origin <origin>`;保存已校验 Relay/Push、HTTP 监听、PATH 和需要时的 CODEX_HOME,不复制全部环境或 npm 认证信息。已有文件权限异常或非 Niuma 同名启动项不会被覆盖。
|
|
70
72
|
|
|
71
73
|
新版登录项需要先安装包含此变更的 npm 版本,再运行 `npx niuma-codex@<新版本> autostart enable`(或在新版设置页重新开启)。仅刷新网页不会升级旧 daemon 的注册逻辑。系统要求批准时按系统设置允许 Niuma;失败清理包括待批准的登记,未知/损坏应用不得执行。取消不停止正在运行的 daemon。旧版本不理解新的注册元数据,不应使用旧版 CLI 修改新版注册。
|
|
74
|
+
|
|
75
|
+
包含 Lite 的 npm 版本内置 arm64 DMG 与外置 daemon 归档;普通 npx 也下载这些资源,但仅 install-app 安装。experimental beta 使用 ad-hoc 签名、未经 Apple 公证,必须在交互终端确认,可能被 Gatekeeper 拦截;不会自动绕过系统保护。用户需预先安装 Node.js >=18.20.5。Electron 完整版保持独立。
|
package/THIRD_PARTY_NOTICES
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
第三方 JavaScript 与原生运行库作为 npm dependencies 单独安装,未合并到
|
|
7
7
|
自有 JavaScript 产物中。各库适用其随包提供的许可证和版权声明,包括:
|
|
8
8
|
@noble/curves、canonicalize、dotenv、bootstrap、chart.js、
|
|
9
|
-
mdast-util-from-markdown、qrcode、qrcode-terminal、sharp、ws、zod。
|
|
9
|
+
mdast-util-from-markdown、qrcode、qrcode-terminal、sharp、tar(BlueOak-1.0.0)、ws、zod。
|
|
10
10
|
其传递依赖同样保留各自许可证;本包的 Apache-2.0 不替代这些许可。
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</nav><p class="trust">仅允许你信任的设备连接。</p>
|
|
14
14
|
</aside>
|
|
15
15
|
<div class="content">
|
|
16
|
-
<section id="settings-panel" class="settings-panel" aria-labelledby="settings-title" hidden><header class="page-heading"><h2 id="settings-title">设置</h2><p>管理这台电脑上的 Niuma。</p></header><h3 class="settings-group-title">启动与运行</h3><div class="autostart-row"><div><label for="autostart-enabled">登录后自动启动 Niuma</label><p id="autostart-description">登录这台 Mac 后自动启动后台服务。关闭后,当前服务仍会继续运行。</p><p class="settings-hint">首次开启需要下载运行文件。</p></div><input id="autostart-enabled" type="checkbox" role="switch" aria-describedby="autostart-description" disabled></div><p id="autostart-message" role="status" aria-live="polite">正在读取设置…</p><button id="autostart-retry" class="text-button" hidden>重试</button></section>
|
|
16
|
+
<section id="settings-panel" class="settings-panel" aria-labelledby="settings-title" hidden><header class="page-heading"><h2 id="settings-title">设置</h2><p>管理这台电脑上的 Niuma。</p></header><h3 class="settings-group-title">启动与运行</h3><div id="autostart-controls" class="autostart-row"><div><label id="autostart-label" for="autostart-enabled">登录后自动启动 Niuma</label><p id="autostart-description">登录这台 Mac 后自动启动后台服务。关闭后,当前服务仍会继续运行。</p><p id="autostart-hint" class="settings-hint">首次开启需要下载运行文件。</p></div><input id="autostart-enabled" type="checkbox" role="switch" aria-describedby="autostart-description" disabled></div><p id="autostart-message" role="status" aria-live="polite">正在读取设置…</p><button id="autostart-retry" class="text-button" hidden>重试</button></section>
|
|
17
17
|
<div id="device-workspace">
|
|
18
18
|
<div id="home-intro"></div>
|
|
19
19
|
<div id="flow-intro" hidden><button id="back" class="text-button back"><span class="icon icon-arrow" aria-hidden="true"></span>返回设备列表</button><h1>添加设备</h1><p>使用手机 Niuma 扫码,在此页面确认配对。</p><ol class="steps" aria-label="配对进度"><li id="step-1"><span class="step-number">1</span><span>扫描二维码</span></li><li id="step-2"><span class="step-number">2</span><span>允许配对</span></li><li id="step-3"><span class="step-number">3</span><span>完成连接</span></li></ol></div>
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
<div id="status-panel" class="flow-panel status-panel" role="status" aria-live="polite" hidden><span id="status-icon" class="icon icon-spinner" aria-hidden="true"></span><h2 id="status-title"></h2><p id="status-device"></p><p id="status-detail"></p><button id="retry" class="primary" hidden>重试</button><button id="status-back" class="text-button" hidden>返回设备列表</button><p id="status-hint" class="hint"></p></div>
|
|
25
25
|
</section>
|
|
26
26
|
</div>
|
|
27
|
-
</div></main><footer
|
|
27
|
+
</div></main><footer>关闭此页面后,后台服务仍会继续运行。</footer>
|
|
28
28
|
<script type="module" src="/app.js"></script><script type="module" src="/settings.js"></script></body></html>
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
/** 设置使用独立请求状态,不触碰设备列表、二维码或配对轮询。 */
|
|
2
2
|
export function mountAutostartSettings(doc,win,request){
|
|
3
3
|
const $=id=>doc.getElementById(id);
|
|
4
|
+
const bridge=win.niumaLoginItem;
|
|
5
|
+
// 只有应用 preload 提供登录项能力;普通浏览器继续使用 npm 设置接口。
|
|
6
|
+
if(bridge){
|
|
7
|
+
$('autostart-label').textContent='登录时自动启动 Niuma';
|
|
8
|
+
$('autostart-description').textContent='登录这台 Mac 后自动启动 Niuma 应用及后台服务。关闭后,当前应用仍会继续运行。';
|
|
9
|
+
$('autostart-hint').hidden=true;
|
|
10
|
+
}
|
|
11
|
+
async function settingsRequest(init){
|
|
12
|
+
if(!bridge)return request('/api/v1/settings/autostart',init);
|
|
13
|
+
if(init.method==='POST')await bridge.set(JSON.parse(init.body).enabled);
|
|
14
|
+
const current=await bridge.read();
|
|
15
|
+
// 宿主桥接返回实际登录项状态,映射到页面共用的系统启用字段。
|
|
16
|
+
return {ok:true,json:async()=>({code:0,data:{supported:current.available,registered:current.enabled,loaded:current.enabled,available:current.available,operation:null,reason:'请安装 Niuma 应用后设置登录自启动'}})};
|
|
17
|
+
}
|
|
4
18
|
let state=null,inFlight=false,changing=false,generation=0,timer=null;
|
|
5
19
|
const visible=()=>!$('settings-panel').hidden&&!doc.hidden;
|
|
6
20
|
// 注册文件保留不代表系统允许启动;未知状态只能刷新,不能据此修改注册。
|
|
@@ -10,6 +24,9 @@ export function mountAutostartSettings(doc,win,request){
|
|
|
10
24
|
function render(message=''){
|
|
11
25
|
const operation=state?.operation;
|
|
12
26
|
const working=changing||operation?.state==='running';
|
|
27
|
+
// 不支持的运行方式只显示原因,不误导用户配置另一套登录项。
|
|
28
|
+
const controls=$('autostart-controls');
|
|
29
|
+
if(controls)controls.hidden=state?.supported===false;
|
|
13
30
|
$('autostart-enabled').checked=state?.registered===true&&state.loaded===true&&state.available===true;
|
|
14
31
|
$('autostart-enabled').disabled=!state||!state.supported||systemUnknown()||working||inFlight;
|
|
15
32
|
$('autostart-message').textContent=message||(working?(operation?.target_enabled===false?'正在关闭…':'正在开启…'):
|
|
@@ -23,7 +40,7 @@ export function mountAutostartSettings(doc,win,request){
|
|
|
23
40
|
if(inFlight||!visible())return;
|
|
24
41
|
inFlight=true;const owner=generation;render();
|
|
25
42
|
try {
|
|
26
|
-
const response=await
|
|
43
|
+
const response=await settingsRequest({cache:'no-store'});const payload=await response.json();
|
|
27
44
|
if(owner!==generation)return;
|
|
28
45
|
if(payload.data&&typeof payload.data.registered==='boolean')state=payload.data;
|
|
29
46
|
else if(!response.ok||payload.code!==0)throw Error(payload.message||'无法读取设置,请重试');
|
|
@@ -41,10 +58,10 @@ export function mountAutostartSettings(doc,win,request){
|
|
|
41
58
|
changing=true;stop();render();
|
|
42
59
|
let message='';
|
|
43
60
|
try {
|
|
44
|
-
const response=await
|
|
61
|
+
const response=await settingsRequest({method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({enabled})});
|
|
45
62
|
const payload=await response.json();
|
|
46
63
|
if(!response.ok||payload.code!==0)message=payload.message||'设置失败,请重试';
|
|
47
|
-
}catch{message='连接中断,正在核对实际设置,请勿重复操作';}
|
|
64
|
+
}catch(error){message=bridge?(error.message||'设置失败,请重试'):'连接中断,正在核对实际设置,请勿重复操作';}
|
|
48
65
|
finally{changing=false;await load();if(message&&visible())render(message);}
|
|
49
66
|
}
|
|
50
67
|
// 导航只切换容器可见性,保留设备与配对状态;业务响应不能抢回当前页面。
|