@dashclaw/cli 0.1.2 → 0.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/bin/dashclaw.js +20 -0
- package/package.json +1 -1
package/bin/dashclaw.js
CHANGED
|
@@ -158,6 +158,25 @@ async function cmdApprovals() {
|
|
|
158
158
|
|
|
159
159
|
await fetchPending();
|
|
160
160
|
|
|
161
|
+
// Open SSE stream for live push of new approval requests
|
|
162
|
+
let stream = null;
|
|
163
|
+
try {
|
|
164
|
+
stream = claw.events()
|
|
165
|
+
.on('guard.decision.created', (data) => {
|
|
166
|
+
if (data.decision !== 'require_approval') return;
|
|
167
|
+
const exists = items.some((it) => (it.action_id || it.id) === data.action_id);
|
|
168
|
+
if (exists) return;
|
|
169
|
+
items.push(data);
|
|
170
|
+
render();
|
|
171
|
+
})
|
|
172
|
+
.on('error', () => {
|
|
173
|
+
moveCursor(items.length + 6, 1);
|
|
174
|
+
process.stdout.write(dim(' SSE stream error — live push unavailable, use R to refresh') + '\n');
|
|
175
|
+
});
|
|
176
|
+
} catch (_) {
|
|
177
|
+
// SSE unavailable — inbox still works via manual refresh
|
|
178
|
+
}
|
|
179
|
+
|
|
161
180
|
// Set up raw mode for interactive input
|
|
162
181
|
if (!process.stdin.isTTY) {
|
|
163
182
|
console.error('Error: Interactive mode requires a TTY. Use dashclaw approve/deny for non-interactive use.');
|
|
@@ -171,6 +190,7 @@ async function cmdApprovals() {
|
|
|
171
190
|
|
|
172
191
|
// Ensure cleanup on exit
|
|
173
192
|
function cleanup() {
|
|
193
|
+
if (stream) stream.close();
|
|
174
194
|
showCursor();
|
|
175
195
|
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
176
196
|
process.stdout.write('\n');
|