@posthog/agent 2.3.507 → 2.3.508

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.
@@ -196,6 +196,7 @@ export interface ClaudeCodeSettings {
196
196
  permissions?: PermissionSettings;
197
197
  env?: Record<string, string>;
198
198
  model?: string;
199
+ posthogApprovedExecTools?: string[];
199
200
  }
200
201
 
201
202
  export type PermissionDecision = "allow" | "deny" | "ask";
@@ -295,6 +296,7 @@ export class SettingsManager {
295
296
  ask: [],
296
297
  };
297
298
  const merged: ClaudeCodeSettings = { permissions };
299
+ const posthogApprovedExecTools = new Set<string>();
298
300
 
299
301
  for (const settings of allSettings) {
300
302
  if (settings.permissions) {
@@ -323,6 +325,15 @@ export class SettingsManager {
323
325
  if (settings.model) {
324
326
  merged.model = settings.model;
325
327
  }
328
+ if (settings.posthogApprovedExecTools) {
329
+ for (const tool of settings.posthogApprovedExecTools) {
330
+ posthogApprovedExecTools.add(tool);
331
+ }
332
+ }
333
+ }
334
+
335
+ if (posthogApprovedExecTools.size > 0) {
336
+ merged.posthogApprovedExecTools = Array.from(posthogApprovedExecTools);
326
337
  }
327
338
 
328
339
  this.mergedSettings = merged;
@@ -405,6 +416,43 @@ export class SettingsManager {
405
416
  }
406
417
  }
407
418
 
419
+ hasPostHogExecApproval(subTool: string): boolean {
420
+ return (
421
+ this.mergedSettings.posthogApprovedExecTools?.includes(subTool) ?? false
422
+ );
423
+ }
424
+
425
+ /**
426
+ * Persists an approved PostHog MCP `exec` sub-tool (e.g. `experiment-update`)
427
+ * to the local settings file so future calls skip the prompt. Mirrors
428
+ * `addAllowRules` — serialised via `writeMutex`, atomic temp-file + rename.
429
+ */
430
+ async addPostHogExecApproval(subTool: string): Promise<void> {
431
+ if (!subTool) return;
432
+ if (!this.initialized) await this.initialize();
433
+ await this.writeMutex.acquire();
434
+ try {
435
+ const filePath = this.getLocalSettingsPath();
436
+ const existing = await readSettingsFileForUpdate(filePath);
437
+ const current = new Set(existing.posthogApprovedExecTools ?? []);
438
+ if (current.has(subTool)) {
439
+ return;
440
+ }
441
+ current.add(subTool);
442
+ const next: ClaudeCodeSettings = {
443
+ ...existing,
444
+ posthogApprovedExecTools: Array.from(current),
445
+ };
446
+ await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
447
+ await writeFileAtomic(filePath, `${JSON.stringify(next, null, 2)}\n`);
448
+
449
+ this.localSettings = next;
450
+ this.mergeAllSettings();
451
+ } finally {
452
+ this.writeMutex.release();
453
+ }
454
+ }
455
+
408
456
  async setCwd(cwd: string): Promise<void> {
409
457
  if (this.cwd === cwd) return;
410
458
  if (this.initPromise) await this.initPromise;