send-to-paseo 2.6.0 → 2.6.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/client/display.tsx +12 -17
- package/client/navigation.ts +7 -0
- package/client/settings-feed/index.ts +79 -0
- package/client/settings.tsx +2 -1
- package/index.server.ts +9 -3
- package/package.json +3 -2
- package/server/daemon.ts +7 -3
- package/server/follow-up-id.ts +12 -24
- package/server/send.ts +13 -2
- package/server/settings-feed/index.ts +48 -0
- package/shared/contracts.ts +4 -1
- package/shared/display.ts +7 -0
package/client/display.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { watchSettings } from "./settings-feed/index";
|
|
1
2
|
import type { PluginClientContext, PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
2
3
|
import { useSettings } from "@getpaseo/plugin/client";
|
|
3
4
|
import { SettingsAction, SettingsCard, SettingsSection, SettingsSwitch } from "@getpaseo/plugin/client/ui";
|
|
4
5
|
import { useEffect } from "react";
|
|
5
6
|
import { ActivityIndicator, ScrollView, Text, View } from "react-native";
|
|
6
|
-
import { displayPreferences, displayRpc } from "../shared/display";
|
|
7
|
+
import { displayFeed, displayPreferences, displayRpc } from "../shared/display";
|
|
7
8
|
import { sidebarVisibility } from "./sidebar-visibility";
|
|
8
9
|
|
|
9
10
|
const listeners = new Set<(visible: boolean) => void>();
|
|
@@ -45,7 +46,7 @@ function DisplaySettings({ theme }: PluginSurfaceProps) {
|
|
|
45
46
|
);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
/**
|
|
49
|
+
/** Push settings across clients; older hosts fall back to one read a minute. */
|
|
49
50
|
export function contributeDisplay(client: PluginClientContext, item: { title: string; register: () => (() => void) | void }) {
|
|
50
51
|
const sidebar = sidebarVisibility(item.register);
|
|
51
52
|
// Paseo 0.10.1 memoizes sidebar route resolution when an installation mounts.
|
|
@@ -64,29 +65,23 @@ export function contributeDisplay(client: PluginClientContext, item: { title: st
|
|
|
64
65
|
onSelect({ openSettings }) { openSettings("display"); },
|
|
65
66
|
});
|
|
66
67
|
let disposed = false;
|
|
67
|
-
let pending = false;
|
|
68
68
|
let generation = 0;
|
|
69
69
|
const update = (visible: boolean) => { generation += 1; sidebar.set(visible); };
|
|
70
70
|
listeners.add(update);
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!disposed && generation === currentGeneration && result.status === "ready") {
|
|
71
|
+
const feed = watchSettings({
|
|
72
|
+
client, contract: displayFeed,
|
|
73
|
+
revision: () => generation,
|
|
74
|
+
read: () => client.rpc(displayRpc.read, {}),
|
|
75
|
+
apply: result => {
|
|
76
|
+
if (!disposed && result.status === "ready") {
|
|
78
77
|
const parsed = displayPreferences.schema.safeParse(result.values);
|
|
79
78
|
if (parsed.success) sidebar.set(parsed.data.showSidebar);
|
|
80
79
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
} finally { pending = false; }
|
|
84
|
-
};
|
|
85
|
-
void refresh();
|
|
86
|
-
const timer = setInterval(() => void refresh(), 5000);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
87
82
|
return () => {
|
|
88
83
|
disposed = true;
|
|
89
|
-
|
|
84
|
+
feed.stop();
|
|
90
85
|
listeners.delete(update);
|
|
91
86
|
sidebar.dispose();
|
|
92
87
|
removeSurface();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
2
|
+
|
|
3
|
+
/** Open a recent send on its own host. */
|
|
4
|
+
export function openSettingsAgent(navigation: PluginSurfaceProps["navigation"], serverId: string, agentId: string): void {
|
|
5
|
+
const target = navigation as (NonNullable<PluginSurfaceProps["navigation"]> & { supportsFocusHost?: boolean }) | undefined;
|
|
6
|
+
target?.openAgent({ agentId, serverId, ...(target.supportsFocusHost === true ? { focusHost: true } : {}) });
|
|
7
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Vendored from paseo-plugin-kit v0.4.0-beta.0 (settings-feed-client/index.ts). Do not edit; change the kit and run `paseo-kit vendor settings-feed-client <dir>`.
|
|
2
|
+
/** Push settings on current hosts; read once a minute while a feed is unavailable. */
|
|
3
|
+
type Handle = (() => void) & { ready?: Promise<unknown> };
|
|
4
|
+
type Clock = Pick<typeof globalThis, "setTimeout" | "clearTimeout" | "setInterval" | "clearInterval">;
|
|
5
|
+
type Timer = ReturnType<typeof setTimeout>;
|
|
6
|
+
|
|
7
|
+
export function watchSettings<Document>(o: {
|
|
8
|
+
client: unknown;
|
|
9
|
+
contract: unknown;
|
|
10
|
+
read(): Promise<Document>;
|
|
11
|
+
apply(document: Document): void;
|
|
12
|
+
/** Changes from this client's settings screen invalidate an older RPC read. */
|
|
13
|
+
revision?: () => number;
|
|
14
|
+
clock?: Clock;
|
|
15
|
+
}): { stop(): void } {
|
|
16
|
+
const clock = o.clock ?? globalThis;
|
|
17
|
+
const client = o.client as { subscribe?: (contract: unknown, input: object, event: (document: Document) => void, options: { onClosed(): void }) => Handle };
|
|
18
|
+
let stopped = false, pending = false, live = true, attempt = 0, generation = 0, eventRevision = 0;
|
|
19
|
+
let poll: Timer | undefined, retry: Timer | undefined, steady: Timer | undefined, handle: Handle | undefined;
|
|
20
|
+
const read = async () => {
|
|
21
|
+
if (stopped || pending) return;
|
|
22
|
+
pending = true;
|
|
23
|
+
const current = eventRevision, revision = o.revision?.();
|
|
24
|
+
try {
|
|
25
|
+
const document = await o.read();
|
|
26
|
+
if (!stopped && current === eventRevision && revision === o.revision?.()) o.apply(document);
|
|
27
|
+
} catch { /* Keep the last valid setting through a disconnect. */ }
|
|
28
|
+
finally { pending = false; }
|
|
29
|
+
};
|
|
30
|
+
const stopPoll = () => { if (poll !== undefined) clock.clearInterval(poll); poll = undefined; };
|
|
31
|
+
const startPoll = () => {
|
|
32
|
+
if (poll !== undefined || stopped) return;
|
|
33
|
+
void read();
|
|
34
|
+
poll = clock.setInterval(() => void read(), 60_000);
|
|
35
|
+
};
|
|
36
|
+
const clearSteady = () => { if (steady !== undefined) clock.clearTimeout(steady); steady = undefined; };
|
|
37
|
+
const release = (h: Handle | undefined) => { try { h?.(); } catch { /* Already closed. */ } };
|
|
38
|
+
const start = () => {
|
|
39
|
+
retry = undefined;
|
|
40
|
+
if (stopped) return;
|
|
41
|
+
const mine = ++generation;
|
|
42
|
+
const closed = () => {
|
|
43
|
+
if (stopped || mine !== generation) return;
|
|
44
|
+
generation++; clearSteady();
|
|
45
|
+
const old = handle; handle = undefined; release(old);
|
|
46
|
+
const wasLive = live; live = false;
|
|
47
|
+
const delay = attempt < 15 ? 1_000 : Math.min(30_000, 1_000 * 2 ** Math.min(5, attempt - 14));
|
|
48
|
+
attempt++;
|
|
49
|
+
retry = clock.setTimeout(start, delay);
|
|
50
|
+
if (wasLive) startPoll();
|
|
51
|
+
};
|
|
52
|
+
try {
|
|
53
|
+
const h = client.subscribe!.call(o.client, o.contract, {}, document => {
|
|
54
|
+
if (!stopped && mine === generation) { eventRevision++; o.apply(document); }
|
|
55
|
+
}, { onClosed: closed });
|
|
56
|
+
if (stopped || mine !== generation) { release(h); return; }
|
|
57
|
+
handle = h;
|
|
58
|
+
Promise.resolve(h.ready).then(() => {
|
|
59
|
+
if (stopped || mine !== generation) return;
|
|
60
|
+
clearSteady();
|
|
61
|
+
// Acknowledgement followed by immediate closure must not restart RPC polling every second.
|
|
62
|
+
steady = clock.setTimeout(() => {
|
|
63
|
+
steady = undefined;
|
|
64
|
+
if (stopped || mine !== generation) return;
|
|
65
|
+
live = true; attempt = 0; stopPoll();
|
|
66
|
+
}, 30_000);
|
|
67
|
+
}, closed);
|
|
68
|
+
} catch { closed(); }
|
|
69
|
+
};
|
|
70
|
+
if (typeof client?.subscribe === "function") start();
|
|
71
|
+
else startPoll();
|
|
72
|
+
return { stop() {
|
|
73
|
+
if (stopped) return;
|
|
74
|
+
stopped = true; generation++;
|
|
75
|
+
stopPoll(); clearSteady();
|
|
76
|
+
if (retry !== undefined) clock.clearTimeout(retry);
|
|
77
|
+
release(handle); handle = undefined;
|
|
78
|
+
} };
|
|
79
|
+
}
|
package/client/settings.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { openSettingsAgent } from "./navigation";
|
|
1
2
|
import type { PluginTheme } from "@getpaseo/plugin";
|
|
2
3
|
import {
|
|
3
4
|
getPaseoClient,
|
|
@@ -763,7 +764,7 @@ export function SendToPaseoSettings({ theme, host, layout, navigation }: PluginS
|
|
|
763
764
|
onCopyToken={() => void onCopy()}
|
|
764
765
|
detailsOpen={showConnectionDetails}
|
|
765
766
|
onToggleDetails={() => setShowConnectionDetails(!showConnectionDetails)}
|
|
766
|
-
onOpenAgent={navigation === undefined ? null : (agentId) => navigation
|
|
767
|
+
onOpenAgent={navigation === undefined ? null : (agentId) => openSettingsAgent(navigation, host.id, agentId)}
|
|
767
768
|
onClear={() => void clearRecent({ serverId: host.id }).then(invalidate)}
|
|
768
769
|
/>
|
|
769
770
|
)}
|
package/index.server.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { registerSettingsFeed } from "./server/settings-feed/index";
|
|
1
2
|
import { contributeAgentTools } from "./server/native-tools";
|
|
2
|
-
import { displayPreferences } from "./shared/display";
|
|
3
|
+
import { displayFeed, displayPreferences } from "./shared/display";
|
|
3
4
|
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
4
5
|
import {
|
|
5
6
|
addAdditionalMachine,
|
|
@@ -37,7 +38,7 @@ import { requireServerTarget } from "./server/target";
|
|
|
37
38
|
|
|
38
39
|
export default function contribute(server: PluginServerContext) {
|
|
39
40
|
const removeTools = contributeAgentTools(server);
|
|
40
|
-
server.registerSettings(displayPreferences);
|
|
41
|
+
const stopDisplayFeed = registerSettingsFeed(server, displayFeed, server.registerSettings(displayPreferences));
|
|
41
42
|
server.handle(getStatus, async ({ serverId }, { paseo }) => {
|
|
42
43
|
await requireServerTarget(serverId);
|
|
43
44
|
const current = await settings.read();
|
|
@@ -182,5 +183,10 @@ export default function contribute(server: PluginServerContext) {
|
|
|
182
183
|
// Connect now, not on the first popover: the click path never pays for a daemon connect (warm-daemon-connection).
|
|
183
184
|
warmDaemon();
|
|
184
185
|
// The held daemon connection closes after the bridge has stopped serving requests.
|
|
185
|
-
return async () => {
|
|
186
|
+
return async () => {
|
|
187
|
+
stopDisplayFeed();
|
|
188
|
+
removeTools();
|
|
189
|
+
await stopBridge();
|
|
190
|
+
await closeDaemon();
|
|
191
|
+
};
|
|
186
192
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "send-to-paseo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.6.0",
|
|
4
|
+
"version": "2.6.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": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"typecheck": "tsc --noEmit",
|
|
38
38
|
"test": "node check-deps.mjs && node --test client/hosts.test.mjs client/settings.test.mjs server/main-agent.test.mjs server/follow-up.test.mjs server/daemon-connection.test.mjs",
|
|
39
|
-
"verify": "npm run typecheck && npm test && node --test --experimental-strip-types agent-tools.test.mjs shared/chat.test.mjs && node --test native-tools.test.mjs"
|
|
39
|
+
"verify": "npm run typecheck && npm test && node --test --experimental-strip-types agent-tools.test.mjs shared/chat.test.mjs && node --test native-tools.test.mjs && node --test display-feed.test.mjs && paseo-kit vendor --check settings-feed-client client/settings-feed && paseo-kit vendor --check settings-feed-server server/settings-feed"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@getpaseo/client": "0.14.0",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"@types/node": "^22.10.2",
|
|
47
47
|
"@types/react": "~19.2.0",
|
|
48
48
|
"esbuild": "^0.28.2",
|
|
49
|
+
"paseo-plugin-kit": "github:tomgrin10/paseo-plugin-kit#v0.4.0-beta.0",
|
|
49
50
|
"react": "19.1.0",
|
|
50
51
|
"react-native": "0.81.5",
|
|
51
52
|
"typescript": "^5.9.3",
|
package/server/daemon.ts
CHANGED
|
@@ -45,6 +45,7 @@ type PaseoApi = PluginHandlerContext["paseo"];
|
|
|
45
45
|
|
|
46
46
|
/** The subset of Paseo's DaemonClient this plugin uses. */
|
|
47
47
|
interface DaemonClient {
|
|
48
|
+
sendMessage?: AgentMessageSender;
|
|
48
49
|
connect(): Promise<void>;
|
|
49
50
|
close(): Promise<void>;
|
|
50
51
|
invokePluginRpc(plugin: string, method: string, input: unknown): Promise<unknown>;
|
|
@@ -252,13 +253,16 @@ export async function callFollowUp(method: "follow.pr-owner" | "follow.pr-worksp
|
|
|
252
253
|
} finally { if (timer) clearTimeout(timer); }
|
|
253
254
|
}
|
|
254
255
|
|
|
255
|
-
/**
|
|
256
|
-
export
|
|
256
|
+
/** The low-level client preserves receipts that the high-level SDK currently discards. */
|
|
257
|
+
export type AgentMessageSender = (agentId: string, text: string, options: { activeTurnBehavior: "steer" }) => Promise<unknown>;
|
|
258
|
+
|
|
259
|
+
/** Runs work in a scoped SDK view, preserving access to the held connection's receipt. */
|
|
260
|
+
export async function withPaseo<T>(work: (paseo: PaseoApi, sendMessage?: AgentMessageSender) => Promise<T>): Promise<T> {
|
|
257
261
|
const { createPaseoApi } = loadClientModule();
|
|
258
262
|
return shared.run(async (client) => {
|
|
259
263
|
const paseo = createPaseoApi(client);
|
|
260
264
|
try {
|
|
261
|
-
return await work(paseo);
|
|
265
|
+
return await work(paseo, typeof client.sendMessage === "function" ? client.sendMessage.bind(client) : undefined);
|
|
262
266
|
} finally {
|
|
263
267
|
// Releases this request's handles and listeners, never the socket.
|
|
264
268
|
await paseo.dispose().catch(() => undefined);
|
package/server/follow-up-id.ts
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
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;
|
|
1
|
+
/** Follow-up 2.x's plugin id. */
|
|
2
|
+
const FOLLOW_UP_PLUGIN_ID = "follow-up";
|
|
6
3
|
|
|
7
4
|
/** Paseo's answer when no plugin runs under the id (0.15: "Plugin is not available: <id>"). */
|
|
8
5
|
const absent = (error: unknown) => /plugin (?:is )?not (?:available|installed|configured)|unknown plugin/i.test(error instanceof Error ? error.message : String(error));
|
|
9
6
|
|
|
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
|
-
*/
|
|
7
|
+
// Browser polls must not repeatedly probe a missing optional plugin.
|
|
16
8
|
const ABSENT_TTL_MS = 30_000;
|
|
17
|
-
let
|
|
18
|
-
let
|
|
19
|
-
let neitherError: unknown;
|
|
9
|
+
let absentUntil = 0;
|
|
10
|
+
let absentError: unknown;
|
|
20
11
|
|
|
21
|
-
/** Calls
|
|
12
|
+
/** Calls Follow-up once; RPC errors and timeouts are propagated without caching them as absence. */
|
|
22
13
|
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 (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
if (now() < absentUntil) throw absentError;
|
|
15
|
+
try {
|
|
16
|
+
return await invoke(FOLLOW_UP_PLUGIN_ID, method, input);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (absent(error)) { absentError = error; absentUntil = now() + ABSENT_TTL_MS; }
|
|
19
|
+
throw error;
|
|
29
20
|
}
|
|
30
|
-
remembered = undefined;
|
|
31
|
-
neitherError = last; neitherUntil = now() + ABSENT_TTL_MS;
|
|
32
|
-
throw last;
|
|
33
21
|
}
|
package/server/send.ts
CHANGED
|
@@ -210,7 +210,7 @@ export async function handleSend(request: SendRequest): Promise<SendResponse> {
|
|
|
210
210
|
const prompt = normalizePrompt(request.prompt);
|
|
211
211
|
const dryRun = isDryRun();
|
|
212
212
|
|
|
213
|
-
return withPaseo(async (paseo) => {
|
|
213
|
+
return withPaseo(async (paseo, sendMessage) => {
|
|
214
214
|
// All four are read-only and independent. On a cold send, `gh` and the
|
|
215
215
|
// daemon status are the slow inputs; starting them together avoids paying
|
|
216
216
|
// their latency in series after the already-prefetched resolve.
|
|
@@ -334,6 +334,7 @@ export async function handleSend(request: SendRequest): Promise<SendResponse> {
|
|
|
334
334
|
let recordedProvider: string;
|
|
335
335
|
let recordedModeId: string | null;
|
|
336
336
|
let agentCreated = true;
|
|
337
|
+
let delivery: Pick<SendResponse, "deliveryStatus" | "guidance"> = {};
|
|
337
338
|
let dispatch: "new" | "main" = "new";
|
|
338
339
|
|
|
339
340
|
if (mainAgent !== null) {
|
|
@@ -348,12 +349,21 @@ export async function handleSend(request: SendRequest): Promise<SendResponse> {
|
|
|
348
349
|
// The public 0.9 SDK forwards this supported daemon option but omits
|
|
349
350
|
// it from PaseoAgentSendOptions. Steering preserves a running main
|
|
350
351
|
// agent's current turn instead of implicitly interrupting it.
|
|
351
|
-
|
|
352
|
+
const receipt: unknown = sendMessage
|
|
353
|
+
? await sendMessage(mainAgent.id, composedPrompt, { activeTurnBehavior: "steer" })
|
|
354
|
+
: await paseo.agents.ref(mainAgent).send(
|
|
352
355
|
composedPrompt,
|
|
353
356
|
{ activeTurnBehavior: "steer" } as Parameters<
|
|
354
357
|
ReturnType<PaseoApi["agents"]["ref"]>["send"]
|
|
355
358
|
>[1] & { activeTurnBehavior: "steer" },
|
|
356
359
|
);
|
|
360
|
+
if (receipt && typeof receipt === "object") {
|
|
361
|
+
const value = receipt as { deliveryStatus?: unknown; guidance?: unknown };
|
|
362
|
+
delivery = {
|
|
363
|
+
...(value.deliveryStatus === "queued" ? { deliveryStatus: "queued" as const } : {}),
|
|
364
|
+
...(typeof value.guidance === "string" ? { guidance: value.guidance } : {}),
|
|
365
|
+
};
|
|
366
|
+
}
|
|
357
367
|
} catch (error) {
|
|
358
368
|
throw new BridgeError(
|
|
359
369
|
"agent_create_failed",
|
|
@@ -444,6 +454,7 @@ export async function handleSend(request: SendRequest): Promise<SendResponse> {
|
|
|
444
454
|
deepLink,
|
|
445
455
|
title: responseTitle,
|
|
446
456
|
agentCreated,
|
|
457
|
+
...delivery,
|
|
447
458
|
dispatch,
|
|
448
459
|
dryRun,
|
|
449
460
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Vendored from paseo-plugin-kit v0.4.0-beta.0 (settings-feed-server/index.ts). Do not edit; change the kit and run `paseo-kit vendor settings-feed-server <dir>`.
|
|
2
|
+
/** Bridge the host's settings notifications to plugin subscriptions, without a polling timer. */
|
|
3
|
+
type Push = (document: unknown) => Promise<void>;
|
|
4
|
+
type Context = { push: Push; signal: AbortSignal };
|
|
5
|
+
export function registerSettingsFeed(
|
|
6
|
+
server: unknown,
|
|
7
|
+
contract: unknown,
|
|
8
|
+
settings: { read(): Promise<unknown>; subscribe?: unknown },
|
|
9
|
+
): () => void {
|
|
10
|
+
const host = server as { handle(contract: unknown, handler: (input: unknown, context: Context) => void): void };
|
|
11
|
+
const subscribe = settings.subscribe;
|
|
12
|
+
if (typeof subscribe !== "function") return () => {};
|
|
13
|
+
let stopped = false, revision = 0;
|
|
14
|
+
const subscribers = new Map<Push, () => void>();
|
|
15
|
+
const send = (push: Push, document: unknown) => {
|
|
16
|
+
if (stopped || !subscribers.has(push)) return;
|
|
17
|
+
void Promise.resolve().then(() => {
|
|
18
|
+
if (!stopped && subscribers.has(push)) return push(document);
|
|
19
|
+
}).catch(() => { subscribers.get(push)?.(); });
|
|
20
|
+
};
|
|
21
|
+
let off: () => void;
|
|
22
|
+
try {
|
|
23
|
+
off = subscribe.call(settings, (document: unknown) => {
|
|
24
|
+
revision++;
|
|
25
|
+
for (const push of subscribers.keys()) send(push, document);
|
|
26
|
+
}) as (() => void);
|
|
27
|
+
} catch { return () => {}; }
|
|
28
|
+
try {
|
|
29
|
+
host.handle(contract, (_input, context) => {
|
|
30
|
+
if (stopped || context.signal.aborted) return;
|
|
31
|
+
if (typeof context.push !== "function") throw new Error("Settings feeds require plugin subscriptions.");
|
|
32
|
+
const remove = () => { subscribers.delete(context.push); context.signal.removeEventListener("abort", remove); };
|
|
33
|
+
subscribers.set(context.push, remove);
|
|
34
|
+
context.signal.addEventListener("abort", remove, { once: true });
|
|
35
|
+
const current = revision;
|
|
36
|
+
void settings.read().then(document => {
|
|
37
|
+
if (revision === current) send(context.push, document);
|
|
38
|
+
}).catch(remove);
|
|
39
|
+
});
|
|
40
|
+
} catch {
|
|
41
|
+
off(); return () => {};
|
|
42
|
+
}
|
|
43
|
+
return () => {
|
|
44
|
+
if (stopped) return;
|
|
45
|
+
stopped = true; off();
|
|
46
|
+
for (const remove of [...subscribers.values()]) remove();
|
|
47
|
+
};
|
|
48
|
+
}
|
package/shared/contracts.ts
CHANGED
|
@@ -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.6.0";
|
|
12
|
+
export const PLUGIN_VERSION = "2.6.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
|
|
|
@@ -423,6 +423,9 @@ export interface ResolveResponse extends LocalResolveResponse {
|
|
|
423
423
|
|
|
424
424
|
export interface SendResponse {
|
|
425
425
|
ok: true;
|
|
426
|
+
/** Additive daemon receipt; absent on older hosts. */
|
|
427
|
+
deliveryStatus?: "queued";
|
|
428
|
+
guidance?: string;
|
|
426
429
|
agentId: string;
|
|
427
430
|
workspaceId: string;
|
|
428
431
|
workspaceCreated: boolean;
|
package/shared/display.ts
CHANGED
|
@@ -9,3 +9,10 @@ export const displayPreferences = defineSettings({
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
export const displayRpc = settingsRpc(displayPreferences.id);
|
|
12
|
+
|
|
13
|
+
/** Plain contract keeps clients on older SDKs compatible. */
|
|
14
|
+
export const displayFeed = {
|
|
15
|
+
name: "send-to-paseo.display-feed",
|
|
16
|
+
input: z.object({}),
|
|
17
|
+
event: z.object({ status: z.string(), revision: z.string().optional(), values: z.unknown().optional(), error: z.string().optional() }),
|
|
18
|
+
};
|