@omercnet/paseo-omp 5.3.0 → 5.4.0-next.391.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +1 -0
- package/README.md +3 -1
- package/client/omp-accounts-section.tsx +77 -80
- package/client/omp-accounts-state.ts +1 -1
- package/client/omp-config-surface.tsx +5 -0
- package/client/omp-config-views.ts +3 -1
- package/client/omp-mcps-section.tsx +388 -0
- package/index.server.ts +35 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
- package/server/omp-accounts.ts +26 -10
- package/server/omp-mcps.ts +487 -0
- package/server/package-version.ts +1 -1
- package/shared/omp-mcps.ts +128 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
SettingsAction,
|
|
5
|
+
SettingsCard,
|
|
6
|
+
SettingsInput,
|
|
7
|
+
SettingsRow,
|
|
8
|
+
SettingsSection,
|
|
9
|
+
SettingsSwitch,
|
|
10
|
+
useToast,
|
|
11
|
+
} from "@getpaseo/plugin/client/ui";
|
|
12
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
13
|
+
import { useState } from "react";
|
|
14
|
+
import { Text, View } from "react-native";
|
|
15
|
+
import {
|
|
16
|
+
addOmpMcp,
|
|
17
|
+
cancelOmpMcpAuth,
|
|
18
|
+
listOmpMcps,
|
|
19
|
+
type OmpMcpAction,
|
|
20
|
+
OmpMcpNameSchema,
|
|
21
|
+
type OmpMcpServer,
|
|
22
|
+
OmpMcpTargetSchema,
|
|
23
|
+
runOmpMcpAction,
|
|
24
|
+
startOmpMcpAuth,
|
|
25
|
+
submitOmpMcpAuthCode,
|
|
26
|
+
} from "../shared/omp-mcps";
|
|
27
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
28
|
+
import { ConfirmModal, describe, LoginProgress } from "./omp-accounts-section";
|
|
29
|
+
import { loginIsOpen } from "./omp-accounts-state";
|
|
30
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
31
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
32
|
+
|
|
33
|
+
type Theme = PluginSurfaceProps["theme"];
|
|
34
|
+
|
|
35
|
+
/** Kept apart from the config editor's `paseo-omp` key so MCP work never locks setting edits. */
|
|
36
|
+
const MCPS_KEY = ["paseo-omp-mcps"] as const;
|
|
37
|
+
const OPEN_AUTH_POLL_MS = 1_000;
|
|
38
|
+
const TEST_HINT = "Connects and lists its tools";
|
|
39
|
+
|
|
40
|
+
/** What the last test or add check said about one server; shown on its own row. */
|
|
41
|
+
interface Outcome {
|
|
42
|
+
ok: boolean;
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface ServerSectionProps {
|
|
47
|
+
styles: OmpConfigStyles;
|
|
48
|
+
server: OmpMcpServer;
|
|
49
|
+
outcome: Outcome | undefined;
|
|
50
|
+
busy: boolean;
|
|
51
|
+
testing: boolean;
|
|
52
|
+
authorizing: boolean;
|
|
53
|
+
onToggle(enabled: boolean): void;
|
|
54
|
+
onTest(): void;
|
|
55
|
+
onAuthorize(): void;
|
|
56
|
+
onRemove(): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function ServerSection({
|
|
60
|
+
styles,
|
|
61
|
+
server,
|
|
62
|
+
outcome,
|
|
63
|
+
busy,
|
|
64
|
+
testing,
|
|
65
|
+
authorizing,
|
|
66
|
+
onToggle,
|
|
67
|
+
onTest,
|
|
68
|
+
onAuthorize,
|
|
69
|
+
onRemove,
|
|
70
|
+
}: ServerSectionProps) {
|
|
71
|
+
// Only a remote server signs in with OAuth; a local one is a process OMP starts.
|
|
72
|
+
const remote = server.transport === "http" || server.transport === "sse";
|
|
73
|
+
const failed = outcome !== undefined && !outcome.ok;
|
|
74
|
+
// OMP allows names the plugin cannot pass as one command argument. Such a server is shown with
|
|
75
|
+
// its address and no actions, because every action would be refused.
|
|
76
|
+
if (!OmpMcpNameSchema.safeParse(server.name).success) {
|
|
77
|
+
return (
|
|
78
|
+
<SettingsSection
|
|
79
|
+
title={server.name}
|
|
80
|
+
trailing={<Text style={styles.muted}>{`${server.transport} · ${server.source}`}</Text>}
|
|
81
|
+
>
|
|
82
|
+
<SettingsCard>
|
|
83
|
+
<SettingsRow label={server.target} />
|
|
84
|
+
<SettingsRow
|
|
85
|
+
label="Manage in the OMP terminal"
|
|
86
|
+
hint="Its name has spaces or other characters this plugin cannot pass to omp safely"
|
|
87
|
+
/>
|
|
88
|
+
</SettingsCard>
|
|
89
|
+
</SettingsSection>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return (
|
|
93
|
+
<SettingsSection
|
|
94
|
+
title={server.name}
|
|
95
|
+
trailing={<Text style={styles.muted}>{`${server.transport} · ${server.source}`}</Text>}
|
|
96
|
+
>
|
|
97
|
+
<SettingsCard>
|
|
98
|
+
<SettingsRow label={server.target} />
|
|
99
|
+
<SettingsSwitch
|
|
100
|
+
label="Enabled"
|
|
101
|
+
hint="Whether OMP connects to it"
|
|
102
|
+
value={server.state === "enabled"}
|
|
103
|
+
disabled={busy}
|
|
104
|
+
onValueChange={onToggle}
|
|
105
|
+
/>
|
|
106
|
+
<SettingsAction
|
|
107
|
+
label="Test connection"
|
|
108
|
+
hint={outcome?.ok ? outcome.message : TEST_HINT}
|
|
109
|
+
error={failed ? outcome.message : null}
|
|
110
|
+
actionLabel={testing ? "Testing..." : "Test"}
|
|
111
|
+
disabled={busy}
|
|
112
|
+
onPress={onTest}
|
|
113
|
+
/>
|
|
114
|
+
{remote ? (
|
|
115
|
+
<SettingsAction
|
|
116
|
+
label="Sign in"
|
|
117
|
+
hint="Authorize through your browser"
|
|
118
|
+
actionLabel={authorizing ? "Starting..." : "Authorize"}
|
|
119
|
+
disabled={busy || authorizing}
|
|
120
|
+
onPress={onAuthorize}
|
|
121
|
+
/>
|
|
122
|
+
) : null}
|
|
123
|
+
{server.source === "user" ? (
|
|
124
|
+
<SettingsAction
|
|
125
|
+
label="Remove server"
|
|
126
|
+
hint="Deletes it from OMP's user MCP file"
|
|
127
|
+
actionLabel="Remove"
|
|
128
|
+
disabled={busy}
|
|
129
|
+
onPress={onRemove}
|
|
130
|
+
/>
|
|
131
|
+
) : null}
|
|
132
|
+
</SettingsCard>
|
|
133
|
+
</SettingsSection>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function AddMcpModal({
|
|
138
|
+
busy,
|
|
139
|
+
error,
|
|
140
|
+
onAdd,
|
|
141
|
+
onEdit,
|
|
142
|
+
onClose,
|
|
143
|
+
}: {
|
|
144
|
+
busy: boolean;
|
|
145
|
+
error: string | null;
|
|
146
|
+
onAdd(input: { name: string; target: string }): void;
|
|
147
|
+
/** The person changed a field, so the last attempt's error no longer describes it. */
|
|
148
|
+
onEdit(): void;
|
|
149
|
+
onClose(): void;
|
|
150
|
+
}) {
|
|
151
|
+
const [name, setName] = useState("");
|
|
152
|
+
const [target, setTarget] = useState("");
|
|
153
|
+
const valid =
|
|
154
|
+
OmpMcpNameSchema.safeParse(name.trim()).success && OmpMcpTargetSchema.safeParse(target).success;
|
|
155
|
+
return (
|
|
156
|
+
<Modal
|
|
157
|
+
title="Add MCP server"
|
|
158
|
+
open
|
|
159
|
+
onOpenChange={(open) => (open || busy ? undefined : onClose())}
|
|
160
|
+
>
|
|
161
|
+
<Modal.Content>
|
|
162
|
+
<SettingsCard>
|
|
163
|
+
<SettingsInput
|
|
164
|
+
label="Name"
|
|
165
|
+
placeholder="docs"
|
|
166
|
+
onChangeText={(value) => {
|
|
167
|
+
setName(value);
|
|
168
|
+
if (error) onEdit();
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
<SettingsInput
|
|
172
|
+
label="Address"
|
|
173
|
+
hint="A URL, or the command that starts the server"
|
|
174
|
+
placeholder="https://mcp.example.com/mcp"
|
|
175
|
+
error={error}
|
|
176
|
+
onChangeText={(value) => {
|
|
177
|
+
setTarget(value);
|
|
178
|
+
if (error) onEdit();
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
<SettingsAction
|
|
182
|
+
label="Add to OMP"
|
|
183
|
+
hint="Adds it to OMP's user MCP file, then tests the connection"
|
|
184
|
+
actionLabel={busy ? "Adding..." : "Add"}
|
|
185
|
+
disabled={busy || !valid}
|
|
186
|
+
onPress={() => onAdd({ name: name.trim(), target })}
|
|
187
|
+
/>
|
|
188
|
+
</SettingsCard>
|
|
189
|
+
</Modal.Content>
|
|
190
|
+
</Modal>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function OmpMcpsSection({
|
|
195
|
+
theme,
|
|
196
|
+
styles,
|
|
197
|
+
store,
|
|
198
|
+
}: {
|
|
199
|
+
theme: Theme;
|
|
200
|
+
styles: OmpConfigStyles;
|
|
201
|
+
store?: OmpStore;
|
|
202
|
+
}) {
|
|
203
|
+
const toast = useToast();
|
|
204
|
+
const queryClient = useQueryClient();
|
|
205
|
+
const load = useRpc(listOmpMcps);
|
|
206
|
+
const act = useRpc(runOmpMcpAction);
|
|
207
|
+
const addServer = useRpc(addOmpMcp);
|
|
208
|
+
const start = useRpc(startOmpMcpAuth);
|
|
209
|
+
const submit = useRpc(submitOmpMcpAuthCode);
|
|
210
|
+
const cancel = useRpc(cancelOmpMcpAuth);
|
|
211
|
+
const [adding, setAdding] = useState(false);
|
|
212
|
+
const [pendingRemove, setPendingRemove] = useState<string | null>(null);
|
|
213
|
+
const [authId, setAuthId] = useState<string | null>(null);
|
|
214
|
+
const [outcomes, setOutcomes] = useState<ReadonlyMap<string, Outcome>>(new Map());
|
|
215
|
+
const queryKey = [...MCPS_KEY, ompStoreKey(store)];
|
|
216
|
+
const mcps = useQuery({
|
|
217
|
+
queryKey,
|
|
218
|
+
queryFn: () => load({ store }),
|
|
219
|
+
refetchInterval: (query) =>
|
|
220
|
+
query.state.data?.auths.some(loginIsOpen) ? OPEN_AUTH_POLL_MS : false,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
function remember(name: string, outcome: Outcome | null) {
|
|
224
|
+
setOutcomes((previous) => {
|
|
225
|
+
const next = new Map(previous);
|
|
226
|
+
if (outcome) next.set(name, outcome);
|
|
227
|
+
else next.delete(name);
|
|
228
|
+
return next;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const refresh = useMutation({
|
|
233
|
+
mutationKey: [...MCPS_KEY, "refresh"],
|
|
234
|
+
mutationFn: () => load({ store, refresh: true }),
|
|
235
|
+
onSuccess: (view) => queryClient.setQueryData(queryKey, view),
|
|
236
|
+
onError: (error) => toast.error(describe(error)),
|
|
237
|
+
});
|
|
238
|
+
const run = useMutation({
|
|
239
|
+
mutationKey: [...MCPS_KEY, "run"],
|
|
240
|
+
mutationFn: (change: { name: string; action: OmpMcpAction }) => act({ store, ...change }),
|
|
241
|
+
onSuccess: async (result, { name, action }) => {
|
|
242
|
+
if (action === "test") remember(name, result);
|
|
243
|
+
else if (result.ok) toast.show(result.message, { variant: "success" });
|
|
244
|
+
else toast.error(result.message);
|
|
245
|
+
if (action === "remove" && result.ok) remember(name, null);
|
|
246
|
+
await queryClient.invalidateQueries({ queryKey: MCPS_KEY });
|
|
247
|
+
},
|
|
248
|
+
onError: (error) => toast.error(describe(error)),
|
|
249
|
+
onSettled: () => setPendingRemove(null),
|
|
250
|
+
});
|
|
251
|
+
const add = useMutation({
|
|
252
|
+
mutationKey: [...MCPS_KEY, "add"],
|
|
253
|
+
mutationFn: (input: { name: string; target: string }) => addServer({ store, ...input }),
|
|
254
|
+
onSuccess: async (result, { name }) => {
|
|
255
|
+
if (!result.ok) return;
|
|
256
|
+
const healthy = result.check !== "failed";
|
|
257
|
+
remember(name, { ok: healthy, message: result.message });
|
|
258
|
+
toast.show(result.message, { variant: healthy ? "success" : "warning" });
|
|
259
|
+
setAdding(false);
|
|
260
|
+
await queryClient.invalidateQueries({ queryKey: MCPS_KEY });
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
const authorize = useMutation({
|
|
264
|
+
mutationKey: [...MCPS_KEY, "authorize"],
|
|
265
|
+
mutationFn: (name: string) => start({ store, name }),
|
|
266
|
+
onSuccess: async (started) => {
|
|
267
|
+
setAuthId(started.id);
|
|
268
|
+
await queryClient.invalidateQueries({ queryKey: MCPS_KEY });
|
|
269
|
+
},
|
|
270
|
+
onError: (error) => toast.error(describe(error)),
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const view = mcps.data;
|
|
274
|
+
const auth = authId ? view?.auths.find((entry) => entry.id === authId) : undefined;
|
|
275
|
+
const addFailure = add.data && !add.data.ok ? add.data.message : null;
|
|
276
|
+
const addError = add.error ? describe(add.error) : addFailure;
|
|
277
|
+
|
|
278
|
+
function closeAuth() {
|
|
279
|
+
// An open authorization holds OMP's OAuth callback port until it is canceled.
|
|
280
|
+
if (auth && loginIsOpen(auth)) cancel({ store, authId: auth.id }).catch(() => undefined);
|
|
281
|
+
setAuthId(null);
|
|
282
|
+
void queryClient.invalidateQueries({ queryKey: MCPS_KEY });
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function openAdd() {
|
|
286
|
+
add.reset();
|
|
287
|
+
setAdding(true);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const notice = mcps.error
|
|
291
|
+
? `Could not read OMP's MCP servers: ${describe(mcps.error)}`
|
|
292
|
+
: (view?.error ?? null);
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<View style={{ gap: 12 }}>
|
|
296
|
+
<SettingsSection
|
|
297
|
+
title="MCP servers"
|
|
298
|
+
info="The servers OMP connects to, read and changed through omp itself, so the terminal sees the same list."
|
|
299
|
+
>
|
|
300
|
+
<SettingsCard>
|
|
301
|
+
<SettingsAction
|
|
302
|
+
label="Add server"
|
|
303
|
+
hint="Connect OMP to a URL or a local command"
|
|
304
|
+
actionLabel="Add"
|
|
305
|
+
disabled={view === undefined || !view.installed}
|
|
306
|
+
onPress={openAdd}
|
|
307
|
+
/>
|
|
308
|
+
<SettingsAction
|
|
309
|
+
label="Refresh list"
|
|
310
|
+
hint="Read the servers from omp again"
|
|
311
|
+
actionLabel={refresh.isPending ? "Refreshing..." : "Refresh"}
|
|
312
|
+
disabled={refresh.isPending}
|
|
313
|
+
onPress={() => refresh.mutate()}
|
|
314
|
+
/>
|
|
315
|
+
</SettingsCard>
|
|
316
|
+
</SettingsSection>
|
|
317
|
+
{mcps.isLoading ? <Text style={styles.muted}>Loading MCP servers...</Text> : null}
|
|
318
|
+
{notice ? <Text style={styles.error}>{notice}</Text> : null}
|
|
319
|
+
{view && !view.installed ? (
|
|
320
|
+
<Text style={styles.muted}>The omp command was not found on this host</Text>
|
|
321
|
+
) : null}
|
|
322
|
+
{view?.installed && !view.error && view.servers.length === 0 ? (
|
|
323
|
+
<Text style={styles.muted}>No MCP servers yet</Text>
|
|
324
|
+
) : null}
|
|
325
|
+
{view?.servers.map((server) => (
|
|
326
|
+
<ServerSection
|
|
327
|
+
key={`${server.source}/${server.name}`}
|
|
328
|
+
styles={styles}
|
|
329
|
+
server={server}
|
|
330
|
+
outcome={outcomes.get(server.name)}
|
|
331
|
+
busy={run.isPending}
|
|
332
|
+
testing={
|
|
333
|
+
run.isPending && run.variables?.name === server.name && run.variables.action === "test"
|
|
334
|
+
}
|
|
335
|
+
authorizing={authorize.isPending && authorize.variables === server.name}
|
|
336
|
+
onToggle={(enabled) =>
|
|
337
|
+
run.mutate({ name: server.name, action: enabled ? "enable" : "disable" })
|
|
338
|
+
}
|
|
339
|
+
onTest={() => run.mutate({ name: server.name, action: "test" })}
|
|
340
|
+
onAuthorize={() => authorize.mutate(server.name)}
|
|
341
|
+
onRemove={() => setPendingRemove(server.name)}
|
|
342
|
+
/>
|
|
343
|
+
))}
|
|
344
|
+
{adding ? (
|
|
345
|
+
<AddMcpModal
|
|
346
|
+
busy={add.isPending}
|
|
347
|
+
error={addError}
|
|
348
|
+
onAdd={(input) => add.mutate(input)}
|
|
349
|
+
onEdit={() => add.reset()}
|
|
350
|
+
onClose={() => setAdding(false)}
|
|
351
|
+
/>
|
|
352
|
+
) : null}
|
|
353
|
+
{pendingRemove ? (
|
|
354
|
+
<ConfirmModal
|
|
355
|
+
styles={styles}
|
|
356
|
+
theme={theme}
|
|
357
|
+
title={`Remove ${pendingRemove}?`}
|
|
358
|
+
body="This deletes the server from OMP's user MCP file, for the terminal too. Its OAuth sign-in is kept."
|
|
359
|
+
confirmLabel="Remove"
|
|
360
|
+
tone="danger"
|
|
361
|
+
busy={run.isPending}
|
|
362
|
+
onConfirm={() => run.mutate({ name: pendingRemove, action: "remove" })}
|
|
363
|
+
onCancel={() => setPendingRemove(null)}
|
|
364
|
+
/>
|
|
365
|
+
) : null}
|
|
366
|
+
{auth ? (
|
|
367
|
+
<Modal
|
|
368
|
+
title={`Authorize ${auth.name}`}
|
|
369
|
+
open
|
|
370
|
+
onOpenChange={(open) => (open ? undefined : closeAuth())}
|
|
371
|
+
>
|
|
372
|
+
<Modal.Content>
|
|
373
|
+
<LoginProgress
|
|
374
|
+
styles={styles}
|
|
375
|
+
login={auth}
|
|
376
|
+
onSubmit={async (code) => {
|
|
377
|
+
await submit({ store, authId: auth.id, code });
|
|
378
|
+
await queryClient.invalidateQueries({ queryKey: MCPS_KEY });
|
|
379
|
+
}}
|
|
380
|
+
onRetry={() => authorize.mutate(auth.name)}
|
|
381
|
+
onClose={closeAuth}
|
|
382
|
+
/>
|
|
383
|
+
</Modal.Content>
|
|
384
|
+
</Modal>
|
|
385
|
+
) : null}
|
|
386
|
+
</View>
|
|
387
|
+
);
|
|
388
|
+
}
|
package/index.server.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { resolveListOmpMemory } from "./server/memory";
|
|
8
8
|
import { OmpAccounts } from "./server/omp-accounts";
|
|
9
9
|
import { resolveListOmpConfig } from "./server/omp-config";
|
|
10
|
+
import { OmpMcps } from "./server/omp-mcps";
|
|
10
11
|
import { resolveListOmpModels } from "./server/omp-models";
|
|
11
12
|
import {
|
|
12
13
|
resolveInspectOmpPluginConfig,
|
|
@@ -52,6 +53,14 @@ import {
|
|
|
52
53
|
submitOmpAccountLoginCode,
|
|
53
54
|
} from "./shared/omp-accounts";
|
|
54
55
|
import { listOmpConfig } from "./shared/omp-config";
|
|
56
|
+
import {
|
|
57
|
+
addOmpMcp,
|
|
58
|
+
cancelOmpMcpAuth,
|
|
59
|
+
listOmpMcps,
|
|
60
|
+
runOmpMcpAction,
|
|
61
|
+
startOmpMcpAuth,
|
|
62
|
+
submitOmpMcpAuthCode,
|
|
63
|
+
} from "./shared/omp-mcps";
|
|
55
64
|
import { listOmpModels } from "./shared/omp-models";
|
|
56
65
|
import {
|
|
57
66
|
inspectOmpPluginConfig,
|
|
@@ -91,6 +100,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
91
100
|
const protocolViolations = new OmpProtocolViolationCollector();
|
|
92
101
|
const operationalFailures = new OmpOperationalFailureCollector();
|
|
93
102
|
const accounts = new OmpAccounts();
|
|
103
|
+
const mcps = new OmpMcps();
|
|
94
104
|
const profiles = discoverOmpProfilesSync();
|
|
95
105
|
server.handle(listOmpStores, async () => ({ profiles: await discoverOmpProfiles() }));
|
|
96
106
|
for (const profile of profiles) {
|
|
@@ -149,6 +159,30 @@ export default function contribute(server: PluginServerContext) {
|
|
|
149
159
|
return { ok: true as const };
|
|
150
160
|
}),
|
|
151
161
|
);
|
|
162
|
+
server.handle(
|
|
163
|
+
listOmpMcps,
|
|
164
|
+
scoped(({ store, refresh }) => mcps.list(store, refresh ?? false)),
|
|
165
|
+
);
|
|
166
|
+
server.handle(
|
|
167
|
+
addOmpMcp,
|
|
168
|
+
scoped(({ name, target }) => mcps.add(name, target)),
|
|
169
|
+
);
|
|
170
|
+
server.handle(
|
|
171
|
+
runOmpMcpAction,
|
|
172
|
+
scoped(({ store, name, action }) => mcps.run(store, name, action)),
|
|
173
|
+
);
|
|
174
|
+
server.handle(
|
|
175
|
+
startOmpMcpAuth,
|
|
176
|
+
scoped(({ store, name }) => mcps.startAuth(store, name)),
|
|
177
|
+
);
|
|
178
|
+
server.handle(
|
|
179
|
+
submitOmpMcpAuthCode,
|
|
180
|
+
scoped(({ authId, code }) => mcps.submitCode(authId, code)),
|
|
181
|
+
);
|
|
182
|
+
server.handle(
|
|
183
|
+
cancelOmpMcpAuth,
|
|
184
|
+
scoped(({ authId }) => mcps.cancelAuth(authId)),
|
|
185
|
+
);
|
|
152
186
|
server.handle(listOmpMemory, scoped(resolveListOmpMemory));
|
|
153
187
|
server.handle(listOmpSessions, scoped(resolveListOmpSessions));
|
|
154
188
|
server.handle(listOmpConfig, scoped(resolveListOmpConfig));
|
|
@@ -191,6 +225,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
191
225
|
return () => {
|
|
192
226
|
browserAuthorizationRegistry.clear();
|
|
193
227
|
accounts.stop();
|
|
228
|
+
mcps.stop();
|
|
194
229
|
removeSessionLimitListener();
|
|
195
230
|
subagentControlRegistry.clear();
|
|
196
231
|
removeSessionOpenHook();
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omercnet/paseo-omp",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@omercnet/paseo-omp",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.4.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@getpaseo/protocol": "0.15.0",
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.2",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omercnet/paseo-omp",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0-next.391.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
"@getpaseo/client": "0.15.0",
|
|
65
65
|
"@getpaseo/plugin": "0.15.0",
|
|
66
66
|
"@getpaseo/server": "0.15.0",
|
|
67
|
-
"@oh-my-pi/pi-agent-core": "18.
|
|
68
|
-
"@oh-my-pi/pi-coding-agent": "18.
|
|
67
|
+
"@oh-my-pi/pi-agent-core": "18.15.0",
|
|
68
|
+
"@oh-my-pi/pi-coding-agent": "18.15.0",
|
|
69
69
|
"@tanstack/react-query": "^5.102.3",
|
|
70
70
|
"@types/node": "^24.10.1",
|
|
71
71
|
"@types/react": "^19.2.18",
|
|
72
72
|
"@vitest/coverage-v8": "^5.0.0",
|
|
73
73
|
"esbuild": "0.28.2",
|
|
74
|
+
"pino": "10.4.0",
|
|
74
75
|
"react": "19.1.0",
|
|
75
76
|
"react-native": "0.81.5",
|
|
76
|
-
"pino": "10.4.0",
|
|
77
77
|
"tsx": "^4.20.6",
|
|
78
78
|
"typescript": "^7.0.2",
|
|
79
79
|
"vitest": "^5.0.0",
|
package/server/omp-accounts.ts
CHANGED
|
@@ -50,7 +50,7 @@ const RPC_ARGS = [
|
|
|
50
50
|
|
|
51
51
|
export class OmpAccountsError extends OmpPublicError {}
|
|
52
52
|
|
|
53
|
-
interface OmpCommand {
|
|
53
|
+
export interface OmpCommand {
|
|
54
54
|
executable: string;
|
|
55
55
|
env: NodeJS.ProcessEnv;
|
|
56
56
|
}
|
|
@@ -83,8 +83,9 @@ const FrameSchema = z.object({
|
|
|
83
83
|
instructions: OptionalText,
|
|
84
84
|
title: OptionalText,
|
|
85
85
|
message: OptionalText,
|
|
86
|
+
text: OptionalText,
|
|
86
87
|
});
|
|
87
|
-
type Frame = z.infer<typeof FrameSchema>;
|
|
88
|
+
export type Frame = z.infer<typeof FrameSchema>;
|
|
88
89
|
|
|
89
90
|
const LoginProvidersSchema = z.object({
|
|
90
91
|
providers: entries(
|
|
@@ -192,7 +193,7 @@ const RECLAIM_MARGIN_PCT = 15;
|
|
|
192
193
|
const DEFAULT_RESERVE_PCT = 10;
|
|
193
194
|
|
|
194
195
|
/** What the client may see: the plugin's own messages, never a raw Node error or omp's stderr. */
|
|
195
|
-
function publicMessage(error: unknown): string {
|
|
196
|
+
export function publicMessage(error: unknown): string {
|
|
196
197
|
return error instanceof OmpPublicError ? error.message : "omp did not answer";
|
|
197
198
|
}
|
|
198
199
|
|
|
@@ -202,7 +203,7 @@ function readOutput<T>(schema: z.ZodType<T>, value: unknown, command: string): T
|
|
|
202
203
|
return parsed.data;
|
|
203
204
|
}
|
|
204
205
|
|
|
205
|
-
async function resolveCommand(): Promise<OmpCommand> {
|
|
206
|
+
export async function resolveCommand(): Promise<OmpCommand> {
|
|
206
207
|
const executable = await resolveOmpExecutable();
|
|
207
208
|
if (!executable) throw new OmpAccountsError("The omp command was not found on this host");
|
|
208
209
|
return { executable, env: buildStatefulCommandEnv(currentOmpEnvironment()) };
|
|
@@ -240,8 +241,17 @@ async function runJson<T>(command: OmpCommand, args: readonly string[], schema:
|
|
|
240
241
|
return readOutput(schema, output, label);
|
|
241
242
|
}
|
|
242
243
|
|
|
244
|
+
/** What a caller hears from the process besides answers to its own requests. */
|
|
245
|
+
export interface OmpRpcHandlers {
|
|
246
|
+
onUiRequest?(frame: Frame): void;
|
|
247
|
+
/** Text omp prints for a slash command (`command_output`). */
|
|
248
|
+
onOutput?(text: string): void;
|
|
249
|
+
/** omp ended without the caller closing it. */
|
|
250
|
+
onExit?(): void;
|
|
251
|
+
}
|
|
252
|
+
|
|
243
253
|
/** One short-lived `omp --mode rpc` process, spoken to in JSON lines. */
|
|
244
|
-
class OmpRpcProcess {
|
|
254
|
+
export class OmpRpcProcess {
|
|
245
255
|
private readonly child: ChildProcess;
|
|
246
256
|
private readonly pending = new Map<
|
|
247
257
|
string,
|
|
@@ -253,7 +263,7 @@ class OmpRpcProcess {
|
|
|
253
263
|
|
|
254
264
|
constructor(
|
|
255
265
|
command: OmpCommand,
|
|
256
|
-
private readonly
|
|
266
|
+
private readonly handlers: OmpRpcHandlers = {},
|
|
257
267
|
) {
|
|
258
268
|
this.child = spawn(command.executable, RPC_ARGS, {
|
|
259
269
|
cwd: tmpdir(),
|
|
@@ -267,10 +277,12 @@ class OmpRpcProcess {
|
|
|
267
277
|
}
|
|
268
278
|
this.child.on("error", (error) => this.failAll(error));
|
|
269
279
|
this.child.on("close", (code) => {
|
|
280
|
+
const unexpected = !this.closed;
|
|
270
281
|
this.closed = true;
|
|
271
282
|
clearTimeout(this.killer);
|
|
272
283
|
const status = code === null ? "" : ` with code ${code}`;
|
|
273
284
|
this.failAll(new OmpAccountsError(`omp exited${status}`));
|
|
285
|
+
if (unexpected) this.handlers.onExit?.();
|
|
274
286
|
});
|
|
275
287
|
}
|
|
276
288
|
|
|
@@ -327,7 +339,9 @@ class OmpRpcProcess {
|
|
|
327
339
|
if (frame.success) waiter.resolve(frame.data);
|
|
328
340
|
else waiter.reject(new OmpAccountsError(frame.error ?? "omp refused the request"));
|
|
329
341
|
} else if (frame.type === "extension_ui_request") {
|
|
330
|
-
this.onUiRequest?.(frame);
|
|
342
|
+
this.handlers.onUiRequest?.(frame);
|
|
343
|
+
} else if (frame.type === "command_output" && frame.text !== undefined) {
|
|
344
|
+
this.handlers.onOutput?.(frame.text);
|
|
331
345
|
}
|
|
332
346
|
}
|
|
333
347
|
|
|
@@ -719,7 +733,7 @@ interface LoginState {
|
|
|
719
733
|
endedAt: number | null;
|
|
720
734
|
}
|
|
721
735
|
|
|
722
|
-
function isOpen(step: OmpLoginStep): boolean {
|
|
736
|
+
export function isOpen(step: OmpLoginStep): boolean {
|
|
723
737
|
return step === "starting" || step === "waiting" || step === "verifying";
|
|
724
738
|
}
|
|
725
739
|
|
|
@@ -735,7 +749,7 @@ function toLogin(login: LoginState): OmpLogin {
|
|
|
735
749
|
};
|
|
736
750
|
}
|
|
737
751
|
|
|
738
|
-
function storeKey(store: OmpStore | undefined): string {
|
|
752
|
+
export function storeKey(store: OmpStore | undefined): string {
|
|
739
753
|
return JSON.stringify(store ?? {});
|
|
740
754
|
}
|
|
741
755
|
|
|
@@ -1038,7 +1052,9 @@ export class OmpAccounts {
|
|
|
1038
1052
|
store: OmpStore | undefined,
|
|
1039
1053
|
): Promise<void> {
|
|
1040
1054
|
try {
|
|
1041
|
-
const rpc = new OmpRpcProcess(command,
|
|
1055
|
+
const rpc = new OmpRpcProcess(command, {
|
|
1056
|
+
onUiRequest: (frame) => this.onLoginUiRequest(login, frame),
|
|
1057
|
+
});
|
|
1042
1058
|
if (!isOpen(login.step)) {
|
|
1043
1059
|
rpc.close();
|
|
1044
1060
|
return;
|