diff --git a/.env.example b/.env.example index b90e6c9..e69de29 100644 --- a/.env.example +++ b/.env.example @@ -1 +0,0 @@ -TELEGRAM_BOT_TOKEN= diff --git a/src/claw-skill.test.ts b/src/claw-skill.test.ts index 24260c9..2d86c8e 100644 --- a/src/claw-skill.test.ts +++ b/src/claw-skill.test.ts @@ -6,7 +6,7 @@ import { spawnSync } from 'child_process'; import { describe, expect, it } from 'vitest'; describe('claw skill script', () => { - it('exits zero after successful structured output even if the runtime is terminated', () => { + it('exits zero after successful structured output even if the runtime is terminated', { timeout: 20000 }, () => { const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claw-skill-test-')); const binDir = path.join(tempDir, 'bin'); fs.mkdirSync(binDir, { recursive: true }); diff --git a/src/container-runner.test.ts b/src/container-runner.test.ts index 64c3455..36fca0a 100644 --- a/src/container-runner.test.ts +++ b/src/container-runner.test.ts @@ -51,6 +51,14 @@ vi.mock('./mount-security.js', () => ({ validateAdditionalMounts: vi.fn(() => []), })); +// Mock container-runtime +vi.mock('./container-runtime.js', () => ({ + CONTAINER_RUNTIME_BIN: 'docker', + hostGatewayArgs: () => [], + readonlyMountArgs: (h: string, c: string) => ['-v', `${h}:${c}:ro`], + stopContainer: vi.fn(), +})); + // Mock OneCLI SDK vi.mock('@onecli-sh/sdk', () => ({ OneCLI: class { diff --git a/src/container-runner.ts b/src/container-runner.ts index facc68c..f6f86b1 100644 --- a/src/container-runner.ts +++ b/src/container-runner.ts @@ -2,7 +2,7 @@ * Container Runner for NanoClaw * Spawns agent execution in containers and handles IPC */ -import { ChildProcess, exec, spawn } from 'child_process'; +import { ChildProcess, spawn } from 'child_process'; import fs from 'fs'; import path from 'path'; @@ -431,15 +431,15 @@ export async function runContainerAgent( { group: group.name, containerName }, 'Container timeout, stopping gracefully', ); - exec(stopContainer(containerName), { timeout: 15000 }, (err) => { - if (err) { - logger.warn( - { group: group.name, containerName, err }, - 'Graceful stop failed, force killing', - ); - container.kill('SIGKILL'); - } - }); + try { + stopContainer(containerName); + } catch (err) { + logger.warn( + { group: group.name, containerName, err }, + 'Graceful stop failed, force killing', + ); + container.kill('SIGKILL'); + } }; let timeout = setTimeout(killOnTimeout, timeoutMs);