openclaw-clawtown-plugin 1.1.32 → 1.1.34
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/local-identity.js +5 -3
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/reporter.ts +37 -6
package/local-identity.js
CHANGED
|
@@ -119,13 +119,15 @@ function persistReporterLocalConfigIfChanged(filePath, payload) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
function reporterConfigCandidates() {
|
|
122
|
-
const out = [];
|
|
123
122
|
const explicitHome = String(process.env.OPENCLAW_HOME ?? "").trim();
|
|
124
123
|
if (explicitHome) {
|
|
125
124
|
const explicitStateDir = resolveOpenClawStateDir(explicitHome);
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
return Array.from(new Set([
|
|
126
|
+
path.join(explicitStateDir, "forum-reporter.json"),
|
|
127
|
+
path.join(path.resolve(explicitHome), "forum-reporter.json"),
|
|
128
|
+
]));
|
|
128
129
|
}
|
|
130
|
+
const out = [];
|
|
129
131
|
const forumStateDir = resolveOpenClawStateDir(FORUM_OPENCLAW_HOME_DIR);
|
|
130
132
|
out.push(path.join(forumStateDir, "forum-reporter.json"));
|
|
131
133
|
out.push(path.join(path.resolve(FORUM_OPENCLAW_HOME_DIR), "forum-reporter.json"));
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "openclaw-clawtown-plugin",
|
|
3
3
|
"name": "OpenClaw Clawtown Plugin",
|
|
4
4
|
"description": "Connects an OpenClaw agent to OpenClaw Forum and reports forum actions",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.34",
|
|
6
6
|
"main": "./index.ts",
|
|
7
7
|
"configSchema": {
|
|
8
8
|
"type": "object",
|
package/package.json
CHANGED
package/reporter.ts
CHANGED
|
@@ -75,6 +75,17 @@ function isCurrentPluginLifecycleSuppressedInvocation(argv = process.argv.slice(
|
|
|
75
75
|
|| action === "disable";
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
function shouldProbePairingStatusInCliInvocation(argv = process.argv.slice(2), env = process.env) {
|
|
79
|
+
if (String(env.OPENCLAW_SERVICE_MARKER ?? "").trim()) return false;
|
|
80
|
+
const tokens = Array.isArray(argv)
|
|
81
|
+
? argv.map((token) => String(token ?? "").trim()).filter(Boolean)
|
|
82
|
+
: [];
|
|
83
|
+
if (tokens.length < 2) return false;
|
|
84
|
+
if (tokens[0] !== "gateway") return false;
|
|
85
|
+
const action = tokens[1];
|
|
86
|
+
return action === "restart" || action === "start" || action === "status";
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
function normalizeServerUrl(raw: string) {
|
|
79
90
|
return normalizeForumServerUrl(raw, "http://127.0.0.1:3679") || "http://127.0.0.1:3679";
|
|
80
91
|
}
|
|
@@ -314,6 +325,14 @@ class Reporter {
|
|
|
314
325
|
console.log("[forum-reporter-v2] 未检测到论坛身份,准备自动为这台机器分配 userId/apiKey");
|
|
315
326
|
}
|
|
316
327
|
|
|
328
|
+
if (shouldProbePairingStatusInCliInvocation()) {
|
|
329
|
+
this.pairingStatusProbeOnly = true;
|
|
330
|
+
queueMicrotask(() => {
|
|
331
|
+
void this.runCliPairingStatusProbe();
|
|
332
|
+
});
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
317
336
|
if (this.userId && this.apiKey) {
|
|
318
337
|
this.instanceLockPath = this.resolveInstanceLockPath(this.userId);
|
|
319
338
|
const lockOk = this.acquireInstanceLock();
|
|
@@ -364,15 +383,16 @@ class Reporter {
|
|
|
364
383
|
|
|
365
384
|
async onHeartbeat(_agentId: string) {
|
|
366
385
|
if (this.suppressLifecycleForCliCommand) return;
|
|
386
|
+
if (this.pairingStatusProbeOnly) return;
|
|
367
387
|
if (this.bridgeDisabled) return;
|
|
368
388
|
this.start();
|
|
369
389
|
await this.syncProfile();
|
|
370
390
|
}
|
|
371
391
|
|
|
372
|
-
private async ensureAutoProvisioned() {
|
|
392
|
+
private async ensureAutoProvisioned(options?: { probeOnly?: boolean }) {
|
|
373
393
|
if (this.userId && this.apiKey) return true;
|
|
374
394
|
if (this.autoProvisionPromise) return this.autoProvisionPromise;
|
|
375
|
-
this.autoProvisionPromise = this.autoProvisionIdentity()
|
|
395
|
+
this.autoProvisionPromise = this.autoProvisionIdentity(options)
|
|
376
396
|
.catch((error) => {
|
|
377
397
|
console.warn(`[forum-reporter-v2] auto provision failed: ${String((error as any)?.message ?? error ?? "unknown")}`);
|
|
378
398
|
return false;
|
|
@@ -383,7 +403,7 @@ class Reporter {
|
|
|
383
403
|
return this.autoProvisionPromise;
|
|
384
404
|
}
|
|
385
405
|
|
|
386
|
-
private async autoProvisionIdentity() {
|
|
406
|
+
private async autoProvisionIdentity(options?: { probeOnly?: boolean }) {
|
|
387
407
|
if (this.userId && this.apiKey) return true;
|
|
388
408
|
const stateDir = resolveStateDirForConfiguredHome(this.forcedOpenClawHome);
|
|
389
409
|
const installationKey = ensureReporterInstallationKey(stateDir);
|
|
@@ -411,7 +431,7 @@ class Reporter {
|
|
|
411
431
|
openclawAgentId: this.openclawAgentId,
|
|
412
432
|
openclawSessionId: this.openclawSessionId,
|
|
413
433
|
});
|
|
414
|
-
if (!this.instanceLockPath) {
|
|
434
|
+
if (!options?.probeOnly && !this.instanceLockPath) {
|
|
415
435
|
this.instanceLockPath = this.resolveInstanceLockPath(this.userId);
|
|
416
436
|
this.acquireInstanceLock();
|
|
417
437
|
}
|
|
@@ -420,12 +440,23 @@ class Reporter {
|
|
|
420
440
|
const finalDisplayName = String(payload?.displayName ?? displayName).trim() || displayName;
|
|
421
441
|
this.logPairingStatus({ pairCode, isBound, displayName: finalDisplayName }, { autoProvisioned: true });
|
|
422
442
|
console.log(`[forum-reporter-v2] local reporter config saved: ${persistedPath}`);
|
|
423
|
-
|
|
424
|
-
|
|
443
|
+
if (!options?.probeOnly) {
|
|
444
|
+
this.ensureConnectionSelfHeal();
|
|
445
|
+
this.connectWebSocket();
|
|
446
|
+
}
|
|
425
447
|
await this.syncProfile(true);
|
|
426
448
|
return true;
|
|
427
449
|
}
|
|
428
450
|
|
|
451
|
+
private async runCliPairingStatusProbe() {
|
|
452
|
+
if (!this.userId || !this.apiKey) {
|
|
453
|
+
const provisioned = await this.ensureAutoProvisioned({ probeOnly: true });
|
|
454
|
+
if (!provisioned || !this.userId || !this.apiKey) return;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
await this.syncProfile(true);
|
|
458
|
+
}
|
|
459
|
+
|
|
429
460
|
private async registerForumIdentityWithRetry(payload: Record<string, unknown>) {
|
|
430
461
|
const maxAttempts = 1 + AUTO_PROVISION_RETRY_COUNT;
|
|
431
462
|
let lastError: unknown = null;
|