foliko 1.1.47 → 1.1.49

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.
@@ -7,7 +7,8 @@ const fs = require('fs');
7
7
  const path = require('path');
8
8
  const { spawn } = require('child_process');
9
9
  const dotenv = require('dotenv');
10
-
10
+ // 加载 .env 文件
11
+ dotenv.config();
11
12
  // Daemon 脚本路径
12
13
  const DAEMON_SCRIPT = path.join(__dirname, '../daemon.js');
13
14
 
package/cli/src/daemon.js CHANGED
@@ -7,6 +7,26 @@
7
7
  const fs = require('fs');
8
8
  const path = require('path');
9
9
 
10
+ // 默认配置
11
+ const DEFAULT_CONFIG = {
12
+ model: 'MiniMax-M2.7',
13
+ provider: 'minimax',
14
+ baseURL: 'https://api.minimaxi.com/v1',
15
+ apiKey: null,
16
+ };
17
+
18
+ // Provider 默认配置
19
+ const PROVIDER_DEFAULTS = {
20
+ minimax: {
21
+ model: 'MiniMax-M2.7',
22
+ baseURL: 'https://api.minimaxi.com/v1',
23
+ },
24
+ deepseek: {
25
+ model: 'deepseek-chat',
26
+ baseURL: 'https://api.deepseek.com/v1',
27
+ },
28
+ };
29
+
10
30
  // 解析命令行参数 --cwd <path>
11
31
  const cwdArg = process.argv.find((arg) => arg === '--cwd');
12
32
  const daemonCwd = cwdArg ? process.argv[process.argv.indexOf(cwdArg) + 1] : process.cwd();
@@ -53,16 +73,58 @@ const { Framework } = require('../../src');
53
73
  // 调试:打印接收到的环境变量
54
74
  console.log('[DEBUG] process.env.QQ_APP_ID =', process.env.QQ_APP_ID);
55
75
  console.log('[DEBUG] process.env.QQ_CLIENT_SECRET =', process.env.QQ_CLIENT_SECRET ? '***' + process.env.QQ_CLIENT_SECRET.slice(-6) : 'undefined');
76
+ console.log('[DEBUG] process.env.FOLIKO_API_KEY =', process.env.FOLIKO_API_KEY ? '***' + process.env.FOLIKO_API_KEY.slice(-6) : 'undefined');
56
77
 
57
- async function main() {
58
- console.log('[Foliko] 启动后台服务...');
78
+ /**
79
+ * 获取环境变量配置
80
+ */
81
+ function getEnvConfig() {
82
+ const provider = process.env.FOLIKO_PROVIDER || DEFAULT_CONFIG.provider;
83
+ const providerDefaults = PROVIDER_DEFAULTS[provider] || PROVIDER_DEFAULTS.minimax;
84
+
85
+ // 支持多种 API key 环境变量名
86
+ let apiKey = process.env.FOLIKO_API_KEY || null;
87
+ if (!apiKey) {
88
+ // 根据 provider 查找对应的 API key
89
+ const upperProvider = provider.toUpperCase().replace(/-/g, '_');
90
+ apiKey = process.env[`${upperProvider}_API_KEY`] || null;
91
+ }
92
+
93
+ return {
94
+ model: process.env.FOLIKO_MODEL || providerDefaults.model,
95
+ provider: provider,
96
+ baseURL: process.env.FOLIKO_BASE_URL || providerDefaults.baseURL,
97
+ apiKey: apiKey,
98
+ };
99
+ }
100
+
101
+ /**
102
+ * 解析命令行参数(命令行参数优先于环境变量)
103
+ */
104
+ function parseArgs(args) {
105
+ // 先获取环境变量配置(作为默认值)
106
+ const envConfig = getEnvConfig();
107
+ const options = { ...envConfig };
59
108
 
109
+ return options;
110
+ }
111
+
112
+
113
+ async function main(args = process.argv.slice(2)) {
114
+ console.log('[Foliko] 启动后台服务...');
115
+ const options = parseArgs(args);
60
116
  // 创建框架
61
117
  const framework = new Framework({ debug: false });
62
118
 
63
119
  // 使用 bootstrap 自动加载所有默认插件
64
120
  await framework.bootstrap({
65
121
  agentDir: './.agent',
122
+ aiConfig: {
123
+ provider: options.provider,
124
+ model: options.model,
125
+ apiKey: options.apiKey,
126
+ baseURL: options.baseURL,
127
+ },
66
128
  });
67
129
 
68
130
  console.log('[Foliko] 框架已就绪');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foliko",
3
- "version": "1.1.47",
3
+ "version": "1.1.49",
4
4
  "description": "简约的插件化 Agent 框架",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",