@omercnet/paseo-omp 5.4.0-next.409.1 → 5.4.0-next.412.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.
@@ -0,0 +1,169 @@
1
+ import type { RpcInput } from "@getpaseo/plugin";
2
+ import { z } from "zod";
3
+ import {
4
+ type listOmpSecurity,
5
+ type OmpSecurityList,
6
+ type OmpSecurityScan,
7
+ type OmpSecuritySeverity,
8
+ OmpSecuritySeveritySchema,
9
+ } from "../shared/omp-security";
10
+ import {
11
+ type OmpListDependencies,
12
+ ompListDependencies,
13
+ requireOmpExecutable,
14
+ } from "./omp-list-setting";
15
+ import { inOmpScope, readSetting } from "./omp-rules";
16
+ import { OmpPublicError } from "./provider/security";
17
+
18
+ const MAX_SCANS = 20;
19
+ const MAX_PARALLEL_READS = 4;
20
+ const MAX_FIELD_CHARS = 256;
21
+ const DASH = "\u2014";
22
+ const SCAN_LINE = new RegExp(
23
+ `^- \`(secscan_[A-Za-z0-9]+)\` ${DASH} (\\w+); (\\d+) finding\\(s\\); (.*); (\\S+)$`,
24
+ "u",
25
+ );
26
+ const FINDING_LINE = new RegExp(`^- \`[^\`]+\` \\*\\*(\\w+)\\*\\* ${DASH} `, "u");
27
+ const EnabledSchema = z.object({ value: z.boolean() });
28
+
29
+ export class OmpSecurityError extends OmpPublicError {}
30
+
31
+ interface ListedScan {
32
+ id: string;
33
+ phase: string;
34
+ findingCount: number;
35
+ producer: string;
36
+ createdAt: string;
37
+ }
38
+
39
+ interface ParsedScans {
40
+ scans: ListedScan[];
41
+ /** Bullet lines that did not parse, or repeated an id: an odd producer name can break a line. */
42
+ skipped: number;
43
+ }
44
+
45
+ /**
46
+ * The scan lines of `security://scans`. A heading or a blank line is ignored; a bullet that does
47
+ * not parse, or whose id was already listed, is counted as skipped so the tab can say so.
48
+ */
49
+ export function parseScanLines(text: string): ParsedScans {
50
+ const scans: ListedScan[] = [];
51
+ const seen = new Set<string>();
52
+ let skipped = 0;
53
+ for (const line of text.split("\n")) {
54
+ if (!line.startsWith("- `")) continue;
55
+ const match = SCAN_LINE.exec(line);
56
+ if (!match || seen.has(match[1])) {
57
+ skipped += 1;
58
+ continue;
59
+ }
60
+ const [, id, phase, count, producer, createdAt] = match;
61
+ seen.add(id);
62
+ scans.push({
63
+ id: id.slice(0, MAX_FIELD_CHARS),
64
+ phase: phase.slice(0, MAX_FIELD_CHARS),
65
+ findingCount: Number(count),
66
+ producer: producer.slice(0, MAX_FIELD_CHARS),
67
+ createdAt: createdAt.slice(0, MAX_FIELD_CHARS),
68
+ });
69
+ }
70
+ return { scans, skipped };
71
+ }
72
+
73
+ /** Counts the severity at the start of each finding line; a title can never be mistaken for one. */
74
+ export function countSeverities(text: string): Record<OmpSecuritySeverity, number> {
75
+ const counts: Record<OmpSecuritySeverity, number> = {
76
+ critical: 0,
77
+ high: 0,
78
+ medium: 0,
79
+ low: 0,
80
+ informational: 0,
81
+ };
82
+ for (const line of text.split("\n")) {
83
+ const level = OmpSecuritySeveritySchema.safeParse(FINDING_LINE.exec(line)?.[1]);
84
+ if (level.success) counts[level.data] += 1;
85
+ }
86
+ return counts;
87
+ }
88
+
89
+ async function readResource(
90
+ dependencies: OmpListDependencies,
91
+ executable: string,
92
+ url: string,
93
+ cwd: string,
94
+ ): Promise<string> {
95
+ const run = await dependencies.run(executable, ["read", url], cwd);
96
+ if (run.outcome === "timeout") throw new OmpSecurityError(`omp read ${url} timed out`);
97
+ if (run.outcome !== "exited" || run.exitCode !== 0 || run.truncated) {
98
+ throw new OmpSecurityError(`omp read ${url} failed`);
99
+ }
100
+ return run.stdout;
101
+ }
102
+
103
+ /** A scan whose findings cannot be read still lists, with its counts marked incomplete. */
104
+ async function withSeverities(
105
+ dependencies: OmpListDependencies,
106
+ executable: string,
107
+ scan: ListedScan,
108
+ cwd: string,
109
+ ): Promise<OmpSecurityScan> {
110
+ const url = `security://scans/${scan.id}/findings`;
111
+ const text =
112
+ scan.findingCount === 0
113
+ ? ""
114
+ : await readResource(dependencies, executable, url, cwd).catch((error: unknown) => {
115
+ if (error instanceof OmpSecurityError) return null;
116
+ throw error;
117
+ });
118
+ const severities = countSeverities(text ?? "");
119
+ const counted = Object.values(severities).reduce((sum, count) => sum + count, 0);
120
+ return {
121
+ ...scan,
122
+ severities,
123
+ severitiesComplete: text !== null && counted === scan.findingCount,
124
+ };
125
+ }
126
+
127
+ /**
128
+ * Scans live in OMP's private, project-keyed store. The plugin reads them through OMP itself
129
+ * (`omp read security://...`), the documented read-only surface, so the store layout, profiles and
130
+ * XDG roots stay OMP's business. Only phase and counts leave the server, never finding details.
131
+ */
132
+ export async function listOmpSecurityWithDependencies(
133
+ input: RpcInput<typeof listOmpSecurity>,
134
+ dependencies: OmpListDependencies,
135
+ ): Promise<OmpSecurityList> {
136
+ try {
137
+ const executable = await requireOmpExecutable(dependencies);
138
+ return await inOmpScope(input.cwd, dependencies, async (runIn) => {
139
+ const enabled = await readSetting(
140
+ dependencies,
141
+ executable,
142
+ "security.enabled",
143
+ EnabledSchema,
144
+ runIn,
145
+ );
146
+ if (!enabled) return { status: "off" as const };
147
+ const text = await readResource(dependencies, executable, "security://scans", runIn);
148
+ const { scans: listed, skipped } = parseScanLines(text);
149
+ const shown = listed.slice(0, MAX_SCANS);
150
+ const scans: OmpSecurityScan[] = [];
151
+ for (let start = 0; start < shown.length; start += MAX_PARALLEL_READS) {
152
+ const batch = shown.slice(start, start + MAX_PARALLEL_READS);
153
+ scans.push(
154
+ ...(await Promise.all(
155
+ batch.map((scan) => withSeverities(dependencies, executable, scan, runIn)),
156
+ )),
157
+ );
158
+ }
159
+ return { status: "ready" as const, scans, truncated: listed.length > shown.length, skipped };
160
+ });
161
+ } catch (error) {
162
+ if (error instanceof OmpPublicError) return { status: "error", message: error.message };
163
+ throw error;
164
+ }
165
+ }
166
+
167
+ export function resolveListOmpSecurity(input: RpcInput<typeof listOmpSecurity>) {
168
+ return listOmpSecurityWithDependencies(input, ompListDependencies);
169
+ }
@@ -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") document.deleteIn(segments);
116
- else document.setIn(segments, change.value);
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 ? await markWorkspaceOverrides(cwd, catalog.settings) : catalog.settings,
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.409.1"; // x-release-please-version
2
+ export const PASEO_OMP_PACKAGE_VERSION = "5.4.0-next.412.1"; // x-release-please-version
@@ -200,7 +200,7 @@ function inheritedEnvironmentNames(inheritEnv: readonly string[] | undefined): R
200
200
  return names;
201
201
  }
202
202
 
203
- function buildOmpEnvironment(
203
+ export function buildOmpEnvironment(
204
204
  sessionEnv: Readonly<Record<string, string>> | undefined,
205
205
  inheritEnv: readonly string[] | undefined,
206
206
  sourceEnv: NodeJS.ProcessEnv,
@@ -356,6 +356,8 @@ export interface BoundedRun {
356
356
  spawnErrorCode: string | null;
357
357
  /** True when tree termination/verification failed or the leader missed its final close bound. */
358
358
  cleanupFailed: boolean;
359
+ /** Only present when the caller asked for it with `stderrLimit`. Never forwarded across RPC. */
360
+ stderr?: string;
359
361
  }
360
362
 
361
363
  /**
@@ -375,6 +377,7 @@ export function runBounded(
375
377
  killGraceMs: number,
376
378
  maxBytes: number,
377
379
  cwd?: string,
380
+ stderrLimit = 0,
378
381
  ): Promise<BoundedRun> {
379
382
  const { promise, resolve } = Promise.withResolvers<BoundedRun>();
380
383
  let child: ProbeChildProcess;
@@ -397,6 +400,8 @@ export function runBounded(
397
400
  const stdoutChunks: Buffer[] = [];
398
401
  let stdoutBytes = 0;
399
402
  let truncated = false;
403
+ const stderrChunks: Buffer[] = [];
404
+ let stderrBytes = 0;
400
405
  let timedOut = false;
401
406
  let leaderClosed = false;
402
407
  let leaderExitCode: number | null = null;
@@ -405,6 +410,7 @@ export function runBounded(
405
410
  let treeCleanupSucceeded = false;
406
411
  let finalLeaderTimer: ReturnType<typeof setTimeout> | undefined;
407
412
  const getStdout = () => Buffer.concat(stdoutChunks, stdoutBytes).toString("utf8");
413
+ const getStderr = () => Buffer.concat(stderrChunks, stderrBytes).toString("utf8");
408
414
 
409
415
  const cleanupListeners = () => {
410
416
  child.stdout.removeAllListeners();
@@ -428,6 +434,7 @@ export function runBounded(
428
434
  signal: leaderSignal,
429
435
  spawnErrorCode: null,
430
436
  cleanupFailed,
437
+ ...(stderrLimit > 0 ? { stderr: getStderr() } : {}),
431
438
  });
432
439
  };
433
440
  const settleAfterCleanup = () => {
@@ -482,8 +489,14 @@ export function runBounded(
482
489
  stdoutChunks.push(accepted);
483
490
  stdoutBytes += accepted.length;
484
491
  });
485
- child.stderr.on("data", () => {
486
- // Intentionally discarded: never stored, parsed, or forwarded across the RPC boundary.
492
+ child.stderr.on("data", (chunk: Buffer) => {
493
+ // Discarded unless the caller opted in with `stderrLimit`; then kept, bounded, for that
494
+ // caller to parse. It is never forwarded across the RPC boundary as-is.
495
+ const remaining = stderrLimit - stderrBytes;
496
+ if (remaining <= 0) return;
497
+ const accepted = chunk.subarray(0, remaining);
498
+ stderrChunks.push(accepted);
499
+ stderrBytes += accepted.length;
487
500
  });
488
501
  child.onClose((code, signal) => {
489
502
  leaderClosed = true;
@@ -501,6 +514,7 @@ export function runBounded(
501
514
  signal,
502
515
  spawnErrorCode: null,
503
516
  cleanupFailed: false,
517
+ ...(stderrLimit > 0 ? { stderr: getStderr() } : {}),
504
518
  });
505
519
  });
506
520
 
@@ -0,0 +1,30 @@
1
+ import { defineRpc } from "@getpaseo/plugin";
2
+ import { z } from "zod";
3
+ import { OmpStoreSchema } from "./omp-store";
4
+
5
+ /**
6
+ * Whether OMP loaded `models.yml`. A typo makes OMP drop every custom provider with only a
7
+ * warning, so the card says so. `unknown` means the check could not run: never a guess.
8
+ */
9
+ export const OmpModelsFileStatusSchema = z.discriminatedUnion("state", [
10
+ z.object({ state: z.literal("ok") }),
11
+ /**
12
+ * OMP's own validation message, control characters stripped and bounded. Values OMP echoes as
13
+ * "(was ...)" are removed; field paths and the provider and model names from the file remain.
14
+ */
15
+ z.object({ state: z.literal("invalid"), detail: z.string().max(400) }),
16
+ z.object({ state: z.literal("unknown") }),
17
+ ]);
18
+ export type OmpModelsFileStatus = z.infer<typeof OmpModelsFileStatusSchema>;
19
+
20
+ export const getOmpModelsFileStatus = defineRpc({
21
+ name: "paseo-omp.get-models-file-status",
22
+ input: z.object({ store: OmpStoreSchema.optional() }),
23
+ output: OmpModelsFileStatusSchema,
24
+ });
25
+
26
+ export const refreshOmpModels = defineRpc({
27
+ name: "paseo-omp.refresh-models",
28
+ input: z.object({ store: OmpStoreSchema.optional() }),
29
+ output: z.object({ ok: z.boolean(), message: z.string() }),
30
+ });
@@ -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
+ });
@@ -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 === "cycleOrder" || path === "task.disabledAgents" ? "array" : "record";
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 switchLabel = TOOL_SWITCH_LABELS.get(path);
402
- if (switchLabel) return switchLabel;
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([