@lark-apaas/openclaw-scripts-diagnose-cli 0.1.8-alpha.4 → 0.1.9-alpha.0

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/dist/index.cjs +83 -2
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -52,7 +52,7 @@ node_assert = __toESM(node_assert);
52
52
  * it terse and parseable.
53
53
  */
54
54
  function getVersion() {
55
- return "0.1.8-alpha.4";
55
+ return "0.1.9-alpha.0";
56
56
  }
57
57
  //#endregion
58
58
  //#region src/rule-engine/base.ts
@@ -1896,6 +1896,87 @@ function hasLegacyTopLevel(feishu) {
1896
1896
  return feishu.appSecret !== void 0;
1897
1897
  }
1898
1898
  //#endregion
1899
+ //#region src/rules/feishu-bot-id.ts
1900
+ let FeishuBotIdRule = class FeishuBotIdRule extends DiagnoseRule {
1901
+ validate(ctx) {
1902
+ const accounts = asRecord(getNestedMap(ctx.config, "channels", "feishu")?.accounts);
1903
+ if (!accounts) return { pass: true };
1904
+ const mismatched = getMismatchedAccounts(accounts);
1905
+ if (mismatched.length === 0) return { pass: true };
1906
+ return {
1907
+ pass: false,
1908
+ message: `channels.feishu.accounts botId/appId mismatch: ${mismatched.join(", ")}`
1909
+ };
1910
+ }
1911
+ repair(ctx) {
1912
+ const accounts = asRecord(getNestedMap(ctx.config, "channels", "feishu")?.accounts);
1913
+ if (!accounts) return;
1914
+ for (const account of Object.values(accounts)) {
1915
+ const bot = asRecord(account);
1916
+ if (!bot || typeof bot.appId !== "string" || bot.appId === "") continue;
1917
+ bot.botId = bot.appId;
1918
+ }
1919
+ }
1920
+ };
1921
+ FeishuBotIdRule = __decorate([Rule({
1922
+ key: "feishu_bot_id",
1923
+ description: "确保多账号飞书配置中每个 bot 账号的 botId 与 appId 一致",
1924
+ dependsOn: ["config_syntax_check", "feishu_default_account"],
1925
+ repairMode: "standard"
1926
+ })], FeishuBotIdRule);
1927
+ function getMismatchedAccounts(accounts) {
1928
+ const mismatched = [];
1929
+ for (const [accountId, account] of Object.entries(accounts)) {
1930
+ const bot = asRecord(account);
1931
+ if (!bot || typeof bot.appId !== "string" || bot.appId === "") continue;
1932
+ if (bot.botId !== bot.appId) mismatched.push(accountId);
1933
+ }
1934
+ return mismatched;
1935
+ }
1936
+ //#endregion
1937
+ //#region src/rules/session-persistence.ts
1938
+ const DEFAULT_SESSION = {
1939
+ dmScope: "per-account-channel-peer",
1940
+ resetByChannel: { feishu: {
1941
+ mode: "idle",
1942
+ idleMinutes: 10080
1943
+ } },
1944
+ maintenance: {
1945
+ mode: "enforce",
1946
+ resetArchiveRetention: "7d",
1947
+ maxDiskBytes: "5GB"
1948
+ }
1949
+ };
1950
+ let SessionPersistenceRule = class SessionPersistenceRule extends DiagnoseRule {
1951
+ validate(ctx) {
1952
+ const session = getNestedMap(ctx.config, "session");
1953
+ const issues = [];
1954
+ if (!getNestedMap(session, "resetByChannel")) issues.push("session.resetByChannel missing");
1955
+ if (!getNestedMap(session, "maintenance")) issues.push("session.maintenance missing");
1956
+ if (issues.length === 0) return { pass: true };
1957
+ return {
1958
+ pass: false,
1959
+ message: issues.join("; ")
1960
+ };
1961
+ }
1962
+ repair(ctx) {
1963
+ const session = getNestedMap(ctx.config, "session") ?? {};
1964
+ if (!getNestedMap(ctx.config, "session")) ctx.config.session = session;
1965
+ const needsResetByChannel = !getNestedMap(session, "resetByChannel");
1966
+ const needsMaintenance = !getNestedMap(session, "maintenance");
1967
+ if (!needsResetByChannel && !needsMaintenance) return;
1968
+ session.dmScope = DEFAULT_SESSION.dmScope;
1969
+ if (needsResetByChannel) session.resetByChannel = DEFAULT_SESSION.resetByChannel;
1970
+ if (needsMaintenance) session.maintenance = DEFAULT_SESSION.maintenance;
1971
+ }
1972
+ };
1973
+ SessionPersistenceRule = __decorate([Rule({
1974
+ key: "session_persistence",
1975
+ description: "补齐 session.resetByChannel 与 session.maintenance 持久化配置",
1976
+ dependsOn: ["config_syntax_check"],
1977
+ repairMode: "standard"
1978
+ })], SessionPersistenceRule);
1979
+ //#endregion
1899
1980
  //#region src/rules/gateway.ts
1900
1981
  const DEFAULT_PORT = 18789;
1901
1982
  const DEFAULT_MODE = "local";
@@ -9790,7 +9871,7 @@ async function reportCliRun(opts) {
9790
9871
  //#region src/help.ts
9791
9872
  const BIN = "mclaw-diagnose";
9792
9873
  function versionBanner() {
9793
- return `v0.1.8-alpha.4`;
9874
+ return `v0.1.9-alpha.0`;
9794
9875
  }
9795
9876
  const COMMANDS = [
9796
9877
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/openclaw-scripts-diagnose-cli",
3
- "version": "0.1.8-alpha.4",
3
+ "version": "0.1.9-alpha.0",
4
4
  "description": "CLI for OpenClaw config diagnose and repair with JSON5 support",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {