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

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