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. Tasks, calendar, and messages require explicit consent * and an invoking user; mail is not exposed. */ export const APP_PERMISSIONS_V2 = [ "references.read", "tasks.read", "tasks.write", "calendar.read", "calendar.write", "messages.read", "messages.write", "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", "network.external", "jobs.run", "endpoints.receive", "connections.use", "site.serve", ] 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 = { "references.read": "Resolve names and links for workspace objects you can access.", "tasks.read": "Read tasks and task board statuses you can access.", "tasks.write": "Create, edit, and delete tasks on your behalf.", "calendar.read": "Read calendar events you can access.", "calendar.write": "Create, edit, and cancel calendar events on your behalf.", "messages.read": "Read conversations and task or event comments you can access.", "messages.write": "Send messages and comments on your behalf.", "members.read": "See who is in the workspace (names, emails, 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.", "network.external": "Call the external services it lists (through Coline, with the app's own credentials).", "jobs.run": "Run background work after you leave, on your behalf or its own.", "endpoints.receive": "Receive requests from the external services it lists at private URLs.", "connections.use": "Ask you to connect accounts on the services it lists, and use them for you.", "site.serve": "Serve a public website. Visitors can use only the tools and collections the app opens to them.", }; export const appPermissionV2ListSchema = z .array(appPermissionV2Schema) .max(APP_PERMISSIONS_V2.length) .default([]) .refine((values) => new Set(values).size === values.length, "Permissions must be unique.");