omoclaw 2.0.0 → 2.2.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 CHANGED
@@ -399,56 +399,26 @@ 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);
404
+ const body = { text, mode: "now" };
408
405
  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
- });
406
+ body.sessionKey = `agent:main:discord:channel:${webhook.channel}`;
437
407
  }
438
- wlog(`Sending /hooks/wake to ${webhook.url}: ${text}`);
408
+ wlog(`Sending /hooks/wake to ${webhook.url} (session: ${body.sessionKey ?? "main"}): ${text}`);
439
409
  fetch(webhook.url, {
440
410
  method: "POST",
441
411
  headers: {
442
412
  Authorization: `Bearer ${webhook.token}`,
443
413
  "Content-Type": "application/json"
444
414
  },
445
- body: JSON.stringify({ text, mode: "now" })
415
+ body: JSON.stringify(body)
446
416
  }).then((resp) => {
447
417
  wlog(`/hooks/wake: status=${resp.status} ok=${resp.ok}`);
448
- console.log("[monitor] wake fallback sent:", text);
418
+ console.log("[monitor] wake sent:", text);
449
419
  }).catch((error) => {
450
- wlog(`/hooks/wake FETCH ERROR: ${String(error)}`);
451
- console.error("[monitor] wake fallback error:", error);
420
+ wlog(`/hooks/wake ERROR: ${String(error)}`);
421
+ console.error("[monitor] wake error:", error);
452
422
  });
453
423
  }
454
424
 
package/dist/webhook.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import type { MonitorConfig } from "./config";
2
2
  /**
3
- * Send notification to OpenClaw using /v1/responses with x-openclaw-session-key header.
4
- * This directly wakes the specific channel session where Miruri is active.
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 with session targeting.
4
+ * Uses patched /hooks/wake that accepts optional sessionKey parameter.
5
+ * If channel is configured, targets the specific Discord channel session.
6
+ * Fire-and-forget, no token cost, instant 200 response.
9
7
  */
10
8
  export declare function sendWebhook(config: MonitorConfig, text: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omoclaw",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "OpenCode session monitor plugin \u2014 native event-driven webhook notifications for session state changes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",