patchcord 0.5.125 → 0.5.127

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "patchcord",
3
3
  "description": "Cross-machine agent messaging. Messages from other agents land in the inbox and wake the agent to reply.",
4
- "version": "0.5.125",
4
+ "version": "0.5.127",
5
5
  "author": {
6
6
  "name": "ppravdin"
7
7
  },
package/bin/patchcord.mjs CHANGED
@@ -934,11 +934,26 @@ if (cmd === "login" || cmd === "orchestrator" || cmd === "teamlead" || cmd === "
934
934
  const accountCall = async (method, path, body) => {
935
935
  let m = await requireAuth();
936
936
  let r = await _httpJSON(method, `${m.baseUrl}${path}`, m.token, body);
937
- if (r.status === "401" || r.status === "403") {
938
- // Stale/invalid account token. Forget it and fail fast do NOT auto-relogin
939
- // (would hang headless, see requireAuth). The user re-runs `patchcord login`.
940
- forgetAuth();
941
- console.error(`patchcord account token rejected (HTTP ${r.status}). Run \`patchcord login\` again. Cannot continue.`);
937
+ // NEVER delete the stored credential on a request-level failure. The account
938
+ // token (pcm-) does not expire, and a 401/403 is almost never proof it is bad:
939
+ // - 401 can be transient (server restart / DB blip surfaces as a false
940
+ // "invalid main token"). Deleting it would strand a headless agent that
941
+ // cannot open a browser login.
942
+ // - 403 means THIS action is forbidden (namespace/role) — it says nothing
943
+ // about credential validity.
944
+ // Surface the error and stop. If the token is genuinely revoked, the user
945
+ // runs `patchcord login` — an explicit, human action, never automatic.
946
+ if (r.status === "401") {
947
+ console.error(`patchcord: account request returned HTTP 401. Your login was NOT deleted. If this keeps happening, run \`patchcord login\`.`);
948
+ process.exit(1);
949
+ }
950
+ if (r.status === "403") {
951
+ const reason = (r.json && (r.json.error || r.json.message)) || (r.body || "").slice(0, 200) || "forbidden";
952
+ console.error(`patchcord: request forbidden (HTTP 403): ${reason}`);
953
+ process.exit(1);
954
+ }
955
+ if (r.status === "503") {
956
+ console.error(`patchcord: server temporarily unavailable (HTTP 503). Retry in a moment.`);
942
957
  process.exit(1);
943
958
  }
944
959
  return { ...r, m };
@@ -1854,6 +1869,22 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd?.startsWith("--")) {
1854
1869
  // legacy prompt) in one pass, preserving all other tables.
1855
1870
  kimiConfig = removeHookBlocks(kimiConfig, isPatchcordHook).replace(/\n{3,}/g, "\n\n").trim();
1856
1871
 
1872
+ // Self-heal config a PRIOR patchcord version corrupted. The old
1873
+ // split("[[hooks]]")+filter deleted every table that trailed a patchcord
1874
+ // hook block — including kimi's own [providers."managed:kimi-code"] and
1875
+ // [models."kimi-code/kimi-for-coding"] — leaving `default_model` dangling
1876
+ // and the CLI dead with "Model ... is not configured". Restore the
1877
+ // canonical managed block. Guarded three ways: only when default_model
1878
+ // names exactly that managed model AND neither the model nor the provider
1879
+ // section is present — so a user's own provider/model config is never
1880
+ // touched, and this is a no-op on healthy hosts.
1881
+ if (/^\s*default_model\s*=\s*"kimi-code\/kimi-for-coding"/m.test(kimiConfig)
1882
+ && !/^\s*\[models\."kimi-code\/kimi-for-coding"\]/m.test(kimiConfig)
1883
+ && !/^\s*\[providers\."managed:kimi-code"\]/m.test(kimiConfig)) {
1884
+ kimiConfig = kimiConfig.trimEnd() + `\n\n[providers."managed:kimi-code"]\ntype = "kimi"\napi_key = ""\nbase_url = "https://api.kimi.com/coding/v1"\n\n[providers."managed:kimi-code".oauth]\nstorage = "file"\nkey = "oauth/kimi-code"\n\n[models."kimi-code/kimi-for-coding"]\nprovider = "managed:kimi-code"\nmodel = "kimi-for-coding"\nmax_context_size = 262144\ncapabilities = [ "thinking", "always_thinking", "image_in", "video_in", "tool_use" ]\ndisplay_name = "K2.7 Code"\n`;
1885
+ globalChanges.push("Repaired kimi-code model/provider block deleted by an earlier patchcord version");
1886
+ }
1887
+
1857
1888
  // Append new hooks
1858
1889
  kimiConfig = kimiConfig.trimEnd() + `\n\n[[hooks]]\nevent = "SessionStart"\ncommand = "${kimiSessionDest}"\ntimeout = 10\n\n[[hooks]]\nevent = "Stop"\ncommand = "${kimiHookDest}"\ntimeout = 10\n`;
1859
1890
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.5.125",
3
+ "version": "0.5.127",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "scripts": {
6
6
  "version": "node scripts/sync-plugin-version.mjs && git add .claude-plugin/plugin.json"