From f3e19872ac13b7a311c6b31fee9f74c8d8bc6daa Mon Sep 17 00:00:00 2001 From: gavrielc Date: Fri, 8 May 2026 01:07:09 +0300 Subject: [PATCH] refactor: use static gateway skill instead of fetching on spawn MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the dynamic `onecli.getGatewaySkill()` fetch from `buildMounts` — the skill content ships as a static SKILL.md. This avoids adding latency to every container spawn and dirtying the source tree at runtime. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../{SKILL.fallback.md => SKILL.md} | 0 src/container-runner.ts | 23 +++---------------- 2 files changed, 3 insertions(+), 20 deletions(-) rename container/skills/onecli-gateway/{SKILL.fallback.md => SKILL.md} (100%) diff --git a/container/skills/onecli-gateway/SKILL.fallback.md b/container/skills/onecli-gateway/SKILL.md similarity index 100% rename from container/skills/onecli-gateway/SKILL.fallback.md rename to container/skills/onecli-gateway/SKILL.md diff --git a/src/container-runner.ts b/src/container-runner.ts index 26af37930..27b0f5c6c 100644 --- a/src/container-runner.ts +++ b/src/container-runner.ts @@ -132,7 +132,7 @@ async function spawnContainer(session: Session): Promise { // buildMounts and buildContainerArgs so side effects (mkdir, etc.) fire once. const { provider, contribution } = resolveProviderContribution(session, agentGroup, containerConfig); - const mounts = await buildMounts(agentGroup, session, containerConfig, contribution); + const mounts = buildMounts(agentGroup, session, containerConfig, contribution); const containerName = `nanoclaw-v2-${agentGroup.folder}-${Date.now()}`; // OneCLI agent identifier is always the agent group id — stable across // sessions and reversible via getAgentGroup() for approval routing. @@ -239,12 +239,12 @@ function resolveProviderContribution( return { provider, contribution }; } -async function buildMounts( +function buildMounts( agentGroup: AgentGroup, session: Session, containerConfig: import('./container-config.js').ContainerConfig, providerContribution: ProviderContainerContribution, -): Promise { +): VolumeMount[] { const projectRoot = process.cwd(); // Per-group filesystem state lives forever after first creation. Init is @@ -252,23 +252,6 @@ async function buildMounts( // is a no-op for groups that have spawned before. initGroupFilesystem(agentGroup); - // Fetch the latest gateway skill from the API; fall back to the static copy. - const skillDir = path.join(projectRoot, 'container', 'skills', 'onecli-gateway'); - const skillPath = path.join(skillDir, 'SKILL.md'); - const fallbackPath = path.join(skillDir, 'SKILL.fallback.md'); - try { - const skill = await onecli.getGatewaySkill(); - const existing = fs.existsSync(skillPath) ? fs.readFileSync(skillPath, 'utf8') : ''; - if (skill && skill !== existing) { - fs.writeFileSync(skillPath, skill); - } - } catch { - if (!fs.existsSync(skillPath) && fs.existsSync(fallbackPath)) { - fs.copyFileSync(fallbackPath, skillPath); - } - log.warn('Could not fetch gateway skill from OneCLI API; using static fallback'); - } - // Sync skill symlinks based on container.json selection before mounting. const claudeDir = path.join(DATA_DIR, 'v2-sessions', agentGroup.id, '.claude-shared'); syncSkillSymlinks(claudeDir, containerConfig);