yingclaw 2.0.4 → 2.0.7

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/lib/desktop.js +44 -27
  2. package/package.json +1 -1
package/lib/desktop.js CHANGED
@@ -16,7 +16,7 @@ const DESKTOP_GATEWAY_KEYS = [
16
16
  'deploymentOrganizationUuid',
17
17
  ];
18
18
 
19
- // Claude 3P 数据目录(与 1P 的 Claude/ 目录区分)
19
+ // Claude Desktop 主进程从 Claude-3p/ 目录读取 deploymentMode 和 enterpriseConfig
20
20
  function getClaudeDesktopDataDir(options = {}) {
21
21
  const platform = options.platform || process.platform;
22
22
  const homeDir = options.homeDir || os.homedir();
@@ -117,39 +117,56 @@ function clearClaudeDesktopConfigLibrary(options = {}) {
117
117
  return { result: 'updated', dir };
118
118
  }
119
119
 
120
- // 旧版写法:写入 Claude-3p/claude_desktop_config.json,保留用户其他偏好。
120
+ // 写入 Claude-3p/configLibrary/ 下的 enterprise config 条目(主进程从此处读取)
121
121
  function writeClaudeDesktopConfig(config, options = {}) {
122
- const file = options.configFile || getClaudeDesktopConfigPath(options);
123
- if (!file) {
122
+ const dataDir = options.dataDir || getClaudeDesktopDataDir(options);
123
+ if (!dataDir) {
124
124
  return { result: 'unsupported', file: null };
125
125
  }
126
126
 
127
- const current = readJsonFile(file);
128
- const existingEnterpriseConfig = current.enterpriseConfig && typeof current.enterpriseConfig === 'object'
129
- ? current.enterpriseConfig
130
- : {};
131
- const deploymentUuid = existingEnterpriseConfig.deploymentOrganizationUuid || options.uuid;
132
-
133
- const enterpriseConfig = buildClaudeDesktopEnterpriseConfig(config, {
134
- authScheme: options.authScheme,
135
- uuid: deploymentUuid,
136
- });
137
-
138
- const next = {
139
- ...current,
140
- deploymentMode: '3p',
141
- enterpriseConfig: {
142
- ...existingEnterpriseConfig,
143
- ...enterpriseConfig,
144
- },
127
+ const configLibraryDir = path.join(dataDir, 'configLibrary');
128
+ const existingMetaFile = path.join(configLibraryDir, '_meta.json');
129
+ const existingMeta = readJsonFile(existingMetaFile);
130
+ const uuid = existingMeta.appliedId || options.uuid || crypto.randomUUID();
131
+
132
+ const models = collectModels(config);
133
+ const baseUrl = normalizeAnthropicBaseUrl(config.baseUrl);
134
+ if (!baseUrl.startsWith('https://')) {
135
+ throw new Error('Claude 桌面应用要求 Gateway Base URL 使用 HTTPS');
136
+ }
137
+
138
+ const entry = {
139
+ inferenceProvider: 'gateway',
140
+ inferenceGatewayBaseUrl: baseUrl,
141
+ inferenceGatewayApiKey: config.apiKey,
142
+ inferenceGatewayAuthScheme: options.authScheme || 'bearer',
143
+ inferenceModels: models,
144
+ disableDeploymentModeChooser: true,
145
+ deploymentOrganizationUuid: uuid,
145
146
  };
146
147
 
148
+ const meta = {
149
+ appliedId: uuid,
150
+ entries: [{ id: uuid, name: 'yingclaw' }],
151
+ isManaged: false,
152
+ platform: process.platform,
153
+ };
154
+
155
+ fs.mkdirSync(configLibraryDir, { recursive: true });
156
+
157
+ const entryFile = path.join(configLibraryDir, `${uuid}.json`);
158
+ const beforeEntry = fs.existsSync(entryFile) ? fs.readFileSync(entryFile, 'utf8') : '';
159
+ const entryBody = JSON.stringify(entry, null, 2) + '\n';
160
+ fs.writeFileSync(entryFile, entryBody);
161
+ fs.writeFileSync(existingMetaFile, JSON.stringify(meta, null, 2) + '\n');
162
+
163
+ const file = options.configFile || path.join(dataDir, 'claude_desktop_config.json');
164
+ const current = readJsonFile(file);
165
+ const next = { ...current, deploymentMode: '3p' };
147
166
  fs.mkdirSync(path.dirname(file), { recursive: true });
148
- const before = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
149
- const body = JSON.stringify(next, null, 2) + '\n';
150
- fs.writeFileSync(file, body);
151
- clearClaudeDesktopConfigLibrary({ ...options, dataDir: path.dirname(file) });
152
- return { result: before === body ? 'unchanged' : 'updated', file };
167
+ fs.writeFileSync(file, JSON.stringify(next, null, 2) + '\n');
168
+
169
+ return { result: beforeEntry === entryBody ? 'unchanged' : 'updated', file };
153
170
  }
154
171
 
155
172
  function clearClaudeDesktopConfig(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yingclaw",
3
- "version": "2.0.4",
3
+ "version": "2.0.7",
4
4
  "description": "Claude Code × 国产大模型一键接入:DeepSeek、Kimi、Qwen、MiniMax、GLM、MiMo",
5
5
  "main": "index.js",
6
6
  "bin": {