xiaozuoassistant 0.1.90 → 0.1.91

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/bin/cli.js CHANGED
@@ -372,8 +372,34 @@ async function updateApp() {
372
372
  await stopServer();
373
373
  }
374
374
 
375
+ // Backup user config before update
376
+ const configPath = path.join(APP_HOME, 'config.json');
377
+ const configBackupPath = path.join(APP_HOME, 'config.json.bak');
378
+ let configBackedUp = false;
379
+ if (fs.existsSync(configPath)) {
380
+ try {
381
+ fs.copyFileSync(configPath, configBackupPath);
382
+ configBackedUp = true;
383
+ console.log('[CLI] 用户配置已备份。');
384
+ } catch (e) {
385
+ console.warn('[CLI] ⚠️ 用户配置备份失败:', e);
386
+ }
387
+ }
388
+
375
389
  console.log(`[CLI] 正在更新 xiaozuoassistant(registry=${registry})...`);
376
390
  const code = await runWithSudoIfNeeded('npm', ['install', '-g', 'xiaozuoassistant@latest', `--registry=${registry}`]);
391
+
392
+ // Restore user config after update
393
+ if (configBackedUp && fs.existsSync(configBackupPath)) {
394
+ try {
395
+ fs.copyFileSync(configBackupPath, configPath);
396
+ fs.unlinkSync(configBackupPath);
397
+ console.log('[CLI] 用户配置已恢复。');
398
+ } catch (e) {
399
+ console.warn('[CLI] ⚠️ 用户配置恢复失败:', e);
400
+ }
401
+ }
402
+
377
403
  if (code !== 0) {
378
404
  console.error('[CLI] ❌ 更新失败。');
379
405
  if (wasRunning) {
package/config.json CHANGED
@@ -6,13 +6,13 @@
6
6
  "userId": "bigBoss",
7
7
  "llm": {
8
8
  "provider": "qwen",
9
- "apiKey": "sk-e4a47318eab748e2b2a11110c77c39a1",
9
+ "apiKey": "",
10
10
  "baseURL": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
11
11
  "model": "qwen-plus",
12
+ "embeddingModel": "text-embedding-ada-002",
12
13
  "temperature": 0.7,
13
- "requestTimeoutMs": 600000,
14
- "maxRetries": 2,
15
- "maxToolIterations": 200
14
+ "maxHistoryMessages": 10,
15
+ "maxToolIterations": 5
16
16
  },
17
17
  "logging": {
18
18
  "level": "info"
@@ -443,12 +443,16 @@ app.get('/api/auth/:provider/authorize', (req, res) => {
443
443
  const host = req.get('host') || 'localhost:3001';
444
444
  const redirectUri = encodeURIComponent(`${protocol}://${host}/api/auth/${provider}/callback`);
445
445
  if (provider === 'lark') {
446
- const appId = config.channels?.feishu?.appId || 'cli_a939363208f8dbb4'; // 使用已有配置或默认
446
+ const appId = config.channels?.feishu?.appId;
447
+ const appSecret = config.channels?.feishu?.appSecret;
448
+ if (!appId || !appSecret) {
449
+ return res.status(500).send('Feishu credentials not configured');
450
+ }
447
451
  authUrl = `https://open.feishu.cn/open-apis/authen/v1/user_auth_page_beta?app_id=${appId}&redirect_uri=${redirectUri}&state=${state}`;
448
452
  }
449
453
  else if (provider === 'wps') {
450
454
  // WPS OAuth 2.0 文档参考:https://open.wps.cn/docs/office/auth
451
- const appId = 'your_wps_app_id'; // 需要在 WPS 开放平台申请
455
+ const appId = process.env.WPS_APP_ID || ''; // 需要在 WPS 开放平台申请
452
456
  authUrl = `https://openapi.wps.cn/oauthapi/v2/authorize?response_type=code&app_id=${appId}&redirect_uri=${redirectUri}&state=${state}`;
453
457
  }
454
458
  else {
@@ -479,8 +483,11 @@ app.get('/api/auth/:provider/callback', async (req, res) => {
479
483
  try {
480
484
  let tokenData;
481
485
  if (provider === 'lark') {
482
- const appId = config.channels?.feishu?.appId || 'cli_a939363208f8dbb4';
483
- const appSecret = config.channels?.feishu?.appSecret || 'e6oamY93lKQt9JFkbdWmGC6ULjNKAU62';
486
+ const appId = config.channels?.feishu?.appId;
487
+ const appSecret = config.channels?.feishu?.appSecret;
488
+ if (!appId || !appSecret) {
489
+ throw new Error('Feishu credentials not configured');
490
+ }
484
491
  // 1. 获取 app_access_token
485
492
  const appTokenRes = await axios.post('https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal', {
486
493
  app_id: appId,
@@ -498,8 +505,11 @@ app.get('/api/auth/:provider/callback', async (req, res) => {
498
505
  oauthTokens.set('lark', tokenData); // 实际应持久化
499
506
  }
500
507
  else if (provider === 'wps') {
501
- const appId = 'your_wps_app_id';
502
- const appSecret = 'your_wps_app_secret';
508
+ const appId = process.env.WPS_APP_ID || '';
509
+ const appSecret = process.env.WPS_APP_SECRET || '';
510
+ if (!appId || !appSecret) {
511
+ throw new Error('WPS credentials not configured in environment variables');
512
+ }
503
513
  // WPS 用 code 换 token
504
514
  const tokenRes = await axios.post('https://openapi.wps.cn/oauthapi/v2/token', {
505
515
  app_id: appId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaozuoassistant",
3
- "version": "0.1.90",
3
+ "version": "0.1.91",
4
4
  "description": "A local-first personal AI assistant with multi-channel support and enhanced memory.",
5
5
  "author": "mantle.lau",
6
6
  "license": "MIT",