@chrysb/alphaclaw 0.6.0-beta.0 → 0.6.0-beta.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,5 +1,6 @@
1
1
  const { buildManagedPaths } = require("../internal-files-migration");
2
2
  const { readOpenclawConfig } = require("../openclaw-config");
3
+ const { hasScopedBindingFields } = require("../utils/channels");
3
4
 
4
5
  const registerSystemRoutes = ({
5
6
  app,
@@ -80,12 +81,6 @@ const registerSystemRoutes = ({
80
81
  .filter(Boolean)
81
82
  .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
82
83
  .join(" ");
83
- const hasScopedBindingFields = (match = {}) =>
84
- !!match.peer ||
85
- !!match.parentPeer ||
86
- !!String(match.guildId || "").trim() ||
87
- !!String(match.teamId || "").trim() ||
88
- (Array.isArray(match.roles) && match.roles.length > 0);
89
84
  const resolveTelegramAccountIdForAgent = ({ config, agentId }) => {
90
85
  const normalizedAgentId = String(agentId || "").trim();
91
86
  if (!normalizedAgentId) return "default";
@@ -1,7 +1,15 @@
1
1
  const fs = require("fs");
2
2
  const { OPENCLAW_DIR } = require("../constants");
3
3
  const { isDebugEnabled } = require("../helpers");
4
+ const {
5
+ readOpenclawConfig,
6
+ writeOpenclawConfig,
7
+ } = require("../openclaw-config");
4
8
  const { parseBooleanValue } = require("../utils/boolean");
9
+ const {
10
+ hasScopedBindingFields,
11
+ normalizeAccountId,
12
+ } = require("../utils/channels");
5
13
  const { quoteShellArg } = require("../utils/shell");
6
14
  const topicRegistry = require("../topic-registry");
7
15
  const { syncConfigForTelegram } = require("../telegram-workspace");
@@ -54,7 +62,6 @@ const buildTelegramGitSyncCommand = (action, target = "") => {
54
62
  const { createTelegramApi } = require("../telegram-api");
55
63
 
56
64
  const kTelegramEnvKeyBase = "TELEGRAM_BOT_TOKEN";
57
- const normalizeAccountId = (value) => String(value || "").trim() || "default";
58
65
 
59
66
  const deriveAccountEnvKey = (accountId) => {
60
67
  const normalized = normalizeAccountId(accountId);
@@ -101,13 +108,6 @@ const resolveTelegramConfigForAccount = ({ telegramConfig, accountId }) => {
101
108
  };
102
109
  };
103
110
 
104
- const hasScopedBindingFields = (match) =>
105
- !!match.peer ||
106
- !!match.parentPeer ||
107
- !!String(match.guildId || "").trim() ||
108
- !!String(match.teamId || "").trim() ||
109
- (Array.isArray(match.roles) && match.roles.length > 0);
110
-
111
111
  const resolveBoundAgentIdForAccount = ({ cfg, accountId }) => {
112
112
  const bindings = Array.isArray(cfg?.bindings) ? cfg.bindings : [];
113
113
  const normalizedAccountId = normalizeAccountId(accountId);
@@ -510,8 +510,11 @@ const registerTelegramRoutes = ({
510
510
  });
511
511
 
512
512
  // Save metadata in local topic registry only.
513
- const configPath = `${OPENCLAW_DIR}/openclaw.json`;
514
- const cfg = JSON.parse(fs.readFileSync(configPath, "utf8"));
513
+ const cfg = readOpenclawConfig({
514
+ fsModule: fs,
515
+ openclawDir: OPENCLAW_DIR,
516
+ fallback: {},
517
+ });
515
518
  const boundAgentId = resolveBoundAgentIdForAccount({ cfg, accountId });
516
519
  topicRegistry.setGroup(groupId, {
517
520
  ...(groupName ? { name: groupName } : {}),
@@ -537,8 +540,11 @@ const registerTelegramRoutes = ({
537
540
  try {
538
541
  const accountId = resolveAccountId(req);
539
542
  const debugEnabled = isDebugEnabled();
540
- const configPath = `${OPENCLAW_DIR}/openclaw.json`;
541
- let cfg = JSON.parse(fs.readFileSync(configPath, "utf8"));
543
+ let cfg = readOpenclawConfig({
544
+ fsModule: fs,
545
+ openclawDir: OPENCLAW_DIR,
546
+ fallback: {},
547
+ });
542
548
  let telegramConfig = cfg.channels?.telegram || {};
543
549
  const { accountConfig } = resolveTelegramConfigForAccount({
544
550
  telegramConfig,
@@ -580,7 +586,11 @@ const registerTelegramRoutes = ({
580
586
  }
581
587
  }
582
588
  if (anyRepaired) {
583
- cfg = JSON.parse(fs.readFileSync(configPath, "utf8"));
589
+ cfg = readOpenclawConfig({
590
+ fsModule: fs,
591
+ openclawDir: OPENCLAW_DIR,
592
+ fallback: {},
593
+ });
584
594
  telegramConfig = cfg.channels?.telegram || {};
585
595
  }
586
596
  const refreshedAccountConfig = resolveTelegramConfigForAccount({
@@ -634,8 +644,11 @@ const registerTelegramRoutes = ({
634
644
  app.post("/api/telegram/workspace/reset", async (req, res) => {
635
645
  try {
636
646
  const accountId = resolveAccountId(req);
637
- const configPath = `${OPENCLAW_DIR}/openclaw.json`;
638
- const cfg = JSON.parse(fs.readFileSync(configPath, "utf8"));
647
+ const cfg = readOpenclawConfig({
648
+ fsModule: fs,
649
+ openclawDir: OPENCLAW_DIR,
650
+ fallback: {},
651
+ });
639
652
  const telegramConfig = cfg.channels?.telegram;
640
653
  if (!telegramConfig || typeof telegramConfig !== "object") {
641
654
  return res.json({ ok: true, syncWarning: null });
@@ -660,7 +673,12 @@ const registerTelegramRoutes = ({
660
673
  delete telegramConfig.groups;
661
674
  delete telegramConfig.groupAllowFrom;
662
675
  }
663
- fs.writeFileSync(configPath, JSON.stringify(cfg, null, 2));
676
+ writeOpenclawConfig({
677
+ fsModule: fs,
678
+ openclawDir: OPENCLAW_DIR,
679
+ config: cfg,
680
+ spacing: 2,
681
+ });
664
682
 
665
683
  // Remove corresponding groups from topic registry
666
684
  const registry = topicRegistry.readRegistry();
@@ -1,8 +1,11 @@
1
1
  const kTelegramTopicConcurrencyMultiplier = 3;
2
2
  const kAgentConcurrencyFloor = 8;
3
3
  const kSubagentConcurrencyFloor = 4;
4
-
5
- const normalizeAccountId = (value) => String(value || "").trim() || "default";
4
+ const { normalizeAccountId } = require("./utils/channels");
5
+ const {
6
+ readOpenclawConfig,
7
+ writeOpenclawConfig,
8
+ } = require("./openclaw-config");
6
9
 
7
10
  const resolveTelegramAccountConfig = ({ telegramConfig, accountId }) => {
8
11
  const normalizedAccountId = normalizeAccountId(accountId);
@@ -38,8 +41,11 @@ const syncConfigForTelegram = ({
38
41
  requireMention = false,
39
42
  resolvedUserId = "",
40
43
  }) => {
41
- const configPath = `${openclawDir}/openclaw.json`;
42
- const cfg = JSON.parse(fs.readFileSync(configPath, "utf8"));
44
+ const cfg = readOpenclawConfig({
45
+ fsModule: fs,
46
+ openclawDir,
47
+ fallback: {},
48
+ });
43
49
 
44
50
  // Remove legacy root keys from older setup flow.
45
51
  delete cfg.sessions;
@@ -121,7 +127,12 @@ const syncConfigForTelegram = ({
121
127
  kSubagentConcurrencyFloor,
122
128
  );
123
129
 
124
- fs.writeFileSync(configPath, JSON.stringify(cfg, null, 2));
130
+ writeOpenclawConfig({
131
+ fsModule: fs,
132
+ openclawDir,
133
+ config: cfg,
134
+ spacing: 2,
135
+ });
125
136
 
126
137
  return {
127
138
  totalTopics,
@@ -1,13 +1,10 @@
1
1
  const fs = require("fs");
2
2
  const { WORKSPACE_DIR } = require("./constants");
3
+ const { normalizeAccountId } = require("./utils/channels");
3
4
 
4
5
  const kRegistryPath = `${WORKSPACE_DIR}/topic-registry.json`;
5
- const kDefaultAccountId = "default";
6
6
  const kDefaultAgentId = "default";
7
7
 
8
- const normalizeAccountId = (value) =>
9
- String(value || "").trim() || kDefaultAccountId;
10
-
11
8
  const normalizeGroupAgentId = (value) =>
12
9
  String(value || "").trim() || kDefaultAgentId;
13
10
 
@@ -0,0 +1,13 @@
1
+ const normalizeAccountId = (value) => String(value || "").trim() || "default";
2
+
3
+ const hasScopedBindingFields = (match = {}) =>
4
+ !!match.peer ||
5
+ !!match.parentPeer ||
6
+ !!String(match.guildId || "").trim() ||
7
+ !!String(match.teamId || "").trim() ||
8
+ (Array.isArray(match.roles) && match.roles.length > 0);
9
+
10
+ module.exports = {
11
+ normalizeAccountId,
12
+ hasScopedBindingFields,
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrysb/alphaclaw",
3
- "version": "0.6.0-beta.0",
3
+ "version": "0.6.0-beta.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "express": "^4.21.0",
33
33
  "http-proxy": "^1.18.1",
34
- "openclaw": "2026.3.7"
34
+ "openclaw": "^2026.3.8"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@vitest/coverage-v8": "^4.0.18",