openclaw-lark-multi-agent 1.0.8 → 1.0.10

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.
@@ -1651,8 +1651,8 @@ export class FeishuBot {
1651
1651
  async downloadResource(messageId, fileKey, type) {
1652
1652
  const { mkdirSync, writeFileSync } = await import("fs");
1653
1653
  const { resolve } = await import("path");
1654
- const { getStateDir } = await import("./paths.js");
1655
- const dir = resolve(getStateDir(), "data", "media");
1654
+ const { getLmaMediaDir } = await import("./paths.js");
1655
+ const dir = getLmaMediaDir();
1656
1656
  mkdirSync(dir, { recursive: true });
1657
1657
  const resp = await this.client.im.messageResource.get({
1658
1658
  path: { message_id: messageId, file_key: fileKey },
@@ -2,11 +2,11 @@ import WebSocket from "ws";
2
2
  import { randomUUID } from "crypto";
3
3
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
4
4
  import { basename, extname, join } from "path";
5
- import { getBridgeAttachmentsDir, getStateDir } from "./paths.js";
5
+ import { getBridgeAttachmentsDir, getDataDir } from "./paths.js";
6
6
  export const GATEWAY_PROTOCOL_MIN = 3;
7
7
  export const GATEWAY_PROTOCOL_MAX = 4;
8
8
  const BRIDGE_ATTACHMENTS_DIR = getBridgeAttachmentsDir();
9
- const CONTEXT_SYNC_DIR = join(getStateDir(), "context-sync");
9
+ const CONTEXT_SYNC_DIR = join(getDataDir(), "context-sync");
10
10
  const MAX_INLINE_CONTEXT_MESSAGES = Number(process.env.OPENCLAW_LARK_MULTI_AGENT_MAX_INLINE_CONTEXT_MESSAGES || 1000);
11
11
  const MAX_INLINE_CONTEXT_BYTES = Number(process.env.OPENCLAW_LARK_MULTI_AGENT_MAX_INLINE_CONTEXT_BYTES || 8 * 1024 * 1024);
12
12
  /**
@@ -606,12 +606,22 @@ export class OpenClawClient {
606
606
  }
607
607
  if (!latestFinalText) {
608
608
  const failureText = buildFailureText(ev);
609
- if (ev.data?.replayInvalid) {
609
+ const state = ev.data?.livenessState || "";
610
+ const reason = ev.data?.stopReason || "";
611
+ // replayInvalid, cancelled/rpc, and abandoned are often
612
+ // transient runtime states — the real reply may still arrive
613
+ // shortly after via session.message or a subsequent run.
614
+ // Defer the failure instead of finishing immediately.
615
+ const isTransient = ev.data?.replayInvalid
616
+ || state === "cancelled"
617
+ || state === "abandoned"
618
+ || reason === "rpc";
619
+ if (isTransient) {
610
620
  pendingRuntimeFailureText = failureText;
611
- console.warn(`[OpenClaw] replayInvalid lifecycle observed for runId=${evRunId || runId}; waiting for real text or idle timeout`);
621
+ console.warn(`[OpenClaw] transient lifecycle end (${state}, reason=${reason}) for runId=${evRunId || runId}; waiting for real text or idle timeout`);
612
622
  return;
613
623
  }
614
- if (ev.data?.livenessState !== "working") {
624
+ if (state !== "working") {
615
625
  finish(failureText);
616
626
  return;
617
627
  }
package/dist/paths.d.ts CHANGED
@@ -3,6 +3,8 @@
3
3
  * for packaged deployments, tests, containers, or systemd installations.
4
4
  */
5
5
  export declare function getStateDir(): string;
6
+ export declare function getDataDir(): string;
6
7
  export declare function getBridgeAttachmentsDir(): string;
7
8
  export declare function getOpenClawWorkspaceDir(): string;
9
+ export declare function getLmaMediaDir(): string;
8
10
  export declare function getBridgeAttachmentAllowedRoots(): string[];
package/dist/paths.js CHANGED
@@ -1,20 +1,39 @@
1
1
  import { homedir } from "os";
2
- import { resolve } from "path";
2
+ import { dirname, resolve } from "path";
3
3
  /**
4
4
  * Runtime state defaults to the user's home directory but can be overridden
5
5
  * for packaged deployments, tests, containers, or systemd installations.
6
6
  */
7
7
  export function getStateDir() {
8
- return resolve(process.env.OPENCLAW_LARK_MULTI_AGENT_STATE_DIR || resolve(homedir(), ".openclaw/openclaw-lark-multi-agent"));
8
+ // Windows services often run as LocalSystem, where homedir() resolves to
9
+ // C:\\Windows\\System32\\config\\systemprofile. When the installer supplies
10
+ // LMA_DATA_DIR, derive the state dir from it instead of falling back to that
11
+ // service profile home.
12
+ if (process.env.OPENCLAW_LARK_MULTI_AGENT_STATE_DIR)
13
+ return resolve(process.env.OPENCLAW_LARK_MULTI_AGENT_STATE_DIR);
14
+ if (process.env.LMA_DATA_DIR)
15
+ return dirname(resolve(process.env.LMA_DATA_DIR));
16
+ return resolve(homedir(), ".openclaw/openclaw-lark-multi-agent");
17
+ }
18
+ export function getDataDir() {
19
+ return resolve(process.env.LMA_DATA_DIR || resolve(getStateDir(), "data"));
9
20
  }
10
21
  export function getBridgeAttachmentsDir() {
11
22
  return resolve(process.env.OPENCLAW_LARK_MULTI_AGENT_ATTACHMENTS_DIR || resolve(getStateDir(), "attachments"));
12
23
  }
13
24
  export function getOpenClawWorkspaceDir() {
14
- return resolve(process.env.OPENCLAW_WORKSPACE_DIR || resolve(homedir(), ".openclaw/workspace"));
25
+ // Prefer the explicit OpenClaw workspace when provided. Otherwise derive it
26
+ // from the LMA state dir instead of homedir(); Windows services may run as
27
+ // LocalSystem, whose homedir is C:\\Windows\\System32\\config\\systemprofile.
28
+ return resolve(process.env.OPENCLAW_WORKSPACE_DIR || resolve(dirname(getStateDir()), "workspace"));
29
+ }
30
+ export function getLmaMediaDir() {
31
+ // Feishu-downloaded media should live inside the OpenClaw workspace so agent
32
+ // tools such as read/image can access it on both Linux and Windows services.
33
+ return resolve(process.env.OPENCLAW_LARK_MULTI_AGENT_MEDIA_DIR || resolve(getOpenClawWorkspaceDir(), ".lma-media"));
15
34
  }
16
35
  export function getBridgeAttachmentAllowedRoots() {
17
- const roots = [getBridgeAttachmentsDir(), getOpenClawWorkspaceDir(), resolve(getStateDir(), "data", "media")];
36
+ const roots = [getBridgeAttachmentsDir(), getOpenClawWorkspaceDir(), getLmaMediaDir()];
18
37
  const extra = process.env.OPENCLAW_LARK_MULTI_AGENT_ATTACHMENT_ALLOW_ROOTS || "";
19
38
  for (const part of extra.split(",")) {
20
39
  const trimmed = part.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-lark-multi-agent",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Multi-bot Lark/Feishu bridge for OpenClaw, with per-bot model routing and isolated sessions",
5
5
  "type": "module",
6
6
  "scripts": {