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