@clwnt/clawnet 0.7.16 → 0.7.18
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/index.ts +2 -4
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/cli.ts +2 -3
- package/src/config.ts +4 -0
- package/src/service.ts +8 -3
package/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
|
2
2
|
import { registerClawnetCli, buildClawnetMapping, upsertMapping, buildStatusText } from "./src/cli.js";
|
|
3
3
|
import { createClawnetService, getHooksUrl, getHooksToken } from "./src/service.js";
|
|
4
|
-
import { parseConfig } from "./src/config.js";
|
|
4
|
+
import { parseConfig, resolveToken } from "./src/config.js";
|
|
5
5
|
import { registerTools, loadToolDescriptions } from "./src/tools.js";
|
|
6
6
|
import { migrateConfig, CURRENT_SETUP_VERSION } from "./src/migrate.js";
|
|
7
7
|
|
|
@@ -56,9 +56,7 @@ const plugin = {
|
|
|
56
56
|
if (enabledAccounts.length > 0) {
|
|
57
57
|
const issues: string[] = [];
|
|
58
58
|
for (const account of enabledAccounts) {
|
|
59
|
-
const
|
|
60
|
-
const envMatch = tokenRef.match(/^\$\{(.+)\}$/);
|
|
61
|
-
const token = envMatch ? process.env[envMatch[1]] || "" : tokenRef;
|
|
59
|
+
const token = resolveToken(typeof account.token === "string" ? account.token : "");
|
|
62
60
|
if (!token) {
|
|
63
61
|
issues.push(`${account.agentId}: no token resolved`);
|
|
64
62
|
continue;
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as fs from "node:fs/promises";
|
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import * as os from "node:os";
|
|
7
7
|
import type { ClawnetConfig } from "./config.js";
|
|
8
|
+
import { resolveToken } from "./config.js";
|
|
8
9
|
import { PLUGIN_VERSION } from "./service.js";
|
|
9
10
|
|
|
10
11
|
const API_BASE = "https://api.clwnt.com";
|
|
@@ -660,9 +661,7 @@ export function registerClawnetCli(params: { program: Command; api: any; cfg: Cl
|
|
|
660
661
|
console.log("\n Connectivity:\n");
|
|
661
662
|
const routingIssues: string[] = [];
|
|
662
663
|
for (const account of pluginCfg.accounts) {
|
|
663
|
-
const
|
|
664
|
-
const match = tokenRef.match(/^\$\{(.+)\}$/);
|
|
665
|
-
const resolvedToken = match ? process.env[match[1]] || "" : tokenRef;
|
|
664
|
+
const resolvedToken = resolveToken(typeof account.token === "string" ? account.token : "");
|
|
666
665
|
|
|
667
666
|
if (!resolvedToken) {
|
|
668
667
|
console.log(` ${account.id}: NO TOKEN (env var not set)`);
|
package/src/config.ts
CHANGED
package/src/service.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
1
4
|
import type { ClawnetConfig, ClawnetAccount } from "./config.js";
|
|
2
|
-
import { parseConfig, resolveToken } from "./config.js";
|
|
5
|
+
import { parseConfig, resolveHooksToken, resolveToken } from "./config.js";
|
|
3
6
|
import { reloadCapabilities } from "./tools.js";
|
|
4
7
|
import { reloadHookTemplate, getHookTemplate } from "./cli.js";
|
|
5
8
|
|
|
@@ -38,7 +41,7 @@ export function getHooksUrl(api: any): string {
|
|
|
38
41
|
|
|
39
42
|
export function getHooksToken(api: any): string {
|
|
40
43
|
const rawToken = api.config?.hooks?.token ?? "";
|
|
41
|
-
return
|
|
44
|
+
return resolveHooksToken(rawToken);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
// --- Onboarding message (cached from server) ---
|
|
@@ -73,7 +76,9 @@ async function reloadOnboardingMessage(): Promise<void> {
|
|
|
73
76
|
|
|
74
77
|
const SKILL_UPDATE_INTERVAL_MS = 6 * 60 * 60 * 1000; // 6 hours
|
|
75
78
|
const SKILL_FILES = ["skill.json", "api-reference.md", "inbox-handler.md", "capabilities.json", "hook-template.txt", "tool-descriptions.json", "onboarding-message.txt", "inbox-protocol.md"];
|
|
76
|
-
|
|
79
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
80
|
+
const manifest = JSON.parse(readFileSync(join(__dirname, "..", "openclaw.plugin.json"), "utf-8"));
|
|
81
|
+
export const PLUGIN_VERSION: string = manifest.version ?? "unknown";
|
|
77
82
|
|
|
78
83
|
function loadFreshConfig(api: any): ClawnetConfig {
|
|
79
84
|
const raw = api.runtime?.config?.loadConfig?.()?.plugins?.entries?.clawnet?.config ?? {};
|