@omercnet/paseo-omp 5.3.0 → 5.4.0-next.392.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/client/sessions-popover.tsx +8 -8
- 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/server/sessions.ts +19 -52
- package/shared/omp-mcps.ts +128 -0
- package/shared/sessions.ts +2 -7
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { OmpLoginSchema } from "./omp-accounts";
|
|
4
|
+
import { OmpStoreSchema } from "./omp-store";
|
|
5
|
+
|
|
6
|
+
/** A server name as `omp` lists it. OMP allows spaces and other characters in names. */
|
|
7
|
+
export const OmpMcpListedNameSchema = z.string().min(1).max(200);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A name the plugin may put in a slash command: it never starts with `-` and has no spaces, so it
|
|
11
|
+
* is one argument. A listed server whose name does not fit can be shown but not acted on here.
|
|
12
|
+
*/
|
|
13
|
+
export const OmpMcpNameSchema = z.string().regex(/^[a-zA-Z0-9_.:][a-zA-Z0-9_.:-]{0,99}$/u);
|
|
14
|
+
|
|
15
|
+
/** One line of `/mcp list`: `name | transport | state | target [source]`. */
|
|
16
|
+
export const OmpMcpServerSchema = z.object({
|
|
17
|
+
name: OmpMcpListedNameSchema,
|
|
18
|
+
transport: z.string(),
|
|
19
|
+
/** `enabled` or `disabled`, as OMP words it. */
|
|
20
|
+
state: z.string(),
|
|
21
|
+
/** The URL of a remote server, or the command line of a local one. */
|
|
22
|
+
target: z.string(),
|
|
23
|
+
/** Where the definition lives, such as `user` or a tool OMP imported it from. */
|
|
24
|
+
source: z.string(),
|
|
25
|
+
});
|
|
26
|
+
export type OmpMcpServer = z.infer<typeof OmpMcpServerSchema>;
|
|
27
|
+
|
|
28
|
+
/** An OAuth authorization in flight; the same steps as an account sign-in. */
|
|
29
|
+
export const OmpMcpAuthSchema = OmpLoginSchema.omit({ provider: true }).extend({
|
|
30
|
+
name: OmpMcpNameSchema,
|
|
31
|
+
});
|
|
32
|
+
export type OmpMcpAuth = z.infer<typeof OmpMcpAuthSchema>;
|
|
33
|
+
|
|
34
|
+
export const OmpMcpsViewSchema = z.object({
|
|
35
|
+
installed: z.boolean(),
|
|
36
|
+
servers: z.array(OmpMcpServerSchema),
|
|
37
|
+
auths: z.array(OmpMcpAuthSchema),
|
|
38
|
+
error: z.string().nullable(),
|
|
39
|
+
});
|
|
40
|
+
export type OmpMcpsView = z.infer<typeof OmpMcpsViewSchema>;
|
|
41
|
+
|
|
42
|
+
export const OMP_MCP_ACTIONS = ["test", "enable", "disable", "remove"] as const;
|
|
43
|
+
export const OmpMcpActionSchema = z.enum(OMP_MCP_ACTIONS);
|
|
44
|
+
export type OmpMcpAction = z.infer<typeof OmpMcpActionSchema>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A remote server's URL, or the command line OMP starts for a local one. A URL goes after `--url`,
|
|
48
|
+
* so it is a single token; anything after `--` is the command.
|
|
49
|
+
*/
|
|
50
|
+
export const OmpMcpTargetSchema = z
|
|
51
|
+
.string()
|
|
52
|
+
.trim()
|
|
53
|
+
.min(1)
|
|
54
|
+
.max(4096)
|
|
55
|
+
.regex(/^[^\r\n]+$/u, "Use a single line")
|
|
56
|
+
.refine(
|
|
57
|
+
(target) => !/^https?:\/\//iu.test(target) || /^\S+$/u.test(target),
|
|
58
|
+
"A server URL can't contain spaces",
|
|
59
|
+
)
|
|
60
|
+
// omp reads the command line as shell-like words and drops quote characters, which would store a
|
|
61
|
+
// different URL than the one typed.
|
|
62
|
+
.refine(
|
|
63
|
+
(target) => !/^https?:\/\//iu.test(target) || !/['"]/u.test(target),
|
|
64
|
+
"A server URL can't contain quotes; write them as %27 and %22",
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const listOmpMcps = defineRpc({
|
|
68
|
+
name: "paseo-omp.list-mcps",
|
|
69
|
+
/** `refresh` asks omp again instead of answering from the last listing. */
|
|
70
|
+
input: z.object({ store: OmpStoreSchema.optional(), refresh: z.boolean().optional() }),
|
|
71
|
+
output: OmpMcpsViewSchema,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/** What a connection check found: a server that answers, one that wants a sign-in (HTTP 401), or neither. */
|
|
75
|
+
export const OmpMcpCheckSchema = z.enum(["connected", "needs-authorization", "failed"]);
|
|
76
|
+
export type OmpMcpCheck = z.infer<typeof OmpMcpCheckSchema>;
|
|
77
|
+
|
|
78
|
+
export const OmpMcpAddResultSchema = z.object({
|
|
79
|
+
ok: z.boolean(),
|
|
80
|
+
message: z.string(),
|
|
81
|
+
/** omp's `/mcp add` only writes the file, so the server is tested right after. Null when the add failed or the test could not run. */
|
|
82
|
+
check: OmpMcpCheckSchema.nullable(),
|
|
83
|
+
});
|
|
84
|
+
export type OmpMcpAddResult = z.infer<typeof OmpMcpAddResultSchema>;
|
|
85
|
+
|
|
86
|
+
/** Adds the server to omp's user MCP file with `/mcp add`, then tests it. A server that fails the test stays added. */
|
|
87
|
+
export const addOmpMcp = defineRpc({
|
|
88
|
+
name: "paseo-omp.add-mcp",
|
|
89
|
+
input: z.object({
|
|
90
|
+
store: OmpStoreSchema.optional(),
|
|
91
|
+
name: OmpMcpNameSchema,
|
|
92
|
+
target: OmpMcpTargetSchema,
|
|
93
|
+
}),
|
|
94
|
+
output: OmpMcpAddResultSchema,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
/** Runs the matching `/mcp` command through omp. `ok` is false when omp reports the command failed. */
|
|
98
|
+
export const runOmpMcpAction = defineRpc({
|
|
99
|
+
name: "paseo-omp.run-mcp-action",
|
|
100
|
+
input: z.object({
|
|
101
|
+
store: OmpStoreSchema.optional(),
|
|
102
|
+
name: OmpMcpNameSchema,
|
|
103
|
+
action: OmpMcpActionSchema,
|
|
104
|
+
}),
|
|
105
|
+
output: z.object({ ok: z.boolean(), message: z.string() }),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export const startOmpMcpAuth = defineRpc({
|
|
109
|
+
name: "paseo-omp.start-mcp-auth",
|
|
110
|
+
input: z.object({ store: OmpStoreSchema.optional(), name: OmpMcpNameSchema }),
|
|
111
|
+
output: OmpMcpAuthSchema,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export const submitOmpMcpAuthCode = defineRpc({
|
|
115
|
+
name: "paseo-omp.submit-mcp-auth-code",
|
|
116
|
+
input: z.object({
|
|
117
|
+
store: OmpStoreSchema.optional(),
|
|
118
|
+
authId: z.string(),
|
|
119
|
+
code: z.string().trim().min(1).max(4096),
|
|
120
|
+
}),
|
|
121
|
+
output: OmpMcpAuthSchema,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const cancelOmpMcpAuth = defineRpc({
|
|
125
|
+
name: "paseo-omp.cancel-mcp-auth",
|
|
126
|
+
input: z.object({ store: OmpStoreSchema.optional(), authId: z.string() }),
|
|
127
|
+
output: OmpMcpAuthSchema.nullable(),
|
|
128
|
+
});
|
package/shared/sessions.ts
CHANGED
|
@@ -4,16 +4,11 @@ import { OmpStoreSchema } from "./omp-store";
|
|
|
4
4
|
|
|
5
5
|
const CwdSchema = z.string().min(1).max(4_096);
|
|
6
6
|
|
|
7
|
-
// omp's history.db stores created_at as epoch seconds (confirmed against live rows: 10-digit
|
|
8
|
-
// values), unlike agent.db's usage_history which stores milliseconds. Diff against
|
|
9
|
-
// Date.now() / 1_000, never Date.now() directly.
|
|
10
7
|
export const OmpSessionEntrySchema = z.object({
|
|
11
|
-
|
|
12
|
-
sessionId: z.string().nullable(),
|
|
8
|
+
sessionId: z.string(),
|
|
13
9
|
title: z.string().nullable(),
|
|
14
10
|
prompt: z.string(),
|
|
15
|
-
|
|
16
|
-
createdAt: z.number().int(),
|
|
11
|
+
updatedAt: z.string().nullable(),
|
|
17
12
|
});
|
|
18
13
|
export type OmpSessionEntry = z.infer<typeof OmpSessionEntrySchema>;
|
|
19
14
|
|