nanoclaw init
Some checks failed
Sync upstream & merge-forward skill branches / sync-and-merge (push) Has been cancelled
Merge-forward skill branches / merge-forward (push) Has been cancelled
Bump version / bump-version (push) Has been cancelled
Update token count / update-tokens (push) Has been cancelled

This commit is contained in:
woozu-shin
2026-03-24 01:43:09 +09:00
parent a1b8c70b5c
commit 4dc270d2dd
10 changed files with 1541 additions and 30 deletions

View File

@@ -26,6 +26,7 @@ import {
stopContainer,
} from './container-runtime.js';
import { detectAuthMode } from './credential-proxy.js';
import { readEnvFile } from './env.js';
import { validateAdditionalMounts } from './mount-security.js';
import { RegisteredGroup } from './types.js';
@@ -123,28 +124,37 @@ function buildVolumeMounts(
);
fs.mkdirSync(groupSessionsDir, { recursive: true });
const settingsFile = path.join(groupSessionsDir, 'settings.json');
if (!fs.existsSync(settingsFile)) {
fs.writeFileSync(
settingsFile,
JSON.stringify(
{
env: {
// Enable agent swarms (subagent orchestration)
// https://code.claude.com/docs/en/agent-teams#orchestrate-teams-of-claude-code-sessions
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1',
// Load CLAUDE.md from additional mounted directories
// https://code.claude.com/docs/en/memory#load-memory-from-additional-directories
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD: '1',
// Enable Claude's memory feature (persists user preferences between sessions)
// https://code.claude.com/docs/en/memory#manage-auto-memory
CLAUDE_CODE_DISABLE_AUTO_MEMORY: '0',
},
},
null,
2,
) + '\n',
);
// Read model/provider env vars from .env to forward into container settings
const providerEnv = readEnvFile([
'ANTHROPIC_MODEL',
'ANTHROPIC_SMALL_FAST_MODEL',
'ANTHROPIC_DEFAULT_SONNET_MODEL',
'ANTHROPIC_DEFAULT_OPUS_MODEL',
'ANTHROPIC_DEFAULT_HAIKU_MODEL',
'API_TIMEOUT_MS',
'CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC',
]);
const envBlock: Record<string, string> = {
// Enable agent swarms (subagent orchestration)
// https://code.claude.com/docs/en/agent-teams#orchestrate-teams-of-claude-code-sessions
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1',
// Load CLAUDE.md from additional mounted directories
// https://code.claude.com/docs/en/memory#load-memory-from-additional-directories
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD: '1',
// Enable Claude's memory feature (persists user preferences between sessions)
// https://code.claude.com/docs/en/memory#manage-auto-memory
CLAUDE_CODE_DISABLE_AUTO_MEMORY: '0',
};
// Merge provider env vars (from .env or process.env)
for (const [key, val] of Object.entries(providerEnv)) {
const effective = process.env[key] || val;
if (effective) envBlock[key] = effective;
}
// Always write settings to pick up env changes (model, provider, etc.)
fs.writeFileSync(
settingsFile,
JSON.stringify({ env: envBlock }, null, 2) + '\n',
);
// Sync skills from container/skills/ into each group's .claude/skills/
const skillsSrc = path.join(process.cwd(), 'container', 'skills');
@@ -238,6 +248,23 @@ function buildContainerArgs(
args.push('-e', 'CLAUDE_CODE_OAUTH_TOKEN=placeholder');
}
// Forward model and SDK configuration from .env to the container.
// These allow custom API providers (e.g. MiniMax) to override model names.
const MODEL_ENV_KEYS = [
'API_TIMEOUT_MS',
'CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC',
'ANTHROPIC_MODEL',
'ANTHROPIC_SMALL_FAST_MODEL',
'ANTHROPIC_DEFAULT_SONNET_MODEL',
'ANTHROPIC_DEFAULT_OPUS_MODEL',
'ANTHROPIC_DEFAULT_HAIKU_MODEL',
] as const;
const modelEnv = readEnvFile([...MODEL_ENV_KEYS]);
for (const key of MODEL_ENV_KEYS) {
const val = process.env[key] || modelEnv[key];
if (val) args.push('-e', `${key}=${val}`);
}
// Runtime-specific args for host gateway resolution
args.push(...hostGatewayArgs());