openclaw-clawtown-plugin 1.1.21 → 1.1.25
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/reporter.ts +33 -12
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.25",
|
|
6
6
|
"main": "./index.ts",
|
|
7
7
|
"configSchema": {
|
|
8
8
|
"type": "object",
|
package/package.json
CHANGED
package/reporter.ts
CHANGED
|
@@ -15,9 +15,11 @@ const BRIDGE_DISABLED = process.env[DISABLE_BRIDGE_ENV] === "1";
|
|
|
15
15
|
|
|
16
16
|
const PROFILE_SYNC_MIN_INTERVAL_MS = 5 * 60_000;
|
|
17
17
|
const TASK_FIRST_TURN_TIMEOUT_SECONDS = 120;
|
|
18
|
+
const TASK_FIRST_TURN_TIMEOUT_MS = 130_000;
|
|
18
19
|
const TASK_TIMEOUT_RETRY_SECONDS = 180;
|
|
19
|
-
const
|
|
20
|
-
const
|
|
20
|
+
const TASK_TIMEOUT_RETRY_MS = 190_000;
|
|
21
|
+
const ACTION_CONTEXT_TIMEOUT_SECONDS = 115;
|
|
22
|
+
const ACTION_CONTEXT_TIMEOUT_MS = 125_000;
|
|
21
23
|
const API_FETCH_TIMEOUT_MS = 20_000;
|
|
22
24
|
const AUTO_PROVISION_RETRY_COUNT = 3;
|
|
23
25
|
const AUTO_PROVISION_RETRY_DELAYS_MS = [1_500, 3_000, 5_000];
|
|
@@ -231,6 +233,7 @@ class Reporter {
|
|
|
231
233
|
private authHealth: AuthHealthCheck | null = null;
|
|
232
234
|
private autoProvisionPromise: Promise<boolean> | null = null;
|
|
233
235
|
private lastPairingStatusShown = "";
|
|
236
|
+
private pairingStatusProbeOnly = false;
|
|
234
237
|
|
|
235
238
|
constructor() {
|
|
236
239
|
const legacyRuntime = handleLegacyRuntimeConflict(this.reporterRuntime);
|
|
@@ -286,7 +289,11 @@ class Reporter {
|
|
|
286
289
|
const lockOk = this.acquireInstanceLock();
|
|
287
290
|
if (!lockOk) {
|
|
288
291
|
this.bridgeDisabled = true;
|
|
292
|
+
this.pairingStatusProbeOnly = true;
|
|
289
293
|
console.warn(`[forum-reporter-v2] duplicate reporter instance detected for userId=${this.userId}; bridge disabled in this process`);
|
|
294
|
+
queueMicrotask(() => {
|
|
295
|
+
void this.syncProfile(true);
|
|
296
|
+
});
|
|
290
297
|
}
|
|
291
298
|
}
|
|
292
299
|
|
|
@@ -301,11 +308,17 @@ class Reporter {
|
|
|
301
308
|
}
|
|
302
309
|
|
|
303
310
|
start() {
|
|
311
|
+
if (this.pairingStatusProbeOnly) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
304
314
|
if (this.bridgeDisabled) return;
|
|
305
315
|
if (!this.userId || !this.apiKey) {
|
|
306
316
|
void this.ensureAutoProvisioned();
|
|
307
317
|
return;
|
|
308
318
|
}
|
|
319
|
+
if (!this.lastPairingStatusShown) {
|
|
320
|
+
void this.syncProfile(true);
|
|
321
|
+
}
|
|
309
322
|
this.ensureConnectionSelfHeal();
|
|
310
323
|
this.connectWebSocket();
|
|
311
324
|
}
|
|
@@ -729,7 +742,7 @@ class Reporter {
|
|
|
729
742
|
rawOutput = await runTaskTurn(
|
|
730
743
|
instructions,
|
|
731
744
|
TASK_FIRST_TURN_TIMEOUT_SECONDS,
|
|
732
|
-
|
|
745
|
+
TASK_FIRST_TURN_TIMEOUT_MS,
|
|
733
746
|
tid || qid || taskType,
|
|
734
747
|
);
|
|
735
748
|
} catch (error: any) {
|
|
@@ -751,7 +764,7 @@ class Reporter {
|
|
|
751
764
|
rawOutput = await runTaskTurn(
|
|
752
765
|
instructions,
|
|
753
766
|
TASK_TIMEOUT_RETRY_SECONDS,
|
|
754
|
-
|
|
767
|
+
TASK_TIMEOUT_RETRY_MS,
|
|
755
768
|
`${tid || qid || taskType}-timeout-retry1`,
|
|
756
769
|
);
|
|
757
770
|
} catch (error: any) {
|
|
@@ -776,7 +789,7 @@ class Reporter {
|
|
|
776
789
|
rawOutput = await runTaskTurn(
|
|
777
790
|
instructions,
|
|
778
791
|
TASK_FIRST_TURN_TIMEOUT_SECONDS,
|
|
779
|
-
|
|
792
|
+
TASK_FIRST_TURN_TIMEOUT_MS,
|
|
780
793
|
`${tid || qid || taskType}-retry1`,
|
|
781
794
|
);
|
|
782
795
|
} catch (error: any) {
|
|
@@ -811,7 +824,7 @@ class Reporter {
|
|
|
811
824
|
retryOutput = await runTaskTurn(
|
|
812
825
|
retryInstructions,
|
|
813
826
|
TASK_FIRST_TURN_TIMEOUT_SECONDS,
|
|
814
|
-
|
|
827
|
+
TASK_FIRST_TURN_TIMEOUT_MS,
|
|
815
828
|
`${tid || qid || taskType}-submit-retry1`,
|
|
816
829
|
);
|
|
817
830
|
} catch (error: any) {
|
|
@@ -1074,7 +1087,7 @@ class Reporter {
|
|
|
1074
1087
|
const prompt = buildV2ActionPrompt(context);
|
|
1075
1088
|
let text = "";
|
|
1076
1089
|
try {
|
|
1077
|
-
const turn = await this.runVisibleAgentTurn(prompt,
|
|
1090
|
+
const turn = await this.runVisibleAgentTurn(prompt, ACTION_CONTEXT_TIMEOUT_SECONDS, ACTION_CONTEXT_TIMEOUT_MS, {
|
|
1078
1091
|
taskKey: `context-${context.userId}`,
|
|
1079
1092
|
});
|
|
1080
1093
|
text = turn.extractedText;
|
|
@@ -1162,6 +1175,7 @@ class Reporter {
|
|
|
1162
1175
|
): Promise<AgentTurnResult> {
|
|
1163
1176
|
const isWindows = process.platform === "win32";
|
|
1164
1177
|
const startedAt = Date.now();
|
|
1178
|
+
const commandTimeoutMs = resolveAgentCommandTimeoutMs(timeoutSeconds, timeoutMs);
|
|
1165
1179
|
if (isWindows) {
|
|
1166
1180
|
const script = buildWindowsAgentCommandScript({
|
|
1167
1181
|
agentId: this.openclawAgentId,
|
|
@@ -1185,10 +1199,10 @@ class Reporter {
|
|
|
1185
1199
|
...(this.forcedOpenClawHome ? { OPENCLAW_HOME: this.forcedOpenClawHome } : {}),
|
|
1186
1200
|
},
|
|
1187
1201
|
windowsHide: true,
|
|
1188
|
-
timeout:
|
|
1202
|
+
timeout: commandTimeoutMs,
|
|
1189
1203
|
maxBuffer: 1024 * 1024,
|
|
1190
1204
|
}),
|
|
1191
|
-
|
|
1205
|
+
commandTimeoutMs,
|
|
1192
1206
|
);
|
|
1193
1207
|
return buildAgentTurnResult({
|
|
1194
1208
|
stdout: String(result.stdout ?? ""),
|
|
@@ -1201,6 +1215,7 @@ class Reporter {
|
|
|
1201
1215
|
|
|
1202
1216
|
const args = [
|
|
1203
1217
|
"agent",
|
|
1218
|
+
"--local",
|
|
1204
1219
|
"--session-id", sessionId,
|
|
1205
1220
|
"--message", message,
|
|
1206
1221
|
"--json",
|
|
@@ -1217,10 +1232,10 @@ class Reporter {
|
|
|
1217
1232
|
[DISABLE_BRIDGE_ENV]: "1",
|
|
1218
1233
|
...(this.forcedOpenClawHome ? { OPENCLAW_HOME: this.forcedOpenClawHome } : {}),
|
|
1219
1234
|
},
|
|
1220
|
-
timeout:
|
|
1235
|
+
timeout: commandTimeoutMs,
|
|
1221
1236
|
maxBuffer: 1024 * 1024,
|
|
1222
1237
|
}),
|
|
1223
|
-
|
|
1238
|
+
commandTimeoutMs,
|
|
1224
1239
|
);
|
|
1225
1240
|
return buildAgentTurnResult({
|
|
1226
1241
|
stdout: String(result.stdout ?? ""),
|
|
@@ -1973,7 +1988,7 @@ function buildWindowsAgentCommandScript(input: { agentId: string; sessionId: str
|
|
|
1973
1988
|
"$forumMessage = @'",
|
|
1974
1989
|
safeMessage,
|
|
1975
1990
|
"'@",
|
|
1976
|
-
`openclaw agent --session-id ${quoteForPowerShell(input.sessionId)}${agentArgs} --message $forumMessage --json --thinking minimal --timeout ${Number(input.timeoutSeconds)}`,
|
|
1991
|
+
`openclaw agent --local --session-id ${quoteForPowerShell(input.sessionId)}${agentArgs} --message $forumMessage --json --thinking minimal --timeout ${Number(input.timeoutSeconds)}`,
|
|
1977
1992
|
].join("\n");
|
|
1978
1993
|
}
|
|
1979
1994
|
|
|
@@ -2990,4 +3005,10 @@ async function promiseWithTimeout<T>(promise: Promise<T>, timeoutMs: number): Pr
|
|
|
2990
3005
|
]);
|
|
2991
3006
|
}
|
|
2992
3007
|
|
|
3008
|
+
function resolveAgentCommandTimeoutMs(timeoutSeconds: number, timeoutMs: number) {
|
|
3009
|
+
const cliBudgetMs = Math.max(0, Math.round(Number(timeoutSeconds) || 0)) * 1_000 + 10_000;
|
|
3010
|
+
const externalBudgetMs = Math.max(0, Math.round(Number(timeoutMs) || 0));
|
|
3011
|
+
return Math.max(cliBudgetMs, externalBudgetMs);
|
|
3012
|
+
}
|
|
3013
|
+
|
|
2993
3014
|
export const reporter = new Reporter();
|