Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

managed-policy.md

274 lines14.3 KB

1# Managed policy
2​
3A managed policy lets an administrator configure T3 Code for every user on a machine. It sets
4defaults and locks for settings, and limits such as the broadest permission mode or which
5providers may run. The T3 Code server on the machine enforces it for every app that connects:
6the desktop app, a browser, or the mobile app.
7​
8## Roll out a policy
9​
101. Write the policy as JSON, starting from the [example](#write-a-policy).
112. Run `t3 policy check policy.json`. It prints what the policy will do, or what is wrong with it.
123. Deploy the policy to each machine with your device management tool, in
13 [one of the supported places](#where-the-policy-goes).
144. Restart T3 Code on the machine. The server reads the policy only when it starts.
155. Run `t3 policy show` on the machine to
16 [check what the server loaded](#check-what-the-server-loaded).
17​
18The desktop app includes the `t3` command; see [The `t3` command](./install.md#the-t3-command).
19​
20## Write a policy
21​
22```json
24 "schemaVersion": 1,
25 "organization": "Example Corp",
26 "supportUrl": "https://it.example.com/t3",
27 "settings": {
28 "defaultRuntimeMode": { "value": "approval-required", "locked": false },
29 "enableAgentBrowserAccess": { "value": false, "locked": true }
30 },
31 "limits": {
32 "maxRuntimeMode": "auto-accept-edits",
33 "clients": ["desktop", "local-browser"],
34 "telemetry": false
35 }
37```
38​
39`schemaVersion` and `organization` are required. Users see the organization's name in Settings
40and beside each control the policy locks, with a link to `supportUrl` if you set one. [`settings`](#settings)
41sets defaults and locks, and [`limits`](#limits) restricts what T3 Code may do.
42​
43Every user on the machine can read the policy, so do not put credentials in it.
44​
45## Where the policy goes
46​
47Use one of these per machine:
48​
49| OS | Native policy | Policy file |
50| ------- | ------------------------------------------------------------------- | ------------------------------------------------- |
51| macOS | Configuration profile for `com.t3tools.t3code` | `/Library/Application Support/T3Code/policy.json` |
52| Windows | `Policy` string value under `HKLM\SOFTWARE\Policies\T3Tools\T3Code` | `C:\Program Files\T3Code\policy.json` |
53| Linux | | `/etc/t3code/policy.json` |
54​
55T3 Code does not merge sources. If a machine has both a native policy and a policy file, T3 Code
56refuses to start until you remove one.
57​
58**Policy file.** Copy the JSON to the path for the OS. Make it and its folder writable only by
59administrators.
60​
61**macOS configuration profile.** Add a custom settings payload for the preference domain
62`com.t3tools.t3code`. The payload's keys are the policy's top-level keys (`schemaVersion`,
63`organization`, `supportUrl`, `settings`, `limits`); JSON objects become dictionaries and lists
64become arrays. To make the payload from a policy file you checked, run
65`plutil -convert xml1 -o com.t3tools.t3code.plist policy.json` and upload the result. Install it as
66a device profile, since T3 Code ignores user profiles, and deploy only one profile for this domain.
67A profile cannot hold `null`, so use a policy file if a setting's value must be `null`.
68​
69**Windows registry.** Set the `Policy` value (`REG_SZ`) to the whole policy as one line of JSON,
70from Group Policy Preferences or an Intune script. T3 Code reads it through the Windows registry
71API, so it works where registry tools such as `reg.exe` are blocked for users. In PowerShell, as an
72administrator:
73​
74```powershell
75$json = (Get-Content -Raw -Encoding UTF8 policy.json) -replace '\r?\n\s*', ''
76New-Item -Path HKLM:\SOFTWARE\Policies\T3Tools\T3Code -Force | Out-Null
77Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\T3Tools\T3Code -Name Policy -Value $json -Type String
78```
79​
80## Check what the server loaded
81​
82Run `t3 policy show` as the user who runs T3 Code. It prints the installed policy and its
83fingerprint, then says whether the running server loaded that policy or an older one. The server
84reads the policy only when it starts, so "Restart T3 Code to apply the installed policy" means it
85still enforces the old one. In Settings, users see that your organization manages the environment,
86and each locked control shows **Managed by**.
87​
88## Change or remove a policy
89​
90After you deploy, change, or remove a policy, restart the T3 Code server on the machine: quit and
91reopen the desktop app, or run `t3 service restart` for the
92[background service](./background-service.md). Reconnecting a phone or browser does not reload the
93policy.
94​
95To remove a policy, delete the file, remove the profile, or delete the registry value, then restart
96the server. Users get back the settings they had chosen, since T3 Code never writes policy values
97into them.
98​
99## When T3 Code refuses to start
100​
101T3 Code refuses to start rather than run with a policy it cannot fully enforce. That includes a
102policy it cannot read or parse, a setting it does not know, a value of the wrong type, a key this
103version does not support, or a machine with both a native policy and a file. The error names where
104the policy came from and what is wrong.
105​
106`t3 policy check` catches the same problems in a JSON file. For a profile or registry value, check
107the JSON before you convert it. A policy written for a newer version can use keys an older one
108cannot enforce, so upgrade T3 Code before you deploy a policy that uses them.
109​
110## Settings
111​
112Each key under `settings` is a setting's path in the server's `settings.json`, such as
113`storageCleanup.logsAfterDays`. To find a path, change the setting in T3 Code and look in
114`settings.json` under `~/.t3/userdata`.
115​
116- `"locked": false` sets a default. It applies wherever the user has not chosen a value of their
117 own, and users can change it.
118- `"locked": true` sets the value. Users and agents cannot change it, in Settings or in a project's
119 settings, and Settings shows the control as managed by your organization. Removing the policy
120 brings back the user's own value.
121​
122A few settings need care:
123​
124- A default cannot add an entry, such as a provider instance, because users could never remove it.
125 Lock the entry instead, or set provider fields with [`providers.instances`](#providers).
126- A setting that can be empty, such as `defaultModelSelection`, is managed as a whole. You cannot
127 manage one field inside it.
128- `defaultRuntimeMode` cannot be broader than [`maxRuntimeMode`](#permission-modes).
129- `worktreeCleanup`, which projects can also set, overrides the `worktree` rules in
130 `storageCleanup`. Lock it along with those rules; T3 Code refuses a policy that locks only the
131 rules.
132- Manage `idleCompaction`, not the older `compactIdleThreads`. A Claude instance's own idle
133 compaction choice still wins over `idleCompaction`.
134- A provider instance's fields override each other, so lock `providerInstances.<id>` as a whole,
135 or pin single fields with [`providers.instances`](#providers). T3 Code refuses a lock on one
136 field inside an instance. A whole-instance lock covers only that instance; to cover every
137 instance of a provider, use `providers.instances`.
138​
139## Limits
140​
141`limits` restricts what T3 Code may do. Leave a key out to keep T3 Code's normal behavior.
142​
143```json
145 "schemaVersion": 1,
146 "organization": "Example Corp",
147 "limits": {
148 "maxRuntimeMode": "auto-accept-edits",
149 "clients": ["desktop"],
150 "connect": false,
151 "webhookTasks": false,
152 "browserCookieImport": false,
153 "telemetry": false,
154 "providers": {
155 "allowedDrivers": ["claudeAgent", "codex"],
156 "instances": {
157 "claudeAgent": {
158 "locked": true,
159 "environment": [{ "name": "CLAUDE_CODE_USE_BEDROCK", "value": "1" }]
160 }
161 }
162 },
163 "updates": { "mode": "auto", "feedUrl": "https://updates.example.com/t3code/" }
164 }
166```
167​
168### Permission modes
169​
170`maxRuntimeMode` is the broadest [permission mode](./permission-modes.md) any thread may use:
171`approval-required` (Supervised), `auto-accept-edits`, `auto`, or `full-access`. It covers threads
172that users start, agents start, and scheduled tasks start. A thread already above the limit cannot
173run another turn until someone lowers its mode; its queued messages send once that happens. New
174threads start at the limit when the user's default is above it.
175​
176With `maxRuntimeMode` set, you own each provider's launch settings: binary path, launch arguments,
177config home, and the environment variables set on each provider. They come from
178[`providers.instances`](#providers) or T3 Code's defaults, and users cannot change them, because a
179wrapper script, a launch flag, or a variable such as `NODE_OPTIONS` could otherwise turn off the
180provider's approvals. Pin the variables your users need, such as a gateway URL, in
181`providers.instances`. Variables in the environment that starts T3 Code itself still reach
182providers.
183​
184ACP agents' own mode menus have no effect under `maxRuntimeMode`, except Antigravity's, whose modes
185T3 Code can place under the limit. Users still choose which ACP Registry agent runs; leave
186`acpRegistry` out of `allowedDrivers` to stop that.
187​
188The limit decides which modes T3 Code asks the provider for. It is not a sandbox; see
189[What a policy does not cover](#what-a-policy-does-not-cover).
190​
191### Clients and T3 Connect
192​
193`clients` lists how the server may run:
194​
195- `desktop`: as the desktop app's own server.
196- `local-browser`: as a server only browsers on this machine reach, such as `npx t3`.
197- `remote`: reachable from phones, other computers, and app.t3.codes over the network.
198​
199`remote` is the line that matters. A server reachable from the network also accepts browsers on
200this machine, and the two local kinds differ only in how T3 Code was started. On machines with the
201desktop app, keep `desktop` in the list, or the app cannot start.
202​
203Without `remote`, the server listens only on a loopback address, creates no pairing links, and
204signs out devices that paired earlier. It does not start with a host other than a loopback
205address or `localhost`. The [background service](./background-service.md) listens on private
206networks by default, so set `T3CODE_HOST=127.0.0.1` in its `service.env`. The desktop app starts
207with network access and Tailscale Serve off, whatever the user chose. That also turns off
208T3 Connect. To keep other remote access but turn off T3 Connect alone, set `"connect": false`.
209​
210When it starts, the server also turns off each Tailscale Serve route, HTTPS or TCP, that forwards
211to it, such as one `t3 pair --tailscale` set up, and leaves other routes alone. It does not start
212while such a route stays on, or while Tailscale's answer cannot be read; the error names the
213command that turns the route off. A route whose target is a name, such as `localhost` or another
214machine on the same port, also stops it, since a name can resolve to this server; change the route
215or T3 Code's port. If Tailscale is installed but does not answer, as on a Mac where it was never set up, the
216server does not start until Tailscale is set up or removed. It does start when Tailscale is not
217installed, not running, or
218logged out, since nothing forwards then; a route Tailscale kept returns when Tailscale runs again,
219so restart T3 Code after that.
220​
221### Other capabilities
222​
223- `webhookTasks: false`: scheduled tasks cannot use webhook triggers. Existing webhook tasks stay
224 but do not run, and cannot be turned back on. Users can still edit or delete them.
225- `browserCookieImport: false`: users cannot import cookies from another browser into T3 Code's
226 browser.
227- `telemetry: false`: the server and desktop app send no [product usage data](./telemetry.md) or
228 relay connection traces. A policy cannot turn them on. A browser that opens the server, such as
229 app.t3.codes, still sends its own relay traces.
230​
231### Providers
232​
233`providers.allowedDrivers` lists the providers that may run, by ID: `codex` (Codex),
234`claudeAgent` (Claude), `cursor` (Cursor), `grok` (Grok), `opencode` (OpenCode), `antigravity`
235(Antigravity), `fx` (fx), `pi` (Pi), `muse` (Muse Code), and `acpRegistry` (ACP Registry).
236`t3 policy check` rejects an ID this version does not know. Threads on other providers stay,
237marked unavailable, and users can still turn those providers off.
238​
239`providers.instances` sets fields on every instance of a provider, such as an environment variable
240that routes Claude through Amazon Bedrock or a base URL for a company gateway. `binaryPath` and
241`launchArgs` work only for providers that have those settings. With `"locked": true`, users cannot
242change the fields you set. With `"locked": false`, the fields fill in only what the user left
243empty. A `codex` entry that is locked, or any `codex` entry under `maxRuntimeMode`, also rules out
244[Connect with ChatGPT](./providers-codex.md#connect-with-chatgpt), since that runtime would skip
245your fields. In the same way, an `opencode` entry like that rules out a server URL, so OpenCode
246starts the binary you set.
247​
248### Updates
249​
250- `mode`: `auto` keeps the normal update flow. `off` stops T3 Code from checking for updates, for
251 machines that get T3 Code through device management.
252- `feedUrl`: the desktop app updates from your own mirror of the release feed instead of GitHub.
253 Publish only the versions you have approved. The `t3` command-line server updates through npm,
254 so pin it with your package tooling.
255- `allowNightly: false`: the nightly channel is unavailable.
256​
257## What a policy does not cover
258​
259The policy controls what T3 Code does. Agents run through each provider's own CLI, which reads its
260own configuration, such as `~/.claude`, and which a user can also run outside T3 Code. To restrict
261those CLIs, use their own managed configuration, such as Claude Code's managed settings.
262​
263On a managed Windows machine, the desktop app does not run a WSL environment. A T3 Code server a
264user starts inside WSL reads `/etc/t3code/policy.json` in that distro, not the Windows policy.
265Deploy the policy file there too if your users run T3 Code in WSL.
266​
267Without `remote`, T3 Code does not expose the server, but a user can still forward its local port
268with other tools.
269​
270A user with administrator rights on the machine can edit or remove the policy. T3 Code enforces
271the policy in its own processes, which run as the user, so it stops users from changing managed
272settings in T3 Code but does not stop a user who modifies or replaces T3 Code itself. A version
273from before managed policy ignores it too. To control which builds can run, use your device
274management tool's application controls.