send-to-paseo 2.4.0 → 2.4.1-beta.1

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "send-to-paseo",
3
3
  "type": "module",
4
- "version": "2.4.0",
4
+ "version": "2.4.1-beta.1",
5
5
  "license": "MIT",
6
6
  "description": "Local HTTP bridge that dispatches PR work to the right Paseo workspace and agent.",
7
7
  "repository": {
package/server/daemon.ts CHANGED
@@ -6,6 +6,7 @@ import type { PluginHandlerContext } from "@getpaseo/plugin/server";
6
6
  import { BridgeError } from "../shared/contracts";
7
7
  import { resolveDaemonPassword } from "./daemon-password";
8
8
  import { settings } from "./settings";
9
+ import { invokeFollowUp } from "./follow-up-id";
9
10
 
10
11
  /**
11
12
  * Short-lived Paseo SDK connections for the HTTP bridge.
@@ -150,7 +151,7 @@ export async function callFollowUp(method: "follow.pr-owner" | "follow.pr-worksp
150
151
  try {
151
152
  await client.connect();
152
153
  return await Promise.race([
153
- client.invokePluginRpc("follow-through", method, input),
154
+ invokeFollowUp((plugin, m, i) => client.invokePluginRpc(plugin, m, i), method, input),
154
155
  new Promise<never>((_, reject) => { timer = setTimeout(() => reject(new Error("Optional Follow Up request timed out.")), 2_000); timer.unref?.(); }),
155
156
  ]);
156
157
  } finally { if (timer) clearTimeout(timer); await client.close().catch(() => undefined); }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Follow-up's plugin id. Follow-up 2.0 runs as `follow-up`; 1.x (and a 2.0 that hasn't finished moving to its new id)
3
+ * still runs as `follow-through`. Callers try the new id first and fall back only when that plugin isn't there.
4
+ */
5
+ export const FOLLOW_UP_PLUGIN_IDS = ["follow-up", "follow-through"] as const;
6
+
7
+ /** Paseo's answer when no plugin runs under the id (0.15: "Plugin is not available: <id>"). */
8
+ const absent = (error: unknown) => /plugin (?:is )?not (?:available|installed|configured)|unknown plugin/i.test(error instanceof Error ? error.message : String(error));
9
+
10
+ /**
11
+ * The browser bridge polls every few seconds, and the daemon logs every absent-plugin answer at error level, so an id
12
+ * is never re-probed per call. The id that answered goes first next time and is only abandoned when it comes back
13
+ * absent (2.0 moved to a new id mid-process, or a rollback). When neither id is installed, that fact is cached for
14
+ * `ABSENT_TTL_MS` so a host without Follow-up isn't probed on every poll either.
15
+ */
16
+ const ABSENT_TTL_MS = 30_000;
17
+ let remembered: (typeof FOLLOW_UP_PLUGIN_IDS)[number] | undefined;
18
+ let neitherUntil = 0;
19
+ let neitherError: unknown;
20
+
21
+ /** Calls `method` on whichever Follow-up id answers. Any other failure (an RPC error, a timeout) is the answer. */
22
+ export async function invokeFollowUp(invoke: (pluginId: string, method: string, input: unknown) => Promise<unknown>, method: string, input: unknown, now: () => number = Date.now): Promise<unknown> {
23
+ if (!remembered && now() < neitherUntil) throw neitherError;
24
+ const order = remembered ? [remembered, ...FOLLOW_UP_PLUGIN_IDS.filter(id => id !== remembered)] : FOLLOW_UP_PLUGIN_IDS;
25
+ let last: unknown;
26
+ for (const id of order) {
27
+ try { const answer = await invoke(id, method, input); remembered = id; return answer; }
28
+ catch (error) { if (!absent(error)) throw error; last = error; }
29
+ }
30
+ remembered = undefined;
31
+ neitherError = last; neitherUntil = now() + ABSENT_TTL_MS;
32
+ throw last;
33
+ }
@@ -9,7 +9,7 @@ import { z } from "zod";
9
9
 
10
10
  /** Advertised in `GET /v1/ping`. Keep in step with `package.json`. */
11
11
  export const PLUGIN_NAME = "send-to-paseo";
12
- export const PLUGIN_VERSION = "2.4.0";
12
+ export const PLUGIN_VERSION = "2.4.1-beta.1";
13
13
  /** Bumped only for an incompatible bridge API; the paths stay `/v1`. */
14
14
  export const CONTRACT_VERSION = 1;
15
15