@i14ks/ccv 0.37.0 → 0.38.0
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/bundle/ccv.mjs +657 -303
- package/package.json +1 -1
- package/web/assets/{codemirror-D1cUi2V7.js → codemirror-B0NAQjxW.js} +1 -1
- package/web/assets/{index-CBhA54BF.js → index-1MYdpgaD.js} +1 -1
- package/web/assets/{index-BXJ1espS.js → index-B5iRbk6K.js} +1 -1
- package/web/assets/{index-EeZRrDkR.js → index-BoyP7MYO.js} +1 -1
- package/web/assets/{index-CfBrRHFZ.js → index-C7I7Qrgh.js} +1 -1
- package/web/assets/{index-SiXyTYpN.js → index-CA0PxYkA.js} +1 -1
- package/web/assets/{index-BOi5nzFz.js → index-CF_pC8Hx.js} +1 -1
- package/web/assets/{index-Dlh4RtNI.js → index-CHbY4Q8q.js} +1 -1
- package/web/assets/index-CO577SPK.css +1 -0
- package/web/assets/{index-BhVCT3ST.js → index-Cg_JGWuj.js} +1 -1
- package/web/assets/{index-DNUqPqF2.js → index-CswcCN2I.js} +1 -1
- package/web/assets/{index-BKD3Q2Nb.js → index-Cv6bq7Bb.js} +1 -1
- package/web/assets/{index-BJoy_XAx.js → index-D24xx07T.js} +1 -1
- package/web/assets/{index-Bqy6ikrI.js → index-D71l3zbz.js} +1 -1
- package/web/assets/{index-xs5AxpJq.js → index-DMq1FoW-.js} +1 -1
- package/web/assets/{index-DAUUK4vp.js → index-DhdpnWaP.js} +1 -1
- package/web/assets/{index-qMt-4408.js → index-DiyYHRov.js} +1 -1
- package/web/assets/{index-DnRv3bEx.js → index-LOhDu6-9.js} +1 -1
- package/web/assets/{index-B2o6F4n4.js → index-XwIPGsoL.js} +1 -1
- package/web/assets/{index-DJKT02UQ.js → index-fSIv5wMF.js} +1 -1
- package/web/assets/{index-DooYh81f.js → index-pL68uIyG.js} +1 -1
- package/web/assets/index-wKK666LV.js +134 -0
- package/web/index.html +2 -2
- package/web/assets/index-3GiZYI9o.css +0 -1
- package/web/assets/index-BBsKh79k.js +0 -134
package/bundle/ccv.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// dist/ccv.js
|
|
4
4
|
import { spawn as spawn3 } from "node:child_process";
|
|
5
|
-
import { readFile as
|
|
6
|
-
import
|
|
5
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
6
|
+
import path25 from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
9
9
|
|
|
@@ -63,7 +63,8 @@ async function runClaude(args, options2) {
|
|
|
63
63
|
execFile(file, [...prefix, ...args], {
|
|
64
64
|
timeout: options2.timeout,
|
|
65
65
|
maxBuffer: options2.maxBuffer ?? 1024 * 1024,
|
|
66
|
-
windowsHide: true
|
|
66
|
+
windowsHide: true,
|
|
67
|
+
...options2.env ? { env: options2.env } : {}
|
|
67
68
|
}, (error, stdout, stderr) => {
|
|
68
69
|
if (!error)
|
|
69
70
|
return resolve(stdout.trim());
|
|
@@ -75,9 +76,9 @@ async function runClaude(args, options2) {
|
|
|
75
76
|
});
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
|
-
async function spawnClaude(args) {
|
|
79
|
+
async function spawnClaude(args, env) {
|
|
79
80
|
const { file, prefix } = await claudeLauncher();
|
|
80
|
-
return spawn(file, [...prefix, ...args], { windowsHide: true });
|
|
81
|
+
return spawn(file, [...prefix, ...args], { windowsHide: true, ...env ? { env } : {} });
|
|
81
82
|
}
|
|
82
83
|
async function locate() {
|
|
83
84
|
for (const dir of searchDirs()) {
|
|
@@ -146,14 +147,16 @@ function envDefaults() {
|
|
|
146
147
|
// ../host/dist/server.js
|
|
147
148
|
import { createServer } from "node:http";
|
|
148
149
|
import { createReadStream, existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
149
|
-
import
|
|
150
|
-
import { homedir as
|
|
151
|
-
import { randomUUID as
|
|
150
|
+
import path24 from "node:path";
|
|
151
|
+
import { homedir as homedir7 } from "node:os";
|
|
152
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
152
153
|
import { WebSocketServer } from "ws";
|
|
153
154
|
import { renameSession as renameSession2 } from "@anthropic-ai/claude-agent-sdk";
|
|
154
155
|
|
|
155
156
|
// ../protocol/dist/index.js
|
|
156
157
|
var PROTOCOL_VERSION = 1;
|
|
158
|
+
var MAIN_ACCOUNT_ID = "main";
|
|
159
|
+
var ACCOUNT_COLORS = ["orange", "blue", "green", "purple", "pink", "teal"];
|
|
157
160
|
function isClientFrame(value) {
|
|
158
161
|
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
159
162
|
}
|
|
@@ -184,15 +187,184 @@ function hashText(text) {
|
|
|
184
187
|
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36);
|
|
185
188
|
}
|
|
186
189
|
|
|
190
|
+
// ../host/dist/accounts.js
|
|
191
|
+
import { randomUUID } from "node:crypto";
|
|
192
|
+
import { lstat, mkdir, readFile as readFile2, rename, symlink, writeFile } from "node:fs/promises";
|
|
193
|
+
import { homedir as homedir2 } from "node:os";
|
|
194
|
+
import path3 from "node:path";
|
|
195
|
+
var MAIN_DEFAULT = {
|
|
196
|
+
id: MAIN_ACCOUNT_ID,
|
|
197
|
+
name: "\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439",
|
|
198
|
+
color: "orange",
|
|
199
|
+
configDir: null
|
|
200
|
+
};
|
|
201
|
+
var AccountStore = class {
|
|
202
|
+
#accounts = [{ ...MAIN_DEFAULT }];
|
|
203
|
+
#file;
|
|
204
|
+
constructor(dataDir) {
|
|
205
|
+
this.#file = path3.join(dataDir, "accounts.json");
|
|
206
|
+
}
|
|
207
|
+
async load() {
|
|
208
|
+
try {
|
|
209
|
+
const parsed = JSON.parse(await readFile2(this.#file, "utf8"));
|
|
210
|
+
const stored = (parsed.accounts ?? []).filter(isStored);
|
|
211
|
+
const main = stored.find((a) => a.id === MAIN_ACCOUNT_ID);
|
|
212
|
+
this.#accounts = [
|
|
213
|
+
{ ...MAIN_DEFAULT, ...main ? { name: main.name, color: main.color } : {} },
|
|
214
|
+
...stored.filter((a) => a.id !== MAIN_ACCOUNT_ID && a.configDir)
|
|
215
|
+
];
|
|
216
|
+
} catch {
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
get all() {
|
|
220
|
+
return this.#accounts;
|
|
221
|
+
}
|
|
222
|
+
find(id) {
|
|
223
|
+
return this.#accounts.find((a) => a.id === (id ?? MAIN_ACCOUNT_ID));
|
|
224
|
+
}
|
|
225
|
+
/** Каталог конфигурации аккаунта; null — унаследованный. */
|
|
226
|
+
configDir(id) {
|
|
227
|
+
return this.find(id)?.configDir ?? null;
|
|
228
|
+
}
|
|
229
|
+
async add(input) {
|
|
230
|
+
const name = cleanName(input.name);
|
|
231
|
+
const id = randomUUID().slice(0, 8);
|
|
232
|
+
const configDir = input.configDir?.trim() ? path3.resolve(input.configDir.trim()) : path3.join(homedir2(), `.claude-ccv-${id}`);
|
|
233
|
+
if (this.#accounts.some((a) => sameDir(a.configDir ?? inheritedDir(), configDir))) {
|
|
234
|
+
throw new Error("\u042D\u0442\u043E\u0442 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0443\u0436\u0435 \u0437\u0430\u043D\u044F\u0442 \u0434\u0440\u0443\u0433\u0438\u043C \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u043C");
|
|
235
|
+
}
|
|
236
|
+
const color = input.color ?? this.#freeColor();
|
|
237
|
+
const account = { id, name, color, configDir };
|
|
238
|
+
await mkdir(configDir, { recursive: true });
|
|
239
|
+
if (input.shareConfig)
|
|
240
|
+
await linkSharedConfig(configDir);
|
|
241
|
+
this.#accounts = [...this.#accounts, account];
|
|
242
|
+
await this.#save();
|
|
243
|
+
return account;
|
|
244
|
+
}
|
|
245
|
+
async update(id, patch) {
|
|
246
|
+
const account = this.find(id);
|
|
247
|
+
if (!account)
|
|
248
|
+
throw new Error("\u0410\u043A\u043A\u0430\u0443\u043D\u0442 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D");
|
|
249
|
+
if (patch.name !== void 0)
|
|
250
|
+
account.name = cleanName(patch.name);
|
|
251
|
+
if (patch.color !== void 0 && ACCOUNT_COLORS.includes(patch.color))
|
|
252
|
+
account.color = patch.color;
|
|
253
|
+
await this.#save();
|
|
254
|
+
}
|
|
255
|
+
async remove(id) {
|
|
256
|
+
if (id === MAIN_ACCOUNT_ID)
|
|
257
|
+
throw new Error("\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0430\u043A\u043A\u0430\u0443\u043D\u0442 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043D\u0435\u043B\u044C\u0437\u044F");
|
|
258
|
+
if (!this.find(id))
|
|
259
|
+
return;
|
|
260
|
+
this.#accounts = this.#accounts.filter((a) => a.id !== id);
|
|
261
|
+
await this.#save();
|
|
262
|
+
}
|
|
263
|
+
#freeColor() {
|
|
264
|
+
const used = new Set(this.#accounts.map((a) => a.color));
|
|
265
|
+
return ACCOUNT_COLORS.find((c) => !used.has(c)) ?? ACCOUNT_COLORS[1];
|
|
266
|
+
}
|
|
267
|
+
async #save() {
|
|
268
|
+
await mkdir(path3.dirname(this.#file), { recursive: true });
|
|
269
|
+
await writeFile(this.#file, `${JSON.stringify({ accounts: this.#accounts }, null, 2)}
|
|
270
|
+
`, "utf8");
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
function accountEnv(configDir) {
|
|
274
|
+
return configDir ? { ...process.env, CLAUDE_CONFIG_DIR: configDir } : { ...process.env };
|
|
275
|
+
}
|
|
276
|
+
function inheritedDir() {
|
|
277
|
+
return process.env.CLAUDE_CONFIG_DIR?.trim() || path3.join(homedir2(), ".claude");
|
|
278
|
+
}
|
|
279
|
+
var chain = Promise.resolve();
|
|
280
|
+
function withConfigDir(configDir, work) {
|
|
281
|
+
if (!configDir) {
|
|
282
|
+
const run2 = chain.then(work, work);
|
|
283
|
+
chain = run2.catch(() => void 0);
|
|
284
|
+
return run2;
|
|
285
|
+
}
|
|
286
|
+
const run = chain.then(async () => {
|
|
287
|
+
const before = process.env.CLAUDE_CONFIG_DIR;
|
|
288
|
+
process.env.CLAUDE_CONFIG_DIR = configDir;
|
|
289
|
+
try {
|
|
290
|
+
return await work();
|
|
291
|
+
} finally {
|
|
292
|
+
if (before === void 0)
|
|
293
|
+
delete process.env.CLAUDE_CONFIG_DIR;
|
|
294
|
+
else
|
|
295
|
+
process.env.CLAUDE_CONFIG_DIR = before;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
chain = run.catch(() => void 0);
|
|
299
|
+
return run;
|
|
300
|
+
}
|
|
301
|
+
function cleanName(raw) {
|
|
302
|
+
const name = raw.trim().slice(0, 40);
|
|
303
|
+
if (!name)
|
|
304
|
+
throw new Error("\u0414\u0430\u0439\u0442\u0435 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0443 \u0438\u043C\u044F");
|
|
305
|
+
return name;
|
|
306
|
+
}
|
|
307
|
+
function sameDir(a, b) {
|
|
308
|
+
const norm = (value) => path3.resolve(value).toLowerCase();
|
|
309
|
+
return norm(a) === norm(b);
|
|
310
|
+
}
|
|
311
|
+
function isStored(value) {
|
|
312
|
+
if (!value || typeof value !== "object")
|
|
313
|
+
return false;
|
|
314
|
+
const v = value;
|
|
315
|
+
return typeof v.id === "string" && typeof v.name === "string" && typeof v.color === "string" && ACCOUNT_COLORS.includes(v.color) && (v.configDir === null || typeof v.configDir === "string");
|
|
316
|
+
}
|
|
317
|
+
var SHARED_DIRS = ["skills", "agents", "hooks", "commands", "plugins"];
|
|
318
|
+
var SHARED_FILES = ["CLAUDE.md", "settings.json"];
|
|
319
|
+
function sharedConfigDir() {
|
|
320
|
+
return process.env.CCV_SHARED_CONFIG_DIR?.trim() || path3.join(homedir2(), ".claude-shared");
|
|
321
|
+
}
|
|
322
|
+
async function linkSharedConfig(configDir) {
|
|
323
|
+
const shared = sharedConfigDir();
|
|
324
|
+
const main = inheritedDir();
|
|
325
|
+
await mkdir(shared, { recursive: true });
|
|
326
|
+
for (const name of [...SHARED_DIRS, ...SHARED_FILES]) {
|
|
327
|
+
const isDir = SHARED_DIRS.includes(name);
|
|
328
|
+
const target = path3.join(shared, name);
|
|
329
|
+
const origin = path3.join(main, name);
|
|
330
|
+
if (!await exists(target)) {
|
|
331
|
+
if (await isRealEntry(origin))
|
|
332
|
+
await rename(origin, target);
|
|
333
|
+
else if (isDir)
|
|
334
|
+
await mkdir(target, { recursive: true });
|
|
335
|
+
else
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
if (!await exists(origin) && !sameDir(main, configDir))
|
|
339
|
+
await link(target, origin, isDir);
|
|
340
|
+
const own = path3.join(configDir, name);
|
|
341
|
+
if (!await exists(own))
|
|
342
|
+
await link(target, own, isDir);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
async function link(target, at, isDir) {
|
|
346
|
+
try {
|
|
347
|
+
await symlink(target, at, isDir ? "junction" : "file");
|
|
348
|
+
} catch (error) {
|
|
349
|
+
throw new Error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443 ${at}: ${error instanceof Error ? error.message : String(error)}. \u041D\u0430 Windows \u0441\u0438\u043C\u0432\u043E\u043B\u044C\u043D\u044B\u0435 \u0441\u0441\u044B\u043B\u043A\u0438 \u043D\u0430 \u0444\u0430\u0439\u043B\u044B \u0442\u0440\u0435\u0431\u0443\u044E\u0442 \u0440\u0435\u0436\u0438\u043C\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A\u0430.`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async function exists(file) {
|
|
353
|
+
return lstat(file).then(() => true, () => false);
|
|
354
|
+
}
|
|
355
|
+
async function isRealEntry(file) {
|
|
356
|
+
return lstat(file).then((stat2) => !stat2.isSymbolicLink(), () => false);
|
|
357
|
+
}
|
|
358
|
+
|
|
187
359
|
// ../host/dist/workspace-ids.js
|
|
188
360
|
function workspaceIdRemap(paths, sessionsOf) {
|
|
189
361
|
const byLegacy = /* @__PURE__ */ new Map();
|
|
190
|
-
for (const
|
|
191
|
-
const id = workspaceIdFromPath(
|
|
192
|
-
for (const legacy of formerWorkspaceIdsFromPath(
|
|
362
|
+
for (const path26 of paths) {
|
|
363
|
+
const id = workspaceIdFromPath(path26);
|
|
364
|
+
for (const legacy of formerWorkspaceIdsFromPath(path26)) {
|
|
193
365
|
const group = byLegacy.get(legacy) ?? [];
|
|
194
366
|
if (!group.some((target) => target.id === id))
|
|
195
|
-
group.push({ id, path:
|
|
367
|
+
group.push({ id, path: path26 });
|
|
196
368
|
byLegacy.set(legacy, group);
|
|
197
369
|
}
|
|
198
370
|
}
|
|
@@ -224,8 +396,8 @@ function workspaceIdRemap(paths, sessionsOf) {
|
|
|
224
396
|
|
|
225
397
|
// ../host/dist/session.js
|
|
226
398
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
227
|
-
import { randomUUID } from "node:crypto";
|
|
228
|
-
import
|
|
399
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
400
|
+
import path6 from "node:path";
|
|
229
401
|
import { query, renameSession } from "@anthropic-ai/claude-agent-sdk";
|
|
230
402
|
|
|
231
403
|
// ../host/dist/async-queue.js
|
|
@@ -276,8 +448,8 @@ var AsyncQueue = class {
|
|
|
276
448
|
};
|
|
277
449
|
|
|
278
450
|
// ../host/dist/files.js
|
|
279
|
-
import { cp, lstat, mkdir, readFile as
|
|
280
|
-
import
|
|
451
|
+
import { cp, lstat as lstat2, mkdir as mkdir2, readFile as readFile3, readdir, realpath, rename as renamePath, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
452
|
+
import path4 from "node:path";
|
|
281
453
|
var MAX_FILE = 4 * 1024 * 1024;
|
|
282
454
|
var MAX_MEDIA = 64 * 1024 * 1024;
|
|
283
455
|
var MEDIA_MIME = {
|
|
@@ -315,8 +487,8 @@ var ProjectFiles = class {
|
|
|
315
487
|
for (const dirent of names2) {
|
|
316
488
|
if (HIDDEN.has(dirent.name))
|
|
317
489
|
continue;
|
|
318
|
-
const full =
|
|
319
|
-
const
|
|
490
|
+
const full = path4.join(dir, dirent.name);
|
|
491
|
+
const link2 = dirent.isSymbolicLink();
|
|
320
492
|
const info = await stat(full).catch(() => null);
|
|
321
493
|
if (!info)
|
|
322
494
|
continue;
|
|
@@ -326,7 +498,7 @@ var ProjectFiles = class {
|
|
|
326
498
|
kind: info.isDirectory() ? "dir" : "file",
|
|
327
499
|
size: info.isDirectory() ? 0 : info.size,
|
|
328
500
|
mtime: Math.round(info.mtimeMs),
|
|
329
|
-
link,
|
|
501
|
+
link: link2,
|
|
330
502
|
// Кто игнорируется, знает git, а не файловая система: отметку ставит
|
|
331
503
|
// сервер поверх готового списка (см. `markIgnored`).
|
|
332
504
|
ignored: false
|
|
@@ -363,7 +535,7 @@ var ProjectFiles = class {
|
|
|
363
535
|
return;
|
|
364
536
|
if (SEARCH_SKIP.has(dirent.name))
|
|
365
537
|
continue;
|
|
366
|
-
const full =
|
|
538
|
+
const full = path4.join(dir, dirent.name);
|
|
367
539
|
const rel = join(relative, dirent.name);
|
|
368
540
|
const info = await stat(full).catch(() => null);
|
|
369
541
|
if (!info)
|
|
@@ -418,7 +590,7 @@ var ProjectFiles = class {
|
|
|
418
590
|
return;
|
|
419
591
|
if (SEARCH_SKIP.has(dirent.name) || dirent.isSymbolicLink())
|
|
420
592
|
continue;
|
|
421
|
-
const full =
|
|
593
|
+
const full = path4.join(dir, dirent.name);
|
|
422
594
|
const rel = join(relative, dirent.name);
|
|
423
595
|
if (dirent.isDirectory()) {
|
|
424
596
|
await walk(full, rel);
|
|
@@ -429,7 +601,7 @@ var ProjectFiles = class {
|
|
|
429
601
|
const info = await stat(full).catch(() => null);
|
|
430
602
|
if (!info || info.size > MAX_FILE)
|
|
431
603
|
continue;
|
|
432
|
-
const buffer = await
|
|
604
|
+
const buffer = await readFile3(full).catch(() => null);
|
|
433
605
|
if (!buffer)
|
|
434
606
|
continue;
|
|
435
607
|
const decoded = decode(buffer);
|
|
@@ -486,7 +658,7 @@ var ProjectFiles = class {
|
|
|
486
658
|
binary: false,
|
|
487
659
|
tooLarge: false
|
|
488
660
|
};
|
|
489
|
-
const mediaMime = MEDIA_MIME[
|
|
661
|
+
const mediaMime = MEDIA_MIME[path4.extname(file).toLowerCase()];
|
|
490
662
|
if (mediaMime) {
|
|
491
663
|
if (info.size > MAX_MEDIA)
|
|
492
664
|
return { ...blank, binary: true, mediaMime, mediaTooLarge: true };
|
|
@@ -494,7 +666,7 @@ var ProjectFiles = class {
|
|
|
494
666
|
}
|
|
495
667
|
if (info.size > MAX_FILE)
|
|
496
668
|
return { ...blank, tooLarge: true };
|
|
497
|
-
const buffer = await
|
|
669
|
+
const buffer = await readFile3(file);
|
|
498
670
|
const decoded = decode(buffer);
|
|
499
671
|
if (!decoded)
|
|
500
672
|
return { ...blank, binary: true };
|
|
@@ -517,7 +689,7 @@ var ProjectFiles = class {
|
|
|
517
689
|
*/
|
|
518
690
|
async readMedia(relative) {
|
|
519
691
|
const file = await this.#resolve(relative);
|
|
520
|
-
const mime = MEDIA_MIME[
|
|
692
|
+
const mime = MEDIA_MIME[path4.extname(file).toLowerCase()];
|
|
521
693
|
if (!mime)
|
|
522
694
|
throw new Error("\u0424\u0430\u0439\u043B \u043D\u0435 \u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D \u043A\u0430\u043A \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0430 \u0438\u043B\u0438 \u0432\u0438\u0434\u0435\u043E");
|
|
523
695
|
const info = await stat(file);
|
|
@@ -525,7 +697,7 @@ var ProjectFiles = class {
|
|
|
525
697
|
throw new Error("\u042D\u0442\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433, \u0430 \u043D\u0435 \u0444\u0430\u0439\u043B");
|
|
526
698
|
if (info.size > MAX_MEDIA)
|
|
527
699
|
throw new Error("\u0424\u0430\u0439\u043B \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0432\u0435\u043B\u0438\u043A \u0434\u043B\u044F \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430");
|
|
528
|
-
const buffer = await
|
|
700
|
+
const buffer = await readFile3(file);
|
|
529
701
|
return { mime, base64: buffer.toString("base64") };
|
|
530
702
|
}
|
|
531
703
|
/**
|
|
@@ -547,29 +719,29 @@ var ProjectFiles = class {
|
|
|
547
719
|
throw new ConflictError(info ? "\u0424\u0430\u0439\u043B \u043D\u0430 \u0434\u0438\u0441\u043A\u0435 \u0438\u0437\u043C\u0435\u043D\u0438\u043B\u0441\u044F \u043F\u043E\u0441\u043B\u0435 \u0442\u043E\u0433\u043E, \u043A\u0430\u043A \u0435\u0433\u043E \u043E\u0442\u043A\u0440\u044B\u043B\u0438 \u0432 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u0435" : "\u0424\u0430\u0439\u043B \u043D\u0430 \u0434\u0438\u0441\u043A\u0435 \u0438\u0441\u0447\u0435\u0437 \u043F\u043E\u0441\u043B\u0435 \u0442\u043E\u0433\u043E, \u043A\u0430\u043A \u0435\u0433\u043E \u043E\u0442\u043A\u0440\u044B\u043B\u0438 \u0432 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u0435");
|
|
548
720
|
}
|
|
549
721
|
}
|
|
550
|
-
await
|
|
722
|
+
await writeFile2(file, encode(content, eol, encoding));
|
|
551
723
|
const saved = await stat(file);
|
|
552
724
|
return { mtime: Math.round(saved.mtimeMs), size: saved.size };
|
|
553
725
|
}
|
|
554
726
|
async create(relative, kind) {
|
|
555
727
|
const target = await this.#resolve(relative);
|
|
556
|
-
if (await
|
|
728
|
+
if (await exists2(target))
|
|
557
729
|
throw new Error("\u0422\u0430\u043A\u043E\u0439 \u0444\u0430\u0439\u043B \u0438\u043B\u0438 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u0443\u0436\u0435 \u0435\u0441\u0442\u044C");
|
|
558
730
|
if (kind === "dir") {
|
|
559
|
-
await
|
|
731
|
+
await mkdir2(target, { recursive: true });
|
|
560
732
|
return;
|
|
561
733
|
}
|
|
562
|
-
await
|
|
563
|
-
await
|
|
734
|
+
await mkdir2(path4.dirname(target), { recursive: true });
|
|
735
|
+
await writeFile2(target, "", { encoding: "utf8", flag: "wx" });
|
|
564
736
|
}
|
|
565
737
|
async rename(relative, to) {
|
|
566
738
|
const from = await this.#resolve(relative);
|
|
567
739
|
const target = await this.#resolve(to);
|
|
568
740
|
if (from === target)
|
|
569
741
|
return;
|
|
570
|
-
if (await
|
|
742
|
+
if (await exists2(target))
|
|
571
743
|
throw new Error("\u041F\u043E \u043D\u043E\u0432\u043E\u043C\u0443 \u043F\u0443\u0442\u0438 \u0443\u0436\u0435 \u0447\u0442\u043E-\u0442\u043E \u0435\u0441\u0442\u044C");
|
|
572
|
-
await
|
|
744
|
+
await mkdir2(path4.dirname(target), { recursive: true });
|
|
573
745
|
await renamePath(from, target);
|
|
574
746
|
}
|
|
575
747
|
/**
|
|
@@ -599,10 +771,10 @@ var ProjectFiles = class {
|
|
|
599
771
|
throw new Error("\u041D\u0435\u043A\u0443\u0434\u0430 \u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C \u043A\u043E\u043F\u0438\u044E: \u0438\u043C\u0435\u043D\u0430 \u0437\u0430\u043D\u044F\u0442\u044B");
|
|
600
772
|
target = join(dir, copyName(name, attempt, info.isDirectory()));
|
|
601
773
|
to = await this.#resolve(target);
|
|
602
|
-
if (!await
|
|
774
|
+
if (!await exists2(to))
|
|
603
775
|
break;
|
|
604
776
|
}
|
|
605
|
-
await
|
|
777
|
+
await mkdir2(path4.dirname(to), { recursive: true });
|
|
606
778
|
await cp(from, to, { recursive: true, errorOnExist: true, force: false });
|
|
607
779
|
return target;
|
|
608
780
|
}
|
|
@@ -622,15 +794,15 @@ var ProjectFiles = class {
|
|
|
622
794
|
*/
|
|
623
795
|
async #resolve(relative) {
|
|
624
796
|
const clean = normalize(relative);
|
|
625
|
-
if (
|
|
797
|
+
if (path4.isAbsolute(clean) || /^[A-Za-z]:/.test(clean)) {
|
|
626
798
|
throw new Error("\u041F\u0443\u0442\u044C \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u043C \u043E\u0442 \u043A\u043E\u0440\u043D\u044F \u043F\u0440\u043E\u0435\u043A\u0442\u0430");
|
|
627
799
|
}
|
|
628
800
|
if (clean.split("/").includes("..")) {
|
|
629
801
|
throw new Error("\u0412\u044B\u0445\u043E\u0434 \u0437\u0430 \u043F\u0440\u0435\u0434\u0435\u043B\u044B \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 \u0437\u0430\u043F\u0440\u0435\u0449\u0451\u043D");
|
|
630
802
|
}
|
|
631
803
|
const root = this.#root ??= await realpath(this.cwd);
|
|
632
|
-
const target =
|
|
633
|
-
const probe = await
|
|
804
|
+
const target = path4.resolve(root, clean);
|
|
805
|
+
const probe = await exists2(target) ? target : path4.dirname(target);
|
|
634
806
|
const real = await realpath(probe).catch(() => probe);
|
|
635
807
|
if (!contains(root, real)) {
|
|
636
808
|
throw new Error("\u0412\u044B\u0445\u043E\u0434 \u0437\u0430 \u043F\u0440\u0435\u0434\u0435\u043B\u044B \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 \u0437\u0430\u043F\u0440\u0435\u0449\u0451\u043D");
|
|
@@ -651,11 +823,11 @@ function join(dir, name) {
|
|
|
651
823
|
function contains(root, target) {
|
|
652
824
|
if (target === root)
|
|
653
825
|
return true;
|
|
654
|
-
const prefix = root.endsWith(
|
|
826
|
+
const prefix = root.endsWith(path4.sep) ? root : root + path4.sep;
|
|
655
827
|
return process.platform === "win32" ? target.toLowerCase().startsWith(prefix.toLowerCase()) : target.startsWith(prefix);
|
|
656
828
|
}
|
|
657
|
-
async function
|
|
658
|
-
return
|
|
829
|
+
async function exists2(file) {
|
|
830
|
+
return lstat2(file).then(() => true, () => false);
|
|
659
831
|
}
|
|
660
832
|
var COPY_NAME_LIMIT = 200;
|
|
661
833
|
function copyName(name, attempt, isDir) {
|
|
@@ -955,16 +1127,16 @@ function interfacesSignature() {
|
|
|
955
1127
|
}
|
|
956
1128
|
|
|
957
1129
|
// ../host/dist/settings.js
|
|
958
|
-
import { readFile as
|
|
959
|
-
import { homedir as
|
|
960
|
-
import
|
|
961
|
-
var USER_SETTINGS =
|
|
962
|
-
var PROJECT_SETTINGS =
|
|
963
|
-
var LOCAL_SETTINGS =
|
|
1130
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
1131
|
+
import { homedir as homedir3 } from "node:os";
|
|
1132
|
+
import path5 from "node:path";
|
|
1133
|
+
var USER_SETTINGS = path5.join(homedir3(), ".claude", "settings.json");
|
|
1134
|
+
var PROJECT_SETTINGS = path5.join(".claude", "settings.json");
|
|
1135
|
+
var LOCAL_SETTINGS = path5.join(".claude", "settings.local.json");
|
|
964
1136
|
function managedSettingsPath() {
|
|
965
1137
|
switch (process.platform) {
|
|
966
1138
|
case "win32":
|
|
967
|
-
return
|
|
1139
|
+
return path5.join(process.env.PROGRAMDATA ?? "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
|
|
968
1140
|
case "darwin":
|
|
969
1141
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
970
1142
|
default:
|
|
@@ -975,8 +1147,8 @@ var EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
|
975
1147
|
async function readConfiguredDefaults(cwd) {
|
|
976
1148
|
const files = [
|
|
977
1149
|
USER_SETTINGS,
|
|
978
|
-
|
|
979
|
-
|
|
1150
|
+
path5.join(cwd, PROJECT_SETTINGS),
|
|
1151
|
+
path5.join(cwd, LOCAL_SETTINGS),
|
|
980
1152
|
managedSettingsPath()
|
|
981
1153
|
];
|
|
982
1154
|
const result = {
|
|
@@ -1022,7 +1194,7 @@ async function readConfiguredDefaults(cwd) {
|
|
|
1022
1194
|
}
|
|
1023
1195
|
async function readSettings(file) {
|
|
1024
1196
|
try {
|
|
1025
|
-
const parsed = JSON.parse(await
|
|
1197
|
+
const parsed = JSON.parse(await readFile4(file, "utf8"));
|
|
1026
1198
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
1027
1199
|
} catch {
|
|
1028
1200
|
return null;
|
|
@@ -1037,10 +1209,10 @@ var CUT = "\n\u2026 (\u043E\u0431\u0440\u0435\u0437\u0430\u043D\u043E)";
|
|
|
1037
1209
|
async function readTranscript(sessionId, options2) {
|
|
1038
1210
|
let messages;
|
|
1039
1211
|
try {
|
|
1040
|
-
messages = await getSessionMessages(sessionId, {
|
|
1212
|
+
messages = await withConfigDir(options2.configDir ?? null, () => getSessionMessages(sessionId, {
|
|
1041
1213
|
dir: options2.dir,
|
|
1042
1214
|
includeSystemMessages: true
|
|
1043
|
-
});
|
|
1215
|
+
}));
|
|
1044
1216
|
} catch {
|
|
1045
1217
|
return [];
|
|
1046
1218
|
}
|
|
@@ -1118,10 +1290,10 @@ async function readTranscript(sessionId, options2) {
|
|
|
1118
1290
|
}
|
|
1119
1291
|
return entries;
|
|
1120
1292
|
}
|
|
1121
|
-
async function locateResumePoint(sessionId, dir, userIndex) {
|
|
1293
|
+
async function locateResumePoint(sessionId, dir, userIndex, configDir = null) {
|
|
1122
1294
|
let messages;
|
|
1123
1295
|
try {
|
|
1124
|
-
messages = await getSessionMessages(sessionId, { dir, includeSystemMessages: true });
|
|
1296
|
+
messages = await withConfigDir(configDir, () => getSessionMessages(sessionId, { dir, includeSystemMessages: true }));
|
|
1125
1297
|
} catch {
|
|
1126
1298
|
return null;
|
|
1127
1299
|
}
|
|
@@ -1553,7 +1725,7 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
1553
1725
|
constructor(options2) {
|
|
1554
1726
|
super();
|
|
1555
1727
|
this.#options = options2;
|
|
1556
|
-
this.id = options2.resume && !options2.fork ? options2.resume :
|
|
1728
|
+
this.id = options2.resume && !options2.fork ? options2.resume : randomUUID2();
|
|
1557
1729
|
this.workspaceId = options2.workspaceId;
|
|
1558
1730
|
this.cwd = options2.cwd;
|
|
1559
1731
|
this.#permissionMode = options2.permissionMode ?? "default";
|
|
@@ -1573,6 +1745,13 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
1573
1745
|
get claudeSessionId() {
|
|
1574
1746
|
return this.#claudeSessionId;
|
|
1575
1747
|
}
|
|
1748
|
+
get accountId() {
|
|
1749
|
+
return this.#options.accountId ?? MAIN_ACCOUNT_ID;
|
|
1750
|
+
}
|
|
1751
|
+
/** Каталог конфигурации аккаунта сессии; null — унаследованный хостом. */
|
|
1752
|
+
get configDir() {
|
|
1753
|
+
return this.#options.configDir ?? null;
|
|
1754
|
+
}
|
|
1576
1755
|
/** Боковая сессия («вопрос на полях») — у неё есть родитель и нет прав на запись. */
|
|
1577
1756
|
get parentSessionId() {
|
|
1578
1757
|
return this.#options.parentSessionId ?? null;
|
|
@@ -1603,6 +1782,7 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
1603
1782
|
workspaceId: this.workspaceId,
|
|
1604
1783
|
cwd: this.cwd,
|
|
1605
1784
|
parentSessionId: this.parentSessionId,
|
|
1785
|
+
accountId: this.#options.accountId ?? MAIN_ACCOUNT_ID,
|
|
1606
1786
|
title: this.#title,
|
|
1607
1787
|
state: this.#state,
|
|
1608
1788
|
lastTurn: this.#lastTurn,
|
|
@@ -1630,7 +1810,11 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
1630
1810
|
throw new Error("session already started");
|
|
1631
1811
|
if (this.#options.resume && !this.#options.fork) {
|
|
1632
1812
|
const until = Date.now();
|
|
1633
|
-
this.#history = readTranscript(this.#options.resume, {
|
|
1813
|
+
this.#history = readTranscript(this.#options.resume, {
|
|
1814
|
+
dir: this.cwd,
|
|
1815
|
+
until,
|
|
1816
|
+
configDir: this.#options.configDir ?? null
|
|
1817
|
+
});
|
|
1634
1818
|
}
|
|
1635
1819
|
this.#spawn(false);
|
|
1636
1820
|
}
|
|
@@ -1696,6 +1880,8 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
1696
1880
|
if (this.#executable.executable)
|
|
1697
1881
|
options2.executable = this.#executable.executable;
|
|
1698
1882
|
}
|
|
1883
|
+
if (this.#options.configDir)
|
|
1884
|
+
options2.env = accountEnv(this.#options.configDir);
|
|
1699
1885
|
if (this.#model)
|
|
1700
1886
|
options2.model = this.#model;
|
|
1701
1887
|
if (resumeAt !== null) {
|
|
@@ -2018,7 +2204,7 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
2018
2204
|
if (this.#state === "running")
|
|
2019
2205
|
await this.interrupt();
|
|
2020
2206
|
const source = this.#claudeSessionId ?? this.#options.resume;
|
|
2021
|
-
const anchor = source ? await locateResumePoint(source, this.cwd, userIndex) : null;
|
|
2207
|
+
const anchor = source ? await locateResumePoint(source, this.cwd, userIndex, this.#options.configDir ?? null) : null;
|
|
2022
2208
|
if (!anchor) {
|
|
2023
2209
|
this.#record({
|
|
2024
2210
|
kind: "error",
|
|
@@ -2456,7 +2642,8 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
2456
2642
|
return;
|
|
2457
2643
|
}
|
|
2458
2644
|
try {
|
|
2459
|
-
|
|
2645
|
+
const id = this.#claudeSessionId;
|
|
2646
|
+
await withConfigDir(this.#options.configDir ?? null, () => renameSession(id, title, { dir: this.cwd }));
|
|
2460
2647
|
this.#unpersistedTitle = null;
|
|
2461
2648
|
} catch (error) {
|
|
2462
2649
|
this.#unpersistedTitle = title;
|
|
@@ -2506,7 +2693,7 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
2506
2693
|
const target = writeTarget(input.tool_input);
|
|
2507
2694
|
if (!target)
|
|
2508
2695
|
return pass;
|
|
2509
|
-
const absolute =
|
|
2696
|
+
const absolute = path6.resolve(this.cwd, target);
|
|
2510
2697
|
if (roots.some((root) => contains(root, absolute)))
|
|
2511
2698
|
return pass;
|
|
2512
2699
|
return {
|
|
@@ -2562,7 +2749,7 @@ var ClaudeSession = class extends EventEmitter2 {
|
|
|
2562
2749
|
message: "\u0411\u043E\u043A\u043E\u0432\u0430\u044F \u0441\u0435\u0441\u0441\u0438\u044F \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u0447\u0442\u0435\u043D\u0438\u0435"
|
|
2563
2750
|
});
|
|
2564
2751
|
}
|
|
2565
|
-
const requestId =
|
|
2752
|
+
const requestId = randomUUID2();
|
|
2566
2753
|
const questions = toolName === ASK_QUESTION_TOOL ? parseQuestions(input) : null;
|
|
2567
2754
|
return new Promise((resolve) => {
|
|
2568
2755
|
this.#pendingPermissions.set(requestId, { resolve, toolName, input, questions });
|
|
@@ -3134,32 +3321,32 @@ function contentToText2(content) {
|
|
|
3134
3321
|
// ../host/dist/antigravity-session.js
|
|
3135
3322
|
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
3136
3323
|
import { spawn as spawn2, execFile as execFile3 } from "node:child_process";
|
|
3137
|
-
import { randomUUID as
|
|
3138
|
-
import { mkdir as
|
|
3324
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
3325
|
+
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
3139
3326
|
import { tmpdir } from "node:os";
|
|
3140
|
-
import
|
|
3327
|
+
import path8 from "node:path";
|
|
3141
3328
|
import { createInterface } from "node:readline";
|
|
3142
3329
|
|
|
3143
3330
|
// ../host/dist/antigravity-cli.js
|
|
3144
3331
|
import { execFile as execFile2 } from "node:child_process";
|
|
3145
3332
|
import { existsSync } from "node:fs";
|
|
3146
|
-
import { homedir as
|
|
3147
|
-
import
|
|
3333
|
+
import { homedir as homedir4 } from "node:os";
|
|
3334
|
+
import path7 from "node:path";
|
|
3148
3335
|
function agyExecutable() {
|
|
3149
3336
|
const forced = process.env.CCV_AGY_PATH;
|
|
3150
3337
|
if (forced && existsSync(forced))
|
|
3151
3338
|
return forced;
|
|
3152
3339
|
const names2 = process.platform === "win32" ? ["agy.exe", "agy"] : ["agy"];
|
|
3153
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
3340
|
+
const dirs = (process.env.PATH ?? "").split(path7.delimiter).filter(Boolean);
|
|
3154
3341
|
if (process.platform === "win32") {
|
|
3155
|
-
const local = process.env.LOCALAPPDATA ??
|
|
3156
|
-
dirs.push(
|
|
3342
|
+
const local = process.env.LOCALAPPDATA ?? path7.join(homedir4(), "AppData", "Local");
|
|
3343
|
+
dirs.push(path7.join(local, "agy", "bin"));
|
|
3157
3344
|
} else {
|
|
3158
|
-
dirs.push(
|
|
3345
|
+
dirs.push(path7.join(homedir4(), ".local", "bin"), "/usr/local/bin", "/opt/homebrew/bin");
|
|
3159
3346
|
}
|
|
3160
3347
|
for (const dir of dirs) {
|
|
3161
3348
|
for (const name of names2) {
|
|
3162
|
-
const candidate =
|
|
3349
|
+
const candidate = path7.join(dir, name);
|
|
3163
3350
|
if (existsSync(candidate))
|
|
3164
3351
|
return candidate;
|
|
3165
3352
|
}
|
|
@@ -3395,7 +3582,7 @@ var AntigravitySession = class extends EventEmitter3 {
|
|
|
3395
3582
|
this.cwd = options2.cwd;
|
|
3396
3583
|
const now = Date.now();
|
|
3397
3584
|
this.#record = options2.record ? { ...options2.record } : {
|
|
3398
|
-
id:
|
|
3585
|
+
id: randomUUID3(),
|
|
3399
3586
|
conversationId: null,
|
|
3400
3587
|
workspaceId: options2.workspaceId,
|
|
3401
3588
|
cwd: options2.cwd,
|
|
@@ -3461,7 +3648,8 @@ var AntigravitySession = class extends EventEmitter3 {
|
|
|
3461
3648
|
createdAt: this.#record.createdAt,
|
|
3462
3649
|
updatedAt: this.#updatedAt,
|
|
3463
3650
|
lastSeq: this.journal.lastSeq,
|
|
3464
|
-
totalCostUsd: 0
|
|
3651
|
+
totalCostUsd: 0,
|
|
3652
|
+
accountId: MAIN_ACCOUNT_ID
|
|
3465
3653
|
};
|
|
3466
3654
|
}
|
|
3467
3655
|
// -------------------------------------------------------------------------
|
|
@@ -3769,7 +3957,7 @@ var AntigravitySession = class extends EventEmitter3 {
|
|
|
3769
3957
|
if (this.#closing)
|
|
3770
3958
|
return;
|
|
3771
3959
|
if (reply)
|
|
3772
|
-
this.#record_({ kind: "assistant.text", text: reply, blockId: `cmd:${
|
|
3960
|
+
this.#record_({ kind: "assistant.text", text: reply, blockId: `cmd:${randomUUID3()}` });
|
|
3773
3961
|
if (error)
|
|
3774
3962
|
this.#record_({ kind: "error", message: error });
|
|
3775
3963
|
if (turnRunning || this.#pendingTurns > 0)
|
|
@@ -3825,13 +4013,13 @@ var AntigravitySession = class extends EventEmitter3 {
|
|
|
3825
4013
|
async #composePrompt(text, images) {
|
|
3826
4014
|
if (!images || images.length === 0)
|
|
3827
4015
|
return text;
|
|
3828
|
-
const dir =
|
|
3829
|
-
await
|
|
4016
|
+
const dir = path8.join(tmpdir(), "ccv-antigravity", this.id);
|
|
4017
|
+
await mkdir3(dir, { recursive: true });
|
|
3830
4018
|
const paths = [];
|
|
3831
4019
|
for (const image of images) {
|
|
3832
4020
|
const ext = image.mediaType.split("/")[1] === "jpeg" ? "jpg" : image.mediaType.split("/")[1];
|
|
3833
|
-
const file =
|
|
3834
|
-
await
|
|
4021
|
+
const file = path8.join(dir, `${randomUUID3()}.${ext}`);
|
|
4022
|
+
await writeFile3(file, Buffer.from(image.data, "base64"));
|
|
3835
4023
|
paths.push(file);
|
|
3836
4024
|
}
|
|
3837
4025
|
return `${text}
|
|
@@ -4218,8 +4406,8 @@ function describe2(error) {
|
|
|
4218
4406
|
}
|
|
4219
4407
|
|
|
4220
4408
|
// ../host/dist/antigravity-store.js
|
|
4221
|
-
import { appendFile, mkdir as
|
|
4222
|
-
import
|
|
4409
|
+
import { appendFile, mkdir as mkdir4, readFile as readFile5, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
|
|
4410
|
+
import path9 from "node:path";
|
|
4223
4411
|
var AntigravityStore = class {
|
|
4224
4412
|
#dir;
|
|
4225
4413
|
#file;
|
|
@@ -4227,13 +4415,13 @@ var AntigravityStore = class {
|
|
|
4227
4415
|
#loaded = null;
|
|
4228
4416
|
#writing = Promise.resolve();
|
|
4229
4417
|
constructor(dataDir) {
|
|
4230
|
-
this.#dir =
|
|
4231
|
-
this.#file =
|
|
4418
|
+
this.#dir = path9.join(dataDir, "antigravity");
|
|
4419
|
+
this.#file = path9.join(this.#dir, "sessions.json");
|
|
4232
4420
|
}
|
|
4233
4421
|
#load() {
|
|
4234
4422
|
this.#loaded ??= (async () => {
|
|
4235
4423
|
try {
|
|
4236
|
-
const raw = JSON.parse(await
|
|
4424
|
+
const raw = JSON.parse(await readFile5(this.#file, "utf8"));
|
|
4237
4425
|
for (const record of Array.isArray(raw) ? raw : []) {
|
|
4238
4426
|
if (record && typeof record.id === "string")
|
|
4239
4427
|
this.#records.set(record.id, record);
|
|
@@ -4299,7 +4487,7 @@ var AntigravityStore = class {
|
|
|
4299
4487
|
return this.#writing;
|
|
4300
4488
|
const lines = events.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
4301
4489
|
return this.#enqueue(async () => {
|
|
4302
|
-
await
|
|
4490
|
+
await mkdir4(this.#dir, { recursive: true });
|
|
4303
4491
|
await appendFile(this.#eventsFile(id), lines, "utf8");
|
|
4304
4492
|
});
|
|
4305
4493
|
}
|
|
@@ -4308,7 +4496,7 @@ var AntigravityStore = class {
|
|
|
4308
4496
|
await this.#writing;
|
|
4309
4497
|
let raw;
|
|
4310
4498
|
try {
|
|
4311
|
-
raw = await
|
|
4499
|
+
raw = await readFile5(this.#eventsFile(id), "utf8");
|
|
4312
4500
|
} catch {
|
|
4313
4501
|
return [];
|
|
4314
4502
|
}
|
|
@@ -4325,13 +4513,13 @@ var AntigravityStore = class {
|
|
|
4325
4513
|
return entries;
|
|
4326
4514
|
}
|
|
4327
4515
|
#eventsFile(id) {
|
|
4328
|
-
return
|
|
4516
|
+
return path9.join(this.#dir, `${id.replace(/[^\w-]/g, "_")}.jsonl`);
|
|
4329
4517
|
}
|
|
4330
4518
|
#persist() {
|
|
4331
4519
|
const snapshot = JSON.stringify([...this.#records.values()], null, 2);
|
|
4332
4520
|
return this.#enqueue(async () => {
|
|
4333
|
-
await
|
|
4334
|
-
await
|
|
4521
|
+
await mkdir4(this.#dir, { recursive: true });
|
|
4522
|
+
await writeFile4(this.#file, snapshot, "utf8");
|
|
4335
4523
|
});
|
|
4336
4524
|
}
|
|
4337
4525
|
/** Записи на диск — строго по очереди: две параллельные испортили бы файл. */
|
|
@@ -4346,9 +4534,9 @@ var AntigravityStore = class {
|
|
|
4346
4534
|
|
|
4347
4535
|
// ../host/dist/git.js
|
|
4348
4536
|
import { execFile as execFile4 } from "node:child_process";
|
|
4349
|
-
import { mkdtemp, readFile as
|
|
4537
|
+
import { mkdtemp, readFile as readFile6, rm as rm3, writeFile as writeFile5 } from "node:fs/promises";
|
|
4350
4538
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
4351
|
-
import
|
|
4539
|
+
import path10 from "node:path";
|
|
4352
4540
|
var TIMEOUT_MS = 2e4;
|
|
4353
4541
|
var NET_TIMEOUT_MS = 5 * 6e4;
|
|
4354
4542
|
var MAX_BUFFER = 32 * 1024 * 1024;
|
|
@@ -4664,7 +4852,7 @@ var GitRepo = class {
|
|
|
4664
4852
|
* важнее всего (см. `checkIgnored`).
|
|
4665
4853
|
*/
|
|
4666
4854
|
async #withoutRepo(args) {
|
|
4667
|
-
const dir = await mkdtemp(
|
|
4855
|
+
const dir = await mkdtemp(path10.join(tmpdir2(), "ccv-git-"));
|
|
4668
4856
|
try {
|
|
4669
4857
|
await this.#run(["init", "--bare", "--quiet", dir]);
|
|
4670
4858
|
return await this.#soft([`--git-dir=${dir}`, `--work-tree=${this.cwd}`, ...args]);
|
|
@@ -4710,14 +4898,14 @@ var GitRepo = class {
|
|
|
4710
4898
|
* исключил. Повторы отсеиваются, чтобы файл не рос от каждой публикации.
|
|
4711
4899
|
*/
|
|
4712
4900
|
async #appendGitignore(paths) {
|
|
4713
|
-
const file =
|
|
4714
|
-
const existing = await
|
|
4901
|
+
const file = path10.join(this.cwd, ".gitignore");
|
|
4902
|
+
const existing = await readFile6(file, "utf8").catch(() => "");
|
|
4715
4903
|
const known = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
|
|
4716
4904
|
const lines = paths.map(ignorePattern).filter((line) => !known.has(line));
|
|
4717
4905
|
if (lines.length === 0)
|
|
4718
4906
|
return;
|
|
4719
4907
|
const prefix = existing === "" || existing.endsWith("\n") ? "" : "\n";
|
|
4720
|
-
await
|
|
4908
|
+
await writeFile5(file, `${existing}${prefix}${lines.join("\n")}
|
|
4721
4909
|
`, "utf8");
|
|
4722
4910
|
}
|
|
4723
4911
|
/** Команда, чей провал — обычное дело (нет upstream, нет коммитов, detached). */
|
|
@@ -4916,9 +5104,9 @@ function parsePatch(raw) {
|
|
|
4916
5104
|
body = "";
|
|
4917
5105
|
}
|
|
4918
5106
|
total += body.length;
|
|
4919
|
-
const
|
|
5107
|
+
const path26 = status === "deleted" ? oldPath : newPath || oldPath;
|
|
4920
5108
|
files.push({
|
|
4921
|
-
path:
|
|
5109
|
+
path: path26,
|
|
4922
5110
|
oldPath: status === "renamed" ? oldPath : "",
|
|
4923
5111
|
status,
|
|
4924
5112
|
added: count(body, "+"),
|
|
@@ -4930,10 +5118,10 @@ function parsePatch(raw) {
|
|
|
4930
5118
|
return { files, truncated };
|
|
4931
5119
|
}
|
|
4932
5120
|
function stripPrefix(value) {
|
|
4933
|
-
const
|
|
4934
|
-
if (
|
|
5121
|
+
const path26 = unquote(value.trim());
|
|
5122
|
+
if (path26 === "/dev/null")
|
|
4935
5123
|
return "";
|
|
4936
|
-
return
|
|
5124
|
+
return path26.replace(/^[ab]\//, "");
|
|
4937
5125
|
}
|
|
4938
5126
|
function count(body, mark) {
|
|
4939
5127
|
let n = 0;
|
|
@@ -4946,8 +5134,8 @@ function count(body, mark) {
|
|
|
4946
5134
|
|
|
4947
5135
|
// ../host/dist/github.js
|
|
4948
5136
|
import { execFile as execFile5 } from "node:child_process";
|
|
4949
|
-
import { mkdir as
|
|
4950
|
-
import
|
|
5137
|
+
import { mkdir as mkdir5, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
5138
|
+
import path11 from "node:path";
|
|
4951
5139
|
var API = "https://api.github.com";
|
|
4952
5140
|
var API_VERSION = "2022-11-28";
|
|
4953
5141
|
var API_TIMEOUT_MS = 2e4;
|
|
@@ -4968,11 +5156,11 @@ var GitHubAccount = class {
|
|
|
4968
5156
|
*/
|
|
4969
5157
|
#ghInstalled = null;
|
|
4970
5158
|
constructor(dataDir) {
|
|
4971
|
-
this.#storePath =
|
|
5159
|
+
this.#storePath = path11.join(dataDir, "github.json");
|
|
4972
5160
|
}
|
|
4973
5161
|
async load() {
|
|
4974
5162
|
try {
|
|
4975
|
-
const raw = JSON.parse(await
|
|
5163
|
+
const raw = JSON.parse(await readFile7(this.#storePath, "utf8"));
|
|
4976
5164
|
const token = raw.token;
|
|
4977
5165
|
this.#token = typeof token === "string" ? token.trim() : "";
|
|
4978
5166
|
} catch {
|
|
@@ -4982,8 +5170,8 @@ var GitHubAccount = class {
|
|
|
4982
5170
|
/** Сохранить токен или стереть его пустой строкой. */
|
|
4983
5171
|
async setToken(token) {
|
|
4984
5172
|
this.#token = token.trim();
|
|
4985
|
-
await
|
|
4986
|
-
await
|
|
5173
|
+
await mkdir5(path11.dirname(this.#storePath), { recursive: true });
|
|
5174
|
+
await writeFile6(this.#storePath, JSON.stringify({ token: this.#token }, null, 2), {
|
|
4987
5175
|
encoding: "utf8",
|
|
4988
5176
|
mode: 384
|
|
4989
5177
|
});
|
|
@@ -5178,7 +5366,7 @@ function describe4(error) {
|
|
|
5178
5366
|
import { existsSync as existsSync2, statSync } from "node:fs";
|
|
5179
5367
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
5180
5368
|
import os2 from "node:os";
|
|
5181
|
-
import
|
|
5369
|
+
import path12 from "node:path";
|
|
5182
5370
|
import { listSessions } from "@anthropic-ai/claude-agent-sdk";
|
|
5183
5371
|
var CACHE_TTL = 6e4;
|
|
5184
5372
|
var FIND_LIMIT = 50;
|
|
@@ -5186,12 +5374,14 @@ var ROOT_LIMIT = 5;
|
|
|
5186
5374
|
var SKIP_NAMES = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", ".next", "venv"]);
|
|
5187
5375
|
var ProjectFinder = class {
|
|
5188
5376
|
registry;
|
|
5377
|
+
configDirs;
|
|
5189
5378
|
#dirs = [];
|
|
5190
5379
|
#loadedAt = 0;
|
|
5191
5380
|
/** Обновление уже идёт: второй `listSessions()` параллельно первому не нужен. */
|
|
5192
5381
|
#refreshing = null;
|
|
5193
|
-
constructor(registry) {
|
|
5382
|
+
constructor(registry, configDirs = () => [null]) {
|
|
5194
5383
|
this.registry = registry;
|
|
5384
|
+
this.configDirs = configDirs;
|
|
5195
5385
|
}
|
|
5196
5386
|
/**
|
|
5197
5387
|
* Прогреть кэш при старте хоста.
|
|
@@ -5217,7 +5407,7 @@ var ProjectFinder = class {
|
|
|
5217
5407
|
if (needles.length === 0)
|
|
5218
5408
|
return { candidates: [], truncated: false };
|
|
5219
5409
|
const open = new Map(this.registry.list().map((workspace) => [workspace.path.toLowerCase(), workspace]));
|
|
5220
|
-
const byName = this.#dirs.filter((dir) => matches(
|
|
5410
|
+
const byName = this.#dirs.filter((dir) => matches(path12.basename(dir.path), needles));
|
|
5221
5411
|
const matched = byName.length > 0 ? byName : this.#dirs.filter((dir) => matches(dir.path, needles));
|
|
5222
5412
|
const sorted = [...matched].sort((a, b) => {
|
|
5223
5413
|
const aOpen = open.has(a.path.toLowerCase());
|
|
@@ -5228,7 +5418,7 @@ var ProjectFinder = class {
|
|
|
5228
5418
|
return a.sessions > 0 ? -1 : 1;
|
|
5229
5419
|
if (a.lastUsedAt !== b.lastUsedAt)
|
|
5230
5420
|
return b.lastUsedAt - a.lastUsedAt;
|
|
5231
|
-
return
|
|
5421
|
+
return path12.basename(a.path).localeCompare(path12.basename(b.path), void 0, {
|
|
5232
5422
|
numeric: true,
|
|
5233
5423
|
sensitivity: "base"
|
|
5234
5424
|
});
|
|
@@ -5236,7 +5426,7 @@ var ProjectFinder = class {
|
|
|
5236
5426
|
return {
|
|
5237
5427
|
candidates: sorted.slice(0, FIND_LIMIT).map((dir) => ({
|
|
5238
5428
|
path: dir.path,
|
|
5239
|
-
name:
|
|
5429
|
+
name: path12.basename(dir.path) || dir.path,
|
|
5240
5430
|
sessions: dir.sessions,
|
|
5241
5431
|
lastUsedAt: dir.lastUsedAt || null,
|
|
5242
5432
|
open: open.has(dir.path.toLowerCase()),
|
|
@@ -5260,7 +5450,7 @@ var ProjectFinder = class {
|
|
|
5260
5450
|
const candidates = [];
|
|
5261
5451
|
for (const entry of named) {
|
|
5262
5452
|
const absolute = entry.path.trim();
|
|
5263
|
-
if (!absolute || !
|
|
5453
|
+
if (!absolute || !path12.isAbsolute(absolute))
|
|
5264
5454
|
continue;
|
|
5265
5455
|
const key = absolute.toLowerCase();
|
|
5266
5456
|
if (seen.has(key))
|
|
@@ -5271,7 +5461,7 @@ var ProjectFinder = class {
|
|
|
5271
5461
|
const record = known.get(key);
|
|
5272
5462
|
candidates.push({
|
|
5273
5463
|
path: record?.path ?? absolute,
|
|
5274
|
-
name:
|
|
5464
|
+
name: path12.basename(absolute) || absolute,
|
|
5275
5465
|
sessions: record?.sessions ?? 0,
|
|
5276
5466
|
lastUsedAt: record?.lastUsedAt || null,
|
|
5277
5467
|
open: open.has(key),
|
|
@@ -5306,7 +5496,7 @@ var ProjectFinder = class {
|
|
|
5306
5496
|
lastUsedAt: 0
|
|
5307
5497
|
});
|
|
5308
5498
|
}
|
|
5309
|
-
for (const info of await allSessions()) {
|
|
5499
|
+
for (const info of await allSessions(this.configDirs())) {
|
|
5310
5500
|
const cwd = info.cwd;
|
|
5311
5501
|
if (!cwd || !usable(cwd))
|
|
5312
5502
|
continue;
|
|
@@ -5328,7 +5518,7 @@ var ProjectFinder = class {
|
|
|
5328
5518
|
if (!dirent.isDirectory() || SKIP_NAMES.has(dirent.name) || dirent.name.startsWith(".")) {
|
|
5329
5519
|
continue;
|
|
5330
5520
|
}
|
|
5331
|
-
const full =
|
|
5521
|
+
const full = path12.join(parent, dirent.name);
|
|
5332
5522
|
const key = full.toLowerCase();
|
|
5333
5523
|
if (dirs.has(key))
|
|
5334
5524
|
continue;
|
|
@@ -5349,7 +5539,7 @@ var ProjectFinder = class {
|
|
|
5349
5539
|
#parents(dirs) {
|
|
5350
5540
|
const counted = /* @__PURE__ */ new Map();
|
|
5351
5541
|
for (const dir of dirs) {
|
|
5352
|
-
const parent =
|
|
5542
|
+
const parent = path12.dirname(dir.path);
|
|
5353
5543
|
if (parent === dir.path || !usable(parent))
|
|
5354
5544
|
continue;
|
|
5355
5545
|
const key = parent.toLowerCase();
|
|
@@ -5379,12 +5569,15 @@ function isDirectory(dir) {
|
|
|
5379
5569
|
return false;
|
|
5380
5570
|
}
|
|
5381
5571
|
}
|
|
5382
|
-
async function allSessions() {
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5572
|
+
async function allSessions(configDirs) {
|
|
5573
|
+
const all = [];
|
|
5574
|
+
for (const dir of configDirs) {
|
|
5575
|
+
try {
|
|
5576
|
+
all.push(...await withConfigDir(dir, () => listSessions()));
|
|
5577
|
+
} catch {
|
|
5578
|
+
}
|
|
5387
5579
|
}
|
|
5580
|
+
return all;
|
|
5388
5581
|
}
|
|
5389
5582
|
var FINDER_SCHEMA = {
|
|
5390
5583
|
type: "object",
|
|
@@ -5461,18 +5654,18 @@ function fromText(text) {
|
|
|
5461
5654
|
|
|
5462
5655
|
// ../host/dist/workspaces.js
|
|
5463
5656
|
import { existsSync as existsSync3, statSync as statSync2 } from "node:fs";
|
|
5464
|
-
import { mkdir as
|
|
5465
|
-
import
|
|
5657
|
+
import { mkdir as mkdir6, readFile as readFile8, writeFile as writeFile7 } from "node:fs/promises";
|
|
5658
|
+
import path13 from "node:path";
|
|
5466
5659
|
import { listSessions as listSessions2 } from "@anthropic-ai/claude-agent-sdk";
|
|
5467
5660
|
var WorkspaceRegistry = class {
|
|
5468
5661
|
#entries = [];
|
|
5469
5662
|
#storePath;
|
|
5470
5663
|
constructor(dataDir) {
|
|
5471
|
-
this.#storePath =
|
|
5664
|
+
this.#storePath = path13.join(dataDir, "workspaces.json");
|
|
5472
5665
|
}
|
|
5473
5666
|
async load() {
|
|
5474
5667
|
try {
|
|
5475
|
-
const raw = await
|
|
5668
|
+
const raw = await readFile8(this.#storePath, "utf8");
|
|
5476
5669
|
const parsed = JSON.parse(raw);
|
|
5477
5670
|
if (!Array.isArray(parsed)) {
|
|
5478
5671
|
this.#entries = [];
|
|
@@ -5490,8 +5683,8 @@ var WorkspaceRegistry = class {
|
|
|
5490
5683
|
}
|
|
5491
5684
|
}
|
|
5492
5685
|
async #persist() {
|
|
5493
|
-
await
|
|
5494
|
-
await
|
|
5686
|
+
await mkdir6(path13.dirname(this.#storePath), { recursive: true });
|
|
5687
|
+
await writeFile7(this.#storePath, JSON.stringify(this.#entries, null, 2), "utf8");
|
|
5495
5688
|
}
|
|
5496
5689
|
/** Активные проекты. */
|
|
5497
5690
|
list() {
|
|
@@ -5510,7 +5703,7 @@ var WorkspaceRegistry = class {
|
|
|
5510
5703
|
return entry ? toInfo(entry) : void 0;
|
|
5511
5704
|
}
|
|
5512
5705
|
async open(rawPath) {
|
|
5513
|
-
const absolute =
|
|
5706
|
+
const absolute = path13.resolve(rawPath);
|
|
5514
5707
|
if (!existsSync3(absolute)) {
|
|
5515
5708
|
throw new Error(`\u041A\u0430\u0442\u0430\u043B\u043E\u0433 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${absolute}`);
|
|
5516
5709
|
}
|
|
@@ -5577,40 +5770,53 @@ var WorkspaceRegistry = class {
|
|
|
5577
5770
|
async create(parentRaw, nameRaw, init) {
|
|
5578
5771
|
const name = nameRaw.trim();
|
|
5579
5772
|
requireName(name);
|
|
5580
|
-
const parent =
|
|
5773
|
+
const parent = path13.resolve(parentRaw.trim());
|
|
5581
5774
|
if (!existsSync3(parent)) {
|
|
5582
5775
|
throw new Error(`\u041A\u0430\u0442\u0430\u043B\u043E\u0433 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${parent}`);
|
|
5583
5776
|
}
|
|
5584
5777
|
if (!statSync2(parent).isDirectory()) {
|
|
5585
5778
|
throw new Error(`\u042D\u0442\u043E \u043D\u0435 \u043A\u0430\u0442\u0430\u043B\u043E\u0433: ${parent}`);
|
|
5586
5779
|
}
|
|
5587
|
-
const target =
|
|
5780
|
+
const target = path13.join(parent, name);
|
|
5588
5781
|
if (existsSync3(target)) {
|
|
5589
5782
|
throw new Error(`\u0423\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442: ${target} \u2014 \u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0435\u0433\u043E \u043A\u0430\u043A \u043F\u0440\u043E\u0435\u043A\u0442`);
|
|
5590
5783
|
}
|
|
5591
|
-
await
|
|
5784
|
+
await mkdir6(target);
|
|
5592
5785
|
const warnings = [];
|
|
5593
5786
|
if (init.claudeMd) {
|
|
5594
|
-
await step(warnings, "CLAUDE.md", () =>
|
|
5787
|
+
await step(warnings, "CLAUDE.md", () => writeFile7(path13.join(target, "CLAUDE.md"), claudeMdStub(name), "utf8"));
|
|
5595
5788
|
}
|
|
5596
5789
|
if (init.readme) {
|
|
5597
|
-
await step(warnings, "README.md", () =>
|
|
5790
|
+
await step(warnings, "README.md", () => writeFile7(path13.join(target, "README.md"), readmeStub(name), "utf8"));
|
|
5598
5791
|
}
|
|
5599
5792
|
if (init.git) {
|
|
5600
5793
|
await step(warnings, "git init", () => new GitRepo(target).init());
|
|
5601
5794
|
}
|
|
5602
5795
|
return { workspace: await this.open(target), warnings };
|
|
5603
5796
|
}
|
|
5604
|
-
/**
|
|
5605
|
-
|
|
5797
|
+
/**
|
|
5798
|
+
* Сессии Claude Code, уже лежащие на диске для этого каталога, — по всем
|
|
5799
|
+
* аккаунтам: у каждого свой каталог конфигурации и свои транскрипты.
|
|
5800
|
+
*/
|
|
5801
|
+
async sessionsOnDisk(workspaceId, accounts = [{ id: MAIN_ACCOUNT_ID, configDir: null }]) {
|
|
5606
5802
|
const workspace = this.find(workspaceId);
|
|
5607
5803
|
if (!workspace)
|
|
5608
5804
|
return [];
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5805
|
+
const found = [];
|
|
5806
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5807
|
+
for (const account of accounts) {
|
|
5808
|
+
try {
|
|
5809
|
+
const sessions = await withConfigDir(account.configDir, () => listSessions2({ dir: workspace.path }));
|
|
5810
|
+
for (const info of sessions) {
|
|
5811
|
+
if (seen.has(info.sessionId))
|
|
5812
|
+
continue;
|
|
5813
|
+
seen.add(info.sessionId);
|
|
5814
|
+
found.push({ ...info, accountId: account.id });
|
|
5815
|
+
}
|
|
5816
|
+
} catch {
|
|
5817
|
+
}
|
|
5613
5818
|
}
|
|
5819
|
+
return found;
|
|
5614
5820
|
}
|
|
5615
5821
|
};
|
|
5616
5822
|
var RESERVED = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/i;
|
|
@@ -5635,9 +5841,9 @@ function requireName(name) {
|
|
|
5635
5841
|
throw new Error(`\xAB${name}\xBB \u2014 \u0437\u0430\u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u043E\u0435 \u0438\u043C\u044F \u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0430 Windows`);
|
|
5636
5842
|
}
|
|
5637
5843
|
}
|
|
5638
|
-
async function step(warnings, what,
|
|
5844
|
+
async function step(warnings, what, run) {
|
|
5639
5845
|
try {
|
|
5640
|
-
await
|
|
5846
|
+
await run();
|
|
5641
5847
|
} catch (error) {
|
|
5642
5848
|
warnings.push(`${what}: ${error instanceof Error ? error.message : String(error)}`);
|
|
5643
5849
|
}
|
|
@@ -5666,8 +5872,8 @@ function toInfo(entry) {
|
|
|
5666
5872
|
return {
|
|
5667
5873
|
id: workspaceIdFromPath(absolute),
|
|
5668
5874
|
path: absolute,
|
|
5669
|
-
name:
|
|
5670
|
-
hasClaudeMd: existsSync3(
|
|
5875
|
+
name: path13.basename(absolute) || absolute,
|
|
5876
|
+
hasClaudeMd: existsSync3(path13.join(absolute, "CLAUDE.md")),
|
|
5671
5877
|
...archivedAt ? { archivedAt } : {}
|
|
5672
5878
|
};
|
|
5673
5879
|
}
|
|
@@ -5676,18 +5882,18 @@ function isEntry(value) {
|
|
|
5676
5882
|
}
|
|
5677
5883
|
|
|
5678
5884
|
// ../host/dist/archive.js
|
|
5679
|
-
import { mkdir as
|
|
5680
|
-
import
|
|
5885
|
+
import { mkdir as mkdir7, readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
|
|
5886
|
+
import path14 from "node:path";
|
|
5681
5887
|
var SessionArchive = class {
|
|
5682
5888
|
#archived = /* @__PURE__ */ new Map();
|
|
5683
5889
|
#restored = /* @__PURE__ */ new Map();
|
|
5684
5890
|
#storePath;
|
|
5685
5891
|
constructor(dataDir) {
|
|
5686
|
-
this.#storePath =
|
|
5892
|
+
this.#storePath = path14.join(dataDir, "session-archive.json");
|
|
5687
5893
|
}
|
|
5688
5894
|
async load() {
|
|
5689
5895
|
try {
|
|
5690
|
-
const raw = await
|
|
5896
|
+
const raw = await readFile9(this.#storePath, "utf8");
|
|
5691
5897
|
const parsed = JSON.parse(raw);
|
|
5692
5898
|
this.#archived = new Map(Object.entries(parsed.archived ?? {}).filter(([, r]) => isRecord(r)));
|
|
5693
5899
|
this.#restored = new Map(Object.entries(parsed.restored ?? {}).filter((entry) => typeof entry[1] === "number"));
|
|
@@ -5795,8 +6001,8 @@ var SessionArchive = class {
|
|
|
5795
6001
|
archived: Object.fromEntries(this.#archived),
|
|
5796
6002
|
restored: Object.fromEntries(this.#restored)
|
|
5797
6003
|
};
|
|
5798
|
-
await
|
|
5799
|
-
await
|
|
6004
|
+
await mkdir7(path14.dirname(this.#storePath), { recursive: true });
|
|
6005
|
+
await writeFile8(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
5800
6006
|
}
|
|
5801
6007
|
};
|
|
5802
6008
|
function isRecord(value) {
|
|
@@ -5804,8 +6010,8 @@ function isRecord(value) {
|
|
|
5804
6010
|
}
|
|
5805
6011
|
|
|
5806
6012
|
// ../host/dist/pins.js
|
|
5807
|
-
import { mkdir as
|
|
5808
|
-
import
|
|
6013
|
+
import { mkdir as mkdir8, readFile as readFile10, writeFile as writeFile9 } from "node:fs/promises";
|
|
6014
|
+
import path15 from "node:path";
|
|
5809
6015
|
var SessionPins = class {
|
|
5810
6016
|
#pinned = /* @__PURE__ */ new Map();
|
|
5811
6017
|
/**
|
|
@@ -5820,11 +6026,11 @@ var SessionPins = class {
|
|
|
5820
6026
|
#moved = /* @__PURE__ */ new Map();
|
|
5821
6027
|
#storePath;
|
|
5822
6028
|
constructor(dataDir) {
|
|
5823
|
-
this.#storePath =
|
|
6029
|
+
this.#storePath = path15.join(dataDir, "session-pins.json");
|
|
5824
6030
|
}
|
|
5825
6031
|
async load() {
|
|
5826
6032
|
try {
|
|
5827
|
-
const raw = await
|
|
6033
|
+
const raw = await readFile10(this.#storePath, "utf8");
|
|
5828
6034
|
const parsed = JSON.parse(raw);
|
|
5829
6035
|
this.#pinned = new Map(Object.entries(parsed.pinned ?? {}).filter(([, r]) => isRecord2(r)));
|
|
5830
6036
|
this.#moved = new Map(Object.entries(parsed.moved ?? {}).filter(([, to]) => typeof to === "string"));
|
|
@@ -5977,8 +6183,8 @@ var SessionPins = class {
|
|
|
5977
6183
|
pinned: Object.fromEntries(this.#pinned),
|
|
5978
6184
|
...this.#moved.size > 0 ? { moved: Object.fromEntries(this.#moved) } : {}
|
|
5979
6185
|
};
|
|
5980
|
-
await
|
|
5981
|
-
await
|
|
6186
|
+
await mkdir8(path15.dirname(this.#storePath), { recursive: true });
|
|
6187
|
+
await writeFile9(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
5982
6188
|
}
|
|
5983
6189
|
};
|
|
5984
6190
|
function isRecord2(value) {
|
|
@@ -5986,17 +6192,17 @@ function isRecord2(value) {
|
|
|
5986
6192
|
}
|
|
5987
6193
|
|
|
5988
6194
|
// ../host/dist/order.js
|
|
5989
|
-
import { mkdir as
|
|
5990
|
-
import
|
|
6195
|
+
import { mkdir as mkdir9, readFile as readFile11, writeFile as writeFile10 } from "node:fs/promises";
|
|
6196
|
+
import path16 from "node:path";
|
|
5991
6197
|
var ListOrderStore = class {
|
|
5992
6198
|
#order = emptyOrder();
|
|
5993
6199
|
#storePath;
|
|
5994
6200
|
constructor(dataDir) {
|
|
5995
|
-
this.#storePath =
|
|
6201
|
+
this.#storePath = path16.join(dataDir, "list-order.json");
|
|
5996
6202
|
}
|
|
5997
6203
|
async load() {
|
|
5998
6204
|
try {
|
|
5999
|
-
const raw = await
|
|
6205
|
+
const raw = await readFile11(this.#storePath, "utf8");
|
|
6000
6206
|
this.#order = sanitize(JSON.parse(raw));
|
|
6001
6207
|
} catch {
|
|
6002
6208
|
this.#order = emptyOrder();
|
|
@@ -6068,8 +6274,8 @@ var ListOrderStore = class {
|
|
|
6068
6274
|
return changed;
|
|
6069
6275
|
}
|
|
6070
6276
|
async #persist() {
|
|
6071
|
-
await
|
|
6072
|
-
await
|
|
6277
|
+
await mkdir9(path16.dirname(this.#storePath), { recursive: true });
|
|
6278
|
+
await writeFile10(this.#storePath, JSON.stringify(this.#order, null, 2), "utf8");
|
|
6073
6279
|
}
|
|
6074
6280
|
};
|
|
6075
6281
|
function emptyOrder() {
|
|
@@ -6098,9 +6304,9 @@ function sanitize(value) {
|
|
|
6098
6304
|
}
|
|
6099
6305
|
|
|
6100
6306
|
// ../host/dist/folders.js
|
|
6101
|
-
import { mkdir as
|
|
6102
|
-
import
|
|
6103
|
-
import { randomUUID as
|
|
6307
|
+
import { mkdir as mkdir10, readFile as readFile12, writeFile as writeFile11 } from "node:fs/promises";
|
|
6308
|
+
import path17 from "node:path";
|
|
6309
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
6104
6310
|
var COLOR_PATTERN = /^#[0-9a-f]{6}$/i;
|
|
6105
6311
|
var Folders = class {
|
|
6106
6312
|
#workspaceFolders = /* @__PURE__ */ new Map();
|
|
@@ -6111,11 +6317,11 @@ var Folders = class {
|
|
|
6111
6317
|
#pinnedAssignments = /* @__PURE__ */ new Map();
|
|
6112
6318
|
#storePath;
|
|
6113
6319
|
constructor(dataDir) {
|
|
6114
|
-
this.#storePath =
|
|
6320
|
+
this.#storePath = path17.join(dataDir, "folders.json");
|
|
6115
6321
|
}
|
|
6116
6322
|
async load() {
|
|
6117
6323
|
try {
|
|
6118
|
-
const raw = await
|
|
6324
|
+
const raw = await readFile12(this.#storePath, "utf8");
|
|
6119
6325
|
const parsed = JSON.parse(raw);
|
|
6120
6326
|
this.#workspaceFolders = new Map(Object.entries(parsed.workspaceFolders ?? {}).filter(([, r]) => isWorkspaceFolder(r)).map(([id, r]) => [id, withValidColor(r)]));
|
|
6121
6327
|
this.#sessionFolders = new Map(Object.entries(parsed.sessionFolders ?? {}).filter(([, r]) => isSessionFolder(r)).map(([id, r]) => [id, withValidColor(r)]));
|
|
@@ -6200,19 +6406,19 @@ var Folders = class {
|
|
|
6200
6406
|
};
|
|
6201
6407
|
}
|
|
6202
6408
|
async createWorkspaceFolder(name) {
|
|
6203
|
-
const id =
|
|
6409
|
+
const id = randomUUID4();
|
|
6204
6410
|
this.#workspaceFolders.set(id, { name });
|
|
6205
6411
|
await this.#persist();
|
|
6206
6412
|
return id;
|
|
6207
6413
|
}
|
|
6208
6414
|
async createSessionFolder(workspaceId, name) {
|
|
6209
|
-
const id =
|
|
6415
|
+
const id = randomUUID4();
|
|
6210
6416
|
this.#sessionFolders.set(id, { name, workspaceId });
|
|
6211
6417
|
await this.#persist();
|
|
6212
6418
|
return id;
|
|
6213
6419
|
}
|
|
6214
6420
|
async createPinnedFolder(name) {
|
|
6215
|
-
const id =
|
|
6421
|
+
const id = randomUUID4();
|
|
6216
6422
|
this.#pinnedFolders.set(id, { name });
|
|
6217
6423
|
await this.#persist();
|
|
6218
6424
|
return id;
|
|
@@ -6392,8 +6598,8 @@ var Folders = class {
|
|
|
6392
6598
|
sessionAssignments: Object.fromEntries(this.#sessionAssignments),
|
|
6393
6599
|
pinnedAssignments: Object.fromEntries(this.#pinnedAssignments)
|
|
6394
6600
|
};
|
|
6395
|
-
await
|
|
6396
|
-
await
|
|
6601
|
+
await mkdir10(path17.dirname(this.#storePath), { recursive: true });
|
|
6602
|
+
await writeFile11(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
6397
6603
|
}
|
|
6398
6604
|
};
|
|
6399
6605
|
function withValidColor(record) {
|
|
@@ -6414,9 +6620,9 @@ function isPinnedFolder(value) {
|
|
|
6414
6620
|
}
|
|
6415
6621
|
|
|
6416
6622
|
// ../host/dist/app-settings.js
|
|
6417
|
-
import { mkdir as
|
|
6418
|
-
import { homedir as
|
|
6419
|
-
import
|
|
6623
|
+
import { mkdir as mkdir11, readFile as readFile13, writeFile as writeFile12 } from "node:fs/promises";
|
|
6624
|
+
import { homedir as homedir5 } from "node:os";
|
|
6625
|
+
import path18 from "node:path";
|
|
6420
6626
|
var DEFAULT_AUTO_ARCHIVE_AFTER_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
6421
6627
|
var MIN_AUTO_ARCHIVE_AFTER_MS = 60 * 60 * 1e3;
|
|
6422
6628
|
var DEFAULT_AUTO_STOP_AFTER_MS = 10 * 60 * 1e3;
|
|
@@ -6469,11 +6675,11 @@ var AppSettingsStore = class {
|
|
|
6469
6675
|
#settings = { ...DEFAULT_APP_SETTINGS };
|
|
6470
6676
|
#storePath;
|
|
6471
6677
|
constructor(dataDir) {
|
|
6472
|
-
this.#storePath =
|
|
6678
|
+
this.#storePath = path18.join(dataDir, "app-settings.json");
|
|
6473
6679
|
}
|
|
6474
6680
|
async load() {
|
|
6475
6681
|
try {
|
|
6476
|
-
const raw = await
|
|
6682
|
+
const raw = await readFile13(this.#storePath, "utf8");
|
|
6477
6683
|
this.#settings = sanitize2(JSON.parse(raw), DEFAULT_APP_SETTINGS);
|
|
6478
6684
|
} catch {
|
|
6479
6685
|
this.#settings = { ...DEFAULT_APP_SETTINGS };
|
|
@@ -6493,8 +6699,8 @@ var AppSettingsStore = class {
|
|
|
6493
6699
|
async update(patch) {
|
|
6494
6700
|
const next = sanitize2(patch, this.#settings);
|
|
6495
6701
|
this.#settings = next;
|
|
6496
|
-
await
|
|
6497
|
-
await
|
|
6702
|
+
await mkdir11(path18.dirname(this.#storePath), { recursive: true });
|
|
6703
|
+
await writeFile12(this.#storePath, JSON.stringify(next, null, 2), "utf8");
|
|
6498
6704
|
return this.current;
|
|
6499
6705
|
}
|
|
6500
6706
|
};
|
|
@@ -6560,7 +6766,7 @@ function sanitize2(value, fallback) {
|
|
|
6560
6766
|
return result;
|
|
6561
6767
|
}
|
|
6562
6768
|
function claudeHome() {
|
|
6563
|
-
return
|
|
6769
|
+
return path18.join(homedir5(), ".claude");
|
|
6564
6770
|
}
|
|
6565
6771
|
function writableRoots(mode, cwd, workspacePaths) {
|
|
6566
6772
|
if (mode === "all")
|
|
@@ -6570,7 +6776,7 @@ function writableRoots(mode, cwd, workspacePaths) {
|
|
|
6570
6776
|
return [...roots];
|
|
6571
6777
|
for (const workspace of [cwd, ...workspacePaths]) {
|
|
6572
6778
|
roots.add(workspace);
|
|
6573
|
-
const parent =
|
|
6779
|
+
const parent = path18.dirname(workspace);
|
|
6574
6780
|
if (parent !== workspace)
|
|
6575
6781
|
roots.add(parent);
|
|
6576
6782
|
}
|
|
@@ -6578,19 +6784,19 @@ function writableRoots(mode, cwd, workspacePaths) {
|
|
|
6578
6784
|
}
|
|
6579
6785
|
|
|
6580
6786
|
// ../host/dist/handoff-store.js
|
|
6581
|
-
import { mkdir as
|
|
6582
|
-
import
|
|
6787
|
+
import { mkdir as mkdir12, readFile as readFile14, readdir as readdir3, rm as rm4, writeFile as writeFile13 } from "node:fs/promises";
|
|
6788
|
+
import path19 from "node:path";
|
|
6583
6789
|
var HandoffStore = class {
|
|
6584
6790
|
#dir;
|
|
6585
6791
|
constructor(dataDir) {
|
|
6586
|
-
this.#dir =
|
|
6792
|
+
this.#dir = path19.join(dataDir, "handoffs");
|
|
6587
6793
|
}
|
|
6588
6794
|
async get(sessionId) {
|
|
6589
6795
|
const file = this.#file(sessionId);
|
|
6590
6796
|
if (!file)
|
|
6591
6797
|
return null;
|
|
6592
6798
|
try {
|
|
6593
|
-
const parsed = JSON.parse(await
|
|
6799
|
+
const parsed = JSON.parse(await readFile14(file, "utf8"));
|
|
6594
6800
|
return typeof parsed.text === "string" ? parsed : null;
|
|
6595
6801
|
} catch {
|
|
6596
6802
|
return null;
|
|
@@ -6600,8 +6806,8 @@ var HandoffStore = class {
|
|
|
6600
6806
|
const file = this.#file(handoff.sessionId);
|
|
6601
6807
|
if (!file)
|
|
6602
6808
|
return;
|
|
6603
|
-
await
|
|
6604
|
-
await
|
|
6809
|
+
await mkdir12(this.#dir, { recursive: true });
|
|
6810
|
+
await writeFile13(file, JSON.stringify(handoff, null, 2), "utf8");
|
|
6605
6811
|
}
|
|
6606
6812
|
async remove(sessionId) {
|
|
6607
6813
|
const file = this.#file(sessionId);
|
|
@@ -6620,29 +6826,47 @@ var HandoffStore = class {
|
|
|
6620
6826
|
#file(sessionId) {
|
|
6621
6827
|
if (!/^[\w-]{1,128}$/.test(sessionId))
|
|
6622
6828
|
return null;
|
|
6623
|
-
return
|
|
6829
|
+
return path19.join(this.#dir, `${sessionId}.json`);
|
|
6624
6830
|
}
|
|
6625
6831
|
};
|
|
6626
6832
|
var SAME_WINDOW_MS = 5 * 6e4;
|
|
6627
6833
|
var LimitStopState = class {
|
|
6834
|
+
/** Аккаунт → окно → срок. Лимиты у каждого аккаунта свои, и сработавшее окно одного чужому не помеха. */
|
|
6628
6835
|
#fired = {};
|
|
6629
6836
|
#storePath;
|
|
6630
6837
|
constructor(dataDir) {
|
|
6631
|
-
this.#storePath =
|
|
6838
|
+
this.#storePath = path19.join(dataDir, "limit-stop.json");
|
|
6632
6839
|
}
|
|
6633
6840
|
async load() {
|
|
6634
6841
|
try {
|
|
6635
|
-
const parsed = JSON.parse(await
|
|
6842
|
+
const parsed = JSON.parse(await readFile14(this.#storePath, "utf8"));
|
|
6636
6843
|
this.#fired = {};
|
|
6637
|
-
|
|
6638
|
-
const
|
|
6639
|
-
|
|
6640
|
-
|
|
6844
|
+
const read = (source) => {
|
|
6845
|
+
const out = {};
|
|
6846
|
+
for (const key of ["fiveHour", "sevenDay"]) {
|
|
6847
|
+
const until = source[key];
|
|
6848
|
+
if (typeof until === "number" && Number.isFinite(until))
|
|
6849
|
+
out[key] = until;
|
|
6850
|
+
}
|
|
6851
|
+
return out;
|
|
6852
|
+
};
|
|
6853
|
+
this.#fired[MAIN_ACCOUNT_ID] = read(parsed);
|
|
6854
|
+
for (const [account, value] of Object.entries(parsed)) {
|
|
6855
|
+
if (value && typeof value === "object")
|
|
6856
|
+
this.#fired[account] = read(value);
|
|
6641
6857
|
}
|
|
6642
6858
|
} catch {
|
|
6643
6859
|
this.#fired = {};
|
|
6644
6860
|
}
|
|
6645
6861
|
}
|
|
6862
|
+
/** Срабатывания одного аккаунта. */
|
|
6863
|
+
forAccount(account) {
|
|
6864
|
+
return {
|
|
6865
|
+
fired: (limit, resets, now = Date.now()) => this.#isFired(account, limit, resets, now),
|
|
6866
|
+
until: (limit) => this.#fired[account]?.[limit] ?? 0,
|
|
6867
|
+
mark: (limit, until) => this.#mark(account, limit, until)
|
|
6868
|
+
};
|
|
6869
|
+
}
|
|
6646
6870
|
/**
|
|
6647
6871
|
* Окно `limit` со сроком сброса `resets` уже сработало и ещё не сбросилось.
|
|
6648
6872
|
*
|
|
@@ -6651,21 +6875,17 @@ var LimitStopState = class {
|
|
|
6651
6875
|
* 7.10 новое окно до 21:20 пропустили, приняв его за сработавшее до 20:30).
|
|
6652
6876
|
* `null` — срок не разобрать, сверять не с чем, решает только записанный.
|
|
6653
6877
|
*/
|
|
6654
|
-
|
|
6655
|
-
const until = this.#fired[limit] ?? 0;
|
|
6878
|
+
#isFired(account, limit, resets, now) {
|
|
6879
|
+
const until = this.#fired[account]?.[limit] ?? 0;
|
|
6656
6880
|
if (until <= now)
|
|
6657
6881
|
return false;
|
|
6658
6882
|
return resets === null || Math.abs(resets - until) <= SAME_WINDOW_MS;
|
|
6659
6883
|
}
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
async mark(limit, until) {
|
|
6666
|
-
this.#fired[limit] = until;
|
|
6667
|
-
await mkdir11(path18.dirname(this.#storePath), { recursive: true });
|
|
6668
|
-
await writeFile12(this.#storePath, JSON.stringify(this.#fired, null, 2), "utf8");
|
|
6884
|
+
async #mark(account, limit, until) {
|
|
6885
|
+
this.#fired[account] = { ...this.#fired[account], [limit]: until };
|
|
6886
|
+
await mkdir12(path19.dirname(this.#storePath), { recursive: true });
|
|
6887
|
+
const { [MAIN_ACCOUNT_ID]: main = {}, ...others } = this.#fired;
|
|
6888
|
+
await writeFile13(this.#storePath, JSON.stringify({ ...main, ...others }, null, 2), "utf8");
|
|
6669
6889
|
}
|
|
6670
6890
|
};
|
|
6671
6891
|
|
|
@@ -6769,9 +6989,9 @@ function capitalize(text) {
|
|
|
6769
6989
|
}
|
|
6770
6990
|
|
|
6771
6991
|
// ../host/dist/plugins.js
|
|
6772
|
-
import { readFile as
|
|
6773
|
-
import { homedir as
|
|
6774
|
-
import
|
|
6992
|
+
import { readFile as readFile15 } from "node:fs/promises";
|
|
6993
|
+
import { homedir as homedir6 } from "node:os";
|
|
6994
|
+
import path20 from "node:path";
|
|
6775
6995
|
var TIMEOUT_MS2 = 12e4;
|
|
6776
6996
|
var SAFE_ARG = /^[A-Za-z0-9][A-Za-z0-9._@/-]*$/;
|
|
6777
6997
|
var PluginCli = class {
|
|
@@ -6870,10 +7090,10 @@ async function readCatalog(markets, installed) {
|
|
|
6870
7090
|
return lists.flat().sort((a, b) => a.name.localeCompare(b.name));
|
|
6871
7091
|
}
|
|
6872
7092
|
async function readMarketplace(market, installed) {
|
|
6873
|
-
const root = market.installLocation ||
|
|
7093
|
+
const root = market.installLocation || path20.join(homedir6(), ".claude", "plugins", "marketplaces", market.name);
|
|
6874
7094
|
let manifest;
|
|
6875
7095
|
try {
|
|
6876
|
-
const text = await
|
|
7096
|
+
const text = await readFile15(path20.join(root, ".claude-plugin", "marketplace.json"), "utf8");
|
|
6877
7097
|
manifest = JSON.parse(text);
|
|
6878
7098
|
} catch {
|
|
6879
7099
|
return [];
|
|
@@ -6929,11 +7149,18 @@ var IDLE = {
|
|
|
6929
7149
|
error: null
|
|
6930
7150
|
};
|
|
6931
7151
|
var AuthCli = class extends EventEmitter4 {
|
|
7152
|
+
configDir;
|
|
6932
7153
|
#child = null;
|
|
6933
7154
|
#state = IDLE;
|
|
6934
7155
|
#timer = null;
|
|
6935
|
-
|
|
7156
|
+
/**
|
|
7157
|
+
* `configDir` — каталог конфигурации аккаунта, чей это вход (`null` —
|
|
7158
|
+
* унаследованный). Один `AuthCli` — один аккаунт: у каждого свой вход, своя
|
|
7159
|
+
* ссылка и свой код, и параллельные входы двух аккаунтов не мешают друг другу.
|
|
7160
|
+
*/
|
|
7161
|
+
constructor(configDir = null) {
|
|
6936
7162
|
super();
|
|
7163
|
+
this.configDir = configDir;
|
|
6937
7164
|
void warmClaudeLauncher();
|
|
6938
7165
|
}
|
|
6939
7166
|
get loginState() {
|
|
@@ -6941,7 +7168,7 @@ var AuthCli = class extends EventEmitter4 {
|
|
|
6941
7168
|
}
|
|
6942
7169
|
/** Кто вошёл. Незалогиненный CLI — не ошибка, а обычный ответ. */
|
|
6943
7170
|
async status() {
|
|
6944
|
-
const raw = await run(["auth", "status", "--json"]
|
|
7171
|
+
const raw = await this.#run(["auth", "status", "--json"]).catch(
|
|
6945
7172
|
// Старый CLI мог не знать `auth status`. Показать «не вошёл» честнее,
|
|
6946
7173
|
// чем уронить окно: сессии всё равно расскажут, работает ли ключ.
|
|
6947
7174
|
() => ""
|
|
@@ -6960,7 +7187,7 @@ var AuthCli = class extends EventEmitter4 {
|
|
|
6960
7187
|
if (this.#child)
|
|
6961
7188
|
throw new Error("\u0412\u0445\u043E\u0434 \u0443\u0436\u0435 \u0438\u0434\u0451\u0442 \u2014 \u0434\u043E\u0436\u0434\u0438\u0442\u0435\u0441\u044C \u0438\u043B\u0438 \u043E\u0442\u043C\u0435\u043D\u0438\u0442\u0435 \u0435\u0433\u043E");
|
|
6962
7189
|
if (switchAccount) {
|
|
6963
|
-
const out = await run(["auth", "logout"]
|
|
7190
|
+
const out = await this.#run(["auth", "logout"]).catch(describe5);
|
|
6964
7191
|
this.#push({ ...IDLE, active: true, output: `${out}
|
|
6965
7192
|
` });
|
|
6966
7193
|
this.emit("changed");
|
|
@@ -6968,7 +7195,7 @@ var AuthCli = class extends EventEmitter4 {
|
|
|
6968
7195
|
this.#push({ ...IDLE, active: true });
|
|
6969
7196
|
}
|
|
6970
7197
|
const args = ["auth", "login", mode === "console" ? "--console" : "--claudeai"];
|
|
6971
|
-
const child = await spawnClaude(args);
|
|
7198
|
+
const child = await spawnClaude(args, this.configDir ? accountEnv(this.configDir) : void 0);
|
|
6972
7199
|
if (!this.#state.active) {
|
|
6973
7200
|
child.kill();
|
|
6974
7201
|
return;
|
|
@@ -7020,11 +7247,18 @@ var AuthCli = class extends EventEmitter4 {
|
|
|
7020
7247
|
}
|
|
7021
7248
|
async logout() {
|
|
7022
7249
|
this.cancel();
|
|
7023
|
-
const output = await run(["auth", "logout"]
|
|
7250
|
+
const output = await this.#run(["auth", "logout"]);
|
|
7024
7251
|
this.#push({ ...IDLE, output });
|
|
7025
7252
|
this.emit("changed");
|
|
7026
7253
|
}
|
|
7027
7254
|
// -------------------------------------------------------------------------
|
|
7255
|
+
#run(args) {
|
|
7256
|
+
return runClaude(args, {
|
|
7257
|
+
timeout: QUICK_TIMEOUT_MS,
|
|
7258
|
+
missing: "\u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u043C \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E",
|
|
7259
|
+
...this.configDir ? { env: accountEnv(this.configDir) } : {}
|
|
7260
|
+
});
|
|
7261
|
+
}
|
|
7028
7262
|
#absorb(text) {
|
|
7029
7263
|
const output = this.#state.output + text;
|
|
7030
7264
|
this.#push({
|
|
@@ -7059,9 +7293,6 @@ var AuthCli = class extends EventEmitter4 {
|
|
|
7059
7293
|
this.emit("login", state);
|
|
7060
7294
|
}
|
|
7061
7295
|
};
|
|
7062
|
-
function run(args, timeout) {
|
|
7063
|
-
return runClaude(args, { timeout, missing: "\u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u043C \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E" });
|
|
7064
|
-
}
|
|
7065
7296
|
function normalizeAuthCode(raw) {
|
|
7066
7297
|
const value = raw.trim();
|
|
7067
7298
|
if (!/^https?:\/\//i.test(value))
|
|
@@ -7114,8 +7345,8 @@ function describe5(error) {
|
|
|
7114
7345
|
|
|
7115
7346
|
// ../host/dist/relay-link.js
|
|
7116
7347
|
import { EventEmitter as EventEmitter5 } from "node:events";
|
|
7117
|
-
import { readFile as
|
|
7118
|
-
import
|
|
7348
|
+
import { readFile as readFile16, writeFile as writeFile14, rm as rm5, mkdir as mkdir13 } from "node:fs/promises";
|
|
7349
|
+
import path21 from "node:path";
|
|
7119
7350
|
import { hostname } from "node:os";
|
|
7120
7351
|
import WebSocket from "ws";
|
|
7121
7352
|
|
|
@@ -7170,7 +7401,7 @@ var RelayLink = class extends EventEmitter5 {
|
|
|
7170
7401
|
#log;
|
|
7171
7402
|
constructor(options2) {
|
|
7172
7403
|
super();
|
|
7173
|
-
this.#file =
|
|
7404
|
+
this.#file = path21.join(options2.dataDir, "relay.json");
|
|
7174
7405
|
this.#defaultUrl = options2.defaultUrl.replace(/\/+$/, "");
|
|
7175
7406
|
this.#log = options2.log ?? ((msg) => console.log(`[relay] ${msg}`));
|
|
7176
7407
|
}
|
|
@@ -7251,7 +7482,7 @@ var RelayLink = class extends EventEmitter5 {
|
|
|
7251
7482
|
}
|
|
7252
7483
|
async #read() {
|
|
7253
7484
|
try {
|
|
7254
|
-
const raw = await
|
|
7485
|
+
const raw = await readFile16(this.#file, "utf8");
|
|
7255
7486
|
const parsed = JSON.parse(raw);
|
|
7256
7487
|
if (typeof parsed !== "object" || parsed === null)
|
|
7257
7488
|
return null;
|
|
@@ -7264,8 +7495,8 @@ var RelayLink = class extends EventEmitter5 {
|
|
|
7264
7495
|
}
|
|
7265
7496
|
}
|
|
7266
7497
|
async #write(credentials) {
|
|
7267
|
-
await
|
|
7268
|
-
await
|
|
7498
|
+
await mkdir13(path21.dirname(this.#file), { recursive: true });
|
|
7499
|
+
await writeFile14(this.#file, `${JSON.stringify(credentials, null, 2)}
|
|
7269
7500
|
`, {
|
|
7270
7501
|
encoding: "utf8",
|
|
7271
7502
|
mode: 384
|
|
@@ -7522,8 +7753,8 @@ function humanize(error) {
|
|
|
7522
7753
|
// ../host/dist/terminal.js
|
|
7523
7754
|
import { EventEmitter as EventEmitter6 } from "node:events";
|
|
7524
7755
|
import { access as access2, constants as constants2 } from "node:fs/promises";
|
|
7525
|
-
import
|
|
7526
|
-
import { randomUUID as
|
|
7756
|
+
import path22 from "node:path";
|
|
7757
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
7527
7758
|
var SCROLLBACK_BYTES = 256 * 1024;
|
|
7528
7759
|
var FLUSH_MS = 12;
|
|
7529
7760
|
var MAX_TERMINALS = 24;
|
|
@@ -7560,7 +7791,7 @@ var TerminalHub = class extends EventEmitter6 {
|
|
|
7560
7791
|
env: environment()
|
|
7561
7792
|
});
|
|
7562
7793
|
const info = {
|
|
7563
|
-
id:
|
|
7794
|
+
id: randomUUID5(),
|
|
7564
7795
|
workspaceId: options2.workspaceId,
|
|
7565
7796
|
title: shell.title,
|
|
7566
7797
|
shell: shell.file,
|
|
@@ -7692,36 +7923,36 @@ async function defaultShell() {
|
|
|
7692
7923
|
if (pwsh)
|
|
7693
7924
|
return { file: pwsh, args: [], title: "pwsh" };
|
|
7694
7925
|
const system = process.env.SystemRoot ?? "C:\\Windows";
|
|
7695
|
-
const powershell =
|
|
7696
|
-
if (await
|
|
7926
|
+
const powershell = path22.join(system, "System32/WindowsPowerShell/v1.0/powershell.exe");
|
|
7927
|
+
if (await exists3(powershell))
|
|
7697
7928
|
return { file: powershell, args: [], title: "powershell" };
|
|
7698
7929
|
return { file: process.env.COMSPEC ?? "cmd.exe", args: [], title: "cmd" };
|
|
7699
7930
|
}
|
|
7700
7931
|
const shell = process.env.SHELL;
|
|
7701
|
-
if (shell && await
|
|
7702
|
-
return { file: shell, args: [], title:
|
|
7703
|
-
if (await
|
|
7932
|
+
if (shell && await exists3(shell))
|
|
7933
|
+
return { file: shell, args: [], title: path22.basename(shell) };
|
|
7934
|
+
if (await exists3("/bin/bash"))
|
|
7704
7935
|
return { file: "/bin/bash", args: [], title: "bash" };
|
|
7705
7936
|
return { file: "/bin/sh", args: [], title: "sh" };
|
|
7706
7937
|
}
|
|
7707
7938
|
async function findOnPath(name) {
|
|
7708
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
7939
|
+
const dirs = (process.env.PATH ?? "").split(path22.delimiter).filter(Boolean);
|
|
7709
7940
|
for (const dir of dirs) {
|
|
7710
|
-
const candidate =
|
|
7711
|
-
if (await
|
|
7941
|
+
const candidate = path22.join(dir, name);
|
|
7942
|
+
if (await exists3(candidate))
|
|
7712
7943
|
return candidate;
|
|
7713
7944
|
}
|
|
7714
7945
|
return null;
|
|
7715
7946
|
}
|
|
7716
|
-
function
|
|
7947
|
+
function exists3(file) {
|
|
7717
7948
|
return access2(file, constants2.X_OK).then(() => true, () => false);
|
|
7718
7949
|
}
|
|
7719
7950
|
|
|
7720
7951
|
// ../host/dist/mcp-config.js
|
|
7721
|
-
import { readFile as
|
|
7722
|
-
import
|
|
7952
|
+
import { readFile as readFile17, writeFile as writeFile15, mkdir as mkdir14 } from "node:fs/promises";
|
|
7953
|
+
import path23 from "node:path";
|
|
7723
7954
|
var MCP_FILE = ".mcp.json";
|
|
7724
|
-
var LOCAL_SETTINGS2 =
|
|
7955
|
+
var LOCAL_SETTINGS2 = path23.join(".claude", "settings.local.json");
|
|
7725
7956
|
var queues = /* @__PURE__ */ new Map();
|
|
7726
7957
|
function serialize(cwd, work) {
|
|
7727
7958
|
const previous = queues.get(cwd) ?? Promise.resolve();
|
|
@@ -7730,7 +7961,7 @@ function serialize(cwd, work) {
|
|
|
7730
7961
|
return next;
|
|
7731
7962
|
}
|
|
7732
7963
|
async function readProjectServers(cwd) {
|
|
7733
|
-
const file = await readJson(
|
|
7964
|
+
const file = await readJson(path23.join(cwd, MCP_FILE));
|
|
7734
7965
|
const servers = file?.mcpServers;
|
|
7735
7966
|
if (!servers || typeof servers !== "object")
|
|
7736
7967
|
return {};
|
|
@@ -7738,23 +7969,23 @@ async function readProjectServers(cwd) {
|
|
|
7738
7969
|
}
|
|
7739
7970
|
function addProjectServer(cwd, name, config) {
|
|
7740
7971
|
return serialize(cwd, async () => {
|
|
7741
|
-
const file = await readJson(
|
|
7972
|
+
const file = await readJson(path23.join(cwd, MCP_FILE)) ?? {};
|
|
7742
7973
|
const servers = file.mcpServers ?? {};
|
|
7743
7974
|
servers[name] = config;
|
|
7744
7975
|
file.mcpServers = servers;
|
|
7745
|
-
await writeJson(
|
|
7976
|
+
await writeJson(path23.join(cwd, MCP_FILE), file);
|
|
7746
7977
|
await approve(cwd, name);
|
|
7747
7978
|
});
|
|
7748
7979
|
}
|
|
7749
7980
|
function removeProjectServer(cwd, name) {
|
|
7750
7981
|
return serialize(cwd, async () => {
|
|
7751
|
-
const file = await readJson(
|
|
7982
|
+
const file = await readJson(path23.join(cwd, MCP_FILE));
|
|
7752
7983
|
const servers = file?.mcpServers;
|
|
7753
7984
|
if (!servers || !(name in servers))
|
|
7754
7985
|
return false;
|
|
7755
7986
|
delete servers[name];
|
|
7756
|
-
await writeJson(
|
|
7757
|
-
const settingsPath =
|
|
7987
|
+
await writeJson(path23.join(cwd, MCP_FILE), file);
|
|
7988
|
+
const settingsPath = path23.join(cwd, LOCAL_SETTINGS2);
|
|
7758
7989
|
const settings = await readJson(settingsPath);
|
|
7759
7990
|
const enabled = settings?.enabledMcpjsonServers;
|
|
7760
7991
|
if (settings && Array.isArray(enabled) && enabled.includes(name)) {
|
|
@@ -7765,7 +7996,7 @@ function removeProjectServer(cwd, name) {
|
|
|
7765
7996
|
});
|
|
7766
7997
|
}
|
|
7767
7998
|
async function approve(cwd, name) {
|
|
7768
|
-
const file =
|
|
7999
|
+
const file = path23.join(cwd, LOCAL_SETTINGS2);
|
|
7769
8000
|
const settings = await readJson(file) ?? {};
|
|
7770
8001
|
const enabled = Array.isArray(settings.enabledMcpjsonServers) ? settings.enabledMcpjsonServers : [];
|
|
7771
8002
|
if (!enabled.includes(name))
|
|
@@ -7804,21 +8035,21 @@ function describeConfig(config) {
|
|
|
7804
8035
|
}
|
|
7805
8036
|
async function readJson(file) {
|
|
7806
8037
|
try {
|
|
7807
|
-
const raw = await
|
|
8038
|
+
const raw = await readFile17(file, "utf8");
|
|
7808
8039
|
const parsed = JSON.parse(raw);
|
|
7809
8040
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
7810
8041
|
} catch (error) {
|
|
7811
8042
|
if (error.code === "ENOENT")
|
|
7812
8043
|
return null;
|
|
7813
8044
|
if (error instanceof SyntaxError) {
|
|
7814
|
-
throw new Error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C ${
|
|
8045
|
+
throw new Error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C ${path23.basename(file)}: ${error.message}`);
|
|
7815
8046
|
}
|
|
7816
8047
|
throw error;
|
|
7817
8048
|
}
|
|
7818
8049
|
}
|
|
7819
8050
|
async function writeJson(file, data) {
|
|
7820
|
-
await
|
|
7821
|
-
await
|
|
8051
|
+
await mkdir14(path23.dirname(file), { recursive: true });
|
|
8052
|
+
await writeFile15(file, `${JSON.stringify(data, null, 2)}
|
|
7822
8053
|
`, "utf8");
|
|
7823
8054
|
}
|
|
7824
8055
|
|
|
@@ -7882,8 +8113,8 @@ var HostServer = class {
|
|
|
7882
8113
|
#limitTimer = null;
|
|
7883
8114
|
/** Идёт остановка у лимита — второй снимок лимитов её не запускает. */
|
|
7884
8115
|
#limitStopping = false;
|
|
7885
|
-
/** Последний снимок лимитов Claude — им сверяется ход без промпта. */
|
|
7886
|
-
#lastUsage =
|
|
8116
|
+
/** Последний снимок лимитов Claude по аккаунтам — им сверяется ход без промпта. */
|
|
8117
|
+
#lastUsage = /* @__PURE__ */ new Map();
|
|
7887
8118
|
/**
|
|
7888
8119
|
* Сессии, которым человек сам написал после срабатывания порога: id
|
|
7889
8120
|
* сессии → окно → срок, до которого оно было отмечено сработавшим. Это его
|
|
@@ -7895,9 +8126,13 @@ var HostServer = class {
|
|
|
7895
8126
|
#limitHandoffBusy = /* @__PURE__ */ new Set();
|
|
7896
8127
|
/** Живые id сессий, у которых сейчас пишется ручной хэндофф. */
|
|
7897
8128
|
#handoffBusy = /* @__PURE__ */ new Set();
|
|
7898
|
-
#hostId =
|
|
8129
|
+
#hostId = randomUUID6();
|
|
7899
8130
|
#plugins = new PluginCli();
|
|
7900
|
-
#
|
|
8131
|
+
#accounts;
|
|
8132
|
+
/** Вход у каждого аккаунта свой: у него свой каталог конфигурации и свой разговор с CLI. */
|
|
8133
|
+
#auths = /* @__PURE__ */ new Map();
|
|
8134
|
+
/** Чей транскрипт лежит под дисковым id сессии — заполняется списками сессий. */
|
|
8135
|
+
#diskAccounts = /* @__PURE__ */ new Map();
|
|
7901
8136
|
#relay;
|
|
7902
8137
|
#terminals = new TerminalHub();
|
|
7903
8138
|
#github;
|
|
@@ -7912,6 +8147,7 @@ var HostServer = class {
|
|
|
7912
8147
|
#gitBusy = /* @__PURE__ */ new Set();
|
|
7913
8148
|
constructor(options2) {
|
|
7914
8149
|
this.#options = options2;
|
|
8150
|
+
this.#accounts = new AccountStore(options2.dataDir);
|
|
7915
8151
|
this.#workspaces = new WorkspaceRegistry(options2.dataDir);
|
|
7916
8152
|
this.#archive = new SessionArchive(options2.dataDir);
|
|
7917
8153
|
this.#pins = new SessionPins(options2.dataDir);
|
|
@@ -7921,17 +8157,56 @@ var HostServer = class {
|
|
|
7921
8157
|
this.#antigravity = new AntigravityStore(options2.dataDir);
|
|
7922
8158
|
this.#handoffs = new HandoffStore(options2.dataDir);
|
|
7923
8159
|
this.#limitStop = new LimitStopState(options2.dataDir);
|
|
7924
|
-
this.#finder = new ProjectFinder(this.#workspaces);
|
|
8160
|
+
this.#finder = new ProjectFinder(this.#workspaces, () => this.#accounts.all.map((a) => a.configDir));
|
|
7925
8161
|
this.#relay = new RelayLink({ dataDir: options2.dataDir, defaultUrl: options2.relayUrl });
|
|
7926
8162
|
this.#github = new GitHubAccount(options2.dataDir);
|
|
7927
8163
|
this.#wireRelay();
|
|
7928
8164
|
this.#wireTerminals();
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
this.#
|
|
7933
|
-
|
|
7934
|
-
|
|
8165
|
+
}
|
|
8166
|
+
/** Вход аккаунта; создаётся при первом обращении и живёт, пока жив хост. */
|
|
8167
|
+
#authFor(accountId) {
|
|
8168
|
+
const account = this.#accounts.find(accountId);
|
|
8169
|
+
if (!account)
|
|
8170
|
+
throw new Error("\u0410\u043A\u043A\u0430\u0443\u043D\u0442 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D");
|
|
8171
|
+
let auth = this.#auths.get(account.id);
|
|
8172
|
+
if (!auth) {
|
|
8173
|
+
auth = new AuthCli(account.configDir);
|
|
8174
|
+
auth.on("login", (state) => {
|
|
8175
|
+
this.#broadcast({ type: "auth.login", accountId: account.id, state });
|
|
8176
|
+
});
|
|
8177
|
+
auth.on("changed", () => {
|
|
8178
|
+
void this.#sendAuthStatus(account.id);
|
|
8179
|
+
});
|
|
8180
|
+
this.#auths.set(account.id, auth);
|
|
8181
|
+
}
|
|
8182
|
+
return auth;
|
|
8183
|
+
}
|
|
8184
|
+
/** Аккаунты для UI: с числом живых сессий, по которому решается, можно ли убрать аккаунт. */
|
|
8185
|
+
#accountList() {
|
|
8186
|
+
const live = [...this.#sessions.values()].filter((s) => s instanceof ClaudeSession && s.state !== "closed" && !s.summary().parentSessionId);
|
|
8187
|
+
return this.#accounts.all.map((a) => ({
|
|
8188
|
+
id: a.id,
|
|
8189
|
+
name: a.name,
|
|
8190
|
+
color: a.color,
|
|
8191
|
+
configDir: a.configDir,
|
|
8192
|
+
main: a.id === MAIN_ACCOUNT_ID,
|
|
8193
|
+
liveSessions: live.filter((s) => s.accountId === a.id).length
|
|
8194
|
+
}));
|
|
8195
|
+
}
|
|
8196
|
+
/** Список аккаунтов и, для каждого, кто в нём вошёл. Вход спрашивается у CLI — это процесс на аккаунт. */
|
|
8197
|
+
async #accountsFrame() {
|
|
8198
|
+
const accounts = this.#accountList();
|
|
8199
|
+
const entries = await Promise.all(accounts.map(async (a) => {
|
|
8200
|
+
const status = await this.#authFor(a.id).status().catch(() => null);
|
|
8201
|
+
return [a.id, status];
|
|
8202
|
+
}));
|
|
8203
|
+
return { type: "accounts.state", accounts, auth: Object.fromEntries(entries) };
|
|
8204
|
+
}
|
|
8205
|
+
async #sendAccounts() {
|
|
8206
|
+
this.#broadcast(await this.#accountsFrame());
|
|
8207
|
+
}
|
|
8208
|
+
#diskAccountList() {
|
|
8209
|
+
return this.#accounts.all.map((a) => ({ id: a.id, configDir: a.configDir }));
|
|
7935
8210
|
}
|
|
7936
8211
|
/**
|
|
7937
8212
|
* Перенести всё, что записано под id проектов прежнего формата, на нынешние.
|
|
@@ -7943,7 +8218,7 @@ var HostServer = class {
|
|
|
7943
8218
|
async #carryOverWorkspaceIds() {
|
|
7944
8219
|
const remap = workspaceIdRemap(this.#workspaces.paths(), async (dir) => {
|
|
7945
8220
|
const id = workspaceIdFromPath(dir);
|
|
7946
|
-
const onDisk = await this.#workspaces.sessionsOnDisk(id);
|
|
8221
|
+
const onDisk = await this.#workspaces.sessionsOnDisk(id, this.#diskAccountList());
|
|
7947
8222
|
const antigravity = await this.#antigravity.list(id);
|
|
7948
8223
|
return [...onDisk.map((s) => s.sessionId), ...antigravity.map((r) => r.id)];
|
|
7949
8224
|
});
|
|
@@ -7962,6 +8237,7 @@ var HostServer = class {
|
|
|
7962
8237
|
await this.#carryOverWorkspaceIds();
|
|
7963
8238
|
await this.#settings.load();
|
|
7964
8239
|
this.#wireNetworkGuard();
|
|
8240
|
+
await this.#accounts.load();
|
|
7965
8241
|
await this.#limitStop.load();
|
|
7966
8242
|
await this.#github.load();
|
|
7967
8243
|
await warmClaudeLauncher();
|
|
@@ -8015,7 +8291,8 @@ var HostServer = class {
|
|
|
8015
8291
|
if (this.#limitTimer)
|
|
8016
8292
|
clearInterval(this.#limitTimer);
|
|
8017
8293
|
this.#limitTimer = null;
|
|
8018
|
-
this.#
|
|
8294
|
+
for (const auth of this.#auths.values())
|
|
8295
|
+
auth.cancel();
|
|
8019
8296
|
this.#terminals.closeAll();
|
|
8020
8297
|
await this.#relay.close();
|
|
8021
8298
|
await Promise.all([...this.#sessions.values()].map((s) => s.close("host shutdown")));
|
|
@@ -8174,7 +8451,13 @@ var HostServer = class {
|
|
|
8174
8451
|
this.#sendFolders(socket);
|
|
8175
8452
|
this.#send(socket, { type: "order.state", order: this.#order.current });
|
|
8176
8453
|
this.#sendLive(socket);
|
|
8177
|
-
this.#
|
|
8454
|
+
this.#accountsFrame().then((frame2) => {
|
|
8455
|
+
this.#send(socket, frame2);
|
|
8456
|
+
for (const [accountId, status] of Object.entries(frame2.auth)) {
|
|
8457
|
+
if (status)
|
|
8458
|
+
this.#send(socket, { type: "auth.status", accountId, status });
|
|
8459
|
+
}
|
|
8460
|
+
}).catch(() => void 0);
|
|
8178
8461
|
this.#send(socket, { type: "relay.state", state: this.#relay.state });
|
|
8179
8462
|
this.#send(socket, { type: "network.state", state: networkGuard.state });
|
|
8180
8463
|
return;
|
|
@@ -8874,26 +9157,69 @@ var HostServer = class {
|
|
|
8874
9157
|
}
|
|
8875
9158
|
return;
|
|
8876
9159
|
}
|
|
8877
|
-
case "auth.status":
|
|
8878
|
-
|
|
8879
|
-
|
|
9160
|
+
case "auth.status": {
|
|
9161
|
+
const account = this.#accounts.find(frame.accountId);
|
|
9162
|
+
if (!account)
|
|
9163
|
+
throw new Error("\u0410\u043A\u043A\u0430\u0443\u043D\u0442 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D");
|
|
9164
|
+
const auth = this.#authFor(account.id);
|
|
9165
|
+
this.#send(socket, {
|
|
9166
|
+
type: "auth.status",
|
|
9167
|
+
accountId: account.id,
|
|
9168
|
+
status: await auth.status()
|
|
9169
|
+
});
|
|
9170
|
+
this.#send(socket, { type: "auth.login", accountId: account.id, state: auth.loginState });
|
|
8880
9171
|
return;
|
|
9172
|
+
}
|
|
8881
9173
|
case "auth.login": {
|
|
8882
9174
|
const blocked = (await networkGuard.ensureFresh()).status === "blocked";
|
|
8883
9175
|
if (blocked)
|
|
8884
9176
|
throw new Error(`${networkGuard.blockedReason()}. \u0412\u0445\u043E\u0434 \u043E\u0442\u043B\u043E\u0436\u0435\u043D.`);
|
|
8885
|
-
await this.#
|
|
9177
|
+
await this.#authFor(frame.accountId).login(frame.mode, frame.switchAccount === true);
|
|
8886
9178
|
return;
|
|
8887
9179
|
}
|
|
8888
9180
|
case "auth.code":
|
|
8889
|
-
this.#
|
|
9181
|
+
this.#authFor(frame.accountId).submitCode(frame.code);
|
|
8890
9182
|
return;
|
|
8891
9183
|
case "auth.cancel":
|
|
8892
|
-
this.#
|
|
9184
|
+
this.#authFor(frame.accountId).cancel();
|
|
8893
9185
|
return;
|
|
8894
9186
|
case "auth.logout":
|
|
8895
|
-
await this.#
|
|
9187
|
+
await this.#authFor(frame.accountId).logout();
|
|
9188
|
+
return;
|
|
9189
|
+
case "accounts.list":
|
|
9190
|
+
this.#send(socket, await this.#accountsFrame());
|
|
8896
9191
|
return;
|
|
9192
|
+
case "accounts.add":
|
|
9193
|
+
await this.#accounts.add({
|
|
9194
|
+
name: frame.name,
|
|
9195
|
+
...frame.color ? { color: frame.color } : {},
|
|
9196
|
+
...frame.configDir ? { configDir: frame.configDir } : {},
|
|
9197
|
+
...frame.shareConfig ? { shareConfig: true } : {}
|
|
9198
|
+
});
|
|
9199
|
+
await this.#sendAccounts();
|
|
9200
|
+
return;
|
|
9201
|
+
case "accounts.update":
|
|
9202
|
+
await this.#accounts.update(frame.accountId, {
|
|
9203
|
+
...frame.name !== void 0 ? { name: frame.name } : {},
|
|
9204
|
+
...frame.color ? { color: frame.color } : {}
|
|
9205
|
+
});
|
|
9206
|
+
await this.#sendAccounts();
|
|
9207
|
+
return;
|
|
9208
|
+
case "accounts.remove": {
|
|
9209
|
+
const account = this.#accountList().find((a) => a.id === frame.accountId);
|
|
9210
|
+
if (!account)
|
|
9211
|
+
return;
|
|
9212
|
+
if (account.main)
|
|
9213
|
+
throw new Error("\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0430\u043A\u043A\u0430\u0443\u043D\u0442 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043D\u0435\u043B\u044C\u0437\u044F");
|
|
9214
|
+
if (account.liveSessions > 0) {
|
|
9215
|
+
throw new Error("\u041F\u043E\u0434 \u044D\u0442\u0438\u043C \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u043C \u0438\u0434\u0443\u0442 \u0441\u0435\u0441\u0441\u0438\u0438 \u2014 \u0437\u0430\u043A\u0440\u043E\u0439\u0442\u0435 \u0438\u0445, \u043F\u043E\u0442\u043E\u043C \u0443\u0434\u0430\u043B\u044F\u0439\u0442\u0435 \u0430\u043A\u043A\u0430\u0443\u043D\u0442");
|
|
9216
|
+
}
|
|
9217
|
+
this.#auths.get(account.id)?.cancel();
|
|
9218
|
+
this.#auths.delete(account.id);
|
|
9219
|
+
await this.#accounts.remove(account.id);
|
|
9220
|
+
await this.#sendAccounts();
|
|
9221
|
+
return;
|
|
9222
|
+
}
|
|
8897
9223
|
case "relay.status":
|
|
8898
9224
|
this.#send(socket, { type: "relay.state", state: this.#relay.state });
|
|
8899
9225
|
return;
|
|
@@ -8952,8 +9278,13 @@ var HostServer = class {
|
|
|
8952
9278
|
return;
|
|
8953
9279
|
throw new Error(`${action} \u043C\u043E\u0436\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u043D\u0451\u043C \u0441\u0430\u043C\u043E\u043C, \u043D\u0435 \u0443\u0434\u0430\u043B\u0451\u043D\u043D\u043E`);
|
|
8954
9280
|
}
|
|
8955
|
-
async #sendAuthStatus() {
|
|
8956
|
-
this.#broadcast({
|
|
9281
|
+
async #sendAuthStatus(accountId) {
|
|
9282
|
+
this.#broadcast({
|
|
9283
|
+
type: "auth.status",
|
|
9284
|
+
accountId,
|
|
9285
|
+
status: await this.#authFor(accountId).status()
|
|
9286
|
+
});
|
|
9287
|
+
await this.#sendAccounts();
|
|
8957
9288
|
}
|
|
8958
9289
|
// -------------------------------------------------------------------------
|
|
8959
9290
|
// MCP и плагины
|
|
@@ -9019,11 +9350,11 @@ var HostServer = class {
|
|
|
9019
9350
|
* CLI показываем как результат операции, а не роняем кадр: пользователь
|
|
9020
9351
|
* должен увидеть текст «маркетплейс не найден», а не молчание.
|
|
9021
9352
|
*/
|
|
9022
|
-
async #pluginOperation(sessionId,
|
|
9353
|
+
async #pluginOperation(sessionId, run) {
|
|
9023
9354
|
let ok = true;
|
|
9024
9355
|
let message;
|
|
9025
9356
|
try {
|
|
9026
|
-
message = await
|
|
9357
|
+
message = await run() || "\u0413\u043E\u0442\u043E\u0432\u043E";
|
|
9027
9358
|
} catch (error) {
|
|
9028
9359
|
ok = false;
|
|
9029
9360
|
message = error instanceof Error ? error.message : String(error);
|
|
@@ -9201,21 +9532,26 @@ var HostServer = class {
|
|
|
9201
9532
|
* прошёл бы мимо порога. Лимиты общие на аккаунт — спросить одну хватит.
|
|
9202
9533
|
*/
|
|
9203
9534
|
#sweepUsage() {
|
|
9204
|
-
const
|
|
9205
|
-
|
|
9206
|
-
|
|
9535
|
+
const asked = /* @__PURE__ */ new Set();
|
|
9536
|
+
for (const session of this.#claudeUserSessions()) {
|
|
9537
|
+
if (asked.has(session.accountId) || !this.#isBusy(session))
|
|
9538
|
+
continue;
|
|
9539
|
+
asked.add(session.accountId);
|
|
9540
|
+
void session.refreshUsage();
|
|
9541
|
+
}
|
|
9207
9542
|
}
|
|
9208
|
-
async #checkLimit(usage) {
|
|
9209
|
-
this.#lastUsage
|
|
9543
|
+
async #checkLimit(usage, accountId) {
|
|
9544
|
+
this.#lastUsage.set(accountId, usage);
|
|
9210
9545
|
if (this.#limitStopping)
|
|
9211
9546
|
return;
|
|
9212
|
-
const
|
|
9547
|
+
const stops = this.#limitStop.forAccount(accountId);
|
|
9548
|
+
const hit = crossedLimit(usage, this.#settings.current, (limit, resets) => stops.fired(limit, resets));
|
|
9213
9549
|
if (!hit)
|
|
9214
9550
|
return;
|
|
9215
9551
|
this.#limitStopping = true;
|
|
9216
9552
|
try {
|
|
9217
|
-
await
|
|
9218
|
-
await this.#stopAtLimit(hit);
|
|
9553
|
+
await stops.mark(hit.limit, hit.until);
|
|
9554
|
+
await this.#stopAtLimit(hit, accountId);
|
|
9219
9555
|
} catch (error) {
|
|
9220
9556
|
console.error("[limit-stop]", error instanceof Error ? error.message : String(error));
|
|
9221
9557
|
} finally {
|
|
@@ -9231,8 +9567,10 @@ var HostServer = class {
|
|
|
9231
9567
|
#approveAfterLimit(sessionId) {
|
|
9232
9568
|
const now = Date.now();
|
|
9233
9569
|
const approved = {};
|
|
9570
|
+
const accountId = this.#sessions.get(sessionId);
|
|
9571
|
+
const stops = this.#limitStop.forAccount(accountId instanceof ClaudeSession ? accountId.accountId : MAIN_ACCOUNT_ID);
|
|
9234
9572
|
for (const limit of ["fiveHour", "sevenDay"]) {
|
|
9235
|
-
const until =
|
|
9573
|
+
const until = stops.until(limit);
|
|
9236
9574
|
if (until > now)
|
|
9237
9575
|
approved[limit] = until;
|
|
9238
9576
|
}
|
|
@@ -9253,14 +9591,16 @@ var HostServer = class {
|
|
|
9253
9591
|
* срабатывало, здесь не трогаем: его поймает обычный `#checkLimit`.
|
|
9254
9592
|
*/
|
|
9255
9593
|
async #checkUnpromptedTurn(session) {
|
|
9256
|
-
|
|
9594
|
+
const lastUsage = this.#lastUsage.get(session.accountId);
|
|
9595
|
+
if (!lastUsage || this.#limitStopping)
|
|
9257
9596
|
return;
|
|
9597
|
+
const stops = this.#limitStop.forAccount(session.accountId);
|
|
9258
9598
|
if (this.#limitHandoffBusy.has(session.id) || this.#handoffBusy.has(session.id))
|
|
9259
9599
|
return;
|
|
9260
9600
|
if (!this.#claudeUserSessions().includes(session))
|
|
9261
9601
|
return;
|
|
9262
9602
|
const approved = this.#limitApproved.get(session.id) ?? {};
|
|
9263
|
-
const hit = crossedLimit(
|
|
9603
|
+
const hit = crossedLimit(lastUsage, this.#settings.current, (limit, resets) => !stops.fired(limit, resets) || approved[limit] === stops.until(limit));
|
|
9264
9604
|
if (!hit)
|
|
9265
9605
|
return;
|
|
9266
9606
|
const saved = await this.#limitHandoff(session, hit);
|
|
@@ -9280,8 +9620,8 @@ var HostServer = class {
|
|
|
9280
9620
|
* когда из её хэндоффа продолжили в новой (см. `continueFromHandoff` в
|
|
9281
9621
|
* окне).
|
|
9282
9622
|
*/
|
|
9283
|
-
async #stopAtLimit(hit) {
|
|
9284
|
-
const sessions = this.#claudeUserSessions();
|
|
9623
|
+
async #stopAtLimit(hit, accountId) {
|
|
9624
|
+
const sessions = this.#claudeUserSessions().filter((s) => s.accountId === accountId);
|
|
9285
9625
|
if (sessions.length === 0)
|
|
9286
9626
|
return;
|
|
9287
9627
|
const now = Date.now();
|
|
@@ -9441,13 +9781,19 @@ var HostServer = class {
|
|
|
9441
9781
|
this.#send(socket, { type: "session.summary", session: session2.summary() });
|
|
9442
9782
|
return;
|
|
9443
9783
|
}
|
|
9444
|
-
const
|
|
9784
|
+
const onDisk = frame.resume ? (await this.#workspaces.sessionsOnDisk(workspace.id, this.#diskAccountList())).find((info) => info.sessionId === frame.resume) : void 0;
|
|
9785
|
+
const resumed = onDisk && !frame.fork ? onDisk : void 0;
|
|
9445
9786
|
const resumedTitle = resumed ? diskTitle(resumed) : null;
|
|
9787
|
+
const account = this.#accounts.find(onDisk?.accountId ?? frame.accountId);
|
|
9788
|
+
if (!account)
|
|
9789
|
+
throw new Error("\u0410\u043A\u043A\u0430\u0443\u043D\u0442 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D");
|
|
9446
9790
|
if (frame.resume)
|
|
9447
9791
|
await this.#archive.unarchive([frame.resume]);
|
|
9448
9792
|
const startDefaults = this.#settings.current;
|
|
9449
9793
|
const session = new ClaudeSession({
|
|
9450
9794
|
workspaceId: workspace.id,
|
|
9795
|
+
accountId: account.id,
|
|
9796
|
+
configDir: account.configDir,
|
|
9451
9797
|
cwd: workspace.path,
|
|
9452
9798
|
resume: frame.resume,
|
|
9453
9799
|
fork: frame.fork,
|
|
@@ -9574,7 +9920,7 @@ var HostServer = class {
|
|
|
9574
9920
|
session.on("usage", (usage) => {
|
|
9575
9921
|
this.#broadcast({ type: "usage.state", sessionId: session.id, usage });
|
|
9576
9922
|
if (session instanceof ClaudeSession)
|
|
9577
|
-
void this.#checkLimit(usage);
|
|
9923
|
+
void this.#checkLimit(usage, session.accountId);
|
|
9578
9924
|
});
|
|
9579
9925
|
if (session instanceof ClaudeSession) {
|
|
9580
9926
|
session.on("unpromptedTurn", () => void this.#checkUnpromptedTurn(session));
|
|
@@ -9613,6 +9959,9 @@ var HostServer = class {
|
|
|
9613
9959
|
const claudeId = parent.claudeSessionId;
|
|
9614
9960
|
const side = new ClaudeSession({
|
|
9615
9961
|
workspaceId: parent.workspaceId,
|
|
9962
|
+
// Вопрос на полях — тот же разговор, значит и тот же аккаунт: форк читает
|
|
9963
|
+
// транскрипт родителя из его каталога.
|
|
9964
|
+
...parent instanceof ClaudeSession ? { accountId: parent.accountId, configDir: parent.configDir } : {},
|
|
9616
9965
|
cwd: parent.cwd,
|
|
9617
9966
|
parentSessionId: parent.id,
|
|
9618
9967
|
readOnly: true,
|
|
@@ -9661,7 +10010,7 @@ var HostServer = class {
|
|
|
9661
10010
|
*/
|
|
9662
10011
|
#roots() {
|
|
9663
10012
|
const roots = this.#finder.roots();
|
|
9664
|
-
return roots.length > 0 ? roots : [
|
|
10013
|
+
return roots.length > 0 ? roots : [homedir7()];
|
|
9665
10014
|
}
|
|
9666
10015
|
/**
|
|
9667
10016
|
* Где сессии этого каталога разрешено писать без вопроса.
|
|
@@ -9750,12 +10099,12 @@ var HostServer = class {
|
|
|
9750
10099
|
* его как есть. Своей формулировки у нас нет и быть не должно: git объясняет
|
|
9751
10100
|
* отказ («ваши правки будут перезаписаны», «обновлений нет») точнее.
|
|
9752
10101
|
*/
|
|
9753
|
-
async #gitOperation(workspaceId,
|
|
10102
|
+
async #gitOperation(workspaceId, run) {
|
|
9754
10103
|
let ok = true;
|
|
9755
10104
|
let message = "";
|
|
9756
10105
|
let url2;
|
|
9757
10106
|
try {
|
|
9758
|
-
const outcome = await
|
|
10107
|
+
const outcome = await run(this.#git(workspaceId));
|
|
9759
10108
|
message = outcome.message;
|
|
9760
10109
|
url2 = outcome.url;
|
|
9761
10110
|
} catch (error) {
|
|
@@ -9775,7 +10124,7 @@ var HostServer = class {
|
|
|
9775
10124
|
* рассылается всем по той же причине, по которой рассылается итог, — вкладки
|
|
9776
10125
|
* смотрят в один каталог.
|
|
9777
10126
|
*/
|
|
9778
|
-
async #gitNetwork(workspaceId, label,
|
|
10127
|
+
async #gitNetwork(workspaceId, label, run) {
|
|
9779
10128
|
if (this.#gitBusy.has(workspaceId)) {
|
|
9780
10129
|
this.#broadcast({
|
|
9781
10130
|
type: "git.result",
|
|
@@ -9788,7 +10137,7 @@ var HostServer = class {
|
|
|
9788
10137
|
this.#gitBusy.add(workspaceId);
|
|
9789
10138
|
this.#broadcast({ type: "git.busy", workspaceId, label });
|
|
9790
10139
|
try {
|
|
9791
|
-
await this.#gitOperation(workspaceId,
|
|
10140
|
+
await this.#gitOperation(workspaceId, run);
|
|
9792
10141
|
} finally {
|
|
9793
10142
|
this.#gitBusy.delete(workspaceId);
|
|
9794
10143
|
this.#broadcast({ type: "git.busy", workspaceId, label: "" });
|
|
@@ -9909,7 +10258,8 @@ var HostServer = class {
|
|
|
9909
10258
|
return;
|
|
9910
10259
|
}
|
|
9911
10260
|
const dir = workspaceId ? this.#workspaces.find(workspaceId)?.path : void 0;
|
|
9912
|
-
|
|
10261
|
+
const configDir = this.#accounts.configDir(this.#diskAccounts.get(sessionId));
|
|
10262
|
+
await withConfigDir(configDir, () => renameSession2(sessionId, title, dir ? { dir } : void 0));
|
|
9913
10263
|
if (!workspaceId)
|
|
9914
10264
|
return;
|
|
9915
10265
|
await this.#sendSessionList(workspaceId);
|
|
@@ -9925,11 +10275,14 @@ var HostServer = class {
|
|
|
9925
10275
|
async #listSessions(workspaceId) {
|
|
9926
10276
|
const live = [...this.#sessions.values()].filter((s) => s.workspaceId === workspaceId && !s.parentSessionId).map((s) => s.summary());
|
|
9927
10277
|
const liveIds = new Set(live.flatMap((s) => s.claudeSessionId ? [s.id, s.claudeSessionId] : [s.id]));
|
|
9928
|
-
const onDisk = await this.#workspaces.sessionsOnDisk(workspaceId);
|
|
10278
|
+
const onDisk = await this.#workspaces.sessionsOnDisk(workspaceId, this.#diskAccountList());
|
|
10279
|
+
for (const info of onDisk)
|
|
10280
|
+
this.#diskAccounts.set(info.sessionId, info.accountId);
|
|
9929
10281
|
const workspacePath = this.#workspaces.find(workspaceId)?.path ?? "";
|
|
9930
10282
|
const historical = onDisk.filter((info) => !liveIds.has(info.sessionId) && info.customTitle !== SIDE_TITLE && info.customTitle !== FINDER_TITLE).map((info) => ({
|
|
9931
10283
|
id: info.sessionId,
|
|
9932
10284
|
provider: "claude",
|
|
10285
|
+
accountId: info.accountId,
|
|
9933
10286
|
claudeSessionId: info.sessionId,
|
|
9934
10287
|
workspaceId,
|
|
9935
10288
|
cwd: info.cwd ?? workspacePath,
|
|
@@ -10012,8 +10365,8 @@ var HostServer = class {
|
|
|
10012
10365
|
return;
|
|
10013
10366
|
}
|
|
10014
10367
|
const url2 = new URL(req.url ?? "/", "http://localhost");
|
|
10015
|
-
const requested =
|
|
10016
|
-
const target = requested.startsWith(webRoot) && existsSync4(requested) && statSync3(requested).isFile() ? requested :
|
|
10368
|
+
const requested = path24.join(webRoot, path24.normalize(url2.pathname));
|
|
10369
|
+
const target = requested.startsWith(webRoot) && existsSync4(requested) && statSync3(requested).isFile() ? requested : path24.join(webRoot, "index.html");
|
|
10017
10370
|
if (!existsSync4(target)) {
|
|
10018
10371
|
res.writeHead(404).end("not found");
|
|
10019
10372
|
return;
|
|
@@ -10039,7 +10392,7 @@ function contentType(file) {
|
|
|
10039
10392
|
".svg": "image/svg+xml",
|
|
10040
10393
|
".woff2": "font/woff2"
|
|
10041
10394
|
};
|
|
10042
|
-
return types[
|
|
10395
|
+
return types[path24.extname(file)] ?? "application/octet-stream";
|
|
10043
10396
|
}
|
|
10044
10397
|
function antigravitySummary(record) {
|
|
10045
10398
|
return {
|
|
@@ -10063,13 +10416,14 @@ function antigravitySummary(record) {
|
|
|
10063
10416
|
createdAt: record.createdAt,
|
|
10064
10417
|
updatedAt: record.updatedAt,
|
|
10065
10418
|
lastSeq: 0,
|
|
10066
|
-
totalCostUsd: 0
|
|
10419
|
+
totalCostUsd: 0,
|
|
10420
|
+
accountId: MAIN_ACCOUNT_ID
|
|
10067
10421
|
};
|
|
10068
10422
|
}
|
|
10069
10423
|
|
|
10070
10424
|
// dist/ccv.js
|
|
10071
|
-
var HERE =
|
|
10072
|
-
var PACKAGE_ROOT =
|
|
10425
|
+
var HERE = path25.dirname(fileURLToPath(import.meta.url));
|
|
10426
|
+
var PACKAGE_ROOT = path25.resolve(HERE, "..");
|
|
10073
10427
|
var USAGE = `ccv \u2014 Claude Code Visual: \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u0445\u043E\u0441\u0442 Claude Code \u0441 \u0438\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043E\u043C \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.
|
|
10074
10428
|
|
|
10075
10429
|
\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435:
|
|
@@ -10136,7 +10490,7 @@ var server = new HostServer({
|
|
|
10136
10490
|
dataDir: defaults.dataDir,
|
|
10137
10491
|
// UI лежит в пакете рядом с бандлом — это и есть разница между установленной
|
|
10138
10492
|
// утилитой и запуском из репозитория, где сборка живёт в `apps/web/dist`.
|
|
10139
|
-
webRoot: process.env.CCV_WEB_ROOT ??
|
|
10493
|
+
webRoot: process.env.CCV_WEB_ROOT ?? path25.join(PACKAGE_ROOT, "web"),
|
|
10140
10494
|
version,
|
|
10141
10495
|
relayUrl: defaults.relayUrl
|
|
10142
10496
|
});
|
|
@@ -10165,7 +10519,7 @@ for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
|
10165
10519
|
}
|
|
10166
10520
|
async function packageVersion() {
|
|
10167
10521
|
try {
|
|
10168
|
-
const text = await
|
|
10522
|
+
const text = await readFile18(path25.join(PACKAGE_ROOT, "package.json"), "utf8");
|
|
10169
10523
|
return JSON.parse(text).version ?? "0.0.0";
|
|
10170
10524
|
} catch {
|
|
10171
10525
|
return "0.0.0";
|