send-to-paseo 1.3.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/LICENSE +21 -0
- package/README.md +879 -0
- package/client/hosts.ts +70 -0
- package/client/settings.tsx +1231 -0
- package/index.client.tsx +23 -0
- package/index.server.ts +157 -0
- package/package.json +51 -0
- package/paseo-plugin.json +6 -0
- package/server/bridge.ts +725 -0
- package/server/cache.ts +23 -0
- package/server/daemon-password.ts +44 -0
- package/server/daemon.ts +287 -0
- package/server/deps.ts +432 -0
- package/server/gh.ts +864 -0
- package/server/git.ts +298 -0
- package/server/main-agent.ts +110 -0
- package/server/peers.ts +404 -0
- package/server/resolve.ts +1041 -0
- package/server/send.ts +463 -0
- package/server/settings.ts +288 -0
- package/server/target.ts +6 -0
- package/shared/contracts.ts +766 -0
- package/shared/host-target.ts +8 -0
|
@@ -0,0 +1,1231 @@
|
|
|
1
|
+
import type { PluginTheme } from "@getpaseo/plugin";
|
|
2
|
+
import {
|
|
3
|
+
getPaseoClient,
|
|
4
|
+
type PluginSurfaceProps,
|
|
5
|
+
useHosts,
|
|
6
|
+
useRpc,
|
|
7
|
+
} from "@getpaseo/plugin/client";
|
|
8
|
+
import { copyText, useToast } from "@getpaseo/plugin/client/react-native";
|
|
9
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
|
+
import React, { useMemo, useState } from "react";
|
|
11
|
+
import { Pressable, ScrollView, Text, TextInput, View } from "react-native";
|
|
12
|
+
import {
|
|
13
|
+
addAdditionalMachine,
|
|
14
|
+
clearRecentSends,
|
|
15
|
+
DEFAULT_PORT,
|
|
16
|
+
enablePrivateAccess,
|
|
17
|
+
externalBridgeUrlProblem,
|
|
18
|
+
getConnectionCode,
|
|
19
|
+
getStatus,
|
|
20
|
+
removeAdditionalMachine,
|
|
21
|
+
regenerateToken,
|
|
22
|
+
revealToken,
|
|
23
|
+
testAdditionalMachine,
|
|
24
|
+
updateAdditionalMachine,
|
|
25
|
+
updateConfig,
|
|
26
|
+
type AdditionalMachine,
|
|
27
|
+
type AgentProfileOption,
|
|
28
|
+
type BridgeStatus,
|
|
29
|
+
type DependencyReportPayload,
|
|
30
|
+
type ModeOption,
|
|
31
|
+
type ProviderOption,
|
|
32
|
+
type RecentSend,
|
|
33
|
+
} from "../shared/contracts";
|
|
34
|
+
import { checkHostAccess, organizeDiscoveredHosts, type DiscoveredHostRow } from "./hosts";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The Send to Paseo sidebar surface: bridge status, the pairing token, the
|
|
38
|
+
* default model and a short send history.
|
|
39
|
+
*
|
|
40
|
+
* Every `Text` takes its color from `theme.colors` and every gap from
|
|
41
|
+
* `layout.compact`. Unstyled text renders black, which is unreadable in Paseo's
|
|
42
|
+
* dark themes and on mobile.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const QUERY_KEY = ["send-to-paseo", "status"];
|
|
46
|
+
/** The daemon offers 180+ models; the list stays usable behind a filter. */
|
|
47
|
+
const PROVIDER_LIST_LIMIT = 12;
|
|
48
|
+
|
|
49
|
+
function stateLabel(status: BridgeStatus): string {
|
|
50
|
+
switch (status.state) {
|
|
51
|
+
case "running":
|
|
52
|
+
return `Listening on http://127.0.0.1:${status.port}`;
|
|
53
|
+
case "starting":
|
|
54
|
+
return "Starting…";
|
|
55
|
+
case "failed":
|
|
56
|
+
return "Not running";
|
|
57
|
+
case "stopped":
|
|
58
|
+
return "Stopped";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function stateTone(status: BridgeStatus, theme: PluginTheme): string {
|
|
63
|
+
if (status.state === "running") return theme.colors.statusSuccess;
|
|
64
|
+
if (status.state === "failed") return theme.colors.statusDanger;
|
|
65
|
+
return theme.colors.statusWarning;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function hostStatusTone(
|
|
69
|
+
status: DiscoveredHostRow["status"],
|
|
70
|
+
theme: PluginTheme,
|
|
71
|
+
): string {
|
|
72
|
+
if (status === "online") return theme.colors.statusSuccess;
|
|
73
|
+
if (status === "error") return theme.colors.statusDanger;
|
|
74
|
+
return theme.colors.statusWarning;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function formatWhen(iso: string | null): string {
|
|
78
|
+
if (iso === null) return "never";
|
|
79
|
+
const at = Date.parse(iso);
|
|
80
|
+
if (Number.isNaN(at)) return "never";
|
|
81
|
+
const seconds = Math.round((Date.now() - at) / 1000);
|
|
82
|
+
if (seconds < 5) return "just now";
|
|
83
|
+
if (seconds < 60) return `${seconds}s ago`;
|
|
84
|
+
const minutes = Math.round(seconds / 60);
|
|
85
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
86
|
+
const hours = Math.round(minutes / 60);
|
|
87
|
+
if (hours < 24) return `${hours}h ago`;
|
|
88
|
+
return new Date(at).toLocaleDateString();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function copyToClipboard(value: string): Promise<boolean> {
|
|
92
|
+
try {
|
|
93
|
+
await copyText(value);
|
|
94
|
+
return true;
|
|
95
|
+
} catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function useStyles(theme: PluginTheme, compact: boolean) {
|
|
101
|
+
return useMemo(
|
|
102
|
+
() => ({
|
|
103
|
+
screen: {
|
|
104
|
+
flex: 1,
|
|
105
|
+
backgroundColor: theme.colors.surface0,
|
|
106
|
+
},
|
|
107
|
+
content: {
|
|
108
|
+
padding: compact ? 16 : 24,
|
|
109
|
+
gap: compact ? 16 : 20,
|
|
110
|
+
},
|
|
111
|
+
card: {
|
|
112
|
+
backgroundColor: theme.colors.surface1,
|
|
113
|
+
borderColor: theme.colors.border,
|
|
114
|
+
borderWidth: 1,
|
|
115
|
+
borderRadius: 12,
|
|
116
|
+
padding: compact ? 12 : 16,
|
|
117
|
+
gap: compact ? 8 : 10,
|
|
118
|
+
},
|
|
119
|
+
heading: {
|
|
120
|
+
color: theme.colors.foreground,
|
|
121
|
+
fontSize: compact ? 15 : 16,
|
|
122
|
+
fontWeight: "600" as const,
|
|
123
|
+
},
|
|
124
|
+
title: {
|
|
125
|
+
color: theme.colors.foreground,
|
|
126
|
+
fontSize: compact ? 20 : 24,
|
|
127
|
+
fontWeight: "600" as const,
|
|
128
|
+
},
|
|
129
|
+
body: { color: theme.colors.foreground, fontSize: compact ? 13 : 14 },
|
|
130
|
+
muted: { color: theme.colors.foregroundMuted, fontSize: compact ? 12 : 13 },
|
|
131
|
+
mono: {
|
|
132
|
+
color: theme.colors.foreground,
|
|
133
|
+
fontSize: compact ? 12 : 13,
|
|
134
|
+
fontFamily: "Menlo",
|
|
135
|
+
},
|
|
136
|
+
row: { flexDirection: "row" as const, gap: 8, alignItems: "center" as const },
|
|
137
|
+
wrapRow: { flexDirection: "row" as const, gap: 8, flexWrap: "wrap" as const },
|
|
138
|
+
input: {
|
|
139
|
+
color: theme.colors.foreground,
|
|
140
|
+
backgroundColor: theme.colors.surface2,
|
|
141
|
+
borderColor: theme.colors.border,
|
|
142
|
+
borderWidth: 1,
|
|
143
|
+
borderRadius: 8,
|
|
144
|
+
paddingHorizontal: 10,
|
|
145
|
+
paddingVertical: 8,
|
|
146
|
+
fontSize: compact ? 13 : 14,
|
|
147
|
+
minWidth: 96,
|
|
148
|
+
},
|
|
149
|
+
button: {
|
|
150
|
+
backgroundColor: theme.colors.surface2,
|
|
151
|
+
borderColor: theme.colors.border,
|
|
152
|
+
borderWidth: 1,
|
|
153
|
+
borderRadius: 8,
|
|
154
|
+
paddingHorizontal: 12,
|
|
155
|
+
paddingVertical: 8,
|
|
156
|
+
},
|
|
157
|
+
buttonText: { color: theme.colors.foreground, fontSize: compact ? 12 : 13 },
|
|
158
|
+
primary: {
|
|
159
|
+
backgroundColor: theme.colors.accent,
|
|
160
|
+
borderColor: theme.colors.accent,
|
|
161
|
+
borderWidth: 1,
|
|
162
|
+
borderRadius: 8,
|
|
163
|
+
paddingHorizontal: 12,
|
|
164
|
+
paddingVertical: 8,
|
|
165
|
+
},
|
|
166
|
+
primaryText: { color: theme.colors.accentForeground, fontSize: compact ? 12 : 13 },
|
|
167
|
+
danger: { color: theme.colors.statusDanger, fontSize: compact ? 12 : 13 },
|
|
168
|
+
tokenBox: {
|
|
169
|
+
backgroundColor: theme.colors.surface2,
|
|
170
|
+
borderColor: theme.colors.border,
|
|
171
|
+
borderWidth: 1,
|
|
172
|
+
borderRadius: 8,
|
|
173
|
+
padding: 10,
|
|
174
|
+
},
|
|
175
|
+
listRow: {
|
|
176
|
+
borderTopColor: theme.colors.border,
|
|
177
|
+
borderTopWidth: 1,
|
|
178
|
+
paddingVertical: 8,
|
|
179
|
+
gap: 2,
|
|
180
|
+
},
|
|
181
|
+
selectedRow: {
|
|
182
|
+
backgroundColor: theme.colors.surface2,
|
|
183
|
+
borderRadius: 8,
|
|
184
|
+
paddingHorizontal: 8,
|
|
185
|
+
},
|
|
186
|
+
}),
|
|
187
|
+
[theme, compact],
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
type Styles = ReturnType<typeof useStyles>;
|
|
192
|
+
|
|
193
|
+
function Button({
|
|
194
|
+
label,
|
|
195
|
+
onPress,
|
|
196
|
+
styles,
|
|
197
|
+
primary = false,
|
|
198
|
+
disabled = false,
|
|
199
|
+
}: {
|
|
200
|
+
label: string;
|
|
201
|
+
onPress: () => void;
|
|
202
|
+
styles: Styles;
|
|
203
|
+
primary?: boolean;
|
|
204
|
+
disabled?: boolean;
|
|
205
|
+
}) {
|
|
206
|
+
return (
|
|
207
|
+
<Pressable
|
|
208
|
+
accessibilityRole="button"
|
|
209
|
+
accessibilityLabel={label}
|
|
210
|
+
onPress={onPress}
|
|
211
|
+
disabled={disabled}
|
|
212
|
+
style={[primary ? styles.primary : styles.button, disabled ? { opacity: 0.5 } : null]}
|
|
213
|
+
>
|
|
214
|
+
<Text style={primary ? styles.primaryText : styles.buttonText}>{label}</Text>
|
|
215
|
+
</Pressable>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function ProviderPicker({
|
|
220
|
+
providers,
|
|
221
|
+
selected,
|
|
222
|
+
onSelect,
|
|
223
|
+
styles,
|
|
224
|
+
}: {
|
|
225
|
+
providers: ProviderOption[];
|
|
226
|
+
selected: string | null;
|
|
227
|
+
onSelect: (id: string) => void;
|
|
228
|
+
styles: Styles;
|
|
229
|
+
}) {
|
|
230
|
+
const [filter, setFilter] = useState("");
|
|
231
|
+
const needle = filter.trim().toLowerCase();
|
|
232
|
+
const matches = useMemo(() => {
|
|
233
|
+
const filtered =
|
|
234
|
+
needle === ""
|
|
235
|
+
? providers
|
|
236
|
+
: providers.filter(
|
|
237
|
+
(provider) =>
|
|
238
|
+
provider.label.toLowerCase().includes(needle) ||
|
|
239
|
+
provider.id.toLowerCase().includes(needle),
|
|
240
|
+
);
|
|
241
|
+
return filtered.slice(0, PROVIDER_LIST_LIMIT);
|
|
242
|
+
}, [providers, needle]);
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<View style={{ gap: 8 }}>
|
|
246
|
+
<TextInput
|
|
247
|
+
value={filter}
|
|
248
|
+
onChangeText={setFilter}
|
|
249
|
+
placeholder="Filter models"
|
|
250
|
+
style={styles.input}
|
|
251
|
+
autoCapitalize="none"
|
|
252
|
+
autoCorrect={false}
|
|
253
|
+
/>
|
|
254
|
+
{matches.length === 0 ? (
|
|
255
|
+
<Text style={styles.muted}>No model matches that filter.</Text>
|
|
256
|
+
) : null}
|
|
257
|
+
{matches.map((provider) => {
|
|
258
|
+
const isSelected = provider.id === selected;
|
|
259
|
+
return (
|
|
260
|
+
<Pressable
|
|
261
|
+
key={provider.id}
|
|
262
|
+
accessibilityRole="button"
|
|
263
|
+
accessibilityLabel={`Use ${provider.label} by default`}
|
|
264
|
+
onPress={() => onSelect(provider.id)}
|
|
265
|
+
style={isSelected ? styles.selectedRow : undefined}
|
|
266
|
+
>
|
|
267
|
+
<View style={{ paddingVertical: 6 }}>
|
|
268
|
+
<Text style={styles.body}>
|
|
269
|
+
{isSelected ? "● " : "○ "}
|
|
270
|
+
{provider.label}
|
|
271
|
+
</Text>
|
|
272
|
+
<Text style={styles.muted}>{provider.id}</Text>
|
|
273
|
+
</View>
|
|
274
|
+
</Pressable>
|
|
275
|
+
);
|
|
276
|
+
})}
|
|
277
|
+
{providers.length > matches.length ? (
|
|
278
|
+
<Text style={styles.muted}>
|
|
279
|
+
{providers.length - matches.length} more; use the filter to narrow it down.
|
|
280
|
+
</Text>
|
|
281
|
+
) : null}
|
|
282
|
+
</View>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The saved Paseo agent profiles, as a single-select list.
|
|
288
|
+
*
|
|
289
|
+
* A profile is followed by *id*, re-read on every send: there is no way to
|
|
290
|
+
* reference one at agent-create time, so the plugin copies `provider`, `model`,
|
|
291
|
+
* `modeId` and `thinkingOptionId` out of it each time. Edit the profile in
|
|
292
|
+
* Paseo and the next send follows, with no re-copy step here.
|
|
293
|
+
*/
|
|
294
|
+
function ProfilePicker({
|
|
295
|
+
profiles,
|
|
296
|
+
selected,
|
|
297
|
+
onSelect,
|
|
298
|
+
styles,
|
|
299
|
+
}: {
|
|
300
|
+
profiles: AgentProfileOption[];
|
|
301
|
+
selected: string | null;
|
|
302
|
+
onSelect: (id: string | null) => void;
|
|
303
|
+
styles: Styles;
|
|
304
|
+
}) {
|
|
305
|
+
if (profiles.length === 0) {
|
|
306
|
+
return <Text style={styles.muted}>No agent profiles are saved in Paseo yet.</Text>;
|
|
307
|
+
}
|
|
308
|
+
return (
|
|
309
|
+
<View style={{ gap: 4 }}>
|
|
310
|
+
<Pressable
|
|
311
|
+
accessibilityRole="button"
|
|
312
|
+
accessibilityLabel="Do not follow a profile"
|
|
313
|
+
onPress={() => onSelect(null)}
|
|
314
|
+
style={selected === null ? styles.selectedRow : undefined}
|
|
315
|
+
>
|
|
316
|
+
<View style={{ paddingVertical: 6 }}>
|
|
317
|
+
<Text style={styles.body}>{selected === null ? "● " : "○ "}No profile</Text>
|
|
318
|
+
<Text style={styles.muted}>Use the model and mode chosen below instead.</Text>
|
|
319
|
+
</View>
|
|
320
|
+
</Pressable>
|
|
321
|
+
{profiles.map((profile) => {
|
|
322
|
+
const isSelected = profile.id === selected;
|
|
323
|
+
const detail = [
|
|
324
|
+
profile.model === null ? profile.provider : `${profile.provider}/${profile.model}`,
|
|
325
|
+
profile.modeId === null ? "no mode set" : `mode ${profile.modeId}`,
|
|
326
|
+
profile.thinkingOptionId === null ? null : `thinking ${profile.thinkingOptionId}`,
|
|
327
|
+
]
|
|
328
|
+
.filter((part): part is string => part !== null)
|
|
329
|
+
.join(" · ");
|
|
330
|
+
return (
|
|
331
|
+
<Pressable
|
|
332
|
+
key={profile.id}
|
|
333
|
+
accessibilityRole="button"
|
|
334
|
+
accessibilityLabel={`Follow the ${profile.name} profile`}
|
|
335
|
+
onPress={() => onSelect(profile.id)}
|
|
336
|
+
style={isSelected ? styles.selectedRow : undefined}
|
|
337
|
+
>
|
|
338
|
+
<View style={{ paddingVertical: 6 }}>
|
|
339
|
+
<Text style={styles.body}>
|
|
340
|
+
{isSelected ? "● " : "○ "}
|
|
341
|
+
{profile.name}
|
|
342
|
+
</Text>
|
|
343
|
+
<Text style={styles.muted}>{detail}</Text>
|
|
344
|
+
</View>
|
|
345
|
+
</Pressable>
|
|
346
|
+
);
|
|
347
|
+
})}
|
|
348
|
+
</View>
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Permission modes, grouped by provider because mode ids *are* per provider:
|
|
354
|
+
* `bypassPermissions` is a Claude id and means nothing to Codex. The stored
|
|
355
|
+
* value is a bare mode id, and a send validates it against whichever provider
|
|
356
|
+
* it actually resolved to, falling through when it does not fit.
|
|
357
|
+
*
|
|
358
|
+
* Unattended modes are listed, never hidden — they are marked in the warning
|
|
359
|
+
* colour and named as what they are.
|
|
360
|
+
*/
|
|
361
|
+
function ModePicker({
|
|
362
|
+
modes,
|
|
363
|
+
selected,
|
|
364
|
+
onSelect,
|
|
365
|
+
styles,
|
|
366
|
+
theme,
|
|
367
|
+
}: {
|
|
368
|
+
modes: ModeOption[];
|
|
369
|
+
selected: string | null;
|
|
370
|
+
onSelect: (id: string | null) => void;
|
|
371
|
+
styles: Styles;
|
|
372
|
+
theme: PluginTheme;
|
|
373
|
+
}) {
|
|
374
|
+
const providers = useMemo(() => {
|
|
375
|
+
const grouped = new Map<string, ModeOption[]>();
|
|
376
|
+
for (const mode of modes) {
|
|
377
|
+
const bucket = grouped.get(mode.provider);
|
|
378
|
+
if (bucket === undefined) grouped.set(mode.provider, [mode]);
|
|
379
|
+
else bucket.push(mode);
|
|
380
|
+
}
|
|
381
|
+
return [...grouped.entries()];
|
|
382
|
+
}, [modes]);
|
|
383
|
+
|
|
384
|
+
if (providers.length === 0) {
|
|
385
|
+
return <Text style={styles.muted}>Paseo reported no selectable modes.</Text>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return (
|
|
389
|
+
<View style={{ gap: 4 }}>
|
|
390
|
+
<Pressable
|
|
391
|
+
accessibilityRole="button"
|
|
392
|
+
accessibilityLabel="Follow Paseo's own default mode"
|
|
393
|
+
onPress={() => onSelect(null)}
|
|
394
|
+
style={selected === null ? styles.selectedRow : undefined}
|
|
395
|
+
>
|
|
396
|
+
<View style={{ paddingVertical: 6 }}>
|
|
397
|
+
<Text style={styles.body}>{selected === null ? "● " : "○ "}Follow Paseo</Text>
|
|
398
|
+
<Text style={styles.muted}>Each provider's own default mode.</Text>
|
|
399
|
+
</View>
|
|
400
|
+
</Pressable>
|
|
401
|
+
{providers.map(([provider, providerModes]) => (
|
|
402
|
+
<View key={provider} style={{ gap: 2 }}>
|
|
403
|
+
<Text style={styles.muted}>{provider}</Text>
|
|
404
|
+
{providerModes.map((mode) => {
|
|
405
|
+
const isSelected = mode.id === selected;
|
|
406
|
+
const unattended = mode.isUnattended === true;
|
|
407
|
+
return (
|
|
408
|
+
<Pressable
|
|
409
|
+
key={`${provider}/${mode.id}`}
|
|
410
|
+
accessibilityRole="button"
|
|
411
|
+
accessibilityLabel={`Default to ${mode.label} for ${provider}`}
|
|
412
|
+
onPress={() => onSelect(mode.id)}
|
|
413
|
+
style={isSelected ? styles.selectedRow : undefined}
|
|
414
|
+
>
|
|
415
|
+
<View style={{ paddingVertical: 6 }}>
|
|
416
|
+
<Text style={styles.body}>
|
|
417
|
+
{isSelected ? "● " : "○ "}
|
|
418
|
+
{mode.label}
|
|
419
|
+
{unattended ? (
|
|
420
|
+
<Text style={{ color: theme.colors.statusWarning }}> — unattended</Text>
|
|
421
|
+
) : null}
|
|
422
|
+
{mode.isDefault ? <Text style={styles.muted}> (provider default)</Text> : null}
|
|
423
|
+
</Text>
|
|
424
|
+
<Text style={styles.muted}>{mode.id}</Text>
|
|
425
|
+
</View>
|
|
426
|
+
</Pressable>
|
|
427
|
+
);
|
|
428
|
+
})}
|
|
429
|
+
</View>
|
|
430
|
+
))}
|
|
431
|
+
</View>
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* One external command: whether it was found, which copy, and what is lost
|
|
437
|
+
* without it. `path` is shown because the whole point of the well-known-location
|
|
438
|
+
* probing is that the answer here can differ from the user's terminal.
|
|
439
|
+
*/
|
|
440
|
+
function DependencyRow({
|
|
441
|
+
dependency,
|
|
442
|
+
styles,
|
|
443
|
+
theme,
|
|
444
|
+
}: {
|
|
445
|
+
dependency: DependencyReportPayload;
|
|
446
|
+
styles: Styles;
|
|
447
|
+
theme: PluginTheme;
|
|
448
|
+
}) {
|
|
449
|
+
const tone =
|
|
450
|
+
dependency.state === "ok"
|
|
451
|
+
? theme.colors.statusSuccess
|
|
452
|
+
: dependency.required
|
|
453
|
+
? theme.colors.statusDanger
|
|
454
|
+
: theme.colors.statusWarning;
|
|
455
|
+
const summary =
|
|
456
|
+
dependency.state === "ok"
|
|
457
|
+
? (dependency.version ?? "found")
|
|
458
|
+
: dependency.state === "missing"
|
|
459
|
+
? dependency.required
|
|
460
|
+
? "not installed — required"
|
|
461
|
+
: "not installed — optional"
|
|
462
|
+
: "installed, not usable";
|
|
463
|
+
|
|
464
|
+
return (
|
|
465
|
+
<View style={{ gap: 2 }}>
|
|
466
|
+
<Text style={styles.body}>
|
|
467
|
+
<Text style={{ color: tone }}>{dependency.state === "ok" ? "● " : "▲ "}</Text>
|
|
468
|
+
{dependency.name} — {summary}
|
|
469
|
+
</Text>
|
|
470
|
+
{dependency.path === null ? null : <Text style={styles.muted}>{dependency.path}</Text>}
|
|
471
|
+
{dependency.detail === "" ? null : (
|
|
472
|
+
<Text style={styles.muted}>{dependency.detail}</Text>
|
|
473
|
+
)}
|
|
474
|
+
{dependency.hint === "" ? null : <Text style={styles.mono}>{dependency.hint}</Text>}
|
|
475
|
+
</View>
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function RecentSendRow({
|
|
480
|
+
send,
|
|
481
|
+
styles,
|
|
482
|
+
onOpen,
|
|
483
|
+
}: {
|
|
484
|
+
send: RecentSend;
|
|
485
|
+
styles: Styles;
|
|
486
|
+
onOpen: ((agentId: string) => void) | null;
|
|
487
|
+
}) {
|
|
488
|
+
const meta = [
|
|
489
|
+
send.workspaceLabel,
|
|
490
|
+
send.branch ?? "no branch",
|
|
491
|
+
send.workspaceCreated ? "new worktree" : null,
|
|
492
|
+
send.dryRun ? "dry run" : null,
|
|
493
|
+
formatWhen(send.at),
|
|
494
|
+
]
|
|
495
|
+
.filter((part): part is string => part !== null && part !== "")
|
|
496
|
+
.join(" · ");
|
|
497
|
+
|
|
498
|
+
const body = (
|
|
499
|
+
<View style={styles.listRow}>
|
|
500
|
+
<Text style={styles.body}>
|
|
501
|
+
{send.outcome === "ok" ? "" : "Failed — "}
|
|
502
|
+
{send.prLabel} · {send.title}
|
|
503
|
+
</Text>
|
|
504
|
+
<Text style={styles.muted}>{meta}</Text>
|
|
505
|
+
{send.error === null ? null : <Text style={styles.danger}>{send.error}</Text>}
|
|
506
|
+
</View>
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
if (send.agentId === null || onOpen === null) return body;
|
|
510
|
+
const agentId = send.agentId;
|
|
511
|
+
return (
|
|
512
|
+
<Pressable
|
|
513
|
+
accessibilityRole="button"
|
|
514
|
+
accessibilityLabel={`Open the agent for ${send.prLabel}`}
|
|
515
|
+
onPress={() => onOpen(agentId)}
|
|
516
|
+
>
|
|
517
|
+
{body}
|
|
518
|
+
</Pressable>
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export function SendToPaseoSettings({ theme, host, layout, navigation }: PluginSurfaceProps) {
|
|
523
|
+
const styles = useStyles(theme, layout.compact);
|
|
524
|
+
const toast = useToast();
|
|
525
|
+
const queryClient = useQueryClient();
|
|
526
|
+
const paseoHosts = useHosts();
|
|
527
|
+
|
|
528
|
+
const fetchStatus = useRpc(getStatus);
|
|
529
|
+
const reveal = useRpc(revealToken);
|
|
530
|
+
const regenerate = useRpc(regenerateToken);
|
|
531
|
+
const update = useRpc(updateConfig);
|
|
532
|
+
const clearRecent = useRpc(clearRecentSends);
|
|
533
|
+
const addMachine = useRpc(addAdditionalMachine);
|
|
534
|
+
const updateMachine = useRpc(updateAdditionalMachine);
|
|
535
|
+
const removeMachine = useRpc(removeAdditionalMachine);
|
|
536
|
+
const testMachine = useRpc(testAdditionalMachine);
|
|
537
|
+
const connectionCode = useRpc(getConnectionCode);
|
|
538
|
+
const enableAccess = useRpc(enablePrivateAccess);
|
|
539
|
+
|
|
540
|
+
const [revealed, setRevealed] = useState<string | null>(null);
|
|
541
|
+
const [portDraft, setPortDraft] = useState<string | null>(null);
|
|
542
|
+
const [externalUrlDraft, setExternalUrlDraft] = useState<string | null>(null);
|
|
543
|
+
const [connectionCodeDraft, setConnectionCodeDraft] = useState("");
|
|
544
|
+
const [sharedCode, setSharedCode] = useState<string | null>(null);
|
|
545
|
+
const [showConnectionDetails, setShowConnectionDetails] = useState(false);
|
|
546
|
+
const [showAgentDefaults, setShowAgentDefaults] = useState(false);
|
|
547
|
+
const [showAdvancedAccess, setShowAdvancedAccess] = useState(false);
|
|
548
|
+
const [machineTests, setMachineTests] = useState<Record<string, string>>({});
|
|
549
|
+
const [hostChecks, setHostChecks] = useState<Record<string, string>>({});
|
|
550
|
+
|
|
551
|
+
const query = useQuery({
|
|
552
|
+
queryKey: [...QUERY_KEY, host.id],
|
|
553
|
+
queryFn: () => fetchStatus({ serverId: host.id }),
|
|
554
|
+
refetchInterval: 5_000,
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
const invalidate = () => void queryClient.invalidateQueries({ queryKey: QUERY_KEY });
|
|
558
|
+
|
|
559
|
+
const savePort = useMutation({
|
|
560
|
+
mutationFn: async (port: number) => update({ serverId: host.id, port }),
|
|
561
|
+
onSuccess: (result) => {
|
|
562
|
+
setPortDraft(null);
|
|
563
|
+
invalidate();
|
|
564
|
+
if (result.error !== null) toast.error(result.error);
|
|
565
|
+
else toast.show(`Bridge now on port ${result.status.port}`, { variant: "success" });
|
|
566
|
+
},
|
|
567
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
const saveProvider = useMutation({
|
|
571
|
+
mutationFn: async (defaultProvider: string | null) =>
|
|
572
|
+
update({ serverId: host.id, defaultProvider }),
|
|
573
|
+
onSuccess: () => {
|
|
574
|
+
invalidate();
|
|
575
|
+
toast.show("Default model saved", { variant: "success" });
|
|
576
|
+
},
|
|
577
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
const saveDispatch = useMutation({
|
|
581
|
+
mutationFn: async (agentDispatch: "new" | "main") =>
|
|
582
|
+
update({ serverId: host.id, agentDispatch }),
|
|
583
|
+
onSuccess: () => {
|
|
584
|
+
invalidate();
|
|
585
|
+
toast.show("Agent destination saved", { variant: "success" });
|
|
586
|
+
},
|
|
587
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
const saveExternalUrl = useMutation({
|
|
591
|
+
mutationFn: async (externalBridgeUrl: string | null) =>
|
|
592
|
+
update({ serverId: host.id, externalBridgeUrl }),
|
|
593
|
+
onSuccess: (result) => {
|
|
594
|
+
setExternalUrlDraft(null);
|
|
595
|
+
invalidate();
|
|
596
|
+
toast.show(
|
|
597
|
+
result.status.externalBridgeUrl === null
|
|
598
|
+
? "Private bridge access disabled"
|
|
599
|
+
: "Private bridge address saved",
|
|
600
|
+
{ variant: "success" },
|
|
601
|
+
);
|
|
602
|
+
},
|
|
603
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
const saveProfile = useMutation({
|
|
607
|
+
mutationFn: async (defaultProfileId: string | null) =>
|
|
608
|
+
update({ serverId: host.id, defaultProfileId }),
|
|
609
|
+
onSuccess: () => {
|
|
610
|
+
invalidate();
|
|
611
|
+
toast.show("Profile saved", { variant: "success" });
|
|
612
|
+
},
|
|
613
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
const saveMode = useMutation({
|
|
617
|
+
mutationFn: async (defaultModeId: string | null) =>
|
|
618
|
+
update({ serverId: host.id, defaultModeId }),
|
|
619
|
+
onSuccess: () => {
|
|
620
|
+
invalidate();
|
|
621
|
+
toast.show("Default permission mode saved", { variant: "success" });
|
|
622
|
+
},
|
|
623
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
const rotate = useMutation({
|
|
627
|
+
mutationFn: async () => regenerate({ serverId: host.id }),
|
|
628
|
+
onSuccess: (result) => {
|
|
629
|
+
setRevealed(result.token);
|
|
630
|
+
invalidate();
|
|
631
|
+
toast.show("New token generated. Paste it into the extension options.", {
|
|
632
|
+
variant: "warning",
|
|
633
|
+
});
|
|
634
|
+
},
|
|
635
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
const connectMachine = useMutation({
|
|
639
|
+
mutationFn: async (code: string) =>
|
|
640
|
+
addMachine({ serverId: host.id, connectionCode: code }),
|
|
641
|
+
onSuccess: (result) => {
|
|
642
|
+
setConnectionCodeDraft("");
|
|
643
|
+
invalidate();
|
|
644
|
+
toast.show(
|
|
645
|
+
`Connected ${result.machine.label || result.machine.machineName || "additional Paseo machine"}`,
|
|
646
|
+
{ variant: "success" },
|
|
647
|
+
);
|
|
648
|
+
},
|
|
649
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
const enableAccessMutation = useMutation({
|
|
653
|
+
mutationFn: async () => enableAccess({ serverId: host.id }),
|
|
654
|
+
onSuccess: (result) => {
|
|
655
|
+
if (!result.ready || result.code === null) {
|
|
656
|
+
toast.error(result.error ?? "Private access could not be enabled.");
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
setSharedCode(result.code);
|
|
660
|
+
invalidate();
|
|
661
|
+
toast.show("Private access enabled. Connection code is ready.", { variant: "success" });
|
|
662
|
+
},
|
|
663
|
+
onError: (error: unknown) => toast.error(error instanceof Error ? error.message : String(error)),
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
const status = query.data?.status ?? null;
|
|
667
|
+
const providers = query.data?.providers ?? [];
|
|
668
|
+
const providersError = query.data?.providersError ?? null;
|
|
669
|
+
const modes = query.data?.modes ?? [];
|
|
670
|
+
const profiles = query.data?.profiles ?? [];
|
|
671
|
+
const profilesError = query.data?.profilesError ?? null;
|
|
672
|
+
const recent = query.data?.recentSends ?? [];
|
|
673
|
+
const dependencies = query.data?.dependencies ?? [];
|
|
674
|
+
const additionalMachines = query.data?.additionalMachines ?? [];
|
|
675
|
+
const hostDiscovery = useMemo(
|
|
676
|
+
() => organizeDiscoveredHosts(paseoHosts, host.id, additionalMachines),
|
|
677
|
+
[paseoHosts, host.id, additionalMachines],
|
|
678
|
+
);
|
|
679
|
+
const selectedProvider =
|
|
680
|
+
status?.defaultProvider ?? providers.find((provider) => provider.isDefault)?.id ?? null;
|
|
681
|
+
const selectedProfileId = status?.defaultProfileId ?? null;
|
|
682
|
+
const selectedProfile = profiles.find((profile) => profile.id === selectedProfileId) ?? null;
|
|
683
|
+
|
|
684
|
+
async function onReveal() {
|
|
685
|
+
if (revealed !== null) {
|
|
686
|
+
setRevealed(null);
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
try {
|
|
690
|
+
const result = await reveal({ serverId: host.id });
|
|
691
|
+
setRevealed(result.token);
|
|
692
|
+
} catch (error) {
|
|
693
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
async function onCopy() {
|
|
698
|
+
try {
|
|
699
|
+
const token = revealed ?? (await reveal({ serverId: host.id })).token;
|
|
700
|
+
const copied = await copyToClipboard(token);
|
|
701
|
+
if (copied) {
|
|
702
|
+
toast.show("Token copied", { variant: "success" });
|
|
703
|
+
} else {
|
|
704
|
+
setRevealed(token);
|
|
705
|
+
toast.show("Copy is unavailable here; the token is shown so you can copy it.", {
|
|
706
|
+
variant: "info",
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
} catch (error) {
|
|
710
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
async function onCopyValue(value: string, label: string) {
|
|
715
|
+
if (await copyToClipboard(value)) toast.show(`${label} copied`, { variant: "success" });
|
|
716
|
+
else toast.error("Copy is unavailable here.");
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
async function onCopyConnectionCode() {
|
|
720
|
+
try {
|
|
721
|
+
const result = await connectionCode({ serverId: host.id });
|
|
722
|
+
if (!result.ready || result.code === null) {
|
|
723
|
+
toast.error(result.error ?? "Enable private access first.");
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
setSharedCode(result.code);
|
|
727
|
+
await onCopyValue(result.code, "Connection code");
|
|
728
|
+
} catch (error) {
|
|
729
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
async function onTestMachine(machine: AdditionalMachine) {
|
|
734
|
+
setMachineTests((current) => ({ ...current, [machine.id]: "Testing…" }));
|
|
735
|
+
try {
|
|
736
|
+
const result = await testMachine({ serverId: host.id, id: machine.id });
|
|
737
|
+
setMachineTests((current) => ({ ...current, [machine.id]: result.detail }));
|
|
738
|
+
invalidate();
|
|
739
|
+
if (result.ok) toast.show("Additional machine connected", { variant: "success" });
|
|
740
|
+
else toast.error(result.detail);
|
|
741
|
+
} catch (error) {
|
|
742
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
743
|
+
setMachineTests((current) => ({ ...current, [machine.id]: detail }));
|
|
744
|
+
toast.error(detail);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
async function onCheckHost(target: DiscoveredHostRow) {
|
|
749
|
+
setHostChecks((current) => ({ ...current, [target.serverId]: "Checking…" }));
|
|
750
|
+
try {
|
|
751
|
+
const projectCount = await checkHostAccess(target.serverId, getPaseoClient);
|
|
752
|
+
const detail = `Paseo access verified · ${projectCount} project${projectCount === 1 ? "" : "s"}`;
|
|
753
|
+
setHostChecks((current) => ({ ...current, [target.serverId]: detail }));
|
|
754
|
+
toast.show(`${target.label}: Paseo access verified`, { variant: "success" });
|
|
755
|
+
} catch (error) {
|
|
756
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
757
|
+
setHostChecks((current) => ({ ...current, [target.serverId]: detail }));
|
|
758
|
+
toast.error(detail);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
return (
|
|
763
|
+
<ScrollView style={styles.screen} contentContainerStyle={styles.content}>
|
|
764
|
+
<View style={{ gap: 4 }}>
|
|
765
|
+
<Text style={styles.title}>Send to Paseo</Text>
|
|
766
|
+
<Text style={styles.muted}>
|
|
767
|
+
Send pull-request work to the right Paseo workspace.
|
|
768
|
+
</Text>
|
|
769
|
+
</View>
|
|
770
|
+
|
|
771
|
+
<View style={styles.card}>
|
|
772
|
+
<Text style={styles.heading}>Connection</Text>
|
|
773
|
+
{status === null ? (
|
|
774
|
+
<Text style={styles.muted}>{query.isError ? "Status unavailable." : "Loading…"}</Text>
|
|
775
|
+
) : (
|
|
776
|
+
<>
|
|
777
|
+
<Text style={{ ...styles.body, color: stateTone(status, theme) }}>
|
|
778
|
+
{stateLabel(status)}
|
|
779
|
+
</Text>
|
|
780
|
+
{status.error === null ? null : <Text style={styles.danger}>{status.error}</Text>}
|
|
781
|
+
<Text style={styles.muted}>
|
|
782
|
+
{hostDiscovery.hosts.length} Paseo machine
|
|
783
|
+
{hostDiscovery.hosts.length === 1 ? "" : "s"} discovered automatically.
|
|
784
|
+
</Text>
|
|
785
|
+
<Button
|
|
786
|
+
label={showConnectionDetails ? "Hide connection details" : "Advanced connection details"}
|
|
787
|
+
styles={styles}
|
|
788
|
+
onPress={() => setShowConnectionDetails(!showConnectionDetails)}
|
|
789
|
+
/>
|
|
790
|
+
{showConnectionDetails ? (
|
|
791
|
+
<View style={{ gap: 8 }}>
|
|
792
|
+
<Text style={styles.muted}>
|
|
793
|
+
{status.paired ? "Paired" : "Not yet paired"} · {status.requestCount} request
|
|
794
|
+
{status.requestCount === 1 ? "" : "s"} · last {formatWhen(status.lastRequestAt)}
|
|
795
|
+
</Text>
|
|
796
|
+
<Text style={styles.muted}>
|
|
797
|
+
Daemon{" "}
|
|
798
|
+
{status.daemon.reachable
|
|
799
|
+
? `reachable (${status.daemon.version ?? "unknown"})`
|
|
800
|
+
: "unreachable"}
|
|
801
|
+
{status.dryRun ? " · dry run enabled" : ""}
|
|
802
|
+
</Text>
|
|
803
|
+
<View style={styles.row}>
|
|
804
|
+
<Text style={styles.muted}>Port</Text>
|
|
805
|
+
<TextInput
|
|
806
|
+
value={portDraft ?? String(status.configuredPort)}
|
|
807
|
+
onChangeText={setPortDraft}
|
|
808
|
+
keyboardType="number-pad"
|
|
809
|
+
style={styles.input}
|
|
810
|
+
accessibilityLabel="Bridge port"
|
|
811
|
+
/>
|
|
812
|
+
<Button
|
|
813
|
+
label="Save"
|
|
814
|
+
styles={styles}
|
|
815
|
+
primary
|
|
816
|
+
disabled={portDraft === null || savePort.isPending}
|
|
817
|
+
onPress={() => {
|
|
818
|
+
const parsed = Number(portDraft);
|
|
819
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65535) {
|
|
820
|
+
toast.error("Enter a port between 1 and 65535.");
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
savePort.mutate(parsed);
|
|
824
|
+
}}
|
|
825
|
+
/>
|
|
826
|
+
</View>
|
|
827
|
+
</View>
|
|
828
|
+
) : null}
|
|
829
|
+
</>
|
|
830
|
+
)}
|
|
831
|
+
</View>
|
|
832
|
+
|
|
833
|
+
{showConnectionDetails ? (
|
|
834
|
+
<>
|
|
835
|
+
<View style={styles.card}>
|
|
836
|
+
<Text style={styles.heading}>Paseo machines</Text>
|
|
837
|
+
<Text style={styles.muted}>
|
|
838
|
+
Discovered automatically from Paseo 0.9. Offline configured hosts stay visible. “Check
|
|
839
|
+
Paseo access” borrows that exact host's authenticated app connection; it never falls
|
|
840
|
+
back to this screen's host.
|
|
841
|
+
</Text>
|
|
842
|
+
{hostDiscovery.hosts.length === 0 ? (
|
|
843
|
+
<Text style={styles.muted}>No Paseo hosts are configured in this app.</Text>
|
|
844
|
+
) : (
|
|
845
|
+
hostDiscovery.hosts.map((target) => (
|
|
846
|
+
<View key={target.serverId} style={styles.listRow}>
|
|
847
|
+
<Text style={styles.body}>
|
|
848
|
+
{target.label}
|
|
849
|
+
{target.isSurfaceHost ? " — this screen" : ""}
|
|
850
|
+
</Text>
|
|
851
|
+
<Text style={{ ...styles.muted, color: hostStatusTone(target.status, theme) }}>
|
|
852
|
+
{target.status}
|
|
853
|
+
</Text>
|
|
854
|
+
<Text style={styles.mono}>{target.serverId}</Text>
|
|
855
|
+
<Text style={styles.muted}>
|
|
856
|
+
{target.isSurfaceHost
|
|
857
|
+
? "Browser route: this plugin's loopback bridge."
|
|
858
|
+
: target.route === null
|
|
859
|
+
? "Discovered by Paseo; not connected to this browser bridge yet."
|
|
860
|
+
: `Browser route: ${target.route.enabled ? "connected" : "disabled"} · ${target.route.bridgeUrl}`}
|
|
861
|
+
</Text>
|
|
862
|
+
{hostChecks[target.serverId] === undefined ? null : (
|
|
863
|
+
<Text style={styles.muted}>{hostChecks[target.serverId]}</Text>
|
|
864
|
+
)}
|
|
865
|
+
<Button
|
|
866
|
+
label={target.status === "online" ? "Check Paseo access" : `Unavailable (${target.status})`}
|
|
867
|
+
styles={styles}
|
|
868
|
+
disabled={target.status !== "online" || hostChecks[target.serverId] === "Checking…"}
|
|
869
|
+
onPress={() => void onCheckHost(target)}
|
|
870
|
+
/>
|
|
871
|
+
</View>
|
|
872
|
+
))
|
|
873
|
+
)}
|
|
874
|
+
<Text style={styles.muted}>
|
|
875
|
+
Paseo discovery does not expose bridge URLs or pairing tokens. To make another host a
|
|
876
|
+
browser target, copy its Send to Paseo connection code and paste it here.
|
|
877
|
+
</Text>
|
|
878
|
+
<TextInput
|
|
879
|
+
value={connectionCodeDraft}
|
|
880
|
+
onChangeText={setConnectionCodeDraft}
|
|
881
|
+
placeholder="Paste stp1_… connection code"
|
|
882
|
+
style={styles.input}
|
|
883
|
+
autoCapitalize="none"
|
|
884
|
+
autoCorrect={false}
|
|
885
|
+
accessibilityLabel="Additional Paseo machine connection code"
|
|
886
|
+
/>
|
|
887
|
+
<Button
|
|
888
|
+
label={connectMachine.isPending ? "Connecting…" : "Connect additional machine"}
|
|
889
|
+
styles={styles}
|
|
890
|
+
primary
|
|
891
|
+
disabled={connectionCodeDraft.trim() === "" || connectMachine.isPending}
|
|
892
|
+
onPress={() => connectMachine.mutate(connectionCodeDraft)}
|
|
893
|
+
/>
|
|
894
|
+
<Text style={styles.heading}>Browser bridge routes</Text>
|
|
895
|
+
{additionalMachines.length === 0 ? (
|
|
896
|
+
<Text style={styles.muted}>No additional browser routes connected yet.</Text>
|
|
897
|
+
) : (
|
|
898
|
+
additionalMachines.map((machine) => (
|
|
899
|
+
<View key={machine.id} style={styles.listRow}>
|
|
900
|
+
<Text style={styles.body}>
|
|
901
|
+
{machine.label || machine.machineName || new URL(machine.bridgeUrl).host}
|
|
902
|
+
{machine.enabled ? "" : " — disabled"}
|
|
903
|
+
</Text>
|
|
904
|
+
<Text style={styles.mono}>
|
|
905
|
+
{machine.serverId ?? "Server ID pending first successful check"}
|
|
906
|
+
</Text>
|
|
907
|
+
<Text style={styles.muted}>{machine.bridgeUrl}</Text>
|
|
908
|
+
<Text style={styles.muted}>Token {machine.tokenPreview}</Text>
|
|
909
|
+
{machineTests[machine.id] === undefined ? null : (
|
|
910
|
+
<Text style={styles.muted}>{machineTests[machine.id]}</Text>
|
|
911
|
+
)}
|
|
912
|
+
<View style={styles.wrapRow}>
|
|
913
|
+
<Button
|
|
914
|
+
label="Test"
|
|
915
|
+
styles={styles}
|
|
916
|
+
onPress={() => void onTestMachine(machine)}
|
|
917
|
+
/>
|
|
918
|
+
<Button
|
|
919
|
+
label={machine.enabled ? "Disable" : "Enable"}
|
|
920
|
+
styles={styles}
|
|
921
|
+
onPress={() =>
|
|
922
|
+
void updateMachine({
|
|
923
|
+
serverId: host.id,
|
|
924
|
+
id: machine.id,
|
|
925
|
+
enabled: !machine.enabled,
|
|
926
|
+
})
|
|
927
|
+
.then(invalidate)
|
|
928
|
+
.catch((error: unknown) =>
|
|
929
|
+
toast.error(error instanceof Error ? error.message : String(error)),
|
|
930
|
+
)
|
|
931
|
+
}
|
|
932
|
+
/>
|
|
933
|
+
<Button
|
|
934
|
+
label="Remove"
|
|
935
|
+
styles={styles}
|
|
936
|
+
onPress={() =>
|
|
937
|
+
void removeMachine({ serverId: host.id, id: machine.id })
|
|
938
|
+
.then(invalidate)
|
|
939
|
+
.catch((error: unknown) =>
|
|
940
|
+
toast.error(error instanceof Error ? error.message : String(error)),
|
|
941
|
+
)
|
|
942
|
+
}
|
|
943
|
+
/>
|
|
944
|
+
</View>
|
|
945
|
+
</View>
|
|
946
|
+
))
|
|
947
|
+
)}
|
|
948
|
+
{hostDiscovery.undiscoveredRoutes.length === 0 ? null : (
|
|
949
|
+
<Text style={styles.muted}>
|
|
950
|
+
{hostDiscovery.undiscoveredRoutes.length} route
|
|
951
|
+
{hostDiscovery.undiscoveredRoutes.length === 1 ? " is" : "s are"} retained for browser
|
|
952
|
+
compatibility but not currently present in Paseo's configured host list. Check or
|
|
953
|
+
remove {hostDiscovery.undiscoveredRoutes.length === 1 ? "it" : "them"} above.
|
|
954
|
+
</Text>
|
|
955
|
+
)}
|
|
956
|
+
</View>
|
|
957
|
+
|
|
958
|
+
<View style={styles.card}>
|
|
959
|
+
<Text style={styles.heading}>Share this Paseo machine</Text>
|
|
960
|
+
<Text style={styles.muted}>
|
|
961
|
+
This is needed only for browser bridge routing; Paseo host discovery itself is automatic.
|
|
962
|
+
“Enable private access” runs Tailscale Serve on this machine, then creates one secret
|
|
963
|
+
connection code containing its server ID, private bridge address and pairing token.
|
|
964
|
+
</Text>
|
|
965
|
+
<View style={styles.wrapRow}>
|
|
966
|
+
<Button
|
|
967
|
+
label={enableAccessMutation.isPending ? "Enabling…" : "Enable private access"}
|
|
968
|
+
styles={styles}
|
|
969
|
+
primary
|
|
970
|
+
disabled={enableAccessMutation.isPending}
|
|
971
|
+
onPress={() => enableAccessMutation.mutate()}
|
|
972
|
+
/>
|
|
973
|
+
<Button label="Copy connection code" styles={styles} onPress={() => void onCopyConnectionCode()} />
|
|
974
|
+
</View>
|
|
975
|
+
{sharedCode === null ? null : (
|
|
976
|
+
<View style={styles.tokenBox}>
|
|
977
|
+
<Text style={styles.mono} selectable>{sharedCode}</Text>
|
|
978
|
+
</View>
|
|
979
|
+
)}
|
|
980
|
+
<Text style={styles.muted}>
|
|
981
|
+
The code is a secret: anyone who has it can start Paseo agents on this machine.
|
|
982
|
+
</Text>
|
|
983
|
+
<Button
|
|
984
|
+
label={showAdvancedAccess ? "Hide advanced setup" : "Advanced: configure private access manually"}
|
|
985
|
+
styles={styles}
|
|
986
|
+
onPress={() => setShowAdvancedAccess(!showAdvancedAccess)}
|
|
987
|
+
/>
|
|
988
|
+
{showAdvancedAccess ? (
|
|
989
|
+
<View style={{ gap: 8 }}>
|
|
990
|
+
<Text style={styles.muted}>
|
|
991
|
+
Run this command in a terminal on this Paseo machine, then paste the HTTPS .ts.net
|
|
992
|
+
address it prints below. Do not use a cloud .internal name or a 100.x IP over HTTP.
|
|
993
|
+
</Text>
|
|
994
|
+
<View style={styles.tokenBox}>
|
|
995
|
+
<Text style={styles.mono} selectable>
|
|
996
|
+
{`tailscale serve --bg ${status?.configuredPort ?? DEFAULT_PORT}`}
|
|
997
|
+
</Text>
|
|
998
|
+
</View>
|
|
999
|
+
<Button
|
|
1000
|
+
label="Copy command"
|
|
1001
|
+
styles={styles}
|
|
1002
|
+
onPress={() => void onCopyValue(`tailscale serve --bg ${status?.configuredPort ?? DEFAULT_PORT}`, "Command")}
|
|
1003
|
+
/>
|
|
1004
|
+
<TextInput
|
|
1005
|
+
value={externalUrlDraft ?? status?.externalBridgeUrl ?? ""}
|
|
1006
|
+
onChangeText={setExternalUrlDraft}
|
|
1007
|
+
placeholder="https://devbox.example.ts.net"
|
|
1008
|
+
style={styles.input}
|
|
1009
|
+
autoCapitalize="none"
|
|
1010
|
+
autoCorrect={false}
|
|
1011
|
+
keyboardType="url"
|
|
1012
|
+
accessibilityLabel="Private bridge address"
|
|
1013
|
+
/>
|
|
1014
|
+
<Button
|
|
1015
|
+
label={saveExternalUrl.isPending ? "Saving…" : "Save private bridge address"}
|
|
1016
|
+
styles={styles}
|
|
1017
|
+
disabled={externalUrlDraft === null || saveExternalUrl.isPending}
|
|
1018
|
+
onPress={() => {
|
|
1019
|
+
const value = externalUrlDraft?.trim() ?? "";
|
|
1020
|
+
if (value === "") return saveExternalUrl.mutate(null);
|
|
1021
|
+
const problem = externalBridgeUrlProblem(value);
|
|
1022
|
+
if (problem !== null) return toast.error(problem);
|
|
1023
|
+
saveExternalUrl.mutate(value);
|
|
1024
|
+
}}
|
|
1025
|
+
/>
|
|
1026
|
+
</View>
|
|
1027
|
+
) : null}
|
|
1028
|
+
</View>
|
|
1029
|
+
</>
|
|
1030
|
+
) : null}
|
|
1031
|
+
|
|
1032
|
+
{/*
|
|
1033
|
+
The most discoverable place to learn that gh is missing. Sending works
|
|
1034
|
+
without it, so this reads as information rather than as a failure — the
|
|
1035
|
+
card only turns loud for a dependency that is actually required.
|
|
1036
|
+
*/}
|
|
1037
|
+
{showConnectionDetails || dependencies.some((dependency) => dependency.state !== "ok") ? (
|
|
1038
|
+
<View style={styles.card}>
|
|
1039
|
+
<Text style={styles.heading}>Requirements</Text>
|
|
1040
|
+
{dependencies.length === 0 ? (
|
|
1041
|
+
<Text style={styles.muted}>{query.isError ? "Unavailable." : "Checking…"}</Text>
|
|
1042
|
+
) : (
|
|
1043
|
+
dependencies.map((dependency) => (
|
|
1044
|
+
<DependencyRow
|
|
1045
|
+
key={dependency.name}
|
|
1046
|
+
dependency={dependency}
|
|
1047
|
+
styles={styles}
|
|
1048
|
+
theme={theme}
|
|
1049
|
+
/>
|
|
1050
|
+
))
|
|
1051
|
+
)}
|
|
1052
|
+
</View>
|
|
1053
|
+
) : null}
|
|
1054
|
+
|
|
1055
|
+
<View style={styles.card}>
|
|
1056
|
+
<Text style={styles.heading}>Pairing token</Text>
|
|
1057
|
+
<Text style={styles.muted}>
|
|
1058
|
+
Paste this into the extension options page. It is the only thing standing between a web
|
|
1059
|
+
page and an agent on this machine, so treat it like a password.
|
|
1060
|
+
</Text>
|
|
1061
|
+
<View style={styles.tokenBox}>
|
|
1062
|
+
<Text style={styles.mono} selectable>
|
|
1063
|
+
{revealed ?? status?.tokenPreview ?? "…"}
|
|
1064
|
+
</Text>
|
|
1065
|
+
</View>
|
|
1066
|
+
<View style={styles.wrapRow}>
|
|
1067
|
+
<Button
|
|
1068
|
+
label={revealed === null ? "Reveal" : "Hide"}
|
|
1069
|
+
styles={styles}
|
|
1070
|
+
onPress={() => void onReveal()}
|
|
1071
|
+
/>
|
|
1072
|
+
<Button label="Copy" styles={styles} onPress={() => void onCopy()} />
|
|
1073
|
+
<Button
|
|
1074
|
+
label={rotate.isPending ? "Regenerating…" : "Regenerate"}
|
|
1075
|
+
styles={styles}
|
|
1076
|
+
disabled={rotate.isPending}
|
|
1077
|
+
onPress={() => rotate.mutate()}
|
|
1078
|
+
/>
|
|
1079
|
+
</View>
|
|
1080
|
+
</View>
|
|
1081
|
+
|
|
1082
|
+
<View style={styles.card}>
|
|
1083
|
+
<Text style={styles.heading}>Agent destination</Text>
|
|
1084
|
+
<Text style={styles.muted}>
|
|
1085
|
+
Choose whether each send starts fresh or continues the workspace's main agent.
|
|
1086
|
+
</Text>
|
|
1087
|
+
<Pressable
|
|
1088
|
+
accessibilityRole="button"
|
|
1089
|
+
accessibilityLabel="Start a new agent for every send"
|
|
1090
|
+
onPress={() => saveDispatch.mutate("new")}
|
|
1091
|
+
style={(status?.agentDispatch ?? "new") === "new" ? styles.selectedRow : undefined}
|
|
1092
|
+
>
|
|
1093
|
+
<View style={{ paddingVertical: 6 }}>
|
|
1094
|
+
<Text style={styles.body}>
|
|
1095
|
+
{(status?.agentDispatch ?? "new") === "new" ? "● " : "○ "}New agent
|
|
1096
|
+
</Text>
|
|
1097
|
+
<Text style={styles.muted}>Start a separate agent for every send.</Text>
|
|
1098
|
+
</View>
|
|
1099
|
+
</Pressable>
|
|
1100
|
+
<Pressable
|
|
1101
|
+
accessibilityRole="button"
|
|
1102
|
+
accessibilityLabel="Continue the main agent in the target workspace"
|
|
1103
|
+
onPress={() => saveDispatch.mutate("main")}
|
|
1104
|
+
style={status?.agentDispatch === "main" ? styles.selectedRow : undefined}
|
|
1105
|
+
>
|
|
1106
|
+
<View style={{ paddingVertical: 6 }}>
|
|
1107
|
+
<Text style={styles.body}>
|
|
1108
|
+
{status?.agentDispatch === "main" ? "● " : "○ "}Main workspace agent
|
|
1109
|
+
</Text>
|
|
1110
|
+
<Text style={styles.muted}>
|
|
1111
|
+
Reuse the best root agent in that workspace. Prefers one named Main, then an open,
|
|
1112
|
+
active, or recently used agent; subagents are ignored. Starts fresh if none exists.
|
|
1113
|
+
</Text>
|
|
1114
|
+
</View>
|
|
1115
|
+
</Pressable>
|
|
1116
|
+
{status?.agentDispatch === "main" ? (
|
|
1117
|
+
<View style={{ gap: 6 }}>
|
|
1118
|
+
<Text style={styles.muted}>
|
|
1119
|
+
Profile, model, and permission defaults only apply if no main agent exists.
|
|
1120
|
+
</Text>
|
|
1121
|
+
<Button
|
|
1122
|
+
label={showAgentDefaults ? "Hide fallback agent defaults" : "Fallback new-agent defaults"}
|
|
1123
|
+
styles={styles}
|
|
1124
|
+
onPress={() => setShowAgentDefaults(!showAgentDefaults)}
|
|
1125
|
+
/>
|
|
1126
|
+
</View>
|
|
1127
|
+
) : null}
|
|
1128
|
+
</View>
|
|
1129
|
+
|
|
1130
|
+
{(status?.agentDispatch ?? "new") === "new" || showAgentDefaults ? (
|
|
1131
|
+
<>
|
|
1132
|
+
<View style={styles.card}>
|
|
1133
|
+
<Text style={styles.heading}>Agent profile</Text>
|
|
1134
|
+
<Text style={styles.muted}>
|
|
1135
|
+
Follow one of your saved Paseo profiles. Its model, permission mode and thinking option
|
|
1136
|
+
are re-read on every send, so editing it in Paseo changes what this plugin does next —
|
|
1137
|
+
there is nothing to copy back here.
|
|
1138
|
+
</Text>
|
|
1139
|
+
{profilesError === null ? null : <Text style={styles.danger}>{profilesError}</Text>}
|
|
1140
|
+
<ProfilePicker
|
|
1141
|
+
profiles={profiles}
|
|
1142
|
+
selected={selectedProfileId}
|
|
1143
|
+
onSelect={(id) => saveProfile.mutate(id)}
|
|
1144
|
+
styles={styles}
|
|
1145
|
+
/>
|
|
1146
|
+
</View>
|
|
1147
|
+
|
|
1148
|
+
<View style={styles.card}>
|
|
1149
|
+
<Text style={styles.heading}>Default permission mode</Text>
|
|
1150
|
+
<Text style={styles.muted}>
|
|
1151
|
+
Used when a send does not pick one and the followed profile does not set one. Mode ids
|
|
1152
|
+
belong to a provider, so a mode the chosen provider does not offer is skipped rather than
|
|
1153
|
+
failing the send.
|
|
1154
|
+
</Text>
|
|
1155
|
+
{selectedProfile?.modeId === null || selectedProfile === null ? null : (
|
|
1156
|
+
<Text style={styles.muted}>
|
|
1157
|
+
The {selectedProfile.name} profile sets mode {selectedProfile.modeId}, which wins over
|
|
1158
|
+
this.
|
|
1159
|
+
</Text>
|
|
1160
|
+
)}
|
|
1161
|
+
<ModePicker
|
|
1162
|
+
modes={modes}
|
|
1163
|
+
selected={status?.defaultModeId ?? null}
|
|
1164
|
+
onSelect={(id) => saveMode.mutate(id)}
|
|
1165
|
+
styles={styles}
|
|
1166
|
+
theme={theme}
|
|
1167
|
+
/>
|
|
1168
|
+
</View>
|
|
1169
|
+
|
|
1170
|
+
<View style={styles.card}>
|
|
1171
|
+
<Text style={styles.heading}>Default model</Text>
|
|
1172
|
+
<Text style={styles.muted}>
|
|
1173
|
+
Used when a send does not pick one. {selectedProvider ?? "Following the daemon default."}
|
|
1174
|
+
</Text>
|
|
1175
|
+
{selectedProfile === null || selectedProfile.model === null ? null : (
|
|
1176
|
+
<Text style={styles.muted}>
|
|
1177
|
+
The {selectedProfile.name} profile selects {selectedProfile.provider}/
|
|
1178
|
+
{selectedProfile.model}, which wins over this.
|
|
1179
|
+
</Text>
|
|
1180
|
+
)}
|
|
1181
|
+
{providersError === null ? null : <Text style={styles.danger}>{providersError}</Text>}
|
|
1182
|
+
<ProviderPicker
|
|
1183
|
+
providers={providers}
|
|
1184
|
+
selected={selectedProvider}
|
|
1185
|
+
onSelect={(id) => saveProvider.mutate(id)}
|
|
1186
|
+
styles={styles}
|
|
1187
|
+
/>
|
|
1188
|
+
{status?.defaultProvider === null || status === null ? null : (
|
|
1189
|
+
<Button
|
|
1190
|
+
label="Follow the daemon default"
|
|
1191
|
+
styles={styles}
|
|
1192
|
+
onPress={() => saveProvider.mutate(null)}
|
|
1193
|
+
/>
|
|
1194
|
+
)}
|
|
1195
|
+
</View>
|
|
1196
|
+
</>
|
|
1197
|
+
) : null}
|
|
1198
|
+
|
|
1199
|
+
<View style={styles.card}>
|
|
1200
|
+
<View style={{ ...styles.row, justifyContent: "space-between" }}>
|
|
1201
|
+
<Text style={styles.heading}>Recent sends</Text>
|
|
1202
|
+
{recent.length === 0 ? null : (
|
|
1203
|
+
<Button
|
|
1204
|
+
label="Clear"
|
|
1205
|
+
styles={styles}
|
|
1206
|
+
onPress={() => {
|
|
1207
|
+
void clearRecent({ serverId: host.id }).then(invalidate);
|
|
1208
|
+
}}
|
|
1209
|
+
/>
|
|
1210
|
+
)}
|
|
1211
|
+
</View>
|
|
1212
|
+
{recent.length === 0 ? (
|
|
1213
|
+
<Text style={styles.muted}>Nothing sent yet.</Text>
|
|
1214
|
+
) : (
|
|
1215
|
+
recent.map((send) => (
|
|
1216
|
+
<RecentSendRow
|
|
1217
|
+
key={send.id}
|
|
1218
|
+
send={send}
|
|
1219
|
+
styles={styles}
|
|
1220
|
+
onOpen={
|
|
1221
|
+
navigation === undefined
|
|
1222
|
+
? null
|
|
1223
|
+
: (agentId) => navigation.openAgent({ agentId, serverId: host.id })
|
|
1224
|
+
}
|
|
1225
|
+
/>
|
|
1226
|
+
))
|
|
1227
|
+
)}
|
|
1228
|
+
</View>
|
|
1229
|
+
</ScrollView>
|
|
1230
|
+
);
|
|
1231
|
+
}
|