@thegitai/cli 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,12 @@
1
- # TheGitAI - AI coding agent for your terminal
1
+ # TheGitAI - AI coding agent
2
2
 
3
- TheGitAI is an AI coding agent that carries a task the whole way in your
4
- terminal: it investigates your repository, changes code across files, runs your
5
- real project, and checks the result against your own tests before handing it
6
- back. Every edit it makes can be undone without touching yours.
3
+ TheGitAI is an AI coding agent that finishes the job: it changes your code,
4
+ runs and tests it, and can use your signed-in Chrome and the apps on your
5
+ computer to check the result. Every edit it makes can be undone without
6
+ touching yours.
7
+
8
+ This package is the CLI. The same agent is also available as a
9
+ [desktop app](https://thegit.ai/desktop), with the same account and plan.
7
10
 
8
11
  - **Your repository and shell** - literal, regex and natural-language code
9
12
  search, multi-file edits, shell commands, tests, builds and diagnostics, with
@@ -12,6 +15,9 @@ back. Every edit it makes can be undone without touching yours.
12
15
  running in the background while it reproduces a bug and reads the logs.
13
16
  - **Your signed-in Chrome** - with the TheGitAI Chrome extension it works in the
14
17
  browser you already have open, signed in as you, in its own tab group.
18
+ - **Computer Control** - it uses the apps on your computer on GNOME Wayland,
19
+ Linux Mint and macOS: in front of you, or on a screen of its own while you
20
+ keep working. [Setup guide](https://thegit.ai/docs/computer-control/overview).
15
21
  - **Skills** - teach it your team's workflows as `SKILL.md` folders. It uses one
16
22
  when a request calls for it, or when you type `/<name>`.
17
23
  - **MCP servers** - connect local or remote MCP servers with `ai mcp add`.
@@ -20,18 +26,28 @@ back. Every edit it makes can be undone without touching yours.
20
26
  - **Steering and recovery** - send corrections while it works, switch between
21
27
  Default, Bypass all permissions and Plan modes, and undo an edit, a turn or a
22
28
  file, or restore a checkpoint.
23
- - **Curated frontier models** - switch models mid-session without losing the
24
- conversation. No provider API keys to manage.
29
+ - **Curated frontier models** - models from OpenAI, Anthropic, Google, xAI and
30
+ leading Chinese labs, or Auto to pick one for each task. Switch mid-session
31
+ without losing the conversation. No provider API keys to manage.
25
32
 
26
33
  Documentation: https://thegit.ai/docs
27
34
 
35
+ Models: https://thegit.ai/models
36
+
37
+ Full manual for AI tools: https://thegit.ai/llms-full.txt
38
+
39
+ Demos: [Desktop app](https://youtu.be/hQ-K_VFlMrM),
40
+ [Browser Control](https://youtu.be/yFbGC5r9WbY),
41
+ [Computer Control](https://youtu.be/2K3klt4DNYc)
42
+
28
43
  ## Install
29
44
 
30
45
  ```bash
31
46
  npm i -g @thegitai/cli
32
47
  ```
33
48
 
34
- Supports Node.js 22 and newer. Node.js 24 is recommended.
49
+ Runs on macOS, Linux and Windows. Supports Node.js 22 and newer. Node.js 24 is
50
+ recommended.
35
51
 
36
52
  This installs the `ai` command. If `ai` is already taken by another command on
37
53
  your machine, `thegitai` starts the same CLI.
@@ -18,6 +18,7 @@ import { describeSessionImageStore } from '../core/session-image-store.js';
18
18
  import { autoAttachImages } from '../core/image-path-extractor.js';
19
19
  import { formatTurnFailureMarker } from '../turn-failure-marker.js';
20
20
  import { browserExtensionSeen, releaseBrowserAfterTurn } from '../browser/session-bridge.js';
21
+ import { withComputerTurn } from '../tools/computer.js';
21
22
  export class TurnCancelledError extends Error {
22
23
  name = 'TurnCancelledError';
23
24
  constructor(message = 'Turn cancelled.') {
@@ -742,7 +743,10 @@ async function runTurnStream({ openStream, config, session, input, request, reco
742
743
  }
743
744
  }
744
745
  }
745
- export async function sendServerUserMessage({ config, session, input, jobFollowUp = false, imageAttachments = [], fetchImpl = globalThis.fetch, signal, onTurnStart, onInterjectionDelivered, recoverySleep, }) {
746
+ export function sendServerUserMessage(request) {
747
+ return withComputerTurn(() => sendServerUserMessageInner(request));
748
+ }
749
+ async function sendServerUserMessageInner({ config, session, input, jobFollowUp = false, imageAttachments = [], fetchImpl = globalThis.fetch, signal, onTurnStart, onInterjectionDelivered, recoverySleep, }) {
746
750
  if (!jobFollowUp)
747
751
  session.sessionLastPromptAt = new Date().toISOString();
748
752
  const autoAttach = autoAttachImages(input, session.rootDir, imageAttachments);
@@ -3,6 +3,7 @@ import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { ensureSessionScratchDir } from './scratch-dir.js';
5
5
  import { browserExtensionSeen } from './browser/session-bridge.js';
6
+ import { computerHelperPath } from './tools/computer.js';
6
7
  const PACKAGE_MANAGER_CANDIDATES = [
7
8
  'apt',
8
9
  'apt-get',
@@ -127,5 +128,6 @@ export function collectClientEnvironment(options = {}) {
127
128
  packageManagers: detectPackageManagers(env, platform, executableExists),
128
129
  scratchDir: options.scratchDir ?? ensureSessionScratchDir(),
129
130
  browserExtensionSeen: options.browserExtensionSeen ?? browserExtensionSeen(env),
131
+ computerControl: (platform === 'linux' || platform === 'darwin') && Boolean(computerHelperPath(env)),
130
132
  };
131
133
  }
@@ -1,4 +1,4 @@
1
- import { execFileSync } from 'node:child_process';
1
+ import { execFileSync, spawn } from 'node:child_process';
2
2
  import { existsSync, readFileSync, statSync } from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { MAX_IMAGE_SIZE_BYTES, SUPPORTED_IMAGE_MIME_TYPES as SUPPORTED_MIME_TYPES, sniffImageMimeType, } from './image-limits.js';
@@ -218,43 +218,96 @@ export function readClipboardText(platform = process.platform) {
218
218
  function normalizeClipboardTextOutput(text) {
219
219
  return text.replace(/\r?\n$/, '');
220
220
  }
221
- function tryWriteClipboardCommand(cmd, args, text) {
222
- if (!whichSync(cmd))
223
- return false;
224
- try {
225
- execFileSync(cmd, args, {
226
- input: text,
227
- timeout: 2000,
228
- stdio: ['pipe', 'ignore', 'ignore'],
221
+ const CLIPBOARD_WRITE_TIMEOUT_MS = 4000;
222
+ let latestCopy = 0;
223
+ let runningWriter = null;
224
+ let copyQueue = Promise.resolve();
225
+ function runClipboardWriter(cmd, args, text) {
226
+ return new Promise((resolve, reject) => {
227
+ let settled = false;
228
+ const child = spawn(cmd, args, { stdio: ['pipe', 'ignore', 'ignore'] });
229
+ runningWriter = child;
230
+ const finish = (error) => {
231
+ if (settled)
232
+ return;
233
+ settled = true;
234
+ clearTimeout(timer);
235
+ if (runningWriter === child)
236
+ runningWriter = null;
237
+ if (error)
238
+ reject(error);
239
+ else
240
+ resolve();
241
+ };
242
+ const timer = setTimeout(() => {
243
+ child.kill();
244
+ finish(new Error(`did not finish within ${CLIPBOARD_WRITE_TIMEOUT_MS / 1000}s`));
245
+ }, CLIPBOARD_WRITE_TIMEOUT_MS);
246
+ child.on('error', (error) => finish(error));
247
+ child.on('exit', (code, signal) => {
248
+ if (code === 0)
249
+ finish();
250
+ else
251
+ finish(new Error(`exited with ${signal ?? code}`));
229
252
  });
230
- return true;
231
- }
232
- catch (error) {
233
- throw new ClipboardError(`Failed to write clipboard with ${cmd}: ${error.message}`, 'WRITE_FAILED');
234
- }
253
+ child.stdin?.on('error', () => { });
254
+ child.stdin?.end(text);
255
+ });
235
256
  }
236
- export function writeClipboardText(text, platform = process.platform) {
237
- const value = String(text ?? '');
257
+ function clipboardWriters(platform) {
258
+ if (platform === 'darwin')
259
+ return [['pbcopy', []]];
260
+ if (platform === 'win32')
261
+ return [['clip.exe', []]];
262
+ if (platform !== 'linux')
263
+ return [];
264
+ const writers = [];
265
+ if (isWayland())
266
+ writers.push(['wl-copy', []]);
267
+ writers.push(['xclip', ['-selection', 'clipboard']], ['xsel', ['--clipboard', '--input']]);
268
+ return writers;
269
+ }
270
+ function missingClipboardTool(platform) {
238
271
  if (platform === 'darwin') {
239
- if (tryWriteClipboardCommand('pbcopy', [], value))
240
- return;
241
- throw new ClipboardError('pbcopy is required to copy text on macOS.', 'NO_TOOL');
272
+ return new ClipboardError('pbcopy is required to copy text on macOS.', 'NO_TOOL');
242
273
  }
243
274
  if (platform === 'win32') {
244
- if (tryWriteClipboardCommand('clip.exe', [], value))
245
- return;
246
- throw new ClipboardError('clip.exe is required to copy text on Windows.', 'NO_TOOL');
275
+ return new ClipboardError('clip.exe is required to copy text on Windows.', 'NO_TOOL');
247
276
  }
248
277
  if (platform === 'linux') {
249
- if (isWayland() && tryWriteClipboardCommand('wl-copy', [], value))
250
- return;
251
- if (tryWriteClipboardCommand('xclip', ['-selection', 'clipboard'], value))
278
+ return new ClipboardError('wl-copy, xclip, or xsel is required to copy text. Install wl-clipboard, xclip, or xsel.', 'NO_TOOL');
279
+ }
280
+ return new ClipboardError(`Clipboard text copy is not supported on ${platform}.`, 'NO_TOOL');
281
+ }
282
+ export function writeClipboardText(text, platform = process.platform) {
283
+ const copy = ++latestCopy;
284
+ runningWriter?.kill();
285
+ const result = copyQueue.then(() => writeLatestCopy(String(text ?? ''), platform, copy));
286
+ copyQueue = result.catch(() => { });
287
+ return result;
288
+ }
289
+ async function writeLatestCopy(value, platform, copy) {
290
+ if (copy !== latestCopy)
291
+ return;
292
+ const writers = clipboardWriters(platform).filter(([cmd]) => whichSync(cmd));
293
+ if (!writers.length)
294
+ throw missingClipboardTool(platform);
295
+ const attempts = writers.length === 1 ? [writers[0], writers[0]] : writers;
296
+ const failures = [];
297
+ for (const [cmd, args] of attempts) {
298
+ if (copy !== latestCopy)
252
299
  return;
253
- if (tryWriteClipboardCommand('xsel', ['--clipboard', '--input'], value))
300
+ try {
301
+ await runClipboardWriter(cmd, args, value);
254
302
  return;
255
- throw new ClipboardError('wl-copy, xclip, or xsel is required to copy text. Install wl-clipboard, xclip, or xsel.', 'NO_TOOL');
303
+ }
304
+ catch (error) {
305
+ failures.push(`${cmd} ${error.message}`);
306
+ }
256
307
  }
257
- throw new ClipboardError(`Clipboard text copy is not supported on ${platform}.`, 'NO_TOOL');
308
+ if (copy !== latestCopy)
309
+ return;
310
+ throw new ClipboardError(`Failed to write clipboard: ${failures.join('; ')}`, 'WRITE_FAILED');
258
311
  }
259
312
  export function loadImageFromFile(filePath) {
260
313
  const resolved = path.resolve(filePath);
@@ -147,7 +147,7 @@ const HELP_MARKDOWN = [
147
147
  '- `/<skill> [what to do]` - run a skill yourself. Skills show up in the',
148
148
  ' command picker, and the agent also loads a matching skill on its own',
149
149
  '- `/about` - show version and platform info',
150
- '- `/report` - file a bug privately through the TheGitAI website in your',
150
+ '- `/report` - report a bug or request a feature privately through the TheGitAI website in your',
151
151
  ' browser (sign in with your existing account)',
152
152
  '- `/usage` - show account usage percentage and reset times',
153
153
  '- `/model` - ↑/↓ picks a model, ←/→ adjusts effort; Enter saves for this project, Esc cancels',
@@ -192,6 +192,11 @@ const HELP_MARKDOWN = [
192
192
  ' command and keeps the password masked and local.',
193
193
  '- `-y` / `--yes` at startup auto-approves every shell command and file',
194
194
  ' edit for the whole session - use with care.',
195
+ '- Using desktop apps (GNOME or Linux Mint, preview) always asks first, even in',
196
+ ' Bypass all permissions mode: in the background, on a screen of its own',
197
+ ' you watch in a small window while you keep your mouse and keyboard, or on',
198
+ ' your screen, where Esc takes over. The answer lasts for the task, or for',
199
+ ' the session if you choose that.',
195
200
  '- Long-running commands (e.g. dev servers) can run as managed background',
196
201
  ' jobs after the same approval as any other command. Background output',
197
202
  ' stays quiet once the model has responded; the footer shows only a compact',
@@ -1,5 +1,5 @@
1
1
  import { getUnquotedShellText } from './agent-mode.js';
2
- export const PERMISSION_BUCKETS = ['create', 'edit', 'delete', 'run', 'browse', 'mcp'];
2
+ export const PERMISSION_BUCKETS = ['create', 'edit', 'delete', 'run', 'browse', 'mcp', 'computer'];
3
3
  export function createSessionGrants() {
4
4
  return { buckets: [], commandPrefixes: [], origins: [] };
5
5
  }
@@ -14,6 +14,8 @@ export function bucketActionLabel(bucket) {
14
14
  return 'act on any website';
15
15
  if (bucket === 'mcp')
16
16
  return 'use MCP tools';
17
+ if (bucket === 'computer')
18
+ return 'use apps on this computer';
17
19
  return 'run commands';
18
20
  }
19
21
  export function originForUrl(url) {
@@ -3,6 +3,7 @@ import { normalizeAgentMode, } from './agent-mode.js';
3
3
  import { createSessionGrants, } from './permissions.js';
4
4
  import { createSessionSafetyState, } from './session-safety.js';
5
5
  import { closeBrowserBridge } from './browser/session-bridge.js';
6
+ import { disconnectComputerHelper } from './tools/computer.js';
6
7
  import { clampInteger } from './utils.js';
7
8
  const DEFAULT_MAX_TOOL_STEPS = 32;
8
9
  function defaultStatus(message) {
@@ -103,6 +104,7 @@ export function clearConversation(session) {
103
104
  }
104
105
  export async function disposeSession(session) {
105
106
  closeBrowserBridge();
107
+ disconnectComputerHelper();
106
108
  await session.mcp?.close();
107
109
  }
108
110
  export function switchModel(session, modelId) {
@@ -37,6 +37,9 @@ function toolCallSummary(call) {
37
37
  return '';
38
38
  return `${todos.length} item${todos.length === 1 ? '' : 's'}`;
39
39
  }
40
+ if (call.name.startsWith('computer_')) {
41
+ return String(args.title ?? args.app ?? '').trim();
42
+ }
40
43
  const filePath = getEditToolFilePath(call);
41
44
  if (filePath)
42
45
  return filePath;
@@ -250,6 +253,7 @@ export async function executeLocalToolCall(session, call, diagnosticsPlan) {
250
253
  ? captureMutationBaseline(session.rootDir)
251
254
  : null;
252
255
  const context = {
256
+ signal: session.turnAbortSignal,
253
257
  rootDir: session.rootDir,
254
258
  sessionId: session.sessionId,
255
259
  autoYes: session.autoYes,
@@ -0,0 +1,274 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { spawn } from 'node:child_process';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import readline from 'node:readline';
6
+ import { storeSessionImageBytes } from '../core/session-image-store.js';
7
+ import { scopedSessionId } from '../session-context.js';
8
+ export const COMPUTER_OPERATIONS = [
9
+ 'list_apps',
10
+ 'open_app',
11
+ 'get_app_state',
12
+ 'click',
13
+ 'perform_secondary_action',
14
+ 'set_value',
15
+ 'type_text',
16
+ 'press_key',
17
+ 'scroll',
18
+ 'drag',
19
+ 'zoom',
20
+ 'hover',
21
+ 'move_window',
22
+ ];
23
+ const CALL_TIMEOUT_MS = 90_000;
24
+ const TYPE_MS_PER_CHARACTER = 20;
25
+ let helper = null;
26
+ const activeTurns = new Set();
27
+ const currentTurn = new AsyncLocalStorage();
28
+ const computerUsers = new Set();
29
+ const screenHolders = new Set();
30
+ function defaultHelperPath(env) {
31
+ const home = env.HOME?.trim();
32
+ const dataHome = env.XDG_DATA_HOME?.trim() || (home ? path.join(home, '.local', 'share') : '');
33
+ return dataHome ? path.join(dataHome, 'thegitai', 'computer', 'helper') : null;
34
+ }
35
+ export function computerHelperPath(env = process.env) {
36
+ const candidate = String(env.THEGITAI_COMPUTER_HELPER ?? '').trim() || defaultHelperPath(env);
37
+ if (!candidate)
38
+ return null;
39
+ try {
40
+ fs.accessSync(candidate, fs.constants.X_OK);
41
+ return candidate;
42
+ }
43
+ catch {
44
+ return null;
45
+ }
46
+ }
47
+ function startHelper(helperPath, env) {
48
+ const proc = spawn(helperPath, [], { stdio: ['pipe', 'pipe', 'ignore'], env });
49
+ const state = { proc, pending: new Map(), nextId: 1, inUse: false, backgroundUsed: false, path: helperPath, env };
50
+ readline.createInterface({ input: proc.stdout }).on('line', (line) => {
51
+ let message;
52
+ try {
53
+ message = JSON.parse(line);
54
+ }
55
+ catch {
56
+ return;
57
+ }
58
+ const waiting = state.pending.get(Number(message?.id));
59
+ if (!waiting)
60
+ return;
61
+ state.pending.delete(Number(message.id));
62
+ clearTimeout(waiting.timer);
63
+ waiting.resolve(message);
64
+ });
65
+ const fail = (reason) => {
66
+ for (const [id, waiting] of state.pending) {
67
+ clearTimeout(waiting.timer);
68
+ waiting.resolve({ id, ok: false, error: reason });
69
+ }
70
+ state.pending.clear();
71
+ if (helper === state)
72
+ helper = null;
73
+ };
74
+ proc.on('exit', (code) => fail(`The desktop helper stopped (exit ${code}).`));
75
+ proc.on('error', (error) => fail(`The desktop helper could not start: ${error.message}`));
76
+ return state;
77
+ }
78
+ function send(helperPath, env, request, signal) {
79
+ if (!helper)
80
+ helper = startHelper(helperPath, env);
81
+ const state = helper;
82
+ if (request.op !== 'end')
83
+ state.inUse = true;
84
+ if (request.desktop === 'background' && request.op !== 'begin')
85
+ state.backgroundUsed = true;
86
+ const id = state.nextId++;
87
+ const owner = currentTurn.getStore();
88
+ const stop = () => {
89
+ if (!state.pending.has(id) || helper !== state)
90
+ return false;
91
+ if ([...computerUsers].some((user) => user !== owner))
92
+ return false;
93
+ state.inUse = false;
94
+ state.proc.stdin.write(`${JSON.stringify({ op: 'end', id: state.nextId++ })}\n`);
95
+ return true;
96
+ };
97
+ const timeoutMs = CALL_TIMEOUT_MS +
98
+ (request.op === 'type_text' ? String(request.text ?? '').length * TYPE_MS_PER_CHARACTER : 0);
99
+ return new Promise((resolve) => {
100
+ const timer = setTimeout(() => {
101
+ const stopped = stop();
102
+ state.pending.delete(id);
103
+ const seconds = Math.round(timeoutMs / 1000);
104
+ resolve({
105
+ id,
106
+ ok: false,
107
+ error: `The desktop helper did not answer within ${seconds}s${stopped ? ', so the action was stopped' : ''}.`,
108
+ });
109
+ }, timeoutMs);
110
+ state.pending.set(id, { resolve, timer });
111
+ state.proc.stdin.write(`${JSON.stringify({ ...request, id })}\n`);
112
+ signal?.addEventListener('abort', stop, { once: true });
113
+ }).finally(() => signal?.removeEventListener('abort', stop));
114
+ }
115
+ const taskChoices = new Map();
116
+ const pendingChoices = new Map();
117
+ function conversation() {
118
+ return scopedSessionId() ?? '';
119
+ }
120
+ function promptBody() {
121
+ const background = process.platform === 'darwin'
122
+ ? 'In the background, it works on a virtual display in your login session. Adding the display can briefly move your pointer before restoring it. Targeted input is experimental: some apps can take focus or ignore gestures. Hover requires control on your screen. You can move the same running window to your desktop afterward. '
123
+ : 'In the background, it works on a screen of its own with its own mouse and keyboard, so you keep yours. ';
124
+ return background +
125
+ 'You can watch it in a small window.\n' +
126
+ "On your screen, it moves your pointer and types until it's done. Press Esc anytime to take over.";
127
+ }
128
+ async function askForDesktop(context, key) {
129
+ if (!context.requestPermission)
130
+ return null;
131
+ const decision = await context.requestPermission({
132
+ bucket: 'computer',
133
+ alwaysAsk: true,
134
+ title: 'TheGitAI wants to use apps on this computer',
135
+ body: promptBody(),
136
+ options: [
137
+ { label: 'Allow in the background', decision: { kind: 'computer', desktop: 'background', session: false } },
138
+ { label: 'Allow on my screen', decision: { kind: 'computer', desktop: 'screen', session: false } },
139
+ {
140
+ label: 'Allow in the background for this session',
141
+ decision: { kind: 'computer', desktop: 'background', session: true },
142
+ },
143
+ { label: 'Allow on my screen for this session', decision: { kind: 'computer', desktop: 'screen', session: true } },
144
+ { label: 'Deny', decision: { kind: 'deny' } },
145
+ ],
146
+ });
147
+ if (decision.kind !== 'computer') {
148
+ taskChoices.set(key, 'denied');
149
+ return null;
150
+ }
151
+ if (decision.session && context.grants)
152
+ context.grants.computer = decision.desktop;
153
+ taskChoices.set(key, decision.desktop);
154
+ return decision.desktop;
155
+ }
156
+ function chooseDesktop(context) {
157
+ const remembered = context.grants?.computer;
158
+ if (remembered)
159
+ return Promise.resolve(remembered);
160
+ const key = conversation();
161
+ const choice = taskChoices.get(key);
162
+ if (choice === 'denied')
163
+ return Promise.resolve(null);
164
+ if (choice)
165
+ return Promise.resolve(choice);
166
+ let pending = pendingChoices.get(key);
167
+ if (!pending) {
168
+ pending = askForDesktop(context, key).finally(() => pendingChoices.delete(key));
169
+ pendingChoices.set(key, pending);
170
+ }
171
+ return pending;
172
+ }
173
+ export async function withComputerTurn(run) {
174
+ const token = Symbol();
175
+ const key = conversation();
176
+ activeTurns.add(token);
177
+ try {
178
+ const state = helper;
179
+ if (activeTurns.size === 1 && state?.backgroundUsed) {
180
+ const response = await send(state.path, state.env, { op: 'begin', desktop: 'background' });
181
+ if (response?.ok)
182
+ screenHolders.add(token);
183
+ else
184
+ state.backgroundUsed = false;
185
+ }
186
+ return await currentTurn.run(token, run);
187
+ }
188
+ finally {
189
+ activeTurns.delete(token);
190
+ computerUsers.delete(token);
191
+ screenHolders.delete(token);
192
+ taskChoices.delete(key);
193
+ if (screenHolders.size === 0)
194
+ await releaseComputerAfterTurn();
195
+ }
196
+ }
197
+ async function releaseComputerAfterTurn() {
198
+ if (!helper?.inUse)
199
+ return;
200
+ helper.inUse = false;
201
+ await send(helper.path, helper.env, { op: 'end' });
202
+ }
203
+ export function disconnectComputerHelper() {
204
+ const state = helper;
205
+ helper = null;
206
+ if (!state)
207
+ return;
208
+ for (const [id, waiting] of state.pending) {
209
+ clearTimeout(waiting.timer);
210
+ waiting.resolve({ id, ok: false, error: 'The CLI session closed.' });
211
+ }
212
+ state.pending.clear();
213
+ state.proc.stdin?.end();
214
+ }
215
+ export function computerTool(operation) {
216
+ return async (context, args) => {
217
+ const env = context.env ?? process.env;
218
+ const helperPath = computerHelperPath(env);
219
+ if (!helperPath) {
220
+ return {
221
+ ok: false,
222
+ error: 'Desktop control is not set up on this machine.',
223
+ failureCategory: 'policy_blocked',
224
+ };
225
+ }
226
+ const desktop = await chooseDesktop(context);
227
+ context.signal?.throwIfAborted();
228
+ if (!desktop) {
229
+ return {
230
+ ok: false,
231
+ error: context.requestPermission
232
+ ? 'The user did not allow TheGitAI to use apps on this computer for this request. Do not use the computer tools again for it; do it another way or tell the user.'
233
+ : 'Using apps on this computer needs the user to allow it, and they cannot be asked here.',
234
+ failureCategory: 'user_declined',
235
+ };
236
+ }
237
+ const title = String(args.title ?? '').trim();
238
+ context.onStatus(title || operation.replace(/_/g, ' '));
239
+ const turn = currentTurn.getStore();
240
+ if (turn) {
241
+ computerUsers.add(turn);
242
+ screenHolders.add(turn);
243
+ }
244
+ const reply = await send(helperPath, env, { ...args, op: operation, desktop }, context.signal);
245
+ if (!reply?.ok) {
246
+ return {
247
+ ok: false,
248
+ error: String(reply?.error ?? 'The desktop helper failed.'),
249
+ failureCategory: reply?.cancelled ? 'user_declined' : 'command_failed',
250
+ desktop,
251
+ };
252
+ }
253
+ const { png, width, height, text } = reply;
254
+ const result = { ok: true, state: String(text ?? ''), desktop };
255
+ if (typeof png === 'string') {
256
+ result.screenshot = { width, height };
257
+ result.imageBytes = { base64Data: png, mimeType: 'image/png' };
258
+ if (context.sessionId) {
259
+ try {
260
+ const stored = storeSessionImageBytes({
261
+ sessionId: context.sessionId,
262
+ base64Data: png,
263
+ mimeType: 'image/png',
264
+ env: context.env,
265
+ });
266
+ result.imageBytes.cachePath = stored.cachePath;
267
+ result.imageBytes.index = stored.index;
268
+ }
269
+ catch { }
270
+ }
271
+ }
272
+ return result;
273
+ };
274
+ }
@@ -1,5 +1,6 @@
1
1
  import { browserBatch, browserComputer, browserConsole, browserDownloads, browserEvaluate, browserFileUpload, browserFind, browserFormInput, browserGateway, browserGetPageText, browserNavigate, browserNetwork, browserReadPage, browserResize, browserTabClose, browserTabNew, browserTabs, } from './browser.js';
2
2
  import { shellJobOutput } from './shell-job-output.js';
3
+ import { COMPUTER_OPERATIONS, computerTool } from './computer.js';
3
4
  import { deleteFile } from './delete-file.js';
4
5
  import { getDiagnostics } from './get-diagnostics.js';
5
6
  import { grepCode } from './grep-code.js';
@@ -64,6 +65,7 @@ export const TOOL_MAP = {
64
65
  browser_file_upload: browserFileUpload,
65
66
  browser_downloads: browserDownloads,
66
67
  browser_batch: browserBatch,
68
+ ...Object.fromEntries(COMPUTER_OPERATIONS.map((operation) => [`computer_${operation}`, computerTool(operation)])),
67
69
  generate_image: (_context, args) => {
68
70
  if (!String(args.base64Data ?? '').trim()) {
69
71
  return {
@@ -97,14 +97,14 @@ export function buildReportTranscriptEntries(openedUrl) {
97
97
  return openedUrl
98
98
  ? [
99
99
  {
100
- body: `Opening the private bug report form in your browser. If nothing opened, visit:\n\n${REPORT_ISSUE_URL}\n`,
100
+ body: `Opening the private form for bugs and feature requests in your browser. If nothing opened, visit:\n\n${REPORT_ISSUE_URL}\n`,
101
101
  kind: 'system',
102
102
  title: 'Report',
103
103
  },
104
104
  ]
105
105
  : [
106
106
  {
107
- body: `Could not open a browser. Report the bug manually at:\n\n${REPORT_ISSUE_URL}\n`,
107
+ body: `Could not open a browser. Report the bug or request the feature at:\n\n${REPORT_ISSUE_URL}\n`,
108
108
  kind: 'error',
109
109
  title: 'Report',
110
110
  },
@@ -1688,22 +1688,10 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
1688
1688
  });
1689
1689
  };
1690
1690
  const handleAppSelectionCopy = (text) => {
1691
- try {
1692
- writeClipboardText(text);
1693
- showTransientStatus('Copied selection');
1694
- }
1695
- catch (error) {
1696
- appendError(`Selection copy failed: ${error.message}`);
1697
- }
1691
+ void writeClipboardText(text).then(() => showTransientStatus('Copied selection'), (error) => appendError(`Selection copy failed: ${error.message}`));
1698
1692
  };
1699
1693
  const handleLinkCopy = (url) => {
1700
- try {
1701
- writeClipboardText(url);
1702
- showTransientStatus('Copied link');
1703
- }
1704
- catch (error) {
1705
- appendError(`Link copy failed: ${error.message}`);
1706
- }
1694
+ void writeClipboardText(url).then(() => showTransientStatus('Copied link'), (error) => appendError(`Link copy failed: ${error.message}`));
1707
1695
  };
1708
1696
  const handleLinkOpen = async (url) => {
1709
1697
  try {
@@ -3366,7 +3354,7 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3366
3354
  const deny = { kind: 'deny' };
3367
3355
  if (exiting)
3368
3356
  return deny;
3369
- if (sessionAutoYes)
3357
+ if (sessionAutoYes && !request.alwaysAsk)
3370
3358
  return { kind: 'once' };
3371
3359
  const decision = await openApprovalPrompt(request, session.turnAbortSignal);
3372
3360
  if (decision.kind === 'always-bucket') {
@@ -3397,6 +3385,24 @@ export async function runClientInteractive({ appendPromptHistory, authConfig, de
3397
3385
  title: 'Approvals',
3398
3386
  });
3399
3387
  }
3388
+ else if (decision.kind === 'computer' && decision.session) {
3389
+ appendTurnAwareEntry({
3390
+ body: decision.desktop === 'background'
3391
+ ? 'Allowed for the rest of this session: using apps in the background.'
3392
+ : 'Allowed for the rest of this session: using apps on your screen.',
3393
+ kind: 'system',
3394
+ title: 'Approvals',
3395
+ });
3396
+ }
3397
+ else if (decision.kind === 'computer') {
3398
+ appendTurnAwareEntry({
3399
+ body: decision.desktop === 'background'
3400
+ ? 'Allowed for this request: using apps in the background.'
3401
+ : 'Allowed for this request: using apps on your screen.',
3402
+ kind: 'system',
3403
+ title: 'Approvals',
3404
+ });
3405
+ }
3400
3406
  return decision;
3401
3407
  };
3402
3408
  const shellInputHandlers = {
@@ -14,7 +14,7 @@ export const SLASH_COMMANDS = [
14
14
  command: '/notify',
15
15
  description: 'Toggle desktop notifications when a turn ends (Ctrl+G)',
16
16
  },
17
- { command: '/report', description: 'Report a bug privately on the TheGitAI website' },
17
+ { command: '/report', description: 'Report a bug or request a feature privately on the TheGitAI website' },
18
18
  { command: '/about', description: 'Show version and platform info' },
19
19
  { command: '/logout', description: 'Sign out and quit' },
20
20
  { command: '/exit', description: 'Quit the current session', aliases: ['/quit'] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thegitai/cli",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "description": "TheGitAI is an agentic AI coding tool for your terminal. It reads and searches your repository, writes and edits files, runs your tests, and verifies the change before handing it back.",
5
5
  "keywords": [
6
6
  "agentic-ai",
@@ -45,11 +45,11 @@
45
45
  "@lydell/node-pty-linux-x64": "1.1.0",
46
46
  "@lydell/node-pty-win32-arm64": "1.1.0",
47
47
  "@lydell/node-pty-win32-x64": "1.1.0",
48
- "@thegitai/tui-darwin-arm64": "1.0.4",
49
- "@thegitai/tui-darwin-x64": "1.0.4",
50
- "@thegitai/tui-linux-arm64": "1.0.4",
51
- "@thegitai/tui-linux-x64": "1.0.4",
52
- "@thegitai/tui-win32-x64": "1.0.4",
48
+ "@thegitai/tui-darwin-arm64": "1.1.1",
49
+ "@thegitai/tui-darwin-x64": "1.1.1",
50
+ "@thegitai/tui-linux-arm64": "1.1.1",
51
+ "@thegitai/tui-linux-x64": "1.1.1",
52
+ "@thegitai/tui-win32-x64": "1.1.1",
53
53
  "@vscode/ripgrep": "1.18.0"
54
54
  },
55
55
  "repository": {