Permission Sheet

What an agent may do in each app (always, ask first or never), and the moment it asks to use one.

  • FilesRead and edit files in your drive
  • MailRead, draft and send email
  • Team chatRead channels and post messages
  • CRMRead accounts and dealsNot connected

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/permission-sheet

Usage

import { PermissionList, PermissionRequest } from "./ui/uicontext/components/kit/PermissionSheet.ts"
const Message = UiSchema.TaggedEnum({	ChangedAccess: { app: Schema.String, access: Schema.Literals(["always", "ask", "never"]) },	Answered: { request: Schema.String, allow: Schema.Boolean },})// the settings list goes in a Sheet; the request goes in the conversation where the task stoppedexport const Permissions = (h: Html.H<typeof Message.Type>) => [	PermissionList(h, {		apps: [{ id: "mail", name: "Mail", mark: { letter: "M", tone: "red" }, description: "Read, draft and send email", access: "ask" }],		onChange: (app, access) => Message.ChangedAccess({ app, access }),	}),	PermissionRequest(h, {		agent: "Work", state: "pending",		apps: [{ id: "mail", name: "Mail", mark: { letter: "M", tone: "red" }, scope: "full", warning: "Can send email as you" }],		onAllow: Message.Answered({ request: "p1", allow: true }),		onDeny: Message.Answered({ request: "p1", allow: false }),	}),]

Examples

When a task asks

Each app with its scope, and a warning where it reaches far. Deny or Allow for this session; the answer stays as a receipt.

Work wants to use:

  • Team chatFull controlCan post as you
  • AccountingView only

You'll be asked again next task. Change this for good in Permissions.

API reference

PermissionListView function

Options

PermissionList options
NameTypeDescription
appsrequiredAppPermission[]—
onChangerequired(app: string, access: AppAccess) => Message—
labelstring—
styleStyle—

PermissionRequestView function

Options

PermissionRequest options
NameTypeDescription
agentrequiredstringWho asks: the agent's name
appsrequiredRequestedApp[]—
notestringA sentence under the apps: what happens while it works
staterequired"pending" | "allowed" | "denied"—
onAllowrequiredMessage—
onDenyrequiredMessage—
answeringbooleanThe answer is on its way: the buttons wait
styleStyle—

Source