Skip to content
567 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step1/**
2 * Scopes: what an access token may do on its owner's behalf. Mirrors
3 * `crates/contracts/src/scopes.rs`, which is the source of truth; a Rust
4 * test keeps the tables here the same.
5 *
6 * A token reaches whatever its owner can reach (a workspace's token, that
7 * workspace); what a request may do is the intersection of the owner's
8 * role and the token's scopes.
9 */
10
11export type ScopeResource =
12 | "repo"
13 | "code"
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar14 | "security"
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member15 | "packages"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step16 | "issues"
17 | "pull_requests"
18 | "agents"
19 | "workflows"
Token reach: workflow_files scope, fine-grained reach, workspace token cap20 | "workflow_files"
Merge checks: statuses and check runs on every commit21 | "checks"
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9722 | "deployments"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step23 | "memory"
24 | "account"
API: notifications over REST and MCP, with notifications scopes25 | "notifications"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step26 | "workspace"
Usage, Billing settings and prepaid AI credit; fixes from the UX audit27 | "billing"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step28 | "access"
29 | "webhooks"
Fast pages, required checks on the branch, self-hosted runners, honest incidents30 | "secrets"
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens31 | "runners"
32 | "models";
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step33
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member34export type ScopeLevel = "read" | "write" | "run" | "delete" | "admin";
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step35
36/** Every scope, grouped by resource, least first. */
37export const SCOPES = [
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9738 { scope: "repo:read", description: "See repositories, their settings, labels, timelines, releases, languages, contributors and security alerts, and search" },
39 { scope: "repo:write", description: "Create repositories, rename branches, change how pull requests merge and publish releases" },
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge40 { scope: "repo:admin", description: "Rename, archive, transfer, delete or change who can see a repository, change its rulesets, and dismiss security alerts" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step41 { scope: "code:read", description: "Clone and fetch private repositories with git" },
42 { scope: "code:write", description: "Push commits with git" },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar43 { scope: "security:read", description: "See secret scanning, code scanning and vulnerability alerts, custom patterns, the dependency graph and SBOM, and security settings" },
44 { scope: "security:write", description: "Dismiss and reopen alerts, bypass push protection, review bypass requests, manage custom patterns, upload SARIF and change security settings" },
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member45 { scope: "packages:read", description: "Pull container images and install private packages" },
46 { scope: "packages:write", description: "Push container images and publish packages" },
Merge packages: roles, Actions access, source label, soft delete, API47 { scope: "packages:delete", description: "Delete and restore packages and their versions" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step48 { scope: "issues:read", description: "Read issues, comments and plans" },
49 { scope: "issues:write", description: "Open, edit, close and comment on issues" },
50 { scope: "pull_requests:read", description: "Read pull requests, their changes, sessions and merge queues" },
51 { scope: "pull_requests:write", description: "Open, review, close and merge pull requests" },
52 { scope: "agents:run", description: "Put g1t agents to work and message them, which uses the workspace's money" },
53 { scope: "workflows:read", description: "Read workflows, runs and logs" },
54 { scope: "workflows:write", description: "Run, cancel, rerun and turn workflows on or off" },
Token reach: workflow_files scope, fine-grained reach, workspace token cap55 { scope: "workflow_files:write", description: "Add, change and delete workflow files under .g1t/workflows and .github/workflows, with git or the API" },
Merge checks: statuses and check runs on every commit56 { scope: "checks:read", description: "Read commits' statuses, check runs, check suites and annotations" },
57 { scope: "checks:write", description: "Report statuses and check runs on commits, and ask for checks to run again" },
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9758 { scope: "deployments:read", description: "See deployments, their statuses and environments" },
59 { scope: "deployments:write", description: "Report deployments and their statuses, from any CI" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step60 { scope: "memory:read", description: "Recall memory and search the workspace's context" },
61 { scope: "memory:write", description: "Save memory for the next agent" },
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9762 { scope: "account:read", description: "Read your email addresses, invites, invitations, pinned projects and stars" },
63 { scope: "account:write", description: "Change your email addresses, make invites, answer invitations, pin projects and star repositories" },
API: notifications over REST and MCP, with notifications scopes64 { scope: "notifications:read", description: "See your inbox, its threads, and what you subscribe to and watch" },
65 { scope: "notifications:write", description: "Mark notifications read, done, saved or snoozed, subscribe to threads and watch repositories" },
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge66 { scope: "workspace:read", description: "Read workspace settings, invites, integrations, model routes, teams and rulesets" },
67 { scope: "workspace:admin", description: "Create and delete workspaces, invite members, connect integrations, create, change and delete teams, and change the workspace's rulesets" },
Usage, Billing settings and prepaid AI credit; fixes from the UX audit68 { scope: "billing:read", description: "See a workspace's usage, budget, AI credit and invoices" },
69 { scope: "billing:write", description: "Change a workspace's budget and buy AI credit" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step70 { scope: "access:read", description: "See who has access to repositories" },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar71 { scope: "access:admin", description: "Give and take away access to repositories, a team's included" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step72 { scope: "webhooks:read", description: "See webhooks and their deliveries" },
73 { scope: "webhooks:admin", description: "Create, change and delete webhooks" },
74 { scope: "secrets:read", description: "List secrets (never their values) and read variables" },
75 { scope: "secrets:admin", description: "Set and delete secrets and variables" },
Fast pages, required checks on the branch, self-hosted runners, honest incidents76 { scope: "runners:read", description: "See self-hosted runners, their groups and where agents run" },
77 { scope: "runners:admin", description: "Register and remove self-hosted runners, change their groups and settings" },
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens78 { scope: "models:read", description: "See the workspace's AI Gateway requests: their models, tokens, cost and status" },
79 { scope: "models:write", description: "Send model requests through the AI Gateway, which uses the workspace's AI credit" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step80] as const;
81
82export type Scope = (typeof SCOPES)[number]["scope"];
83
84/** Resources in the order settings show them, with their names for people. */
85export const SCOPE_RESOURCES: { resource: ScopeResource; label: string }[] = [
86 { resource: "repo", label: "Repositories" },
87 { resource: "code", label: "Code" },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar88 { resource: "security", label: "Security" },
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member89 { resource: "packages", label: "Packages" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step90 { resource: "issues", label: "Issues" },
91 { resource: "pull_requests", label: "Pull requests" },
92 { resource: "agents", label: "g1t agents" },
93 { resource: "workflows", label: "Workflows" },
Token reach: workflow_files scope, fine-grained reach, workspace token cap94 { resource: "workflow_files", label: "Workflow files" },
Merge checks: statuses and check runs on every commit95 { resource: "checks", label: "Checks and statuses" },
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9796 { resource: "deployments", label: "Deployments" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step97 { resource: "memory", label: "Memory and context" },
98 { resource: "account", label: "Your account" },
API: notifications over REST and MCP, with notifications scopes99 { resource: "notifications", label: "Notifications" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step100 { resource: "workspace", label: "Workspaces" },
Usage, Billing settings and prepaid AI credit; fixes from the UX audit101 { resource: "billing", label: "Billing" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step102 { resource: "access", label: "Who has access" },
103 { resource: "webhooks", label: "Webhooks" },
104 { resource: "secrets", label: "Secrets and variables" },
Fast pages, required checks on the branch, self-hosted runners, honest incidents105 { resource: "runners", label: "Self-hosted runners" },
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens106 { resource: "models", label: "AI Gateway" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step107];
108
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member109const LEVEL_ORDER: Record<ScopeLevel, number> = { read: 0, write: 1, run: 2, delete: 3, admin: 4 };
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step110
111export function scopeResource(scope: Scope): ScopeResource {
112 return scope.split(":")[0] as ScopeResource;
113}
114
115export function scopeLevel(scope: Scope): ScopeLevel {
116 return scope.split(":")[1] as ScopeLevel;
117}
118
119export function isScope(text: string): text is Scope {
120 return SCOPES.some((row) => row.scope === text);
121}
122
123/** Changes that are hard to undo, or decide who can reach what. */
124export function isDangerous(scope: Scope): boolean {
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member125 const level = scopeLevel(scope);
126 return level === "admin" || level === "delete";
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step127}
128
129export function describeScope(scope: Scope): string {
130 return SCOPES.find((row) => row.scope === scope)?.description ?? scope;
131}
132
133/** Whether holding `held` gives `needed`: the same resource, at its level or lower. */
134export function scopeIncludes(held: Scope, needed: Scope): boolean {
135 return (
136 scopeResource(held) === scopeResource(needed) &&
137 LEVEL_ORDER[scopeLevel(held)] >= LEVEL_ORDER[scopeLevel(needed)]
138 );
139}
140
141/** The levels a resource has, least first. */
142export function levelsOf(resource: ScopeResource): ScopeLevel[] {
143 return SCOPES.filter((row) => scopeResource(row.scope) === resource).map((row) => scopeLevel(row.scope));
144}
145
146/** Scopes from text separated by spaces or commas, in table order; unknown ones are left out. */
147export function parseScopes(text: string): Scope[] {
148 const given = new Set(text.split(/[\s,]+/).map((part) => part.trim().toLowerCase()));
149 return SCOPES.map((row) => row.scope).filter((scope) => given.has(scope));
150}
151
152/** What a token stores for full access. */
153export const FULL_ACCESS = "*";
154
155export type PresetId = "read_only" | "agent" | "ci" | "full";
156
157/** Starting points for choosing scopes. `*` is full access. */
158export const PRESET_SCOPES = {
159 read_only: [
Merge checks: statuses and check runs on every commit160 "repo:read", "code:read", "security:read", "packages:read", "issues:read", "pull_requests:read", "workflows:read", "checks:read", "deployments:read", "memory:read", "account:read", "notifications:read", "workspace:read", "billing:read", "access:read", "webhooks:read", "secrets:read", "runners:read", "models:read",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step161 ] as const,
162 agent: [
Merge checks: statuses and check runs on every commit163 "repo:read", "code:read", "code:write", "security:read", "packages:read", "issues:read", "issues:write", "pull_requests:read", "pull_requests:write", "agents:run", "workflows:read", "checks:read", "deployments:read", "memory:read", "memory:write", "account:read", "notifications:read", "notifications:write", "workspace:read", "billing:read", "access:read", "webhooks:read", "secrets:read", "models:read",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step164 ] as const,
165 ci: [
Merge checks: statuses and check runs on every commit166 "repo:read", "code:read", "code:write", "packages:read", "packages:write", "workflows:read", "workflows:write", "checks:read", "checks:write", "deployments:read", "deployments:write",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step167 ] as const,
168 full: [
169 "*",
170 ] as const,
171};
172
173export const PRESETS: { id: PresetId; label: string; description: string }[] = [
174 { id: "read_only", label: "Read only", description: "Read everything you can read; change nothing." },
175 { id: "agent", label: "Agent", description: "Read everything, work on issues and pull requests, push code and run g1t agents." },
Merge checks: statuses and check runs on every commit176 { id: "ci", label: "CI", description: "Clone and push code, push and pull packages, run workflows, and report checks and deployments." },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step177 { id: "full", label: "Full access", description: "Everything you can do, including deleting repositories and changing who has access." },
178];
179
180/** The scopes of a preset, or null for full access. */
181export function presetScopes(id: PresetId): Scope[] | null {
182 if (id === "full") return null;
183 return [...PRESET_SCOPES[id]] as Scope[];
184}
185
186/** What an OAuth client gets when it asks for nothing in particular. */
187export const OAUTH_DEFAULT_SCOPES: Scope[] = [...PRESET_SCOPES.agent];
188
189/** The operation each scope gates, by the API's operation names. */
190export const OPERATION_SCOPES = [
191 ["list_emails", "account:read"],
192 ["add_email", "account:write"],
Merge email confirmation gate: a code and a link, nothing until confirmed (identity 0036)193 ["confirm_email", "account:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step194 ["remove_email", "account:write"],
195 ["update_email_settings", "account:write"],
196 ["list_invites", "account:read"],
197 ["create_invite", "account:write"],
198 ["revoke_invite", "account:write"],
Merge workspace invitations: nobody joins a workspace without saying yes, people are found by username, your own invites can bring someone in, and nobody is left without a workspace (identity 0040)199 ["list_invitations", "account:read"],
200 ["accept_invitation", "account:write"],
201 ["decline_invitation", "account:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step202 ["list_my_repo_invitations", "account:read"],
203 ["accept_repo_invitation", "account:write"],
204 ["decline_repo_invitation", "account:write"],
API: pinned projects over REST and MCP205 // Your pinned projects: a preference of your account.
206 ["list_pinned_projects", "account:read"],
207 ["pin_project", "account:write"],
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97208 // Your stars: a preference of your account.
209 ["list_starred", "account:read"],
210 ["check_starred", "account:read"],
211 ["star_repo", "account:write"],
212 ["unstar_repo", "account:write"],
API: pinned projects over REST and MCP213 ["unpin_project", "account:write"],
214 ["reorder_pinned_projects", "account:write"],
API: notifications over REST and MCP, with notifications scopes215 // Your inbox: notifications, subscriptions and watching.
216 ["list_notifications", "notifications:read"],
217 ["get_notification_thread", "notifications:read"],
218 ["get_thread_subscription", "notifications:read"],
219 ["get_repo_subscription", "notifications:read"],
220 ["list_watched_repos", "notifications:read"],
221 ["mark_notifications_read", "notifications:write"],
222 ["mark_thread_read", "notifications:write"],
223 ["mark_thread_done", "notifications:write"],
224 ["save_thread", "notifications:write"],
225 ["snooze_thread", "notifications:write"],
226 ["set_thread_subscription", "notifications:write"],
227 ["delete_thread_subscription", "notifications:write"],
228 ["set_repo_subscription", "notifications:write"],
229 ["delete_repo_subscription", "notifications:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step230 ["create_workspace", "workspace:admin"],
231 ["delete_workspace", "workspace:admin"],
Merge branch 'worktree-agent-ad7c6d88d93adc817'232 ["get_workspace", "workspace:read"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily233 ["update_workspace", "workspace:admin"],
Merge main (membership, two-factor, GitHub repo roles) into tokens234 ["list_members", "workspace:read"],
235 ["update_member", "workspace:admin"],
236 ["remove_member", "workspace:admin"],
237 ["transfer_ownership", "workspace:admin"],
238 ["leave_workspace", "account:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step239 ["list_workspace_invites", "workspace:read"],
240 ["invite_member", "workspace:admin"],
241 ["revoke_workspace_invite", "workspace:admin"],
242 ["list_integrations", "workspace:read"],
243 ["connect_integration", "workspace:admin"],
AI Gateway: OpenAI's format, open models, and your own providers244 ["update_integration", "workspace:admin"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step245 ["disconnect_integration", "workspace:admin"],
246 ["test_integration", "workspace:admin"],
247 ["get_model_routes", "workspace:read"],
248 ["set_model_routes", "workspace:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar249 ["list_teams", "workspace:read"],
250 ["get_team", "workspace:read"],
251 ["list_team_members", "workspace:read"],
252 ["list_child_teams", "workspace:read"],
253 ["list_team_repos", "workspace:read"],
254 ["list_user_teams", "workspace:read"],
255 ["create_team", "workspace:admin"],
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge256 ["list_workspace_rulesets", "workspace:read"],
257 ["get_workspace_ruleset", "workspace:read"],
258 ["list_workspace_rule_evaluations", "workspace:read"],
259 ["create_workspace_ruleset", "workspace:admin"],
260 ["update_workspace_ruleset", "workspace:admin"],
261 ["delete_workspace_ruleset", "workspace:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar262 ["update_team", "workspace:admin"],
263 ["delete_team", "workspace:admin"],
264 ["set_team_member", "workspace:admin"],
265 ["remove_team_member", "workspace:admin"],
266 ["set_team_review_assignment", "workspace:admin"],
Usage, Billing settings and prepaid AI credit; fixes from the UX audit267 // A workspace's billing: usage, budget, AI credit and invoices.
268 ["get_usage", "billing:read"],
269 ["get_budget", "billing:read"],
270 ["get_ai_credit", "billing:read"],
271 ["list_invoices", "billing:read"],
272 ["get_billing_details", "billing:read"],
273 ["set_budget", "billing:write"],
274 ["buy_ai_credit", "billing:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step275 ["list_repos", "repo:read"],
276 ["get_repo", "repo:read"],
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97277 // Projects follow their repositories.
278 ["list_projects", "repo:read"],
279 ["get_project", "repo:read"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step280 ["search", "repo:read"],
281 ["list_events", "repo:read"],
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97282 // What the default branch says about a repository, who starred it, and
283 // its releases.
284 ["get_languages", "repo:read"],
285 ["list_contributors", "repo:read"],
286 ["get_license", "repo:read"],
287 ["list_stargazers", "repo:read"],
288 ["list_releases", "repo:read"],
289 ["get_latest_release", "repo:read"],
290 ["get_release_by_tag", "repo:read"],
291 ["get_release", "repo:read"],
292 ["create_release", "repo:write"],
293 ["update_release", "repo:write"],
294 ["delete_release", "repo:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step295 ["list_labels", "repo:read"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar296 ["list_milestones", "repo:read"],
297 ["get_milestone", "repo:read"],
298 ["create_label", "issues:write"],
299 ["update_label", "issues:write"],
300 ["delete_label", "issues:write"],
301 ["add_default_labels", "issues:write"],
302 ["create_milestone", "issues:write"],
303 ["update_milestone", "issues:write"],
304 ["delete_milestone", "issues:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step305 ["get_repo_settings", "repo:read"],
Fast pages, required checks on the branch, self-hosted runners, honest incidents306 ["list_check_names", "repo:read"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step307 ["list_deleted_repos", "repo:read"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily308 ["list_security_alerts", "repo:read"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar309 ["get_codeowners_errors", "repo:read"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step310 ["create_repo", "repo:write"],
311 ["update_repo", "repo:write"],
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97312 ["update_project", "repo:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step313 ["update_repo_settings", "repo:write"],
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge314 ["list_repo_rulesets", "repo:read"],
315 ["get_repo_ruleset", "repo:read"],
316 ["get_branch_rules", "repo:read"],
317 ["list_rule_evaluations", "repo:read"],
318 ["create_repo_ruleset", "repo:admin"],
319 ["update_repo_ruleset", "repo:admin"],
320 ["delete_repo_ruleset", "repo:admin"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step321 ["rename_branch", "repo:write"],
322 ["rename_repo", "repo:admin"],
323 ["transfer_repo", "repo:admin"],
324 ["archive_repo", "repo:admin"],
325 ["unarchive_repo", "repo:admin"],
326 ["set_repo_visibility", "repo:admin"],
327 ["delete_repo", "repo:admin"],
328 ["restore_repo", "repo:admin"],
329 ["purge_repo", "repo:admin"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily330 ["dismiss_security_alert", "repo:admin"],
331 ["reopen_security_alert", "repo:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar332 // The security suite.
333 ["list_secret_scanning_alerts", "security:read"],
334 ["get_secret_scanning_alert", "security:read"],
335 ["list_secret_scanning_locations", "security:read"],
336 ["list_bypass_requests", "security:read"],
337 ["list_custom_patterns", "security:read"],
338 ["list_code_scanning_alerts", "security:read"],
339 ["get_code_scanning_alert", "security:read"],
340 ["list_code_scanning_analyses", "security:read"],
341 ["get_sarif_upload", "security:read"],
342 ["list_vulnerability_alerts", "security:read"],
343 ["get_vulnerability_alert", "security:read"],
344 ["get_dependency_graph", "security:read"],
345 ["get_sbom", "security:read"],
346 ["compare_dependencies", "security:read"],
347 ["get_security_settings", "security:read"],
348 ["get_workspace_security_settings", "security:read"],
349 ["get_security_overview", "security:read"],
350 ["update_secret_scanning_alert", "security:write"],
351 ["bypass_push_protection", "security:write"],
352 ["check_secret_validity", "security:write"],
353 ["review_bypass_request", "security:write"],
354 ["create_custom_pattern", "security:write"],
355 ["update_custom_pattern", "security:write"],
356 ["delete_custom_pattern", "security:write"],
357 ["dry_run_custom_pattern", "security:write"],
358 ["update_code_scanning_alert", "security:write"],
359 ["upload_sarif", "security:write"],
360 ["update_vulnerability_alert", "security:write"],
361 ["fix_security_alert", "security:write"],
362 ["update_security_settings", "security:write"],
363 ["update_workspace_security_settings", "security:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step364 ["list_issues", "issues:read"],
365 ["get_issue", "issues:read"],
366 ["get_plan", "issues:read"],
367 ["create_issue", "issues:write"],
368 ["update_issue", "issues:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar369 ["list_issue_labels", "issues:read"],
370 ["add_issue_labels", "issues:write"],
371 ["set_issue_labels", "issues:write"],
372 ["remove_issue_labels", "issues:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step373 ["close_issue", "issues:write"],
374 ["reopen_issue", "issues:write"],
375 ["add_comment", "issues:write"],
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts376 ["edit_comment", "issues:write"],
377 ["delete_comment", "issues:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step378 ["import_issue", "issues:write"],
379 ["apply_plan", "issues:write"],
380 ["list_pull_requests", "pull_requests:read"],
381 ["get_pull_request", "pull_requests:read"],
382 ["get_pull_request_changes", "pull_requests:read"],
383 ["read_session", "pull_requests:read"],
384 ["get_merge_queue", "pull_requests:read"],
385 ["create_pull_request", "pull_requests:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar386 ["update_pull_request", "pull_requests:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step387 ["record_session", "pull_requests:write"],
388 ["mark_pull_request_ready", "pull_requests:write"],
389 ["close_pull_request", "pull_requests:write"],
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts390 ["reopen_pull_request", "pull_requests:write"],
391 ["convert_pull_request_to_draft", "pull_requests:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step392 ["review_pull_request", "pull_requests:write"],
393 ["merge_pull_request", "pull_requests:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar394 ["request_reviewers", "pull_requests:write"],
395 ["remove_requested_reviewers", "pull_requests:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step396 ["assign_issue", "agents:run"],
397 ["delegate", "agents:run"],
398 ["plan_work", "agents:run"],
399 ["message_agent", "agents:run"],
400 ["answer_message", "agents:run"],
401 ["take_messages", "agents:run"],
402 ["list_workflows", "workflows:read"],
403 ["list_workflow_runs", "workflows:read"],
404 ["get_workflow_run", "workflows:read"],
405 ["get_job_logs", "workflows:read"],
406 ["dispatch_workflow", "workflows:write"],
407 ["cancel_workflow_run", "workflows:write"],
408 ["rerun_workflow_run", "workflows:write"],
409 ["update_workflow", "workflows:write"],
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2410 ["list_artifacts", "workflows:read"],
411 ["list_workflow_run_artifacts", "workflows:read"],
412 ["get_artifact", "workflows:read"],
413 ["download_artifact", "workflows:read"],
414 ["get_artifact_retention", "workflows:read"],
415 ["delete_artifact", "workflows:write"],
416 ["set_artifact_retention", "workflows:write"],
Merge checks: statuses and check runs on every commit417 ["list_commit_statuses", "checks:read"],
418 ["get_combined_status", "checks:read"],
419 ["list_check_runs_for_ref", "checks:read"],
420 ["get_check_run", "checks:read"],
421 ["list_check_run_annotations", "checks:read"],
422 ["list_check_suites_for_ref", "checks:read"],
423 ["get_check_suite", "checks:read"],
424 ["create_commit_status", "checks:write"],
425 ["create_check_run", "checks:write"],
426 ["update_check_run", "checks:write"],
427 ["rerequest_check_run", "checks:write"],
428 ["rerequest_check_suite", "checks:write"],
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97429 // Deployments, wherever they run: reading them, and reporting them.
430 ["list_deployments", "deployments:read"],
431 ["get_deployment", "deployments:read"],
432 ["list_deployment_statuses", "deployments:read"],
433 ["list_environments", "deployments:read"],
434 ["get_environment", "deployments:read"],
435 ["create_deployment", "deployments:write"],
436 ["create_deployment_status", "deployments:write"],
Merge branch 'worktree-agent-a3abfcce648e87dca'437 // What keeps runs safe: the runs environments hold and reviewing them,
438 // approving a pull request's run, and a repository's own rules for its
439 // environments and tokens, which are an admin's.
440 ["get_pending_deployments", "workflows:read"],
441 ["review_pending_deployments", "workflows:write"],
442 ["approve_workflow_run", "workflows:write"],
443 ["get_workflow_permissions", "repo:read"],
444 ["get_fork_pr_approval", "repo:read"],
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts445 ["get_actions_access", "repo:read"],
Merge branch 'worktree-agent-a3abfcce648e87dca'446 ["update_environment", "repo:admin"],
447 ["delete_environment", "repo:admin"],
448 ["set_workflow_permissions", "repo:admin"],
449 ["set_fork_pr_approval", "repo:admin"],
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts450 ["set_actions_access", "repo:admin"],
Merge branch 'worktree-agent-a3abfcce648e87dca'451 // Starting workflows from outside, as a push would.
452 ["create_repository_dispatch", "code:write"],
453 // A workspace's policy for its repositories' tokens.
454 ["get_workspace_workflow_permissions", "workspace:read"],
455 ["set_workspace_workflow_permissions", "workspace:admin"],
API and MCP for a workspace's personal access token rules, members' tokens and approvals456 // A workspace's rules for personal access tokens, and its members' tokens.
457 ["get_token_policy", "workspace:read"],
458 ["set_token_policy", "workspace:admin"],
459 ["list_member_tokens", "access:read"],
460 ["list_token_requests", "access:read"],
461 ["review_token_request", "access:admin"],
462 ["revoke_member_token", "access:admin"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step463 ["recall", "memory:read"],
464 ["search_context", "memory:read"],
465 ["get_entity", "memory:read"],
466 ["get_context", "memory:read"],
467 ["remember", "memory:write"],
468 ["list_collaborators", "access:read"],
469 ["get_collaborator_permission", "access:read"],
470 ["list_repo_invitations", "access:read"],
471 ["list_outside_collaborators", "access:read"],
472 ["add_collaborator", "access:admin"],
473 ["update_collaborator", "access:admin"],
474 ["remove_collaborator", "access:admin"],
475 ["revoke_repo_invitation", "access:admin"],
476 ["set_base_permission", "access:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar477 ["set_team_repo", "access:admin"],
478 ["remove_team_repo", "access:admin"],
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca479 ["list_deploy_keys", "access:read"],
480 ["get_deploy_key", "access:read"],
481 ["create_deploy_key", "access:admin"],
482 ["delete_deploy_key", "access:admin"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step483 ["list_webhooks", "webhooks:read"],
484 ["list_webhook_deliveries", "webhooks:read"],
485 ["create_webhook", "webhooks:admin"],
486 ["update_webhook", "webhooks:admin"],
487 ["delete_webhook", "webhooks:admin"],
488 ["ping_webhook", "webhooks:admin"],
489 ["redeliver_webhook", "webhooks:admin"],
490 ["list_actions_secrets", "secrets:read"],
491 ["list_actions_variables", "secrets:read"],
492 ["set_actions_secret", "secrets:admin"],
493 ["delete_actions_secret", "secrets:admin"],
494 ["set_actions_variable", "secrets:admin"],
495 ["delete_actions_variable", "secrets:admin"],
Fast pages, required checks on the branch, self-hosted runners, honest incidents496 // Self-hosted runners.
497 ["list_runners", "runners:read"],
498 ["list_runner_groups", "runners:read"],
499 ["get_runner_settings", "runners:read"],
500 ["create_runner_registration_token", "runners:admin"],
501 ["remove_runner", "runners:admin"],
502 ["create_runner_group", "runners:admin"],
503 ["update_runner_group", "runners:admin"],
504 ["delete_runner_group", "runners:admin"],
505 ["update_runner_settings", "runners:admin"],
Merge packages: roles, Actions access, source label, soft delete, API506 // Packages: reading them, their versions and who may use them needs
507 // `packages:read`; changing their settings, access and Manage Actions
508 // access `packages:write` (and the Admin role on the package, which the
509 // packages service checks); deleting and restoring packages and
510 // versions `packages:delete`, as the registries' own deletes do.
511 ["list_packages", "packages:read"],
512 ["get_package", "packages:read"],
513 ["list_package_versions", "packages:read"],
514 ["get_package_version", "packages:read"],
515 ["list_package_access", "packages:read"],
516 ["list_package_actions_access", "packages:read"],
517 ["update_package", "packages:write"],
518 ["link_package", "packages:write"],
519 ["unlink_package", "packages:write"],
520 ["set_package_access", "packages:write"],
521 ["remove_package_access", "packages:write"],
522 ["set_package_actions_access", "packages:write"],
523 ["remove_package_actions_access", "packages:write"],
524 ["delete_package", "packages:delete"],
525 ["restore_package", "packages:delete"],
526 ["delete_package_version", "packages:delete"],
527 ["restore_package_version", "packages:delete"],
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens528 // The AI Gateway. Sending a request to a model needs `models:write`,
529 // checked by the model proxy at models.g1t.sh.
530 ["list_gateway_requests", "models:read"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step531] as const;
532
533/**
534 * The scopes a token or grant holds, as stored: null for full access, or
535 * the list. `legacy` marks a token made before scopes, which has full
536 * access until someone narrows it.
537 */
538export type TokenScopes = {
539 scopes: Scope[] | null;
540 legacy: boolean;
541};
542
543/**
544 * How settings group scopes into a checklist: each group's scopes, least
545 * first. Admin scopes are not here; they are under "Dangerous" on their
546 * own (see `DANGEROUS_SCOPES`). Every other scope is in exactly one group.
547 */
548export const SCOPE_GROUPS: { id: string; label: string; scopes: Scope[] }[] = [
549 { id: "code", label: "Repositories & code", scopes: ["repo:read", "repo:write", "code:read", "code:write"] },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar550 { id: "security", label: "Security", scopes: ["security:read", "security:write"] },
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member551 { id: "packages", label: "Packages", scopes: ["packages:read", "packages:write"] },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step552 { id: "work", label: "Issues & pull requests", scopes: ["issues:read", "issues:write", "pull_requests:read", "pull_requests:write"] },
553 { id: "agents", label: "Agents", scopes: ["agents:run"] },
Token reach: workflow_files scope, fine-grained reach, workspace token cap554 { id: "workflows", label: "Workflows", scopes: ["workflows:read", "workflows:write", "workflow_files:write"] },
Merge checks: statuses and check runs on every commit555 { id: "checks", label: "Checks", scopes: ["checks:read", "checks:write"] },
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97556 { id: "deployments", label: "Deployments", scopes: ["deployments:read", "deployments:write"] },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step557 { id: "memory", label: "Memory & search", scopes: ["memory:read", "memory:write"] },
558 { id: "account", label: "Account", scopes: ["account:read", "account:write"] },
API: notifications over REST and MCP, with notifications scopes559 { id: "notifications", label: "Notifications", scopes: ["notifications:read", "notifications:write"] },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step560 { id: "workspace", label: "Workspace", scopes: ["workspace:read", "access:read", "webhooks:read", "secrets:read"] },
Usage, Billing settings and prepaid AI credit; fixes from the UX audit561 { id: "billing", label: "Billing", scopes: ["billing:read", "billing:write"] },
Fast pages, required checks on the branch, self-hosted runners, honest incidents562 { id: "runners", label: "Runners", scopes: ["runners:read"] },
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens563 { id: "models", label: "AI Gateway", scopes: ["models:read", "models:write"] },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step564];
565
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member566/** The admin and delete scopes, shown under "Dangerous" behind a warning. */
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step567export const DANGEROUS_SCOPES: Scope[] = SCOPES.map((row) => row.scope).filter(isDangerous);

This file's history is long; its oldest lines are credited to the oldest commit read.