@omercnet/paseo-omp 5.4.0 → 5.5.0-next.427.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,204 @@
|
|
|
1
|
+
import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { TextInput } from "@getpaseo/plugin/client/ui";
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Pressable, Text, View } from "react-native";
|
|
6
|
+
import type { OmpStore } from "../shared/omp-store";
|
|
7
|
+
import {
|
|
8
|
+
type OmpToolConfigKind,
|
|
9
|
+
readOmpToolConfig,
|
|
10
|
+
writeOmpToolConfig,
|
|
11
|
+
} from "../shared/omp-tool-config";
|
|
12
|
+
import type { OmpConfigStyles } from "./omp-config-styles";
|
|
13
|
+
import { ompStoreKey } from "./omp-store-state";
|
|
14
|
+
|
|
15
|
+
type Theme = PluginSurfaceProps["theme"];
|
|
16
|
+
|
|
17
|
+
const KINDS: readonly { kind: OmpToolConfigKind; label: string; example: string }[] = [
|
|
18
|
+
{
|
|
19
|
+
kind: "lsp",
|
|
20
|
+
label: "Language servers (lsp.json)",
|
|
21
|
+
example: '{\n "servers": {\n "pylsp": { "disabled": true }\n }\n}',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
kind: "dap",
|
|
25
|
+
label: "Debug adapters (dap.json)",
|
|
26
|
+
example:
|
|
27
|
+
'{\n "adapters": {\n "my-adapter": { "command": "my-dap-server", "fileTypes": [".xyz"] }\n }\n}',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export function Choice({
|
|
32
|
+
styles,
|
|
33
|
+
label,
|
|
34
|
+
selected,
|
|
35
|
+
disabled,
|
|
36
|
+
onPress,
|
|
37
|
+
}: {
|
|
38
|
+
styles: OmpConfigStyles;
|
|
39
|
+
label: string;
|
|
40
|
+
selected?: boolean;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
onPress(): void;
|
|
43
|
+
}) {
|
|
44
|
+
return (
|
|
45
|
+
<Pressable
|
|
46
|
+
accessibilityRole="button"
|
|
47
|
+
accessibilityState={{ selected: selected === true }}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
onPress={onPress}
|
|
50
|
+
style={[styles.editorAction, selected ? styles.editorActionPrimary : null]}
|
|
51
|
+
>
|
|
52
|
+
<Text style={[styles.editorActionText, selected ? styles.editorActionTextPrimary : null]}>
|
|
53
|
+
{label}
|
|
54
|
+
</Text>
|
|
55
|
+
</Pressable>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function OmpToolConfigSection({
|
|
60
|
+
styles,
|
|
61
|
+
theme,
|
|
62
|
+
store,
|
|
63
|
+
cwd,
|
|
64
|
+
}: {
|
|
65
|
+
styles: OmpConfigStyles;
|
|
66
|
+
theme: Theme;
|
|
67
|
+
store: OmpStore | undefined;
|
|
68
|
+
cwd: string | undefined;
|
|
69
|
+
}) {
|
|
70
|
+
const read = useRpc(readOmpToolConfig);
|
|
71
|
+
const write = useRpc(writeOmpToolConfig);
|
|
72
|
+
const queryClient = useQueryClient();
|
|
73
|
+
const [kind, setKind] = useState<OmpToolConfigKind>("lsp");
|
|
74
|
+
/** A draft keeps the revision it started from, so a refetch cannot hide an outside edit. */
|
|
75
|
+
const [drafts, setDrafts] = useState<Record<string, { text: string; revision: string }>>({});
|
|
76
|
+
const scope = `${ompStoreKey(store)}:${cwd ?? "user"}:${kind}`;
|
|
77
|
+
const queryKey = ["paseo-omp", "tool-config", ompStoreKey(store), cwd ?? "user", kind];
|
|
78
|
+
const target = { ...(store ? { store } : {}), ...(cwd ? { cwd } : {}), kind };
|
|
79
|
+
const file = useQuery({ queryKey, queryFn: () => read(target) });
|
|
80
|
+
const save = useMutation({
|
|
81
|
+
mutationKey: ["paseo-omp", "tool-config-save"],
|
|
82
|
+
mutationFn: (input: { revision: string; text: string }) => write({ ...target, ...input }),
|
|
83
|
+
onSuccess: async (result, input) => {
|
|
84
|
+
if (result.outcome !== "saved") return;
|
|
85
|
+
await queryClient.invalidateQueries({ queryKey });
|
|
86
|
+
setDrafts((current) => {
|
|
87
|
+
if (current[scope]?.text !== input.text) return current;
|
|
88
|
+
const { [scope]: _saved, ...rest } = current;
|
|
89
|
+
return rest;
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const loaded = file.data;
|
|
95
|
+
const draft = drafts[scope];
|
|
96
|
+
const text = draft?.text ?? loaded?.text ?? "";
|
|
97
|
+
const dirty = draft !== undefined && loaded !== undefined && draft.text !== loaded.text;
|
|
98
|
+
const result = save.data;
|
|
99
|
+
const example = KINDS.find((entry) => entry.kind === kind)?.example ?? "";
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<View style={styles.card}>
|
|
103
|
+
<View style={styles.cardHeader}>
|
|
104
|
+
<Text style={styles.cardTitle}>Language server and debugger config</Text>
|
|
105
|
+
</View>
|
|
106
|
+
<View style={styles.setting}>
|
|
107
|
+
<View style={styles.editorActions}>
|
|
108
|
+
{KINDS.map((entry) => (
|
|
109
|
+
<Choice
|
|
110
|
+
key={entry.kind}
|
|
111
|
+
styles={styles}
|
|
112
|
+
label={entry.label}
|
|
113
|
+
selected={entry.kind === kind}
|
|
114
|
+
onPress={() => {
|
|
115
|
+
save.reset();
|
|
116
|
+
setKind(entry.kind);
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
</View>
|
|
121
|
+
<Text style={styles.settingDescription}>
|
|
122
|
+
{cwd ? "Project file" : "User file"} for new sessions only. OMP keeps running agents on
|
|
123
|
+
their current servers, and reports server status only inside a session. OMP ignores an
|
|
124
|
+
invalid definition and only logs a warning, so Save checks the file first. Save cannot
|
|
125
|
+
tell which servers are built in, so a new server still needs command, fileTypes and
|
|
126
|
+
rootMarkers.
|
|
127
|
+
</Text>
|
|
128
|
+
{loaded ? (
|
|
129
|
+
<Text selectable style={styles.settingPath}>
|
|
130
|
+
{loaded.path}
|
|
131
|
+
{loaded.exists ? "" : " (not created yet)"}
|
|
132
|
+
</Text>
|
|
133
|
+
) : null}
|
|
134
|
+
{loaded && loaded.otherFiles.length > 0 ? (
|
|
135
|
+
<Text style={styles.settingDescription}>
|
|
136
|
+
OMP also merges {loaded.otherFiles.join(", ")} from the same folder. This editor does
|
|
137
|
+
not change those files.
|
|
138
|
+
</Text>
|
|
139
|
+
) : null}
|
|
140
|
+
{file.error ? (
|
|
141
|
+
<Text style={styles.error}>Could not read the file. Check its permissions.</Text>
|
|
142
|
+
) : null}
|
|
143
|
+
<TextInput
|
|
144
|
+
accessibilityLabel={`Edit ${kind}.json`}
|
|
145
|
+
multiline
|
|
146
|
+
editable={loaded !== undefined && !save.isPending}
|
|
147
|
+
placeholder={example}
|
|
148
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
149
|
+
value={text}
|
|
150
|
+
onChangeText={(next) => {
|
|
151
|
+
save.reset();
|
|
152
|
+
setDrafts((current) => ({
|
|
153
|
+
...current,
|
|
154
|
+
[scope]: { text: next, revision: current[scope]?.revision ?? loaded?.revision ?? "" },
|
|
155
|
+
}));
|
|
156
|
+
}}
|
|
157
|
+
style={[styles.scalarInput, { minHeight: 200, maxWidth: undefined }]}
|
|
158
|
+
/>
|
|
159
|
+
{result?.outcome === "invalid"
|
|
160
|
+
? result.errors.map((error) => (
|
|
161
|
+
<Text key={error} style={styles.error}>
|
|
162
|
+
{error}
|
|
163
|
+
</Text>
|
|
164
|
+
))
|
|
165
|
+
: null}
|
|
166
|
+
{result?.outcome === "conflict" ? (
|
|
167
|
+
<Text style={styles.error}>
|
|
168
|
+
The file changed on disk. Revert to load the current version.
|
|
169
|
+
</Text>
|
|
170
|
+
) : null}
|
|
171
|
+
{save.error ? <Text style={styles.error}>Could not save the file.</Text> : null}
|
|
172
|
+
{result?.outcome === "saved" ? (
|
|
173
|
+
<Text style={styles.muted}>Saved. New sessions will use it.</Text>
|
|
174
|
+
) : null}
|
|
175
|
+
{result?.outcome === "saved"
|
|
176
|
+
? result.warnings.map((warning) => (
|
|
177
|
+
<Text key={warning} style={styles.error}>
|
|
178
|
+
{warning}
|
|
179
|
+
</Text>
|
|
180
|
+
))
|
|
181
|
+
: null}
|
|
182
|
+
<View style={styles.editorActions}>
|
|
183
|
+
<Choice
|
|
184
|
+
styles={styles}
|
|
185
|
+
label="Revert"
|
|
186
|
+
disabled={!dirty || save.isPending}
|
|
187
|
+
onPress={() => {
|
|
188
|
+
save.reset();
|
|
189
|
+
setDrafts(({ [scope]: _discarded, ...rest }) => rest);
|
|
190
|
+
void file.refetch();
|
|
191
|
+
}}
|
|
192
|
+
/>
|
|
193
|
+
<Choice
|
|
194
|
+
styles={styles}
|
|
195
|
+
label={save.isPending ? "Saving..." : "Save"}
|
|
196
|
+
selected
|
|
197
|
+
disabled={!loaded || !dirty || save.isPending}
|
|
198
|
+
onPress={() => save.mutate({ revision: draft?.revision ?? "", text })}
|
|
199
|
+
/>
|
|
200
|
+
</View>
|
|
201
|
+
</View>
|
|
202
|
+
</View>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type OmpBashRule,
|
|
3
|
+
OmpBashRuleSchema,
|
|
4
|
+
OmpBashRulesSchema,
|
|
5
|
+
OmpRestrictedFoldersSchema,
|
|
6
|
+
type OmpToolApproval,
|
|
7
|
+
OmpToolApprovalSchema,
|
|
8
|
+
OmpToolPoliciesSchema,
|
|
9
|
+
} from "../shared/omp-settings";
|
|
10
|
+
|
|
11
|
+
export type ToolPolicies = Record<string, OmpToolApproval>;
|
|
12
|
+
|
|
13
|
+
export interface ToolPolicyState {
|
|
14
|
+
policies: ToolPolicies;
|
|
15
|
+
rules: OmpBashRule[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* OMP does not validate these values when it stores them. Keep only entries Apply would accept,
|
|
20
|
+
* so one stored bad entry cannot make every later save fail.
|
|
21
|
+
*/
|
|
22
|
+
export function readToolPolicies(value: unknown): ToolPolicies {
|
|
23
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
24
|
+
const policies: ToolPolicies = {};
|
|
25
|
+
for (const [tool, approval] of Object.entries(value)) {
|
|
26
|
+
const parsed = OmpToolPoliciesSchema.safeParse({ [tool]: approval });
|
|
27
|
+
if (parsed.success) Object.assign(policies, parsed.data);
|
|
28
|
+
}
|
|
29
|
+
return policies;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function readBashRules(value: unknown): OmpBashRule[] {
|
|
33
|
+
if (!Array.isArray(value)) return [];
|
|
34
|
+
return value.flatMap((entry): OmpBashRule[] => {
|
|
35
|
+
if (entry === null || typeof entry !== "object") return [];
|
|
36
|
+
const { match, approval } = entry as { match?: unknown; approval?: unknown };
|
|
37
|
+
const parsed = OmpBashRuleSchema.safeParse({ match, approval });
|
|
38
|
+
return parsed.success ? [parsed.data] : [];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A rule being edited can be momentarily invalid, for example an emptied pattern, and must stay on screen. */
|
|
43
|
+
export function readBashRuleDraft(value: unknown): OmpBashRule[] {
|
|
44
|
+
if (!Array.isArray(value)) return [];
|
|
45
|
+
return value.flatMap((entry): OmpBashRule[] => {
|
|
46
|
+
if (entry === null || typeof entry !== "object") return [];
|
|
47
|
+
const { match, approval } = entry as { match?: unknown; approval?: unknown };
|
|
48
|
+
const parsed = OmpToolApprovalSchema.safeParse(approval);
|
|
49
|
+
return typeof match === "string" && parsed.success ? [{ match, approval: parsed.data }] : [];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function readFolders(value: unknown): string[] {
|
|
54
|
+
if (!Array.isArray(value)) return [];
|
|
55
|
+
const folders = value.filter((item) => OmpRestrictedFoldersSchema.safeParse([item]).success);
|
|
56
|
+
return [...new Set(folders as string[])];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Rules are first match wins, so moving a rule changes which one applies. */
|
|
60
|
+
export function moveRule<T>(rules: readonly T[], index: number, offset: -1 | 1): T[] {
|
|
61
|
+
const target = index + offset;
|
|
62
|
+
if (target < 0 || target >= rules.length) return [...rules];
|
|
63
|
+
const next = [...rules];
|
|
64
|
+
const [moved] = next.splice(index, 1);
|
|
65
|
+
if (moved === undefined) return next;
|
|
66
|
+
next.splice(target, 0, moved);
|
|
67
|
+
return next;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Effects of the saved policy that a user would not guess from the approval mode picker. */
|
|
71
|
+
export function policyWarnings({ policies, rules }: ToolPolicyState): string[] {
|
|
72
|
+
const warnings: string[] = [];
|
|
73
|
+
if (policies.bash === "allow") {
|
|
74
|
+
warnings.push(
|
|
75
|
+
"Bash is set to Allow, so it runs without asking in every mode, including Always Ask.",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (rules.some((rule) => rule.approval === "allow")) {
|
|
79
|
+
warnings.push("Commands matching an Allow rule run without asking, even in Always Ask.");
|
|
80
|
+
}
|
|
81
|
+
const asks =
|
|
82
|
+
Object.values(policies).includes("prompt") || rules.some((rule) => rule.approval === "prompt");
|
|
83
|
+
if (asks) {
|
|
84
|
+
warnings.push(
|
|
85
|
+
"Subagents cannot answer prompts, so a call that matches an Ask rule fails there.",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return warnings;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Add is offered only when the whole resulting list would pass the schema Apply uses. */
|
|
92
|
+
export function canAddToolRule(policies: ToolPolicies, tool: string): boolean {
|
|
93
|
+
return (
|
|
94
|
+
!Object.hasOwn(policies, tool) &&
|
|
95
|
+
OmpToolPoliciesSchema.safeParse({ ...policies, [tool]: "prompt" }).success
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function canAddBashRule(rules: readonly OmpBashRule[], match: string): boolean {
|
|
100
|
+
return OmpBashRulesSchema.safeParse([...rules, { match, approval: "prompt" }]).success;
|
|
101
|
+
}
|