@chrysb/alphaclaw 0.1.9 → 0.1.10

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/bin/alphaclaw.js CHANGED
@@ -67,6 +67,30 @@ const openclawDir = path.join(rootDir, ".openclaw");
67
67
  fs.mkdirSync(openclawDir, { recursive: true });
68
68
  console.log(`[alphaclaw] Root directory: ${rootDir}`);
69
69
 
70
+ // Check for pending update marker (written by the update endpoint before restart).
71
+ // In environments where the container filesystem is ephemeral (Railway, etc.),
72
+ // the npm install from the update endpoint is lost on restart. This re-runs it
73
+ // from the fresh container using the persistent volume marker.
74
+ const pendingUpdateMarker = path.join(rootDir, ".alphaclaw-update-pending");
75
+ if (fs.existsSync(pendingUpdateMarker)) {
76
+ console.log("[alphaclaw] Pending update detected, installing @chrysb/alphaclaw@latest...");
77
+ const alphaPkgRoot = path.resolve(__dirname, "..");
78
+ const nmIndex = alphaPkgRoot.lastIndexOf(`${path.sep}node_modules${path.sep}`);
79
+ const installDir = nmIndex >= 0 ? alphaPkgRoot.slice(0, nmIndex) : alphaPkgRoot;
80
+ try {
81
+ execSync("npm install @chrysb/alphaclaw@latest --omit=dev --prefer-online", {
82
+ cwd: installDir,
83
+ stdio: "inherit",
84
+ timeout: 180000,
85
+ });
86
+ fs.unlinkSync(pendingUpdateMarker);
87
+ console.log("[alphaclaw] Update applied successfully");
88
+ } catch (e) {
89
+ console.log(`[alphaclaw] Update install failed: ${e.message}`);
90
+ fs.unlinkSync(pendingUpdateMarker);
91
+ }
92
+ }
93
+
70
94
  // ---------------------------------------------------------------------------
71
95
  // 3. Symlink ~/.openclaw -> <root>/.openclaw
72
96
  // ---------------------------------------------------------------------------
@@ -7,6 +7,7 @@ const {
7
7
  kLatestVersionCacheTtlMs,
8
8
  kAlphaclawRegistryUrl,
9
9
  kPackageRoot,
10
+ kRootDir,
10
11
  } = require("./constants");
11
12
 
12
13
  // kPackageRoot is lib/ — the actual npm package root (with package.json) is one level up
@@ -184,6 +185,14 @@ const createAlphaclawVersionService = () => {
184
185
  const previousVersion = readAlphaclawVersion();
185
186
  try {
186
187
  await installLatestAlphaclaw();
188
+ // Write marker to persistent volume so the update survives container recreation
189
+ const markerPath = path.join(kRootDir, ".alphaclaw-update-pending");
190
+ try {
191
+ fs.writeFileSync(markerPath, JSON.stringify({ from: previousVersion, ts: Date.now() }));
192
+ console.log(`[alphaclaw] Update marker written to ${markerPath}`);
193
+ } catch (e) {
194
+ console.log(`[alphaclaw] Could not write update marker: ${e.message}`);
195
+ }
187
196
  kUpdateStatusCache = { latestVersion: null, hasUpdate: false, fetchedAt: 0 };
188
197
  return {
189
198
  status: 200,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrysb/alphaclaw",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },