openclaw-scheduler 0.2.4 → 0.2.5

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.
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  import { hostname } from 'os';
20
+ import { resolveCompletionDelivery } from './completion.mjs';
20
21
  import { sendMessage } from '../messages.js';
21
22
 
22
23
  const LOKI_URL = process.env.LOKI_PUSH_URL || '';
@@ -70,13 +71,23 @@ async function webhookPush(event, payload) {
70
71
  * Used for unregistered-label done signals where no watcher is waiting.
71
72
  *
72
73
  * @param {string} label - Dispatch label
73
- * @param {string} summary - One-line summary of what was done
74
+ * @param {string} summary - Legacy fallback summary
74
75
  * @param {string} deliverTo - Target chat/user ID (stored for reference)
75
76
  * @param {string} [deliveryChannel='telegram'] - Channel to deliver via (stored for reference)
77
+ * @param {object} [completion=null] - Structured completion payload
76
78
  */
77
- async function gatewayNotify(label, summary, deliverTo, deliveryChannel = 'telegram') {
79
+ async function gatewayNotify(label, summary, deliverTo, deliveryChannel = 'telegram', completion = null) {
78
80
  try {
79
- const body = `✅ [${label}] done -- ${summary}`;
81
+ const delivery = resolveCompletionDelivery({
82
+ completion,
83
+ fallbackSummary: summary,
84
+ });
85
+ const bodyText = delivery.deliveryText || null;
86
+ if (!bodyText) {
87
+ process.stderr.write(`[dispatch-hooks] completion delivery suppressed for ${label}: no meaningful structured summary\n`);
88
+ return;
89
+ }
90
+ const body = `✅ [${label}] done\n\n${bodyText}`;
80
91
  await sendMessage({
81
92
  from_agent: 'dispatch',
82
93
  to_agent: 'main',
@@ -130,7 +141,8 @@ export function onStarted(opts) {
130
141
  * Extended opts:
131
142
  * deliverTo {string} -- If set, send a completion notification via gateway
132
143
  * deliveryChannel {string} -- Channel for delivery (default: 'telegram')
133
- * summary {string} -- One-line summary to include in the notification
144
+ * summary {string} -- Legacy fallback summary for notification formatting
145
+ * completion {object} -- Structured completion payload
134
146
  */
135
147
  export async function onFinished(opts) {
136
148
  const tasks = [
@@ -150,7 +162,7 @@ export async function onFinished(opts) {
150
162
  if (opts.deliverTo) {
151
163
  const summary = opts.summary || opts.status || 'completed';
152
164
  tasks.push(
153
- gatewayNotify(opts.label, summary, opts.deliverTo, opts.deliveryChannel || 'telegram')
165
+ gatewayNotify(opts.label, summary, opts.deliverTo, opts.deliveryChannel || 'telegram', opts.completion || null)
154
166
  );
155
167
  }
156
168