refactor: use static gateway skill instead of fetching on spawn
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) <noreply@anthropic.com>
This commit is contained in:
@@ -132,7 +132,7 @@ async function spawnContainer(session: Session): Promise<void> {
|
|||||||
// buildMounts and buildContainerArgs so side effects (mkdir, etc.) fire once.
|
// buildMounts and buildContainerArgs so side effects (mkdir, etc.) fire once.
|
||||||
const { provider, contribution } = resolveProviderContribution(session, agentGroup, containerConfig);
|
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()}`;
|
const containerName = `nanoclaw-v2-${agentGroup.folder}-${Date.now()}`;
|
||||||
// OneCLI agent identifier is always the agent group id — stable across
|
// OneCLI agent identifier is always the agent group id — stable across
|
||||||
// sessions and reversible via getAgentGroup() for approval routing.
|
// sessions and reversible via getAgentGroup() for approval routing.
|
||||||
@@ -239,12 +239,12 @@ function resolveProviderContribution(
|
|||||||
return { provider, contribution };
|
return { provider, contribution };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildMounts(
|
function buildMounts(
|
||||||
agentGroup: AgentGroup,
|
agentGroup: AgentGroup,
|
||||||
session: Session,
|
session: Session,
|
||||||
containerConfig: import('./container-config.js').ContainerConfig,
|
containerConfig: import('./container-config.js').ContainerConfig,
|
||||||
providerContribution: ProviderContainerContribution,
|
providerContribution: ProviderContainerContribution,
|
||||||
): Promise<VolumeMount[]> {
|
): VolumeMount[] {
|
||||||
const projectRoot = process.cwd();
|
const projectRoot = process.cwd();
|
||||||
|
|
||||||
// Per-group filesystem state lives forever after first creation. Init is
|
// 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.
|
// is a no-op for groups that have spawned before.
|
||||||
initGroupFilesystem(agentGroup);
|
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.
|
// Sync skill symlinks based on container.json selection before mounting.
|
||||||
const claudeDir = path.join(DATA_DIR, 'v2-sessions', agentGroup.id, '.claude-shared');
|
const claudeDir = path.join(DATA_DIR, 'v2-sessions', agentGroup.id, '.claude-shared');
|
||||||
syncSkillSymlinks(claudeDir, containerConfig);
|
syncSkillSymlinks(claudeDir, containerConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user