send-to-paseo 1.4.2 → 2.1.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/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # send-to-paseo
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/send-to-paseo?style=for-the-badge&color=cb3837)](https://www.npmjs.com/package/send-to-paseo)
4
+ [![npm downloads](https://img.shields.io/npm/dm/send-to-paseo?style=for-the-badge&color=cb3837)](https://www.npmjs.com/package/send-to-paseo)
5
+ [![Paseo](https://img.shields.io/badge/Paseo-%E2%89%A5%200.14.0-8A63D2?style=for-the-badge)](https://paseo.sh)
6
+ [![License](https://img.shields.io/github/license/tomgrin10/send-to-paseo?style=for-the-badge&color=2563eb)](LICENSE)
7
+
3
8
  A Paseo plugin that runs a small local HTTP bridge so a browser extension can
4
9
  send work from a pull request to the right workspace and agent — creating a
5
10
  worktree checked out to the PR if none exists.
@@ -18,6 +23,90 @@ Paseo through the supported SDK.
18
23
 
19
24
  ---
20
25
 
26
+ ## Install
27
+
28
+ Plugins are trusted, unsandboxed code: this one runs an HTTP server that can
29
+ start agents which execute arbitrary code on the daemon machine. Read the source
30
+ before installing it.
31
+
32
+ One command from npm. No clone or build step:
33
+
34
+ ```sh
35
+ paseo plugin install send-to-paseo
36
+ paseo plugin ls # expect: send-to-paseo running yes
37
+ paseo plugin logs send-to-paseo
38
+ ```
39
+
40
+ `pluginsEnabled` must already be `true` in the daemon's `config.json`.
41
+
42
+ There is nothing to install because the plugin imports nothing at runtime that
43
+ the Paseo host does not already provide — see
44
+ [No runtime dependencies, ever](#no-runtime-dependencies-ever). To update an
45
+ installed plugin, run `paseo plugin update send-to-paseo`; for a checkout,
46
+ run `paseo plugin reload send-to-paseo`.
47
+
48
+ ### From a checkout (contributors)
49
+
50
+ Installing from a directory is the loop to use while editing, because
51
+ `paseo plugin reload` picks up changes in place:
52
+
53
+ ```sh
54
+ git clone https://github.com/tomgrin10/send-to-paseo.git
55
+ cd send-to-paseo/plugin
56
+ npm install # devDependencies only — for `npm run typecheck`
57
+ npm run verify
58
+ paseo plugin add /absolute/path/to/send-to-paseo/plugin
59
+ paseo plugin ls # expect: send-to-paseo running yes
60
+ ```
61
+
62
+ After editing the source:
63
+
64
+ ```sh
65
+ npm run verify
66
+ paseo plugin reload send-to-paseo
67
+ ```
68
+
69
+ Never restart the daemon to pick up plugin changes — that kills running agents.
70
+
71
+ ### No runtime dependencies, ever
72
+
73
+ `paseo plugin add` compiles the plugin **with no packages installed** — there is
74
+ no `npm install` step in that path, and the daemon's bundler can only resolve the
75
+ specifiers the host provides at runtime:
76
+
77
+ ```
78
+ @getpaseo/plugin @getpaseo/plugin/client @getpaseo/plugin/server
79
+ @getpaseo/plugin/client/react-native
80
+ zod react react/jsx-runtime react-native @tanstack/react-query
81
+ node:* (built-ins, in the server bundle)
82
+ ```
83
+
84
+ Everything in `plugin/package.json` is therefore a **devDependency**, present only
85
+ so `npm run typecheck` works for contributors.
86
+
87
+ > **Nothing may be added to `dependencies`.** A runtime import of anything outside
88
+ > the list above fails `paseo plugin add` for every user with
89
+ > `Build failed: Could not resolve "<pkg>"`, while still working perfectly on any
90
+ > machine that has run `npm install` — so it will not be caught locally. Imports
91
+ > from `@getpaseo/client` and `@getpaseo/protocol` must stay `import type` (erased
92
+ > at build time) or be reimplemented locally; the one runtime use of the Paseo SDK
93
+ > goes through the assembled-specifier `require` in `server/daemon.ts`, precisely
94
+ > so the bundler cannot see it. Before changing an import, read
95
+ > [`VERIFICATION.md`](VERIFICATION.md) §18, which includes the exact
96
+ > no-`node_modules` build command that proves an install still works.
97
+
98
+ ### Pairing
99
+
100
+ 1. Open **Send to Paseo** in the Paseo sidebar.
101
+ 2. Under **Pairing token**, press **Copy** (or **Reveal** and copy by hand).
102
+ 3. Paste it into the extension's options page. Simple setup already uses the Primary Paseo
103
+ machine's loopback bridge URL.
104
+
105
+ **Regenerate** issues a new token and immediately invalidates the old one, so any
106
+ paired extension has to be re-paired.
107
+
108
+ ---
109
+
21
110
  ## Requirements
22
111
 
23
112
  Two external commands, one required and one optional. **Nothing here is fatal
@@ -103,90 +192,6 @@ is the place to look first if you have never opened a log file.
103
192
 
104
193
  ---
105
194
 
106
- ## Install
107
-
108
- Plugins are trusted, unsandboxed code: this one runs an HTTP server that can
109
- start agents which execute arbitrary code on the daemon machine. Read the source
110
- before installing it.
111
-
112
- One command from npm. No clone or build step:
113
-
114
- ```sh
115
- paseo plugin install send-to-paseo
116
- paseo plugin ls # expect: send-to-paseo running yes
117
- paseo plugin logs send-to-paseo
118
- ```
119
-
120
- `pluginsEnabled` must already be `true` in the daemon's `config.json`.
121
-
122
- There is nothing to install because the plugin imports nothing at runtime that
123
- the Paseo host does not already provide — see
124
- [No runtime dependencies, ever](#no-runtime-dependencies-ever). To update an
125
- installed plugin, run `paseo plugin update send-to-paseo`; for a checkout,
126
- run `paseo plugin reload send-to-paseo`.
127
-
128
- ### From a checkout (contributors)
129
-
130
- Installing from a directory is the loop to use while editing, because
131
- `paseo plugin reload` picks up changes in place:
132
-
133
- ```sh
134
- git clone https://github.com/tomgrin10/send-to-paseo.git
135
- cd send-to-paseo/plugin
136
- npm install # devDependencies only — for `npm run typecheck`
137
- npm run verify
138
- paseo plugin add /absolute/path/to/send-to-paseo/plugin
139
- paseo plugin ls # expect: send-to-paseo running yes
140
- ```
141
-
142
- After editing the source:
143
-
144
- ```sh
145
- npm run verify
146
- paseo plugin reload send-to-paseo
147
- ```
148
-
149
- Never restart the daemon to pick up plugin changes — that kills running agents.
150
-
151
- ### No runtime dependencies, ever
152
-
153
- `paseo plugin add` compiles the plugin **with no packages installed** — there is
154
- no `npm install` step in that path, and the daemon's bundler can only resolve the
155
- specifiers the host provides at runtime:
156
-
157
- ```
158
- @getpaseo/plugin @getpaseo/plugin/client @getpaseo/plugin/server
159
- @getpaseo/plugin/client/react-native
160
- zod react react/jsx-runtime react-native @tanstack/react-query
161
- node:* (built-ins, in the server bundle)
162
- ```
163
-
164
- Everything in `plugin/package.json` is therefore a **devDependency**, present only
165
- so `npm run typecheck` works for contributors.
166
-
167
- > **Nothing may be added to `dependencies`.** A runtime import of anything outside
168
- > the list above fails `paseo plugin add` for every user with
169
- > `Build failed: Could not resolve "<pkg>"`, while still working perfectly on any
170
- > machine that has run `npm install` — so it will not be caught locally. Imports
171
- > from `@getpaseo/client` and `@getpaseo/protocol` must stay `import type` (erased
172
- > at build time) or be reimplemented locally; the one runtime use of the Paseo SDK
173
- > goes through the assembled-specifier `require` in `server/daemon.ts`, precisely
174
- > so the bundler cannot see it. Before changing an import, read
175
- > [`VERIFICATION.md`](VERIFICATION.md) §18, which includes the exact
176
- > no-`node_modules` build command that proves an install still works.
177
-
178
- ### Pairing
179
-
180
- 1. Open **Send to Paseo** in the Paseo sidebar.
181
- 2. Under **Pairing token**, press **Copy** (or **Reveal** and copy by hand).
182
- 3. Paste it into the extension's options page. Simple setup already uses the Primary Paseo
183
- machine's loopback bridge URL.
184
-
185
- **Regenerate** issues a new token and immediately invalidates the old one, so any
186
- paired extension has to be re-paired.
187
-
188
- ---
189
-
190
195
  ## Configuration
191
196
 
192
197
  All of it lives in the Paseo surface; there is no config file to hunt for.
@@ -881,11 +886,33 @@ assembled specifier.
881
886
  The listener cleanup and no-runtime-dependency rules are demonstrated in
882
887
  [`VERIFICATION.md`](VERIFICATION.md) §3, §10 and §18.
883
888
 
884
- ## More Paseo plugins
889
+ ## License
890
+
891
+ [MIT](LICENSE) © 2026 Tom Gringauz.
892
+
893
+ ## Navigation and display
894
+
895
+ Open this plugin from Command-K or its sidebar entry. **Overview** and **Display settings** link the main view and settings directly, without opening the Plugins settings page. Hiding a sidebar entry keeps Command-K available.
896
+
897
+ ## Paseo 0.14 agent integration
898
+
899
+ `send_to_paseo_bridge_status` exposes bridge state and executable health. Pairing tokens, token previews, connection codes, daemon credentials and recent prompt text are excluded.
900
+
901
+ Requires Paseo **0.14.0 or newer**. Agent tools are scoped to interactive Claude
902
+ and Codex sessions; history-only opens receive none. They become available on
903
+ the next idle session open after install or reload. The agent label
904
+ `plugin-tools/enabled: "false"` opts a session out. Existing plugin data and
905
+ settings are retained.
906
+
907
+ ## Other plugins
885
908
 
886
- Also available from [Tom Gringauz](https://github.com/tomgrin10):
909
+ - [Defer](https://github.com/tomgrin10/paseo-defer) — Schedule messages for later delivery.
910
+ - [Graphite](https://github.com/tomgrin10/paseo-graphite) — Graphite stacks and PR status.
911
+ - [Smart Session](https://github.com/tomgrin10/paseo-smart-session) — Context compaction and usage insights.
912
+ - [Vitals](https://github.com/tomgrin10/paseo-vitals) — Host, agent, and Docker health.
913
+ - [Session Guard](https://github.com/tomgrin10/paseo-session-guard) — Pause at session limits and continue after reset.
914
+ - [Transfer](https://github.com/tomgrin10/paseo-transfer) — Copy or move workspaces between hosts.
915
+ - [Transcript Search](https://github.com/tomgrin10/paseo-transcript-search) — Search conversations across connected hosts.
916
+ - [Dispatch](https://github.com/tomgrin10/paseo-dispatch) — Route tasks to existing workspaces (development preview).
887
917
 
888
- - [Defer](https://github.com/tomgrin10/paseo-defer) — Schedule messages to agents for later delivery.
889
- - [Graphite](https://github.com/tomgrin10/paseo-graphite) — Monitor Graphite stacks and PR action state.
890
- - [Smart Session](https://github.com/tomgrin10/paseo-smart-session) — Context-aware compaction and usage insights for long-running agents.
891
- - [Vitals](https://github.com/tomgrin10/paseo-vitals) — Host, Paseo, agent, and Docker health in one dashboard.
918
+ - [Follow-up](https://github.com/tomgrin10/paseo-follow-up) — Track workspace PRs, remaining tasks and completion.
@@ -0,0 +1,97 @@
1
+ import type { PluginClientContext, PluginSidebarContribution, PluginSurfaceProps } from "@getpaseo/plugin/client";
2
+ import { useSettings } from "@getpaseo/plugin/client";
3
+ import { SettingsAction, SettingsCard, SettingsSection, SettingsSwitch } from "@getpaseo/plugin/client/ui";
4
+ import { useEffect } from "react";
5
+ import { ActivityIndicator, ScrollView, Text, View } from "react-native";
6
+ import { displayPreferences, displayRpc } from "../shared/display";
7
+ import { withNavigation } from "./navigation";
8
+ import { sidebarVisibility } from "./sidebar-visibility";
9
+
10
+ const listeners = new Set<(visible: boolean) => void>();
11
+
12
+ function DisplaySettings({ theme }: PluginSurfaceProps) {
13
+ const settings = useSettings(displayPreferences);
14
+ const visible = settings.status === "ready" ? settings.values.showSidebar : undefined;
15
+ useEffect(() => {
16
+ if (visible !== undefined) for (const listener of listeners) listener(visible);
17
+ }, [visible]);
18
+
19
+ if (settings.status === "loading") return <ActivityIndicator accessibilityLabel="Loading display settings" color={theme.colors.foregroundMuted} />;
20
+ if (settings.status !== "ready") return (
21
+ <View style={{ gap: 12 }}>
22
+ <Text style={{ color: theme.colors.statusDanger }}>{settings.error}</Text>
23
+ <SettingsCard>
24
+ <SettingsAction label="Try loading the saved settings again" actionLabel="Retry" onPress={() => void settings.reload()} />
25
+ {settings.status === "invalid" && <SettingsAction label="Replace invalid display settings with defaults" actionLabel="Reset" disabled={settings.saving} onPress={() => void settings.reset()} />}
26
+ </SettingsCard>
27
+ {settings.saveError && <Text style={{ color: theme.colors.statusDanger }}>{settings.saveError}</Text>}
28
+ </View>
29
+ );
30
+
31
+ return (
32
+ <ScrollView style={{ flex: 1 }} contentContainerStyle={{ padding: 16, gap: 16 }}>
33
+ <SettingsSection title="Navigation">
34
+ <SettingsCard>
35
+ <SettingsSwitch
36
+ label="Show in sidebar"
37
+ hint="Open this plugin from Command-K (Ctrl-K on Windows and Linux) while viewing a workspace or plugin on this host."
38
+ value={settings.values.showSidebar}
39
+ disabled={settings.saving}
40
+ onValueChange={(showSidebar) => void settings.save({ ...settings.values, showSidebar }, settings.revision)}
41
+ />
42
+ </SettingsCard>
43
+ {settings.saveError && <Text accessibilityRole="alert" style={{ color: theme.colors.statusDanger }}>{settings.saveError}</Text>}
44
+ </SettingsSection>
45
+ </ScrollView>
46
+ );
47
+ }
48
+
49
+ /** Settings notifications reach mounted screens; poll for changes made on other clients. */
50
+ export function contributeDisplay(client: PluginClientContext, item: PluginSidebarContribution) {
51
+ const sidebar = sidebarVisibility(() => client.addSidebarItem(item));
52
+ // Paseo 0.10.1 memoizes sidebar route resolution when an installation mounts.
53
+ // Register synchronously, then reconcile the saved preference, so that an
54
+ // already-open sidebar route can resolve its surface during that first render.
55
+ sidebar.set(true);
56
+ const Settings = withNavigation(DisplaySettings, client, item.surface, "display");
57
+ const removeSurface = client.addSurface("display-settings", Settings);
58
+ const removeSettings = client.addSettingsScreen({ id: "display", title: "Display", icon: "PanelLeft", Component: Settings });
59
+ const removeCommand = client.addCommandCenterItem({
60
+ id: "display-settings",
61
+ title: `${item.title}: display settings`,
62
+ icon: "PanelLeft",
63
+ keywords: [item.title, "sidebar", "show", "hide", "display", "settings"],
64
+ context: "global",
65
+ onSelect({ openSurface }) { openSurface("display-settings"); },
66
+ });
67
+ let disposed = false;
68
+ let pending = false;
69
+ let generation = 0;
70
+ const update = (visible: boolean) => { generation += 1; sidebar.set(visible); };
71
+ listeners.add(update);
72
+ const refresh = async () => {
73
+ if (disposed || pending) return;
74
+ pending = true;
75
+ const currentGeneration = generation;
76
+ try {
77
+ const result = await client.rpc(displayRpc.read, {});
78
+ if (!disposed && generation === currentGeneration && result.status === "ready") {
79
+ const parsed = displayPreferences.schema.safeParse(result.values);
80
+ if (parsed.success) sidebar.set(parsed.data.showSidebar);
81
+ }
82
+ } catch {
83
+ // Retain the last valid preference through temporary disconnects.
84
+ } finally { pending = false; }
85
+ };
86
+ void refresh();
87
+ const timer = setInterval(() => void refresh(), 5000);
88
+ return () => {
89
+ disposed = true;
90
+ clearInterval(timer);
91
+ listeners.delete(update);
92
+ sidebar.dispose();
93
+ removeSurface();
94
+ removeSettings();
95
+ removeCommand();
96
+ };
97
+ }
@@ -0,0 +1,14 @@
1
+ import type { ComponentType } from "react";
2
+ import type { PluginClientContext, PluginSurfaceProps } from "@getpaseo/plugin/client";
3
+ import { Pressable, Text, View } from "react-native";
4
+
5
+ export function withNavigation<P extends PluginSurfaceProps>(Component: ComponentType<P>, client: PluginClientContext, home: string, active = "overview") {
6
+ return function PluginView(props: P) {
7
+ return <View style={{ flex: 1, backgroundColor: props.theme.colors.surface0 }}>
8
+ <View accessibilityRole="toolbar" style={{ flexDirection: "row", flexWrap: "wrap", gap: 4, padding: 8, borderBottomWidth: 1, borderColor: props.theme.colors.border }}>
9
+ {[{ id: "overview", title: "Overview", target: home }, { id: "display", title: "Display settings", target: "display-settings" }].map(item => <Pressable key={item.id} accessibilityRole="button" accessibilityState={{ selected: active === item.id }} onPress={() => client.openSurface(item.target)} style={({ pressed }) => ({ minHeight: 44, paddingHorizontal: 12, justifyContent: "center", borderRadius: 6, backgroundColor: pressed || active === item.id ? props.theme.colors.surface2 : "transparent" })}><Text style={{ color: active === item.id ? props.theme.colors.foreground : props.theme.colors.foregroundMuted, fontSize: 13, fontWeight: active === item.id ? "600" : "400" }}>{item.title}</Text></Pressable>)}
10
+ </View>
11
+ <Component {...props} />
12
+ </View>;
13
+ };
14
+ }
@@ -0,0 +1,21 @@
1
+ /** Own one sidebar registration; late reads cannot register after teardown. */
2
+ export function sidebarVisibility(register: () => (() => void) | void) {
3
+ let disposed = false;
4
+ let remove: (() => void) | undefined;
5
+ return {
6
+ set(visible: boolean) {
7
+ if (disposed) return;
8
+ if (visible && !remove) remove = register() ?? (() => {});
9
+ if (!visible && remove) {
10
+ remove();
11
+ remove = undefined;
12
+ }
13
+ },
14
+ dispose() {
15
+ if (disposed) return;
16
+ disposed = true;
17
+ remove?.();
18
+ remove = undefined;
19
+ },
20
+ };
21
+ }
package/index.client.tsx CHANGED
@@ -1,9 +1,11 @@
1
+ import { contributeDisplay } from "./client/display";
2
+ import { withNavigation } from "./client/navigation";
1
3
  import type { PluginClientContext } from "@getpaseo/plugin/client";
2
4
  import { SendToPaseoSettings } from "./client/settings";
3
5
 
4
6
  export default function contribute(client: PluginClientContext) {
5
- client.addSurface("settings", SendToPaseoSettings);
6
- client.addSidebarItem({
7
+ client.addSurface("settings", withNavigation(SendToPaseoSettings, client, "settings"));
8
+ const removeDisplay = contributeDisplay(client, {
7
9
  id: "send-to-paseo",
8
10
  title: "Send to Paseo",
9
11
  icon: "Send",
@@ -19,5 +21,5 @@ export default function contribute(client: PluginClientContext) {
19
21
  openSurface("settings");
20
22
  },
21
23
  });
22
- return () => {};
24
+ return () => { removeDisplay(); };
23
25
  }
package/index.server.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { contributeAgentTools } from "./server/native-tools";
2
+ import { displayPreferences } from "./shared/display";
1
3
  import type { PluginServerContext } from "@getpaseo/plugin/server";
2
4
  import {
3
5
  addAdditionalMachine,
@@ -31,6 +33,8 @@ import {
31
33
  import { requireServerTarget } from "./server/target";
32
34
 
33
35
  export default function contribute(server: PluginServerContext) {
36
+ const removeTools = contributeAgentTools(server);
37
+ server.registerSettings(displayPreferences);
34
38
  server.handle(getStatus, async ({ serverId }, { paseo }) => {
35
39
  await requireServerTarget(serverId);
36
40
  const current = await settings.read();
@@ -153,5 +157,6 @@ export default function contribute(server: PluginServerContext) {
153
157
  return enableMachinePrivateAccess();
154
158
  });
155
159
 
156
- return runBridge();
160
+ const stopBridge = runBridge();
161
+ return async () => { removeTools(); await stopBridge(); };
157
162
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "send-to-paseo",
3
3
  "type": "module",
4
- "version": "1.4.2",
4
+ "version": "2.1.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": {
@@ -33,16 +33,17 @@
33
33
  },
34
34
  "scripts": {
35
35
  "typecheck": "tsc --noEmit",
36
- "test": "node check-deps.mjs && node --test client/hosts.test.mjs server/main-agent.test.mjs",
37
- "verify": "npm run typecheck && npm test"
36
+ "test": "node check-deps.mjs && node --test client/hosts.test.mjs server/main-agent.test.mjs server/follow-up.test.mjs",
37
+ "verify": "npm run typecheck && npm test && node --test --experimental-strip-types agent-tools.test.mjs && node --test native-tools.test.mjs"
38
38
  },
39
39
  "devDependencies": {
40
- "@getpaseo/client": "0.9.0",
41
- "@getpaseo/plugin": "0.9.0",
42
- "@getpaseo/protocol": "0.9.0",
40
+ "@getpaseo/client": "0.14.0",
41
+ "@getpaseo/plugin": "0.14.0",
42
+ "@getpaseo/protocol": "0.14.0",
43
43
  "@tanstack/react-query": "^5.90.11",
44
44
  "@types/node": "^22.10.2",
45
45
  "@types/react": "~19.2.0",
46
+ "esbuild": "^0.28.2",
46
47
  "react": "19.1.0",
47
48
  "react-native": "0.81.5",
48
49
  "typescript": "^5.9.3",
package/paseo-plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "send-to-paseo",
3
3
  "requirements": {
4
- "paseo": ">=0.9.0"
4
+ "paseo": ">=0.14.0"
5
5
  }
6
6
  }
@@ -0,0 +1,10 @@
1
+ import type { AgentToolDefinition, PluginServerContext } from "@getpaseo/plugin/server";
2
+
3
+ /** 0.14's launch hook is re-evaluated on create, resume, import, and refresh. */
4
+ export function registerAgentTools(server: PluginServerContext, tools: AgentToolDefinition[], workspaceOnly = false) {
5
+ return server.before("agent.session_open", ({ request }) => {
6
+ if (request.purpose !== "interactive" || !["claude", "codex"].includes(request.provider)
7
+ || request.labels["plugin-tools/enabled"] === "false" || (workspaceOnly && !request.workspaceId)) return;
8
+ return { ...request, tools: [...request.tools, ...tools] };
9
+ });
10
+ }
package/server/bridge.ts CHANGED
@@ -31,6 +31,7 @@ import {
31
31
  import { handleSend, isDryRun, recordFailedSend } from "./send";
32
32
  import { previewToken, settings, tokenMatches } from "./settings";
33
33
  import { machineById, resolveOnMachine, sendToMachine } from "./peers";
34
+ import { browserExchange, exchangeBrowser } from "./browser-bridge";
34
35
 
35
36
  /**
36
37
  * The local HTTP bridge the Chrome extension talks to.
@@ -342,6 +343,7 @@ async function ping(authenticated: boolean): Promise<PingResponse> {
342
343
  name: PLUGIN_NAME,
343
344
  version: PLUGIN_VERSION,
344
345
  contract: CONTRACT_VERSION,
346
+ capabilities: { followUpRouting: true },
345
347
  daemon,
346
348
  machine: { name: machineName() },
347
349
  paired: authenticated,
@@ -368,7 +370,7 @@ async function route(
368
370
  return;
369
371
  }
370
372
 
371
- if (path === "/v1/resolve" || path === "/v1/send") {
373
+ if (path === "/v1/resolve" || path === "/v1/send" || path === "/follow-up/v1/exchange") {
372
374
  if (req.method !== "POST") throw methodNotAllowed();
373
375
  const { body, tooLarge } = await readBody(req);
374
376
  if (tooLarge) {
@@ -379,6 +381,12 @@ async function route(
379
381
  }
380
382
  await requireToken(req);
381
383
  const json = parseJsonBody(body);
384
+ if (path === "/follow-up/v1/exchange") {
385
+ const parsed = browserExchange.safeParse(json);
386
+ if (!parsed.success) throw badRequest(parsed.error.issues);
387
+ writeJson(res, 200, await exchangeBrowser(parsed.data, localOnly), cors);
388
+ return;
389
+ }
382
390
 
383
391
  if (path === "/v1/resolve") {
384
392
  const parsed = ResolveRequestSchema.safeParse(json);
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ import { callFollowUp, readDaemonStatus } from "./daemon";
3
+ import { exchangeBrowserOnMachine } from "./peers";
4
+ import { settings } from "./settings";
5
+
6
+ const repo = z.string().max(201).regex(/^[\w.-]+\/[\w.-]+$/);
7
+ const result = z.object({ routeId: z.string().min(1).max(200), id: z.string().min(1).max(200), nonce: z.string().min(1).max(200), outcome: z.enum(["completed", "failed", "uncertain"]), prs: z.array(z.object({ repo, number: z.number().int().positive(), head: z.string().min(1).max(200), state: z.enum(["OPEN", "CLOSED", "MERGED"]), mergeWhenReady: z.boolean(), merging: z.boolean() })).max(50), applied: z.array(z.number().int().positive()).max(50), error: z.string().max(500) });
8
+ export const browserExchange = z.object({
9
+ clientId: z.string().min(1).max(100),
10
+ routes: z.array(z.object({ routeId: z.string().min(1).max(200), serverId: z.string().min(1).max(200), repositories: z.array(repo).max(100) })).max(32),
11
+ ready: z.boolean(), acceptJobs: z.boolean(), results: z.array(result).max(10),
12
+ });
13
+ type Exchange = z.infer<typeof browserExchange>;
14
+ const turns = new Map<string, number>();
15
+ type Route = { routeId: string; serverId: string | null; label: string; available: boolean; jobs: unknown[]; accepted: string[] };
16
+
17
+ /** Each route gets its own consent scopes. A proxy can never widen them. */
18
+ export async function exchangeBrowser(input: Exchange, localOnly: boolean) {
19
+ const configured = await settings.read();
20
+ const machines = localOnly ? [] : configured.additionalMachines.filter(m => m.enabled);
21
+ const eligible = ["local", ...machines.map(m => m.id)].filter(id => input.routes.some(r => r.routeId === id && r.repositories.length));
22
+ const turn = turns.get(input.clientId) ?? 0;
23
+ const selected = eligible[turn % eligible.length];
24
+ if (turns.size >= 100) turns.delete(turns.keys().next().value!);
25
+ turns.set(input.clientId, turn + 1);
26
+ const daemon = await readDaemonStatus();
27
+ const localScope = input.routes.find(r => r.routeId === "local" && r.serverId === daemon.serverId);
28
+ const local: Route = { routeId: "local", serverId: daemon.serverId, label: "This Paseo machine", available: false, jobs: [], accepted: [] };
29
+ try {
30
+ const answer = await callFollowUp("follow.browser-exchange", {
31
+ clientId: `send:${input.clientId}`, ready: input.ready && !!localScope?.repositories.length,
32
+ acceptJobs: input.acceptJobs && selected === "local", repositories: localScope?.repositories ?? [],
33
+ results: input.results.filter(r => r.routeId === "local").map(({ routeId: _, ...r }) => r),
34
+ }) as { jobs?: unknown[]; accepted?: string[] };
35
+ local.available = true;
36
+ local.jobs = Array.isArray(answer.jobs) ? answer.jobs : [];
37
+ local.accepted = Array.isArray(answer.accepted) ? answer.accepted : [];
38
+ } catch { /* Follow Up is optional, including older versions. */ }
39
+ // One fair lease slot across all routes; sleeping peers run within independent total budgets.
40
+ const remoteRoutes = await Promise.all(machines.map(async machine => {
41
+ const route: Route = { routeId: machine.id, serverId: null, label: machine.label, available: false, jobs: [], accepted: [] };
42
+ try {
43
+ const scope = input.routes.find(r => r.routeId === machine.id);
44
+ const response = await exchangeBrowserOnMachine(machine, { ...input, acceptJobs: input.acceptJobs && selected === machine.id, routes: scope ? [{ ...scope, routeId: "local" }] : [], results: input.results.filter(r => r.routeId === machine.id).map(r => ({ ...r, routeId: "local" })) }) as { routes?: Route[] };
45
+ const remote = response.routes?.find(r => r.routeId === "local");
46
+ if (remote) { route.serverId = remote.serverId; route.available = remote.available; route.jobs = remote.jobs; route.accepted = remote.accepted; }
47
+ } catch { /* A sleeping peer cannot disable local sends. */ }
48
+ return route;
49
+ }));
50
+ return { routes: [local, ...remoteRoutes] };
51
+ }
package/server/daemon.ts CHANGED
@@ -136,6 +136,26 @@ async function resolvePassword(): Promise<string | undefined> {
136
136
  return resolveDaemonPassword(async () => (await settings.read()).daemonPassword);
137
137
  }
138
138
 
139
+ /** 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
+ const load = typeof require === "function" ? require : createRequire(join(process.cwd(), "noop.cjs"));
142
+ const { DaemonClient } = load(["@getpaseo", "client", "internal", "daemon-client"].join("/")) as {
143
+ DaemonClient: new (options: Record<string, unknown>) => {
144
+ connect(): Promise<void>; close(): Promise<void>; invokePluginRpc(plugin: string, method: string, input: unknown): Promise<unknown>;
145
+ };
146
+ };
147
+ const password = await resolvePassword();
148
+ const client = new DaemonClient({ url: await resolveUrl(), clientId: "send-to-paseo-follow-up", clientType: "cli", reconnect: { enabled: false }, connectTimeoutMs: 2_000, suppressSendErrors: true, ...(password ? { password } : {}) });
149
+ let timer: ReturnType<typeof setTimeout> | undefined;
150
+ try {
151
+ await client.connect();
152
+ return await Promise.race([
153
+ client.invokePluginRpc("follow-through", method, input),
154
+ new Promise<never>((_, reject) => { timer = setTimeout(() => reject(new Error("Optional Follow Up request timed out.")), 2_000); timer.unref?.(); }),
155
+ ]);
156
+ } finally { if (timer) clearTimeout(timer); await client.close().catch(() => undefined); }
157
+ }
158
+
139
159
  /** Runs `work` against an SDK connection that is always closed before returning. */
140
160
  export async function withPaseo<T>(work: (paseo: PaseoApi) => Promise<T>): Promise<T> {
141
161
  const { createPaseoClient } = loadClientModule();
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import { callFollowUp } from "./daemon";
3
+ import type { ListedAgent } from "./main-agent";
4
+
5
+ const ownerReply = z.object({ owner: z.object({ workspaceId: z.string().min(1).max(200), agentId: z.string().min(1).max(200) }).nullable() });
6
+ export type PrOwner = NonNullable<z.infer<typeof ownerReply>["owner"]>;
7
+ export async function lookupPrOwner(owner: string, repo: string, number: number): Promise<PrOwner | null> {
8
+ // Missing, old, stopped or broken companions cannot break standalone sends.
9
+ try { return ownerReply.parse(await callFollowUp("follow.pr-owner", { repo: `${owner}/${repo}`, number })).owner; }
10
+ catch { return null; }
11
+ }
12
+ export function registeredAgent(agents: readonly ListedAgent[], owner: PrOwner | null, workspaceId: string): ListedAgent | null {
13
+ if (!owner || owner.workspaceId !== workspaceId) return null;
14
+ return agents.find(a => a.id === owner.agentId && a.workspaceId === workspaceId && a.archivedAt == null) ?? null;
15
+ }
@@ -0,0 +1,17 @@
1
+ import { defineAgentTool, type PluginServerContext } from "@getpaseo/plugin/server";
2
+ import { z } from "zod";
3
+ import { getBridgeStatus } from "./bridge";
4
+ import { dependencySnapshot } from "./deps";
5
+ import { registerAgentTools } from "./agent-tools";
6
+ export function contributeAgentTools(server: PluginServerContext) {
7
+ return registerAgentTools(server, [defineAgentTool({
8
+ name: "send_to_paseo_bridge_status", description: "Diagnose the Send to Paseo browser bridge and required executables. Never returns pairing tokens, connection codes, credentials or recent prompt text. Does not start agents or change pairing.",
9
+ input: z.object({}).strict(),
10
+ async execute(_, { signal }) {
11
+ if (signal.aborted) throw new Error("Tool call cancelled.");
12
+ const [bridge, deps] = await Promise.all([getBridgeStatus(), dependencySnapshot()]);
13
+ const result = { state: bridge.state, port: bridge.port, paired: bridge.paired, dryRun: bridge.dryRun, defaultProvider: bridge.defaultProvider, agentDispatch: bridge.agentDispatch, dependencies: deps.dependencies.map(dep => ({ name: dep.name, state: dep.state })) };
14
+ return { text: JSON.stringify(result), structuredContent: result };
15
+ },
16
+ })]);
17
+ }
package/server/peers.ts CHANGED
@@ -381,7 +381,10 @@ export async function sendToMachine(
381
381
  timeoutMs = SEND_ROUTE_TIMEOUT_MS,
382
382
  ): Promise<SendResponse> {
383
383
  const deadline = Date.now() + timeoutMs;
384
- await checkedPing(machine, deadline);
384
+ const ping = await checkedPing(machine, deadline);
385
+ if (request.followUpAgentId && ping.capabilities?.followUpRouting !== true) {
386
+ throw new BridgeError("bad_request", "Update Send to Paseo on the additional machine before sending to a registered Follow Up agent.");
387
+ }
385
388
  const target = { ...request.target };
386
389
  delete target.routeId;
387
390
  const json = await fetchJson(
@@ -402,3 +405,10 @@ export async function sendToMachine(
402
405
  export async function machineById(id: string): Promise<SavedMachine | null> {
403
406
  return (await settings.read()).additionalMachines.find((machine) => machine.id === id) ?? null;
404
407
  }
408
+
409
+ /** Companion transport shares the same authenticated machine-identity check as sends. */
410
+ export async function exchangeBrowserOnMachine(machine: SavedMachine, input: unknown): Promise<unknown> {
411
+ const deadline = Date.now() + 3_000;
412
+ await checkedPing(machine, deadline);
413
+ return fetchJson(machine, "/follow-up/v1/exchange?local=1", { method: "POST", body: JSON.stringify(input) }, remainingMs(deadline));
414
+ }
package/server/resolve.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  type StackPrState,
15
15
  } from "../shared/contracts";
16
16
  import { withPaseo } from "./daemon";
17
+ import { lookupPrOwner, registeredAgent, type PrOwner } from "./follow-up";
17
18
  import {
18
19
  ANCESTRY_STACK_DISTANCE,
19
20
  UNKNOWN_STACK_DISTANCE,
@@ -74,9 +75,16 @@ function sameRepo(a: { owner: string; repo: string }, b: { owner: string; repo:
74
75
  export async function resolveProject(
75
76
  paseo: PaseoApi,
76
77
  ref: Pick<PrRef, "owner" | "repo">,
78
+ preferredProjectId?: string,
77
79
  ): Promise<ProjectPayload> {
78
80
  const { projects } = await paseo.projects.list();
79
81
  const wanted = remoteProjectId(ref.owner, ref.repo).toLowerCase();
82
+ const preferred = projects.find(p => p.projectId === preferredProjectId);
83
+ if (preferred?.projectKind === "git" && preferred.projectRootPath) {
84
+ const fromId = /^remote:github\.com\/([^/]+)\/(.+)$/i.exec(preferred.projectId);
85
+ const identity = fromId?.[1] && fromId[2] ? { owner: fromId[1], repo: fromId[2] } : await readOriginOwnerRepo(preferred.projectRootPath);
86
+ if (identity && sameRepo(identity, ref)) return { projectId: preferred.projectId, name: preferred.projectDisplayName, path: preferred.projectRootPath };
87
+ }
80
88
 
81
89
  for (const project of projects) {
82
90
  if (project.projectId.toLowerCase() === wanted) {
@@ -229,6 +237,7 @@ export async function buildCandidates(input: {
229
237
  /** Non-null when `gh` could not be consulted; carried into the create label. */
230
238
  outage?: GhOutage | null;
231
239
  agents?: readonly ListedAgent[];
240
+ owner?: PrOwner | null;
232
241
  }): Promise<{ candidates: Candidate[]; defaultCandidateIndex: number }> {
233
242
  const { counts, agents } = await workspaceAgents(
234
243
  input.paseo,
@@ -261,16 +270,12 @@ export async function buildCandidates(input: {
261
270
  isolation: isolationOf(workspace),
262
271
  agentCount: counts.get(workspace.id) ?? 0,
263
272
  ...(() => {
273
+ const registered = registeredAgent(agents, input.owner ?? null, workspace.id);
264
274
  const main = selectMainAgent(agents, workspace.id);
265
- return main === null
266
- ? {}
267
- : {
268
- mainAgent: {
269
- agentId: main.id,
270
- title: agentDisplayTitle(main),
271
- status: main.status,
272
- },
273
- };
275
+ return {
276
+ ...(main ? { mainAgent: { agentId: main.id, title: agentDisplayTitle(main), status: main.status } } : {}),
277
+ ...(registered ? { followUpAgent: { agentId: registered.id, title: agentDisplayTitle(registered), status: registered.status } } : {}),
278
+ };
274
279
  })(),
275
280
  };
276
281
  if (branch !== null && branch === input.pr.headBranch) {
@@ -972,14 +977,20 @@ export async function handleResolve(request: ResolveRequest): Promise<ResolveRes
972
977
  // These sources are independent. Starting them together removes several
973
978
  // daemon/network round trips from the click path (and the extension now
974
979
  // starts this work before the popover opens).
975
- const [project, prLookup, currentSettings, profile, catalog, allWorkspaces] =
980
+ const workspacesPromise = paseo.workspaces.list();
981
+ const ownerPromise = lookupPrOwner(ref.owner, ref.repo, ref.number);
982
+ const projectPromise = Promise.all([workspacesPromise, ownerPromise]).then(([all, owner]) =>
983
+ resolveProject(paseo, ref, all.entries.find(w => w.id === owner?.workspaceId && w.archivingAt === null)?.projectId),
984
+ );
985
+ const [project, prLookup, currentSettings, profile, catalog, allWorkspaces, owner] =
976
986
  await Promise.all([
977
- resolveProject(paseo, ref),
987
+ projectPromise,
978
988
  lookupPr(ref),
979
989
  settings.read(),
980
990
  resolveSelectedProfile(paseo),
981
991
  listModes(paseo),
982
- paseo.workspaces.list(),
992
+ workspacesPromise,
993
+ ownerPromise,
983
994
  ]);
984
995
  // PR lookup degrades instead of failing when `gh` is unavailable: Paseo's
985
996
  // forge checkout still supports the create path.
@@ -1016,7 +1027,9 @@ export async function handleResolve(request: ResolveRequest): Promise<ResolveRes
1016
1027
  stackBranches,
1017
1028
  outage,
1018
1029
  agents: await agentsPromise,
1030
+ owner,
1019
1031
  });
1032
+ const ownerIndex = candidates.findIndex(c => c.kind === "existing" && c.followUpAgent !== undefined);
1020
1033
  const { providers } = await providersPromise;
1021
1034
  const effectiveProvider = providers.find((entry) => entry.isDefault)?.id ?? providers[0]?.id;
1022
1035
  const resolvedModeId =
@@ -1027,7 +1040,7 @@ export async function handleResolve(request: ResolveRequest): Promise<ResolveRes
1027
1040
  pr,
1028
1041
  project,
1029
1042
  candidates,
1030
- defaultCandidateIndex,
1043
+ defaultCandidateIndex: ownerIndex >= 0 ? ownerIndex : defaultCandidateIndex,
1031
1044
  providers,
1032
1045
  modes: catalog.modes,
1033
1046
  resolvedModeId: resolvedModeId ?? null,
package/server/send.ts CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  resolveStackBranches,
30
30
  } from "./resolve";
31
31
  import { settings } from "./settings";
32
+ import { lookupPrOwner, registeredAgent } from "./follow-up";
32
33
  import {
33
34
  agentDisplayTitle,
34
35
  agentProvider,
@@ -214,7 +215,9 @@ export async function handleSend(request: SendRequest): Promise<SendResponse> {
214
215
  // daemon status are the slow inputs; starting them together avoids paying
215
216
  // their latency in series after the already-prefetched resolve.
216
217
  const [project, prLookup, serverId, currentSettings] = await Promise.all([
217
- resolveProject(paseo, ref),
218
+ request.target.kind === "existing"
219
+ ? paseo.workspaces.list().then(all => resolveProject(paseo, ref, all.entries.find(w => request.target.kind === "existing" && w.id === request.target.workspaceId && w.archivingAt === null)?.projectId))
220
+ : resolveProject(paseo, ref),
218
221
  lookupPr(ref),
219
222
  requireServerId(),
220
223
  settings.read(),
@@ -306,11 +309,17 @@ export async function handleSend(request: SendRequest): Promise<SendResponse> {
306
309
  let mainAgent: ListedAgent | null = null;
307
310
  if (agentDispatch === "main" && request.target.kind === "existing") {
308
311
  try {
309
- mainAgent = selectMainAgent(
310
- await listProjectAgents(paseo, project.projectId),
311
- workspaceId,
312
- );
312
+ const [agents, owner] = await Promise.all([
313
+ listProjectAgents(paseo, project.projectId),
314
+ request.followUpAgentId ? lookupPrOwner(ref.owner, ref.repo, ref.number) : Promise.resolve(null),
315
+ ]);
316
+ const registered = request.followUpAgentId ? registeredAgent(agents, owner, workspaceId) : null;
317
+ if (request.followUpAgentId && registered?.id !== request.followUpAgentId) {
318
+ throw new BridgeError("bad_request", "The Follow Up registration changed or is unavailable. Reopen the composer before sending.");
319
+ }
320
+ mainAgent = registered ?? selectMainAgent(agents, workspaceId);
313
321
  } catch (error) {
322
+ if (error instanceof BridgeError) throw error;
314
323
  throw new BridgeError(
315
324
  "agent_create_failed",
316
325
  `Paseo could not find the main agent in ${workspaceLabel}: ${
@@ -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 = "1.4.2";
12
+ export const PLUGIN_VERSION = "2.1.0";
13
13
  /** Bumped only for an incompatible bridge API; the paths stay `/v1`. */
14
14
  export const CONTRACT_VERSION = 1;
15
15
 
@@ -133,6 +133,7 @@ export const SendRequestSchema = PrRefSchema.extend({
133
133
  target: SendTargetSchema,
134
134
  /** Per-send override. Missing preserves the plugin's saved preference. */
135
135
  agentDispatch: AgentDispatchSchema.optional(),
136
+ followUpAgentId: z.string().min(1).max(200).optional(),
136
137
  provider: z.string().min(1).max(200).optional(),
137
138
  /**
138
139
  * Permission mode for the new agent, e.g. `auto` or `bypassPermissions`.
@@ -203,6 +204,7 @@ export class BridgeError extends Error {
203
204
  }
204
205
 
205
206
  export interface PingResponse {
207
+ capabilities?: { followUpRouting?: boolean };
206
208
  ok: true;
207
209
  name: string;
208
210
  version: string;
@@ -284,6 +286,8 @@ export interface ExistingCandidate {
284
286
  title: string;
285
287
  status: "error" | "initializing" | "idle" | "running" | "closed";
286
288
  };
289
+ /** Explicit PR registration, independent of the workspace's root-agent heuristic. */
290
+ followUpAgent?: { agentId: string; title: string; status: string };
287
291
  }
288
292
 
289
293
  export interface CreateCandidate {
@@ -552,6 +556,7 @@ export const updateConfig = defineRpc({
552
556
  /** Null clears the override and falls back to the mode chain. */
553
557
  defaultModeId: z.string().max(200).nullable().optional(),
554
558
  agentDispatch: AgentDispatchSchema.optional(),
559
+ followUpAgentId: z.string().min(1).max(200).optional(),
555
560
  /** Null removes the declared reverse-proxy origin. */
556
561
  externalBridgeUrl: ExternalBridgeUrlSchema.nullable().optional(),
557
562
  }),
@@ -0,0 +1,11 @@
1
+ import { defineSettings, settingsRpc } from "@getpaseo/plugin";
2
+ import { z } from "zod";
3
+
4
+ export const displayPreferences = defineSettings({
5
+ id: "display",
6
+ scope: "host",
7
+ version: 1,
8
+ schema: z.object({ showSidebar: z.boolean().default(true) }),
9
+ });
10
+
11
+ export const displayRpc = settingsRpc(displayPreferences.id);