patchcord 0.5.76 → 0.5.77
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/package.json
CHANGED
|
@@ -8,11 +8,7 @@ description: >
|
|
|
8
8
|
|
|
9
9
|
# patchcord:subscribe
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Start the listener
|
|
14
|
-
|
|
15
|
-
Run `patchcord subscribe` as a **background Shell task** with a short poll interval and long timeout:
|
|
11
|
+
Run this exact background Shell task:
|
|
16
12
|
|
|
17
13
|
```
|
|
18
14
|
Shell:
|
|
@@ -22,44 +18,7 @@ Shell:
|
|
|
22
18
|
timeout: 86400
|
|
23
19
|
```
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## How it works
|
|
30
|
-
|
|
31
|
-
- Walks up from cwd looking for `.kimi/mcp.json`, falls back to global
|
|
32
|
-
- Polls `/api/inbox?status=pending` every N seconds
|
|
33
|
-
- When messages found: writes `~/.kimi/patchcord-subscribe-notify.txt` and **exits 0**
|
|
34
|
-
- Kimi's `BackgroundTaskManager` detects the terminal state
|
|
35
|
-
- If `background_autotrigger_armed = true`, Kimi auto-starts a new turn
|
|
36
|
-
- **One-shot** — must be re-launched after each detection
|
|
37
|
-
- **Pidfile guard** — prevents multiple concurrent instances
|
|
38
|
-
|
|
39
|
-
## Re-arming the background poll
|
|
40
|
-
|
|
41
|
-
**Critical:** the background poll is **one-shot** — it exits on first detection and must be re-launched. Every time you read messages from `inbox()` or `wait_for_message()`, **re-arm the listener before doing any work**:
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
Shell:
|
|
45
|
-
command: patchcord subscribe 5
|
|
46
|
-
run_in_background: true
|
|
47
|
-
description: Patchcord inbox polling
|
|
48
|
-
timeout: 86400
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
This ensures the next incoming message will also wake you up.
|
|
52
|
-
|
|
53
|
-
## Stop hook (secondary)
|
|
54
|
-
|
|
55
|
-
Kimi also has a Stop hook (`~/.kimi/patchcord-stop-hook.sh`) that checks the inbox at the end of each turn. If messages are pending, it triggers a new turn with the notification. This is a fallback — it only fires when a turn is already ending. The background poll is the primary proactive mechanism.
|
|
56
|
-
|
|
57
|
-
## Limitations
|
|
58
|
-
|
|
59
|
-
### Auto-trigger requires "arming"
|
|
60
|
-
|
|
61
|
-
Kimi only auto-triggers on background task completion after the user has sent at least one message in the session (`background_autotrigger_armed = true`). A fresh idle session with zero user turns will NOT auto-trigger.
|
|
62
|
-
|
|
63
|
-
### Message consumption by other clients
|
|
64
|
-
|
|
65
|
-
If the same Patchcord identity is also used by Claude Code or Codex (with `patchcord subscribe` running), those clients will consume messages via their WebSocket listeners. The Kimi background poll competes with them. For reliable Kimi-only usage, use a dedicated agent identity.
|
|
21
|
+
- `command: patchcord subscribe 5` — polls inbox every **5 seconds**
|
|
22
|
+
- `timeout: 86400` — runs for **24 hours** (maximum). Always 86400, never anything else.
|
|
23
|
+
- One-shot: exits when messages found, triggers Kimi auto-run
|
|
24
|
+
- Must re-arm after every `inbox()` or `wait_for_message()` call by running the exact same command again
|
|
@@ -3,13 +3,12 @@ name: patchcord:wait
|
|
|
3
3
|
description: >
|
|
4
4
|
Block this turn for up to 5 minutes waiting for one incoming Patchcord
|
|
5
5
|
message via the wait_for_message MCP tool. Single blocking call, no
|
|
6
|
-
background process.
|
|
7
|
-
or asks you to wait for a patchcord message.
|
|
6
|
+
background process.
|
|
8
7
|
---
|
|
9
8
|
|
|
10
9
|
# patchcord:wait
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Use `wait_for_message()` only. Do NOT spawn a background listener.
|
|
13
12
|
|
|
14
13
|
Call `wait_for_message()` to block until a message arrives (up to 5 minutes).
|
|
15
14
|
|
package/scripts/subscribe.mjs
CHANGED
|
@@ -453,7 +453,7 @@ function runOnce(ticket, baseUrl, token, refreshTicket) {
|
|
|
453
453
|
// Successful subscribe ack — log once for confirmation, then quiet.
|
|
454
454
|
// Replace Supabase's "Subscribed to PostgreSQL" with a user-facing label.
|
|
455
455
|
if (status === "ok" && message) {
|
|
456
|
-
const displayMsg = message.replace(/
|
|
456
|
+
const displayMsg = message.replace(/postgresql/gi, "Patchcord").replace(/postgres/gi, "Patchcord");
|
|
457
457
|
logErr(`subscribe: system ok on ${frame.topic}: ${displayMsg}`);
|
|
458
458
|
}
|
|
459
459
|
return;
|