Skip to content

g1t/packages/contracts/src/scopes.ts

474 lines23,030 bytesCodeBlame

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"
Merge main: Deployments panel in the About, project homepage, both sides' operations20 | "deployments"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step21 | "memory"
22 | "account"
API: notifications over REST and MCP, with notifications scopes23 | "notifications"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step24 | "workspace"
Usage, Billing settings and prepaid AI credit; fixes from the UX audit25 | "billing"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step26 | "access"
27 | "webhooks"
Fast pages, required checks on the branch, self-hosted runners, honest incidents28 | "secrets"
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens29 | "runners"
30 | "models";
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step31
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member32export 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 step33
34/** Every scope, grouped by resource, least first. */
35export const SCOPES = [
About: license, languages, contributors, stars, releases and activity beside the files36 { scope: "repo:read", description: "See repositories, their settings, labels, timelines, releases, languages, contributors and security alerts, and search" },
37 { 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 merge38 { 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 step39 { scope: "code:read", description: "Clone and fetch private repositories with git" },
40 { scope: "code:write", description: "Push commits with git" },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar41 { scope: "security:read", description: "See secret scanning, code scanning and vulnerability alerts, custom patterns, the dependency graph and SBOM, and security settings" },
42 { 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 member43 { scope: "packages:read", description: "Pull container images and install private packages" },
44 { scope: "packages:write", description: "Push container images and publish packages" },
45 { scope: "packages:delete", description: "Delete packages and their versions" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step46 { scope: "issues:read", description: "Read issues, comments and plans" },
47 { scope: "issues:write", description: "Open, edit, close and comment on issues" },
48 { scope: "pull_requests:read", description: "Read pull requests, their changes, sessions and merge queues" },
49 { scope: "pull_requests:write", description: "Open, review, close and merge pull requests" },
50 { scope: "agents:run", description: "Put g1t agents to work and message them, which uses the workspace's money" },
51 { scope: "workflows:read", description: "Read workflows, runs and logs" },
52 { scope: "workflows:write", description: "Run, cancel, rerun and turn workflows on or off" },
Merge main: Deployments panel in the About, project homepage, both sides' operations53 { scope: "deployments:read", description: "See deployments, their statuses and environments" },
54 { 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 step55 { scope: "memory:read", description: "Recall memory and search the workspace's context" },
56 { scope: "memory:write", description: "Save memory for the next agent" },
About: license, languages, contributors, stars, releases and activity beside the files57 { scope: "account:read", description: "Read your email addresses, invites, invitations, pinned projects and stars" },
58 { 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 scopes59 { scope: "notifications:read", description: "See your inbox, its threads, and what you subscribe to and watch" },
60 { 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 merge61 { scope: "workspace:read", description: "Read workspace settings, invites, integrations, model routes, teams and rulesets" },
62 { 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 audit63 { scope: "billing:read", description: "See a workspace's usage, budget, AI credit and invoices" },
64 { 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 step65 { 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 bar66 { 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 step67 { scope: "webhooks:read", description: "See webhooks and their deliveries" },
68 { scope: "webhooks:admin", description: "Create, change and delete webhooks" },
69 { scope: "secrets:read", description: "List secrets (never their values) and read variables" },
70 { scope: "secrets:admin", description: "Set and delete secrets and variables" },
Fast pages, required checks on the branch, self-hosted runners, honest incidents71 { scope: "runners:read", description: "See self-hosted runners, their groups and where agents run" },
72 { 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 tokens73 { scope: "models:read", description: "See the workspace's AI Gateway requests: their models, tokens, cost and status" },
74 { 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 step75] as const;
76
77export type Scope = (typeof SCOPES)[number]["scope"];
78
79/** Resources in the order settings show them, with their names for people. */
80export const SCOPE_RESOURCES: { resource: ScopeResource; label: string }[] = [
81 { resource: "repo", label: "Repositories" },
82 { resource: "code", label: "Code" },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar83 { resource: "security", label: "Security" },
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member84 { resource: "packages", label: "Packages" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step85 { resource: "issues", label: "Issues" },
86 { resource: "pull_requests", label: "Pull requests" },
87 { resource: "agents", label: "g1t agents" },
88 { resource: "workflows", label: "Workflows" },
Merge main: Deployments panel in the About, project homepage, both sides' operations89 { resource: "deployments", label: "Deployments" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step90 { resource: "memory", label: "Memory and context" },
91 { resource: "account", label: "Your account" },
API: notifications over REST and MCP, with notifications scopes92 { resource: "notifications", label: "Notifications" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step93 { resource: "workspace", label: "Workspaces" },
Usage, Billing settings and prepaid AI credit; fixes from the UX audit94 { resource: "billing", label: "Billing" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step95 { resource: "access", label: "Who has access" },
96 { resource: "webhooks", label: "Webhooks" },
97 { resource: "secrets", label: "Secrets and variables" },
Fast pages, required checks on the branch, self-hosted runners, honest incidents98 { resource: "runners", label: "Self-hosted runners" },
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens99 { 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 step100];
101
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member102const 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 step103
104export function scopeResource(scope: Scope): ScopeResource {
105 return scope.split(":")[0] as ScopeResource;
106}
107
108export function scopeLevel(scope: Scope): ScopeLevel {
109 return scope.split(":")[1] as ScopeLevel;
110}
111
112export function isScope(text: string): text is Scope {
113 return SCOPES.some((row) => row.scope === text);
114}
115
116/** Changes that are hard to undo, or decide who can reach what. */
117export function isDangerous(scope: Scope): boolean {
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member118 const level = scopeLevel(scope);
119 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 step120}
121
122export function describeScope(scope: Scope): string {
123 return SCOPES.find((row) => row.scope === scope)?.description ?? scope;
124}
125
126/** Whether holding `held` gives `needed`: the same resource, at its level or lower. */
127export function scopeIncludes(held: Scope, needed: Scope): boolean {
128 return (
129 scopeResource(held) === scopeResource(needed) &&
130 LEVEL_ORDER[scopeLevel(held)] >= LEVEL_ORDER[scopeLevel(needed)]
131 );
132}
133
134/** The levels a resource has, least first. */
135export function levelsOf(resource: ScopeResource): ScopeLevel[] {
136 return SCOPES.filter((row) => scopeResource(row.scope) === resource).map((row) => scopeLevel(row.scope));
137}
138
139/** Scopes from text separated by spaces or commas, in table order; unknown ones are left out. */
140export function parseScopes(text: string): Scope[] {
141 const given = new Set(text.split(/[\s,]+/).map((part) => part.trim().toLowerCase()));
142 return SCOPES.map((row) => row.scope).filter((scope) => given.has(scope));
143}
144
145/** What a token stores for full access. */
146export const FULL_ACCESS = "*";
147
148export type PresetId = "read_only" | "agent" | "ci" | "full";
149
150/** Starting points for choosing scopes. `*` is full access. */
151export const PRESET_SCOPES = {
152 read_only: [
Merge main: Deployments panel in the About, project homepage, both sides' operations153 "repo:read", "code:read", "security:read", "packages:read", "issues:read", "pull_requests:read", "workflows: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 step154 ] as const,
155 agent: [
Merge main: Deployments panel in the About, project homepage, both sides' operations156 "repo:read", "code:read", "code:write", "security:read", "packages:read", "issues:read", "issues:write", "pull_requests:read", "pull_requests:write", "agents:run", "workflows: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 step157 ] as const,
158 ci: [
Merge main: Deployments panel in the About, project homepage, both sides' operations159 "repo:read", "code:read", "code:write", "packages:read", "packages:write", "workflows:read", "workflows: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 step160 ] as const,
161 full: [
162 "*",
163 ] as const,
164};
165
166export const PRESETS: { id: PresetId; label: string; description: string }[] = [
167 { id: "read_only", label: "Read only", description: "Read everything you can read; change nothing." },
168 { id: "agent", label: "Agent", description: "Read everything, work on issues and pull requests, push code and run g1t agents." },
Merge main: Deployments panel in the About, project homepage, both sides' operations169 { id: "ci", label: "CI", description: "Clone and push code, push and pull packages, run workflows and report deployments." },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step170 { id: "full", label: "Full access", description: "Everything you can do, including deleting repositories and changing who has access." },
171];
172
173/** The scopes of a preset, or null for full access. */
174export function presetScopes(id: PresetId): Scope[] | null {
175 if (id === "full") return null;
176 return [...PRESET_SCOPES[id]] as Scope[];
177}
178
179/** What an OAuth client gets when it asks for nothing in particular. */
180export const OAUTH_DEFAULT_SCOPES: Scope[] = [...PRESET_SCOPES.agent];
181
182/** The operation each scope gates, by the API's operation names. */
183export const OPERATION_SCOPES = [
184 ["list_emails", "account:read"],
185 ["add_email", "account:write"],
186 ["remove_email", "account:write"],
187 ["update_email_settings", "account:write"],
188 ["list_invites", "account:read"],
189 ["create_invite", "account:write"],
190 ["revoke_invite", "account:write"],
191 ["list_my_repo_invitations", "account:read"],
192 ["accept_repo_invitation", "account:write"],
193 ["decline_repo_invitation", "account:write"],
API: pinned projects over REST and MCP194 // Your pinned projects: a preference of your account.
195 ["list_pinned_projects", "account:read"],
196 ["pin_project", "account:write"],
About: license, languages, contributors, stars, releases and activity beside the files197 // Your stars: a preference of your account.
198 ["list_starred", "account:read"],
199 ["check_starred", "account:read"],
200 ["star_repo", "account:write"],
201 ["unstar_repo", "account:write"],
API: pinned projects over REST and MCP202 ["unpin_project", "account:write"],
203 ["reorder_pinned_projects", "account:write"],
API: notifications over REST and MCP, with notifications scopes204 // Your inbox: notifications, subscriptions and watching.
205 ["list_notifications", "notifications:read"],
206 ["get_notification_thread", "notifications:read"],
207 ["get_thread_subscription", "notifications:read"],
208 ["get_repo_subscription", "notifications:read"],
209 ["list_watched_repos", "notifications:read"],
210 ["mark_notifications_read", "notifications:write"],
211 ["mark_thread_read", "notifications:write"],
212 ["mark_thread_done", "notifications:write"],
213 ["save_thread", "notifications:write"],
214 ["snooze_thread", "notifications:write"],
215 ["set_thread_subscription", "notifications:write"],
216 ["delete_thread_subscription", "notifications:write"],
217 ["set_repo_subscription", "notifications:write"],
218 ["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 step219 ["create_workspace", "workspace:admin"],
220 ["delete_workspace", "workspace:admin"],
Merge branch 'worktree-agent-ad7c6d88d93adc817'221 ["get_workspace", "workspace:read"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily222 ["update_workspace", "workspace:admin"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step223 ["list_workspace_invites", "workspace:read"],
224 ["invite_member", "workspace:admin"],
225 ["revoke_workspace_invite", "workspace:admin"],
226 ["list_integrations", "workspace:read"],
227 ["connect_integration", "workspace:admin"],
228 ["disconnect_integration", "workspace:admin"],
229 ["test_integration", "workspace:admin"],
230 ["get_model_routes", "workspace:read"],
231 ["set_model_routes", "workspace:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar232 ["list_teams", "workspace:read"],
233 ["get_team", "workspace:read"],
234 ["list_team_members", "workspace:read"],
235 ["list_child_teams", "workspace:read"],
236 ["list_team_repos", "workspace:read"],
237 ["list_user_teams", "workspace:read"],
238 ["create_team", "workspace:admin"],
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge239 ["list_workspace_rulesets", "workspace:read"],
240 ["get_workspace_ruleset", "workspace:read"],
241 ["list_workspace_rule_evaluations", "workspace:read"],
242 ["create_workspace_ruleset", "workspace:admin"],
243 ["update_workspace_ruleset", "workspace:admin"],
244 ["delete_workspace_ruleset", "workspace:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar245 ["update_team", "workspace:admin"],
246 ["delete_team", "workspace:admin"],
247 ["set_team_member", "workspace:admin"],
248 ["remove_team_member", "workspace:admin"],
249 ["set_team_review_assignment", "workspace:admin"],
Usage, Billing settings and prepaid AI credit; fixes from the UX audit250 // A workspace's billing: usage, budget, AI credit and invoices.
251 ["get_usage", "billing:read"],
252 ["get_budget", "billing:read"],
253 ["get_ai_credit", "billing:read"],
254 ["list_invoices", "billing:read"],
255 ["get_billing_details", "billing:read"],
256 ["set_budget", "billing:write"],
257 ["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 step258 ["list_repos", "repo:read"],
259 ["get_repo", "repo:read"],
Merge main: Deployments panel in the About, project homepage, both sides' operations260 // Projects follow their repositories.
261 ["list_projects", "repo:read"],
262 ["get_project", "repo:read"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step263 ["search", "repo:read"],
264 ["list_events", "repo:read"],
About: license, languages, contributors, stars, releases and activity beside the files265 // What the default branch says about a repository, who starred it, and
266 // its releases.
267 ["get_languages", "repo:read"],
268 ["list_contributors", "repo:read"],
269 ["get_license", "repo:read"],
270 ["list_stargazers", "repo:read"],
271 ["list_releases", "repo:read"],
272 ["get_latest_release", "repo:read"],
273 ["get_release_by_tag", "repo:read"],
274 ["get_release", "repo:read"],
275 ["create_release", "repo:write"],
276 ["update_release", "repo:write"],
277 ["delete_release", "repo:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step278 ["list_labels", "repo:read"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar279 ["list_milestones", "repo:read"],
280 ["get_milestone", "repo:read"],
281 ["create_label", "issues:write"],
282 ["update_label", "issues:write"],
283 ["delete_label", "issues:write"],
284 ["add_default_labels", "issues:write"],
285 ["create_milestone", "issues:write"],
286 ["update_milestone", "issues:write"],
287 ["delete_milestone", "issues:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step288 ["get_repo_settings", "repo:read"],
Fast pages, required checks on the branch, self-hosted runners, honest incidents289 ["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 step290 ["list_deleted_repos", "repo:read"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily291 ["list_security_alerts", "repo:read"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar292 ["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 step293 ["create_repo", "repo:write"],
294 ["update_repo", "repo:write"],
Merge main: Deployments panel in the About, project homepage, both sides' operations295 ["update_project", "repo:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step296 ["update_repo_settings", "repo:write"],
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge297 ["list_repo_rulesets", "repo:read"],
298 ["get_repo_ruleset", "repo:read"],
299 ["get_branch_rules", "repo:read"],
300 ["list_rule_evaluations", "repo:read"],
301 ["create_repo_ruleset", "repo:admin"],
302 ["update_repo_ruleset", "repo:admin"],
303 ["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 step304 ["rename_branch", "repo:write"],
305 ["rename_repo", "repo:admin"],
306 ["transfer_repo", "repo:admin"],
307 ["archive_repo", "repo:admin"],
308 ["unarchive_repo", "repo:admin"],
309 ["set_repo_visibility", "repo:admin"],
310 ["delete_repo", "repo:admin"],
311 ["restore_repo", "repo:admin"],
312 ["purge_repo", "repo:admin"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily313 ["dismiss_security_alert", "repo:admin"],
314 ["reopen_security_alert", "repo:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar315 // The security suite.
316 ["list_secret_scanning_alerts", "security:read"],
317 ["get_secret_scanning_alert", "security:read"],
318 ["list_secret_scanning_locations", "security:read"],
319 ["list_bypass_requests", "security:read"],
320 ["list_custom_patterns", "security:read"],
321 ["list_code_scanning_alerts", "security:read"],
322 ["get_code_scanning_alert", "security:read"],
323 ["list_code_scanning_analyses", "security:read"],
324 ["get_sarif_upload", "security:read"],
325 ["list_vulnerability_alerts", "security:read"],
326 ["get_vulnerability_alert", "security:read"],
327 ["get_dependency_graph", "security:read"],
328 ["get_sbom", "security:read"],
329 ["compare_dependencies", "security:read"],
330 ["get_security_settings", "security:read"],
331 ["get_workspace_security_settings", "security:read"],
332 ["get_security_overview", "security:read"],
333 ["update_secret_scanning_alert", "security:write"],
334 ["bypass_push_protection", "security:write"],
335 ["check_secret_validity", "security:write"],
336 ["review_bypass_request", "security:write"],
337 ["create_custom_pattern", "security:write"],
338 ["update_custom_pattern", "security:write"],
339 ["delete_custom_pattern", "security:write"],
340 ["dry_run_custom_pattern", "security:write"],
341 ["update_code_scanning_alert", "security:write"],
342 ["upload_sarif", "security:write"],
343 ["update_vulnerability_alert", "security:write"],
344 ["fix_security_alert", "security:write"],
345 ["update_security_settings", "security:write"],
346 ["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 step347 ["list_issues", "issues:read"],
348 ["get_issue", "issues:read"],
349 ["get_plan", "issues:read"],
350 ["create_issue", "issues:write"],
351 ["update_issue", "issues:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar352 ["list_issue_labels", "issues:read"],
353 ["add_issue_labels", "issues:write"],
354 ["set_issue_labels", "issues:write"],
355 ["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 step356 ["close_issue", "issues:write"],
357 ["reopen_issue", "issues:write"],
358 ["add_comment", "issues:write"],
359 ["import_issue", "issues:write"],
360 ["apply_plan", "issues:write"],
361 ["list_pull_requests", "pull_requests:read"],
362 ["get_pull_request", "pull_requests:read"],
363 ["get_pull_request_changes", "pull_requests:read"],
364 ["read_session", "pull_requests:read"],
365 ["get_merge_queue", "pull_requests:read"],
366 ["create_pull_request", "pull_requests:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar367 ["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 step368 ["record_session", "pull_requests:write"],
369 ["mark_pull_request_ready", "pull_requests:write"],
370 ["close_pull_request", "pull_requests:write"],
371 ["review_pull_request", "pull_requests:write"],
372 ["merge_pull_request", "pull_requests:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar373 ["request_reviewers", "pull_requests:write"],
374 ["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 step375 ["assign_issue", "agents:run"],
376 ["delegate", "agents:run"],
377 ["plan_work", "agents:run"],
378 ["message_agent", "agents:run"],
379 ["answer_message", "agents:run"],
380 ["take_messages", "agents:run"],
381 ["list_workflows", "workflows:read"],
382 ["list_workflow_runs", "workflows:read"],
383 ["get_workflow_run", "workflows:read"],
384 ["get_job_logs", "workflows:read"],
385 ["dispatch_workflow", "workflows:write"],
386 ["cancel_workflow_run", "workflows:write"],
387 ["rerun_workflow_run", "workflows:write"],
388 ["update_workflow", "workflows:write"],
Merge main: Deployments panel in the About, project homepage, both sides' operations389 // Deployments, wherever they run: reading them, and reporting them.
390 ["list_deployments", "deployments:read"],
391 ["get_deployment", "deployments:read"],
392 ["list_deployment_statuses", "deployments:read"],
393 ["list_environments", "deployments:read"],
394 ["get_environment", "deployments:read"],
395 ["create_deployment", "deployments:write"],
396 ["create_deployment_status", "deployments:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step397 ["recall", "memory:read"],
398 ["search_context", "memory:read"],
399 ["get_entity", "memory:read"],
400 ["get_context", "memory:read"],
401 ["remember", "memory:write"],
402 ["list_collaborators", "access:read"],
403 ["get_collaborator_permission", "access:read"],
404 ["list_repo_invitations", "access:read"],
405 ["list_outside_collaborators", "access:read"],
406 ["add_collaborator", "access:admin"],
407 ["update_collaborator", "access:admin"],
408 ["remove_collaborator", "access:admin"],
409 ["revoke_repo_invitation", "access:admin"],
410 ["set_base_permission", "access:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar411 ["set_team_repo", "access:admin"],
412 ["remove_team_repo", "access:admin"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step413 ["list_webhooks", "webhooks:read"],
414 ["list_webhook_deliveries", "webhooks:read"],
415 ["create_webhook", "webhooks:admin"],
416 ["update_webhook", "webhooks:admin"],
417 ["delete_webhook", "webhooks:admin"],
418 ["ping_webhook", "webhooks:admin"],
419 ["redeliver_webhook", "webhooks:admin"],
420 ["list_actions_secrets", "secrets:read"],
421 ["list_actions_variables", "secrets:read"],
422 ["set_actions_secret", "secrets:admin"],
423 ["delete_actions_secret", "secrets:admin"],
424 ["set_actions_variable", "secrets:admin"],
425 ["delete_actions_variable", "secrets:admin"],
Fast pages, required checks on the branch, self-hosted runners, honest incidents426 // Self-hosted runners.
427 ["list_runners", "runners:read"],
428 ["list_runner_groups", "runners:read"],
429 ["get_runner_settings", "runners:read"],
430 ["create_runner_registration_token", "runners:admin"],
431 ["remove_runner", "runners:admin"],
432 ["create_runner_group", "runners:admin"],
433 ["update_runner_group", "runners:admin"],
434 ["delete_runner_group", "runners:admin"],
435 ["update_runner_settings", "runners:admin"],
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens436 // The AI Gateway. Sending a request to a model needs `models:write`,
437 // checked by the model proxy at models.g1t.sh.
438 ["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 step439] as const;
440
441/**
442 * The scopes a token or grant holds, as stored: null for full access, or
443 * the list. `legacy` marks a token made before scopes, which has full
444 * access until someone narrows it.
445 */
446export type TokenScopes = {
447 scopes: Scope[] | null;
448 legacy: boolean;
449};
450
451/**
452 * How settings group scopes into a checklist: each group's scopes, least
453 * first. Admin scopes are not here; they are under "Dangerous" on their
454 * own (see `DANGEROUS_SCOPES`). Every other scope is in exactly one group.
455 */
456export const SCOPE_GROUPS: { id: string; label: string; scopes: Scope[] }[] = [
457 { 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 bar458 { 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 member459 { 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 step460 { id: "work", label: "Issues & pull requests", scopes: ["issues:read", "issues:write", "pull_requests:read", "pull_requests:write"] },
461 { id: "agents", label: "Agents", scopes: ["agents:run"] },
462 { id: "workflows", label: "Workflows", scopes: ["workflows:read", "workflows:write"] },
Merge main: Deployments panel in the About, project homepage, both sides' operations463 { 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 step464 { id: "memory", label: "Memory & search", scopes: ["memory:read", "memory:write"] },
465 { id: "account", label: "Account", scopes: ["account:read", "account:write"] },
API: notifications over REST and MCP, with notifications scopes466 { 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 step467 { id: "workspace", label: "Workspace", scopes: ["workspace:read", "access:read", "webhooks:read", "secrets:read"] },
Usage, Billing settings and prepaid AI credit; fixes from the UX audit468 { id: "billing", label: "Billing", scopes: ["billing:read", "billing:write"] },
Fast pages, required checks on the branch, self-hosted runners, honest incidents469 { id: "runners", label: "Runners", scopes: ["runners:read"] },
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens470 { 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 step471];
472
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member473/** 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 step474export 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.