@ian2018cs/agenthub 0.2.9 → 0.2.11
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ian2018cs/agenthub",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "A web-based UI for AI Agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "server/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
54
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.89",
|
|
55
55
|
"@codemirror/lang-css": "^6.3.1",
|
|
56
56
|
"@codemirror/lang-html": "^6.4.9",
|
|
57
57
|
"@codemirror/lang-javascript": "^6.2.4",
|
package/server/claude-sdk.js
CHANGED
|
@@ -250,6 +250,11 @@ function mapCliOptionsToSDK(options = {}) {
|
|
|
250
250
|
sdkOptions.resume = sessionId;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
// Map per-request environment variables (e.g. CLAUDE_CONFIG_DIR for user isolation)
|
|
254
|
+
if (options.env) {
|
|
255
|
+
sdkOptions.env = options.env;
|
|
256
|
+
}
|
|
257
|
+
|
|
253
258
|
return sdkOptions;
|
|
254
259
|
}
|
|
255
260
|
|
|
@@ -552,11 +557,18 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|
|
552
557
|
let tempDir = null;
|
|
553
558
|
let abortController = null;
|
|
554
559
|
|
|
555
|
-
// Set CLAUDE_CONFIG_DIR for user isolation
|
|
560
|
+
// Set CLAUDE_CONFIG_DIR for user isolation via per-request env (avoids global process.env race condition).
|
|
561
|
+
// The SDK passes this env object to the Claude CLI subprocess, so each concurrent
|
|
562
|
+
// request gets its own isolated config directory without overwriting the global env.
|
|
556
563
|
if (userUuid) {
|
|
557
564
|
const userPaths = getUserPaths(userUuid);
|
|
558
|
-
|
|
559
|
-
|
|
565
|
+
options = {
|
|
566
|
+
...options,
|
|
567
|
+
env: {
|
|
568
|
+
...process.env,
|
|
569
|
+
CLAUDE_CONFIG_DIR: userPaths.claudeDir,
|
|
570
|
+
},
|
|
571
|
+
};
|
|
560
572
|
}
|
|
561
573
|
|
|
562
574
|
try {
|
|
@@ -48,6 +48,8 @@ const DANGEROUS_SCRIPT_PATTERNS = [
|
|
|
48
48
|
// 容器/云平台
|
|
49
49
|
{ pattern: /\bdocker\s+(rm|rmi|stop|kill|restart|network|volume|system\s+prune)\b/, reason: '管理 Docker' },
|
|
50
50
|
{ pattern: /\bkubectl\b/, reason: '操作 Kubernetes' },
|
|
51
|
+
{ pattern: /\bgcloud\b/, reason: '操作 Google Cloud' },
|
|
52
|
+
{ pattern: /\bbq\b/, reason: '使用 BigQuery CLI(bq)' },
|
|
51
53
|
// Web 服务器
|
|
52
54
|
{ pattern: /\bnginx\s+(-s\s+)?(reload|stop|start|restart|quit)\b/, reason: '管理 nginx' },
|
|
53
55
|
{ pattern: /\bapachectl\b/, reason: '管理 Apache' },
|
|
@@ -379,6 +381,7 @@ const rules = [
|
|
|
379
381
|
reason: '不允许管理 Docker 容器和资源' },
|
|
380
382
|
{ pattern: /\bkubectl\b/, reason: '不允许操作 Kubernetes' },
|
|
381
383
|
{ pattern: /\bgcloud\b/, reason: '不允许操作 Google Cloud' },
|
|
384
|
+
{ pattern: /\bbq\b/, reason: '不允许使用 BigQuery CLI(bq)' },
|
|
382
385
|
{ pattern: /\baws\s+(?!configure\s+list\b)/, reason: '不允许操作 AWS' },
|
|
383
386
|
{ pattern: /\bterraform\s+(apply|destroy|import)\b/, reason: '不允许执行 Terraform 变更' },
|
|
384
387
|
|
|
@@ -287,7 +287,10 @@ export async function initUserDirectories(userUuid) {
|
|
|
287
287
|
const settingsConfig = {
|
|
288
288
|
env: {
|
|
289
289
|
ANTHROPIC_AUTH_TOKEN: process.env.ANTHROPIC_AUTH_TOKEN || '',
|
|
290
|
-
ANTHROPIC_BASE_URL: process.env.ANTHROPIC_BASE_URL || ''
|
|
290
|
+
ANTHROPIC_BASE_URL: process.env.ANTHROPIC_BASE_URL || '',
|
|
291
|
+
CLAUDE_CODE_ATTRIBUTION_HEADER: '0',
|
|
292
|
+
CLAUDE_CODE_DISABLE_1M_CONTEXT: '1',
|
|
293
|
+
DISABLE_PROMPT_CACHING: '1'
|
|
291
294
|
}
|
|
292
295
|
};
|
|
293
296
|
await fs.writeFile(destSettings, JSON.stringify(settingsConfig, null, 2));
|