import { z } from "zod/v4"; /** * The v2 app permission vocabulary (plan ยง12.1). * * Deliberately coarse: each value is a consent-screen line item, not a * per-endpoint scope. Sensitive domains (messages, mail, calendar, tasks) * are intentionally absent and land post-v2 as individual product * decisions. */ export const APP_PERMISSIONS_V2 = [ "members.read", "files.read", "files.write", "drives.app", "storage.app", "search.index", "search.query", "notifications.write", "ai.generate", "ai.tools", "events.emit", "webhooks.subscribe", "commands.register", "realtime.subscribe", ] as const; export const appPermissionV2Schema = z.enum(APP_PERMISSIONS_V2); export type AppPermissionV2 = z.infer; /** Human-readable consent copy, keyed by permission. */ export const APP_PERMISSION_V2_DESCRIPTIONS: Record = { "members.read": "See who is in the workspace (names, handles, avatars).", "files.read": "Read files the installing user can access.", "files.write": "Create and update files on behalf of users.", "drives.app": "Use its own app drive for files it creates.", "storage.app": "Store app data (key-value state and records) in the workspace.", "search.index": "Add its content to workspace search.", "search.query": "Search the workspace on behalf of users.", "notifications.write": "Send notifications to workspace members.", "ai.generate": "Use Coline AI models (billed to the workspace).", "ai.tools": "Offer tools that Kairo and agents can run.", "events.emit": "Emit ambient events into the workspace.", "webhooks.subscribe": "Receive workspace events at its backend.", "commands.register": "Add commands to the command palette.", "realtime.subscribe": "Receive live updates for its own surfaces.", }; export const appPermissionV2ListSchema = z .array(appPermissionV2Schema) .max(APP_PERMISSIONS_V2.length) .default([]) .refine( (values) => new Set(values).size === values.length, "Permissions must be unique.", );