mercury-agent 0.4.10 → 0.4.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli/mercury.ts +38 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mercury-agent",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "Personal AI assistant for chat platforms (WhatsApp, Slack, Discord, Telegram)",
5
5
  "license": "MIT",
6
6
  "author": "Avishai Tsabari",
@@ -10,6 +10,7 @@ import {
10
10
  readdirSync,
11
11
  readFileSync,
12
12
  rmSync,
13
+ statSync,
13
14
  unlinkSync,
14
15
  writeFileSync,
15
16
  } from "node:fs";
@@ -37,6 +38,19 @@ const TEMPLATES_DIR = join(PACKAGE_ROOT, "resources/templates");
37
38
  const PROFILES_DIR = join(PACKAGE_ROOT, "resources/profiles");
38
39
  const VALID_EXT_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
39
40
 
41
+ function copyDirRecursive(src: string, dest: string): void {
42
+ mkdirSync(dest, { recursive: true });
43
+ for (const entry of readdirSync(src)) {
44
+ const srcPath = join(src, entry);
45
+ const destPath = join(dest, entry);
46
+ if (statSync(srcPath).isDirectory()) {
47
+ copyDirRecursive(srcPath, destPath);
48
+ } else {
49
+ copyFileSync(srcPath, destPath);
50
+ }
51
+ }
52
+ }
53
+
40
54
  function isPortInUse(port: string): boolean {
41
55
  if (process.platform === "win32") {
42
56
  const result = spawnSync("netstat", ["-ano"], {
@@ -171,13 +185,30 @@ async function runAction(): Promise<void> {
171
185
  stdio: "pipe",
172
186
  });
173
187
  if (imageCheck.status !== 0) {
174
- console.error(`Error: Container image '${imageName}' not found.`);
175
- if (imageName.startsWith("ghcr.io/")) {
176
- console.error(`Run 'docker pull ${imageName}' to pull it.`);
188
+ // If the configured (registry) image isn't available, try the local build tag
189
+ const localTag = "mercury-agent:latest";
190
+ if (imageName !== localTag) {
191
+ const localCheck = spawnSync("docker", ["image", "inspect", localTag], {
192
+ stdio: "pipe",
193
+ });
194
+ if (localCheck.status === 0) {
195
+ console.log(
196
+ `ℹ️ Registry image not found, using locally built ${localTag}\n`,
197
+ );
198
+ process.env.MERCURY_AGENT_IMAGE = localTag;
199
+ } else {
200
+ console.error(`Error: Container image '${imageName}' not found.`);
201
+ console.error(
202
+ `Pull it: docker pull ${imageName}\n` +
203
+ `Or build: mercury build`,
204
+ );
205
+ process.exit(1);
206
+ }
177
207
  } else {
208
+ console.error(`Error: Container image '${imageName}' not found.`);
178
209
  console.error("Run 'mercury build' to build it.");
210
+ process.exit(1);
179
211
  }
180
- process.exit(1);
181
212
  }
182
213
 
183
214
  console.log("🪽 Starting mercury...\n");
@@ -238,9 +269,8 @@ function buildAction(): void {
238
269
  );
239
270
  process.exit(1);
240
271
  }
241
- // Bun's cpSync with a filter callback silently fails on Windows
242
- // use without filter; node_modules exclusion is only needed in dev.
243
- cpSync(resourcesSrc, resourcesDest, { recursive: true });
272
+ // Bun's cpSync is broken on Windows use manual recursive copy.
273
+ copyDirRecursive(resourcesSrc, resourcesDest);
244
274
  if (!existsSync(resourcesDest)) {
245
275
  console.error(`❌ Failed to copy resources/ into build context`);
246
276
  console.error(` Source: ${resourcesSrc} (exists: ${existsSync(resourcesSrc)})`);
@@ -250,7 +280,7 @@ function buildAction(): void {
250
280
 
251
281
  const examplesSrc = join(PACKAGE_ROOT, "examples", "extensions");
252
282
  const examplesDest = join(tmpDir, "examples", "extensions");
253
- cpSync(examplesSrc, examplesDest, { recursive: true });
283
+ copyDirRecursive(examplesSrc, examplesDest);
254
284
 
255
285
  console.log(`📦 Building container image...`);
256
286
  console.log(` Package root: ${PACKAGE_ROOT}`);