Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/server/src/mcp/McpToolAccess.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { liveThreadShell } from "./McpToolAccess.testkit.ts";
const supervisedThreadId = ThreadId.make("thread:supervised");
const planThreadId = ThreadId.make("thread:plan");
const fullAccessThreadId = ThreadId.make("thread:full-access");
const autoThreadId = ThreadId.make("thread:auto");
const endedThreadId = ThreadId.make("thread:ended");
const backgroundThreadId = ThreadId.make("thread:background");
const oldProviderThreadId = ThreadId.make("thread:old-provider-background");
Expand All @@ -48,6 +49,7 @@ const shells = new Map([
liveThreadShell(planThreadId, { runtimeMode: "approval-required", interactionMode: "plan" }),
],
[fullAccessThreadId, liveThreadShell(fullAccessThreadId)],
[autoThreadId, liveThreadShell(autoThreadId, { runtimeMode: "auto" })],
[endedThreadId, liveThreadShell(endedThreadId, { activeRunId: null })],
[backgroundThreadId, backgroundShell(backgroundThreadId, ProviderInstanceId.make("codex"))],
[oldProviderThreadId, backgroundShell(oldProviderThreadId, ProviderInstanceId.make("claude"))],
Expand Down Expand Up @@ -228,6 +230,7 @@ const call = (
const supervised = threadCaller(supervisedThreadId);
const plan = threadCaller(planThreadId);
const fullAccess = threadCaller(fullAccessThreadId);
const auto = threadCaller(autoThreadId);
const ended = threadCaller(endedThreadId);
const background = threadCaller(backgroundThreadId);
const oldProviderBackground = threadCaller(oldProviderThreadId);
Expand All @@ -239,6 +242,7 @@ const mismatchedProvider = {
};
const supervisedClient = clientCaller("approval-required");
const fullAccessClient = clientCaller("full-access");
const autoAcceptEditsClient = clientCaller("auto-accept-edits");
const readOnlyClient = clientCaller("read-only");
const linkedClient: McpInvocationContext.McpInvocationScope = {
...supervisedClient,
Expand Down Expand Up @@ -317,9 +321,11 @@ it.effect.each([
["starts_threads", fullAccessClient, { runtimeMode: "full-access" }, "full-access/default"],

["writes_environment", fullAccess, {}, "ran"],
["writes_environment", auto, {}, "ran"],
["writes_environment", supervised, {}, "capability_denied"],
["writes_environment", plan, {}, "capability_denied"],
["writes_environment", fullAccessClient, {}, "ran"],
["writes_environment", autoAcceptEditsClient, {}, "ran"],
["writes_environment", supervisedClient, {}, "capability_denied"],
] as const)("%s from %o with %o: %s", ([tool, scope, args, expected]) =>
call(tool, scope, args).pipe(
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/mcp/McpToolAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { assertNotLinked, assertSameLink, callerLinkOrigin } from "./linkOrigin.
import * as McpInvocationContext from "./McpInvocationContext.ts";
import { resolveInteractionMode, resolveRuntimeMode } from "./delegatedTaskModes.ts";
import {
assertFullAccess,
assertLiveCaller,
assertMayChangeEnvironment,
assertTargetWithinLimits,
type Caller,
loadCaller,
Expand Down Expand Up @@ -318,8 +318,8 @@ export const afterForwarding = <P, A, E, R, E2, R2>(
forwarded,
);

const fullAccessRequired =
"Changing projects or environment settings needs a live full-access/default calling thread or a full-access client.";
const environmentChangeRefused =
"Changing projects or environment settings needs a calling thread with Auto-accept edits, Auto or Full access permissions that is not in plan mode, or a client approved for more than Supervised access. Ask the user to change this thread's permissions, or to make the change themselves.";

/** Recheck after waits before writing; caller modes may have changed. */
export const writesEnvironment = <P, A, E, R>(
Expand All @@ -341,14 +341,14 @@ export const writesEnvironment = <P, A, E, R>(
? Effect.void
: assertNotLinked(caller, "change projects or environment settings"),
),
Effect.tap((caller) => assertFullAccess(caller, fullAccessRequired)),
Effect.tap((caller) => assertMayChangeEnvironment(caller, environmentChangeRefused)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical mcp/McpToolAccess.ts:344

Auto and Auto-accept edits callers can now use run_scheduled_task_now to start a stored Full access task, bypassing the caller’s access ceiling. The handler only checks that the task exists, and ScheduledTaskService.runTask launches with the stored mode or dispatches to its bound thread without checking caller limits; validate the task and bound thread before dispatch and recheck under the lock.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/server/src/mcp/McpToolAccess.ts around line 344:

`Auto` and `Auto-accept edits` callers can now use `run_scheduled_task_now` to start a stored `Full` access task, bypassing the caller’s access ceiling. The handler only checks that the task exists, and `ScheduledTaskService.runTask` launches with the stored mode or dispatches to its bound thread without checking caller limits; validate the task and bound thread before dispatch and recheck under the lock.

);
return declare(
(params: P) => check.pipe(Effect.flatMap(() => handle(params, check))),
// Linked work never reaches a link at all; that is checked as the call goes.
() =>
orchestratingCaller.pipe(
Effect.tap((caller) => assertFullAccess(caller, fullAccessRequired)),
Effect.tap((caller) => assertMayChangeEnvironment(caller, environmentChangeRefused)),
),
);
};
Expand Down
5 changes: 3 additions & 2 deletions apps/server/src/mcp/threadAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ export function assertLiveCaller({ caller, scope }: Caller) {
);
}

export const assertFullAccess = (context: Caller, message: string) =>
context.limits.runtimeMode === "full-access" && context.limits.interactionMode === "default"
/** Supervised stays refused: Claude pre-approves T3 tools, so its user would see no approval step. */
export const assertMayChangeEnvironment = (context: Caller, message: string) =>
context.limits.runtimeMode !== "approval-required" && context.limits.interactionMode === "default"
? Effect.void
: Effect.fail(new OrchestratorMcpFailure({ code: "capability_denied", message }));

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/mcp/toolkits/environment/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const EnvironmentReadTool = Tool.make("t3_environment_read", {
const EnvironmentPreferencesTool = Tool.make("t3_environment_preferences_update", {
...shared,
description:
"Update environment-wide preferences. Live full-access or default caller thread only. Omitted fields are unchanged; `customInstructions: ''` clears it.",
"Update environment-wide preferences. Not for Supervised or plan callers. Omitted fields are unchanged; `customInstructions: ''` clears it.",
parameters: Schema.Struct({
environmentId: OrchestratorMcpEnvironmentTarget,
defaultThreadEnvMode: ServerSettingsPatch.fields.defaultThreadEnvMode,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/mcp/toolkits/orchestrator/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const handlers = {
}),
),
// A link lets every agent here reach the other environment, so it is an
// environment setting: full access, and never for linked work.
// environment setting: above Supervised, and never for linked work.
t3_environment_link: McpToolAccess.writesEnvironment((input) =>
Effect.gen(function* () {
const scope = yield* McpInvocationContext.McpInvocationContext;
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/mcp/toolkits/theme/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ThemeReadTool = Tool.make("t3_theme_read", {
const ThemeSetTool = Tool.make("t3_theme_set", {
...shared,
description:
"Restyle T3 Code itself, only when the user asks. With `theme`, publish it as `themeId` (same id updates it) and switch this server's web app and this machine's desktop app to it, not remote desktop apps. Without `theme`, switch to a built-in or published `themeId`. `appearance` sets light, dark, or system mode. Live full-access or default caller thread only.",
"Restyle T3 Code itself, only when the user asks. With `theme`, publish it as `themeId` (same id updates it) and switch this server's web app and this machine's desktop app to it, not remote desktop apps. Without `theme`, switch to a built-in or published `themeId`. `appearance` sets light, dark, or system mode. Not for Supervised or plan callers.",
parameters: Schema.Struct({
themeId: Schema.optionalKey(EnvironmentThemeId),
theme: Schema.optionalKey(EnvironmentThemeFile),
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/mcp/toolkits/thread/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const ThreadSearchTool = Tool.make("t3_thread_search", {
const ScheduledTaskRunTool = Tool.make("run_scheduled_task_now", {
...commandTool,
description:
"Run one scheduled task now. Needs a full-access or default caller. Returns its thread, or null if not started. Success means started, not finished.",
"Run one scheduled task now. Not for Supervised or plan callers. Returns its thread, or null if not started. Success means started, not finished.",
parameters: Schema.Struct({
environmentId: OrchestratorMcpEnvironmentTarget,
taskId: ScheduledTaskId,
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/peer/PeerForwarding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ it.effect("launches in a linked environment with the caller's modes, retry-safe"
).pipe(Effect.provide(NodeHttpServer.layerTest)),
);

it.effect("brings a repository to a linked environment, only through full access", () =>
it.effect("brings a repository to a linked environment, only through a link above supervised", () =>
Effect.scoped(
Effect.gen(function* () {
const seen = yield* Ref.make<Seen>(nothingSeen);
Expand Down Expand Up @@ -583,8 +583,8 @@ it.effect("brings a repository to a linked environment, only through full access
expect(failureOf(planned)).toMatchObject({ code: "capability_denied" });
expect(yield* Ref.get(b.bearers)).toEqual([]);

// Nor may a full-access agent through a link with less: the box holds it.
yield* linkTo(a.links, b, "auto");
// Nor may a full-access agent through a supervised link: the box holds it.
yield* linkTo(a.links, b, "approval-required");
for (const [name, args] of [
["t3_project_clone", clone],
["t3_project_create", register],
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/peer/PeerLinkRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,10 +956,10 @@ it.live("a card an older server left naming a machine beside its address links n
),
);

it.live("an agent below full access may not ask, and no card is shown", () =>
it.live("a supervised agent may not ask, and no card is shown", () =>
withBoth((a, b) =>
Effect.gen(function* () {
yield* seedThread(a, "auto");
yield* seedThread(a, "approval-required");
const refused = yield* a.call({ url: b.url });
expect(errorOf(refused)).toMatchObject({ code: "capability_denied" });
expect(yield* cardOf(a)).toBeUndefined();
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/provider/agentContextBudget.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"claudeSystemAppendBytes": 5930,
"codexAdditionalContextBytes": 7324,
"mcpToolListJsonBytes": 52145
"mcpToolListJsonBytes": 52118
}
2 changes: 1 addition & 1 deletion docs/user/appearance.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ An agent on the same machine as the server can restyle T3 Code for you. Ask it t
for example "make T3 Code's chat header taller" or "give T3 Code a solarized theme". It publishes
an [environment theme](#environment-themes) with colors and CSS, and web and desktop clients of that
server switch to it. It can also switch them to light, dark, or system mode. The thread must run
in Full access. Ask the agent to set a built-in theme to undo it.
in Auto-accept edits, Auto, or Full access, outside plan mode. Ask the agent to set a built-in theme to undo it.

## Environment themes

Expand Down
Loading