@syengup/friday-channel-next 0.0.42 → 0.0.43
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,7 +1,7 @@
|
|
|
1
|
-
export declare function loadNodePairingModule(): {
|
|
1
|
+
export declare function loadNodePairingModule(): Promise<{
|
|
2
2
|
listNodePairing: Function;
|
|
3
3
|
approveNodePairing: Function;
|
|
4
|
-
}
|
|
4
|
+
}>;
|
|
5
5
|
/** Vitest-only: inject mock pairing functions. */
|
|
6
6
|
export declare function __setMockNodePairingForTests(mock: {
|
|
7
7
|
listNodePairing: Function;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { readdirSync } from "node:fs";
|
|
3
2
|
import { join, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
4
|
let cache = null;
|
|
5
5
|
function resolveOpenClawDist() {
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// maps `openclaw/*` to the installed dist.
|
|
9
|
-
const gatewayRequire = createRequire(import.meta.url);
|
|
6
|
+
// Walk up from the gateway-resolved SDK module to find the dist directory.
|
|
7
|
+
// import.meta.resolve is available in Node 20.6+.
|
|
10
8
|
try {
|
|
11
|
-
const corePath =
|
|
9
|
+
const corePath = fileURLToPath(import.meta.resolve("openclaw/plugin-sdk/core"));
|
|
12
10
|
return dirname(dirname(corePath)); // dist/plugin-sdk/core.js → dist/
|
|
13
11
|
}
|
|
14
12
|
catch {
|
|
15
|
-
// Fallback for when the plugin runs outside the gateway process.
|
|
16
|
-
// Probe common install paths.
|
|
17
13
|
for (const root of [
|
|
18
|
-
join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
|
|
19
|
-
"/opt/homebrew/lib/node_modules/openclaw/dist",
|
|
20
|
-
"/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
|
|
21
|
-
"/usr/local/lib/node_modules/openclaw/dist",
|
|
14
|
+
join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
|
|
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",
|
|
22
18
|
]) {
|
|
23
19
|
try {
|
|
24
20
|
readdirSync(root);
|
|
@@ -29,14 +25,16 @@ function resolveOpenClawDist() {
|
|
|
29
25
|
throw new Error("OpenClaw dist directory not found");
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
export function loadNodePairingModule() {
|
|
28
|
+
export async function loadNodePairingModule() {
|
|
33
29
|
if (cache)
|
|
34
30
|
return cache;
|
|
35
31
|
const dist = resolveOpenClawDist();
|
|
36
32
|
const file = readdirSync(dist).find((f) => f.startsWith("node-pairing-") && f.endsWith(".js") && !f.includes("authz"));
|
|
37
33
|
if (!file)
|
|
38
34
|
throw new Error("node-pairing module not found in OpenClaw dist");
|
|
39
|
-
|
|
35
|
+
// ESM import() correctly resolves named exports (listNodePairing, approveNodePairing)
|
|
36
|
+
// unlike createRequire which exposes the minified export names (r, t).
|
|
37
|
+
cache = await import(join(dist, file));
|
|
40
38
|
return cache;
|
|
41
39
|
}
|
|
42
40
|
/** Vitest-only: inject mock pairing functions. */
|
|
@@ -32,8 +32,17 @@ export async function handleNodesApprove(req, res) {
|
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
34
|
const normalizedNodeId = rawNodeId.trim().toUpperCase();
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
let listData, listNodePairing, approveNodePairing;
|
|
36
|
+
try {
|
|
37
|
+
({ listNodePairing, approveNodePairing } = await loadNodePairingModule());
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
log.error(`loadNodePairingModule failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
41
|
+
res.statusCode = 502;
|
|
42
|
+
res.setHeader("Content-Type", "application/json");
|
|
43
|
+
res.end(JSON.stringify({ error: "Failed to load node pairing module" }));
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
37
46
|
try {
|
|
38
47
|
listData = await listNodePairing();
|
|
39
48
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { readdirSync } from "node:fs";
|
|
3
2
|
import { join, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
5
|
let cache: { listNodePairing: Function; approveNodePairing: Function } | null = null;
|
|
6
6
|
|
|
7
7
|
function resolveOpenClawDist(): string {
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// maps `openclaw/*` to the installed dist.
|
|
11
|
-
const gatewayRequire = createRequire(import.meta.url);
|
|
8
|
+
// Walk up from the gateway-resolved SDK module to find the dist directory.
|
|
9
|
+
// import.meta.resolve is available in Node 20.6+.
|
|
12
10
|
try {
|
|
13
|
-
const corePath =
|
|
11
|
+
const corePath = fileURLToPath(import.meta.resolve("openclaw/plugin-sdk/core"));
|
|
14
12
|
return dirname(dirname(corePath)); // dist/plugin-sdk/core.js → dist/
|
|
15
13
|
} catch {
|
|
16
|
-
// Fallback for when the plugin runs outside the gateway process.
|
|
17
|
-
// Probe common install paths.
|
|
18
14
|
for (const root of [
|
|
19
|
-
join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
|
|
20
|
-
"/opt/homebrew/lib/node_modules/openclaw/dist",
|
|
21
|
-
"/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
|
|
22
|
-
"/usr/local/lib/node_modules/openclaw/dist",
|
|
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",
|
|
23
19
|
]) {
|
|
24
20
|
try { readdirSync(root); return root; } catch {}
|
|
25
21
|
}
|
|
@@ -27,17 +23,19 @@ function resolveOpenClawDist(): string {
|
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
export function loadNodePairingModule(): {
|
|
26
|
+
export async function loadNodePairingModule(): Promise<{
|
|
31
27
|
listNodePairing: Function;
|
|
32
28
|
approveNodePairing: Function;
|
|
33
|
-
} {
|
|
29
|
+
}> {
|
|
34
30
|
if (cache) return cache;
|
|
35
31
|
const dist = resolveOpenClawDist();
|
|
36
32
|
const file = readdirSync(dist).find(
|
|
37
33
|
(f) => f.startsWith("node-pairing-") && f.endsWith(".js") && !f.includes("authz"),
|
|
38
34
|
);
|
|
39
35
|
if (!file) throw new Error("node-pairing module not found in OpenClaw dist");
|
|
40
|
-
|
|
36
|
+
// ESM import() correctly resolves named exports (listNodePairing, approveNodePairing)
|
|
37
|
+
// unlike createRequire which exposes the minified export names (r, t).
|
|
38
|
+
cache = await import(join(dist, file));
|
|
41
39
|
return cache!;
|
|
42
40
|
}
|
|
43
41
|
|
|
@@ -62,9 +62,16 @@ export async function handleNodesApprove(
|
|
|
62
62
|
|
|
63
63
|
const normalizedNodeId = rawNodeId.trim().toUpperCase();
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
let listData, listNodePairing, approveNodePairing;
|
|
66
|
+
try {
|
|
67
|
+
({ listNodePairing, approveNodePairing } = await loadNodePairingModule());
|
|
68
|
+
} catch (err) {
|
|
69
|
+
log.error(`loadNodePairingModule failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
70
|
+
res.statusCode = 502;
|
|
71
|
+
res.setHeader("Content-Type", "application/json");
|
|
72
|
+
res.end(JSON.stringify({ error: "Failed to load node pairing module" }));
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
68
75
|
try {
|
|
69
76
|
listData = await listNodePairing();
|
|
70
77
|
} catch (err) {
|