patchcord 0.5.7 → 0.5.9
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/.claude-plugin/plugin.json +1 -1
- package/bin/patchcord.mjs +20 -0
- package/package.json +1 -1
- package/scripts/check-inbox.sh +2 -0
- package/scripts/statusline.sh +2 -0
- package/scripts/subscribe.mjs +8 -2
package/bin/patchcord.mjs
CHANGED
|
@@ -570,6 +570,26 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd === "--token" || cmd ===
|
|
|
570
570
|
} // end connect flow
|
|
571
571
|
} // end if (!token)
|
|
572
572
|
|
|
573
|
+
// Tell the server where this agent is installed on disk.
|
|
574
|
+
// Universal: works for every client (Claude Code, Codex, Cursor, Gemini,
|
|
575
|
+
// Windsurf, etc.) because the installer runs once per install regardless
|
|
576
|
+
// of which tool is being wired up. Re-running on existing setups also
|
|
577
|
+
// fires this, which is how we backfill install_path for users who
|
|
578
|
+
// installed before the column existed.
|
|
579
|
+
// Best-effort: a network failure here doesn't block the install.
|
|
580
|
+
if (token) {
|
|
581
|
+
const pathPayload = JSON.stringify({ install_path: cwd });
|
|
582
|
+
// Single quotes in the payload could break shell escaping; encode them.
|
|
583
|
+
const safePayload = pathPayload.replace(/'/g, `'\\''`);
|
|
584
|
+
run(
|
|
585
|
+
`curl -sf -X POST --max-time 5 ` +
|
|
586
|
+
`-H "Authorization: Bearer ${token}" ` +
|
|
587
|
+
`-H "Content-Type: application/json" ` +
|
|
588
|
+
`-d '${safePayload}' ` +
|
|
589
|
+
`"${serverUrl}/api/agent/install-path" >/dev/null 2>&1 || true`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
573
593
|
const isCodex = choice === "2";
|
|
574
594
|
const isCursor = choice === "3";
|
|
575
595
|
const isWindsurf = choice === "4";
|
package/package.json
CHANGED
package/scripts/check-inbox.sh
CHANGED
|
@@ -55,9 +55,11 @@ fi
|
|
|
55
55
|
|
|
56
56
|
# Check inbox — one lightweight HTTP call
|
|
57
57
|
MACHINE_NAME=$(hostname -s 2>/dev/null || echo "unknown")
|
|
58
|
+
INSTALL_PATH=$(dirname "$MCP_JSON")
|
|
58
59
|
HTTP_CODE=$(curl -s -o /tmp/patchcord_inbox.json -w "%{http_code}" --max-time 5 \
|
|
59
60
|
-H "Authorization: Bearer ${TOKEN}" \
|
|
60
61
|
-H "x-patchcord-machine: ${MACHINE_NAME}" \
|
|
62
|
+
-H "x-patchcord-install-path: ${INSTALL_PATH}" \
|
|
61
63
|
"${URL}/api/inbox?status=pending&limit=5&count_only=1" 2>/dev/null || echo "000")
|
|
62
64
|
|
|
63
65
|
if [ "$HTTP_CODE" = "401" ] || [ "$HTTP_CODE" = "403" ]; then
|
package/scripts/statusline.sh
CHANGED
|
@@ -74,8 +74,10 @@ if [ -n "$pc_url" ] && [ -n "$pc_token" ]; then
|
|
|
74
74
|
fi
|
|
75
75
|
|
|
76
76
|
if $needs_refresh; then
|
|
77
|
+
install_path=$(dirname "$mcp_json")
|
|
77
78
|
http_code=$(curl -s -o /tmp/claude/patchcord-sl-resp.json -w "%{http_code}" --max-time 5 \
|
|
78
79
|
-H "Authorization: Bearer $pc_token" \
|
|
80
|
+
-H "x-patchcord-install-path: ${install_path}" \
|
|
79
81
|
"${pc_url}/api/inbox?status=pending&limit=50" 2>/dev/null || echo "000")
|
|
80
82
|
if [ "$http_code" = "401" ] || [ "$http_code" = "403" ]; then
|
|
81
83
|
pc_data='{"_auth_error":true}'
|
package/scripts/subscribe.mjs
CHANGED
|
@@ -81,7 +81,10 @@ function httpJson(urlStr, { method = "GET", headers = {}, body = null } = {}) {
|
|
|
81
81
|
|
|
82
82
|
async function fetchTicket(baseUrl, token) {
|
|
83
83
|
const res = await httpJson(`${baseUrl}/api/realtime/ticket`, {
|
|
84
|
-
headers: {
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: `Bearer ${token}`,
|
|
86
|
+
"x-patchcord-install-path": process.cwd(),
|
|
87
|
+
},
|
|
85
88
|
});
|
|
86
89
|
if (res.status === 401 || res.status === 403) {
|
|
87
90
|
die(`ticket: token rejected (HTTP ${res.status}) — check .mcp.json`);
|
|
@@ -109,7 +112,10 @@ async function fetchTicket(baseUrl, token) {
|
|
|
109
112
|
// Monitor wakes the agent the same way a real arrival does.
|
|
110
113
|
async function drainQueueOnce(baseUrl, token) {
|
|
111
114
|
const res = await httpJson(`${baseUrl}/api/inbox?count_only=1&limit=100`, {
|
|
112
|
-
headers: {
|
|
115
|
+
headers: {
|
|
116
|
+
Authorization: `Bearer ${token}`,
|
|
117
|
+
"x-patchcord-install-path": process.cwd(),
|
|
118
|
+
},
|
|
113
119
|
});
|
|
114
120
|
if (res.status !== 200) {
|
|
115
121
|
throw new Error(`inbox HTTP ${res.status}`);
|