@thegitai/cli 1.0.0-preview.63 → 1.0.0-preview.64
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/dist/src/api/http.js +8 -1
- package/dist/src/install-id.js +32 -0
- package/package.json +6 -6
package/dist/src/api/http.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { DEFAULT_THEGITAI_HOST } from './default-host.js';
|
|
3
|
+
import { getInstallId } from '../install-id.js';
|
|
3
4
|
export const TRACE_ID_HEADER = 'x-thegitai-trace-id';
|
|
4
5
|
export const CLIENT_HEADER = 'x-thegitai-client';
|
|
5
6
|
export const CLIENT_PLATFORM_HEADER = 'x-thegitai-client-platform';
|
|
7
|
+
export const INSTALL_ID_HEADER = 'x-thegitai-install-id';
|
|
6
8
|
export class ServerApiError extends Error {
|
|
7
9
|
status;
|
|
8
10
|
traceId;
|
|
@@ -21,12 +23,14 @@ export function createTraceId() {
|
|
|
21
23
|
return `tr_${randomUUID().replace(/-/g, '')}`;
|
|
22
24
|
}
|
|
23
25
|
export function createTraceContext(traceId = createTraceId()) {
|
|
26
|
+
const installId = getInstallId();
|
|
24
27
|
return {
|
|
25
28
|
traceId,
|
|
26
29
|
headers: {
|
|
27
30
|
[TRACE_ID_HEADER]: traceId,
|
|
28
31
|
[CLIENT_HEADER]: 'cli',
|
|
29
32
|
[CLIENT_PLATFORM_HEADER]: `${process.platform}/${process.arch}`,
|
|
33
|
+
...(installId ? { [INSTALL_ID_HEADER]: installId } : {}),
|
|
30
34
|
},
|
|
31
35
|
};
|
|
32
36
|
}
|
|
@@ -251,8 +255,11 @@ export const PLAN_REQUIRED_CODE = 'PLAN_REQUIRED';
|
|
|
251
255
|
export function isPlanRequiredError(error) {
|
|
252
256
|
return error instanceof ServerApiError && error.code === PLAN_REQUIRED_CODE;
|
|
253
257
|
}
|
|
258
|
+
const ACCOUNT_REFUSAL_CODES = new Set(['ACCOUNT_ACTIVITY_REVIEW', 'PHONE_VERIFICATION_REQUIRED']);
|
|
254
259
|
export function isTurnRefusal(error) {
|
|
255
|
-
return isPlanRequiredError(error) ||
|
|
260
|
+
return (isPlanRequiredError(error) ||
|
|
261
|
+
isQuotaExceededError(error) ||
|
|
262
|
+
(error instanceof ServerApiError && ACCOUNT_REFUSAL_CODES.has(error.code)));
|
|
256
263
|
}
|
|
257
264
|
export function isAuthenticationError(error) {
|
|
258
265
|
return error instanceof ServerApiError && error.status === 401;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { getClientStateDir } from './client-state.js';
|
|
5
|
+
const INSTALL_ID_PATTERN = /^[a-f0-9]{32}$/;
|
|
6
|
+
let cached;
|
|
7
|
+
function readInstallId(file) {
|
|
8
|
+
try {
|
|
9
|
+
const value = readFileSync(file, 'utf8').trim();
|
|
10
|
+
return INSTALL_ID_PATTERN.test(value) ? value : null;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function getInstallId(env = process.env) {
|
|
17
|
+
if (cached !== undefined)
|
|
18
|
+
return cached;
|
|
19
|
+
const file = path.join(getClientStateDir(env), 'install-id');
|
|
20
|
+
const existing = readInstallId(file);
|
|
21
|
+
if (existing)
|
|
22
|
+
return (cached = existing);
|
|
23
|
+
try {
|
|
24
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
25
|
+
const id = randomBytes(16).toString('hex');
|
|
26
|
+
writeFileSync(file, `${id}\n`, { mode: 0o600, flag: 'wx' });
|
|
27
|
+
return (cached = id);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return (cached = readInstallId(file));
|
|
31
|
+
}
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegitai/cli",
|
|
3
|
-
"version": "1.0.0-preview.
|
|
3
|
+
"version": "1.0.0-preview.64",
|
|
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.0-preview.
|
|
49
|
-
"@thegitai/tui-darwin-x64": "1.0.0-preview.
|
|
50
|
-
"@thegitai/tui-linux-arm64": "1.0.0-preview.
|
|
51
|
-
"@thegitai/tui-linux-x64": "1.0.0-preview.
|
|
52
|
-
"@thegitai/tui-win32-x64": "1.0.0-preview.
|
|
48
|
+
"@thegitai/tui-darwin-arm64": "1.0.0-preview.64",
|
|
49
|
+
"@thegitai/tui-darwin-x64": "1.0.0-preview.64",
|
|
50
|
+
"@thegitai/tui-linux-arm64": "1.0.0-preview.64",
|
|
51
|
+
"@thegitai/tui-linux-x64": "1.0.0-preview.64",
|
|
52
|
+
"@thegitai/tui-win32-x64": "1.0.0-preview.64",
|
|
53
53
|
"@vscode/ripgrep": "1.18.0"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|