omoclaw 1.3.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/config.d.ts +2 -0
- package/dist/index.js +5 -32
- package/dist/webhook.d.ts +3 -3
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export interface MonitorConfig {
|
|
|
2
2
|
webhook: {
|
|
3
3
|
url: string;
|
|
4
4
|
token: string;
|
|
5
|
+
/** Gateway auth token for /v1/responses API (may differ from hooks token) */
|
|
6
|
+
gatewayToken: string;
|
|
5
7
|
/** Use /hooks/agent instead of /hooks/wake for targeted delivery */
|
|
6
8
|
useAgent: boolean;
|
|
7
9
|
/** Discord channel ID to deliver notifications to */
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var DEFAULT_CONFIG = {
|
|
|
10
10
|
webhook: {
|
|
11
11
|
url: "",
|
|
12
12
|
token: "",
|
|
13
|
+
gatewayToken: "",
|
|
13
14
|
useAgent: true,
|
|
14
15
|
channel: "",
|
|
15
16
|
channelType: "discord"
|
|
@@ -45,6 +46,7 @@ function loadConfig() {
|
|
|
45
46
|
webhook: {
|
|
46
47
|
url: typeof webhook?.url === "string" ? webhook.url : DEFAULT_CONFIG.webhook.url,
|
|
47
48
|
token: typeof webhook?.token === "string" ? webhook.token : DEFAULT_CONFIG.webhook.token,
|
|
49
|
+
gatewayToken: typeof webhook?.gatewayToken === "string" ? webhook.gatewayToken : DEFAULT_CONFIG.webhook.gatewayToken,
|
|
48
50
|
useAgent: typeof webhook?.useAgent === "boolean" ? webhook.useAgent : DEFAULT_CONFIG.webhook.useAgent,
|
|
49
51
|
channel: typeof webhook?.channel === "string" ? webhook.channel : DEFAULT_CONFIG.webhook.channel,
|
|
50
52
|
channelType: typeof webhook?.channelType === "string" ? webhook.channelType : DEFAULT_CONFIG.webhook.channelType
|
|
@@ -397,12 +399,9 @@ function wlog(msg) {
|
|
|
397
399
|
`);
|
|
398
400
|
} catch {}
|
|
399
401
|
}
|
|
400
|
-
function deriveAgentUrl(wakeUrl) {
|
|
401
|
-
return wakeUrl.replace(/\/hooks\/wake\/?$/, "/hooks/agent");
|
|
402
|
-
}
|
|
403
402
|
function sendWebhook(config, text) {
|
|
404
403
|
const { webhook } = config;
|
|
405
|
-
wlog(`Sending
|
|
404
|
+
wlog(`Sending /hooks/wake to ${webhook.url}: ${text}`);
|
|
406
405
|
fetch(webhook.url, {
|
|
407
406
|
method: "POST",
|
|
408
407
|
headers: {
|
|
@@ -411,38 +410,12 @@ function sendWebhook(config, text) {
|
|
|
411
410
|
},
|
|
412
411
|
body: JSON.stringify({ text, mode: "now" })
|
|
413
412
|
}).then((resp) => {
|
|
414
|
-
wlog(
|
|
413
|
+
wlog(`/hooks/wake: status=${resp.status} ok=${resp.ok}`);
|
|
415
414
|
console.log("[monitor] wake sent:", text);
|
|
416
415
|
}).catch((error) => {
|
|
417
|
-
wlog(
|
|
416
|
+
wlog(`/hooks/wake ERROR: ${String(error)}`);
|
|
418
417
|
console.error("[monitor] wake error:", error);
|
|
419
418
|
});
|
|
420
|
-
if (webhook.useAgent && webhook.channel) {
|
|
421
|
-
const agentUrl = deriveAgentUrl(webhook.url);
|
|
422
|
-
const body = {
|
|
423
|
-
message: text,
|
|
424
|
-
name: "omoclaw",
|
|
425
|
-
deliver: true,
|
|
426
|
-
channel: webhook.channelType || "discord",
|
|
427
|
-
to: `channel:${webhook.channel}`,
|
|
428
|
-
wakeMode: "now"
|
|
429
|
-
};
|
|
430
|
-
wlog(`Sending AGENT to ${agentUrl}: ${JSON.stringify(body)}`);
|
|
431
|
-
fetch(agentUrl, {
|
|
432
|
-
method: "POST",
|
|
433
|
-
headers: {
|
|
434
|
-
Authorization: `Bearer ${webhook.token}`,
|
|
435
|
-
"Content-Type": "application/json"
|
|
436
|
-
},
|
|
437
|
-
body: JSON.stringify(body)
|
|
438
|
-
}).then((resp) => {
|
|
439
|
-
wlog(`Agent response: status=${resp.status} ok=${resp.ok}`);
|
|
440
|
-
console.log("[monitor] agent sent:", text);
|
|
441
|
-
}).catch((error) => {
|
|
442
|
-
wlog(`AGENT FETCH ERROR: ${String(error)}`);
|
|
443
|
-
console.error("[monitor] agent error:", error);
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
419
|
}
|
|
447
420
|
|
|
448
421
|
// src/index.ts
|
package/dist/webhook.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MonitorConfig } from "./config";
|
|
2
2
|
/**
|
|
3
|
-
* Send
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
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.
|
|
6
6
|
*/
|
|
7
7
|
export declare function sendWebhook(config: MonitorConfig, text: string): void;
|
package/package.json
CHANGED