Skip to content

g1t/packages/contracts/src/scopes.ts

439 lines21,269 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"
20 | "memory"
21 | "account"
API: notifications over REST and MCP, with notifications scopes22 | "notifications"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step23 | "workspace"
Usage, Billing settings and prepaid AI credit; fixes from the UX audit24 | "billing"
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step25 | "access"
26 | "webhooks"
Fast pages, required checks on the branch, self-hosted runners, honest incidents27 | "secrets"
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens28 | "runners"
29 | "models";
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step30
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member31export 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 step32
33/** Every scope, grouped by resource, least first. */
34export const SCOPES = [
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily35 { scope: "repo:read", description: "See repositories, their settings, labels, timelines and security alerts, and search" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step36 { scope: "repo:write", description: "Create repositories, rename branches and change how pull requests merge" },
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge37 { 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 step38 { scope: "code:read", description: "Clone and fetch private repositories with git" },
39 { scope: "code:write", description: "Push commits with git" },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar40 { scope: "security:read", description: "See secret scanning, code scanning and vulnerability alerts, custom patterns, the dependency graph and SBOM, and security settings" },
41 { 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 member42 { scope: "packages:read", description: "Pull container images and install private packages" },
43 { scope: "packages:write", description: "Push container images and publish packages" },
44 { 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 step45 { scope: "issues:read", description: "Read issues, comments and plans" },
46 { scope: "issues:write", description: "Open, edit, close and comment on issues" },
47 { scope: "pull_requests:read", description: "Read pull requests, their changes, sessions and merge queues" },
48 { scope: "pull_requests:write", description: "Open, review, close and merge pull requests" },
49 { scope: "agents:run", description: "Put g1t agents to work and message them, which uses the workspace's money" },
50 { scope: "workflows:read", description: "Read workflows, runs and logs" },
51 { scope: "workflows:write", description: "Run, cancel, rerun and turn workflows on or off" },
52 { scope: "memory:read", description: "Recall memory and search the workspace's context" },
53 { scope: "memory:write", description: "Save memory for the next agent" },
API: pinned projects over REST and MCP54 { scope: "account:read", description: "Read your email addresses, invites, invitations and pinned projects" },
55 { scope: "account:write", description: "Change your email addresses, make invites, answer invitations and pin projects" },
API: notifications over REST and MCP, with notifications scopes56 { scope: "notifications:read", description: "See your inbox, its threads, and what you subscribe to and watch" },
57 { 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 merge58 { scope: "workspace:read", description: "Read workspace settings, invites, integrations, model routes, teams and rulesets" },
59 { 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 audit60 { scope: "billing:read", description: "See a workspace's usage, budget, AI credit and invoices" },
61 { 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 step62 { 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 bar63 { 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 step64 { scope: "webhooks:read", description: "See webhooks and their deliveries" },
65 { scope: "webhooks:admin", description: "Create, change and delete webhooks" },
66 { scope: "secrets:read", description: "List secrets (never their values) and read variables" },
67 { scope: "secrets:admin", description: "Set and delete secrets and variables" },
Fast pages, required checks on the branch, self-hosted runners, honest incidents68 { scope: "runners:read", description: "See self-hosted runners, their groups and where agents run" },
69 { 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 tokens70 { scope: "models:read", description: "See the workspace's AI Gateway requests: their models, tokens, cost and status" },
71 { 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 step72] as const;
73
74export type Scope = (typeof SCOPES)[number]["scope"];
75
76/** Resources in the order settings show them, with their names for people. */
77export const SCOPE_RESOURCES: { resource: ScopeResource; label: string }[] = [
78 { resource: "repo", label: "Repositories" },
79 { resource: "code", label: "Code" },
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar80 { resource: "security", label: "Security" },
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member81 { resource: "packages", label: "Packages" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step82 { resource: "issues", label: "Issues" },
83 { resource: "pull_requests", label: "Pull requests" },
84 { resource: "agents", label: "g1t agents" },
85 { resource: "workflows", label: "Workflows" },
86 { resource: "memory", label: "Memory and context" },
87 { resource: "account", label: "Your account" },
API: notifications over REST and MCP, with notifications scopes88 { resource: "notifications", label: "Notifications" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step89 { resource: "workspace", label: "Workspaces" },
Usage, Billing settings and prepaid AI credit; fixes from the UX audit90 { resource: "billing", label: "Billing" },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step91 { resource: "access", label: "Who has access" },
92 { resource: "webhooks", label: "Webhooks" },
93 { resource: "secrets", label: "Secrets and variables" },
Fast pages, required checks on the branch, self-hosted runners, honest incidents94 { resource: "runners", label: "Self-hosted runners" },
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens95 { 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 step96];
97
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member98const 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 step99
100export function scopeResource(scope: Scope): ScopeResource {
101 return scope.split(":")[0] as ScopeResource;
102}
103
104export function scopeLevel(scope: Scope): ScopeLevel {
105 return scope.split(":")[1] as ScopeLevel;
106}
107
108export function isScope(text: string): text is Scope {
109 return SCOPES.some((row) => row.scope === text);
110}
111
112/** Changes that are hard to undo, or decide who can reach what. */
113export function isDangerous(scope: Scope): boolean {
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member114 const level = scopeLevel(scope);
115 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 step116}
117
118export function describeScope(scope: Scope): string {
119 return SCOPES.find((row) => row.scope === scope)?.description ?? scope;
120}
121
122/** Whether holding `held` gives `needed`: the same resource, at its level or lower. */
123export function scopeIncludes(held: Scope, needed: Scope): boolean {
124 return (
125 scopeResource(held) === scopeResource(needed) &&
126 LEVEL_ORDER[scopeLevel(held)] >= LEVEL_ORDER[scopeLevel(needed)]
127 );
128}
129
130/** The levels a resource has, least first. */
131export function levelsOf(resource: ScopeResource): ScopeLevel[] {
132 return SCOPES.filter((row) => scopeResource(row.scope) === resource).map((row) => scopeLevel(row.scope));
133}
134
135/** Scopes from text separated by spaces or commas, in table order; unknown ones are left out. */
136export function parseScopes(text: string): Scope[] {
137 const given = new Set(text.split(/[\s,]+/).map((part) => part.trim().toLowerCase()));
138 return SCOPES.map((row) => row.scope).filter((scope) => given.has(scope));
139}
140
141/** What a token stores for full access. */
142export const FULL_ACCESS = "*";
143
144export type PresetId = "read_only" | "agent" | "ci" | "full";
145
146/** Starting points for choosing scopes. `*` is full access. */
147export const PRESET_SCOPES = {
148 read_only: [
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens149 "repo:read", "code:read", "security:read", "packages:read", "issues:read", "pull_requests:read", "workflows: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 step150 ] as const,
151 agent: [
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens152 "repo:read", "code:read", "code:write", "security:read", "packages:read", "issues:read", "issues:write", "pull_requests:read", "pull_requests:write", "agents:run", "workflows: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 step153 ] as const,
154 ci: [
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member155 "repo:read", "code:read", "code:write", "packages:read", "packages:write", "workflows:read", "workflows:write",
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step156 ] as const,
157 full: [
158 "*",
159 ] as const,
160};
161
162export const PRESETS: { id: PresetId; label: string; description: string }[] = [
163 { id: "read_only", label: "Read only", description: "Read everything you can read; change nothing." },
164 { id: "agent", label: "Agent", description: "Read everything, work on issues and pull requests, push code and run g1t agents." },
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member165 { id: "ci", label: "CI", description: "Clone and push code, push and pull packages, and run workflows." },
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step166 { id: "full", label: "Full access", description: "Everything you can do, including deleting repositories and changing who has access." },
167];
168
169/** The scopes of a preset, or null for full access. */
170export function presetScopes(id: PresetId): Scope[] | null {
171 if (id === "full") return null;
172 return [...PRESET_SCOPES[id]] as Scope[];
173}
174
175/** What an OAuth client gets when it asks for nothing in particular. */
176export const OAUTH_DEFAULT_SCOPES: Scope[] = [...PRESET_SCOPES.agent];
177
178/** The operation each scope gates, by the API's operation names. */
179export const OPERATION_SCOPES = [
180 ["list_emails", "account:read"],
181 ["add_email", "account:write"],
182 ["remove_email", "account:write"],
183 ["update_email_settings", "account:write"],
184 ["list_invites", "account:read"],
185 ["create_invite", "account:write"],
186 ["revoke_invite", "account:write"],
187 ["list_my_repo_invitations", "account:read"],
188 ["accept_repo_invitation", "account:write"],
189 ["decline_repo_invitation", "account:write"],
API: pinned projects over REST and MCP190 // Your pinned projects: a preference of your account.
191 ["list_pinned_projects", "account:read"],
192 ["pin_project", "account:write"],
193 ["unpin_project", "account:write"],
194 ["reorder_pinned_projects", "account:write"],
API: notifications over REST and MCP, with notifications scopes195 // Your inbox: notifications, subscriptions and watching.
196 ["list_notifications", "notifications:read"],
197 ["get_notification_thread", "notifications:read"],
198 ["get_thread_subscription", "notifications:read"],
199 ["get_repo_subscription", "notifications:read"],
200 ["list_watched_repos", "notifications:read"],
201 ["mark_notifications_read", "notifications:write"],
202 ["mark_thread_read", "notifications:write"],
203 ["mark_thread_done", "notifications:write"],
204 ["save_thread", "notifications:write"],
205 ["snooze_thread", "notifications:write"],
206 ["set_thread_subscription", "notifications:write"],
207 ["delete_thread_subscription", "notifications:write"],
208 ["set_repo_subscription", "notifications:write"],
209 ["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 step210 ["create_workspace", "workspace:admin"],
211 ["delete_workspace", "workspace:admin"],
Merge branch 'worktree-agent-ad7c6d88d93adc817'212 ["get_workspace", "workspace:read"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily213 ["update_workspace", "workspace:admin"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step214 ["list_workspace_invites", "workspace:read"],
215 ["invite_member", "workspace:admin"],
216 ["revoke_workspace_invite", "workspace:admin"],
217 ["list_integrations", "workspace:read"],
218 ["connect_integration", "workspace:admin"],
219 ["disconnect_integration", "workspace:admin"],
220 ["test_integration", "workspace:admin"],
221 ["get_model_routes", "workspace:read"],
222 ["set_model_routes", "workspace:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar223 ["list_teams", "workspace:read"],
224 ["get_team", "workspace:read"],
225 ["list_team_members", "workspace:read"],
226 ["list_child_teams", "workspace:read"],
227 ["list_team_repos", "workspace:read"],
228 ["list_user_teams", "workspace:read"],
229 ["create_team", "workspace:admin"],
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge230 ["list_workspace_rulesets", "workspace:read"],
231 ["get_workspace_ruleset", "workspace:read"],
232 ["list_workspace_rule_evaluations", "workspace:read"],
233 ["create_workspace_ruleset", "workspace:admin"],
234 ["update_workspace_ruleset", "workspace:admin"],
235 ["delete_workspace_ruleset", "workspace:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar236 ["update_team", "workspace:admin"],
237 ["delete_team", "workspace:admin"],
238 ["set_team_member", "workspace:admin"],
239 ["remove_team_member", "workspace:admin"],
240 ["set_team_review_assignment", "workspace:admin"],
Usage, Billing settings and prepaid AI credit; fixes from the UX audit241 // A workspace's billing: usage, budget, AI credit and invoices.
242 ["get_usage", "billing:read"],
243 ["get_budget", "billing:read"],
244 ["get_ai_credit", "billing:read"],
245 ["list_invoices", "billing:read"],
246 ["get_billing_details", "billing:read"],
247 ["set_budget", "billing:write"],
248 ["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 step249 ["list_repos", "repo:read"],
250 ["get_repo", "repo:read"],
251 ["search", "repo:read"],
252 ["list_events", "repo:read"],
253 ["list_labels", "repo:read"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar254 ["list_milestones", "repo:read"],
255 ["get_milestone", "repo:read"],
256 ["create_label", "issues:write"],
257 ["update_label", "issues:write"],
258 ["delete_label", "issues:write"],
259 ["add_default_labels", "issues:write"],
260 ["create_milestone", "issues:write"],
261 ["update_milestone", "issues:write"],
262 ["delete_milestone", "issues:write"],
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step263 ["get_repo_settings", "repo:read"],
Fast pages, required checks on the branch, self-hosted runners, honest incidents264 ["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 step265 ["list_deleted_repos", "repo:read"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily266 ["list_security_alerts", "repo:read"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar267 ["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 step268 ["create_repo", "repo:write"],
269 ["update_repo", "repo:write"],
270 ["update_repo_settings", "repo:write"],
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge271 ["list_repo_rulesets", "repo:read"],
272 ["get_repo_ruleset", "repo:read"],
273 ["get_branch_rules", "repo:read"],
274 ["list_rule_evaluations", "repo:read"],
275 ["create_repo_ruleset", "repo:admin"],
276 ["update_repo_ruleset", "repo:admin"],
277 ["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 step278 ["rename_branch", "repo:write"],
279 ["rename_repo", "repo:admin"],
280 ["transfer_repo", "repo:admin"],
281 ["archive_repo", "repo:admin"],
282 ["unarchive_repo", "repo:admin"],
283 ["set_repo_visibility", "repo:admin"],
284 ["delete_repo", "repo:admin"],
285 ["restore_repo", "repo:admin"],
286 ["purge_repo", "repo:admin"],
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily287 ["dismiss_security_alert", "repo:admin"],
288 ["reopen_security_alert", "repo:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar289 // The security suite.
290 ["list_secret_scanning_alerts", "security:read"],
291 ["get_secret_scanning_alert", "security:read"],
292 ["list_secret_scanning_locations", "security:read"],
293 ["list_bypass_requests", "security:read"],
294 ["list_custom_patterns", "security:read"],
295 ["list_code_scanning_alerts", "security:read"],
296 ["get_code_scanning_alert", "security:read"],
297 ["list_code_scanning_analyses", "security:read"],
298 ["get_sarif_upload", "security:read"],
299 ["list_vulnerability_alerts", "security:read"],
300 ["get_vulnerability_alert", "security:read"],
301 ["get_dependency_graph", "security:read"],
302 ["get_sbom", "security:read"],
303 ["compare_dependencies", "security:read"],
304 ["get_security_settings", "security:read"],
305 ["get_workspace_security_settings", "security:read"],
306 ["get_security_overview", "security:read"],
307 ["update_secret_scanning_alert", "security:write"],
308 ["bypass_push_protection", "security:write"],
309 ["check_secret_validity", "security:write"],
310 ["review_bypass_request", "security:write"],
311 ["create_custom_pattern", "security:write"],
312 ["update_custom_pattern", "security:write"],
313 ["delete_custom_pattern", "security:write"],
314 ["dry_run_custom_pattern", "security:write"],
315 ["update_code_scanning_alert", "security:write"],
316 ["upload_sarif", "security:write"],
317 ["update_vulnerability_alert", "security:write"],
318 ["fix_security_alert", "security:write"],
319 ["update_security_settings", "security:write"],
320 ["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 step321 ["list_issues", "issues:read"],
322 ["get_issue", "issues:read"],
323 ["get_plan", "issues:read"],
324 ["create_issue", "issues:write"],
325 ["update_issue", "issues:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar326 ["list_issue_labels", "issues:read"],
327 ["add_issue_labels", "issues:write"],
328 ["set_issue_labels", "issues:write"],
329 ["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 step330 ["close_issue", "issues:write"],
331 ["reopen_issue", "issues:write"],
332 ["add_comment", "issues:write"],
333 ["import_issue", "issues:write"],
334 ["apply_plan", "issues:write"],
335 ["list_pull_requests", "pull_requests:read"],
336 ["get_pull_request", "pull_requests:read"],
337 ["get_pull_request_changes", "pull_requests:read"],
338 ["read_session", "pull_requests:read"],
339 ["get_merge_queue", "pull_requests:read"],
340 ["create_pull_request", "pull_requests:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar341 ["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 step342 ["record_session", "pull_requests:write"],
343 ["mark_pull_request_ready", "pull_requests:write"],
344 ["close_pull_request", "pull_requests:write"],
345 ["review_pull_request", "pull_requests:write"],
346 ["merge_pull_request", "pull_requests:write"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar347 ["request_reviewers", "pull_requests:write"],
348 ["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 step349 ["assign_issue", "agents:run"],
350 ["delegate", "agents:run"],
351 ["plan_work", "agents:run"],
352 ["message_agent", "agents:run"],
353 ["answer_message", "agents:run"],
354 ["take_messages", "agents:run"],
355 ["list_workflows", "workflows:read"],
356 ["list_workflow_runs", "workflows:read"],
357 ["get_workflow_run", "workflows:read"],
358 ["get_job_logs", "workflows:read"],
359 ["dispatch_workflow", "workflows:write"],
360 ["cancel_workflow_run", "workflows:write"],
361 ["rerun_workflow_run", "workflows:write"],
362 ["update_workflow", "workflows:write"],
363 ["recall", "memory:read"],
364 ["search_context", "memory:read"],
365 ["get_entity", "memory:read"],
366 ["get_context", "memory:read"],
367 ["remember", "memory:write"],
368 ["list_collaborators", "access:read"],
369 ["get_collaborator_permission", "access:read"],
370 ["list_repo_invitations", "access:read"],
371 ["list_outside_collaborators", "access:read"],
372 ["add_collaborator", "access:admin"],
373 ["update_collaborator", "access:admin"],
374 ["remove_collaborator", "access:admin"],
375 ["revoke_repo_invitation", "access:admin"],
376 ["set_base_permission", "access:admin"],
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar377 ["set_team_repo", "access:admin"],
378 ["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 step379 ["list_webhooks", "webhooks:read"],
380 ["list_webhook_deliveries", "webhooks:read"],
381 ["create_webhook", "webhooks:admin"],
382 ["update_webhook", "webhooks:admin"],
383 ["delete_webhook", "webhooks:admin"],
384 ["ping_webhook", "webhooks:admin"],
385 ["redeliver_webhook", "webhooks:admin"],
386 ["list_actions_secrets", "secrets:read"],
387 ["list_actions_variables", "secrets:read"],
388 ["set_actions_secret", "secrets:admin"],
389 ["delete_actions_secret", "secrets:admin"],
390 ["set_actions_variable", "secrets:admin"],
391 ["delete_actions_variable", "secrets:admin"],
Fast pages, required checks on the branch, self-hosted runners, honest incidents392 // Self-hosted runners.
393 ["list_runners", "runners:read"],
394 ["list_runner_groups", "runners:read"],
395 ["get_runner_settings", "runners:read"],
396 ["create_runner_registration_token", "runners:admin"],
397 ["remove_runner", "runners:admin"],
398 ["create_runner_group", "runners:admin"],
399 ["update_runner_group", "runners:admin"],
400 ["delete_runner_group", "runners:admin"],
401 ["update_runner_settings", "runners:admin"],
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens402 // The AI Gateway. Sending a request to a model needs `models:write`,
403 // checked by the model proxy at models.g1t.sh.
404 ["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 step405] as const;
406
407/**
408 * The scopes a token or grant holds, as stored: null for full access, or
409 * the list. `legacy` marks a token made before scopes, which has full
410 * access until someone narrows it.
411 */
412export type TokenScopes = {
413 scopes: Scope[] | null;
414 legacy: boolean;
415};
416
417/**
418 * How settings group scopes into a checklist: each group's scopes, least
419 * first. Admin scopes are not here; they are under "Dangerous" on their
420 * own (see `DANGEROUS_SCOPES`). Every other scope is in exactly one group.
421 */
422export const SCOPE_GROUPS: { id: string; label: string; scopes: Scope[] }[] = [
423 { 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 bar424 { 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 member425 { 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 step426 { id: "work", label: "Issues & pull requests", scopes: ["issues:read", "issues:write", "pull_requests:read", "pull_requests:write"] },
427 { id: "agents", label: "Agents", scopes: ["agents:run"] },
428 { id: "workflows", label: "Workflows", scopes: ["workflows:read", "workflows:write"] },
429 { id: "memory", label: "Memory & search", scopes: ["memory:read", "memory:write"] },
430 { id: "account", label: "Account", scopes: ["account:read", "account:write"] },
API: notifications over REST and MCP, with notifications scopes431 { 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 step432 { id: "workspace", label: "Workspace", scopes: ["workspace:read", "access:read", "webhooks:read", "secrets:read"] },
Usage, Billing settings and prepaid AI credit; fixes from the UX audit433 { id: "billing", label: "Billing", scopes: ["billing:read", "billing:write"] },
Fast pages, required checks on the branch, self-hosted runners, honest incidents434 { id: "runners", label: "Runners", scopes: ["runners:read"] },
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens435 { 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 step436];
437
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member438/** 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 step439export 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.