omoclaw 2.0.0 → 2.1.0
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 +3 -37
- package/dist/webhook.d.ts +3 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -399,42 +399,8 @@ function wlog(msg) {
|
|
|
399
399
|
`);
|
|
400
400
|
} catch {}
|
|
401
401
|
}
|
|
402
|
-
function deriveBaseUrl(wakeUrl) {
|
|
403
|
-
return wakeUrl.replace(/\/hooks\/wake\/?$/, "");
|
|
404
|
-
}
|
|
405
402
|
function sendWebhook(config, text) {
|
|
406
403
|
const { webhook } = config;
|
|
407
|
-
const baseUrl = deriveBaseUrl(webhook.url);
|
|
408
|
-
if (webhook.channel) {
|
|
409
|
-
const sessionKey = `agent:main:discord:channel:${webhook.channel}`;
|
|
410
|
-
const responsesUrl = `${baseUrl}/v1/responses`;
|
|
411
|
-
const body = {
|
|
412
|
-
model: "openclaw",
|
|
413
|
-
input: [{
|
|
414
|
-
type: "message",
|
|
415
|
-
role: "user",
|
|
416
|
-
content: [{ type: "input_text", text }]
|
|
417
|
-
}],
|
|
418
|
-
stream: false
|
|
419
|
-
};
|
|
420
|
-
const apiToken = webhook.gatewayToken || webhook.token;
|
|
421
|
-
wlog(`Sending /v1/responses to ${responsesUrl} (session: ${sessionKey}): ${text}`);
|
|
422
|
-
fetch(responsesUrl, {
|
|
423
|
-
method: "POST",
|
|
424
|
-
headers: {
|
|
425
|
-
Authorization: `Bearer ${apiToken}`,
|
|
426
|
-
"Content-Type": "application/json",
|
|
427
|
-
"x-openclaw-session-key": sessionKey
|
|
428
|
-
},
|
|
429
|
-
body: JSON.stringify(body)
|
|
430
|
-
}).then(async (resp) => {
|
|
431
|
-
wlog(`/v1/responses: status=${resp.status} ok=${resp.ok}`);
|
|
432
|
-
console.log("[monitor] session wake sent:", text);
|
|
433
|
-
}).catch((error) => {
|
|
434
|
-
wlog(`/v1/responses FETCH ERROR: ${String(error)}`);
|
|
435
|
-
console.error("[monitor] session wake error:", error);
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
404
|
wlog(`Sending /hooks/wake to ${webhook.url}: ${text}`);
|
|
439
405
|
fetch(webhook.url, {
|
|
440
406
|
method: "POST",
|
|
@@ -445,10 +411,10 @@ function sendWebhook(config, text) {
|
|
|
445
411
|
body: JSON.stringify({ text, mode: "now" })
|
|
446
412
|
}).then((resp) => {
|
|
447
413
|
wlog(`/hooks/wake: status=${resp.status} ok=${resp.ok}`);
|
|
448
|
-
console.log("[monitor] wake
|
|
414
|
+
console.log("[monitor] wake sent:", text);
|
|
449
415
|
}).catch((error) => {
|
|
450
|
-
wlog(`/hooks/wake
|
|
451
|
-
console.error("[monitor] wake
|
|
416
|
+
wlog(`/hooks/wake ERROR: ${String(error)}`);
|
|
417
|
+
console.error("[monitor] wake error:", error);
|
|
452
418
|
});
|
|
453
419
|
}
|
|
454
420
|
|
package/dist/webhook.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { MonitorConfig } from "./config";
|
|
2
2
|
/**
|
|
3
|
-
* Send notification to OpenClaw
|
|
4
|
-
* This
|
|
5
|
-
*
|
|
6
|
-
* Dual strategy:
|
|
7
|
-
* 1. /v1/responses + session key → wakes the EXACT channel session (primary)
|
|
8
|
-
* 2. /hooks/wake → wakes main session as fallback
|
|
3
|
+
* Send wake notification to OpenClaw via /hooks/wake.
|
|
4
|
+
* This injects a system event and triggers heartbeat on all active sessions.
|
|
5
|
+
* Fire-and-forget, no token cost, instant 200 response.
|
|
9
6
|
*/
|
|
10
7
|
export declare function sendWebhook(config: MonitorConfig, text: string): void;
|
package/package.json
CHANGED