openclaw-clawtown-plugin 1.1.21 → 1.1.24
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 +30 -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.24",
|
|
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,6 +308,9 @@ 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();
|
|
@@ -729,7 +739,7 @@ class Reporter {
|
|
|
729
739
|
rawOutput = await runTaskTurn(
|
|
730
740
|
instructions,
|
|
731
741
|
TASK_FIRST_TURN_TIMEOUT_SECONDS,
|
|
732
|
-
|
|
742
|
+
TASK_FIRST_TURN_TIMEOUT_MS,
|
|
733
743
|
tid || qid || taskType,
|
|
734
744
|
);
|
|
735
745
|
} catch (error: any) {
|
|
@@ -751,7 +761,7 @@ class Reporter {
|
|
|
751
761
|
rawOutput = await runTaskTurn(
|
|
752
762
|
instructions,
|
|
753
763
|
TASK_TIMEOUT_RETRY_SECONDS,
|
|
754
|
-
|
|
764
|
+
TASK_TIMEOUT_RETRY_MS,
|
|
755
765
|
`${tid || qid || taskType}-timeout-retry1`,
|
|
756
766
|
);
|
|
757
767
|
} catch (error: any) {
|
|
@@ -776,7 +786,7 @@ class Reporter {
|
|
|
776
786
|
rawOutput = await runTaskTurn(
|
|
777
787
|
instructions,
|
|
778
788
|
TASK_FIRST_TURN_TIMEOUT_SECONDS,
|
|
779
|
-
|
|
789
|
+
TASK_FIRST_TURN_TIMEOUT_MS,
|
|
780
790
|
`${tid || qid || taskType}-retry1`,
|
|
781
791
|
);
|
|
782
792
|
} catch (error: any) {
|
|
@@ -811,7 +821,7 @@ class Reporter {
|
|
|
811
821
|
retryOutput = await runTaskTurn(
|
|
812
822
|
retryInstructions,
|
|
813
823
|
TASK_FIRST_TURN_TIMEOUT_SECONDS,
|
|
814
|
-
|
|
824
|
+
TASK_FIRST_TURN_TIMEOUT_MS,
|
|
815
825
|
`${tid || qid || taskType}-submit-retry1`,
|
|
816
826
|
);
|
|
817
827
|
} catch (error: any) {
|
|
@@ -1074,7 +1084,7 @@ class Reporter {
|
|
|
1074
1084
|
const prompt = buildV2ActionPrompt(context);
|
|
1075
1085
|
let text = "";
|
|
1076
1086
|
try {
|
|
1077
|
-
const turn = await this.runVisibleAgentTurn(prompt,
|
|
1087
|
+
const turn = await this.runVisibleAgentTurn(prompt, ACTION_CONTEXT_TIMEOUT_SECONDS, ACTION_CONTEXT_TIMEOUT_MS, {
|
|
1078
1088
|
taskKey: `context-${context.userId}`,
|
|
1079
1089
|
});
|
|
1080
1090
|
text = turn.extractedText;
|
|
@@ -1162,6 +1172,7 @@ class Reporter {
|
|
|
1162
1172
|
): Promise<AgentTurnResult> {
|
|
1163
1173
|
const isWindows = process.platform === "win32";
|
|
1164
1174
|
const startedAt = Date.now();
|
|
1175
|
+
const commandTimeoutMs = resolveAgentCommandTimeoutMs(timeoutSeconds, timeoutMs);
|
|
1165
1176
|
if (isWindows) {
|
|
1166
1177
|
const script = buildWindowsAgentCommandScript({
|
|
1167
1178
|
agentId: this.openclawAgentId,
|
|
@@ -1185,10 +1196,10 @@ class Reporter {
|
|
|
1185
1196
|
...(this.forcedOpenClawHome ? { OPENCLAW_HOME: this.forcedOpenClawHome } : {}),
|
|
1186
1197
|
},
|
|
1187
1198
|
windowsHide: true,
|
|
1188
|
-
timeout:
|
|
1199
|
+
timeout: commandTimeoutMs,
|
|
1189
1200
|
maxBuffer: 1024 * 1024,
|
|
1190
1201
|
}),
|
|
1191
|
-
|
|
1202
|
+
commandTimeoutMs,
|
|
1192
1203
|
);
|
|
1193
1204
|
return buildAgentTurnResult({
|
|
1194
1205
|
stdout: String(result.stdout ?? ""),
|
|
@@ -1201,6 +1212,7 @@ class Reporter {
|
|
|
1201
1212
|
|
|
1202
1213
|
const args = [
|
|
1203
1214
|
"agent",
|
|
1215
|
+
"--local",
|
|
1204
1216
|
"--session-id", sessionId,
|
|
1205
1217
|
"--message", message,
|
|
1206
1218
|
"--json",
|
|
@@ -1217,10 +1229,10 @@ class Reporter {
|
|
|
1217
1229
|
[DISABLE_BRIDGE_ENV]: "1",
|
|
1218
1230
|
...(this.forcedOpenClawHome ? { OPENCLAW_HOME: this.forcedOpenClawHome } : {}),
|
|
1219
1231
|
},
|
|
1220
|
-
timeout:
|
|
1232
|
+
timeout: commandTimeoutMs,
|
|
1221
1233
|
maxBuffer: 1024 * 1024,
|
|
1222
1234
|
}),
|
|
1223
|
-
|
|
1235
|
+
commandTimeoutMs,
|
|
1224
1236
|
);
|
|
1225
1237
|
return buildAgentTurnResult({
|
|
1226
1238
|
stdout: String(result.stdout ?? ""),
|
|
@@ -1973,7 +1985,7 @@ function buildWindowsAgentCommandScript(input: { agentId: string; sessionId: str
|
|
|
1973
1985
|
"$forumMessage = @'",
|
|
1974
1986
|
safeMessage,
|
|
1975
1987
|
"'@",
|
|
1976
|
-
`openclaw agent --session-id ${quoteForPowerShell(input.sessionId)}${agentArgs} --message $forumMessage --json --thinking minimal --timeout ${Number(input.timeoutSeconds)}`,
|
|
1988
|
+
`openclaw agent --local --session-id ${quoteForPowerShell(input.sessionId)}${agentArgs} --message $forumMessage --json --thinking minimal --timeout ${Number(input.timeoutSeconds)}`,
|
|
1977
1989
|
].join("\n");
|
|
1978
1990
|
}
|
|
1979
1991
|
|
|
@@ -2990,4 +3002,10 @@ async function promiseWithTimeout<T>(promise: Promise<T>, timeoutMs: number): Pr
|
|
|
2990
3002
|
]);
|
|
2991
3003
|
}
|
|
2992
3004
|
|
|
3005
|
+
function resolveAgentCommandTimeoutMs(timeoutSeconds: number, timeoutMs: number) {
|
|
3006
|
+
const cliBudgetMs = Math.max(0, Math.round(Number(timeoutSeconds) || 0)) * 1_000 + 10_000;
|
|
3007
|
+
const externalBudgetMs = Math.max(0, Math.round(Number(timeoutMs) || 0));
|
|
3008
|
+
return Math.max(cliBudgetMs, externalBudgetMs);
|
|
3009
|
+
}
|
|
3010
|
+
|
|
2993
3011
|
export const reporter = new Reporter();
|