@devries-cameron20 / t3code Mirror · read-only / commits / d6795eac3c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 12:15 UTC

fix(grok): background text generation no longer inherits Grok always-approve (#29692)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Alex Southwell committed Nov 15, 2026 at 15:50 UTC d6795eac3c662caf713ac6e024b7dd5eb642d8ab
3 files changed +61 -17
apps/server/src/provider/testFixtures/grok-text-mock-agent.mjs
+41 -12
@@ -5,12 +5,35 @@ const sessionId = "grok-text-session";
5 let currentModelId = "grok-mock-default";
6 const models = ["grok-mock-default", "grok-mock-alt"];
7 const write = (message) => process.stdout.write(`${JSON.stringify(message)}\n`);
8 +const permissionRequestId = 9001;
9 +let pendingPromptId;
10 +const completePrompt = (id) => {
11 + write({
12 + jsonrpc: "2.0",
13 + method: "session/update",
14 + params: {
15 + sessionId,
16 + update: {
17 + sessionUpdate: "agent_message_chunk",
18 + content: { type: "text", text: process.env.T3_ACP_PROMPT_RESPONSE_TEXT ?? "" },
19 + },
20 + },
21 + });
22 + write({ jsonrpc: "2.0", id, result: { stopReason: "end_turn" } });
23 +};
24
25 for await (const line of NodeReadline.createInterface({ input: process.stdin })) {
26 const request = JSON.parse(line);
27 if (process.env.T3_ACP_REQUEST_LOG_PATH) {
28 NodeFS.appendFileSync(process.env.T3_ACP_REQUEST_LOG_PATH, `${line}\n`);
29 }
30 + if (request.method === undefined) {
31 + if (request.id === permissionRequestId && pendingPromptId !== undefined) {
32 + completePrompt(pendingPromptId);
33 + pendingPromptId = undefined;
34 + }
35 + continue;
36 + }
37 if (request.id === undefined) continue;
38 let result;
39 switch (request.method) {
@@ -43,19 +66,25 @@ for await (const line of NodeReadline.createInterface({ input: process.stdin }))
66 result = {};
67 break;
68 case "session/prompt":
46 - write({
47 - jsonrpc: "2.0",
48 - method: "session/update",
49 - params: {
50 - sessionId,
51 - update: {
52 - sessionUpdate: "agent_message_chunk",
53 - content: { type: "text", text: process.env.T3_ACP_PROMPT_RESPONSE_TEXT ?? "" },
69 + if (process.env.T3_ACP_REQUEST_PERMISSION) {
70 + pendingPromptId = request.id;
71 + write({
72 + jsonrpc: "2.0",
73 + id: permissionRequestId,
74 + method: "session/request_permission",
75 + params: {
76 + sessionId,
77 + toolCall: { toolCallId: "tool-1", kind: "execute", title: "Run `git status`" },
78 + options: [
79 + { optionId: "allow-once", name: "Yes", kind: "allow_once" },
80 + { optionId: "reject-once", name: "No", kind: "reject_once" },
81 + ],
82 },
55 - },
56 - });
57 - result = { stopReason: "end_turn" };
58 - break;
83 + });
84 + continue;
85 + }
86 + completePrompt(request.id);
87 + continue;
88 default:
89 write({
90 jsonrpc: "2.0",
apps/server/src/textGeneration/GrokTextGeneration.test.ts
+14 -5
@@ -35,7 +35,7 @@ function makeAcpGrokWrapper(dir: string, env: Record<string, string>): string {
35 env,
36 source: execScriptSource({
37 scriptPath: mockAgentPath,
38 - expectedArgs: ["agent", "stdio"],
38 + expectedArgs: ["--permission-mode", "default", "agent", "stdio"],
39 }),
40 });
41 }
@@ -58,14 +58,19 @@ function withFakeAcpGrok<A, E, R>(
58 }).pipe(Effect.scoped);
59 }
60
61 -function readJsonRpcRequests(
62 - filePath: string,
63 -): ReadonlyArray<{ readonly method?: string; readonly params?: Record<string, unknown> }> {
61 +function readJsonRpcRequests(filePath: string): ReadonlyArray<{
62 + readonly id?: unknown;
63 + readonly method?: string;
64 + readonly params?: Record<string, unknown>;
65 +}> {
66 return NodeFS.readFileSync(filePath, "utf8")
67 .trim()
68 .split("\n")
69 .filter((line) => line.length > 0)
68 - .map((line) => JSON.parse(line) as { method?: string; params?: Record<string, unknown> });
70 + .map(
71 + (line) =>
72 + JSON.parse(line) as { id?: unknown; method?: string; params?: Record<string, unknown> },
73 + );
74 }
75
76 it.layer(layerGrokTextGenerationTest)("GrokTextGeneration", (it) => {
@@ -78,6 +83,7 @@ it.layer(layerGrokTextGenerationTest)("GrokTextGeneration", (it) => {
83 return withFakeAcpGrok(
84 {
85 T3_ACP_REQUEST_LOG_PATH: requestLogPath,
86 + T3_ACP_REQUEST_PERMISSION: "1",
87 T3_ACP_PROMPT_RESPONSE_TEXT: JSON.stringify({
88 subject: "Add Grok provider",
89 body: "Wire up the ACP runtime and headless text generation path.",
@@ -110,6 +116,9 @@ it.layer(layerGrokTextGenerationTest)("GrokTextGeneration", (it) => {
116 request.params?.modelId === "grok-mock-alt",
117 ),
118 ).toBe(true);
119 + expect(requests.find((request) => request.id === 9001)).toMatchObject({
120 + result: { outcome: { outcome: "cancelled" } },
121 + });
122 }),
123 );
124 });
packages/provider-grok/src/server/textGeneration.ts
+6
@@ -40,11 +40,17 @@ export const makeGrokTextGeneration = Effect.fn("makeGrokTextGeneration")(functi
40 environment,
41 cwd,
42 clientInfo: { name: "t3-code-git-text", version: "0.0.0" },
43 + // Grok config may always-approve; ask mode sends tool approvals here, and none are granted.
44 + runtimeMode: "approval-required",
45 }).pipe(
46 Effect.provideService(SecureRandom.SecureRandom, random),
47 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, commandSpawner),
48 );
49
50 + yield* runtime.handleRequestPermission(() =>
51 + Effect.succeed({ outcome: { outcome: "cancelled" as const } }),
52 + );
53 +
54 yield* runtime.handleSessionUpdate((notification) => {
55 const update = notification.update;
56 if (update.sessionUpdate !== "agent_message_chunk") {