@1presence/bridge 0.35.0 → 0.36.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/claude.js CHANGED
@@ -6,6 +6,7 @@ exports.setDebug = setDebug;
6
6
  exports.paint = paint;
7
7
  exports.spawnClaude = spawnClaude;
8
8
  exports.killAll = killAll;
9
+ exports.cancelConversation = cancelConversation;
9
10
  const child_process_1 = require("child_process");
10
11
  const fs_1 = require("fs");
11
12
  const os_1 = require("os");
@@ -581,3 +582,26 @@ function killAll() {
581
582
  }
582
583
  active.clear();
583
584
  }
585
+ /**
586
+ * Stop one in-flight turn (the Stop button, relayed by the gateway as a
587
+ * `cancel` frame). Kills the running Claude Code process for this conversation
588
+ * and cancels any scheduled retry, so no further stream events are produced.
589
+ * Mirrors the supersede path in spawnClaude. Returns true if something was
590
+ * actually stopped. Mechanical only — no product logic lives here.
591
+ */
592
+ function cancelConversation(conversationId) {
593
+ let stopped = false;
594
+ const proc = active.get(conversationId);
595
+ if (proc) {
596
+ proc.kill('SIGTERM');
597
+ active.delete(conversationId);
598
+ stopped = true;
599
+ }
600
+ const pending = pendingRetries.get(conversationId);
601
+ if (pending) {
602
+ clearTimeout(pending);
603
+ pendingRetries.delete(conversationId);
604
+ stopped = true;
605
+ }
606
+ return stopped;
607
+ }
package/dist/index.js CHANGED
@@ -386,6 +386,15 @@ function connect(auth, retryDelay = 1000) {
386
386
  }
387
387
  return;
388
388
  }
389
+ // Stop button: the gateway relays a cancel when the user abandons the turn
390
+ // (PWA→gateway connection dropped). Kill the local Claude Code process for
391
+ // this conversation so it stops generating instead of running to the end.
392
+ if (msg.type === 'cancel' && msg.conversationId) {
393
+ const cancelled = (0, claude_1.cancelConversation)(msg.conversationId);
394
+ if (cancelled)
395
+ console.log(`[bridge] ✕ stopped conversation ${msg.conversationId}`);
396
+ return;
397
+ }
389
398
  if (msg.type !== 'message' || !msg.conversationId || !msg.text)
390
399
  return;
391
400
  const { conversationId, text, sessionId, history, vaultFileOpen, clientCapabilities, syncedFolders, agentSlug } = msg;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1presence/bridge",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "Run 1Presence on your Mac and use your Claude.ai Pro subscription from any device",
5
5
  "bin": {
6
6
  "1presence-bridge": "dist/index.js"