@larkup/sandbox 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,4 @@
1
- (node:18200) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
2
- (Use `node --trace-warnings ...` to show where the warning was created)
3
1
 
4
- > @larkup/sandbox@0.1.0 build /Users/abdelrahmanabounida/Desktop/my-ai-startup/larkup/larkup/packages/sandbox
2
+ > @larkup/sandbox@0.1.1 build /Users/abdelrahmanabounida/Desktop/my-ai-startup/larkup/larkup/packages/sandbox
5
3
  > tsc --outDir dist
6
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @larkup/sandbox
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: lazy-import dockerode to prevent Turbopack hash mangling at runtime
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  ### Patch Changes
@@ -5,7 +5,6 @@
5
5
  * Each execution spins up a container, runs the code, captures output +
6
6
  * generated files, then auto-removes the container.
7
7
  */
8
- import Docker from 'dockerode';
9
8
  import { promises as fs } from 'node:fs';
10
9
  import path from 'node:path';
11
10
  import os from 'node:os';
@@ -15,8 +14,11 @@ const OUTPUT_DIR = '/sandbox/output';
15
14
  const INPUT_DIR = '/sandbox/input';
16
15
  const DOCKERFILE_DIR = path.join(import.meta.dirname ?? __dirname, '..');
17
16
  let dockerInstance = null;
18
- function getDocker() {
17
+ async function getDocker() {
19
18
  if (!dockerInstance) {
19
+ // Dynamic import prevents Turbopack from statically bundling dockerode
20
+ // and mangling its module name with a hash suffix.
21
+ const { default: Docker } = await import(/* turbopackIgnore: true */ 'dockerode');
20
22
  dockerInstance = new Docker();
21
23
  }
22
24
  return dockerInstance;
@@ -25,7 +27,7 @@ function getDocker() {
25
27
  /* Health check */
26
28
  /* ------------------------------------------------------------------ */
27
29
  export async function checkDockerHealth() {
28
- const docker = getDocker();
30
+ const docker = await getDocker();
29
31
  try {
30
32
  const info = await docker.version();
31
33
  const images = await docker.listImages({
@@ -50,7 +52,7 @@ export async function checkDockerHealth() {
50
52
  /* Image management */
51
53
  /* ------------------------------------------------------------------ */
52
54
  export async function buildSandboxImage(onProgress) {
53
- const docker = getDocker();
55
+ const docker = await getDocker();
54
56
  const dockerfilePath = path.join(DOCKERFILE_DIR, 'Dockerfile');
55
57
  // Check if Dockerfile exists in the package
56
58
  try {
@@ -78,7 +80,7 @@ export async function buildSandboxImage(onProgress) {
78
80
  onProgress?.('Sandbox image built successfully ✓');
79
81
  }
80
82
  export async function ensureImage() {
81
- const docker = getDocker();
83
+ const docker = await getDocker();
82
84
  const images = await docker.listImages({
83
85
  filters: { reference: [SANDBOX_IMAGE] },
84
86
  });
@@ -247,7 +249,7 @@ if artifacts:
247
249
  `;
248
250
  }
249
251
  export async function executeInDocker(request, config) {
250
- const docker = getDocker();
252
+ const docker = await getDocker();
251
253
  const startTime = Date.now();
252
254
  // Create a temporary directory for input files
253
255
  const tmpDir = path.join(os.tmpdir(), `larkup-sandbox-${randomUUID()}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larkup/sandbox",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,10 +30,10 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "dockerode": "^4.0.7"
33
+ "dockerode": "^5.0.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/dockerode": "^3.3.38",
36
+ "@types/dockerode": "^4.0.1",
37
37
  "typescript": "5.7.3"
38
38
  },
39
39
  "scripts": {
@@ -6,7 +6,6 @@
6
6
  * generated files, then auto-removes the container.
7
7
  */
8
8
 
9
- import Docker from 'dockerode';
10
9
  import { promises as fs } from 'node:fs';
11
10
  import path from 'node:path';
12
11
  import os from 'node:os';
@@ -25,10 +24,13 @@ const OUTPUT_DIR = '/sandbox/output';
25
24
  const INPUT_DIR = '/sandbox/input';
26
25
  const DOCKERFILE_DIR = path.join(import.meta.dirname ?? __dirname, '..');
27
26
 
28
- let dockerInstance: Docker | null = null;
27
+ let dockerInstance: any | null = null;
29
28
 
30
- function getDocker(): Docker {
29
+ async function getDocker(): Promise<any> {
31
30
  if (!dockerInstance) {
31
+ // Dynamic import prevents Turbopack from statically bundling dockerode
32
+ // and mangling its module name with a hash suffix.
33
+ const { default: Docker } = await import(/* turbopackIgnore: true */ 'dockerode');
32
34
  dockerInstance = new Docker();
33
35
  }
34
36
  return dockerInstance;
@@ -39,7 +41,7 @@ function getDocker(): Docker {
39
41
  /* ------------------------------------------------------------------ */
40
42
 
41
43
  export async function checkDockerHealth(): Promise<SandboxHealthCheck> {
42
- const docker = getDocker();
44
+ const docker = await getDocker();
43
45
  try {
44
46
  const info = await docker.version();
45
47
  const images = await docker.listImages({
@@ -65,7 +67,7 @@ export async function checkDockerHealth(): Promise<SandboxHealthCheck> {
65
67
  /* ------------------------------------------------------------------ */
66
68
 
67
69
  export async function buildSandboxImage(onProgress?: (msg: string) => void): Promise<void> {
68
- const docker = getDocker();
70
+ const docker = await getDocker();
69
71
  const dockerfilePath = path.join(DOCKERFILE_DIR, 'Dockerfile');
70
72
 
71
73
  // Check if Dockerfile exists in the package
@@ -105,7 +107,7 @@ export async function buildSandboxImage(onProgress?: (msg: string) => void): Pro
105
107
  }
106
108
 
107
109
  export async function ensureImage(): Promise<boolean> {
108
- const docker = getDocker();
110
+ const docker = await getDocker();
109
111
  const images = await docker.listImages({
110
112
  filters: { reference: [SANDBOX_IMAGE] },
111
113
  });
@@ -279,7 +281,7 @@ export async function executeInDocker(
279
281
  request: ExecutionRequest,
280
282
  config: DockerConfig,
281
283
  ): Promise<ExecutionResult> {
282
- const docker = getDocker();
284
+ const docker = await getDocker();
283
285
  const startTime = Date.now();
284
286
 
285
287
  // Create a temporary directory for input files
@@ -319,7 +321,7 @@ export async function executeInDocker(
319
321
 
320
322
  const timeout = request.timeout ?? config.timeoutMs;
321
323
 
322
- let container: Docker.Container | null = null;
324
+ let container: any | null = null;
323
325
  try {
324
326
  container = await docker.createContainer({
325
327
  Image: config.imageName,