Files
woniu336 141ed9f4a8 feat(llm): DeepSeek Flash + 思考模式;本地密钥加载器
- llm_profiles 增加 thinking / reasoning_effort(migrations/0002),
  ensureD1Schema 容忍 ALTER 重复列,已有库平滑升级
- /api/read 按 profile 组装 thinking / reasoning_effort;只转发 delta.content,
  思考链 reasoning_content 不下发;max_tokens 4096
- 后台 LLM 表单新增「思考模式」「思考强度」,列表显示当前设置;测试连通沿用同一配置
- scripts/load-secrets.mjs:启动前读取 .llm.local(gitignore),
  dev / dev:bg / dev:vinext / build:vinext / start:vinext 共用
- 解卦面板显示「研墨中 · Ns」,思考模式首字慢时有提示
- 新增 llm-request 纯函数与 4 项测试;总 68 项测试通过

本地实测:DeepSeek Flash + thinking=high,/api/read 约 23s、840 字、四段齐全;
UI 4 标题/5 段、0 错误。密钥仅存于 .llm.local(不进仓库/D1)。
2026-11-05 14:36:38 +08:00

43 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Next 启动器:清掉宿主进程泄漏进来的 Next 私有环境变量,再原样转发参数。
*
* 背景:`__NEXT_PRIVATE_STANDALONE_CONFIG` 只有 Next 自己的 standalone server 才该设置。
* 若从宿主的 Electron / 打包应用继承到本项目的 `next dev` / `next build`,
* 会被当成真实配置读入(distDir 被改成别的目录、outputFileTracingRoot 指到不存在的路径),
* 表现为 dev 起不来、或 build 直接 `TypeError: generate is not a function`。
*
* node scripts/next.mjs dev
* node scripts/next.mjs build
*/
import { spawn } from 'node:child_process';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { loadLocalSecrets } from './load-secrets.mjs';
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
loadLocalSecrets(projectRoot);
const nextBin = path.join(projectRoot, 'node_modules', 'next', 'dist', 'bin', 'next');
const env = { ...process.env };
for (const key of Object.keys(env)) {
if (key.startsWith('__NEXT_PRIVATE_')) delete env[key];
}
const child = spawn(process.execPath, [nextBin, ...process.argv.slice(2)], {
cwd: projectRoot,
env,
stdio: 'inherit',
windowsHide: true,
});
child.once('exit', (code, signal) => {
if (signal) process.kill(process.pid, signal);
else process.exit(code ?? 0);
});
child.once('error', (err) => {
console.error(`[next] 启动失败:${err.message}`);
process.exit(1);
});