@omercnet/paseo-omp 5.4.0 → 5.5.0-next.429.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 +7 -1
- package/README.md +2 -1
- package/client/ast-edit.tsx +53 -0
- package/client/composer-pill-settings.tsx +0 -5
- package/client/config-sidebar.tsx +15 -0
- package/client/generated-image.tsx +79 -0
- package/client/lsp-diagnostics.tsx +69 -0
- package/client/omp-config-surface.tsx +438 -108
- package/client/omp-config-views.ts +32 -5
- package/client/omp-extensions-section.tsx +145 -0
- package/client/omp-local-models-section.tsx +215 -0
- package/client/omp-plugin-manager.tsx +198 -3
- package/client/omp-routing-editor.tsx +123 -2
- package/client/omp-rule-test.tsx +140 -0
- package/client/omp-rules-section.tsx +353 -0
- package/client/omp-security-section.tsx +99 -0
- package/client/omp-security-state.ts +14 -0
- package/client/omp-skills-section.tsx +195 -0
- package/client/omp-tool-config-section.tsx +204 -0
- package/client/omp-tool-policy-state.ts +101 -0
- package/client/omp-tool-policy.tsx +435 -0
- package/client/omp-update-row.tsx +87 -0
- package/client/provider-diagnostics-state.ts +38 -1
- package/client/provider-image.tsx +1 -1
- package/client/rule-notice.tsx +33 -0
- package/client/sidebar-compat.ts +0 -109
- package/client/web.ts +34 -0
- package/index.client.tsx +79 -46
- package/index.server.ts +77 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
- package/server/generated-images.ts +57 -0
- package/server/omp-agents.ts +170 -0
- package/server/omp-extensions.ts +235 -0
- package/server/omp-list-setting.ts +98 -0
- package/server/omp-local-models.ts +202 -0
- package/server/omp-models-file.ts +178 -0
- package/server/omp-plugins.ts +182 -0
- package/server/omp-prompt-files.ts +41 -0
- package/server/omp-rule-firings.ts +211 -0
- package/server/omp-rule-switch.ts +38 -0
- package/server/omp-rule-test.ts +82 -0
- package/server/omp-rules.ts +452 -0
- package/server/omp-security.ts +169 -0
- package/server/omp-settings.ts +92 -16
- package/server/omp-skills.ts +179 -0
- package/server/omp-tool-config.ts +144 -0
- package/server/omp-update.ts +203 -0
- package/server/package-version.ts +1 -1
- package/server/provider/connection.ts +1 -1
- package/server/provider/image-cache.ts +1 -1
- package/server/provider/omp-rpc-environment.ts +1 -1
- package/server/provider/session-descriptors.ts +3 -0
- package/server/provider-diagnostics.ts +26 -4
- package/server/regular-file.ts +30 -0
- package/server/rule-notices.ts +112 -0
- package/server/turn-rows.ts +59 -0
- package/server/turn-screenshots.ts +140 -0
- package/shared/ast-edit.ts +124 -0
- package/shared/composer-pill-settings.ts +0 -2
- package/shared/generated-image.ts +68 -0
- package/shared/lsp-diagnostics.ts +141 -0
- package/shared/omp-agents.ts +26 -0
- package/shared/omp-extensions.ts +45 -0
- package/shared/omp-local-models.ts +44 -0
- package/shared/omp-models-file.ts +30 -0
- package/shared/omp-plugins.ts +90 -0
- package/shared/omp-prompt-files.ts +24 -0
- package/shared/omp-rules.ts +134 -0
- package/shared/omp-security.ts +50 -0
- package/shared/omp-settings.ts +211 -2
- package/shared/omp-skills.ts +80 -0
- package/shared/omp-tool-config.ts +283 -0
- package/shared/omp-update.ts +27 -0
- package/shared/provider-image.ts +10 -3
- package/shared/rule-notices.ts +20 -0
- package/client/hub-sidebar.tsx +0 -99
- package/client/sessions-popover.tsx +0 -78
- package/server/sessions.ts +0 -58
- package/shared/sessions.ts +0 -24
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { OmpWorkspaceCwdSchema } from "./hub";
|
|
4
|
+
import { OmpStoreSchema } from "./omp-store";
|
|
5
|
+
|
|
6
|
+
/** OMP reads `lsp.json` for language servers and `dap.json` for debug adapters, from the user and the project. */
|
|
7
|
+
export const OmpToolConfigKindSchema = z.enum(["lsp", "dap"]);
|
|
8
|
+
export type OmpToolConfigKind = z.infer<typeof OmpToolConfigKindSchema>;
|
|
9
|
+
|
|
10
|
+
export const MAX_TOOL_CONFIG_BYTES = 256 * 1024;
|
|
11
|
+
|
|
12
|
+
const stringList = z.array(z.string());
|
|
13
|
+
const object = z.record(z.string(), z.unknown());
|
|
14
|
+
|
|
15
|
+
const LspServerSchema = z
|
|
16
|
+
.looseObject({
|
|
17
|
+
command: z.string().min(1).optional(),
|
|
18
|
+
args: stringList.optional(),
|
|
19
|
+
fileTypes: stringList.optional(),
|
|
20
|
+
languageId: z.string().optional(),
|
|
21
|
+
rootMarkers: stringList.optional(),
|
|
22
|
+
initOptions: object.optional(),
|
|
23
|
+
settings: object.optional(),
|
|
24
|
+
disabled: z.boolean().optional(),
|
|
25
|
+
warmupTimeoutMs: z.number().optional(),
|
|
26
|
+
isLinter: z.boolean().optional(),
|
|
27
|
+
capabilities: z.record(z.string(), z.boolean()).optional(),
|
|
28
|
+
workspaceReadyTimings: z.record(z.string(), z.number()).optional(),
|
|
29
|
+
})
|
|
30
|
+
.refine(
|
|
31
|
+
(server) => !("resolvedCommand" in server) && !("createClient" in server),
|
|
32
|
+
"resolvedCommand and createClient are owned by OMP and cannot be configured",
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const DapAdapterSchema = z
|
|
36
|
+
.looseObject({
|
|
37
|
+
command: z.string().min(1).optional(),
|
|
38
|
+
args: stringList.optional(),
|
|
39
|
+
languages: stringList.optional(),
|
|
40
|
+
fileTypes: stringList.optional(),
|
|
41
|
+
rootMarkers: stringList.optional(),
|
|
42
|
+
launchDefaults: object.optional(),
|
|
43
|
+
attachDefaults: object.optional(),
|
|
44
|
+
connectMode: z.enum(["stdio", "socket", "tcp"]).optional(),
|
|
45
|
+
acceptsDirectoryProgram: z.boolean().optional(),
|
|
46
|
+
})
|
|
47
|
+
.refine(
|
|
48
|
+
(adapter) => !("skipAttachRequest" in adapter),
|
|
49
|
+
"skipAttachRequest belongs inside attachDefaults, where OMP reads it",
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const LspFileSchema = z.looseObject({ idleTimeoutMs: z.number().optional() });
|
|
53
|
+
|
|
54
|
+
function describe(issue: z.core.$ZodIssue, prefix: string): string {
|
|
55
|
+
const path = [prefix, ...issue.path.map(String)].filter(Boolean).join(".");
|
|
56
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isObject(value: unknown): value is Record<string, unknown> {
|
|
60
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** OMP accepts a wrapper key or a flat map of entries. For lsp.json, mixing them silently drops the flat ones. */
|
|
64
|
+
function entriesOf(
|
|
65
|
+
document: Record<string, unknown>,
|
|
66
|
+
wrapper: "servers" | "adapters",
|
|
67
|
+
ignoredKeys: readonly string[],
|
|
68
|
+
rejectMixed: boolean,
|
|
69
|
+
): { entries: Record<string, unknown>; errors: string[] } {
|
|
70
|
+
const wrapped = document[wrapper];
|
|
71
|
+
if (wrapped === undefined) {
|
|
72
|
+
const flat = Object.entries(document).filter(([key]) => !ignoredKeys.includes(key));
|
|
73
|
+
return { entries: Object.fromEntries(flat), errors: [] };
|
|
74
|
+
}
|
|
75
|
+
if (!isObject(wrapped)) return { entries: {}, errors: [`${wrapper} must be an object`] };
|
|
76
|
+
const stray = Object.keys(document).filter(
|
|
77
|
+
(key) => key !== wrapper && !ignoredKeys.includes(key),
|
|
78
|
+
);
|
|
79
|
+
const errors =
|
|
80
|
+
rejectMixed && stray.length > 0
|
|
81
|
+
? [`Do not mix ${wrapper} with entries at the top level (${stray.join(", ")})`]
|
|
82
|
+
: [];
|
|
83
|
+
return { entries: wrapped, errors };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Problems that make OMP ignore a definition, found before the file is written. Empty means valid. */
|
|
87
|
+
export function validateOmpToolConfig(kind: OmpToolConfigKind, text: string): string[] {
|
|
88
|
+
let document: unknown;
|
|
89
|
+
try {
|
|
90
|
+
document = JSON.parse(text);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return [`Not valid JSON: ${error instanceof Error ? error.message : "parse error"}`];
|
|
93
|
+
}
|
|
94
|
+
if (!isObject(document)) return ["The file must hold a JSON object"];
|
|
95
|
+
|
|
96
|
+
const wrapper = kind === "lsp" ? "servers" : "adapters";
|
|
97
|
+
const ignoredKeys = kind === "lsp" ? ["idleTimeoutMs"] : [];
|
|
98
|
+
const errors: string[] = [];
|
|
99
|
+
if (kind === "lsp") {
|
|
100
|
+
const top = LspFileSchema.safeParse(document);
|
|
101
|
+
if (!top.success) errors.push(...top.error.issues.map((issue) => describe(issue, "")));
|
|
102
|
+
}
|
|
103
|
+
const { entries, errors: shapeErrors } = entriesOf(
|
|
104
|
+
document,
|
|
105
|
+
wrapper,
|
|
106
|
+
ignoredKeys,
|
|
107
|
+
kind === "lsp",
|
|
108
|
+
);
|
|
109
|
+
errors.push(...shapeErrors);
|
|
110
|
+
const schema = kind === "lsp" ? LspServerSchema : DapAdapterSchema;
|
|
111
|
+
for (const [name, entry] of Object.entries(entries)) {
|
|
112
|
+
const parsed = schema.safeParse(entry);
|
|
113
|
+
if (!parsed.success) {
|
|
114
|
+
errors.push(...parsed.error.issues.map((issue) => describe(issue, name)));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return errors;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The debug adapters OMP ships. An override of one inherits its command. */
|
|
121
|
+
const BUILT_IN_DAP_ADAPTERS: ReadonlySet<string> = new Set([
|
|
122
|
+
"gdb",
|
|
123
|
+
"lldb-dap",
|
|
124
|
+
"codelldb",
|
|
125
|
+
"debugpy",
|
|
126
|
+
"dlv",
|
|
127
|
+
"js-debug-adapter",
|
|
128
|
+
"netcoredbg",
|
|
129
|
+
"kotlin-debug-adapter",
|
|
130
|
+
"rdbg",
|
|
131
|
+
"php-debug-adapter",
|
|
132
|
+
"bash-debug-adapter",
|
|
133
|
+
"dart-debug-adapter",
|
|
134
|
+
"flutter-debug-adapter",
|
|
135
|
+
"elixir-ls-debugger",
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
/** The servers OMP ships. Any other name is a new definition, which OMP drops unless it is complete. */
|
|
139
|
+
const BUILT_IN_LSP_SERVERS: ReadonlySet<string> = new Set([
|
|
140
|
+
"rust-analyzer",
|
|
141
|
+
"clangd",
|
|
142
|
+
"zls",
|
|
143
|
+
"gopls",
|
|
144
|
+
"typescript-language-server",
|
|
145
|
+
"typescript-native",
|
|
146
|
+
"denols",
|
|
147
|
+
"biome",
|
|
148
|
+
"eslint",
|
|
149
|
+
"vscode-html-language-server",
|
|
150
|
+
"vscode-css-language-server",
|
|
151
|
+
"vscode-json-language-server",
|
|
152
|
+
"tailwindcss",
|
|
153
|
+
"svelte",
|
|
154
|
+
"vue-language-server",
|
|
155
|
+
"astro",
|
|
156
|
+
"pyright",
|
|
157
|
+
"basedpyright",
|
|
158
|
+
"pylsp",
|
|
159
|
+
"ty",
|
|
160
|
+
"ruff",
|
|
161
|
+
"jdtls",
|
|
162
|
+
"kotlin-lsp",
|
|
163
|
+
"metals",
|
|
164
|
+
"hls",
|
|
165
|
+
"ocamllsp",
|
|
166
|
+
"elixirls",
|
|
167
|
+
"expert",
|
|
168
|
+
"erlangls",
|
|
169
|
+
"gleam",
|
|
170
|
+
"solargraph",
|
|
171
|
+
"ruby-lsp",
|
|
172
|
+
"rubocop",
|
|
173
|
+
"bashls",
|
|
174
|
+
"lua-language-server",
|
|
175
|
+
"intelephense",
|
|
176
|
+
"phpactor",
|
|
177
|
+
"omnisharp",
|
|
178
|
+
"yamlls",
|
|
179
|
+
"terraformls",
|
|
180
|
+
"dockerls",
|
|
181
|
+
"helm-ls",
|
|
182
|
+
"nixd",
|
|
183
|
+
"nil",
|
|
184
|
+
"ols",
|
|
185
|
+
"dartls",
|
|
186
|
+
"marksman",
|
|
187
|
+
"texlab",
|
|
188
|
+
"graphql",
|
|
189
|
+
"prismals",
|
|
190
|
+
"vimls",
|
|
191
|
+
"emmet-language-server",
|
|
192
|
+
"sourcekit-lsp",
|
|
193
|
+
"swiftlint",
|
|
194
|
+
"tlaplus",
|
|
195
|
+
]);
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Definitions that pass validation but that OMP drops: a server that is not built in needs a
|
|
199
|
+
* command, file types and root markers (or extensionToLanguage, which supplies both).
|
|
200
|
+
*/
|
|
201
|
+
function hasText(value: unknown): boolean {
|
|
202
|
+
return Array.isArray(value) && value.some((item) => typeof item === "string" && item.length > 0);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function warnOmpToolConfig(kind: OmpToolConfigKind, text: string): string[] {
|
|
206
|
+
let document: unknown;
|
|
207
|
+
try {
|
|
208
|
+
document = JSON.parse(text);
|
|
209
|
+
} catch {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
if (!isObject(document)) return [];
|
|
213
|
+
const lsp = kind === "lsp";
|
|
214
|
+
const { entries } = entriesOf(
|
|
215
|
+
document,
|
|
216
|
+
lsp ? "servers" : "adapters",
|
|
217
|
+
lsp ? ["idleTimeoutMs"] : [],
|
|
218
|
+
false,
|
|
219
|
+
);
|
|
220
|
+
const builtIn = lsp ? BUILT_IN_LSP_SERVERS : BUILT_IN_DAP_ADAPTERS;
|
|
221
|
+
const ignored =
|
|
222
|
+
!lsp && isObject(document.adapters)
|
|
223
|
+
? Object.keys(document).filter((key) => key !== "adapters")
|
|
224
|
+
: [];
|
|
225
|
+
const ignoredWarning =
|
|
226
|
+
ignored.length > 0
|
|
227
|
+
? [`OMP ignores ${ignored.join(", ")} because adapters is present; move them inside adapters`]
|
|
228
|
+
: [];
|
|
229
|
+
return [
|
|
230
|
+
...ignoredWarning,
|
|
231
|
+
...Object.entries(entries).flatMap(([name, entry]) => {
|
|
232
|
+
if (builtIn.has(name) || !isObject(entry)) return [];
|
|
233
|
+
const extensions = isObject(entry.extensionToLanguage)
|
|
234
|
+
? Object.keys(entry.extensionToLanguage).filter((extension) => extension.length > 0)
|
|
235
|
+
: [];
|
|
236
|
+
const missing = [
|
|
237
|
+
typeof entry.command === "string" && entry.command ? null : "command",
|
|
238
|
+
!lsp || extensions.length > 0 || hasText(entry.fileTypes) ? null : "fileTypes",
|
|
239
|
+
!lsp || extensions.length > 0 || hasText(entry.rootMarkers) ? null : "rootMarkers",
|
|
240
|
+
].filter((field) => field !== null);
|
|
241
|
+
return missing.length === 0
|
|
242
|
+
? []
|
|
243
|
+
: [
|
|
244
|
+
`${name} is not a built-in ${lsp ? "server" : "adapter"}, so OMP ignores it without ${missing.join(", ")}`,
|
|
245
|
+
];
|
|
246
|
+
}),
|
|
247
|
+
];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const ToolConfigTargetSchema = z.object({
|
|
251
|
+
store: OmpStoreSchema.optional(),
|
|
252
|
+
/** A workspace folder selects its project file; without one the user file is used. */
|
|
253
|
+
cwd: OmpWorkspaceCwdSchema.optional(),
|
|
254
|
+
kind: OmpToolConfigKindSchema,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
export const readOmpToolConfig = defineRpc({
|
|
258
|
+
name: "paseo-omp.read-tool-config",
|
|
259
|
+
input: ToolConfigTargetSchema.strict(),
|
|
260
|
+
output: z.object({
|
|
261
|
+
path: z.string(),
|
|
262
|
+
exists: z.boolean(),
|
|
263
|
+
text: z.string(),
|
|
264
|
+
revision: z.string(),
|
|
265
|
+
/** Sibling variants OMP also merges, such as lsp.yaml, which this editor does not change. */
|
|
266
|
+
otherFiles: z.array(z.string()),
|
|
267
|
+
}),
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
export const writeOmpToolConfig = defineRpc({
|
|
271
|
+
name: "paseo-omp.write-tool-config",
|
|
272
|
+
input: ToolConfigTargetSchema.extend({
|
|
273
|
+
revision: z.string(),
|
|
274
|
+
text: z.string().max(MAX_TOOL_CONFIG_BYTES),
|
|
275
|
+
}).strict(),
|
|
276
|
+
output: z.object({
|
|
277
|
+
outcome: z.enum(["saved", "conflict", "invalid"]),
|
|
278
|
+
errors: z.array(z.string()),
|
|
279
|
+
/** Saved anyway, but OMP will not use these definitions. */
|
|
280
|
+
warnings: z.array(z.string()),
|
|
281
|
+
revision: z.string(),
|
|
282
|
+
}),
|
|
283
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/** Bounded so nothing unbounded from `omp update --check` output crosses the RPC. */
|
|
5
|
+
const OmpUpdateVersionSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(/^\d{1,4}\.\d{1,4}\.\d{1,4}(?:-[0-9A-Za-z.]{1,32})?$/);
|
|
8
|
+
|
|
9
|
+
/** `unknown` means the check could not run or its output was not understood: never a guess. */
|
|
10
|
+
export const OmpUpdateStatusSchema = z.discriminatedUnion("state", [
|
|
11
|
+
z.object({ state: z.literal("up-to-date") }),
|
|
12
|
+
z.object({ state: z.literal("available"), version: OmpUpdateVersionSchema }),
|
|
13
|
+
z.object({ state: z.literal("unknown") }),
|
|
14
|
+
]);
|
|
15
|
+
export type OmpUpdateStatus = z.infer<typeof OmpUpdateStatusSchema>;
|
|
16
|
+
|
|
17
|
+
export const getOmpUpdateStatus = defineRpc({
|
|
18
|
+
name: "paseo-omp.get-update-status",
|
|
19
|
+
input: z.object({ force: z.boolean().optional() }),
|
|
20
|
+
output: OmpUpdateStatusSchema,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const installOmpUpdate = defineRpc({
|
|
24
|
+
name: "paseo-omp.install-update",
|
|
25
|
+
input: z.object({}),
|
|
26
|
+
output: z.object({ ok: z.boolean(), message: z.string(), status: OmpUpdateStatusSchema }),
|
|
27
|
+
});
|
package/shared/provider-image.ts
CHANGED
|
@@ -83,10 +83,15 @@ function hasExpectedHeader(mimeType: string, bytes: readonly number[]): boolean
|
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const ompImageMimeTypeSchema = z.enum([
|
|
86
|
+
export const ompImageMimeTypeSchema = z.enum([
|
|
87
|
+
"image/gif",
|
|
88
|
+
"image/jpeg",
|
|
89
|
+
"image/png",
|
|
90
|
+
"image/webp",
|
|
91
|
+
]);
|
|
87
92
|
const ompImageIdSchema = z.string().regex(/^[A-Za-z0-9_-]{16}$/u);
|
|
88
93
|
/** SHA-256 of the image bytes, naming the file in the server's image cache. */
|
|
89
|
-
const ompImageRefSchema = z.string().regex(/^[0-9a-f]{64}$/u);
|
|
94
|
+
export const ompImageRefSchema = z.string().regex(/^[0-9a-f]{64}$/u);
|
|
90
95
|
|
|
91
96
|
const cachedOmpImageSchema = z.object({
|
|
92
97
|
id: ompImageIdSchema,
|
|
@@ -104,6 +109,8 @@ const inlineOmpImageSchema = z.object({
|
|
|
104
109
|
const ompImageSchema = z.union([cachedOmpImageSchema, inlineOmpImageSchema]);
|
|
105
110
|
export type OmpImage = z.infer<typeof ompImageSchema>;
|
|
106
111
|
|
|
112
|
+
export const OMP_IMAGE_TIMELINE_KIND = "omp-images";
|
|
113
|
+
|
|
107
114
|
export const getOmpImage = defineRpc({
|
|
108
115
|
name: "paseo-omp.get-image",
|
|
109
116
|
input: z.strictObject({ ref: ompImageRefSchema, mimeType: ompImageMimeTypeSchema }),
|
|
@@ -195,7 +202,7 @@ export function transformOmpImageToolItem(item: { callId: string; metadata?: unk
|
|
|
195
202
|
items: [
|
|
196
203
|
{
|
|
197
204
|
type: "plugin" as const,
|
|
198
|
-
kind:
|
|
205
|
+
kind: OMP_IMAGE_TIMELINE_KIND,
|
|
199
206
|
id: item.callId,
|
|
200
207
|
version: 1,
|
|
201
208
|
data: metadata.data.ompImage,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const OMP_RULE_NOTICE_KIND = "omp-rule-notice";
|
|
4
|
+
export const MAX_OMP_RULE_NOTICE_RULES = 32;
|
|
5
|
+
export const OMP_RULE_NAME_MAX_LENGTH = 256;
|
|
6
|
+
export const OMP_RULE_MATCH_MAX_LENGTH = 512;
|
|
7
|
+
|
|
8
|
+
/** OMP rules (TTSR) that fired during one turn, appended below that turn. */
|
|
9
|
+
export const ompRuleNoticeSchema = z.object({
|
|
10
|
+
rules: z
|
|
11
|
+
.array(
|
|
12
|
+
z.object({
|
|
13
|
+
name: z.string().min(1).max(OMP_RULE_NAME_MAX_LENGTH),
|
|
14
|
+
matched: z.string().max(OMP_RULE_MATCH_MAX_LENGTH).nullable(),
|
|
15
|
+
}),
|
|
16
|
+
)
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(MAX_OMP_RULE_NOTICE_RULES),
|
|
19
|
+
});
|
|
20
|
+
export type OmpRuleNotice = z.infer<typeof ompRuleNoticeSchema>;
|
package/client/hub-sidebar.tsx
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { PluginPopoverProps, PluginSidebarItemProps } from "@getpaseo/plugin/client";
|
|
2
|
-
import { SidebarRow } from "@getpaseo/plugin/client/ui";
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
import { Text, View } from "react-native";
|
|
5
|
-
import { OMP_ICON } from "./hub-icon";
|
|
6
|
-
import { HubProcessList } from "./hub-popover";
|
|
7
|
-
import { CONFIG_SCREEN_ID, type HubSnapshot, hubTrailing } from "./sidebar-compat";
|
|
8
|
-
|
|
9
|
-
// The row is always mounted; a slower poll bounds per-client RPC fan-out across workspaces.
|
|
10
|
-
const HUB_POLL_MS = 15_000;
|
|
11
|
-
const HUB_SIDEBAR_QUERY_KEY = ["paseo-omp", "hub-sidebar"] as const;
|
|
12
|
-
|
|
13
|
-
export function ConfigSidebarItem({ currentScreen, openScreen }: PluginSidebarItemProps) {
|
|
14
|
-
return (
|
|
15
|
-
<SidebarRow
|
|
16
|
-
icon={OMP_ICON}
|
|
17
|
-
label="OMP"
|
|
18
|
-
active={currentScreen?.screenId === CONFIG_SCREEN_ID}
|
|
19
|
-
onPress={() => openScreen({ screenId: CONFIG_SCREEN_ID })}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createHubSidebar(loadSnapshot: () => Promise<HubSnapshot>) {
|
|
25
|
-
const useHubSnapshot = () =>
|
|
26
|
-
useQuery({
|
|
27
|
-
queryKey: HUB_SIDEBAR_QUERY_KEY,
|
|
28
|
-
queryFn: loadSnapshot,
|
|
29
|
-
refetchInterval: HUB_POLL_MS,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
function HubSidebarPopover({ theme, layout }: PluginPopoverProps) {
|
|
33
|
-
const snapshot = useHubSnapshot();
|
|
34
|
-
const muted = { color: theme.colors.foregroundMuted, fontSize: 13 };
|
|
35
|
-
if (snapshot.isLoading) return <Text style={muted}>Loading hub processes…</Text>;
|
|
36
|
-
if (!snapshot.data) {
|
|
37
|
-
return (
|
|
38
|
-
<Text style={{ color: theme.colors.statusDanger, fontSize: 13 }}>
|
|
39
|
-
Could not read omp hub state.
|
|
40
|
-
</Text>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
const active = snapshot.data.workspaces.filter(({ processes }) => processes.length > 0);
|
|
44
|
-
const notes = [
|
|
45
|
-
snapshot.data.unreadable > 0
|
|
46
|
-
? `${snapshot.data.unreadable} workspace(s) could not be read.`
|
|
47
|
-
: undefined,
|
|
48
|
-
snapshot.data.truncated ? "Showing the first 50 workspaces." : undefined,
|
|
49
|
-
].filter(Boolean);
|
|
50
|
-
return (
|
|
51
|
-
<View style={{ gap: layout.compact ? 12 : 14 }}>
|
|
52
|
-
{notes.map((note) => (
|
|
53
|
-
<Text key={note} style={{ ...muted, fontSize: 12 }}>
|
|
54
|
-
{note}
|
|
55
|
-
</Text>
|
|
56
|
-
))}
|
|
57
|
-
{active.length === 0 ? <Text style={muted}>No hub-supervised processes.</Text> : null}
|
|
58
|
-
{active.map(({ cwd, processes }) => (
|
|
59
|
-
<View key={cwd} style={{ gap: 6 }}>
|
|
60
|
-
<Text numberOfLines={1} style={{ ...muted, fontSize: 12 }}>
|
|
61
|
-
{cwd}
|
|
62
|
-
</Text>
|
|
63
|
-
<HubProcessList theme={theme} layout={layout} cwd={cwd} processes={processes} />
|
|
64
|
-
</View>
|
|
65
|
-
))}
|
|
66
|
-
</View>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function HubSidebarItem({ theme, openPopover }: PluginSidebarItemProps) {
|
|
71
|
-
const snapshot = useHubSnapshot();
|
|
72
|
-
const state = hubTrailing(snapshot.data, snapshot.error !== null);
|
|
73
|
-
const trailing = state ? (
|
|
74
|
-
<View
|
|
75
|
-
accessibilityLabel={state.accessibilityLabel}
|
|
76
|
-
style={{ flexDirection: "row", alignItems: "center", gap: 6 }}
|
|
77
|
-
>
|
|
78
|
-
{state.running ? (
|
|
79
|
-
<Text style={{ color: theme.colors.foregroundMuted, fontSize: 12 }}>{state.running}</Text>
|
|
80
|
-
) : null}
|
|
81
|
-
{state.failed || state.unreadable ? (
|
|
82
|
-
<Text style={{ color: theme.colors.statusDanger, fontSize: 12, fontWeight: "600" }}>
|
|
83
|
-
{[state.failed, state.unreadable ? "!" : undefined].filter(Boolean).join(" ")}
|
|
84
|
-
</Text>
|
|
85
|
-
) : null}
|
|
86
|
-
</View>
|
|
87
|
-
) : undefined;
|
|
88
|
-
return (
|
|
89
|
-
<SidebarRow
|
|
90
|
-
icon="Activity"
|
|
91
|
-
label="OMP Hub"
|
|
92
|
-
trailing={trailing}
|
|
93
|
-
onPress={() => openPopover(HubSidebarPopover)}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return { HubSidebarItem, HubSidebarPopover };
|
|
99
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { type PluginButtonContentProps, useAgent, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import { ScrollView, Text, View } from "react-native";
|
|
5
|
-
import { storeForProvider, storeLabel } from "../shared/omp-store";
|
|
6
|
-
import { listOmpSessions } from "../shared/sessions";
|
|
7
|
-
import { ompStoreKey } from "./omp-store-state";
|
|
8
|
-
|
|
9
|
-
const SESSIONS_POLL_MS = 20_000;
|
|
10
|
-
const PREVIEW_LIMIT = 20;
|
|
11
|
-
|
|
12
|
-
function age(epochSeconds: number): string {
|
|
13
|
-
const seconds = Math.max(0, Math.floor(Date.now() / 1_000 - epochSeconds));
|
|
14
|
-
if (seconds < 60) return `${seconds}s ago`;
|
|
15
|
-
const minutes = Math.floor(seconds / 60);
|
|
16
|
-
if (minutes < 60) return `${minutes}m ago`;
|
|
17
|
-
const hours = Math.floor(minutes / 60);
|
|
18
|
-
if (hours < 24) return `${hours}h ago`;
|
|
19
|
-
return `${Math.floor(hours / 24)}d ago`;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function SessionsPopover(props: PluginButtonContentProps) {
|
|
23
|
-
const { theme, layout } = props;
|
|
24
|
-
const agentId = props.context === "agent" ? props.agentId : "";
|
|
25
|
-
const agent = useAgent(agentId, ({ cwd, provider }) => ({ cwd, provider }));
|
|
26
|
-
const cwd = agent?.cwd ?? "";
|
|
27
|
-
const store = storeForProvider(agent?.provider);
|
|
28
|
-
const loadSessions = useRpc(listOmpSessions);
|
|
29
|
-
const sessions = useQuery({
|
|
30
|
-
queryKey: ["paseo-omp", "sessions", ompStoreKey(store), cwd],
|
|
31
|
-
queryFn: () => loadSessions({ cwd, store }),
|
|
32
|
-
enabled: cwd.length > 0,
|
|
33
|
-
refetchInterval: SESSIONS_POLL_MS,
|
|
34
|
-
});
|
|
35
|
-
const styles = useMemo(
|
|
36
|
-
() => ({
|
|
37
|
-
root: { gap: 8, padding: 4, maxHeight: 360, width: 320 },
|
|
38
|
-
muted: { color: theme.colors.foregroundMuted, fontSize: 13 },
|
|
39
|
-
error: { color: theme.colors.statusDanger, fontSize: 13 },
|
|
40
|
-
row: {
|
|
41
|
-
gap: 2,
|
|
42
|
-
padding: layout.compact ? 8 : 10,
|
|
43
|
-
borderWidth: 1,
|
|
44
|
-
borderColor: theme.colors.border,
|
|
45
|
-
borderRadius: 8,
|
|
46
|
-
backgroundColor: theme.colors.surface1,
|
|
47
|
-
},
|
|
48
|
-
title: { color: theme.colors.foreground, fontSize: 13, fontWeight: "600" as const },
|
|
49
|
-
prompt: { color: theme.colors.foreground, fontSize: 13 },
|
|
50
|
-
detail: { color: theme.colors.foregroundMuted, fontSize: 11 },
|
|
51
|
-
}),
|
|
52
|
-
[layout.compact, theme],
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
if (sessions.isLoading) return <Text style={styles.muted}>Loading omp history…</Text>;
|
|
56
|
-
if (sessions.error) return <Text style={styles.error}>Could not read omp history.</Text>;
|
|
57
|
-
const items = sessions.data?.sessions ?? [];
|
|
58
|
-
if (items.length === 0)
|
|
59
|
-
return <Text style={styles.muted}>No omp prompts for this directory.</Text>;
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<ScrollView contentContainerStyle={styles.root}>
|
|
63
|
-
<Text style={styles.muted}>{storeLabel(store)}</Text>
|
|
64
|
-
{items.slice(0, PREVIEW_LIMIT).map((entry) => (
|
|
65
|
-
<View key={entry.id} style={styles.row}>
|
|
66
|
-
{entry.title ? <Text style={styles.title}>{entry.title}</Text> : null}
|
|
67
|
-
<Text style={styles.prompt} numberOfLines={3}>
|
|
68
|
-
{`${entry.prompt}${entry.truncated ? "…" : ""}`}
|
|
69
|
-
</Text>
|
|
70
|
-
<Text style={styles.detail}>{age(entry.createdAt)}</Text>
|
|
71
|
-
</View>
|
|
72
|
-
))}
|
|
73
|
-
{items.length > PREVIEW_LIMIT ? (
|
|
74
|
-
<Text style={styles.muted}>{`Showing ${PREVIEW_LIMIT} of ${items.length}`}</Text>
|
|
75
|
-
) : null}
|
|
76
|
-
</ScrollView>
|
|
77
|
-
);
|
|
78
|
-
}
|
package/server/sessions.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { DatabaseSync } from "node:sqlite";
|
|
3
|
-
import type { RpcInput } from "@getpaseo/plugin";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import type { listOmpSessions, OmpSessionEntry } from "../shared/sessions";
|
|
6
|
-
import { ompDataDir } from "./paths";
|
|
7
|
-
|
|
8
|
-
const PROMPT_LIMIT = 400;
|
|
9
|
-
const ROW_LIMIT = 100;
|
|
10
|
-
|
|
11
|
-
const SessionRowSchema = z.object({
|
|
12
|
-
id: z.number().int(),
|
|
13
|
-
sessionId: z.string().nullable(),
|
|
14
|
-
title: z.string().nullable(),
|
|
15
|
-
prompt: z.string(),
|
|
16
|
-
createdAt: z.number().int(),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export function listOmpSessionsFrom(path: string, cwd: string): OmpSessionEntry[] {
|
|
20
|
-
try {
|
|
21
|
-
const database = new DatabaseSync(path, { readOnly: true, timeout: 500 });
|
|
22
|
-
try {
|
|
23
|
-
const rows = database
|
|
24
|
-
.prepare(
|
|
25
|
-
`SELECT h.id AS id, h.session_id AS sessionId, t.title AS title,
|
|
26
|
-
h.prompt AS prompt, h.created_at AS createdAt
|
|
27
|
-
FROM history h
|
|
28
|
-
LEFT JOIN session_titles t ON t.session_id = h.session_id
|
|
29
|
-
WHERE h.cwd = ?
|
|
30
|
-
ORDER BY h.created_at DESC, h.id DESC
|
|
31
|
-
LIMIT ?`,
|
|
32
|
-
)
|
|
33
|
-
.all(cwd, ROW_LIMIT);
|
|
34
|
-
return rows.flatMap((row) => {
|
|
35
|
-
const parsed = SessionRowSchema.safeParse(row);
|
|
36
|
-
if (!parsed.success) return [];
|
|
37
|
-
const truncated = parsed.data.prompt.length > PROMPT_LIMIT;
|
|
38
|
-
return [
|
|
39
|
-
{
|
|
40
|
-
...parsed.data,
|
|
41
|
-
prompt: truncated ? parsed.data.prompt.slice(0, PROMPT_LIMIT) : parsed.data.prompt,
|
|
42
|
-
truncated,
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
});
|
|
46
|
-
} finally {
|
|
47
|
-
database.close();
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function resolveListOmpSessions({ cwd }: RpcInput<typeof listOmpSessions>): {
|
|
55
|
-
sessions: OmpSessionEntry[];
|
|
56
|
-
} {
|
|
57
|
-
return { sessions: listOmpSessionsFrom(join(ompDataDir(), "history.db"), cwd) };
|
|
58
|
-
}
|
package/shared/sessions.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { OmpStoreSchema } from "./omp-store";
|
|
4
|
-
|
|
5
|
-
const CwdSchema = z.string().min(1).max(4_096);
|
|
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
|
-
export const OmpSessionEntrySchema = z.object({
|
|
11
|
-
id: z.number().int(),
|
|
12
|
-
sessionId: z.string().nullable(),
|
|
13
|
-
title: z.string().nullable(),
|
|
14
|
-
prompt: z.string(),
|
|
15
|
-
truncated: z.boolean(),
|
|
16
|
-
createdAt: z.number().int(),
|
|
17
|
-
});
|
|
18
|
-
export type OmpSessionEntry = z.infer<typeof OmpSessionEntrySchema>;
|
|
19
|
-
|
|
20
|
-
export const listOmpSessions = defineRpc({
|
|
21
|
-
name: "paseo-omp.list-sessions",
|
|
22
|
-
input: z.object({ store: OmpStoreSchema.optional(), cwd: CwdSchema }),
|
|
23
|
-
output: z.object({ sessions: z.array(OmpSessionEntrySchema) }),
|
|
24
|
-
});
|