@syengup/friday-channel-next 0.0.43 → 0.0.44
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,29 +1,20 @@
|
|
|
1
1
|
import { readdirSync } from "node:fs";
|
|
2
|
-
import { join
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { join } from "node:path";
|
|
4
3
|
let cache = null;
|
|
5
4
|
function resolveOpenClawDist() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"/opt/homebrew/lib/node_modules/openclaw/dist",
|
|
16
|
-
"/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
|
|
17
|
-
"/usr/local/lib/node_modules/openclaw/dist",
|
|
18
|
-
]) {
|
|
19
|
-
try {
|
|
20
|
-
readdirSync(root);
|
|
21
|
-
return root;
|
|
22
|
-
}
|
|
23
|
-
catch { }
|
|
5
|
+
for (const root of [
|
|
6
|
+
join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
|
|
7
|
+
"/opt/homebrew/lib/node_modules/openclaw/dist",
|
|
8
|
+
"/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
|
|
9
|
+
"/usr/local/lib/node_modules/openclaw/dist",
|
|
10
|
+
]) {
|
|
11
|
+
try {
|
|
12
|
+
readdirSync(root);
|
|
13
|
+
return root;
|
|
24
14
|
}
|
|
25
|
-
|
|
15
|
+
catch { }
|
|
26
16
|
}
|
|
17
|
+
throw new Error("OpenClaw dist directory not found");
|
|
27
18
|
}
|
|
28
19
|
export async function loadNodePairingModule() {
|
|
29
20
|
if (cache)
|
|
@@ -32,9 +23,24 @@ export async function loadNodePairingModule() {
|
|
|
32
23
|
const file = readdirSync(dist).find((f) => f.startsWith("node-pairing-") && f.endsWith(".js") && !f.includes("authz"));
|
|
33
24
|
if (!file)
|
|
34
25
|
throw new Error("node-pairing module not found in OpenClaw dist");
|
|
35
|
-
// ESM import()
|
|
36
|
-
//
|
|
37
|
-
|
|
26
|
+
// ESM import() returns the minified export names (r, t, …) because the
|
|
27
|
+
// bundled module uses `export { listNodePairing as r, … }`. Resolve the
|
|
28
|
+
// correct functions by Function.name, which preserves the original name.
|
|
29
|
+
const mod = await import(join(dist, file));
|
|
30
|
+
let listNodePairing;
|
|
31
|
+
let approveNodePairing;
|
|
32
|
+
for (const value of Object.values(mod)) {
|
|
33
|
+
if (typeof value === "function") {
|
|
34
|
+
if (value.name === "listNodePairing")
|
|
35
|
+
listNodePairing = value;
|
|
36
|
+
else if (value.name === "approveNodePairing")
|
|
37
|
+
approveNodePairing = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!listNodePairing || !approveNodePairing) {
|
|
41
|
+
throw new Error("node-pairing module did not export expected functions");
|
|
42
|
+
}
|
|
43
|
+
cache = { listNodePairing, approveNodePairing };
|
|
38
44
|
return cache;
|
|
39
45
|
}
|
|
40
46
|
/** Vitest-only: inject mock pairing functions. */
|
package/package.json
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { readdirSync } from "node:fs";
|
|
2
|
-
import { join
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { join } from "node:path";
|
|
4
3
|
|
|
5
4
|
let cache: { listNodePairing: Function; approveNodePairing: Function } | null = null;
|
|
6
5
|
|
|
7
6
|
function resolveOpenClawDist(): string {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
|
|
16
|
-
"/opt/homebrew/lib/node_modules/openclaw/dist",
|
|
17
|
-
"/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
|
|
18
|
-
"/usr/local/lib/node_modules/openclaw/dist",
|
|
19
|
-
]) {
|
|
20
|
-
try { readdirSync(root); return root; } catch {}
|
|
21
|
-
}
|
|
22
|
-
throw new Error("OpenClaw dist directory not found");
|
|
7
|
+
for (const root of [
|
|
8
|
+
join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
|
|
9
|
+
"/opt/homebrew/lib/node_modules/openclaw/dist",
|
|
10
|
+
"/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
|
|
11
|
+
"/usr/local/lib/node_modules/openclaw/dist",
|
|
12
|
+
]) {
|
|
13
|
+
try { readdirSync(root); return root; } catch {}
|
|
23
14
|
}
|
|
15
|
+
throw new Error("OpenClaw dist directory not found");
|
|
24
16
|
}
|
|
25
17
|
|
|
26
18
|
export async function loadNodePairingModule(): Promise<{
|
|
@@ -33,10 +25,24 @@ export async function loadNodePairingModule(): Promise<{
|
|
|
33
25
|
(f) => f.startsWith("node-pairing-") && f.endsWith(".js") && !f.includes("authz"),
|
|
34
26
|
);
|
|
35
27
|
if (!file) throw new Error("node-pairing module not found in OpenClaw dist");
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
|
|
29
|
+
// ESM import() returns the minified export names (r, t, …) because the
|
|
30
|
+
// bundled module uses `export { listNodePairing as r, … }`. Resolve the
|
|
31
|
+
// correct functions by Function.name, which preserves the original name.
|
|
32
|
+
const mod = await import(join(dist, file));
|
|
33
|
+
let listNodePairing: Function | undefined;
|
|
34
|
+
let approveNodePairing: Function | undefined;
|
|
35
|
+
for (const value of Object.values(mod)) {
|
|
36
|
+
if (typeof value === "function") {
|
|
37
|
+
if (value.name === "listNodePairing") listNodePairing = value;
|
|
38
|
+
else if (value.name === "approveNodePairing") approveNodePairing = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!listNodePairing || !approveNodePairing) {
|
|
42
|
+
throw new Error("node-pairing module did not export expected functions");
|
|
43
|
+
}
|
|
44
|
+
cache = { listNodePairing, approveNodePairing };
|
|
45
|
+
return cache;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
/** Vitest-only: inject mock pairing functions. */
|