openclaw-glance-plugin 0.1.11 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-glance-plugin",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "OpenClaw plugin client for ticker-monitor openclaw-bridge",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,3 +1,4 @@
1
+ import os from 'node:os';
1
2
  import path from 'node:path';
2
3
  import process from 'node:process';
3
4
 
@@ -15,13 +16,32 @@ function pick(source, keys, fallback = undefined) {
15
16
  return fallback;
16
17
  }
17
18
 
19
+ export function resolveDefaultLockDir({ env = process.env, cwd = process.cwd() } = {}) {
20
+ const xdgStateHome = pick(env, ['XDG_STATE_HOME']);
21
+ if (xdgStateHome) {
22
+ return path.join(String(xdgStateHome), 'openclaw-locks');
23
+ }
24
+
25
+ const homeDir = pick(env, ['HOME', 'USERPROFILE']);
26
+ if (homeDir) {
27
+ return path.join(String(homeDir), '.openclaw-locks');
28
+ }
29
+
30
+ const cwdRoot = path.parse(cwd).root;
31
+ if (cwd === cwdRoot) {
32
+ return path.join(os.tmpdir(), 'openclaw-locks');
33
+ }
34
+
35
+ return path.join(cwd, '.openclaw-locks');
36
+ }
37
+
18
38
  export function resolveRuntimeConfig({ env = process.env, pluginConfig = {} } = {}) {
19
39
  const baseWsUrl = String(
20
40
  pick(pluginConfig, ['baseWsUrl', 'base_ws_url'], pick(env, ['OPENCLAW_BASE_WS_URL'], DEFAULT_BASE_WS_URL))
21
41
  );
22
42
  const token = String(pick(pluginConfig, ['token'], pick(env, ['OPENCLAW_WS_TOKEN'], '')));
23
43
  const lockDir = String(
24
- pick(pluginConfig, ['lockDir', 'lock_dir'], pick(env, ['OPENCLAW_LOCK_DIR'], path.join(process.cwd(), '.openclaw-locks')))
44
+ pick(pluginConfig, ['lockDir', 'lock_dir'], pick(env, ['OPENCLAW_LOCK_DIR'], resolveDefaultLockDir({ env })))
25
45
  );
26
46
  const lockKey = ProcessLock.buildLockKey(baseWsUrl, token);
27
47
  if (!token) {
@@ -24,6 +24,9 @@ export async function startPluginRuntime({ runtime, pluginConfig } = {}) {
24
24
  return activeRuntime;
25
25
  }
26
26
  const config = resolveRuntimeConfig({ pluginConfig });
27
+ runtime?.logger?.info?.(
28
+ `[openclaw-glance-plugin] runtime config resolved: baseWsUrl=${config.baseWsUrl}, lockDir=${config.lockDir}`
29
+ );
27
30
  const lock = new ProcessLock({
28
31
  lockDir: config.lockDir,
29
32
  key: config.lockKey