@inquiryon/openclaw-amp-governance 1.0.5 → 1.0.6
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/index.js +4 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -122,10 +122,12 @@ async function ampLog(instanceId, message, level = 'INFO') {
|
|
|
122
122
|
* to finish. Uses the openclaw CLI so we don't need to reverse-engineer the
|
|
123
123
|
* gateway REST API. Fire-and-forget — errors are logged but never thrown.
|
|
124
124
|
*/
|
|
125
|
+
const OPENCLAW_BIN = `${process.env.HOME}/.npm-global/bin/openclaw`;
|
|
126
|
+
|
|
125
127
|
function notifyUser(sender, message) {
|
|
126
128
|
if (!sender?.from || !sender?.channelId) return;
|
|
127
129
|
const safeMsg = message.replace(/"/g, '\\"');
|
|
128
|
-
const cmd =
|
|
130
|
+
const cmd = `${OPENCLAW_BIN} message send --channel ${sender.channelId} --target "${sender.from}" --message "${safeMsg}"`;
|
|
129
131
|
console.log(`[AMP Governance] Sending notification to ${sender.from}: ${message}`);
|
|
130
132
|
exec(cmd, (err) => {
|
|
131
133
|
if (err) console.warn('[AMP Governance] notifyUser failed:', err.message);
|
|
@@ -434,17 +436,14 @@ export default {
|
|
|
434
436
|
await ampLog(instanceId, message, event.success === false ? 'ERROR' : 'INFO');
|
|
435
437
|
});
|
|
436
438
|
|
|
437
|
-
// ── OUTBOUND MESSAGE LOGGING
|
|
439
|
+
// ── OUTBOUND MESSAGE LOGGING ──────────────────────────────────────────────
|
|
438
440
|
api.on('message_sending', async (event) => {
|
|
439
441
|
const instanceId = _instanceId || readSession()?.instanceId;
|
|
440
442
|
const msgText = event.content || event.text || event.message || JSON.stringify(event);
|
|
441
443
|
const preview = msgText.substring(0, 100);
|
|
442
|
-
console.log(`[AMP Governance] message_sending fired: ${preview}`);
|
|
443
444
|
if (instanceId) {
|
|
444
445
|
await ampLog(instanceId, `Agent reply: ${preview}`);
|
|
445
446
|
}
|
|
446
|
-
// Prefix every outbound message so the user can distinguish agent replies
|
|
447
|
-
return { content: `[OpenClaw]\n${msgText}` };
|
|
448
447
|
});
|
|
449
448
|
},
|
|
450
449
|
};
|