send-to-paseo 2.3.0 → 2.4.1-beta.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "send-to-paseo",
3
3
  "type": "module",
4
- "version": "2.3.0",
4
+ "version": "2.4.1-beta.0",
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.
@@ -137,7 +138,7 @@ async function resolvePassword(): Promise<string | undefined> {
137
138
  }
138
139
 
139
140
  /** Optional companion RPCs always target this daemon, never a browser-selected host. */
140
- export async function callFollowUp(method: "follow.pr-owner" | "follow.browser-exchange", input: unknown): Promise<unknown> {
141
+ export async function callFollowUp(method: "follow.pr-owner" | "follow.pr-workspaces" | "follow.browser-exchange", input: unknown): Promise<unknown> {
141
142
  const load = typeof require === "function" ? require : createRequire(join(process.cwd(), "noop.cjs"));
142
143
  const { DaemonClient } = load(["@getpaseo", "client", "internal", "daemon-client"].join("/")) as {
143
144
  DaemonClient: new (options: Record<string, unknown>) => {
@@ -150,7 +151,7 @@ export async function callFollowUp(method: "follow.pr-owner" | "follow.browser-e
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,18 @@
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
+ /** Calls `method` on whichever Follow-up id answers. Any other failure (an RPC error, a timeout) is the answer. */
11
+ export async function invokeFollowUp(invoke: (pluginId: string, method: string, input: unknown) => Promise<unknown>, method: string, input: unknown): Promise<unknown> {
12
+ let last: unknown;
13
+ for (const id of FOLLOW_UP_PLUGIN_IDS) {
14
+ try { return await invoke(id, method, input); }
15
+ catch (error) { if (!absent(error)) throw error; last = error; }
16
+ }
17
+ throw last;
18
+ }
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { callFollowUp } from "./daemon";
3
3
  import type { ListedAgent } from "./main-agent";
4
+ import { buildAgentDeepLink, buildAgentWebLink, type FollowUpView } from "../shared/contracts";
4
5
 
5
6
  const ownerReply = z.object({ owner: z.object({ workspaceId: z.string().min(1).max(200), agentId: z.string().min(1).max(200) }).nullable() });
6
7
  export type PrOwner = NonNullable<z.infer<typeof ownerReply>["owner"]>;
@@ -13,3 +14,28 @@ export function registeredAgent(agents: readonly ListedAgent[], owner: PrOwner |
13
14
  if (!owner || owner.workspaceId !== workspaceId) return null;
14
15
  return agents.find(a => a.id === owner.agentId && a.workspaceId === workspaceId && a.archivedAt == null) ?? null;
15
16
  }
17
+
18
+ const text = (max: number) => z.string().max(max);
19
+ const workspacesReply = z.object({
20
+ tracked: z.boolean(), more: z.number().int().nonnegative().max(10_000),
21
+ workspaces: z.array(z.object({ workspaceId: text(200).min(1), agentId: text(200).min(1), title: text(200), agentStatus: text(40), group: text(20), state: text(200) })).max(3),
22
+ });
23
+ export type PrWorkspaces = Omit<z.infer<typeof workspacesReply>, "tracked">;
24
+ /**
25
+ * Follow-up's owners of a PR, or null when there is nothing to show: Follow-up absent, older than this RPC,
26
+ * broken, or the repository outside the scope it tracks (and therefore advertises to the browser).
27
+ */
28
+ export async function lookupPrWorkspaces(owner: string, repo: string, number: number): Promise<PrWorkspaces | null> {
29
+ try {
30
+ const reply = workspacesReply.parse(await callFollowUp("follow.pr-workspaces", { repo: `${owner}/${repo}`, number }));
31
+ return reply.tracked ? { workspaces: reply.workspaces, more: reply.more } : null;
32
+ } catch { return null; }
33
+ }
34
+ /** Adds this machine's open links and Paseo's own workspace names. Without a server id no link can be built, so nothing is shown. */
35
+ export function followUpView(found: PrWorkspaces | null, serverId: string | null, names: ReadonlyMap<string, string>): FollowUpView | undefined {
36
+ if (!found || !serverId) return undefined;
37
+ return {
38
+ more: found.more,
39
+ workspaces: found.workspaces.map(w => ({ ...w, title: names.get(w.workspaceId) || w.title || w.workspaceId, deepLink: buildAgentDeepLink({ serverId, agentId: w.agentId }), webUrl: buildAgentWebLink({ serverId, agentId: w.agentId }) })),
40
+ };
41
+ }
package/server/resolve.ts CHANGED
@@ -13,8 +13,8 @@ import {
13
13
  type ResolveResponse,
14
14
  type StackPrState,
15
15
  } from "../shared/contracts";
16
- import { withPaseo } from "./daemon";
17
- import { lookupPrOwner, registeredAgent, type PrOwner } from "./follow-up";
16
+ import { requireServerId, withPaseo } from "./daemon";
17
+ import { followUpView, lookupPrOwner, lookupPrWorkspaces, registeredAgent, type PrOwner } from "./follow-up";
18
18
  import {
19
19
  ANCESTRY_STACK_DISTANCE,
20
20
  UNKNOWN_STACK_DISTANCE,
@@ -979,6 +979,10 @@ export async function handleResolve(request: ResolveRequest): Promise<ResolveRes
979
979
  // starts this work before the popover opens).
980
980
  const workspacesPromise = paseo.workspaces.list();
981
981
  const ownerPromise = lookupPrOwner(ref.owner, ref.repo, ref.number);
982
+ // Asked for only by an extension with Follow-up browser access on; absent or failing is "no section".
983
+ const followUpPromise = request.followUp === true
984
+ ? Promise.all([lookupPrWorkspaces(ref.owner, ref.repo, ref.number), requireServerId().catch(() => null)])
985
+ : Promise.resolve([null, null] as const);
982
986
  const projectPromise = Promise.all([workspacesPromise, ownerPromise]).then(([all, owner]) =>
983
987
  resolveProject(paseo, ref, all.entries.find(w => w.id === owner?.workspaceId && w.archivingAt === null)?.projectId),
984
988
  );
@@ -1036,7 +1040,10 @@ export async function handleResolve(request: ResolveRequest): Promise<ResolveRes
1036
1040
  effectiveProvider === undefined
1037
1041
  ? undefined
1038
1042
  : await resolveDefaultMode(paseo, effectiveProvider, { profile, catalog });
1043
+ const [ownersFound, serverId] = await followUpPromise;
1044
+ const followUp = followUpView(ownersFound, serverId, new Map(allWorkspaces.entries.map(w => [w.id, typeof w.name === "string" ? w.name : ""])));
1039
1045
  return {
1046
+ ...(followUp ? { followUp } : {}),
1040
1047
  pr,
1041
1048
  project,
1042
1049
  candidates,
@@ -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.3.0";
12
+ export const PLUGIN_VERSION = "2.4.1-beta.0";
13
13
  /** Bumped only for an incompatible bridge API; the paths stay `/v1`. */
14
14
  export const CONTRACT_VERSION = 1;
15
15
 
@@ -110,6 +110,12 @@ export type PrRef = z.infer<typeof PrRefSchema>;
110
110
  export const ResolveRequestSchema = PrRefSchema.extend({
111
111
  /** Sibling PRs in the Graphite stack, excluding this one. Best-effort. */
112
112
  stackPrNumbers: z.array(z.number().int().positive().max(10_000_000)).max(64).optional(),
113
+ /**
114
+ * Additive. Ask for the Follow-up view of this PR (`followUp` on the answer).
115
+ * The extension sets it only while "Use Graphite with Follow Up" is on, so
116
+ * turning that off stops the lookup instead of hiding its result.
117
+ */
118
+ followUp: z.boolean().optional(),
113
119
  });
114
120
  export type ResolveRequest = z.infer<typeof ResolveRequestSchema>;
115
121
 
@@ -352,6 +358,39 @@ export interface LocalResolveResponse {
352
358
  * Additive: absent means the older `new` behavior.
353
359
  */
354
360
  agentDispatch?: AgentDispatch;
361
+ /**
362
+ * Additive. The Paseo workspaces Follow-up says own this PR, on THIS machine.
363
+ * Present only when the request asked for it, Follow-up is installed and
364
+ * answers, and the repository is one Follow-up tracks (the same scope it
365
+ * advertises to the browser). Absent otherwise; never an error.
366
+ */
367
+ followUp?: FollowUpView;
368
+ }
369
+
370
+ /** One workspace that owns the PR, as the popover shows it. Titles, ids, status and one line: nothing else. */
371
+ export interface FollowUpWorkspace {
372
+ workspaceId: string;
373
+ /** The workspace's main agent: the one the open links land on. */
374
+ agentId: string;
375
+ /** As Paseo shows the workspace, else Follow-up's own title. */
376
+ title: string;
377
+ /** Paseo lifecycle status of the main agent (`running`, `idle`, `error`, ...) or `permission`. */
378
+ agentStatus: string;
379
+ /** Follow-up's Home group: needs | fixing | running | waiting | later | quiet. */
380
+ group: string;
381
+ /** Follow-up's one line, e.g. "Needs you · Merge ready". */
382
+ state: string;
383
+ /** Opens the main agent in the Paseo desktop app. */
384
+ deepLink: string;
385
+ /** Opens the same agent in the Paseo web app. */
386
+ webUrl: string;
387
+ }
388
+
389
+ export interface FollowUpView {
390
+ /** Most urgent first, at most three. Empty means Follow-up tracks the repository and no workspace owns this PR. */
391
+ workspaces: FollowUpWorkspace[];
392
+ /** How many more owners were left out. */
393
+ more: number;
355
394
  }
356
395
 
357
396
  /** One Paseo machine reached through the primary machine's bridge. */
@@ -686,6 +725,19 @@ export function buildAgentDeepLink(target: { serverId: string; agentId: string }
686
725
  return `paseo://h/${encodeURIComponent(serverId)}/agent/${encodeURIComponent(agentId)}`;
687
726
  }
688
727
 
728
+ /**
729
+ * The Paseo web app's link for the same agent. The web app's
730
+ * `/h/<serverId>/agent/<agentId>` route (Paseo 0.15.2,
731
+ * `packages/app/src/app/h/[serverId]/agent/[agentId].tsx`) looks the agent's
732
+ * workspace up and redirects there, exactly as the desktop app does for the
733
+ * `paseo://` link, so both land in the workspace with its main agent open.
734
+ * It opens only where that browser already has this server paired.
735
+ */
736
+ export const PASEO_WEB_APP = "https://app.paseo.sh";
737
+ export function buildAgentWebLink(target: { serverId: string; agentId: string }): string {
738
+ return `${PASEO_WEB_APP}${buildAgentDeepLink(target).slice("paseo:/".length)}`;
739
+ }
740
+
689
741
  /** `github:acmegizmos/gizmo-poc#942`, the value of the `send-to-paseo/pr` label. */
690
742
  export function prLabelValue(ref: PrRef): string {
691
743
  return `${ref.forge}:${ref.owner}/${ref.repo}#${ref.number}`;