engine7 7.1.45 → 7.1.46

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +19 -2
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -2157,7 +2157,7 @@ function generateConfig(v) {
2157
2157
  config.models.providers[v.primaryProvider] = {
2158
2158
  baseUrl: (v.customBaseUrl || "").trim(),
2159
2159
  api: "anthropic",
2160
- apiKey: v.primaryApiKey.trim(),
2160
+ apiKey: "env:" + v.primaryProvider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY",
2161
2161
  models: [
2162
2162
  { id: v.customModelId, name: v.customModelId, reasoning: false, input: ["text"], contextWindow: 2e5, maxTokens: 8192 }
2163
2163
  ]
@@ -2170,7 +2170,7 @@ function generateConfig(v) {
2170
2170
  }
2171
2171
  config.models.providers[v.primaryProvider] = {
2172
2172
  ...def,
2173
- apiKey: v.primaryApiKey.trim(),
2173
+ apiKey: "env:" + v.primaryProvider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY",
2174
2174
  ...def.baseUrl ? { baseUrl: def.baseUrl.trim() } : {}
2175
2175
  };
2176
2176
  }
@@ -3111,6 +3111,23 @@ WantedBy=default.target`;
3111
3111
  } else {
3112
3112
  console.log("\n\u{1F4E6} \u6B63\u5728\u521B\u5EFA\u76EE\u5F55\u548C\u6587\u4EF6...\n");
3113
3113
  execute(tree);
3114
+ if (values.primaryApiKey && values.primaryApiKey.trim()) {
3115
+ const envName = values.primaryProvider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY";
3116
+ const secretsDir = path3.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7-secrets");
3117
+ if (!fs3.existsSync(secretsDir)) fs3.mkdirSync(secretsDir, { recursive: true });
3118
+ const envFile = path3.join(secretsDir, "main7.env");
3119
+ let envContent = "";
3120
+ if (fs3.existsSync(envFile)) envContent = fs3.readFileSync(envFile, "utf8");
3121
+ const lines = envContent.split("\n").filter((l) => l && !l.startsWith(envName + "="));
3122
+ lines.push(envName + "=" + values.primaryApiKey.trim());
3123
+ fs3.writeFileSync(envFile, lines.join("\n") + "\n", "utf8");
3124
+ try {
3125
+ fs3.chmodSync(envFile, 384);
3126
+ } catch {
3127
+ }
3128
+ console.log("\u{1F511} API key \u5DF2\u5B58\u5165: " + envFile);
3129
+ console.log(" config \u91CC\u53EA\u6709 env:" + envName + " \u5360\u4F4D\u7B26\uFF0C\u660E\u6587\u4E0D\u843D config");
3130
+ }
3114
3131
  const skillsSrc = findTemplateDir("skills");
3115
3132
  if (skillsSrc) {
3116
3133
  const skillsDest = path3.join(opts.stateDir, "workspace", "skills");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.1.45",
3
+ "version": "7.1.46",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — 给助手一个家 / A home for your AI assistant",
6
6
  "main": "dist/main.mjs",