@farazirfan/costar-server-executor 1.7.34 → 1.7.35

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farazirfan/costar-server-executor",
3
- "version": "1.7.34",
3
+ "version": "1.7.35",
4
4
  "description": "CoStar Server Executor - 24/7 autonomous agent in TypeScript (cloned from OpenClaw)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -5,7 +5,7 @@
5
5
  * 1. Ensure the CLI entry point is executable
6
6
  * 2. Attempt to install Playwright Chromium (for browser tool)
7
7
  * 3. Create ~/.costar directory
8
- * 4. Install Docker + build sandbox browser image on Linux (for VNC live view)
8
+ * 4. Install Docker on Linux if missing (image auto-builds on first browser use)
9
9
  */
10
10
 
11
11
  import fs from "node:fs";
@@ -109,80 +109,44 @@ function installPlaywrightBrowsers() {
109
109
  }
110
110
  }
111
111
 
112
- function setupDockerBrowserSandbox() {
112
+ function ensureDocker() {
113
113
  // Only on Linux (Hetzner / sandbox VMs)
114
114
  if (process.platform !== "linux") return;
115
115
 
116
- const repoRoot = getRepoRoot();
117
-
118
- // Step 1: Install Docker if not present
116
+ // Check if Docker is already installed
119
117
  const dockerCheck = spawnSync("docker", ["--version"], { stdio: "pipe", timeout: 5000 });
120
- if (dockerCheck.status !== 0) {
121
- console.log("[postinstall] Docker not found, installing...");
122
- const whoami = spawnSync("whoami", [], { stdio: "pipe", encoding: "utf-8", timeout: 3000 });
123
- const isRoot = whoami.stdout?.trim() === "root";
124
- const sudo = isRoot ? "" : "sudo ";
125
-
126
- const installResult = spawnSync("sh", ["-c",
127
- `curl -fsSL https://get.docker.com | ${sudo}sh 2>&1`
128
- ], {
129
- stdio: "inherit",
130
- timeout: 180_000, // 3 min
131
- });
132
-
133
- if (installResult.status !== 0) {
134
- console.warn("[postinstall] Docker install failed (browser will work without live view)");
135
- return;
136
- }
137
- console.log("[postinstall] Docker installed successfully");
138
- } else {
118
+ if (dockerCheck.status === 0) {
139
119
  console.log("[postinstall] Docker already installed");
120
+ return;
140
121
  }
141
122
 
142
- // Step 2: Check if Docker daemon is running
143
- const infoCheck = spawnSync("docker", ["info"], { stdio: "pipe", timeout: 10_000 });
144
- if (infoCheck.status !== 0) {
145
- console.log("[postinstall] Docker daemon not running, attempting to start...");
146
- const whoami = spawnSync("whoami", [], { stdio: "pipe", encoding: "utf-8", timeout: 3000 });
147
- const isRoot = whoami.stdout?.trim() === "root";
148
- const sudo = isRoot ? "" : "sudo ";
149
- spawnSync("sh", ["-c", `${sudo}systemctl start docker 2>&1 || ${sudo}service docker start 2>&1`], {
150
- stdio: "inherit",
151
- timeout: 15_000,
152
- });
153
- }
123
+ // Install Docker
124
+ console.log("[postinstall] Docker not found, installing...");
125
+ const whoami = spawnSync("whoami", [], { stdio: "pipe", encoding: "utf-8", timeout: 3000 });
126
+ const isRoot = whoami.stdout?.trim() === "root";
127
+ const sudo = isRoot ? "" : "sudo ";
154
128
 
155
- // Step 3: Build the sandbox browser Docker image
156
- const dockerfile = path.join(repoRoot, "Dockerfile.sandbox-browser");
157
- if (!fs.existsSync(dockerfile)) {
158
- console.warn("[postinstall] Dockerfile.sandbox-browser not found, skipping image build");
129
+ const installResult = spawnSync("sh", ["-c",
130
+ `curl -fsSL https://get.docker.com | ${sudo}sh 2>&1`
131
+ ], {
132
+ stdio: "inherit",
133
+ timeout: 180_000, // 3 min
134
+ });
135
+
136
+ if (installResult.status !== 0) {
137
+ console.warn("[postinstall] Docker install failed (browser sandbox will not be available)");
159
138
  return;
160
139
  }
140
+ console.log("[postinstall] Docker installed successfully");
161
141
 
162
- // Check if image already exists
163
- const imageCheck = spawnSync("docker", ["image", "inspect", "costar-sandbox-browser:bookworm-slim"], {
164
- stdio: "pipe",
165
- timeout: 10_000,
142
+ // Start Docker daemon
143
+ spawnSync("sh", ["-c", `${sudo}systemctl start docker 2>&1 || ${sudo}service docker start 2>&1`], {
144
+ stdio: "inherit",
145
+ timeout: 15_000,
166
146
  });
167
- if (imageCheck.status === 0) {
168
- console.log("[postinstall] Docker sandbox browser image already exists");
169
- return;
170
- }
171
147
 
172
- console.log("[postinstall] Building sandbox browser Docker image (this may take a few minutes)...");
173
- const setupScript = path.join(repoRoot, "scripts", "sandbox-browser-setup.sh");
174
- if (fs.existsSync(setupScript)) {
175
- const buildResult = spawnSync("bash", [setupScript], {
176
- stdio: "inherit",
177
- timeout: 300_000, // 5 min
178
- cwd: repoRoot,
179
- });
180
- if (buildResult.status === 0) {
181
- console.log("[postinstall] Sandbox browser Docker image built successfully");
182
- } else {
183
- console.warn("[postinstall] Docker image build failed (browser will work without live view)");
184
- }
185
- }
148
+ // Note: Docker image will be auto-built on first browser use (see browser-container.ts)
149
+ console.log("[postinstall] Docker image will be built automatically on first browser use");
186
150
  }
187
151
 
188
152
  // ─── Main ──────────────────────────────────────────────────────
@@ -206,8 +170,8 @@ try {
206
170
  // Install Chromium (optional, may fail gracefully)
207
171
  installPlaywrightBrowsers();
208
172
 
209
- // Install Docker + build browser sandbox image on Linux
210
- setupDockerBrowserSandbox();
173
+ // Install Docker on Linux (image auto-builds on first browser use)
174
+ ensureDocker();
211
175
  }
212
176
  } catch (err) {
213
177
  // Postinstall should never fail the npm install