@chrysb/alphaclaw 0.4.6-beta.6 → 0.4.6-beta.8

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.
@@ -17,7 +17,6 @@ const registerSystemRoutes = ({
17
17
  alphaclawVersionService,
18
18
  clawCmd,
19
19
  restartGateway,
20
- onExpectedGatewayRestart,
21
20
  OPENCLAW_DIR,
22
21
  restartRequiredState,
23
22
  topicRegistry,
@@ -59,7 +58,9 @@ const registerSystemRoutes = ({
59
58
  const parseJsonFromStdout = (stdout) => {
60
59
  const raw = String(stdout || "").trim();
61
60
  if (!raw) return null;
62
- const candidateStarts = [raw.indexOf("{"), raw.indexOf("[")].filter((idx) => idx >= 0);
61
+ const candidateStarts = [raw.indexOf("{"), raw.indexOf("[")].filter(
62
+ (idx) => idx >= 0,
63
+ );
63
64
  for (const start of candidateStarts) {
64
65
  const candidate = raw.slice(start);
65
66
  try {
@@ -75,7 +76,9 @@ const registerSystemRoutes = ({
75
76
  if (telegramMatch) {
76
77
  return `Telegram ${telegramMatch[1]}`;
77
78
  }
78
- const telegramTopicMatch = key.match(/:telegram:group:([^:]+):topic:([^:]+)$/);
79
+ const telegramTopicMatch = key.match(
80
+ /:telegram:group:([^:]+):topic:([^:]+)$/,
81
+ );
79
82
  if (telegramTopicMatch) {
80
83
  const [, groupId, topicId] = telegramTopicMatch;
81
84
  let groupEntry = null;
@@ -83,7 +86,9 @@ const registerSystemRoutes = ({
83
86
  groupEntry = topicRegistry?.getGroup?.(groupId) || null;
84
87
  } catch {}
85
88
  const groupName = String(groupEntry?.name || "").trim();
86
- const topicName = String(groupEntry?.topics?.[topicId]?.name || "").trim();
89
+ const topicName = String(
90
+ groupEntry?.topics?.[topicId]?.name || "",
91
+ ).trim();
87
92
  if (groupName && topicName) return `Telegram ${groupName} · ${topicName}`;
88
93
  if (topicName) return `Telegram Topic ${topicName}`;
89
94
  return `Telegram Topic ${topicId}`;
@@ -266,13 +271,19 @@ const registerSystemRoutes = ({
266
271
  );
267
272
  const hiddenKnownVarKeys = new Set(
268
273
  kKnownVars
269
- .filter((def) => !isReservedUserEnvVar(def.key) && !isVisibleInEnvars(def))
274
+ .filter(
275
+ (def) => !isReservedUserEnvVar(def.key) && !isVisibleInEnvars(def),
276
+ )
270
277
  .map((def) => def.key),
271
278
  );
272
279
  const existingHiddenKnownVars = readEnvFile().filter((v) =>
273
280
  hiddenKnownVarKeys.has(v.key),
274
281
  );
275
- const nextEnvVars = [...filtered, ...existingHiddenKnownVars, ...existingLockedVars];
282
+ const nextEnvVars = [
283
+ ...filtered,
284
+ ...existingHiddenKnownVars,
285
+ ...existingLockedVars,
286
+ ];
276
287
  syncChannelConfig(nextEnvVars, "remove");
277
288
  writeEnvFile(nextEnvVars);
278
289
  const changed = reloadEnv();
@@ -402,12 +413,15 @@ const registerSystemRoutes = ({
402
413
  let selectedSession = null;
403
414
  try {
404
415
  const sessions = await listSendableAgentSessions();
405
- selectedSession = sessions.find((sessionRow) => sessionRow.key === sessionKey) || null;
416
+ selectedSession =
417
+ sessions.find((sessionRow) => sessionRow.key === sessionKey) || null;
406
418
  } catch (err) {
407
419
  return res.status(502).json({ ok: false, error: err.message });
408
420
  }
409
421
  if (!selectedSession) {
410
- return res.status(400).json({ ok: false, error: "Selected session was not found" });
422
+ return res
423
+ .status(400)
424
+ .json({ ok: false, error: "Selected session was not found" });
411
425
  }
412
426
  if (selectedSession.replyChannel && selectedSession.replyTo) {
413
427
  command +=
@@ -421,7 +435,10 @@ const registerSystemRoutes = ({
421
435
  if (!result.ok) {
422
436
  return res
423
437
  .status(502)
424
- .json({ ok: false, error: result.stderr || "Could not send message to agent" });
438
+ .json({
439
+ ok: false,
440
+ error: result.stderr || "Could not send message to agent",
441
+ });
425
442
  }
426
443
  return res.json({ ok: true, stdout: result.stdout || "" });
427
444
  });
@@ -458,9 +475,6 @@ const registerSystemRoutes = ({
458
475
  }
459
476
  restartRequiredState.markRestartInProgress();
460
477
  try {
461
- if (typeof onExpectedGatewayRestart === "function") {
462
- onExpectedGatewayRestart();
463
- }
464
478
  restartGateway();
465
479
  envRestartPending = false;
466
480
  restartRequiredState.clearRequired();
@@ -9,7 +9,7 @@ const {
9
9
 
10
10
  const kHealthStartupGraceMs = 30 * 1000;
11
11
  const kBootstrapHealthCheckMs = 5 * 1000;
12
- const kExpectedRestartWindowMs = 45 * 1000;
12
+ const kExpectedRestartWindowMs = 15 * 1000;
13
13
 
14
14
  const isTruthy = (value) =>
15
15
  ["1", "true", "yes", "on"].includes(String(value || "").trim().toLowerCase());
@@ -506,7 +506,7 @@ const createWatchdog = ({
506
506
  const onGatewayExit = ({ code, signal, expectedExit = false, stderrTail = [] } = {}) => {
507
507
  const correlationId = createCorrelationId();
508
508
  clearDegradedHealthCheckTimer();
509
- if (expectedExit) {
509
+ if (expectedExit && (code == null || code === 0)) {
510
510
  state.lifecycle = "restarting";
511
511
  state.health = "unknown";
512
512
  state.crashRecoveryActive = false;
package/lib/server.js CHANGED
@@ -131,7 +131,7 @@ const app = express();
131
131
  app.set("trust proxy", kTrustProxyHops);
132
132
  app.use(["/webhook", "/hooks"], express.raw({ type: "*/*", limit: "5mb" }));
133
133
  app.use("/gmail-pubsub", express.raw({ type: "*/*", limit: "5mb" }));
134
- app.use(express.json());
134
+ app.use(express.json({ limit: "5mb" }));
135
135
 
136
136
  const proxy = httpProxy.createProxyServer({
137
137
  target: GATEWAY_URL,
@@ -242,7 +242,6 @@ registerSystemRoutes({
242
242
  alphaclawVersionService,
243
243
  clawCmd,
244
244
  restartGateway,
245
- onExpectedGatewayRestart: () => watchdog.onExpectedRestart(),
246
245
  OPENCLAW_DIR: constants.OPENCLAW_DIR,
247
246
  restartRequiredState,
248
247
  topicRegistry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrysb/alphaclaw",
3
- "version": "0.4.6-beta.6",
3
+ "version": "0.4.6-beta.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },