@agent-wechat/wechat 0.4.0 → 0.4.1
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/dist/index.js +5 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1118,9 +1118,6 @@ function getWeChatRuntime() {
|
|
|
1118
1118
|
return runtime;
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
1121
|
-
// src/monitor.ts
|
|
1122
|
-
import { execSync } from "node:child_process";
|
|
1123
|
-
|
|
1124
1121
|
// ../shared/dist/client.js
|
|
1125
1122
|
function normalizeUrl(base) {
|
|
1126
1123
|
const url = base.startsWith("http") ? base : `http://${base}`;
|
|
@@ -5553,14 +5550,6 @@ function enqueueWeChatSystemEvent(text, contextKey) {
|
|
|
5553
5550
|
} catch {
|
|
5554
5551
|
}
|
|
5555
5552
|
}
|
|
5556
|
-
function enqueueAndWakeSystemEvent(text, contextKey, log) {
|
|
5557
|
-
enqueueWeChatSystemEvent(text, contextKey);
|
|
5558
|
-
try {
|
|
5559
|
-
execSync("openclaw system event --mode now", { timeout: 5e3, stdio: "ignore" });
|
|
5560
|
-
} catch {
|
|
5561
|
-
log?.info?.("Failed to trigger heartbeat wake \u2014 agent will see event on next prompt");
|
|
5562
|
-
}
|
|
5563
|
-
}
|
|
5564
5553
|
async function startWeChatMonitor(opts) {
|
|
5565
5554
|
const { account, abortSignal, setStatus, log } = opts;
|
|
5566
5555
|
const client = new WeChatClient({ baseUrl: account.serverUrl, token: account.token });
|
|
@@ -5591,12 +5580,11 @@ async function startWeChatMonitor(opts) {
|
|
|
5591
5580
|
});
|
|
5592
5581
|
if (prevStatus === "logged_in" && !isLinked) {
|
|
5593
5582
|
const msg = auth.status === "app_not_running" ? "[WeChat] Application stopped. It will restart automatically \u2014 credentials may be cached, so you can try reconnecting using the wechat_login tool." : "[WeChat] Session ended. You can try reconnecting using the wechat_login tool \u2014 if credentials are cached, login may complete automatically.";
|
|
5594
|
-
|
|
5583
|
+
enqueueWeChatSystemEvent(msg, "wechat:auth_lost");
|
|
5595
5584
|
} else if (prevStatus === void 0 && !isLinked) {
|
|
5596
|
-
|
|
5585
|
+
enqueueWeChatSystemEvent(
|
|
5597
5586
|
"[WeChat] Not logged in. Use the wechat_login tool to authenticate \u2014 if credentials are cached from a previous session, login may complete automatically.",
|
|
5598
|
-
"wechat:auth_required"
|
|
5599
|
-
log
|
|
5587
|
+
"wechat:auth_required"
|
|
5600
5588
|
);
|
|
5601
5589
|
}
|
|
5602
5590
|
prevStatus = auth.status;
|
|
@@ -5614,10 +5602,9 @@ async function startWeChatMonitor(opts) {
|
|
|
5614
5602
|
lastError: String(err)
|
|
5615
5603
|
});
|
|
5616
5604
|
if (prevStatus === "logged_in") {
|
|
5617
|
-
|
|
5605
|
+
enqueueWeChatSystemEvent(
|
|
5618
5606
|
"[WeChat] Cannot reach agent-wechat server. The container may have stopped.",
|
|
5619
|
-
"wechat:server_unreachable"
|
|
5620
|
-
log
|
|
5607
|
+
"wechat:server_unreachable"
|
|
5621
5608
|
);
|
|
5622
5609
|
}
|
|
5623
5610
|
prevStatus = void 0;
|