@walkhi/code-relax 0.1.0-beta.105 → 0.1.0-beta.107
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/dist/build-platform.json +1 -1
- package/dist/src/file-transfer-range.mjs +1 -1
- package/dist/src/file-upload-session.mjs +6 -6
- package/dist/src/lan-socket-server.mjs +1 -1
- package/dist/src/platform/windows/resident-startup.ps1 +7 -1
- package/dist/src/service-doctor.mjs +1 -0
- package/package.json +1 -1
- package/tools/postinstall.mjs +2 -1
package/dist/build-platform.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"layout":"npm-platform-packages","version":"0.1.0-beta.
|
|
1
|
+
{"layout":"npm-platform-packages","version":"0.1.0-beta.107"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const FILE_READ_LIMIT =
|
|
1
|
+
export const FILE_READ_LIMIT = 50 * 1024 * 1024;
|
|
2
2
|
export const FILE_PART_BYTES = 256 * 1024;
|
|
3
3
|
export class FileRangeError extends Error {
|
|
4
4
|
constructor(statusCode, message) { super(message); this.statusCode = statusCode; }
|
|
@@ -2,9 +2,9 @@ import crypto from 'node:crypto';
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
|
-
export const MAX_FILE_BYTES =
|
|
5
|
+
export const MAX_FILE_BYTES = 50 * 1024 * 1024;
|
|
6
6
|
export const MAX_FILE_COUNT = 4;
|
|
7
|
-
export const MAX_TOTAL_BYTES =
|
|
7
|
+
export const MAX_TOTAL_BYTES = MAX_FILE_BYTES;
|
|
8
8
|
export const FILE_CHUNK_BYTES = 256 * 1024;
|
|
9
9
|
|
|
10
10
|
function validName(value) {
|
|
@@ -63,8 +63,8 @@ export function createFileUploadSession(root) {
|
|
|
63
63
|
// and commit after a direct connection has been replaced.
|
|
64
64
|
if (relayed) {
|
|
65
65
|
const originals = [...files.values()].filter(file => !file.previewOf);
|
|
66
|
-
if (originals.some(file => file.size > MAX_FILE_BYTES)) throw new Error('服务器转发仅支持单个文件不超过
|
|
67
|
-
if (originals.reduce((sum, file) => sum + file.size, 0) > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过
|
|
66
|
+
if (originals.some(file => file.size > MAX_FILE_BYTES)) throw new Error('服务器转发仅支持单个文件不超过 50 MiB,请使用局域网或 RTC 直连');
|
|
67
|
+
if (originals.reduce((sum, file) => sum + file.size, 0) > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过 50 MiB,请使用局域网或 RTC 直连');
|
|
68
68
|
}
|
|
69
69
|
if (message.type === 'commit') {
|
|
70
70
|
if (upload) throw new Error('文件尚未上传完成');
|
|
@@ -96,11 +96,11 @@ export function createFileUploadSession(root) {
|
|
|
96
96
|
if (!Number.isSafeInteger(message.size) || message.size < 1) {
|
|
97
97
|
throw new Error('文件大小无效');
|
|
98
98
|
}
|
|
99
|
-
if (relayed && message.size > MAX_FILE_BYTES) throw new Error('服务器转发仅支持单个文件不超过
|
|
99
|
+
if (relayed && message.size > MAX_FILE_BYTES) throw new Error('服务器转发仅支持单个文件不超过 50 MiB,请使用局域网或 RTC 直连');
|
|
100
100
|
const parent = message.previewOf ? completed.get(message.previewOf) : null;
|
|
101
101
|
if (message.previewOf && (!parent || parent.preview || message.size > FILE_CHUNK_BYTES)) throw new Error('预览图关联无效或超过 256 KiB');
|
|
102
102
|
if (!parent && completed.size >= MAX_FILE_COUNT) throw new Error('每条消息最多 4 个文件');
|
|
103
|
-
if (!parent && relayed && completedBytes + message.size > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过
|
|
103
|
+
if (!parent && relayed && completedBytes + message.size > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过 50 MiB,请使用局域网或 RTC 直连');
|
|
104
104
|
const id = crypto.randomUUID();
|
|
105
105
|
await fs.mkdir(directory, { recursive: true });
|
|
106
106
|
const partial = path.join(directory, `.upload-${id}`);
|
|
@@ -150,7 +150,7 @@ export function attachLanSocket(server, { token, dispatch, authorizeDevice = ()
|
|
|
150
150
|
json(status, body) { reply({ type: 'error', status, error: body?.error || '文件读取失败' }); },
|
|
151
151
|
filePart(metadata, data) {
|
|
152
152
|
if (stopped || ws.readyState !== WebSocket.OPEN) return;
|
|
153
|
-
if (fileRelay && metadata.size > FILE_READ_LIMIT) throw new Error('服务器转发仅支持下载不超过
|
|
153
|
+
if (fileRelay && metadata.size > FILE_READ_LIMIT) throw new Error('服务器转发仅支持下载不超过 50 MiB 的文件,请使用局域网或 RTC 直连');
|
|
154
154
|
if (!Buffer.isBuffer(data) || data.length > FILE_CHUNK_BYTES || ws.bufferedAmount > 1024 * 1024) throw new Error('文件接收过慢或分片无效');
|
|
155
155
|
reply({ type: 'part', ...metadata, length: data.length });
|
|
156
156
|
ws.send(data);
|
|
@@ -59,7 +59,13 @@ if ($Action -eq 'enable') {
|
|
|
59
59
|
$exec.Path = $wscript
|
|
60
60
|
$exec.Arguments = $arguments
|
|
61
61
|
$exec.WorkingDirectory = $env:USERPROFILE
|
|
62
|
-
|
|
62
|
+
try {
|
|
63
|
+
[void]$root.RegisterTaskDefinition($taskName, $definition, 6, $null, $null, 3, $null) # TASK_CREATE_OR_UPDATE
|
|
64
|
+
} catch {
|
|
65
|
+
if ($_.Exception.GetBaseException().HResult -ne -2147024891) { throw }
|
|
66
|
+
@{ enabled=$false; taskPresent=($registered.Count -gt 0); scope='current-user-logon'; mechanism='task-scheduler'; error='Windows Task Scheduler denied registration (0x80070005).' } | ConvertTo-Json -Compress
|
|
67
|
+
return
|
|
68
|
+
}
|
|
63
69
|
if ($legacyRegistered.Count -gt 0) { $root.DeleteTask($legacyTaskName, 0) }
|
|
64
70
|
} elseif ($Action -eq 'disable') {
|
|
65
71
|
if ($registered.Count -gt 0) { $root.DeleteTask($taskName, 0) }
|
|
@@ -41,6 +41,7 @@ export async function doctor({ paths, host, service, skillTarget, ensureAutostar
|
|
|
41
41
|
});
|
|
42
42
|
await check('autostart', async () => {
|
|
43
43
|
const state = await ensureAutostart();
|
|
44
|
+
if (state.error) { add('autostart', 'warning', `登录自启未启用:${state.error}`); return; }
|
|
44
45
|
add('autostart', 'ok', `当前用户登录自启:${state.repaired ? '已自动恢复' : '已启用'}。`);
|
|
45
46
|
});
|
|
46
47
|
await check('service', async () => {
|
package/package.json
CHANGED
package/tools/postinstall.mjs
CHANGED
|
@@ -54,7 +54,8 @@ export function formatSetupOutput(output) {
|
|
|
54
54
|
const result = JSON.parse(output);
|
|
55
55
|
const migration = result.managedAppServerMigration || {};
|
|
56
56
|
return `Code Relax ${result.version || '未知版本'} setup 已完成;接下来执行安装后健康检查。\n`
|
|
57
|
-
+ '工作站服务和 Codex
|
|
57
|
+
+ '工作站服务和 Codex 内核已就绪。\n'
|
|
58
|
+
+ (result.autostart?.enabled ? '已启用登录自启。\n' : `登录自启未启用。${result.autostart?.error || ''}\n`)
|
|
58
59
|
+ (result.preserveCodex ? '过渡版保留当前 Codex 和内核运行状态;待手机发起下一次完整更新。\n' : migration.restarted ? `Codex 内核已更新:${migration.previousVersion || '未知'} → ${result.managedAppServer?.version || '未知'}(PID ${migration.previousPid} → ${migration.currentPid})。\n` : 'Codex 内核已是当前选定版本,无需切换。\n')
|
|
59
60
|
+ (result.preserveCodex ? '' : result.desktopRestarted ? '电脑版 Codex 已重启,并确认连接到工作站内核。\n' : migration.restarted ? '桌面连接已随内核更新处理,无需再次重启。\n' : result.desktopWasRunning ? '电脑版 Codex 保持运行,服务更新无需重启桌面。\n' : '安装前未运行电脑版 Codex,保持关闭。\n')
|
|
60
61
|
+ (result.desktopRestartRecommended ? 'Codex Desktop:请完全退出后重新打开。\n' : '');
|