@aspalagin/openclaw-max 0.9.0 → 0.9.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.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Плагин нужен тем, кто пользуется OpenClaw и хочет, чтобы ассистент был доступен в MAX. Понадобятся токен бота MAX (ботов создают организации на [business.max.ru](https://business.max.ru/self)) и собственный gateway OpenClaw.
8
8
 
9
- Версия 0.9.0. Изменения: [CHANGELOG.md](https://github.com/aspalagin/openclaw-max/blob/main/CHANGELOG.md).
9
+ Версия 0.9.2. Изменения: [CHANGELOG.md](https://github.com/aspalagin/openclaw-max/blob/main/CHANGELOG.md).
10
10
 
11
11
  ## Содержание
12
12
 
package/README_EN.md CHANGED
@@ -6,7 +6,7 @@ A channel plugin that connects an [OpenClaw](https://openclaw.ai) assistant to t
6
6
 
7
7
  It is for OpenClaw users who need their assistant reachable in MAX. You need a MAX bot token (bots are created by organisations on [business.max.ru](https://business.max.ru/self)) and an OpenClaw gateway you run yourself.
8
8
 
9
- Version 0.9.0. Changes: [CHANGELOG.md](https://github.com/aspalagin/openclaw-max/blob/main/CHANGELOG.md) (in Russian).
9
+ Version 0.9.2. Changes: [CHANGELOG.md](https://github.com/aspalagin/openclaw-max/blob/main/CHANGELOG.md) (in Russian).
10
10
 
11
11
  ## Contents
12
12
 
@@ -0,0 +1,26 @@
1
+ import { promises as fs } from 'node:fs';
2
+ /**
3
+ * Local replacement for `readJsonFileWithFallback` from `openclaw/plugin-sdk/json-store`.
4
+ * OpenClaw 2026.10.5 dropped that export (only `loadJsonFile`, `saveJsonFile` and
5
+ * `writeJsonFileAtomically` remain), and a missing named export fails ESM linking for
6
+ * the whole plugin. Semantics match the 2026.9.x helper: a missing file yields the
7
+ * fallback with `exists: false`; an unreadable or invalid file yields the fallback with
8
+ * `exists: true`, so callers can warn and start empty.
9
+ */
10
+ export async function readJsonFileWithFallback(filePath, fallback) {
11
+ let raw;
12
+ try {
13
+ raw = await fs.readFile(filePath, 'utf8');
14
+ }
15
+ catch (err) {
16
+ const code = err?.code;
17
+ return { value: fallback, exists: code !== 'ENOENT' };
18
+ }
19
+ try {
20
+ const parsed = JSON.parse(raw);
21
+ return parsed == null ? { value: fallback, exists: true } : { value: parsed, exists: true };
22
+ }
23
+ catch {
24
+ return { value: fallback, exists: true };
25
+ }
26
+ }
package/dist/src/state.js CHANGED
@@ -9,7 +9,8 @@
9
9
  */
10
10
  import * as fs from 'node:fs/promises';
11
11
  import * as path from 'node:path';
12
- import { readJsonFileWithFallback, writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
12
+ import { writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
13
+ import { readJsonFileWithFallback } from './json-store-compat.js';
13
14
  import { resolveStateDir } from 'openclaw/plugin-sdk/state-paths';
14
15
  export function resolveMaxStatePath(accountId) {
15
16
  const safeId = accountId.replace(/[^a-zA-Z0-9_-]/g, '_');
@@ -18,7 +18,8 @@
18
18
  */
19
19
  import * as fs from 'node:fs/promises';
20
20
  import * as path from 'node:path';
21
- import { readJsonFileWithFallback, writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
21
+ import { writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
22
+ import { readJsonFileWithFallback } from './json-store-compat.js';
22
23
  import { resolveStateDir } from 'openclaw/plugin-sdk/state-paths';
23
24
  /** How long a handled update's key rejects a redelivery (MAX retries within 8 h). */
24
25
  export const MAX_JOURNAL_COMPLETED_TTL_MS = 24 * 60 * 60 * 1000;
@@ -2,7 +2,7 @@
2
2
  "id": "openclaw-max",
3
3
  "name": "MAX",
4
4
  "description": "MAX messenger (max.ru) channel for OpenClaw: private and group chats over webhook or long polling; media, voice messages with transcription and voice replies; inline keyboards and command menus; message edits and pins; several bot accounts",
5
- "version": "0.9.0",
5
+ "version": "0.9.2",
6
6
  "categories": [
7
7
  "channels"
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspalagin/openclaw-max",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "MAX messenger (max.ru) channel for OpenClaw: private and group chats over webhook or long polling; media, voice messages with transcription and voice replies; inline keyboards and command menus; message edits and pins; several bot accounts",
5
5
  "keywords": [
6
6
  "openclaw",
@@ -0,0 +1,28 @@
1
+ import { promises as fs } from 'node:fs';
2
+
3
+ /**
4
+ * Local replacement for `readJsonFileWithFallback` from `openclaw/plugin-sdk/json-store`.
5
+ * OpenClaw 2026.10.5 dropped that export (only `loadJsonFile`, `saveJsonFile` and
6
+ * `writeJsonFileAtomically` remain), and a missing named export fails ESM linking for
7
+ * the whole plugin. Semantics match the 2026.9.x helper: a missing file yields the
8
+ * fallback with `exists: false`; an unreadable or invalid file yields the fallback with
9
+ * `exists: true`, so callers can warn and start empty.
10
+ */
11
+ export async function readJsonFileWithFallback<T>(
12
+ filePath: string,
13
+ fallback: T,
14
+ ): Promise<{ value: T; exists: boolean }> {
15
+ let raw: string;
16
+ try {
17
+ raw = await fs.readFile(filePath, 'utf8');
18
+ } catch (err) {
19
+ const code = (err as NodeJS.ErrnoException | undefined)?.code;
20
+ return { value: fallback, exists: code !== 'ENOENT' };
21
+ }
22
+ try {
23
+ const parsed = JSON.parse(raw) as T | null;
24
+ return parsed == null ? { value: fallback, exists: true } : { value: parsed, exists: true };
25
+ } catch {
26
+ return { value: fallback, exists: true };
27
+ }
28
+ }
package/src/state.ts CHANGED
@@ -11,7 +11,9 @@
11
11
  import * as fs from 'node:fs/promises';
12
12
  import * as path from 'node:path';
13
13
 
14
- import { readJsonFileWithFallback, writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
14
+ import { writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
15
+
16
+ import { readJsonFileWithFallback } from './json-store-compat.js';
15
17
  import { resolveStateDir } from 'openclaw/plugin-sdk/state-paths';
16
18
 
17
19
  export interface MaxChatRegistryEntry {
@@ -20,7 +20,9 @@
20
20
  import * as fs from 'node:fs/promises';
21
21
  import * as path from 'node:path';
22
22
 
23
- import { readJsonFileWithFallback, writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
23
+ import { writeJsonFileAtomically } from 'openclaw/plugin-sdk/json-store';
24
+
25
+ import { readJsonFileWithFallback } from './json-store-compat.js';
24
26
  import { resolveStateDir } from 'openclaw/plugin-sdk/state-paths';
25
27
 
26
28
  import type { MaxUpdate } from './api.js';