Open History to see the last commit
1import {
2 AuthAccessReadScope,
3 AuthAccessWriteScope,
4 AuthDiagnosticsReadScope,
5 AuthEnvironmentMaintainScope,
6 AuthFilesystemReadScope,
7 AuthFilesystemWriteScope,
8 type AuthGrantScope,
9 AuthOrchestrationOperateScope,
10 AuthOrchestrationReadScope,
11 AuthPreviewOperateScope,
12 AuthProvidersManageScope,
13 AuthRelayReadScope,
14 AuthRelayWriteScope,
15 AuthSettingsWriteScope,
16 AuthSourceControlWriteScope,
17 AuthTerminalOperateScope,
18 AuthTerminalReadScope,
19} from "@t3tools/contracts";
20import { mFallback, msg } from "gt-i18n";
21import type { MFunctionType } from "gt-i18n/types";
22
23export const AUTH_SCOPE_OPTIONS: ReadonlyArray<{
24 readonly scope: AuthGrantScope;
25 readonly title: string;
26 readonly description: string;
27}> = [
28 {
29 scope: AuthOrchestrationReadScope,
30 title: msg("View environment"),
31 description: msg("Read threads, status, checkpoints, and configuration."),
32 },
33 {
34 scope: AuthOrchestrationOperateScope,
35 title: msg("Operate tasks"),
36 description: msg("Start, update, and stop tasks."),
37 },
38 {
39 scope: AuthSettingsWriteScope,
40 title: msg("Change environment settings"),
41 description: msg("Edit environment preferences and keybindings."),
42 },
43 {
44 scope: AuthProvidersManageScope,
45 title: msg("Manage providers"),
46 description: msg("Configure, install, sign in to, and update providers and usage sources."),
47 },
48 {
49 scope: AuthEnvironmentMaintainScope,
50 title: msg("Maintain environment"),
51 description: msg("Update the server and control environment processes."),
52 },
53 {
54 scope: AuthPreviewOperateScope,
55 title: msg("Control previews"),
56 description: msg("Open browser previews and host browser automation."),
57 },
58 {
59 scope: AuthDiagnosticsReadScope,
60 title: msg("View diagnostics and usage"),
61 description: msg("Read process diagnostics, resource history, and usage totals."),
62 },
63 {
64 scope: AuthTerminalReadScope,
65 title: msg("View terminals"),
66 description: msg("Read existing terminal output and status."),
67 },
68 {
69 scope: AuthTerminalOperateScope,
70 title: msg("Use terminals"),
71 description: msg("Create terminals and send input to running shells."),
72 },
73 {
74 scope: AuthSourceControlWriteScope,
75 title: msg("Change source control"),
76 description: msg("Commit, push, manage branches and repositories, and change pull requests."),
77 },
78 {
79 scope: AuthFilesystemReadScope,
80 title: msg("Read files"),
81 description: msg("Browse host files, search workspaces, and inspect local changes."),
82 },
83 {
84 scope: AuthFilesystemWriteScope,
85 title: msg("Write files"),
86 description: msg("Edit workspace files and save plans to disk."),
87 },
88 {
89 scope: AuthAccessReadScope,
90 title: msg("View access"),
91 description: msg("Inspect pairing links and authorized clients."),
92 },
93 {
94 scope: AuthAccessWriteScope,
95 title: msg("Manage access"),
96 description: msg("Issue and revoke credentials for other clients."),
97 },
98 {
99 scope: AuthRelayReadScope,
100 title: msg("View relay"),
101 description: msg("Inspect managed relay connectivity."),
102 },
103 {
104 scope: AuthRelayWriteScope,
105 title: msg("Manage relay"),
106 description: msg("Change managed tunnel connectivity."),
107 },
108];
109
110/** Shown instead of the granted scopes while they are unknown, so every surface says the same thing. */
111export function sessionPermissionsUnavailableMessage(
112 input: {
113 readonly connected: boolean;
114 /** The check errored; the client retries it while connected. */
115 readonly failed: boolean;
116 /** The environment answered that this session is not signed in; retrying will not change that. */
117 readonly rejected: boolean;
118 },
119 resolve: MFunctionType = mFallback,
120): string {
121 if (!input.connected)
122 return resolve(msg("Connect to this environment to view this session’s permissions."));
123 if (input.rejected)
124 return resolve(msg("This environment did not accept your session. Reconnect to try again."));
125 return input.failed
126 ? resolve(msg("Could not verify your permissions. Retrying automatically."))
127 : resolve(msg("Checking permissions…"));
128}