@clawling/clawchat-plugin-openclaw 2026.6.16-2 → 2026.6.16-3

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.
@@ -1,11 +1,38 @@
1
1
  import { createRequire } from "node:module";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
2
4
  import { createOpenclawClawlingApiClient } from "./api-client.js";
3
- /** Best-effort read of this plugin's package version; "unknown" on failure. */
5
+ const PACKAGE_NAME = "@clawling/clawchat-plugin-openclaw";
6
+ /**
7
+ * Best-effort read of this plugin's package version; "unknown" on failure.
8
+ *
9
+ * Walks up from this module's directory to the nearest package.json whose
10
+ * name matches this plugin, instead of assuming a fixed relative depth. The
11
+ * compiled module lives at dist/src/plugin-report.js (rootDir "." + outDir
12
+ * "dist"), so a hard-coded "../package.json" resolves to the non-existent
13
+ * dist/package.json at runtime and always falls back to "unknown" — even
14
+ * though it happens to work when tests run straight from src/.
15
+ */
4
16
  export function resolvePluginVersion() {
5
17
  try {
6
18
  const require = createRequire(import.meta.url);
7
- const pkg = require("../package.json");
8
- return pkg.version ?? "unknown";
19
+ let dir = dirname(fileURLToPath(import.meta.url));
20
+ // Bounded climb (handles dist/src, src, and any reasonable nesting).
21
+ for (let i = 0; i < 8; i += 1) {
22
+ try {
23
+ const pkg = require(join(dir, "package.json"));
24
+ if (pkg.name === PACKAGE_NAME && pkg.version)
25
+ return pkg.version;
26
+ }
27
+ catch {
28
+ // no package.json at this level — keep climbing
29
+ }
30
+ const parent = dirname(dir);
31
+ if (parent === dir)
32
+ break;
33
+ dir = parent;
34
+ }
35
+ return "unknown";
9
36
  }
10
37
  catch {
11
38
  return "unknown";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawling/clawchat-plugin-openclaw",
3
- "version": "2026.6.16-2",
3
+ "version": "2026.6.16-3",
4
4
  "description": "OpenClaw ClawChat channel plugin",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -1,12 +1,40 @@
1
1
  import { createRequire } from "node:module";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
2
4
  import { createOpenclawClawlingApiClient } from "./api-client.ts";
3
5
 
4
- /** Best-effort read of this plugin's package version; "unknown" on failure. */
6
+ const PACKAGE_NAME = "@clawling/clawchat-plugin-openclaw";
7
+
8
+ /**
9
+ * Best-effort read of this plugin's package version; "unknown" on failure.
10
+ *
11
+ * Walks up from this module's directory to the nearest package.json whose
12
+ * name matches this plugin, instead of assuming a fixed relative depth. The
13
+ * compiled module lives at dist/src/plugin-report.js (rootDir "." + outDir
14
+ * "dist"), so a hard-coded "../package.json" resolves to the non-existent
15
+ * dist/package.json at runtime and always falls back to "unknown" — even
16
+ * though it happens to work when tests run straight from src/.
17
+ */
5
18
  export function resolvePluginVersion(): string {
6
19
  try {
7
20
  const require = createRequire(import.meta.url);
8
- const pkg = require("../package.json") as { version?: string };
9
- return pkg.version ?? "unknown";
21
+ let dir = dirname(fileURLToPath(import.meta.url));
22
+ // Bounded climb (handles dist/src, src, and any reasonable nesting).
23
+ for (let i = 0; i < 8; i += 1) {
24
+ try {
25
+ const pkg = require(join(dir, "package.json")) as {
26
+ name?: string;
27
+ version?: string;
28
+ };
29
+ if (pkg.name === PACKAGE_NAME && pkg.version) return pkg.version;
30
+ } catch {
31
+ // no package.json at this level — keep climbing
32
+ }
33
+ const parent = dirname(dir);
34
+ if (parent === dir) break;
35
+ dir = parent;
36
+ }
37
+ return "unknown";
10
38
  } catch {
11
39
  return "unknown";
12
40
  }