@plosson/agentio 0.4.3 → 0.5.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,22 @@
1
+ import { CliError } from './errors';
2
+ import { isProfileReadOnly } from '../config/config-manager';
3
+ import type { ServiceName } from '../types/config';
4
+
5
+ /**
6
+ * Enforce that a profile has write access for a given operation.
7
+ * Throws a CliError if the profile is read-only.
8
+ */
9
+ export async function enforceWriteAccess(
10
+ service: ServiceName,
11
+ profile: string,
12
+ operation: string
13
+ ): Promise<void> {
14
+ const readOnly = await isProfileReadOnly(service, profile);
15
+ if (readOnly) {
16
+ throw new CliError(
17
+ 'PERMISSION_DENIED',
18
+ `Cannot ${operation}: profile "${profile}" is read-only`,
19
+ `To modify this profile's access: agentio ${service} profile update --profile ${profile} --no-read-only`
20
+ );
21
+ }
22
+ }