@omercnet/paseo-omp 5.4.0-next.410.1 → 5.4.0-next.413.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/client/omp-config-surface.tsx +158 -83
- package/client/omp-config-views.ts +7 -3
- package/client/omp-security-section.tsx +99 -0
- package/client/omp-security-state.ts +14 -0
- package/client/omp-tool-policy-state.ts +101 -0
- package/client/omp-tool-policy.tsx +435 -0
- package/index.server.ts +3 -0
- package/package.json +1 -1
- package/server/omp-security.ts +169 -0
- package/server/omp-settings.ts +68 -4
- package/server/package-version.ts +1 -1
- package/shared/omp-security.ts +50 -0
- package/shared/omp-settings.ts +99 -4
package/server/omp-settings.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type OmpSetting,
|
|
13
13
|
type OmpSettingType,
|
|
14
14
|
OmpSettingTypeSchema,
|
|
15
|
+
OmpToolPoliciesSchema,
|
|
15
16
|
parseOmpStructuredSettingValue,
|
|
16
17
|
structuredSettingType,
|
|
17
18
|
type updateOmpSettings,
|
|
@@ -112,8 +113,9 @@ export async function writeProjectChanges(
|
|
|
112
113
|
if (document.errors.length > 0) throw new Error("Workspace OMP configuration is invalid YAML.");
|
|
113
114
|
for (const change of changes) {
|
|
114
115
|
const segments = change.path.split(".");
|
|
115
|
-
if (change.operation === "reset")
|
|
116
|
-
|
|
116
|
+
if (change.operation === "reset") {
|
|
117
|
+
if (document.hasIn(segments)) document.deleteIn(segments);
|
|
118
|
+
} else document.setIn(segments, change.value);
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
await mkdir(dirname(path), { recursive: true });
|
|
@@ -252,6 +254,51 @@ export const ompSettingsDependencies: OmpSettingsDependencies = {
|
|
|
252
254
|
validateProjectConfig: validateOmpProjectConfig,
|
|
253
255
|
};
|
|
254
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Project `tools.approval` entries merge with the user's instead of replacing them, so a project
|
|
259
|
+
* editor must know which entries are inherited.
|
|
260
|
+
*/
|
|
261
|
+
async function withUserToolPolicies(
|
|
262
|
+
executable: string,
|
|
263
|
+
dependencies: OmpSettingsDependencies,
|
|
264
|
+
settings: OmpSetting[],
|
|
265
|
+
): Promise<OmpSetting[]> {
|
|
266
|
+
const result = await dependencies.runConfig(executable, ["list", "--json"], tmpdir());
|
|
267
|
+
if (!runSucceeded(result)) return settings;
|
|
268
|
+
let listed: unknown;
|
|
269
|
+
try {
|
|
270
|
+
listed = JSON.parse(result.stdout);
|
|
271
|
+
} catch {
|
|
272
|
+
return settings;
|
|
273
|
+
}
|
|
274
|
+
const userValue =
|
|
275
|
+
parseOmpSettingsList(listed).settings.find((setting) => setting.path === "tools.approval")
|
|
276
|
+
?.value ?? {};
|
|
277
|
+
return settings.map((setting) =>
|
|
278
|
+
setting.path === "tools.approval" ? { ...setting, userValue } : setting,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Keeps a project `tools.approval` record to what differs from the user's, so inherited rules stay inherited. */
|
|
283
|
+
function projectChanges(
|
|
284
|
+
changes: RpcInput<typeof updateOmpSettings>["changes"],
|
|
285
|
+
byPath: ReadonlyMap<string, OmpSetting>,
|
|
286
|
+
): ProjectChange[] {
|
|
287
|
+
return changes.map((change) => {
|
|
288
|
+
if (change.operation !== "set" || change.path !== "tools.approval") return change;
|
|
289
|
+
const inherited =
|
|
290
|
+
OmpToolPoliciesSchema.safeParse(byPath.get(change.path)?.userValue).data ?? {};
|
|
291
|
+
const own = Object.fromEntries(
|
|
292
|
+
Object.entries(OmpToolPoliciesSchema.parse(change.value)).filter(
|
|
293
|
+
([tool, approval]) => inherited[tool] !== approval,
|
|
294
|
+
),
|
|
295
|
+
);
|
|
296
|
+
return Object.keys(own).length === 0
|
|
297
|
+
? { operation: "reset", path: change.path }
|
|
298
|
+
: { operation: "set", path: change.path, value: own };
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
255
302
|
async function loadCatalog(
|
|
256
303
|
executable: string | null | undefined,
|
|
257
304
|
dependencies: OmpSettingsDependencies,
|
|
@@ -301,7 +348,13 @@ async function loadCatalog(
|
|
|
301
348
|
revision,
|
|
302
349
|
droppedCount: catalog.droppedCount,
|
|
303
350
|
...(projectPath ? { path: projectPath } : path ? { path } : {}),
|
|
304
|
-
settings: cwd
|
|
351
|
+
settings: cwd
|
|
352
|
+
? await withUserToolPolicies(
|
|
353
|
+
resolved,
|
|
354
|
+
dependencies,
|
|
355
|
+
await markWorkspaceOverrides(cwd, catalog.settings),
|
|
356
|
+
)
|
|
357
|
+
: catalog.settings,
|
|
305
358
|
};
|
|
306
359
|
} catch {
|
|
307
360
|
return {
|
|
@@ -414,6 +467,17 @@ export async function updateOmpSettingsWithDependencies(
|
|
|
414
467
|
catalog: current,
|
|
415
468
|
};
|
|
416
469
|
}
|
|
470
|
+
if (change.path === "tools.approval" && setting.userValue === undefined) {
|
|
471
|
+
return {
|
|
472
|
+
conflict: false,
|
|
473
|
+
appliedPaths: [],
|
|
474
|
+
failed: {
|
|
475
|
+
path: change.path,
|
|
476
|
+
message: "Could not read the user-level tool approvals. Try again.",
|
|
477
|
+
},
|
|
478
|
+
catalog: current,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
417
481
|
}
|
|
418
482
|
|
|
419
483
|
const projectPath = join(input.cwd, ".omp", "config.yml");
|
|
@@ -427,7 +491,7 @@ export async function updateOmpSettingsWithDependencies(
|
|
|
427
491
|
const outcome = await writeProjectChanges(
|
|
428
492
|
input.cwd,
|
|
429
493
|
afterValidation,
|
|
430
|
-
input.changes,
|
|
494
|
+
projectChanges(input.changes, byPath),
|
|
431
495
|
executable,
|
|
432
496
|
dependencies,
|
|
433
497
|
);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Release Please keeps this bundle-safe constant aligned with package.json. */
|
|
2
|
-
export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.
|
|
2
|
+
export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.413.1"; // x-release-please-version
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { OmpWorkspaceCwdSchema } from "./hub";
|
|
4
|
+
import { OmpStoreSchema } from "./omp-store";
|
|
5
|
+
|
|
6
|
+
export const OMP_SECURITY_SEVERITIES = [
|
|
7
|
+
"critical",
|
|
8
|
+
"high",
|
|
9
|
+
"medium",
|
|
10
|
+
"low",
|
|
11
|
+
"informational",
|
|
12
|
+
] as const;
|
|
13
|
+
export const OmpSecuritySeveritySchema = z.enum(OMP_SECURITY_SEVERITIES);
|
|
14
|
+
export type OmpSecuritySeverity = z.infer<typeof OmpSecuritySeveritySchema>;
|
|
15
|
+
|
|
16
|
+
export const OmpSecurityScanSchema = z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
/** OMP's scan status: planned, running, completed, partial, cancelled or failed. */
|
|
19
|
+
phase: z.string(),
|
|
20
|
+
findingCount: z.number().int().nonnegative(),
|
|
21
|
+
/** Findings per severity. Counts only; finding titles and locations are never sent. */
|
|
22
|
+
severities: z.record(OmpSecuritySeveritySchema, z.number().int().nonnegative()),
|
|
23
|
+
/** False when OMP's finding listing was cut short, so the counts add up to less than `findingCount`. */
|
|
24
|
+
severitiesComplete: z.boolean(),
|
|
25
|
+
producer: z.string(),
|
|
26
|
+
createdAt: z.string(),
|
|
27
|
+
});
|
|
28
|
+
export type OmpSecurityScan = z.infer<typeof OmpSecurityScanSchema>;
|
|
29
|
+
|
|
30
|
+
export const OmpSecurityListSchema = z.discriminatedUnion("status", [
|
|
31
|
+
z.object({
|
|
32
|
+
status: z.literal("ready"),
|
|
33
|
+
scans: z.array(OmpSecurityScanSchema),
|
|
34
|
+
/** More scans are stored than are listed. */
|
|
35
|
+
truncated: z.boolean(),
|
|
36
|
+
/** Lines of OMP's scan list the plugin could not read or that repeated an id. */
|
|
37
|
+
skipped: z.number().int().nonnegative(),
|
|
38
|
+
}),
|
|
39
|
+
/** `security.enabled` is false, so OMP refuses to read its security resources. */
|
|
40
|
+
z.object({ status: z.literal("off") }),
|
|
41
|
+
z.object({ status: z.literal("error"), message: z.string() }),
|
|
42
|
+
]);
|
|
43
|
+
export type OmpSecurityList = z.infer<typeof OmpSecurityListSchema>;
|
|
44
|
+
|
|
45
|
+
/** Scans are keyed by project, so a workspace is required. */
|
|
46
|
+
export const listOmpSecurity = defineRpc({
|
|
47
|
+
name: "paseo-omp.list-security",
|
|
48
|
+
input: z.object({ store: OmpStoreSchema.optional(), cwd: OmpWorkspaceCwdSchema }).strict(),
|
|
49
|
+
output: OmpSecurityListSchema,
|
|
50
|
+
});
|
package/shared/omp-settings.ts
CHANGED
|
@@ -21,6 +21,7 @@ const MAX_ROUTING_ENTRIES = 64;
|
|
|
21
21
|
const MAX_FALLBACK_CHAIN_LENGTH = 16;
|
|
22
22
|
const MAX_AGENT_MODEL_CHOICES = 8;
|
|
23
23
|
const MAX_MODEL_SELECTOR_LENGTH = 513;
|
|
24
|
+
const MAX_BASH_RULES = 128;
|
|
24
25
|
|
|
25
26
|
function containsControlCharacter(value: string): boolean {
|
|
26
27
|
for (const character of value) {
|
|
@@ -143,6 +144,44 @@ export const OmpDisabledAgentsSchema = z
|
|
|
143
144
|
.max(MAX_ROUTING_ENTRIES)
|
|
144
145
|
.refine((value) => new Set(value).size === value.length, "Disabled agents must be unique.");
|
|
145
146
|
|
|
147
|
+
export const OmpToolApprovalSchema = z.enum(["allow", "prompt", "deny"]);
|
|
148
|
+
export type OmpToolApproval = z.infer<typeof OmpToolApprovalSchema>;
|
|
149
|
+
|
|
150
|
+
export const OmpToolPoliciesSchema = z
|
|
151
|
+
.record(
|
|
152
|
+
z.string().regex(/^[A-Za-z0-9_.:-]{1,128}$/u, "Tool names use letters, digits and _ . : -."),
|
|
153
|
+
OmpToolApprovalSchema,
|
|
154
|
+
)
|
|
155
|
+
.refine((value) => Object.keys(value).length <= MAX_ROUTING_ENTRIES, "Too many tool policies.");
|
|
156
|
+
|
|
157
|
+
export const OmpBashRuleSchema = z
|
|
158
|
+
.object({
|
|
159
|
+
match: z
|
|
160
|
+
.string()
|
|
161
|
+
.min(1)
|
|
162
|
+
.max(512)
|
|
163
|
+
.refine((value) => !containsControlCharacter(value), "Rules cannot hold control characters."),
|
|
164
|
+
approval: OmpToolApprovalSchema,
|
|
165
|
+
})
|
|
166
|
+
.strict();
|
|
167
|
+
export type OmpBashRule = z.infer<typeof OmpBashRuleSchema>;
|
|
168
|
+
|
|
169
|
+
export const OmpBashRulesSchema = z.array(OmpBashRuleSchema).max(MAX_BASH_RULES);
|
|
170
|
+
|
|
171
|
+
export const OmpRestrictedFoldersSchema = z
|
|
172
|
+
.array(
|
|
173
|
+
z
|
|
174
|
+
.string()
|
|
175
|
+
.min(1)
|
|
176
|
+
.max(1024)
|
|
177
|
+
.refine(
|
|
178
|
+
(value) => !containsControlCharacter(value),
|
|
179
|
+
"Folders cannot hold control characters.",
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
.max(MAX_ROUTING_ENTRIES)
|
|
183
|
+
.refine((value) => new Set(value).size === value.length, "Restricted folders must be unique.");
|
|
184
|
+
|
|
146
185
|
export const OMP_STRUCTURED_SETTING_PATHS = [
|
|
147
186
|
"modelRoles",
|
|
148
187
|
"retry.fallbackChains",
|
|
@@ -152,6 +191,9 @@ export const OMP_STRUCTURED_SETTING_PATHS = [
|
|
|
152
191
|
"task.agentPrewalk",
|
|
153
192
|
"task.agentAdvisor",
|
|
154
193
|
"task.disabledAgents",
|
|
194
|
+
"tools.approval",
|
|
195
|
+
"bash.patterns",
|
|
196
|
+
"tools.restrictedFolders",
|
|
155
197
|
] as const;
|
|
156
198
|
export type OmpStructuredSettingPath = (typeof OMP_STRUCTURED_SETTING_PATHS)[number];
|
|
157
199
|
|
|
@@ -173,6 +215,12 @@ export function parseOmpStructuredSettingValue(path: string, value: unknown): un
|
|
|
173
215
|
return OmpAgentAdvisorSchema.safeParse(value).data;
|
|
174
216
|
case "task.disabledAgents":
|
|
175
217
|
return OmpDisabledAgentsSchema.safeParse(value).data;
|
|
218
|
+
case "tools.approval":
|
|
219
|
+
return OmpToolPoliciesSchema.safeParse(value).data;
|
|
220
|
+
case "bash.patterns":
|
|
221
|
+
return OmpBashRulesSchema.safeParse(value).data;
|
|
222
|
+
case "tools.restrictedFolders":
|
|
223
|
+
return OmpRestrictedFoldersSchema.safeParse(value).data;
|
|
176
224
|
default:
|
|
177
225
|
return undefined;
|
|
178
226
|
}
|
|
@@ -182,9 +230,16 @@ export function isOmpStructuredSettingPath(path: string): path is OmpStructuredS
|
|
|
182
230
|
return (OMP_STRUCTURED_SETTING_PATHS as readonly string[]).includes(path);
|
|
183
231
|
}
|
|
184
232
|
|
|
233
|
+
const ARRAY_STRUCTURED_SETTING_PATHS: readonly string[] = [
|
|
234
|
+
"cycleOrder",
|
|
235
|
+
"task.disabledAgents",
|
|
236
|
+
"bash.patterns",
|
|
237
|
+
"tools.restrictedFolders",
|
|
238
|
+
];
|
|
239
|
+
|
|
185
240
|
/** The OMP value type each structured path must have to be editable. */
|
|
186
241
|
export function structuredSettingType(path: OmpStructuredSettingPath): "array" | "record" {
|
|
187
|
-
return path
|
|
242
|
+
return ARRAY_STRUCTURED_SETTING_PATHS.includes(path) ? "array" : "record";
|
|
188
243
|
}
|
|
189
244
|
|
|
190
245
|
export const OmpSettingSchema = z
|
|
@@ -196,6 +251,8 @@ export const OmpSettingSchema = z
|
|
|
196
251
|
redacted: z.boolean().optional(),
|
|
197
252
|
configured: z.boolean().optional(),
|
|
198
253
|
workspaceOverride: z.boolean().optional(),
|
|
254
|
+
/** Workspace scope only: the user-level value of a setting whose project value merges with it. */
|
|
255
|
+
userValue: z.unknown().optional(),
|
|
199
256
|
})
|
|
200
257
|
.strict();
|
|
201
258
|
export type OmpSetting = z.infer<typeof OmpSettingSchema>;
|
|
@@ -386,9 +443,24 @@ const OMP_TOOL_SWITCHES: readonly { path: string; label: string; description: st
|
|
|
386
443
|
];
|
|
387
444
|
|
|
388
445
|
const TOOL_SWITCH_LABELS = new Map(OMP_TOOL_SWITCHES.map(({ path, label }) => [path, label]));
|
|
446
|
+
const SETTING_LABELS = new Map([
|
|
447
|
+
...TOOL_SWITCH_LABELS,
|
|
448
|
+
["tools.approvalMode", "Approval mode (not used by Paseo)"],
|
|
449
|
+
]);
|
|
450
|
+
|
|
451
|
+
const OMP_TOOL_POLICY_PATHS: readonly string[] = [
|
|
452
|
+
"tools.approval",
|
|
453
|
+
"bash.patterns",
|
|
454
|
+
"tools.restrictedFolders",
|
|
455
|
+
];
|
|
456
|
+
|
|
457
|
+
/** Settings the Tool policy card edits in place of the generic list. */
|
|
458
|
+
export function isOmpToolPolicyPath(path: string): boolean {
|
|
459
|
+
return OMP_TOOL_POLICY_PATHS.includes(path);
|
|
460
|
+
}
|
|
389
461
|
|
|
390
462
|
export function categorizeOmpSetting(path: string): OmpSettingCategory {
|
|
391
|
-
if (TOOL_SWITCH_LABELS.has(path)) return "tools";
|
|
463
|
+
if (TOOL_SWITCH_LABELS.has(path) || isOmpToolPolicyPath(path)) return "tools";
|
|
392
464
|
for (const category of OMP_SETTING_CATEGORIES) {
|
|
393
465
|
if (CATEGORY_PREFIXES[category].some((prefix) => path === prefix || path.startsWith(prefix))) {
|
|
394
466
|
return category;
|
|
@@ -398,8 +470,8 @@ export function categorizeOmpSetting(path: string): OmpSettingCategory {
|
|
|
398
470
|
}
|
|
399
471
|
|
|
400
472
|
export function formatOmpSettingLabel(path: string): string {
|
|
401
|
-
const
|
|
402
|
-
if (
|
|
473
|
+
const settingLabel = SETTING_LABELS.get(path);
|
|
474
|
+
if (settingLabel) return settingLabel;
|
|
403
475
|
const leaf = path.split(".").at(-1) ?? path;
|
|
404
476
|
const words = leaf
|
|
405
477
|
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
@@ -421,6 +493,8 @@ export function orderOmpToolSettings(settings: readonly OmpSetting[]): OmpSettin
|
|
|
421
493
|
/** Plain wording that replaces OMP's own description (or its absence) for these settings. */
|
|
422
494
|
export const OMP_SETTING_DESCRIPTIONS: Readonly<Record<string, string>> = {
|
|
423
495
|
...Object.fromEntries(OMP_TOOL_SWITCHES.map(({ path, description }) => [path, description])),
|
|
496
|
+
"tools.approvalMode":
|
|
497
|
+
"Has no effect on Paseo agents: Paseo launches OMP with its own approval mode (Full Access, Write Approval or Always Ask), and that flag overrides this setting. It only applies to OMP run outside Paseo.",
|
|
424
498
|
"session.warnCost":
|
|
425
499
|
"Warn once when a session's spend reaches this many US dollars. Leave unset for no warning. Applies to every session, including subagents, and takes effect on the next request.",
|
|
426
500
|
"session.maxCost":
|
|
@@ -510,6 +584,27 @@ const OmpStructuredSettingChangeSchema = z.discriminatedUnion("path", [
|
|
|
510
584
|
value: OmpDisabledAgentsSchema,
|
|
511
585
|
})
|
|
512
586
|
.strict(),
|
|
587
|
+
z
|
|
588
|
+
.object({
|
|
589
|
+
operation: z.literal("set"),
|
|
590
|
+
path: z.literal("tools.approval"),
|
|
591
|
+
value: OmpToolPoliciesSchema,
|
|
592
|
+
})
|
|
593
|
+
.strict(),
|
|
594
|
+
z
|
|
595
|
+
.object({
|
|
596
|
+
operation: z.literal("set"),
|
|
597
|
+
path: z.literal("bash.patterns"),
|
|
598
|
+
value: OmpBashRulesSchema,
|
|
599
|
+
})
|
|
600
|
+
.strict(),
|
|
601
|
+
z
|
|
602
|
+
.object({
|
|
603
|
+
operation: z.literal("set"),
|
|
604
|
+
path: z.literal("tools.restrictedFolders"),
|
|
605
|
+
value: OmpRestrictedFoldersSchema,
|
|
606
|
+
})
|
|
607
|
+
.strict(),
|
|
513
608
|
]);
|
|
514
609
|
|
|
515
610
|
const OmpSettingChangeSchema = z.union([
|