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.
- package/lib/desktop.js +44 -27
- 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
|
|
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
|
-
//
|
|
120
|
+
// 写入 Claude-3p/configLibrary/ 下的 enterprise config 条目(主进程从此处读取)
|
|
121
121
|
function writeClaudeDesktopConfig(config, options = {}) {
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
122
|
+
const dataDir = options.dataDir || getClaudeDesktopDataDir(options);
|
|
123
|
+
if (!dataDir) {
|
|
124
124
|
return { result: 'unsupported', file: null };
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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 = {}) {
|