@agentrix/cli 0.0.2
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 +182 -0
- package/bin/agentrix.mjs +35 -0
- package/dist/index.cjs +16774 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +16754 -0
- package/dist/lib.cjs +19 -0
- package/dist/lib.d.cts +76 -0
- package/dist/lib.d.mts +76 -0
- package/dist/lib.mjs +11 -0
- package/dist/logger-CVOTByt5.cjs +497 -0
- package/dist/logger-f691UxTg.mjs +487 -0
- package/package.json +125 -0
- package/scripts/unpack-tools.cjs +163 -0
- package/tools/archives/difftastic-LICENSE +21 -0
- package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
- package/tools/archives/ripgrep-LICENSE +3 -0
- package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
- package/tools/licenses/difftastic-LICENSE +21 -0
- package/tools/licenses/ripgrep-LICENSE +3 -0
- package/tools/unpacked/difft +0 -0
- package/tools/unpacked/rg +0 -0
- package/tools/unpacked/ripgrep.node +0 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import winston from 'winston';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { existsSync, writeFileSync, constants, readFileSync, unlinkSync, mkdirSync } from 'node:fs';
|
|
6
|
+
import { readFile, writeFile, unlink, open } from 'node:fs/promises';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { setAgentContext, createKeyPair } from '@agentrix/shared';
|
|
9
|
+
import { dirname, resolve } from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
|
|
12
|
+
var name = "@agentrix/cli";
|
|
13
|
+
var version = "0.0.2";
|
|
14
|
+
var description = "Mobile and Web client for Claude Code and Codex";
|
|
15
|
+
var author = "agentrix.xmz.ai";
|
|
16
|
+
var type = "module";
|
|
17
|
+
var homepage = "https://github.com/xmz-ai/agentrix-cli";
|
|
18
|
+
var bugs = "https://github.com/xmz-ai/agentrix-cli/issues";
|
|
19
|
+
var repository = "xmz-ai/agentrix-cli";
|
|
20
|
+
var bin = {
|
|
21
|
+
agentrix: "./bin/agentrix.mjs"
|
|
22
|
+
};
|
|
23
|
+
var main = "./dist/index.cjs";
|
|
24
|
+
var module$1 = "./dist/index.mjs";
|
|
25
|
+
var types = "./dist/index.d.cts";
|
|
26
|
+
var exports$1 = {
|
|
27
|
+
".": {
|
|
28
|
+
require: {
|
|
29
|
+
types: "./dist/index.d.cts",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"import": {
|
|
33
|
+
types: "./dist/index.d.mts",
|
|
34
|
+
"default": "./dist/index.mjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"./lib": {
|
|
38
|
+
require: {
|
|
39
|
+
types: "./dist/lib.d.cts",
|
|
40
|
+
"default": "./dist/lib.cjs"
|
|
41
|
+
},
|
|
42
|
+
"import": {
|
|
43
|
+
types: "./dist/lib.d.mts",
|
|
44
|
+
"default": "./dist/lib.mjs"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var files = [
|
|
49
|
+
"dist",
|
|
50
|
+
"bin",
|
|
51
|
+
"scripts",
|
|
52
|
+
"tools",
|
|
53
|
+
"package.json"
|
|
54
|
+
];
|
|
55
|
+
var scripts = {
|
|
56
|
+
"why do we need to build before running tests / dev?": "We need the binary to be built so we run daemon commands which directly run the binary",
|
|
57
|
+
typecheck: "tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true)",
|
|
58
|
+
build: "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll",
|
|
59
|
+
prod: "node --env-file=.env ./bin/agentrix.mjs",
|
|
60
|
+
test: "yarn build && tsx --env-file .env.integration-test node_modules/.bin/vitest run",
|
|
61
|
+
dev: "yarn build && tsx --env-file .env.dev src/index.ts",
|
|
62
|
+
prepublishOnly: "yarn build && yarn test",
|
|
63
|
+
release: "release-it",
|
|
64
|
+
postinstall: "node scripts/unpack-tools.cjs",
|
|
65
|
+
lint: "eslint 'src/**/*.{js,ts}' --fix"
|
|
66
|
+
};
|
|
67
|
+
var pkgroll = {
|
|
68
|
+
minify: true,
|
|
69
|
+
sourcemap: false
|
|
70
|
+
};
|
|
71
|
+
var dependencies = {
|
|
72
|
+
"@agentrix/shared": "*",
|
|
73
|
+
"@anthropic-ai/claude-agent-sdk": "^0.1.30",
|
|
74
|
+
"@anthropic-ai/claude-code": "2.0.14",
|
|
75
|
+
"@anthropic-ai/sdk": "0.65.0",
|
|
76
|
+
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
77
|
+
"@openai/codex-sdk": "^0.58.0",
|
|
78
|
+
"@stablelib/base64": "^2.0.1",
|
|
79
|
+
"@stablelib/hex": "^2.0.1",
|
|
80
|
+
"@types/cross-spawn": "^6.0.6",
|
|
81
|
+
"@types/http-proxy": "^1.17.16",
|
|
82
|
+
"@types/ps-list": "^6.2.1",
|
|
83
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
84
|
+
"@types/react": "^19.1.9",
|
|
85
|
+
"@types/tmp": "^0.2.6",
|
|
86
|
+
"@types/yargs": "^17.0.33",
|
|
87
|
+
axios: "^1.10.0",
|
|
88
|
+
chalk: "^5.4.1",
|
|
89
|
+
"cross-spawn": "^7.0.6",
|
|
90
|
+
"expo-server-sdk": "^3.15.0",
|
|
91
|
+
fastify: "^5.5.0",
|
|
92
|
+
"fastify-type-provider-zod": "4.0.2",
|
|
93
|
+
"http-proxy": "^1.18.1",
|
|
94
|
+
"http-proxy-middleware": "^3.0.5",
|
|
95
|
+
ink: "^6.1.0",
|
|
96
|
+
open: "^10.2.0",
|
|
97
|
+
"ps-list": "^8.1.1",
|
|
98
|
+
"qrcode-terminal": "^0.12.0",
|
|
99
|
+
react: "^19.1.1",
|
|
100
|
+
"simple-git": "^3.30.0",
|
|
101
|
+
"socket.io-client": "^4.8.1",
|
|
102
|
+
tar: "^7.4.3",
|
|
103
|
+
tmp: "^0.2.5",
|
|
104
|
+
tweetnacl: "^1.0.3",
|
|
105
|
+
winston: "^3.18.3",
|
|
106
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
107
|
+
yargs: "^17.7.2",
|
|
108
|
+
zod: "^3.23.8"
|
|
109
|
+
};
|
|
110
|
+
var devDependencies = {
|
|
111
|
+
"@eslint/compat": "^1",
|
|
112
|
+
"@types/mime-types": "^3.0.1",
|
|
113
|
+
"@types/node": ">=20",
|
|
114
|
+
"cross-env": "^10.0.0",
|
|
115
|
+
dotenv: "^16.6.1",
|
|
116
|
+
eslint: "^9",
|
|
117
|
+
"eslint-config-prettier": "^10",
|
|
118
|
+
pkgroll: "^2.14.2",
|
|
119
|
+
"release-it": "^19.0.4",
|
|
120
|
+
shx: "^0.3.3",
|
|
121
|
+
"ts-node": "^10",
|
|
122
|
+
tsx: "^4.20.3",
|
|
123
|
+
typescript: "^5",
|
|
124
|
+
vitest: "^3.2.4"
|
|
125
|
+
};
|
|
126
|
+
var resolutions = {
|
|
127
|
+
"whatwg-url": "14.2.0",
|
|
128
|
+
"parse-path": "7.0.3",
|
|
129
|
+
"@types/parse-path": "7.0.3"
|
|
130
|
+
};
|
|
131
|
+
var publishConfig = {
|
|
132
|
+
registry: "https://registry.npmjs.org"
|
|
133
|
+
};
|
|
134
|
+
var packageManager = "yarn@1.22.22";
|
|
135
|
+
var packageJson = {
|
|
136
|
+
name: name,
|
|
137
|
+
version: version,
|
|
138
|
+
description: description,
|
|
139
|
+
author: author,
|
|
140
|
+
type: type,
|
|
141
|
+
homepage: homepage,
|
|
142
|
+
bugs: bugs,
|
|
143
|
+
repository: repository,
|
|
144
|
+
bin: bin,
|
|
145
|
+
main: main,
|
|
146
|
+
module: module$1,
|
|
147
|
+
types: types,
|
|
148
|
+
exports: exports$1,
|
|
149
|
+
files: files,
|
|
150
|
+
scripts: scripts,
|
|
151
|
+
pkgroll: pkgroll,
|
|
152
|
+
dependencies: dependencies,
|
|
153
|
+
devDependencies: devDependencies,
|
|
154
|
+
resolutions: resolutions,
|
|
155
|
+
publishConfig: publishConfig,
|
|
156
|
+
packageManager: packageManager
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
160
|
+
function projectPath() {
|
|
161
|
+
const path = resolve(__dirname$1, "..");
|
|
162
|
+
return path;
|
|
163
|
+
}
|
|
164
|
+
class Machine {
|
|
165
|
+
serverUrl;
|
|
166
|
+
webappUrl;
|
|
167
|
+
isDaemonProcess;
|
|
168
|
+
agentrixHomeDir;
|
|
169
|
+
agentrixWorkspaceHomeDir;
|
|
170
|
+
agentrixAgentsHomeDir;
|
|
171
|
+
currentCliVersion;
|
|
172
|
+
disableCaffeinate;
|
|
173
|
+
statePaths;
|
|
174
|
+
secretKey;
|
|
175
|
+
constructor() {
|
|
176
|
+
const args = process.argv.slice(2);
|
|
177
|
+
this.isDaemonProcess = args[0] === "daemon";
|
|
178
|
+
this.serverUrl = process.env.AGENTRIX_SERVER_URL || "https://agentrix.xmz.ai";
|
|
179
|
+
this.webappUrl = process.env.AGENTRIX_WEBAPP_URL || "https://agentrix.xmz.ai";
|
|
180
|
+
this.agentrixHomeDir = process.env.AGENTRIX_HOME_DIR ? process.env.AGENTRIX_HOME_DIR.replace(/^~/, os.homedir()) : join(os.homedir(), ".agentrix");
|
|
181
|
+
this.agentrixWorkspaceHomeDir = process.env.AGENTRIX_WORKSPACE_HOME_DIR ? process.env.AGENTRIX_WORKSPACE_HOME_DIR.replace(/^~/, os.homedir()) : join(this.agentrixHomeDir, "workspaces");
|
|
182
|
+
this.agentrixAgentsHomeDir = process.env.AGENTRIX_AGENTS_HOME_DIR ? process.env.AGENTRIX_AGENTS_HOME_DIR.replace(/^~/, os.homedir()) : join(this.agentrixHomeDir, "agents");
|
|
183
|
+
this.disableCaffeinate = ["true", "1", "yes"].includes(
|
|
184
|
+
(process.env.AGENTRIX_DISABLE_CAFFEINATE ?? "").toLowerCase()
|
|
185
|
+
);
|
|
186
|
+
this.currentCliVersion = packageJson.version;
|
|
187
|
+
this.ensureDir(this.agentrixHomeDir);
|
|
188
|
+
this.ensureDir(this.agentrixWorkspaceHomeDir);
|
|
189
|
+
this.ensureDir(this.agentrixAgentsHomeDir);
|
|
190
|
+
this.statePaths = {
|
|
191
|
+
rootDir: this.agentrixHomeDir,
|
|
192
|
+
logsDir: this.ensureDir(join(this.agentrixHomeDir, "logs")),
|
|
193
|
+
settingsFile: join(this.agentrixHomeDir, "settings.json"),
|
|
194
|
+
credentialsFile: join(this.agentrixHomeDir, "credentials.json"),
|
|
195
|
+
daemonStateFile: join(this.agentrixHomeDir, "daemon.state.json"),
|
|
196
|
+
daemonLockFile: join(this.agentrixHomeDir, "daemon.state.json.lock")
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
generateMachineId() {
|
|
200
|
+
return `machine-${randomUUID()}`;
|
|
201
|
+
}
|
|
202
|
+
metadata() {
|
|
203
|
+
return {
|
|
204
|
+
host: os.hostname(),
|
|
205
|
+
platform: os.platform(),
|
|
206
|
+
cliVersion: this.currentCliVersion,
|
|
207
|
+
homeDir: os.homedir(),
|
|
208
|
+
agentrixHomeDir: this.agentrixHomeDir,
|
|
209
|
+
agentrixWorkspaceHomeDir: this.agentrixWorkspaceHomeDir
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
getStatePaths() {
|
|
213
|
+
return this.statePaths;
|
|
214
|
+
}
|
|
215
|
+
async readCredentials() {
|
|
216
|
+
const paths = this.getStatePaths();
|
|
217
|
+
if (!existsSync(paths.credentialsFile)) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
const content = await readFile(paths.credentialsFile, "utf8");
|
|
222
|
+
const parsed = JSON.parse(content);
|
|
223
|
+
return {
|
|
224
|
+
secret: parsed.secret,
|
|
225
|
+
token: parsed.token,
|
|
226
|
+
machineId: parsed.machineId
|
|
227
|
+
};
|
|
228
|
+
} catch {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async writeCredentials(credentials) {
|
|
233
|
+
const paths = this.getStatePaths();
|
|
234
|
+
await writeFile(
|
|
235
|
+
paths.credentialsFile,
|
|
236
|
+
JSON.stringify(credentials, null, 2)
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
async clearCredentials() {
|
|
240
|
+
const paths = this.getStatePaths();
|
|
241
|
+
if (existsSync(paths.credentialsFile)) {
|
|
242
|
+
await unlink(paths.credentialsFile);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async readDaemonState() {
|
|
246
|
+
const paths = this.getStatePaths();
|
|
247
|
+
try {
|
|
248
|
+
if (!existsSync(paths.daemonStateFile)) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
const content = await readFile(paths.daemonStateFile, "utf-8");
|
|
252
|
+
return JSON.parse(content);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.error(`[PERSISTENCE] Daemon state file corrupted: ${paths.daemonStateFile}`, error);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
writeDaemonState(state) {
|
|
259
|
+
const paths = this.getStatePaths();
|
|
260
|
+
writeFileSync(paths.daemonStateFile, JSON.stringify(state, null, 2), "utf-8");
|
|
261
|
+
}
|
|
262
|
+
async clearDaemonState() {
|
|
263
|
+
const paths = this.getStatePaths();
|
|
264
|
+
if (existsSync(paths.daemonStateFile)) {
|
|
265
|
+
await unlink(paths.daemonStateFile);
|
|
266
|
+
}
|
|
267
|
+
if (existsSync(paths.daemonLockFile)) {
|
|
268
|
+
try {
|
|
269
|
+
await unlink(paths.daemonLockFile);
|
|
270
|
+
} catch {
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async acquireDaemonLock(maxAttempts = 5, delayIncrementMs = 200) {
|
|
275
|
+
const paths = this.getStatePaths();
|
|
276
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
277
|
+
try {
|
|
278
|
+
const handle = await open(
|
|
279
|
+
paths.daemonLockFile,
|
|
280
|
+
constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY
|
|
281
|
+
);
|
|
282
|
+
await handle.writeFile(String(process.pid));
|
|
283
|
+
return handle;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (error.code === "EEXIST") {
|
|
286
|
+
try {
|
|
287
|
+
const lockPid = readFileSync(paths.daemonLockFile, "utf-8").trim();
|
|
288
|
+
if (lockPid && !Number.isNaN(Number(lockPid))) {
|
|
289
|
+
try {
|
|
290
|
+
process.kill(Number(lockPid), 0);
|
|
291
|
+
} catch {
|
|
292
|
+
unlinkSync(paths.daemonLockFile);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
} catch {
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (attempt === maxAttempts) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
const delayMs = attempt * delayIncrementMs;
|
|
303
|
+
await new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
async releaseDaemonLock(lockHandle) {
|
|
309
|
+
const paths = this.getStatePaths();
|
|
310
|
+
try {
|
|
311
|
+
await lockHandle.close();
|
|
312
|
+
} catch {
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
if (existsSync(paths.daemonLockFile)) {
|
|
316
|
+
unlinkSync(paths.daemonLockFile);
|
|
317
|
+
}
|
|
318
|
+
} catch {
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
ensureDir(target) {
|
|
322
|
+
if (!existsSync(target)) {
|
|
323
|
+
mkdirSync(target, { recursive: true });
|
|
324
|
+
}
|
|
325
|
+
return target;
|
|
326
|
+
}
|
|
327
|
+
resolveProjectDir(cwd, userId, taskId) {
|
|
328
|
+
if (cwd) {
|
|
329
|
+
return this.ensureDir(cwd.replace(/^~/, os.homedir()));
|
|
330
|
+
}
|
|
331
|
+
const workspaceDir = join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "project");
|
|
332
|
+
return this.ensureDir(workspaceDir);
|
|
333
|
+
}
|
|
334
|
+
resolveDataDir(userId, taskId) {
|
|
335
|
+
const dataDir = join(this.agentrixWorkspaceHomeDir, "users", userId, taskId, "data");
|
|
336
|
+
return this.ensureDir(dataDir);
|
|
337
|
+
}
|
|
338
|
+
resolveAttachmentsDir(userId, taskId) {
|
|
339
|
+
const attachmentsDir = join(this.resolveDataDir(userId, taskId), "attachments");
|
|
340
|
+
return this.ensureDir(attachmentsDir);
|
|
341
|
+
}
|
|
342
|
+
resolveAgentDir(agentId) {
|
|
343
|
+
return join(this.agentrixAgentsHomeDir, agentId);
|
|
344
|
+
}
|
|
345
|
+
getInitialCommitHashPath(userId, taskId) {
|
|
346
|
+
return join(this.resolveDataDir(userId, taskId), "initial-commit-hash.txt");
|
|
347
|
+
}
|
|
348
|
+
async readInitialCommitHash(userId, taskId) {
|
|
349
|
+
const path = this.getInitialCommitHashPath(userId, taskId);
|
|
350
|
+
if (!existsSync(path)) {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
const content = await readFile(path, "utf-8");
|
|
355
|
+
return content.trim();
|
|
356
|
+
} catch {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
async writeInitialCommitHash(userId, taskId, hash) {
|
|
361
|
+
const path = this.getInitialCommitHashPath(userId, taskId);
|
|
362
|
+
await writeFile(path, hash);
|
|
363
|
+
}
|
|
364
|
+
writeTaskInput(data) {
|
|
365
|
+
const path = this.resolveDataDir(data.userId, data.taskId);
|
|
366
|
+
const inputFile = join(path, "input.json");
|
|
367
|
+
writeFileSync(inputFile, JSON.stringify(data, null, 2));
|
|
368
|
+
}
|
|
369
|
+
readTaskInput(userId, taskId) {
|
|
370
|
+
const path = this.resolveDataDir(userId, taskId);
|
|
371
|
+
const inputFile = join(path, "input.json");
|
|
372
|
+
if (!existsSync(inputFile)) {
|
|
373
|
+
throw new Error(`Task input file does not exist: ${inputFile}`);
|
|
374
|
+
}
|
|
375
|
+
const content = readFileSync(inputFile, "utf-8");
|
|
376
|
+
return JSON.parse(content);
|
|
377
|
+
}
|
|
378
|
+
async getSecretKey() {
|
|
379
|
+
if (this.secretKey) {
|
|
380
|
+
return this.secretKey;
|
|
381
|
+
}
|
|
382
|
+
const credentials = await this.readCredentials();
|
|
383
|
+
if (credentials && credentials.secret) {
|
|
384
|
+
const keyPair = await createKeyPair(credentials.secret);
|
|
385
|
+
this.secretKey = keyPair.secretKey;
|
|
386
|
+
}
|
|
387
|
+
return this.secretKey;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const machine = new Machine();
|
|
391
|
+
setAgentContext(machine);
|
|
392
|
+
|
|
393
|
+
const consoleFormat = winston.format.printf(({ level, message, timestamp, ...meta }) => {
|
|
394
|
+
const timeStr = new Date(timestamp).toLocaleTimeString("en-US", {
|
|
395
|
+
hour12: false,
|
|
396
|
+
hour: "2-digit",
|
|
397
|
+
minute: "2-digit",
|
|
398
|
+
second: "2-digit",
|
|
399
|
+
fractionalSecondDigits: 3
|
|
400
|
+
});
|
|
401
|
+
let coloredLevel = level;
|
|
402
|
+
switch (level) {
|
|
403
|
+
case "error":
|
|
404
|
+
coloredLevel = chalk.red(level.toUpperCase());
|
|
405
|
+
break;
|
|
406
|
+
case "warn":
|
|
407
|
+
coloredLevel = chalk.yellow(level.toUpperCase());
|
|
408
|
+
break;
|
|
409
|
+
case "info":
|
|
410
|
+
coloredLevel = chalk.blue(level.toUpperCase());
|
|
411
|
+
break;
|
|
412
|
+
case "debug":
|
|
413
|
+
coloredLevel = chalk.gray(level.toUpperCase());
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
const metaStr = Object.keys(meta).length > 0 ? " " + JSON.stringify(meta) : "";
|
|
417
|
+
return `[${timeStr}] ${coloredLevel}: ${message}${metaStr}`;
|
|
418
|
+
});
|
|
419
|
+
const fileFormat = winston.format.printf(({ level, message, timestamp, ...meta }) => {
|
|
420
|
+
const metaStr = Object.keys(meta).length > 0 ? " " + JSON.stringify(meta) : "";
|
|
421
|
+
return `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;
|
|
422
|
+
});
|
|
423
|
+
function createLogger(context) {
|
|
424
|
+
const logsDir = machine.getStatePaths().logsDir;
|
|
425
|
+
const level = process.env.DEBUG ? "debug" : "info";
|
|
426
|
+
if (context.type === "console-only") {
|
|
427
|
+
return winston.createLogger({
|
|
428
|
+
level,
|
|
429
|
+
format: winston.format.combine(
|
|
430
|
+
winston.format.timestamp(),
|
|
431
|
+
consoleFormat
|
|
432
|
+
),
|
|
433
|
+
transports: [
|
|
434
|
+
new winston.transports.Console()
|
|
435
|
+
]
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
const filename = context.type === "daemon" ? "daemon.log" : `task-${context.taskId}.log`;
|
|
439
|
+
const maxsize = 100 * 1024 * 1024;
|
|
440
|
+
const maxFiles = context.type === "daemon" ? 3 : 1;
|
|
441
|
+
const transports = [
|
|
442
|
+
new winston.transports.File({
|
|
443
|
+
filename,
|
|
444
|
+
dirname: logsDir,
|
|
445
|
+
zippedArchive: true,
|
|
446
|
+
maxsize,
|
|
447
|
+
maxFiles,
|
|
448
|
+
tailable: true,
|
|
449
|
+
format: winston.format.combine(
|
|
450
|
+
winston.format.timestamp(),
|
|
451
|
+
fileFormat
|
|
452
|
+
)
|
|
453
|
+
})
|
|
454
|
+
];
|
|
455
|
+
if (process.env.DEBUG) {
|
|
456
|
+
transports.push(
|
|
457
|
+
new winston.transports.Console({
|
|
458
|
+
format: winston.format.combine(
|
|
459
|
+
winston.format.timestamp(),
|
|
460
|
+
consoleFormat
|
|
461
|
+
)
|
|
462
|
+
})
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
return winston.createLogger({
|
|
466
|
+
level,
|
|
467
|
+
transports
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
let logger = createLogger({ type: "console-only" });
|
|
471
|
+
function getLogPath(context) {
|
|
472
|
+
const logsDir = machine.getStatePaths().logsDir;
|
|
473
|
+
if (context.type === "console-only") {
|
|
474
|
+
return "";
|
|
475
|
+
}
|
|
476
|
+
const filename = context.type === "daemon" ? "daemon.log" : `task-${context.taskId}.log`;
|
|
477
|
+
return join(logsDir, filename);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
var logger$1 = /*#__PURE__*/Object.freeze({
|
|
481
|
+
__proto__: null,
|
|
482
|
+
createLogger: createLogger,
|
|
483
|
+
getLogPath: getLogPath,
|
|
484
|
+
logger: logger
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
export { Machine as M, packageJson as a, logger$1 as b, createLogger as c, getLogPath as g, logger as l, machine as m, projectPath as p };
|
package/package.json
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentrix/cli",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Mobile and Web client for Claude Code and Codex",
|
|
5
|
+
"author": "agentrix.xmz.ai",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"homepage": "https://github.com/xmz-ai/agentrix-cli",
|
|
8
|
+
"bugs": "https://github.com/xmz-ai/agentrix-cli/issues",
|
|
9
|
+
"repository": "xmz-ai/agentrix-cli",
|
|
10
|
+
"bin": {
|
|
11
|
+
"agentrix": "./bin/agentrix.mjs"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./lib": {
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/lib.d.cts",
|
|
30
|
+
"default": "./dist/lib.cjs"
|
|
31
|
+
},
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./dist/lib.d.mts",
|
|
34
|
+
"default": "./dist/lib.mjs"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"bin",
|
|
41
|
+
"scripts",
|
|
42
|
+
"tools",
|
|
43
|
+
"package.json"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"why do we need to build before running tests / dev?": "We need the binary to be built so we run daemon commands which directly run the binary",
|
|
47
|
+
"typecheck": "tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true)",
|
|
48
|
+
"build": "shx rm -rf dist && npx tsc --noEmit --skipLibCheck 2>&1 | (grep -v 'node_modules/effect' | grep -v 'Symbol.dispose' || true) && pkgroll",
|
|
49
|
+
"prod": "node --env-file=.env ./bin/agentrix.mjs",
|
|
50
|
+
"test": "yarn build && tsx --env-file .env.integration-test node_modules/.bin/vitest run",
|
|
51
|
+
"dev": "yarn build && tsx --env-file .env.dev src/index.ts",
|
|
52
|
+
"prepublishOnly": "yarn build && yarn test",
|
|
53
|
+
"release": "release-it",
|
|
54
|
+
"postinstall": "node scripts/unpack-tools.cjs",
|
|
55
|
+
"lint": "eslint 'src/**/*.{js,ts}' --fix"
|
|
56
|
+
},
|
|
57
|
+
"pkgroll": {
|
|
58
|
+
"minify": true,
|
|
59
|
+
"sourcemap": false
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@agentrix/shared": "*",
|
|
63
|
+
"@anthropic-ai/claude-agent-sdk": "^0.1.30",
|
|
64
|
+
"@anthropic-ai/claude-code": "2.0.14",
|
|
65
|
+
"@anthropic-ai/sdk": "0.65.0",
|
|
66
|
+
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
67
|
+
"@openai/codex-sdk": "^0.58.0",
|
|
68
|
+
"@stablelib/base64": "^2.0.1",
|
|
69
|
+
"@stablelib/hex": "^2.0.1",
|
|
70
|
+
"@types/cross-spawn": "^6.0.6",
|
|
71
|
+
"@types/http-proxy": "^1.17.16",
|
|
72
|
+
"@types/ps-list": "^6.2.1",
|
|
73
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
74
|
+
"@types/react": "^19.1.9",
|
|
75
|
+
"@types/tmp": "^0.2.6",
|
|
76
|
+
"@types/yargs": "^17.0.33",
|
|
77
|
+
"axios": "^1.10.0",
|
|
78
|
+
"chalk": "^5.4.1",
|
|
79
|
+
"cross-spawn": "^7.0.6",
|
|
80
|
+
"expo-server-sdk": "^3.15.0",
|
|
81
|
+
"fastify": "^5.5.0",
|
|
82
|
+
"fastify-type-provider-zod": "4.0.2",
|
|
83
|
+
"http-proxy": "^1.18.1",
|
|
84
|
+
"http-proxy-middleware": "^3.0.5",
|
|
85
|
+
"ink": "^6.1.0",
|
|
86
|
+
"open": "^10.2.0",
|
|
87
|
+
"ps-list": "^8.1.1",
|
|
88
|
+
"qrcode-terminal": "^0.12.0",
|
|
89
|
+
"react": "^19.1.1",
|
|
90
|
+
"simple-git": "^3.30.0",
|
|
91
|
+
"socket.io-client": "^4.8.1",
|
|
92
|
+
"tar": "^7.4.3",
|
|
93
|
+
"tmp": "^0.2.5",
|
|
94
|
+
"tweetnacl": "^1.0.3",
|
|
95
|
+
"winston": "^3.18.3",
|
|
96
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
97
|
+
"yargs": "^17.7.2",
|
|
98
|
+
"zod": "^3.23.8"
|
|
99
|
+
},
|
|
100
|
+
"devDependencies": {
|
|
101
|
+
"@eslint/compat": "^1",
|
|
102
|
+
"@types/mime-types": "^3.0.1",
|
|
103
|
+
"@types/node": ">=20",
|
|
104
|
+
"cross-env": "^10.0.0",
|
|
105
|
+
"dotenv": "^16.6.1",
|
|
106
|
+
"eslint": "^9",
|
|
107
|
+
"eslint-config-prettier": "^10",
|
|
108
|
+
"pkgroll": "^2.14.2",
|
|
109
|
+
"release-it": "^19.0.4",
|
|
110
|
+
"shx": "^0.3.3",
|
|
111
|
+
"ts-node": "^10",
|
|
112
|
+
"tsx": "^4.20.3",
|
|
113
|
+
"typescript": "^5",
|
|
114
|
+
"vitest": "^3.2.4"
|
|
115
|
+
},
|
|
116
|
+
"resolutions": {
|
|
117
|
+
"whatwg-url": "14.2.0",
|
|
118
|
+
"parse-path": "7.0.3",
|
|
119
|
+
"@types/parse-path": "7.0.3"
|
|
120
|
+
},
|
|
121
|
+
"publishConfig": {
|
|
122
|
+
"registry": "https://registry.npmjs.org"
|
|
123
|
+
},
|
|
124
|
+
"packageManager": "yarn@1.22.22"
|
|
125
|
+
}
|