mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-19 07:36:52 +00:00
Make ephemeral sandboxes opt-in only
This commit is contained in:
@@ -61,6 +61,10 @@ export class AgentsConfig {
|
||||
@Env('N8N_AGENTS_AI_SANDBOX_TIMEOUT')
|
||||
sandboxTimeout: number = 5 * Time.minutes.toMilliseconds;
|
||||
|
||||
/** When true, Daytona deletes the knowledge sandbox when it stops. */
|
||||
@Env('N8N_AGENTS_AI_SANDBOX_EPHEMERAL')
|
||||
sandboxEphemeral: boolean = false;
|
||||
|
||||
/** Daytona volume ID for the agent knowledge base. */
|
||||
@Env('N8N_AGENTS_AI_SANDBOX_DAYTONA_VOLUME_ID')
|
||||
daytonaVolumeId: string = '';
|
||||
|
||||
@@ -592,6 +592,7 @@ describe('GlobalConfig', () => {
|
||||
sandboxProvider: '',
|
||||
sandboxImage: 'daytonaio/sandbox:0.5.0',
|
||||
sandboxTimeout: 300000,
|
||||
sandboxEphemeral: false,
|
||||
daytonaVolumeId: '',
|
||||
daytonaApiUrl: '',
|
||||
daytonaApiKey: '',
|
||||
@@ -608,6 +609,15 @@ describe('GlobalConfig', () => {
|
||||
expect(readFileSyncMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should parse N8N_AGENTS_AI_SANDBOX_EPHEMERAL from env variables', () => {
|
||||
process.env = {
|
||||
N8N_AGENTS_AI_SANDBOX_EPHEMERAL: 'true',
|
||||
};
|
||||
const config = Container.get(GlobalConfig);
|
||||
|
||||
expect(config.agents.sandboxEphemeral).toBe(true);
|
||||
});
|
||||
|
||||
it('should use values from env variables when defined', () => {
|
||||
process.env = {
|
||||
DB_POSTGRESDB_HOST: 'some-host',
|
||||
|
||||
@@ -90,6 +90,7 @@ function makeService(
|
||||
sandboxProvider: 'daytona',
|
||||
sandboxImage: 'daytonaio/sandbox:0.5.0',
|
||||
sandboxTimeout: 300_000,
|
||||
sandboxEphemeral: false,
|
||||
daytonaApiUrl: 'https://daytona.example',
|
||||
daytonaApiKey: 'test-key',
|
||||
daytonaVolumeId: volumeId,
|
||||
@@ -171,6 +172,16 @@ describe('AgentKnowledgeSandboxService', () => {
|
||||
'n8n-user-id': userId,
|
||||
});
|
||||
expect(params.volumes).toEqual([expectedVolumeMount]);
|
||||
expect(params.ephemeral).toBe(false);
|
||||
expect(options).toEqual({ timeout: 300 });
|
||||
});
|
||||
|
||||
it('forwards sandboxEphemeral config to Daytona create params', async () => {
|
||||
const service = makeService({ sandboxEphemeral: true });
|
||||
|
||||
await service.withKnowledgeFilesystem('project-1', 'agent-1', userId, async () => {});
|
||||
|
||||
const [params] = createMock.mock.calls[0];
|
||||
expect(params.ephemeral).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -199,7 +199,7 @@ export class AgentKnowledgeSandboxService {
|
||||
labels,
|
||||
language: 'typescript',
|
||||
image,
|
||||
ephemeral: true,
|
||||
ephemeral: this.agentsConfig.sandboxEphemeral,
|
||||
autoStopInterval: AUTO_STOP_INTERVAL_MINUTES,
|
||||
volumes: [volumeMount],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user