@i14ks/ccv 0.32.4 → 0.34.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/README.md +2 -80
- package/bundle/ccv.mjs +217 -1458
- package/package.json +2 -4
- package/web/apple-touch-icon.png +0 -0
- package/web/assets/{codemirror-DhfwqjqU.js → codemirror-BtJ9Kw6s.js} +1 -1
- package/web/assets/{index-BFy9JD3-.js → index-B9YW7yGO.js} +1 -1
- package/web/assets/{index-CyWY9B0k.js → index-BAlM5PeU.js} +1 -1
- package/web/assets/{index-DmCd_FaJ.js → index-BDq5JNDx.js} +1 -1
- package/web/assets/{index-Cs_UMcHu.js → index-Ba1mAYRn.js} +1 -1
- package/web/assets/{index-Dm8pXY-_.js → index-BlUJ9mDA.js} +1 -1
- package/web/assets/{index-BU0K--x3.js → index-BpAEaXJC.js} +1 -1
- package/web/assets/{index-SSX0mfJk.js → index-BwiSzzXj.js} +1 -1
- package/web/assets/{index-DskvcGi2.js → index-C3Ai8_SG.js} +1 -1
- package/web/assets/index-C6Y6TadO.css +1 -0
- package/web/assets/{index-Gl9vAyb5.js → index-C8QQfurN.js} +1 -1
- package/web/assets/{index-DH6FWk2W.js → index-CNOLHL_4.js} +1 -1
- package/web/assets/{index-DJ5rXrU7.js → index-CWKatwuc.js} +1 -1
- package/web/assets/{index-Bs_3sIGJ.js → index-Ccp0JT8x.js} +1 -1
- package/web/assets/{index-yxI-03Bw.js → index-DHwxEPqa.js} +1 -1
- package/web/assets/{index-CLEW_qtS.js → index-DWr0O8ZE.js} +1 -1
- package/web/assets/index-DYqdo2vo.js +134 -0
- package/web/assets/{index-BW8Rlkj4.js → index-Dc4p-U2p.js} +1 -1
- package/web/assets/{index-DFHmpocy.js → index-Dm_hwn8g.js} +1 -1
- package/web/assets/{index-BhBx3aKF.js → index-DvfkEh9E.js} +1 -1
- package/web/assets/{index-MRgo-upu.js → index-McXNmpFb.js} +1 -1
- package/web/assets/{index-CEdviSUU.js → index-yIku6ofv.js} +1 -1
- package/web/favicon.ico +0 -0
- package/web/favicon.png +0 -0
- package/web/favicon.svg +2 -4
- package/web/index.html +5 -8
- package/web/assets/index-CajUsdwj.js +0 -143
- package/web/assets/index-Vb27wc8u.css +0 -1
package/bundle/ccv.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// dist/ccv.js
|
|
4
|
-
import { spawn as
|
|
5
|
-
import { readFile as
|
|
6
|
-
import
|
|
4
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
5
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
6
|
+
import path24 from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
9
9
|
|
|
@@ -128,144 +128,15 @@ function reachable(file, mode) {
|
|
|
128
128
|
return access(file, mode).then(() => true, () => false);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
// ../host/dist/codex-cli.js
|
|
132
|
-
import { spawn as spawn2, execFile as execFile2 } from "node:child_process";
|
|
133
|
-
import { existsSync } from "node:fs";
|
|
134
|
-
import { homedir as homedir2 } from "node:os";
|
|
135
|
-
import path2 from "node:path";
|
|
136
|
-
import { EventEmitter } from "node:events";
|
|
137
|
-
import { createInterface } from "node:readline";
|
|
138
|
-
function codexLauncher() {
|
|
139
|
-
const forced = process.env.CCV_CODEX_PATH;
|
|
140
|
-
const dirs = (process.env.PATH ?? "").split(path2.delimiter).filter(Boolean);
|
|
141
|
-
dirs.push(path2.join(homedir2(), ".local", "bin"));
|
|
142
|
-
if (process.platform === "win32") {
|
|
143
|
-
dirs.push(path2.join(process.env.LOCALAPPDATA ?? path2.join(homedir2(), "AppData", "Local"), "Programs", "OpenAI", "Codex", "bin"));
|
|
144
|
-
dirs.push(process.env.APPDATA ? path2.join(process.env.APPDATA, "npm") : path2.join(homedir2(), "AppData", "Roaming", "npm"));
|
|
145
|
-
}
|
|
146
|
-
const names2 = process.platform === "win32" ? ["codex.exe", "codex.cmd", "codex"] : ["codex"];
|
|
147
|
-
for (const candidate of forced ? [forced] : dirs.flatMap((dir) => names2.map((name) => path2.join(dir, name)))) {
|
|
148
|
-
if (!existsSync(candidate))
|
|
149
|
-
continue;
|
|
150
|
-
if (/\.(?:cmd|ps1)$/i.test(candidate)) {
|
|
151
|
-
const js = path2.join(path2.dirname(candidate), "node_modules", "@openai", "codex", "bin", "codex.js");
|
|
152
|
-
if (existsSync(js))
|
|
153
|
-
return { file: process.execPath, args: [js] };
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (/\.(?:m?js)$/i.test(candidate))
|
|
157
|
-
return { file: process.execPath, args: [candidate] };
|
|
158
|
-
return { file: candidate, args: [] };
|
|
159
|
-
}
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
var CODEX_MISSING_HINT = "Codex CLI \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D. \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 npm install -g @openai/codex \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 codex login (\u0438\u043B\u0438 codex login --device-auth \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435). \u041F\u0443\u0442\u044C \u043C\u043E\u0436\u043D\u043E \u0437\u0430\u0434\u0430\u0442\u044C \u0447\u0435\u0440\u0435\u0437 CCV_CODEX_PATH.";
|
|
163
|
-
var CodexClient = class extends EventEmitter {
|
|
164
|
-
#child = null;
|
|
165
|
-
#nextId = 0;
|
|
166
|
-
#pending = /* @__PURE__ */ new Map();
|
|
167
|
-
#closed = false;
|
|
168
|
-
#exited = Promise.resolve();
|
|
169
|
-
async start(cwd) {
|
|
170
|
-
const launcher = codexLauncher();
|
|
171
|
-
if (!launcher)
|
|
172
|
-
throw new Error(CODEX_MISSING_HINT);
|
|
173
|
-
this.#closed = false;
|
|
174
|
-
const child = spawn2(launcher.file, [...launcher.args, "app-server", "--listen", "stdio://"], {
|
|
175
|
-
cwd,
|
|
176
|
-
windowsHide: true,
|
|
177
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
178
|
-
env: { ...process.env, NO_COLOR: "1" }
|
|
179
|
-
});
|
|
180
|
-
this.#child = child;
|
|
181
|
-
this.#exited = new Promise((resolve) => child.once("close", () => resolve()));
|
|
182
|
-
createInterface({ input: child.stdout, crlfDelay: Infinity }).on("line", (line) => {
|
|
183
|
-
let message;
|
|
184
|
-
try {
|
|
185
|
-
message = JSON.parse(line);
|
|
186
|
-
} catch {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (message.method) {
|
|
190
|
-
this.emit("message", message);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
const pending = typeof message.id === "number" ? this.#pending.get(message.id) : void 0;
|
|
194
|
-
if (!pending)
|
|
195
|
-
return;
|
|
196
|
-
clearTimeout(pending.timer);
|
|
197
|
-
this.#pending.delete(message.id);
|
|
198
|
-
if (message.error)
|
|
199
|
-
pending.reject(new Error(message.error.message));
|
|
200
|
-
else
|
|
201
|
-
pending.resolve(message.result);
|
|
202
|
-
});
|
|
203
|
-
child.stderr.on("data", (data) => this.emit("stderr", String(data)));
|
|
204
|
-
child.stdin.on("error", (error) => this.#fail(error));
|
|
205
|
-
child.on("error", (error) => this.#fail(error));
|
|
206
|
-
child.on("exit", (code, signal) => this.#fail(new Error(`Codex \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0441\u044F (${signal ?? code ?? "unknown"})`)));
|
|
207
|
-
await this.request("initialize", { clientInfo: { name: "ccv", title: "\u042D\u0444\u0438\u0440", version: "0.28.0" }, capabilities: { experimentalApi: true } });
|
|
208
|
-
this.notify("initialized", {});
|
|
209
|
-
}
|
|
210
|
-
request(method, params = {}) {
|
|
211
|
-
if (!this.#child || this.#closed)
|
|
212
|
-
return Promise.reject(new Error("Codex \u043D\u0435 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0451\u043D"));
|
|
213
|
-
const id = ++this.#nextId;
|
|
214
|
-
return new Promise((resolve, reject) => {
|
|
215
|
-
const timer = setTimeout(() => {
|
|
216
|
-
this.#pending.delete(id);
|
|
217
|
-
reject(new Error(`Codex: \u0432\u0440\u0435\u043C\u044F \u043E\u0436\u0438\u0434\u0430\u043D\u0438\u044F ${method} \u0438\u0441\u0442\u0435\u043A\u043B\u043E`));
|
|
218
|
-
}, 6e4);
|
|
219
|
-
this.#pending.set(id, { resolve, reject, timer });
|
|
220
|
-
this.#write({ id, method, params });
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
notify(method, params) {
|
|
224
|
-
this.#write({ method, params });
|
|
225
|
-
}
|
|
226
|
-
respond(id, result) {
|
|
227
|
-
this.#write({ id, result });
|
|
228
|
-
}
|
|
229
|
-
reject(id, message) {
|
|
230
|
-
this.#write({ id, error: { code: -32601, message } });
|
|
231
|
-
}
|
|
232
|
-
#write(message) {
|
|
233
|
-
if (this.#child && !this.#closed)
|
|
234
|
-
this.#child.stdin.write(JSON.stringify(message) + "\n");
|
|
235
|
-
}
|
|
236
|
-
#fail(error) {
|
|
237
|
-
if (this.#closed)
|
|
238
|
-
return;
|
|
239
|
-
this.#closed = true;
|
|
240
|
-
for (const pending of this.#pending.values()) {
|
|
241
|
-
clearTimeout(pending.timer);
|
|
242
|
-
pending.reject(error);
|
|
243
|
-
}
|
|
244
|
-
this.#pending.clear();
|
|
245
|
-
this.emit("disconnect", error);
|
|
246
|
-
}
|
|
247
|
-
async close() {
|
|
248
|
-
this.#fail(new Error("Codex \u043E\u0442\u043A\u043B\u044E\u0447\u0451\u043D"));
|
|
249
|
-
const child = this.#child;
|
|
250
|
-
this.#child = null;
|
|
251
|
-
child?.stdin.end();
|
|
252
|
-
if (child?.pid && process.platform === "win32") {
|
|
253
|
-
await new Promise((resolve) => execFile2("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 5e3 }, () => resolve()));
|
|
254
|
-
} else
|
|
255
|
-
child?.kill();
|
|
256
|
-
await this.#exited;
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
131
|
// ../host/dist/config.js
|
|
261
132
|
import os from "node:os";
|
|
262
|
-
import
|
|
133
|
+
import path2 from "node:path";
|
|
263
134
|
function envDefaults() {
|
|
264
135
|
return {
|
|
265
136
|
port: Number(process.env.CCV_PORT ?? 8787),
|
|
266
137
|
// Только loopback. Наружу этот порт не выставляется — снаружи будет relay.
|
|
267
138
|
host: process.env.CCV_HOST ?? "127.0.0.1",
|
|
268
|
-
dataDir: process.env.CCV_DATA_DIR ??
|
|
139
|
+
dataDir: process.env.CCV_DATA_DIR ?? path2.join(os.homedir(), ".claude-code-visual"),
|
|
269
140
|
// Куда сопрягаться за удалённым доступом. Переопределяется ради своего
|
|
270
141
|
// relay — и ради прогона всей связки на одной машине.
|
|
271
142
|
relayUrl: process.env.CCV_RELAY_URL ?? "https://claudevisual.com"
|
|
@@ -274,10 +145,10 @@ function envDefaults() {
|
|
|
274
145
|
|
|
275
146
|
// ../host/dist/server.js
|
|
276
147
|
import { createServer } from "node:http";
|
|
277
|
-
import { createReadStream, existsSync as
|
|
278
|
-
import
|
|
279
|
-
import { homedir as
|
|
280
|
-
import { randomUUID as
|
|
148
|
+
import { createReadStream, existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
149
|
+
import path23 from "node:path";
|
|
150
|
+
import { homedir as homedir6 } from "node:os";
|
|
151
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
281
152
|
import { WebSocketServer } from "ws";
|
|
282
153
|
import { renameSession as renameSession2 } from "@anthropic-ai/claude-agent-sdk";
|
|
283
154
|
|
|
@@ -316,12 +187,12 @@ function hashText(text) {
|
|
|
316
187
|
// ../host/dist/workspace-ids.js
|
|
317
188
|
function workspaceIdRemap(paths, sessionsOf) {
|
|
318
189
|
const byLegacy = /* @__PURE__ */ new Map();
|
|
319
|
-
for (const
|
|
320
|
-
const id = workspaceIdFromPath(
|
|
321
|
-
for (const legacy of formerWorkspaceIdsFromPath(
|
|
190
|
+
for (const path25 of paths) {
|
|
191
|
+
const id = workspaceIdFromPath(path25);
|
|
192
|
+
for (const legacy of formerWorkspaceIdsFromPath(path25)) {
|
|
322
193
|
const group = byLegacy.get(legacy) ?? [];
|
|
323
194
|
if (!group.some((target) => target.id === id))
|
|
324
|
-
group.push({ id, path:
|
|
195
|
+
group.push({ id, path: path25 });
|
|
325
196
|
byLegacy.set(legacy, group);
|
|
326
197
|
}
|
|
327
198
|
}
|
|
@@ -352,9 +223,9 @@ function workspaceIdRemap(paths, sessionsOf) {
|
|
|
352
223
|
}
|
|
353
224
|
|
|
354
225
|
// ../host/dist/session.js
|
|
355
|
-
import { EventEmitter as
|
|
226
|
+
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
356
227
|
import { randomUUID } from "node:crypto";
|
|
357
|
-
import
|
|
228
|
+
import path5 from "node:path";
|
|
358
229
|
import { query, renameSession } from "@anthropic-ai/claude-agent-sdk";
|
|
359
230
|
|
|
360
231
|
// ../host/dist/async-queue.js
|
|
@@ -406,7 +277,7 @@ var AsyncQueue = class {
|
|
|
406
277
|
|
|
407
278
|
// ../host/dist/files.js
|
|
408
279
|
import { cp, lstat, mkdir, readFile as readFile2, readdir, realpath, rename as renamePath, rm, stat, writeFile } from "node:fs/promises";
|
|
409
|
-
import
|
|
280
|
+
import path3 from "node:path";
|
|
410
281
|
var MAX_FILE = 4 * 1024 * 1024;
|
|
411
282
|
var MAX_MEDIA = 64 * 1024 * 1024;
|
|
412
283
|
var MEDIA_MIME = {
|
|
@@ -444,7 +315,7 @@ var ProjectFiles = class {
|
|
|
444
315
|
for (const dirent of names2) {
|
|
445
316
|
if (HIDDEN.has(dirent.name))
|
|
446
317
|
continue;
|
|
447
|
-
const full =
|
|
318
|
+
const full = path3.join(dir, dirent.name);
|
|
448
319
|
const link = dirent.isSymbolicLink();
|
|
449
320
|
const info = await stat(full).catch(() => null);
|
|
450
321
|
if (!info)
|
|
@@ -492,7 +363,7 @@ var ProjectFiles = class {
|
|
|
492
363
|
return;
|
|
493
364
|
if (SEARCH_SKIP.has(dirent.name))
|
|
494
365
|
continue;
|
|
495
|
-
const full =
|
|
366
|
+
const full = path3.join(dir, dirent.name);
|
|
496
367
|
const rel = join(relative, dirent.name);
|
|
497
368
|
const info = await stat(full).catch(() => null);
|
|
498
369
|
if (!info)
|
|
@@ -547,7 +418,7 @@ var ProjectFiles = class {
|
|
|
547
418
|
return;
|
|
548
419
|
if (SEARCH_SKIP.has(dirent.name) || dirent.isSymbolicLink())
|
|
549
420
|
continue;
|
|
550
|
-
const full =
|
|
421
|
+
const full = path3.join(dir, dirent.name);
|
|
551
422
|
const rel = join(relative, dirent.name);
|
|
552
423
|
if (dirent.isDirectory()) {
|
|
553
424
|
await walk(full, rel);
|
|
@@ -615,7 +486,7 @@ var ProjectFiles = class {
|
|
|
615
486
|
binary: false,
|
|
616
487
|
tooLarge: false
|
|
617
488
|
};
|
|
618
|
-
const mediaMime = MEDIA_MIME[
|
|
489
|
+
const mediaMime = MEDIA_MIME[path3.extname(file).toLowerCase()];
|
|
619
490
|
if (mediaMime) {
|
|
620
491
|
if (info.size > MAX_MEDIA)
|
|
621
492
|
return { ...blank, binary: true, mediaMime, mediaTooLarge: true };
|
|
@@ -646,7 +517,7 @@ var ProjectFiles = class {
|
|
|
646
517
|
*/
|
|
647
518
|
async readMedia(relative) {
|
|
648
519
|
const file = await this.#resolve(relative);
|
|
649
|
-
const mime = MEDIA_MIME[
|
|
520
|
+
const mime = MEDIA_MIME[path3.extname(file).toLowerCase()];
|
|
650
521
|
if (!mime)
|
|
651
522
|
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");
|
|
652
523
|
const info = await stat(file);
|
|
@@ -688,7 +559,7 @@ var ProjectFiles = class {
|
|
|
688
559
|
await mkdir(target, { recursive: true });
|
|
689
560
|
return;
|
|
690
561
|
}
|
|
691
|
-
await mkdir(
|
|
562
|
+
await mkdir(path3.dirname(target), { recursive: true });
|
|
692
563
|
await writeFile(target, "", { encoding: "utf8", flag: "wx" });
|
|
693
564
|
}
|
|
694
565
|
async rename(relative, to) {
|
|
@@ -698,7 +569,7 @@ var ProjectFiles = class {
|
|
|
698
569
|
return;
|
|
699
570
|
if (await exists(target))
|
|
700
571
|
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");
|
|
701
|
-
await mkdir(
|
|
572
|
+
await mkdir(path3.dirname(target), { recursive: true });
|
|
702
573
|
await renamePath(from, target);
|
|
703
574
|
}
|
|
704
575
|
/**
|
|
@@ -731,7 +602,7 @@ var ProjectFiles = class {
|
|
|
731
602
|
if (!await exists(to))
|
|
732
603
|
break;
|
|
733
604
|
}
|
|
734
|
-
await mkdir(
|
|
605
|
+
await mkdir(path3.dirname(to), { recursive: true });
|
|
735
606
|
await cp(from, to, { recursive: true, errorOnExist: true, force: false });
|
|
736
607
|
return target;
|
|
737
608
|
}
|
|
@@ -751,15 +622,15 @@ var ProjectFiles = class {
|
|
|
751
622
|
*/
|
|
752
623
|
async #resolve(relative) {
|
|
753
624
|
const clean = normalize(relative);
|
|
754
|
-
if (
|
|
625
|
+
if (path3.isAbsolute(clean) || /^[A-Za-z]:/.test(clean)) {
|
|
755
626
|
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");
|
|
756
627
|
}
|
|
757
628
|
if (clean.split("/").includes("..")) {
|
|
758
629
|
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");
|
|
759
630
|
}
|
|
760
631
|
const root = this.#root ??= await realpath(this.cwd);
|
|
761
|
-
const target =
|
|
762
|
-
const probe = await exists(target) ? target :
|
|
632
|
+
const target = path3.resolve(root, clean);
|
|
633
|
+
const probe = await exists(target) ? target : path3.dirname(target);
|
|
763
634
|
const real = await realpath(probe).catch(() => probe);
|
|
764
635
|
if (!contains(root, real)) {
|
|
765
636
|
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");
|
|
@@ -780,7 +651,7 @@ function join(dir, name) {
|
|
|
780
651
|
function contains(root, target) {
|
|
781
652
|
if (target === root)
|
|
782
653
|
return true;
|
|
783
|
-
const prefix = root.endsWith(
|
|
654
|
+
const prefix = root.endsWith(path3.sep) ? root : root + path3.sep;
|
|
784
655
|
return process.platform === "win32" ? target.toLowerCase().startsWith(prefix.toLowerCase()) : target.startsWith(prefix);
|
|
785
656
|
}
|
|
786
657
|
async function exists(file) {
|
|
@@ -917,7 +788,7 @@ var Journal = class {
|
|
|
917
788
|
};
|
|
918
789
|
|
|
919
790
|
// ../host/dist/network-guard.js
|
|
920
|
-
import { EventEmitter
|
|
791
|
+
import { EventEmitter } from "node:events";
|
|
921
792
|
import { request } from "node:https";
|
|
922
793
|
import { networkInterfaces } from "node:os";
|
|
923
794
|
var TRACE_URL = "https://api.anthropic.com/cdn-cgi/trace";
|
|
@@ -927,7 +798,7 @@ var CHECK_TIMEOUT_MS = 4e3;
|
|
|
927
798
|
var RETRY_DELAY_MS = 1e3;
|
|
928
799
|
var NETWORK_FRESH_MS = 3e3;
|
|
929
800
|
var UNCHECKED_REASON = "\u041C\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043E Anthropic \u0435\u0449\u0451 \u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D";
|
|
930
|
-
var NetworkGuard = class extends
|
|
801
|
+
var NetworkGuard = class extends EventEmitter {
|
|
931
802
|
#enabled = false;
|
|
932
803
|
#blocked = /* @__PURE__ */ new Set();
|
|
933
804
|
#state = {
|
|
@@ -1085,15 +956,15 @@ function interfacesSignature() {
|
|
|
1085
956
|
|
|
1086
957
|
// ../host/dist/settings.js
|
|
1087
958
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
1088
|
-
import { homedir as
|
|
1089
|
-
import
|
|
1090
|
-
var USER_SETTINGS =
|
|
1091
|
-
var PROJECT_SETTINGS =
|
|
1092
|
-
var LOCAL_SETTINGS =
|
|
959
|
+
import { homedir as homedir2 } from "node:os";
|
|
960
|
+
import path4 from "node:path";
|
|
961
|
+
var USER_SETTINGS = path4.join(homedir2(), ".claude", "settings.json");
|
|
962
|
+
var PROJECT_SETTINGS = path4.join(".claude", "settings.json");
|
|
963
|
+
var LOCAL_SETTINGS = path4.join(".claude", "settings.local.json");
|
|
1093
964
|
function managedSettingsPath() {
|
|
1094
965
|
switch (process.platform) {
|
|
1095
966
|
case "win32":
|
|
1096
|
-
return
|
|
967
|
+
return path4.join(process.env.PROGRAMDATA ?? "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
|
|
1097
968
|
case "darwin":
|
|
1098
969
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
1099
970
|
default:
|
|
@@ -1104,8 +975,8 @@ var EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
|
1104
975
|
async function readConfiguredDefaults(cwd) {
|
|
1105
976
|
const files = [
|
|
1106
977
|
USER_SETTINGS,
|
|
1107
|
-
|
|
1108
|
-
|
|
978
|
+
path4.join(cwd, PROJECT_SETTINGS),
|
|
979
|
+
path4.join(cwd, LOCAL_SETTINGS),
|
|
1109
980
|
managedSettingsPath()
|
|
1110
981
|
];
|
|
1111
982
|
const result = {
|
|
@@ -1472,7 +1343,7 @@ var INTERRUPT_SETTLE_MS = 15e3;
|
|
|
1472
1343
|
var TASK_STOP_TIMEOUT_MS = 5e3;
|
|
1473
1344
|
var TASK_WAKE_MS = 5e3;
|
|
1474
1345
|
var CONTEXT_MIN_INTERVAL_MS = 5e3;
|
|
1475
|
-
var ClaudeSession = class extends
|
|
1346
|
+
var ClaudeSession = class extends EventEmitter2 {
|
|
1476
1347
|
id;
|
|
1477
1348
|
workspaceId;
|
|
1478
1349
|
cwd;
|
|
@@ -2635,7 +2506,7 @@ var ClaudeSession = class extends EventEmitter3 {
|
|
|
2635
2506
|
const target = writeTarget(input.tool_input);
|
|
2636
2507
|
if (!target)
|
|
2637
2508
|
return pass;
|
|
2638
|
-
const absolute =
|
|
2509
|
+
const absolute = path5.resolve(this.cwd, target);
|
|
2639
2510
|
if (roots.some((root) => contains(root, absolute)))
|
|
2640
2511
|
return pass;
|
|
2641
2512
|
return {
|
|
@@ -3261,35 +3132,35 @@ function contentToText2(content) {
|
|
|
3261
3132
|
}
|
|
3262
3133
|
|
|
3263
3134
|
// ../host/dist/antigravity-session.js
|
|
3264
|
-
import { EventEmitter as
|
|
3265
|
-
import { spawn as
|
|
3135
|
+
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
3136
|
+
import { spawn as spawn2, execFile as execFile3 } from "node:child_process";
|
|
3266
3137
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
3267
3138
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
3268
3139
|
import { tmpdir } from "node:os";
|
|
3269
|
-
import
|
|
3270
|
-
import { createInterface
|
|
3140
|
+
import path7 from "node:path";
|
|
3141
|
+
import { createInterface } from "node:readline";
|
|
3271
3142
|
|
|
3272
3143
|
// ../host/dist/antigravity-cli.js
|
|
3273
|
-
import { execFile as
|
|
3274
|
-
import { existsSync
|
|
3275
|
-
import { homedir as
|
|
3276
|
-
import
|
|
3144
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
3145
|
+
import { existsSync } from "node:fs";
|
|
3146
|
+
import { homedir as homedir3 } from "node:os";
|
|
3147
|
+
import path6 from "node:path";
|
|
3277
3148
|
function agyExecutable() {
|
|
3278
3149
|
const forced = process.env.CCV_AGY_PATH;
|
|
3279
|
-
if (forced &&
|
|
3150
|
+
if (forced && existsSync(forced))
|
|
3280
3151
|
return forced;
|
|
3281
3152
|
const names2 = process.platform === "win32" ? ["agy.exe", "agy"] : ["agy"];
|
|
3282
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
3153
|
+
const dirs = (process.env.PATH ?? "").split(path6.delimiter).filter(Boolean);
|
|
3283
3154
|
if (process.platform === "win32") {
|
|
3284
|
-
const local = process.env.LOCALAPPDATA ??
|
|
3285
|
-
dirs.push(
|
|
3155
|
+
const local = process.env.LOCALAPPDATA ?? path6.join(homedir3(), "AppData", "Local");
|
|
3156
|
+
dirs.push(path6.join(local, "agy", "bin"));
|
|
3286
3157
|
} else {
|
|
3287
|
-
dirs.push(
|
|
3158
|
+
dirs.push(path6.join(homedir3(), ".local", "bin"), "/usr/local/bin", "/opt/homebrew/bin");
|
|
3288
3159
|
}
|
|
3289
3160
|
for (const dir of dirs) {
|
|
3290
3161
|
for (const name of names2) {
|
|
3291
|
-
const candidate =
|
|
3292
|
-
if (
|
|
3162
|
+
const candidate = path6.join(dir, name);
|
|
3163
|
+
if (existsSync(candidate))
|
|
3293
3164
|
return candidate;
|
|
3294
3165
|
}
|
|
3295
3166
|
}
|
|
@@ -3301,7 +3172,7 @@ function agyModels(file) {
|
|
|
3301
3172
|
if (modelsCache)
|
|
3302
3173
|
return modelsCache;
|
|
3303
3174
|
const pending = new Promise((resolve) => {
|
|
3304
|
-
|
|
3175
|
+
execFile2(file, ["models"], { timeout: 3e4, windowsHide: true }, (error, stdout) => {
|
|
3305
3176
|
if (error) {
|
|
3306
3177
|
resolve([]);
|
|
3307
3178
|
return;
|
|
@@ -3334,7 +3205,7 @@ function agyModels(file) {
|
|
|
3334
3205
|
}
|
|
3335
3206
|
function agyCommand(file, command, cwd) {
|
|
3336
3207
|
return new Promise((resolve) => {
|
|
3337
|
-
|
|
3208
|
+
execFile2(file, ["--output-format", "json", "-p", command], {
|
|
3338
3209
|
cwd,
|
|
3339
3210
|
timeout: 6e4,
|
|
3340
3211
|
windowsHide: true,
|
|
@@ -3481,7 +3352,7 @@ function agyContextWindow(model) {
|
|
|
3481
3352
|
|
|
3482
3353
|
// ../host/dist/antigravity-session.js
|
|
3483
3354
|
var TRANSIENT = /* @__PURE__ */ new Set(["assistant.delta", "thinking.delta", "state"]);
|
|
3484
|
-
var AntigravitySession = class extends
|
|
3355
|
+
var AntigravitySession = class extends EventEmitter3 {
|
|
3485
3356
|
id;
|
|
3486
3357
|
workspaceId;
|
|
3487
3358
|
cwd;
|
|
@@ -3685,7 +3556,7 @@ var AntigravitySession = class extends EventEmitter4 {
|
|
|
3685
3556
|
return;
|
|
3686
3557
|
let child;
|
|
3687
3558
|
try {
|
|
3688
|
-
child =
|
|
3559
|
+
child = spawn2(this.#executable, this.#args(), {
|
|
3689
3560
|
cwd: this.cwd,
|
|
3690
3561
|
windowsHide: true,
|
|
3691
3562
|
env: { ...process.env, NO_COLOR: "1" }
|
|
@@ -3700,7 +3571,7 @@ var AntigravitySession = class extends EventEmitter4 {
|
|
|
3700
3571
|
this.#texts.clear();
|
|
3701
3572
|
this.#thinking.clear();
|
|
3702
3573
|
this.#tools.clear();
|
|
3703
|
-
const lines =
|
|
3574
|
+
const lines = createInterface({ input: child.stdout });
|
|
3704
3575
|
lines.on("line", (line) => {
|
|
3705
3576
|
if (this.#child !== child)
|
|
3706
3577
|
return;
|
|
@@ -3758,7 +3629,7 @@ var AntigravitySession = class extends EventEmitter4 {
|
|
|
3758
3629
|
} catch {
|
|
3759
3630
|
}
|
|
3760
3631
|
if (process.platform === "win32" && child.pid) {
|
|
3761
|
-
|
|
3632
|
+
execFile3("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true }, () => {
|
|
3762
3633
|
if (child.exitCode === null)
|
|
3763
3634
|
child.kill();
|
|
3764
3635
|
});
|
|
@@ -3954,12 +3825,12 @@ var AntigravitySession = class extends EventEmitter4 {
|
|
|
3954
3825
|
async #composePrompt(text, images) {
|
|
3955
3826
|
if (!images || images.length === 0)
|
|
3956
3827
|
return text;
|
|
3957
|
-
const dir =
|
|
3828
|
+
const dir = path7.join(tmpdir(), "ccv-antigravity", this.id);
|
|
3958
3829
|
await mkdir2(dir, { recursive: true });
|
|
3959
3830
|
const paths = [];
|
|
3960
3831
|
for (const image of images) {
|
|
3961
3832
|
const ext = image.mediaType.split("/")[1] === "jpeg" ? "jpg" : image.mediaType.split("/")[1];
|
|
3962
|
-
const file =
|
|
3833
|
+
const file = path7.join(dir, `${randomUUID2()}.${ext}`);
|
|
3963
3834
|
await writeFile2(file, Buffer.from(image.data, "base64"));
|
|
3964
3835
|
paths.push(file);
|
|
3965
3836
|
}
|
|
@@ -4346,837 +4217,18 @@ function describe2(error) {
|
|
|
4346
4217
|
return error instanceof Error ? error.message : String(error);
|
|
4347
4218
|
}
|
|
4348
4219
|
|
|
4349
|
-
// ../host/dist/codex-session.js
|
|
4350
|
-
import { EventEmitter as EventEmitter5 } from "node:events";
|
|
4351
|
-
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
4352
|
-
import { execFile as execFile5 } from "node:child_process";
|
|
4353
|
-
import { promisify } from "node:util";
|
|
4354
|
-
|
|
4355
|
-
// ../host/dist/codex-commands.js
|
|
4356
|
-
var CODEX_COMMANDS = [
|
|
4357
|
-
["help", "\u0412\u0441\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u044B Codex", ""],
|
|
4358
|
-
["model", "\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u043C\u043E\u0434\u0435\u043B\u0438 \u0438 \u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 \u043C\u043E\u0434\u0435\u043B\u0438", "<model>"],
|
|
4359
|
-
["effort", "\u0423\u0440\u043E\u0432\u0435\u043D\u044C \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u044F: low, medium, high, xhigh", "<level>"],
|
|
4360
|
-
["permissions", "Codex permissions: default, auto, bypassPermissions, plan", "<mode>"],
|
|
4361
|
-
["plan", "\u0412\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0438\u043B\u0438 \u0432\u044B\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0440\u0435\u0436\u0438\u043C \u043F\u043B\u0430\u043D\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F", ""],
|
|
4362
|
-
["status", "\u0410\u043A\u043A\u0430\u0443\u043D\u0442 \u0438 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 Codex", ""],
|
|
4363
|
-
["login", "\u0412\u043E\u0439\u0442\u0438 \u0432 ChatGPT \u043F\u043E \u043A\u043E\u0434\u0443", ""],
|
|
4364
|
-
["logout", "\u0412\u044B\u0439\u0442\u0438 \u0438\u0437 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 Codex", ""],
|
|
4365
|
-
["compact", "\u0421\u0436\u0430\u0442\u044C \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442 \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440\u0430", ""],
|
|
4366
|
-
["review", "\u041F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F \u0432 \u0440\u0430\u0431\u043E\u0447\u0435\u043C \u0434\u0435\u0440\u0435\u0432\u0435", ""],
|
|
4367
|
-
["diff", "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F Git", ""],
|
|
4368
|
-
["rename", "\u041F\u0435\u0440\u0435\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u0442\u044C \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440", "<title>"],
|
|
4369
|
-
["mcp", "\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0451\u043D\u043D\u044B\u0435 MCP-\u0441\u0435\u0440\u0432\u0435\u0440\u044B", ""],
|
|
4370
|
-
["skills", "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0441\u043F\u0438\u0441\u043E\u043A \u043D\u0430\u0432\u044B\u043A\u043E\u0432 \u0438 \u043F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0438 \u043A\u043E\u043C\u0430\u043D\u0434", ""],
|
|
4371
|
-
["init", "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u0438 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 AGENTS.md", ""],
|
|
4372
|
-
["new", "\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440", ""],
|
|
4373
|
-
["clear", "\u041D\u0430\u0447\u0430\u0442\u044C \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440 \u0441 \u0447\u0438\u0441\u0442\u044B\u043C \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u043E\u043C", ""],
|
|
4374
|
-
["resume", "\u041D\u0430\u0439\u0442\u0438 \u0438 \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D\u043D\u044B\u0439 \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440", ""],
|
|
4375
|
-
["fork", "\u041E\u0442\u0432\u0435\u0442\u0432\u0438\u0442\u044C \u0440\u0430\u0437\u0433\u043E\u0432\u043E\u0440 \u0432 \u043D\u043E\u0432\u0443\u044E \u043A\u0430\u0440\u0442\u043E\u0447\u043A\u0443", ""],
|
|
4376
|
-
["stop", "\u041F\u0440\u0435\u0440\u0432\u0430\u0442\u044C \u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u0445\u043E\u0434", ""],
|
|
4377
|
-
["exit", "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0441\u0435\u0441\u0441\u0438\u044E Codex", ""]
|
|
4378
|
-
].map(([name, description, argumentHint]) => ({ name, description, argumentHint, aliases: name === "permissions" ? ["approvals"] : name === "exit" ? ["quit"] : [] }));
|
|
4379
|
-
function isCodexModelPrompt(text) {
|
|
4380
|
-
if (!text.startsWith("/"))
|
|
4381
|
-
return true;
|
|
4382
|
-
const name = text.trim().slice(1).split(/\s+/)[0];
|
|
4383
|
-
return name === "init" || name === "review" || !CODEX_COMMANDS.some((command) => command.name === name || command.aliases.includes(name ?? ""));
|
|
4384
|
-
}
|
|
4385
|
-
function codexSkills(response) {
|
|
4386
|
-
const result = /* @__PURE__ */ new Map();
|
|
4387
|
-
if (!response || typeof response !== "object" || !("data" in response) || !Array.isArray(response.data))
|
|
4388
|
-
return result;
|
|
4389
|
-
for (const group of response.data)
|
|
4390
|
-
for (const skill of Array.isArray(group?.skills) ? group.skills : []) {
|
|
4391
|
-
if (!skill || skill.enabled === false || typeof skill.name !== "string" || typeof skill.path !== "string" || !skill.path || !/^[\w.:-]+$/.test(skill.name))
|
|
4392
|
-
continue;
|
|
4393
|
-
const name = CODEX_COMMANDS.some((c) => c.name === skill.name || c.aliases.includes(skill.name)) ? `skill:${skill.name}` : skill.name;
|
|
4394
|
-
result.set(name, { name: skill.name, path: skill.path, description: skill.interface?.shortDescription ?? skill.description ?? "\u041D\u0430\u0432\u044B\u043A Codex" });
|
|
4395
|
-
}
|
|
4396
|
-
return result;
|
|
4397
|
-
}
|
|
4398
|
-
|
|
4399
|
-
// ../host/dist/codex-session.js
|
|
4400
|
-
var TRANSIENT2 = /* @__PURE__ */ new Set(["assistant.delta", "thinking.delta", "state"]);
|
|
4401
|
-
var execFileAsync = promisify(execFile5);
|
|
4402
|
-
var CodexSession = class extends EventEmitter5 {
|
|
4403
|
-
provider = "codex";
|
|
4404
|
-
id;
|
|
4405
|
-
workspaceId;
|
|
4406
|
-
cwd;
|
|
4407
|
-
journal = new Journal();
|
|
4408
|
-
parentSessionId = null;
|
|
4409
|
-
#options;
|
|
4410
|
-
#store;
|
|
4411
|
-
#record;
|
|
4412
|
-
#client = null;
|
|
4413
|
-
#skills = /* @__PURE__ */ new Map();
|
|
4414
|
-
#closing = Promise.resolve();
|
|
4415
|
-
#state = "starting";
|
|
4416
|
-
#lastTurn = null;
|
|
4417
|
-
#capabilities = null;
|
|
4418
|
-
#usage = null;
|
|
4419
|
-
#context = null;
|
|
4420
|
-
#history;
|
|
4421
|
-
#ready = Promise.resolve();
|
|
4422
|
-
#queue = Promise.resolve();
|
|
4423
|
-
#generation = 0;
|
|
4424
|
-
#turnId = null;
|
|
4425
|
-
#interruptRequested = false;
|
|
4426
|
-
#forkPending;
|
|
4427
|
-
#turnDone = null;
|
|
4428
|
-
#startedAt = 0;
|
|
4429
|
-
#permissions = /* @__PURE__ */ new Map();
|
|
4430
|
-
#texts = /* @__PURE__ */ new Map();
|
|
4431
|
-
#thinking = /* @__PURE__ */ new Map();
|
|
4432
|
-
#tools = /* @__PURE__ */ new Set();
|
|
4433
|
-
constructor(options2) {
|
|
4434
|
-
super();
|
|
4435
|
-
this.#options = options2;
|
|
4436
|
-
this.#forkPending = options2.fork ?? false;
|
|
4437
|
-
this.#store = options2.store;
|
|
4438
|
-
const now = Date.now();
|
|
4439
|
-
this.#record = options2.record ? { ...options2.record } : {
|
|
4440
|
-
id: randomUUID3(),
|
|
4441
|
-
conversationId: null,
|
|
4442
|
-
workspaceId: options2.workspaceId,
|
|
4443
|
-
cwd: options2.cwd,
|
|
4444
|
-
title: options2.defaultTitle ?? null,
|
|
4445
|
-
model: options2.model ?? null,
|
|
4446
|
-
permissionMode: options2.permissionMode ?? "default",
|
|
4447
|
-
effort: null,
|
|
4448
|
-
createdAt: now,
|
|
4449
|
-
updatedAt: now
|
|
4450
|
-
};
|
|
4451
|
-
if (options2.fork)
|
|
4452
|
-
this.#record = { ...this.#record, id: randomUUID3(), createdAt: now, updatedAt: now };
|
|
4453
|
-
if (options2.model)
|
|
4454
|
-
this.#record.model = options2.model;
|
|
4455
|
-
if (options2.permissionMode)
|
|
4456
|
-
this.#record.permissionMode = options2.permissionMode;
|
|
4457
|
-
this.id = this.#record.id;
|
|
4458
|
-
this.workspaceId = options2.workspaceId;
|
|
4459
|
-
this.cwd = options2.cwd;
|
|
4460
|
-
this.#history = options2.record ? this.#store.readEvents(options2.record.id) : Promise.resolve([]);
|
|
4461
|
-
}
|
|
4462
|
-
get state() {
|
|
4463
|
-
return this.#state;
|
|
4464
|
-
}
|
|
4465
|
-
get claudeSessionId() {
|
|
4466
|
-
return this.id;
|
|
4467
|
-
}
|
|
4468
|
-
get capabilities() {
|
|
4469
|
-
return this.#capabilities;
|
|
4470
|
-
}
|
|
4471
|
-
get usage() {
|
|
4472
|
-
return this.#usage;
|
|
4473
|
-
}
|
|
4474
|
-
get context() {
|
|
4475
|
-
return this.#context;
|
|
4476
|
-
}
|
|
4477
|
-
async history() {
|
|
4478
|
-
await this.#ready;
|
|
4479
|
-
return this.#history;
|
|
4480
|
-
}
|
|
4481
|
-
summary() {
|
|
4482
|
-
return {
|
|
4483
|
-
id: this.id,
|
|
4484
|
-
provider: "codex",
|
|
4485
|
-
claudeSessionId: this.id,
|
|
4486
|
-
workspaceId: this.workspaceId,
|
|
4487
|
-
cwd: this.cwd,
|
|
4488
|
-
parentSessionId: null,
|
|
4489
|
-
title: this.#record.title,
|
|
4490
|
-
state: this.#state,
|
|
4491
|
-
lastTurn: this.#lastTurn,
|
|
4492
|
-
backgroundWork: false,
|
|
4493
|
-
tasks: [],
|
|
4494
|
-
model: this.#record.model,
|
|
4495
|
-
permissionMode: this.#record.permissionMode,
|
|
4496
|
-
effort: this.#record.effort,
|
|
4497
|
-
ultracode: false,
|
|
4498
|
-
thinking: true,
|
|
4499
|
-
switchModelsOnFlag: false,
|
|
4500
|
-
createdAt: this.#record.createdAt,
|
|
4501
|
-
updatedAt: this.#record.updatedAt,
|
|
4502
|
-
lastSeq: this.journal.lastSeq,
|
|
4503
|
-
totalCostUsd: 0
|
|
4504
|
-
};
|
|
4505
|
-
}
|
|
4506
|
-
start() {
|
|
4507
|
-
this.#ready = this.#connect().catch((error) => this.#fail(error));
|
|
4508
|
-
}
|
|
4509
|
-
async #connect() {
|
|
4510
|
-
const client = new CodexClient();
|
|
4511
|
-
this.#client = client;
|
|
4512
|
-
client.on("message", (message) => {
|
|
4513
|
-
if (this.#client !== client)
|
|
4514
|
-
return;
|
|
4515
|
-
try {
|
|
4516
|
-
this.#message(message);
|
|
4517
|
-
} catch (error) {
|
|
4518
|
-
this.#fail(error);
|
|
4519
|
-
}
|
|
4520
|
-
});
|
|
4521
|
-
client.on("stderr", (data) => this.emit("stderr", data));
|
|
4522
|
-
client.on("disconnect", (error) => {
|
|
4523
|
-
if (this.#client === client && this.#state !== "closed")
|
|
4524
|
-
this.#fail(error);
|
|
4525
|
-
});
|
|
4526
|
-
await client.start(this.cwd);
|
|
4527
|
-
const policy = this.#policy();
|
|
4528
|
-
const forking = this.#forkPending;
|
|
4529
|
-
const params = {
|
|
4530
|
-
cwd: this.cwd,
|
|
4531
|
-
...this.#record.model ? { model: this.#record.model } : {},
|
|
4532
|
-
approvalPolicy: policy.approvalPolicy,
|
|
4533
|
-
sandbox: policy.sandbox,
|
|
4534
|
-
approvalsReviewer: policy.approvalsReviewer
|
|
4535
|
-
};
|
|
4536
|
-
let response;
|
|
4537
|
-
let recreatedEmpty = false;
|
|
4538
|
-
try {
|
|
4539
|
-
response = await client.request(this.#record.conversationId ? forking ? "thread/fork" : "thread/resume" : "thread/start", {
|
|
4540
|
-
...params,
|
|
4541
|
-
...this.#record.conversationId ? { threadId: this.#record.conversationId } : {}
|
|
4542
|
-
});
|
|
4543
|
-
} catch (error) {
|
|
4544
|
-
const history = await this.#history;
|
|
4545
|
-
const hasModelTurns = history.some(({ event }) => event.kind === "result" || event.kind === "tool.use" || event.kind === "user.message" && !event.text.startsWith("/"));
|
|
4546
|
-
if (!this.#record.conversationId || hasModelTurns || !/no rollout found|thread.*not found/i.test(String(error)))
|
|
4547
|
-
throw error;
|
|
4548
|
-
response = await client.request("thread/start", params);
|
|
4549
|
-
recreatedEmpty = true;
|
|
4550
|
-
}
|
|
4551
|
-
if (this.#client !== client || this.#state === "closed")
|
|
4552
|
-
return;
|
|
4553
|
-
this.#record.conversationId = response.thread.id;
|
|
4554
|
-
this.#forkPending = false;
|
|
4555
|
-
this.#record.model = response.model;
|
|
4556
|
-
this.#record.effort ??= this.#effort(response.reasoningEffort);
|
|
4557
|
-
if (this.#record.conversationId && (await this.#history).length === 0) {
|
|
4558
|
-
const imported = [];
|
|
4559
|
-
const add = (event) => imported.push({ seq: imported.length + 1, ts: this.#record.createdAt, event });
|
|
4560
|
-
let items = (response.thread.turns ?? []).flatMap((turn) => turn.items ?? []);
|
|
4561
|
-
if (items.length === 0 && this.#options.record && !recreatedEmpty) {
|
|
4562
|
-
let cursor = null;
|
|
4563
|
-
do {
|
|
4564
|
-
const page = await client.request("thread/items/list", { threadId: this.#record.conversationId, cursor, limit: 100, sortDirection: "asc" });
|
|
4565
|
-
items.push(...(page.data ?? []).map((entry) => entry.item));
|
|
4566
|
-
cursor = page.nextCursor ?? null;
|
|
4567
|
-
} while (cursor);
|
|
4568
|
-
}
|
|
4569
|
-
for (const item of items) {
|
|
4570
|
-
if (item.type === "userMessage") {
|
|
4571
|
-
const content = item.content ?? [];
|
|
4572
|
-
const images = content.filter((v) => v.type === "image" && /^data:image\//.test(v.url)).flatMap((v) => {
|
|
4573
|
-
const match = /^data:(image\/(?:png|jpeg|webp|gif));base64,(.+)$/.exec(v.url);
|
|
4574
|
-
return match ? [{ mediaType: match[1], data: match[2] }] : [];
|
|
4575
|
-
});
|
|
4576
|
-
add({ kind: "user.message", text: content.filter((v) => v.type === "text").map((v) => v.text).join("\n"), ...images.length ? { images } : {} });
|
|
4577
|
-
} else if (item.type === "agentMessage" || item.type === "plan")
|
|
4578
|
-
add({ kind: "assistant.text", text: item.text, blockId: item.id });
|
|
4579
|
-
else if (item.type === "reasoning")
|
|
4580
|
-
add({ kind: "assistant.thinking", text: [...item.summary ?? [], ...item.content ?? []].join("\n"), blockId: `${item.id}:thinking` });
|
|
4581
|
-
else if (item.type === "commandExecution") {
|
|
4582
|
-
add({ kind: "tool.use", toolUseId: item.id, name: "Bash", input: { command: item.command } });
|
|
4583
|
-
add({ kind: "tool.result", toolUseId: item.id, content: item.aggregatedOutput ?? "", isError: item.status === "failed" || item.exitCode != null && item.exitCode !== 0 });
|
|
4584
|
-
}
|
|
4585
|
-
}
|
|
4586
|
-
if (imported.length) {
|
|
4587
|
-
this.#history = Promise.resolve(imported);
|
|
4588
|
-
if (!forking)
|
|
4589
|
-
await this.#store.appendEvents(this.id, imported);
|
|
4590
|
-
}
|
|
4591
|
-
}
|
|
4592
|
-
await this.#store.save(this.#record);
|
|
4593
|
-
if (forking) {
|
|
4594
|
-
const events = await this.#history;
|
|
4595
|
-
await this.#store.appendEvents(this.id, events);
|
|
4596
|
-
}
|
|
4597
|
-
const catalog = await client.request("model/list", {}).catch(() => ({ data: [] }));
|
|
4598
|
-
const models = (catalog.data ?? []).filter((m) => !m.hidden).map((m) => ({
|
|
4599
|
-
value: m.model,
|
|
4600
|
-
resolvedModel: m.model,
|
|
4601
|
-
displayName: m.displayName,
|
|
4602
|
-
description: m.description ?? "",
|
|
4603
|
-
supportsEffort: (m.supportedReasoningEfforts ?? []).some((e) => this.#effort(e.reasoningEffort)),
|
|
4604
|
-
effortLevels: (m.supportedReasoningEfforts ?? []).map((e) => this.#effort(e.reasoningEffort)).filter(Boolean),
|
|
4605
|
-
supportsThinking: false,
|
|
4606
|
-
supportsAutoMode: false
|
|
4607
|
-
}));
|
|
4608
|
-
this.#capabilities = {
|
|
4609
|
-
cwd: this.cwd,
|
|
4610
|
-
model: this.#record.model ?? "",
|
|
4611
|
-
permissionMode: this.#record.permissionMode,
|
|
4612
|
-
slashCommands: CODEX_COMMANDS.map((c) => c.name),
|
|
4613
|
-
commands: CODEX_COMMANDS,
|
|
4614
|
-
models,
|
|
4615
|
-
tools: ["shell", "apply_patch", "web_search", "mcp"],
|
|
4616
|
-
agents: [],
|
|
4617
|
-
mcpServers: [],
|
|
4618
|
-
flags: ["codex-app-server"]
|
|
4619
|
-
};
|
|
4620
|
-
await this.#refreshCommands();
|
|
4621
|
-
this.emit("capabilities");
|
|
4622
|
-
this.#setState("idle");
|
|
4623
|
-
void this.refreshUsage().catch(() => {
|
|
4624
|
-
});
|
|
4625
|
-
}
|
|
4626
|
-
async #refreshCommands() {
|
|
4627
|
-
const client = this.#client;
|
|
4628
|
-
if (!client)
|
|
4629
|
-
return;
|
|
4630
|
-
const response = await client.request("skills/list", { cwds: [this.cwd], forceReload: true }).catch(() => null);
|
|
4631
|
-
if (client !== this.#client || this.#state === "closed")
|
|
4632
|
-
return;
|
|
4633
|
-
this.#skills = codexSkills(response);
|
|
4634
|
-
if (!this.#capabilities)
|
|
4635
|
-
return;
|
|
4636
|
-
this.#capabilities.commands = [...CODEX_COMMANDS, ...[...this.#skills.entries()].map(([name, skill]) => ({ name, description: skill.description, argumentHint: "<\u0437\u0430\u0434\u0430\u0447\u0430>", aliases: [] }))];
|
|
4637
|
-
this.#capabilities.slashCommands = this.#capabilities.commands.map((c) => c.name);
|
|
4638
|
-
this.emit("capabilities");
|
|
4639
|
-
}
|
|
4640
|
-
#effort(value) {
|
|
4641
|
-
return ["low", "medium", "high", "xhigh", "max"].includes(String(value)) ? value : null;
|
|
4642
|
-
}
|
|
4643
|
-
#policy() {
|
|
4644
|
-
const mode = this.#record.permissionMode;
|
|
4645
|
-
if (mode === "bypassPermissions")
|
|
4646
|
-
return { approvalPolicy: "never", sandbox: "danger-full-access", sandboxPolicy: { type: "dangerFullAccess" }, approvalsReviewer: "user" };
|
|
4647
|
-
if (mode === "plan")
|
|
4648
|
-
return { approvalPolicy: "on-request", sandbox: "read-only", sandboxPolicy: { type: "readOnly", networkAccess: false }, approvalsReviewer: "user" };
|
|
4649
|
-
const roots = this.#options.writableRoots?.();
|
|
4650
|
-
return {
|
|
4651
|
-
approvalPolicy: mode === "dontAsk" ? "never" : "on-request",
|
|
4652
|
-
sandbox: "workspace-write",
|
|
4653
|
-
approvalsReviewer: mode === "auto" ? "auto_review" : "user",
|
|
4654
|
-
sandboxPolicy: { type: "workspaceWrite", writableRoots: roots ?? [this.cwd], networkAccess: false, excludeTmpdirEnvVar: false, excludeSlashTmp: false }
|
|
4655
|
-
};
|
|
4656
|
-
}
|
|
4657
|
-
sendPrompt(text, images) {
|
|
4658
|
-
if (this.#state === "closed")
|
|
4659
|
-
throw new Error("\u0421\u0435\u0441\u0441\u0438\u044F Codex \u0437\u0430\u043A\u0440\u044B\u0442\u0430");
|
|
4660
|
-
const generation = this.#generation;
|
|
4661
|
-
this.#queue = this.#queue.then(async () => {
|
|
4662
|
-
await this.#ready;
|
|
4663
|
-
if (generation !== this.#generation || this.#state === "closed")
|
|
4664
|
-
return;
|
|
4665
|
-
if (this.#state === "error")
|
|
4666
|
-
throw new Error("\u041F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u0435\u0441\u0441\u0438\u044E Codex");
|
|
4667
|
-
const blocked = networkGuard.blockedReason();
|
|
4668
|
-
if (blocked)
|
|
4669
|
-
throw new Error(blocked);
|
|
4670
|
-
let turnText = text;
|
|
4671
|
-
let skill;
|
|
4672
|
-
if (text.startsWith("/") && !images?.length) {
|
|
4673
|
-
const [name, ...args] = text.trim().slice(1).split(/\s+/);
|
|
4674
|
-
skill = this.#skills.get(name ?? "");
|
|
4675
|
-
if (skill)
|
|
4676
|
-
turnText = `$${skill.name} ${args.join(" ")}`.trim();
|
|
4677
|
-
else if (name === "init")
|
|
4678
|
-
turnText = "Create or update AGENTS.md with concise project-specific instructions based on the repository. Inspect existing instructions first and preserve useful guidance.";
|
|
4679
|
-
else {
|
|
4680
|
-
try {
|
|
4681
|
-
await this.#command(text);
|
|
4682
|
-
} catch (error) {
|
|
4683
|
-
this.#recordEvent({ kind: "error", message: error instanceof Error ? error.message : String(error) });
|
|
4684
|
-
}
|
|
4685
|
-
return;
|
|
4686
|
-
}
|
|
4687
|
-
}
|
|
4688
|
-
this.#interruptRequested = false;
|
|
4689
|
-
this.#recordEvent({ kind: "user.message", text, ...images?.length ? { images } : {} });
|
|
4690
|
-
if (this.#record.title === this.#options.defaultTitle || !this.#record.title)
|
|
4691
|
-
this.setTitle(text.trim().slice(0, 70));
|
|
4692
|
-
this.#startedAt = Date.now();
|
|
4693
|
-
this.#setState("running");
|
|
4694
|
-
const done = new Promise((resolve) => {
|
|
4695
|
-
this.#turnDone = resolve;
|
|
4696
|
-
});
|
|
4697
|
-
const policy = this.#policy();
|
|
4698
|
-
const response = await this.#client.request("turn/start", {
|
|
4699
|
-
threadId: this.#record.conversationId,
|
|
4700
|
-
input: [
|
|
4701
|
-
{ type: "text", text: turnText, text_elements: [] },
|
|
4702
|
-
...skill ? [{ type: "skill", name: skill.name, path: skill.path }] : [],
|
|
4703
|
-
...(images ?? []).map((img) => ({ type: "image", url: `data:${img.mediaType};base64,${img.data}` }))
|
|
4704
|
-
],
|
|
4705
|
-
cwd: this.cwd,
|
|
4706
|
-
approvalPolicy: policy.approvalPolicy,
|
|
4707
|
-
sandboxPolicy: policy.sandboxPolicy,
|
|
4708
|
-
approvalsReviewer: policy.approvalsReviewer,
|
|
4709
|
-
...this.#record.model ? { model: this.#record.model } : {},
|
|
4710
|
-
...this.#record.effort ? { effort: this.#record.effort } : {}
|
|
4711
|
-
});
|
|
4712
|
-
if (this.#turnDone) {
|
|
4713
|
-
this.#turnId = response.turn.id;
|
|
4714
|
-
if (this.#interruptRequested)
|
|
4715
|
-
await this.#interruptTurn();
|
|
4716
|
-
}
|
|
4717
|
-
await done;
|
|
4718
|
-
}).catch((error) => this.#fail(error));
|
|
4719
|
-
}
|
|
4720
|
-
async #command(text) {
|
|
4721
|
-
const [name, ...args] = text.trim().slice(1).split(/\s+/);
|
|
4722
|
-
const arg = args.join(" ");
|
|
4723
|
-
let reply;
|
|
4724
|
-
switch (name) {
|
|
4725
|
-
case "model":
|
|
4726
|
-
if (arg)
|
|
4727
|
-
await this.setModel(arg);
|
|
4728
|
-
reply = `\u041C\u043E\u0434\u0435\u043B\u044C: ${this.#record.model}
|
|
4729
|
-
` + (arg ? "" : (this.#capabilities?.models ?? []).map((m) => `${m.value} \u2014 ${m.displayName}`).join("\n"));
|
|
4730
|
-
break;
|
|
4731
|
-
case "effort":
|
|
4732
|
-
if (arg)
|
|
4733
|
-
await this.setEffort(arg);
|
|
4734
|
-
reply = `\u0423\u0441\u0438\u043B\u0438\u0435: ${this.#record.effort ?? "\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E"}`;
|
|
4735
|
-
break;
|
|
4736
|
-
case "permissions":
|
|
4737
|
-
case "approvals":
|
|
4738
|
-
if (arg)
|
|
4739
|
-
await this.setPermissionMode(arg);
|
|
4740
|
-
reply = `Codex permissions: ${this.#record.permissionMode}
|
|
4741
|
-
Available: default (Ask for approval), auto (Approve for me), bypassPermissions (Full Access), plan (Read Only)`;
|
|
4742
|
-
break;
|
|
4743
|
-
case "plan":
|
|
4744
|
-
await this.setPermissionMode(this.#record.permissionMode === "plan" ? "default" : "plan");
|
|
4745
|
-
reply = `\u0420\u0435\u0436\u0438\u043C \u0434\u043E\u0441\u0442\u0443\u043F\u0430: ${this.#record.permissionMode}`;
|
|
4746
|
-
break;
|
|
4747
|
-
case "rename":
|
|
4748
|
-
if (!arg)
|
|
4749
|
-
throw new Error("\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435: /rename <title>");
|
|
4750
|
-
this.setTitle(arg);
|
|
4751
|
-
reply = `\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435: ${arg}`;
|
|
4752
|
-
break;
|
|
4753
|
-
case "logout":
|
|
4754
|
-
await this.#client.request("account/logout", {});
|
|
4755
|
-
reply = "\u0412\u044B \u0432\u044B\u0448\u043B\u0438 \u0438\u0437 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 Codex.";
|
|
4756
|
-
break;
|
|
4757
|
-
case "review": {
|
|
4758
|
-
this.#recordEvent({ kind: "user.message", text });
|
|
4759
|
-
this.#startedAt = Date.now();
|
|
4760
|
-
this.#interruptRequested = false;
|
|
4761
|
-
this.#setState("running");
|
|
4762
|
-
const done = new Promise((resolve) => {
|
|
4763
|
-
this.#turnDone = resolve;
|
|
4764
|
-
});
|
|
4765
|
-
try {
|
|
4766
|
-
const response = await this.#client.request("review/start", { threadId: this.#record.conversationId, delivery: "inline", target: arg ? { type: "custom", instructions: arg } : { type: "uncommittedChanges" } });
|
|
4767
|
-
if (this.#turnDone)
|
|
4768
|
-
this.#turnId = response.turn.id;
|
|
4769
|
-
await done;
|
|
4770
|
-
} catch (error) {
|
|
4771
|
-
this.#turnDone = null;
|
|
4772
|
-
this.#turnId = null;
|
|
4773
|
-
this.#setState("idle");
|
|
4774
|
-
throw error;
|
|
4775
|
-
}
|
|
4776
|
-
return;
|
|
4777
|
-
}
|
|
4778
|
-
case "diff": {
|
|
4779
|
-
const diff = await execFileAsync("git", ["--no-pager", "diff", "--no-ext-diff", "HEAD", "--"], { cwd: this.cwd, windowsHide: true, maxBuffer: 2 * 1024 * 1024 });
|
|
4780
|
-
reply = diff.stdout.trim() || "\u041D\u0435\u0442 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439 \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0435\u043B\u044C\u043D\u043E HEAD.";
|
|
4781
|
-
break;
|
|
4782
|
-
}
|
|
4783
|
-
case "compact":
|
|
4784
|
-
await this.#client.request("thread/compact/start", { threadId: this.#record.conversationId });
|
|
4785
|
-
reply = "Codex \u043D\u0430\u0447\u0430\u043B \u0441\u0436\u0430\u0442\u0438\u0435 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u0430.";
|
|
4786
|
-
break;
|
|
4787
|
-
case "status":
|
|
4788
|
-
reply = JSON.stringify(await this.#client.request("account/read", {}), null, 2);
|
|
4789
|
-
break;
|
|
4790
|
-
case "login": {
|
|
4791
|
-
const login = await this.#client.request("account/login/start", { type: "chatgptDeviceCode" });
|
|
4792
|
-
reply = `\u0412\u0445\u043E\u0434 \u0432 Codex: ${login.verificationUrl ?? login.authUrl ?? ""}
|
|
4793
|
-
\u041A\u043E\u0434: ${login.userCode ?? ""}`;
|
|
4794
|
-
break;
|
|
4795
|
-
}
|
|
4796
|
-
case "mcp":
|
|
4797
|
-
reply = JSON.stringify(await this.#client.request("mcpServerStatus/list", {}), null, 2);
|
|
4798
|
-
break;
|
|
4799
|
-
case "skills":
|
|
4800
|
-
await this.#refreshCommands();
|
|
4801
|
-
reply = [...this.#skills.entries()].map(([name2, skill]) => `/${name2} \u2014 ${skill.description}`).join("\n") || "\u0412 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435 \u043D\u0430\u0432\u044B\u043A\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B.";
|
|
4802
|
-
break;
|
|
4803
|
-
case "help":
|
|
4804
|
-
reply = (this.#capabilities?.commands ?? CODEX_COMMANDS).map((c) => `/${c.name}${c.argumentHint ? " " + c.argumentHint : ""} \u2014 ${c.description}`).join("\n");
|
|
4805
|
-
break;
|
|
4806
|
-
default:
|
|
4807
|
-
throw new Error(`\u041A\u043E\u043C\u0430\u043D\u0434\u0430 /${name} \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430. \u041D\u0430\u0431\u0435\u0440\u0438\u0442\u0435 /help \u0434\u043B\u044F \u0441\u043F\u0438\u0441\u043A\u0430 \u043A\u043E\u043C\u0430\u043D\u0434.`);
|
|
4808
|
-
}
|
|
4809
|
-
this.#recordEvent({ kind: "user.message", text });
|
|
4810
|
-
this.#recordEvent({ kind: "assistant.text", text: reply, blockId: randomUUID3() });
|
|
4811
|
-
}
|
|
4812
|
-
#message(message) {
|
|
4813
|
-
const p = message.params ?? {};
|
|
4814
|
-
if (p.threadId && this.#record.conversationId && p.threadId !== this.#record.conversationId)
|
|
4815
|
-
return;
|
|
4816
|
-
if (message.id !== void 0 && message.method) {
|
|
4817
|
-
this.#request(message.id, message.method, p);
|
|
4818
|
-
return;
|
|
4819
|
-
}
|
|
4820
|
-
switch (message.method) {
|
|
4821
|
-
case "skills/changed":
|
|
4822
|
-
void this.#refreshCommands().catch(() => {
|
|
4823
|
-
});
|
|
4824
|
-
break;
|
|
4825
|
-
case "turn/started":
|
|
4826
|
-
this.#turnId = p.turn.id;
|
|
4827
|
-
this.#setState("running");
|
|
4828
|
-
if (this.#interruptRequested)
|
|
4829
|
-
void this.#interruptTurn().catch((error) => this.#fail(error));
|
|
4830
|
-
break;
|
|
4831
|
-
case "item/agentMessage/delta": {
|
|
4832
|
-
this.#texts.set(p.itemId, (this.#texts.get(p.itemId) ?? "") + p.delta);
|
|
4833
|
-
this.#recordEvent({ kind: "assistant.delta", text: p.delta, blockId: p.itemId });
|
|
4834
|
-
break;
|
|
4835
|
-
}
|
|
4836
|
-
case "item/reasoning/summaryTextDelta":
|
|
4837
|
-
case "item/reasoning/textDelta": {
|
|
4838
|
-
this.#thinking.set(p.itemId, (this.#thinking.get(p.itemId) ?? "") + p.delta);
|
|
4839
|
-
this.#recordEvent({ kind: "thinking.delta", text: p.delta, blockId: `${p.itemId}:thinking` });
|
|
4840
|
-
break;
|
|
4841
|
-
}
|
|
4842
|
-
case "item/started":
|
|
4843
|
-
this.#item(p.item, false);
|
|
4844
|
-
break;
|
|
4845
|
-
case "item/completed":
|
|
4846
|
-
this.#item(p.item, true);
|
|
4847
|
-
break;
|
|
4848
|
-
case "turn/plan/updated":
|
|
4849
|
-
this.#recordEvent({ kind: "system", subtype: "codex.plan", data: p });
|
|
4850
|
-
break;
|
|
4851
|
-
case "thread/tokenUsage/updated": {
|
|
4852
|
-
const u = p.tokenUsage;
|
|
4853
|
-
if (u?.modelContextWindow) {
|
|
4854
|
-
this.#context = { tokens: u.last.totalTokens, maxTokens: u.modelContextWindow, fetchedAt: Date.now() };
|
|
4855
|
-
this.emit("context", this.#context);
|
|
4856
|
-
}
|
|
4857
|
-
break;
|
|
4858
|
-
}
|
|
4859
|
-
case "account/rateLimits/updated":
|
|
4860
|
-
this.#rateLimits(p.rateLimits);
|
|
4861
|
-
break;
|
|
4862
|
-
case "account/login/completed":
|
|
4863
|
-
this.#recordEvent({ kind: "assistant.text", blockId: randomUUID3(), text: p.success ? "\u0412\u0445\u043E\u0434 \u0432 Codex \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D." : `\u0412\u0445\u043E\u0434 \u043D\u0435 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D: ${p.error ?? ""}` });
|
|
4864
|
-
break;
|
|
4865
|
-
case "error":
|
|
4866
|
-
this.#recordEvent({ kind: "error", message: p.error?.message ?? "\u041E\u0448\u0438\u0431\u043A\u0430 Codex" });
|
|
4867
|
-
break;
|
|
4868
|
-
case "turn/completed": {
|
|
4869
|
-
this.#flush();
|
|
4870
|
-
const status = p.turn.status;
|
|
4871
|
-
this.#lastTurn = status === "completed" ? "completed" : status === "interrupted" ? "interrupted" : "failed";
|
|
4872
|
-
if (p.turn.error)
|
|
4873
|
-
this.#recordEvent({ kind: "error", message: p.turn.error.message });
|
|
4874
|
-
this.#recordEvent({ kind: "result", subtype: this.#lastTurn, isError: this.#lastTurn === "failed", durationMs: Date.now() - this.#startedAt, costUsd: null, usage: null, contextTokens: this.#context?.tokens ?? null, text: null });
|
|
4875
|
-
this.#clearPermissions();
|
|
4876
|
-
this.#turnId = null;
|
|
4877
|
-
this.#interruptRequested = false;
|
|
4878
|
-
this.#turnDone?.();
|
|
4879
|
-
this.#turnDone = null;
|
|
4880
|
-
this.#setState("idle");
|
|
4881
|
-
break;
|
|
4882
|
-
}
|
|
4883
|
-
}
|
|
4884
|
-
}
|
|
4885
|
-
#item(item, completed) {
|
|
4886
|
-
if (!item?.id)
|
|
4887
|
-
return;
|
|
4888
|
-
const id = item.id;
|
|
4889
|
-
if (item.type === "agentMessage" || item.type === "plan") {
|
|
4890
|
-
if (completed) {
|
|
4891
|
-
this.#texts.delete(id);
|
|
4892
|
-
this.#recordEvent({ kind: "assistant.text", text: item.text ?? "", blockId: id });
|
|
4893
|
-
}
|
|
4894
|
-
return;
|
|
4895
|
-
}
|
|
4896
|
-
if (item.type === "reasoning") {
|
|
4897
|
-
if (completed) {
|
|
4898
|
-
const text = this.#thinking.get(id) ?? [...item.summary ?? [], ...item.content ?? []].join("\n");
|
|
4899
|
-
this.#thinking.delete(id);
|
|
4900
|
-
if (text)
|
|
4901
|
-
this.#recordEvent({ kind: "assistant.thinking", text, blockId: `${id}:thinking` });
|
|
4902
|
-
}
|
|
4903
|
-
return;
|
|
4904
|
-
}
|
|
4905
|
-
if (["userMessage", "contextCompaction"].includes(item.type))
|
|
4906
|
-
return;
|
|
4907
|
-
if (!this.#tools.has(id)) {
|
|
4908
|
-
this.#tools.add(id);
|
|
4909
|
-
const name = item.type === "commandExecution" ? "Bash" : item.type === "fileChange" ? "apply_patch" : item.tool ?? item.type;
|
|
4910
|
-
this.#recordEvent({ kind: "tool.use", toolUseId: id, name, input: item.type === "commandExecution" ? { command: item.command, cwd: item.cwd } : item.arguments ?? item });
|
|
4911
|
-
}
|
|
4912
|
-
if (completed) {
|
|
4913
|
-
this.#tools.delete(id);
|
|
4914
|
-
this.#recordEvent({ kind: "tool.result", toolUseId: id, content: item.aggregatedOutput ?? JSON.stringify(item.result ?? item.changes ?? item), isError: ["failed", "declined"].includes(item.status) || typeof item.exitCode === "number" && item.exitCode !== 0 });
|
|
4915
|
-
}
|
|
4916
|
-
}
|
|
4917
|
-
#request(id, method, params) {
|
|
4918
|
-
if (!["item/commandExecution/requestApproval", "item/fileChange/requestApproval", "item/permissions/requestApproval", "item/tool/requestUserInput"].includes(method)) {
|
|
4919
|
-
this.#client?.reject(id, `Unsupported client request: ${method}`);
|
|
4920
|
-
return;
|
|
4921
|
-
}
|
|
4922
|
-
const requestId = `codex:${String(id)}`;
|
|
4923
|
-
this.#permissions.set(requestId, { id, method, params });
|
|
4924
|
-
const questions = method === "item/tool/requestUserInput" ? (params.questions ?? []).map((q) => ({ question: q.question, header: q.header, options: q.options ?? [], multiSelect: false })) : void 0;
|
|
4925
|
-
this.#recordEvent({ kind: "permission.request", requestId, toolName: questions ? "AskUserQuestion" : method.includes("commandExecution") ? "Bash" : method.includes("fileChange") ? "apply_patch" : "Codex permissions", input: params, ...params.reason ? { reason: params.reason } : {}, ...params.itemId ? { toolUseId: params.itemId } : {}, ...questions ? { questions } : {} });
|
|
4926
|
-
this.#setState("waiting_permission");
|
|
4927
|
-
}
|
|
4928
|
-
respondPermission(requestId, decision, reason, answers) {
|
|
4929
|
-
const pending = this.#permissions.get(requestId);
|
|
4930
|
-
if (!pending)
|
|
4931
|
-
return;
|
|
4932
|
-
let response = { decision: decision === "allow" ? "accept" : "decline" };
|
|
4933
|
-
if (pending.method === "item/tool/requestUserInput")
|
|
4934
|
-
response = { answers: Object.fromEntries((pending.params.questions ?? []).map((q) => [q.id, { answers: decision === "allow" ? [answers?.[q.question] ?? ""] : ["\u041F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C \u043E\u0442\u043A\u043B\u043E\u043D\u0438\u043B \u0432\u043E\u043F\u0440\u043E\u0441"] }])) };
|
|
4935
|
-
if (pending.method === "item/permissions/requestApproval")
|
|
4936
|
-
response = { permissions: decision === "allow" ? Object.fromEntries(Object.entries(pending.params.permissions ?? {}).filter(([, value]) => value != null)) : {}, scope: "turn" };
|
|
4937
|
-
this.#client?.respond(pending.id, response);
|
|
4938
|
-
this.#permissions.delete(requestId);
|
|
4939
|
-
this.#recordEvent({ kind: "permission.resolved", requestId, decision, ...reason ? { reason } : {}, ...answers ? { answers } : {} });
|
|
4940
|
-
this.#setState(this.#permissions.size ? "waiting_permission" : "running");
|
|
4941
|
-
}
|
|
4942
|
-
#clearPermissions() {
|
|
4943
|
-
for (const requestId of this.#permissions.keys())
|
|
4944
|
-
this.#recordEvent({ kind: "permission.resolved", requestId, decision: "deny", reason: "\u0425\u043E\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0451\u043D" });
|
|
4945
|
-
this.#permissions.clear();
|
|
4946
|
-
}
|
|
4947
|
-
#flush() {
|
|
4948
|
-
for (const [blockId, text] of this.#texts)
|
|
4949
|
-
this.#recordEvent({ kind: "assistant.text", blockId, text });
|
|
4950
|
-
for (const [id, text] of this.#thinking)
|
|
4951
|
-
this.#recordEvent({ kind: "assistant.thinking", blockId: `${id}:thinking`, text });
|
|
4952
|
-
for (const toolUseId of this.#tools)
|
|
4953
|
-
this.#recordEvent({ kind: "tool.result", toolUseId, content: "\u0412\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u043F\u0440\u0435\u0440\u0432\u0430\u043D\u043E", isError: true });
|
|
4954
|
-
this.#texts.clear();
|
|
4955
|
-
this.#thinking.clear();
|
|
4956
|
-
this.#tools.clear();
|
|
4957
|
-
}
|
|
4958
|
-
#recordEvent(event) {
|
|
4959
|
-
const entry = this.journal.append(event);
|
|
4960
|
-
this.#record.updatedAt = entry.ts;
|
|
4961
|
-
if (!TRANSIENT2.has(event.kind))
|
|
4962
|
-
void this.#store.appendEvents(this.id, [entry]).catch((e) => this.emit("stderr", String(e)));
|
|
4963
|
-
this.emit("event", entry);
|
|
4964
|
-
}
|
|
4965
|
-
#setState(state) {
|
|
4966
|
-
this.#state = state;
|
|
4967
|
-
this.#recordEvent({ kind: "state", state });
|
|
4968
|
-
this.emit("summary", this.summary());
|
|
4969
|
-
void this.#store.save(this.#record).catch((e) => this.emit("stderr", String(e)));
|
|
4970
|
-
}
|
|
4971
|
-
#fail(error) {
|
|
4972
|
-
if (this.#state === "closed" || this.#state === "error")
|
|
4973
|
-
return;
|
|
4974
|
-
const client = this.#client;
|
|
4975
|
-
this.#client = null;
|
|
4976
|
-
if (client)
|
|
4977
|
-
this.#closing = client.close();
|
|
4978
|
-
this.#flush();
|
|
4979
|
-
this.#clearPermissions();
|
|
4980
|
-
this.#turnDone?.();
|
|
4981
|
-
this.#turnDone = null;
|
|
4982
|
-
this.#turnId = null;
|
|
4983
|
-
this.#recordEvent({ kind: "error", message: error instanceof Error ? error.message : String(error) });
|
|
4984
|
-
this.#lastTurn = "failed";
|
|
4985
|
-
this.#setState("error");
|
|
4986
|
-
}
|
|
4987
|
-
async interrupt() {
|
|
4988
|
-
this.#generation++;
|
|
4989
|
-
this.#interruptRequested = true;
|
|
4990
|
-
await this.#interruptTurn();
|
|
4991
|
-
}
|
|
4992
|
-
async #interruptTurn() {
|
|
4993
|
-
if (!this.#turnId || !this.#interruptRequested)
|
|
4994
|
-
return;
|
|
4995
|
-
this.#interruptRequested = false;
|
|
4996
|
-
await this.#client?.request("turn/interrupt", { threadId: this.#record.conversationId, turnId: this.#turnId });
|
|
4997
|
-
}
|
|
4998
|
-
async close(_reason = "closed by client") {
|
|
4999
|
-
this.#generation++;
|
|
5000
|
-
const client = this.#client;
|
|
5001
|
-
this.#client = null;
|
|
5002
|
-
this.#flush();
|
|
5003
|
-
this.#clearPermissions();
|
|
5004
|
-
this.#turnDone?.();
|
|
5005
|
-
this.#turnDone = null;
|
|
5006
|
-
this.#setState("closed");
|
|
5007
|
-
await client?.close();
|
|
5008
|
-
await this.#closing;
|
|
5009
|
-
await this.#store.save(this.#record);
|
|
5010
|
-
}
|
|
5011
|
-
suspend(reason) {
|
|
5012
|
-
if (this.#state === "closed")
|
|
5013
|
-
return;
|
|
5014
|
-
const client = this.#client;
|
|
5015
|
-
this.#client = null;
|
|
5016
|
-
client?.close();
|
|
5017
|
-
this.#generation++;
|
|
5018
|
-
this.#fail(new Error(reason));
|
|
5019
|
-
}
|
|
5020
|
-
reconnect(_reason) {
|
|
5021
|
-
if (this.#state === "closed")
|
|
5022
|
-
return;
|
|
5023
|
-
const client = this.#client;
|
|
5024
|
-
this.#client = null;
|
|
5025
|
-
client?.close();
|
|
5026
|
-
this.#generation++;
|
|
5027
|
-
this.#flush();
|
|
5028
|
-
this.#clearPermissions();
|
|
5029
|
-
this.#turnDone?.();
|
|
5030
|
-
this.#turnDone = null;
|
|
5031
|
-
this.#setState("reconnecting");
|
|
5032
|
-
this.start();
|
|
5033
|
-
}
|
|
5034
|
-
async setPermissionMode(mode) {
|
|
5035
|
-
if (!["default", "acceptEdits", "plan", "dontAsk", "bypassPermissions", "auto"].includes(mode))
|
|
5036
|
-
throw new Error(`\u0420\u0435\u0436\u0438\u043C \u0434\u043E\u0441\u0442\u0443\u043F\u0430 Codex \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D: ${mode}`);
|
|
5037
|
-
this.#record.permissionMode = mode;
|
|
5038
|
-
this.#changed();
|
|
5039
|
-
}
|
|
5040
|
-
async setModel(model) {
|
|
5041
|
-
if (this.#capabilities && !this.#capabilities.models.some((m) => m.value === model))
|
|
5042
|
-
throw new Error(`\u041C\u043E\u0434\u0435\u043B\u044C Codex \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430: ${model}`);
|
|
5043
|
-
this.#record.model = model;
|
|
5044
|
-
const supported = this.#capabilities?.models.find((m) => m.value === model)?.effortLevels;
|
|
5045
|
-
if (this.#record.effort && supported && !supported.includes(this.#record.effort))
|
|
5046
|
-
this.#record.effort = null;
|
|
5047
|
-
this.#changed();
|
|
5048
|
-
}
|
|
5049
|
-
async setEffort(effort) {
|
|
5050
|
-
const levels = this.#capabilities?.models.find((m) => m.value === this.#record.model)?.effortLevels ?? [];
|
|
5051
|
-
if (!levels.includes(effort))
|
|
5052
|
-
throw new Error(`\u041C\u043E\u0434\u0435\u043B\u044C \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u0441\u0438\u043B\u0438\u0435 ${effort}`);
|
|
5053
|
-
this.#record.effort = effort;
|
|
5054
|
-
this.#changed();
|
|
5055
|
-
}
|
|
5056
|
-
#changed() {
|
|
5057
|
-
if (this.#capabilities) {
|
|
5058
|
-
this.#capabilities.model = this.#record.model ?? "";
|
|
5059
|
-
this.#capabilities.permissionMode = this.#record.permissionMode;
|
|
5060
|
-
this.emit("capabilities");
|
|
5061
|
-
}
|
|
5062
|
-
this.emit("summary", this.summary());
|
|
5063
|
-
void this.#store.save(this.#record).catch((e) => this.emit("stderr", String(e)));
|
|
5064
|
-
}
|
|
5065
|
-
setTitle(title) {
|
|
5066
|
-
this.#record.title = title;
|
|
5067
|
-
this.#changed();
|
|
5068
|
-
if (this.#record.conversationId)
|
|
5069
|
-
void this.#client?.request("thread/name/set", { threadId: this.#record.conversationId, name: title }).catch(() => {
|
|
5070
|
-
});
|
|
5071
|
-
}
|
|
5072
|
-
#rateLimits(limits) {
|
|
5073
|
-
if (!limits)
|
|
5074
|
-
return;
|
|
5075
|
-
const window = (w) => w ? { utilization: w.usedPercent, resetsAt: w.resetsAt ? new Date(w.resetsAt * 1e3).toISOString() : "" } : null;
|
|
5076
|
-
this.#usage = {
|
|
5077
|
-
available: !!(limits.primary || limits.secondary),
|
|
5078
|
-
plan: limits.planType ?? "",
|
|
5079
|
-
fiveHour: null,
|
|
5080
|
-
sevenDay: null,
|
|
5081
|
-
sevenDayOpus: null,
|
|
5082
|
-
fetchedAt: Date.now(),
|
|
5083
|
-
buckets: [limits.primary, limits.secondary].flatMap((w, i) => w ? [{ id: `codex-${i}`, label: w.windowDurationMins ? `${w.windowDurationMins / 60} \u0447` : i === 0 ? "\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439" : "\u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0439", title: limits.limitName ?? "Codex", description: "", period: "", window: window(w) }] : [])
|
|
5084
|
-
};
|
|
5085
|
-
this.emit("usage", this.#usage);
|
|
5086
|
-
}
|
|
5087
|
-
async refreshUsage(_force = false) {
|
|
5088
|
-
if (this.#client)
|
|
5089
|
-
this.#rateLimits((await this.#client.request("account/rateLimits/read", {})).rateLimits);
|
|
5090
|
-
}
|
|
5091
|
-
async refreshContext(_force = false) {
|
|
5092
|
-
if (this.#context)
|
|
5093
|
-
this.emit("context", this.#context);
|
|
5094
|
-
}
|
|
5095
|
-
async editPrompt(userIndex, text, images) {
|
|
5096
|
-
await this.#ready;
|
|
5097
|
-
const blocked = networkGuard.blockedReason();
|
|
5098
|
-
if (blocked)
|
|
5099
|
-
throw new Error(blocked);
|
|
5100
|
-
if (!this.#client || this.#state === "closed" || this.#state === "error")
|
|
5101
|
-
throw new Error("\u041F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u0435\u0441\u0441\u0438\u044E Codex");
|
|
5102
|
-
await this.interrupt();
|
|
5103
|
-
await this.#queue;
|
|
5104
|
-
const events = await this.#store.readEvents(this.id);
|
|
5105
|
-
const messages = events.filter((entry) => entry.event.kind === "user.message");
|
|
5106
|
-
const target = messages[userIndex];
|
|
5107
|
-
if (!target || target.event.kind !== "user.message")
|
|
5108
|
-
throw new Error("\u0420\u0435\u043F\u043B\u0438\u043A\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430");
|
|
5109
|
-
if (target.event.text.startsWith("/"))
|
|
5110
|
-
throw new Error("\u0421\u043B\u0443\u0436\u0435\u0431\u043D\u0443\u044E \u043A\u043E\u043C\u0430\u043D\u0434\u0443 \u043D\u0435\u043B\u044C\u0437\u044F \u043E\u0442\u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C; \u043E\u0442\u043F\u0440\u0430\u0432\u044C\u0442\u0435 \u0435\u0451 \u0437\u0430\u043D\u043E\u0432\u043E");
|
|
5111
|
-
const modelIndex = messages.slice(0, userIndex).filter((entry) => entry.event.kind === "user.message" && isCodexModelPrompt(entry.event.text)).length;
|
|
5112
|
-
const nativeMessages = [];
|
|
5113
|
-
let cursor = null;
|
|
5114
|
-
do {
|
|
5115
|
-
const page = await this.#client.request("thread/items/list", { threadId: this.#record.conversationId, cursor, limit: 100, sortDirection: "asc" });
|
|
5116
|
-
nativeMessages.push(...(page.data ?? []).filter((entry) => entry.item.type === "userMessage"));
|
|
5117
|
-
cursor = page.nextCursor ?? null;
|
|
5118
|
-
} while (cursor && nativeMessages.length <= modelIndex);
|
|
5119
|
-
const beforeTurnId = nativeMessages[modelIndex]?.turnId;
|
|
5120
|
-
if (!beforeTurnId)
|
|
5121
|
-
throw new Error("Codex \u043D\u0435 \u043D\u0430\u0448\u0451\u043B \u0445\u043E\u0434 \u0434\u043B\u044F \u044D\u0442\u043E\u0439 \u0440\u0435\u043F\u043B\u0438\u043A\u0438");
|
|
5122
|
-
await this.#client.request("thread/revert", { threadId: this.#record.conversationId, beforeTurnId });
|
|
5123
|
-
await this.#store.replaceEvents(this.id, events.slice(0, events.indexOf(target)));
|
|
5124
|
-
this.#history = Promise.resolve(await this.#store.readEvents(this.id));
|
|
5125
|
-
this.journal.clear();
|
|
5126
|
-
this.#recordEvent({ kind: "rewound", toUserIndex: userIndex });
|
|
5127
|
-
this.#context = null;
|
|
5128
|
-
this.sendPrompt(text, images);
|
|
5129
|
-
}
|
|
5130
|
-
async setUltracode() {
|
|
5131
|
-
throw new Error("\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0443\u0441\u0438\u043B\u0438\u0435 \u0432 \u043C\u0435\u043D\u044E \u043C\u043E\u0434\u0435\u043B\u0438 Codex");
|
|
5132
|
-
}
|
|
5133
|
-
async setThinking() {
|
|
5134
|
-
throw new Error("\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0443\u0441\u0438\u043B\u0438\u0435 \u0432 \u043C\u0435\u043D\u044E \u043C\u043E\u0434\u0435\u043B\u0438 Codex");
|
|
5135
|
-
}
|
|
5136
|
-
async setSwitchModelsOnFlag() {
|
|
5137
|
-
throw new Error("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430 \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0441\u044F \u043A Claude Code");
|
|
5138
|
-
}
|
|
5139
|
-
async reloadPlugins() {
|
|
5140
|
-
await this.#client?.request("config/mcpServer/reload", {});
|
|
5141
|
-
}
|
|
5142
|
-
async mcpServerStatus() {
|
|
5143
|
-
return [];
|
|
5144
|
-
}
|
|
5145
|
-
async addMcpServer() {
|
|
5146
|
-
throw new Error("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u0442\u0435 MCP \u0432 ~/.codex/config.toml \u0438\u043B\u0438 \u0447\u0435\u0440\u0435\u0437 codex mcp \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435");
|
|
5147
|
-
}
|
|
5148
|
-
async removeMcpServer() {
|
|
5149
|
-
throw new Error("\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 codex mcp remove \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435");
|
|
5150
|
-
}
|
|
5151
|
-
async reconnectMcpServer() {
|
|
5152
|
-
await this.reloadPlugins();
|
|
5153
|
-
}
|
|
5154
|
-
async toggleMcpServer() {
|
|
5155
|
-
throw new Error("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u0442\u0435 MCP \u0432 ~/.codex/config.toml");
|
|
5156
|
-
}
|
|
5157
|
-
async authenticateMcpServer() {
|
|
5158
|
-
throw new Error("\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 codex mcp login \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435");
|
|
5159
|
-
}
|
|
5160
|
-
async submitMcpOAuthCallback() {
|
|
5161
|
-
throw new Error("\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 codex mcp login \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435");
|
|
5162
|
-
}
|
|
5163
|
-
};
|
|
5164
|
-
|
|
5165
|
-
// ../host/dist/codex-store.js
|
|
5166
|
-
import path10 from "node:path";
|
|
5167
|
-
|
|
5168
4220
|
// ../host/dist/antigravity-store.js
|
|
5169
4221
|
import { appendFile, mkdir as mkdir3, readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "node:fs/promises";
|
|
5170
|
-
import
|
|
4222
|
+
import path8 from "node:path";
|
|
5171
4223
|
var AntigravityStore = class {
|
|
5172
4224
|
#dir;
|
|
5173
4225
|
#file;
|
|
5174
4226
|
#records = /* @__PURE__ */ new Map();
|
|
5175
4227
|
#loaded = null;
|
|
5176
4228
|
#writing = Promise.resolve();
|
|
5177
|
-
constructor(dataDir
|
|
5178
|
-
this.#dir =
|
|
5179
|
-
this.#file =
|
|
4229
|
+
constructor(dataDir) {
|
|
4230
|
+
this.#dir = path8.join(dataDir, "antigravity");
|
|
4231
|
+
this.#file = path8.join(this.#dir, "sessions.json");
|
|
5180
4232
|
}
|
|
5181
4233
|
#load() {
|
|
5182
4234
|
this.#loaded ??= (async () => {
|
|
@@ -5251,14 +4303,6 @@ var AntigravityStore = class {
|
|
|
5251
4303
|
await appendFile(this.#eventsFile(id), lines, "utf8");
|
|
5252
4304
|
});
|
|
5253
4305
|
}
|
|
5254
|
-
/** Replace the durable prefix after a successful native conversation rewind. */
|
|
5255
|
-
replaceEvents(id, events) {
|
|
5256
|
-
const lines = events.map((entry) => JSON.stringify(entry)).join("\n");
|
|
5257
|
-
return this.#enqueue(async () => {
|
|
5258
|
-
await mkdir3(this.#dir, { recursive: true });
|
|
5259
|
-
await writeFile3(this.#eventsFile(id), lines ? lines + "\n" : "", "utf8");
|
|
5260
|
-
});
|
|
5261
|
-
}
|
|
5262
4306
|
/** Лента сессии как история: `seq` — позиция, от 1 по порядку. */
|
|
5263
4307
|
async readEvents(id) {
|
|
5264
4308
|
await this.#writing;
|
|
@@ -5281,7 +4325,7 @@ var AntigravityStore = class {
|
|
|
5281
4325
|
return entries;
|
|
5282
4326
|
}
|
|
5283
4327
|
#eventsFile(id) {
|
|
5284
|
-
return
|
|
4328
|
+
return path8.join(this.#dir, `${id.replace(/[^\w-]/g, "_")}.jsonl`);
|
|
5285
4329
|
}
|
|
5286
4330
|
#persist() {
|
|
5287
4331
|
const snapshot = JSON.stringify([...this.#records.values()], null, 2);
|
|
@@ -5300,63 +4344,11 @@ var AntigravityStore = class {
|
|
|
5300
4344
|
}
|
|
5301
4345
|
};
|
|
5302
4346
|
|
|
5303
|
-
// ../host/dist/codex-store.js
|
|
5304
|
-
var CodexStore = class extends AntigravityStore {
|
|
5305
|
-
#scans = /* @__PURE__ */ new Map();
|
|
5306
|
-
constructor(dataDir) {
|
|
5307
|
-
super(dataDir, "codex");
|
|
5308
|
-
}
|
|
5309
|
-
discover(workspaceId, cwd) {
|
|
5310
|
-
const cached = this.#scans.get(workspaceId);
|
|
5311
|
-
if (cached && Date.now() - cached.at < 3e4)
|
|
5312
|
-
return cached.pending;
|
|
5313
|
-
const pending = this.#discover(workspaceId, cwd).catch((error) => {
|
|
5314
|
-
console.error("[codex-discovery]", error instanceof Error ? error.message : error);
|
|
5315
|
-
});
|
|
5316
|
-
this.#scans.set(workspaceId, { at: Date.now(), pending });
|
|
5317
|
-
return pending;
|
|
5318
|
-
}
|
|
5319
|
-
async #discover(workspaceId, cwd) {
|
|
5320
|
-
if (!codexLauncher())
|
|
5321
|
-
return;
|
|
5322
|
-
const client = new CodexClient();
|
|
5323
|
-
try {
|
|
5324
|
-
await client.start(cwd);
|
|
5325
|
-
const records = await this.list(workspaceId);
|
|
5326
|
-
const known = new Set(records.map((r) => r.conversationId));
|
|
5327
|
-
let cursor = null;
|
|
5328
|
-
do {
|
|
5329
|
-
const page = await client.request("thread/list", { cwd, cursor, limit: 100, sortKey: "updated_at", modelProviders: [] });
|
|
5330
|
-
for (const thread of page.data ?? []) {
|
|
5331
|
-
if (known.has(thread.id) || path10.resolve(thread.cwd) !== path10.resolve(cwd) || thread.parentThreadId)
|
|
5332
|
-
continue;
|
|
5333
|
-
await this.save({
|
|
5334
|
-
id: `codex-${thread.id}`,
|
|
5335
|
-
conversationId: thread.id,
|
|
5336
|
-
workspaceId,
|
|
5337
|
-
cwd,
|
|
5338
|
-
title: thread.name || thread.preview?.slice(0, 100) || null,
|
|
5339
|
-
model: thread.model ?? null,
|
|
5340
|
-
effort: ["low", "medium", "high", "xhigh", "max"].includes(thread.reasoningEffort) ? thread.reasoningEffort : null,
|
|
5341
|
-
permissionMode: "default",
|
|
5342
|
-
createdAt: thread.createdAt * 1e3,
|
|
5343
|
-
updatedAt: thread.updatedAt * 1e3
|
|
5344
|
-
});
|
|
5345
|
-
known.add(thread.id);
|
|
5346
|
-
}
|
|
5347
|
-
cursor = page.nextCursor ?? null;
|
|
5348
|
-
} while (cursor);
|
|
5349
|
-
} finally {
|
|
5350
|
-
await client.close();
|
|
5351
|
-
}
|
|
5352
|
-
}
|
|
5353
|
-
};
|
|
5354
|
-
|
|
5355
4347
|
// ../host/dist/git.js
|
|
5356
|
-
import { execFile as
|
|
4348
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
5357
4349
|
import { mkdtemp, readFile as readFile5, rm as rm3, writeFile as writeFile4 } from "node:fs/promises";
|
|
5358
4350
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
5359
|
-
import
|
|
4351
|
+
import path9 from "node:path";
|
|
5360
4352
|
var TIMEOUT_MS = 2e4;
|
|
5361
4353
|
var NET_TIMEOUT_MS = 5 * 6e4;
|
|
5362
4354
|
var MAX_BUFFER = 32 * 1024 * 1024;
|
|
@@ -5672,7 +4664,7 @@ var GitRepo = class {
|
|
|
5672
4664
|
* важнее всего (см. `checkIgnored`).
|
|
5673
4665
|
*/
|
|
5674
4666
|
async #withoutRepo(args) {
|
|
5675
|
-
const dir = await mkdtemp(
|
|
4667
|
+
const dir = await mkdtemp(path9.join(tmpdir2(), "ccv-git-"));
|
|
5676
4668
|
try {
|
|
5677
4669
|
await this.#run(["init", "--bare", "--quiet", dir]);
|
|
5678
4670
|
return await this.#soft([`--git-dir=${dir}`, `--work-tree=${this.cwd}`, ...args]);
|
|
@@ -5718,7 +4710,7 @@ var GitRepo = class {
|
|
|
5718
4710
|
* исключил. Повторы отсеиваются, чтобы файл не рос от каждой публикации.
|
|
5719
4711
|
*/
|
|
5720
4712
|
async #appendGitignore(paths) {
|
|
5721
|
-
const file =
|
|
4713
|
+
const file = path9.join(this.cwd, ".gitignore");
|
|
5722
4714
|
const existing = await readFile5(file, "utf8").catch(() => "");
|
|
5723
4715
|
const known = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
|
|
5724
4716
|
const lines = paths.map(ignorePattern).filter((line) => !known.has(line));
|
|
@@ -5743,7 +4735,7 @@ var GitRepo = class {
|
|
|
5743
4735
|
#run(args, options2 = {}) {
|
|
5744
4736
|
const token = options2.token ?? "";
|
|
5745
4737
|
return new Promise((resolve, reject) => {
|
|
5746
|
-
const child =
|
|
4738
|
+
const child = execFile4(
|
|
5747
4739
|
"git",
|
|
5748
4740
|
// core.quotepath=false — иначе кириллические пути приезжают в виде
|
|
5749
4741
|
// «\320\277\321\200…» и в панели читаются как мусор.
|
|
@@ -5924,9 +4916,9 @@ function parsePatch(raw) {
|
|
|
5924
4916
|
body = "";
|
|
5925
4917
|
}
|
|
5926
4918
|
total += body.length;
|
|
5927
|
-
const
|
|
4919
|
+
const path25 = status === "deleted" ? oldPath : newPath || oldPath;
|
|
5928
4920
|
files.push({
|
|
5929
|
-
path:
|
|
4921
|
+
path: path25,
|
|
5930
4922
|
oldPath: status === "renamed" ? oldPath : "",
|
|
5931
4923
|
status,
|
|
5932
4924
|
added: count(body, "+"),
|
|
@@ -5938,10 +4930,10 @@ function parsePatch(raw) {
|
|
|
5938
4930
|
return { files, truncated };
|
|
5939
4931
|
}
|
|
5940
4932
|
function stripPrefix(value) {
|
|
5941
|
-
const
|
|
5942
|
-
if (
|
|
4933
|
+
const path25 = unquote(value.trim());
|
|
4934
|
+
if (path25 === "/dev/null")
|
|
5943
4935
|
return "";
|
|
5944
|
-
return
|
|
4936
|
+
return path25.replace(/^[ab]\//, "");
|
|
5945
4937
|
}
|
|
5946
4938
|
function count(body, mark) {
|
|
5947
4939
|
let n = 0;
|
|
@@ -5953,9 +4945,9 @@ function count(body, mark) {
|
|
|
5953
4945
|
}
|
|
5954
4946
|
|
|
5955
4947
|
// ../host/dist/github.js
|
|
5956
|
-
import { execFile as
|
|
4948
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
5957
4949
|
import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile5 } from "node:fs/promises";
|
|
5958
|
-
import
|
|
4950
|
+
import path10 from "node:path";
|
|
5959
4951
|
var API = "https://api.github.com";
|
|
5960
4952
|
var API_VERSION = "2022-11-28";
|
|
5961
4953
|
var API_TIMEOUT_MS = 2e4;
|
|
@@ -5976,7 +4968,7 @@ var GitHubAccount = class {
|
|
|
5976
4968
|
*/
|
|
5977
4969
|
#ghInstalled = null;
|
|
5978
4970
|
constructor(dataDir) {
|
|
5979
|
-
this.#storePath =
|
|
4971
|
+
this.#storePath = path10.join(dataDir, "github.json");
|
|
5980
4972
|
}
|
|
5981
4973
|
async load() {
|
|
5982
4974
|
try {
|
|
@@ -5990,7 +4982,7 @@ var GitHubAccount = class {
|
|
|
5990
4982
|
/** Сохранить токен или стереть его пустой строкой. */
|
|
5991
4983
|
async setToken(token) {
|
|
5992
4984
|
this.#token = token.trim();
|
|
5993
|
-
await mkdir4(
|
|
4985
|
+
await mkdir4(path10.dirname(this.#storePath), { recursive: true });
|
|
5994
4986
|
await writeFile5(this.#storePath, JSON.stringify({ token: this.#token }, null, 2), {
|
|
5995
4987
|
encoding: "utf8",
|
|
5996
4988
|
mode: 384
|
|
@@ -6142,7 +5134,7 @@ var GitHubAccount = class {
|
|
|
6142
5134
|
};
|
|
6143
5135
|
function gh(args) {
|
|
6144
5136
|
return new Promise((resolve, reject) => {
|
|
6145
|
-
|
|
5137
|
+
execFile5("gh", args, { timeout: GH_TIMEOUT_MS, windowsHide: true, encoding: "utf8" }, (error, stdout, stderr) => {
|
|
6146
5138
|
if (error)
|
|
6147
5139
|
return reject(new Error(stderr.trim() || error.message));
|
|
6148
5140
|
resolve(stdout);
|
|
@@ -6183,10 +5175,10 @@ function describe4(error) {
|
|
|
6183
5175
|
}
|
|
6184
5176
|
|
|
6185
5177
|
// ../host/dist/finder.js
|
|
6186
|
-
import { existsSync as
|
|
5178
|
+
import { existsSync as existsSync2, statSync } from "node:fs";
|
|
6187
5179
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
6188
5180
|
import os2 from "node:os";
|
|
6189
|
-
import
|
|
5181
|
+
import path11 from "node:path";
|
|
6190
5182
|
import { listSessions } from "@anthropic-ai/claude-agent-sdk";
|
|
6191
5183
|
var CACHE_TTL = 6e4;
|
|
6192
5184
|
var FIND_LIMIT = 50;
|
|
@@ -6225,7 +5217,7 @@ var ProjectFinder = class {
|
|
|
6225
5217
|
if (needles.length === 0)
|
|
6226
5218
|
return { candidates: [], truncated: false };
|
|
6227
5219
|
const open = new Map(this.registry.list().map((workspace) => [workspace.path.toLowerCase(), workspace]));
|
|
6228
|
-
const byName = this.#dirs.filter((dir) => matches(
|
|
5220
|
+
const byName = this.#dirs.filter((dir) => matches(path11.basename(dir.path), needles));
|
|
6229
5221
|
const matched = byName.length > 0 ? byName : this.#dirs.filter((dir) => matches(dir.path, needles));
|
|
6230
5222
|
const sorted = [...matched].sort((a, b) => {
|
|
6231
5223
|
const aOpen = open.has(a.path.toLowerCase());
|
|
@@ -6236,7 +5228,7 @@ var ProjectFinder = class {
|
|
|
6236
5228
|
return a.sessions > 0 ? -1 : 1;
|
|
6237
5229
|
if (a.lastUsedAt !== b.lastUsedAt)
|
|
6238
5230
|
return b.lastUsedAt - a.lastUsedAt;
|
|
6239
|
-
return
|
|
5231
|
+
return path11.basename(a.path).localeCompare(path11.basename(b.path), void 0, {
|
|
6240
5232
|
numeric: true,
|
|
6241
5233
|
sensitivity: "base"
|
|
6242
5234
|
});
|
|
@@ -6244,7 +5236,7 @@ var ProjectFinder = class {
|
|
|
6244
5236
|
return {
|
|
6245
5237
|
candidates: sorted.slice(0, FIND_LIMIT).map((dir) => ({
|
|
6246
5238
|
path: dir.path,
|
|
6247
|
-
name:
|
|
5239
|
+
name: path11.basename(dir.path) || dir.path,
|
|
6248
5240
|
sessions: dir.sessions,
|
|
6249
5241
|
lastUsedAt: dir.lastUsedAt || null,
|
|
6250
5242
|
open: open.has(dir.path.toLowerCase()),
|
|
@@ -6268,7 +5260,7 @@ var ProjectFinder = class {
|
|
|
6268
5260
|
const candidates = [];
|
|
6269
5261
|
for (const entry of named) {
|
|
6270
5262
|
const absolute = entry.path.trim();
|
|
6271
|
-
if (!absolute || !
|
|
5263
|
+
if (!absolute || !path11.isAbsolute(absolute))
|
|
6272
5264
|
continue;
|
|
6273
5265
|
const key = absolute.toLowerCase();
|
|
6274
5266
|
if (seen.has(key))
|
|
@@ -6279,7 +5271,7 @@ var ProjectFinder = class {
|
|
|
6279
5271
|
const record = known.get(key);
|
|
6280
5272
|
candidates.push({
|
|
6281
5273
|
path: record?.path ?? absolute,
|
|
6282
|
-
name:
|
|
5274
|
+
name: path11.basename(absolute) || absolute,
|
|
6283
5275
|
sessions: record?.sessions ?? 0,
|
|
6284
5276
|
lastUsedAt: record?.lastUsedAt || null,
|
|
6285
5277
|
open: open.has(key),
|
|
@@ -6336,7 +5328,7 @@ var ProjectFinder = class {
|
|
|
6336
5328
|
if (!dirent.isDirectory() || SKIP_NAMES.has(dirent.name) || dirent.name.startsWith(".")) {
|
|
6337
5329
|
continue;
|
|
6338
5330
|
}
|
|
6339
|
-
const full =
|
|
5331
|
+
const full = path11.join(parent, dirent.name);
|
|
6340
5332
|
const key = full.toLowerCase();
|
|
6341
5333
|
if (dirs.has(key))
|
|
6342
5334
|
continue;
|
|
@@ -6357,7 +5349,7 @@ var ProjectFinder = class {
|
|
|
6357
5349
|
#parents(dirs) {
|
|
6358
5350
|
const counted = /* @__PURE__ */ new Map();
|
|
6359
5351
|
for (const dir of dirs) {
|
|
6360
|
-
const parent =
|
|
5352
|
+
const parent = path11.dirname(dir.path);
|
|
6361
5353
|
if (parent === dir.path || !usable(parent))
|
|
6362
5354
|
continue;
|
|
6363
5355
|
const key = parent.toLowerCase();
|
|
@@ -6371,7 +5363,7 @@ var ProjectFinder = class {
|
|
|
6371
5363
|
}
|
|
6372
5364
|
};
|
|
6373
5365
|
function usable(dir) {
|
|
6374
|
-
return !contains(os2.tmpdir(), dir) &&
|
|
5366
|
+
return !contains(os2.tmpdir(), dir) && existsSync2(dir);
|
|
6375
5367
|
}
|
|
6376
5368
|
function tokens(query2) {
|
|
6377
5369
|
return query2.toLowerCase().split(/[^a-z0-9а-яё]+/i).filter(Boolean);
|
|
@@ -6468,15 +5460,15 @@ function fromText(text) {
|
|
|
6468
5460
|
}
|
|
6469
5461
|
|
|
6470
5462
|
// ../host/dist/workspaces.js
|
|
6471
|
-
import { existsSync as
|
|
5463
|
+
import { existsSync as existsSync3, statSync as statSync2 } from "node:fs";
|
|
6472
5464
|
import { mkdir as mkdir5, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
6473
|
-
import
|
|
5465
|
+
import path12 from "node:path";
|
|
6474
5466
|
import { listSessions as listSessions2 } from "@anthropic-ai/claude-agent-sdk";
|
|
6475
5467
|
var WorkspaceRegistry = class {
|
|
6476
5468
|
#entries = [];
|
|
6477
5469
|
#storePath;
|
|
6478
5470
|
constructor(dataDir) {
|
|
6479
|
-
this.#storePath =
|
|
5471
|
+
this.#storePath = path12.join(dataDir, "workspaces.json");
|
|
6480
5472
|
}
|
|
6481
5473
|
async load() {
|
|
6482
5474
|
try {
|
|
@@ -6492,13 +5484,13 @@ var WorkspaceRegistry = class {
|
|
|
6492
5484
|
if (isEntry(item))
|
|
6493
5485
|
return item;
|
|
6494
5486
|
return null;
|
|
6495
|
-
}).filter((e) => e !== null &&
|
|
5487
|
+
}).filter((e) => e !== null && existsSync3(e.path));
|
|
6496
5488
|
} catch {
|
|
6497
5489
|
this.#entries = [];
|
|
6498
5490
|
}
|
|
6499
5491
|
}
|
|
6500
5492
|
async #persist() {
|
|
6501
|
-
await mkdir5(
|
|
5493
|
+
await mkdir5(path12.dirname(this.#storePath), { recursive: true });
|
|
6502
5494
|
await writeFile6(this.#storePath, JSON.stringify(this.#entries, null, 2), "utf8");
|
|
6503
5495
|
}
|
|
6504
5496
|
/** Активные проекты. */
|
|
@@ -6518,8 +5510,8 @@ var WorkspaceRegistry = class {
|
|
|
6518
5510
|
return entry ? toInfo(entry) : void 0;
|
|
6519
5511
|
}
|
|
6520
5512
|
async open(rawPath) {
|
|
6521
|
-
const absolute =
|
|
6522
|
-
if (!
|
|
5513
|
+
const absolute = path12.resolve(rawPath);
|
|
5514
|
+
if (!existsSync3(absolute)) {
|
|
6523
5515
|
throw new Error(`\u041A\u0430\u0442\u0430\u043B\u043E\u0433 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${absolute}`);
|
|
6524
5516
|
}
|
|
6525
5517
|
const existing = this.#entries.find((e) => e.path === absolute);
|
|
@@ -6585,32 +5577,24 @@ var WorkspaceRegistry = class {
|
|
|
6585
5577
|
async create(parentRaw, nameRaw, init) {
|
|
6586
5578
|
const name = nameRaw.trim();
|
|
6587
5579
|
requireName(name);
|
|
6588
|
-
const parent =
|
|
6589
|
-
if (!
|
|
5580
|
+
const parent = path12.resolve(parentRaw.trim());
|
|
5581
|
+
if (!existsSync3(parent)) {
|
|
6590
5582
|
throw new Error(`\u041A\u0430\u0442\u0430\u043B\u043E\u0433 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${parent}`);
|
|
6591
5583
|
}
|
|
6592
5584
|
if (!statSync2(parent).isDirectory()) {
|
|
6593
5585
|
throw new Error(`\u042D\u0442\u043E \u043D\u0435 \u043A\u0430\u0442\u0430\u043B\u043E\u0433: ${parent}`);
|
|
6594
5586
|
}
|
|
6595
|
-
const target =
|
|
6596
|
-
if (
|
|
5587
|
+
const target = path12.join(parent, name);
|
|
5588
|
+
if (existsSync3(target)) {
|
|
6597
5589
|
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`);
|
|
6598
5590
|
}
|
|
6599
5591
|
await mkdir5(target);
|
|
6600
5592
|
const warnings = [];
|
|
6601
|
-
if (init.agentsMd) {
|
|
6602
|
-
await step(warnings, "AGENTS.md", () => writeFile6(path14.join(target, "AGENTS.md"), `# ${name}
|
|
6603
|
-
|
|
6604
|
-
## \u0418\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u0438 \u043F\u0440\u043E\u0435\u043A\u0442\u0430
|
|
6605
|
-
|
|
6606
|
-
\u041E\u043F\u0438\u0448\u0438\u0442\u0435 \u0437\u0434\u0435\u0441\u044C \u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u043E \u043F\u0440\u043E\u0435\u043A\u0442\u0430, \u043A\u043E\u043C\u0430\u043D\u0434\u044B \u0441\u0431\u043E\u0440\u043A\u0438 \u0438 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438, \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0440\u0430\u0431\u043E\u0442\u044B.
|
|
6607
|
-
`, "utf8"));
|
|
6608
|
-
}
|
|
6609
5593
|
if (init.claudeMd) {
|
|
6610
|
-
await step(warnings, "CLAUDE.md", () => writeFile6(
|
|
5594
|
+
await step(warnings, "CLAUDE.md", () => writeFile6(path12.join(target, "CLAUDE.md"), claudeMdStub(name), "utf8"));
|
|
6611
5595
|
}
|
|
6612
5596
|
if (init.readme) {
|
|
6613
|
-
await step(warnings, "README.md", () => writeFile6(
|
|
5597
|
+
await step(warnings, "README.md", () => writeFile6(path12.join(target, "README.md"), readmeStub(name), "utf8"));
|
|
6614
5598
|
}
|
|
6615
5599
|
if (init.git) {
|
|
6616
5600
|
await step(warnings, "git init", () => new GitRepo(target).init());
|
|
@@ -6682,8 +5666,8 @@ function toInfo(entry) {
|
|
|
6682
5666
|
return {
|
|
6683
5667
|
id: workspaceIdFromPath(absolute),
|
|
6684
5668
|
path: absolute,
|
|
6685
|
-
name:
|
|
6686
|
-
hasClaudeMd:
|
|
5669
|
+
name: path12.basename(absolute) || absolute,
|
|
5670
|
+
hasClaudeMd: existsSync3(path12.join(absolute, "CLAUDE.md")),
|
|
6687
5671
|
...archivedAt ? { archivedAt } : {}
|
|
6688
5672
|
};
|
|
6689
5673
|
}
|
|
@@ -6693,13 +5677,13 @@ function isEntry(value) {
|
|
|
6693
5677
|
|
|
6694
5678
|
// ../host/dist/archive.js
|
|
6695
5679
|
import { mkdir as mkdir6, readFile as readFile8, writeFile as writeFile7 } from "node:fs/promises";
|
|
6696
|
-
import
|
|
5680
|
+
import path13 from "node:path";
|
|
6697
5681
|
var SessionArchive = class {
|
|
6698
5682
|
#archived = /* @__PURE__ */ new Map();
|
|
6699
5683
|
#restored = /* @__PURE__ */ new Map();
|
|
6700
5684
|
#storePath;
|
|
6701
5685
|
constructor(dataDir) {
|
|
6702
|
-
this.#storePath =
|
|
5686
|
+
this.#storePath = path13.join(dataDir, "session-archive.json");
|
|
6703
5687
|
}
|
|
6704
5688
|
async load() {
|
|
6705
5689
|
try {
|
|
@@ -6811,7 +5795,7 @@ var SessionArchive = class {
|
|
|
6811
5795
|
archived: Object.fromEntries(this.#archived),
|
|
6812
5796
|
restored: Object.fromEntries(this.#restored)
|
|
6813
5797
|
};
|
|
6814
|
-
await mkdir6(
|
|
5798
|
+
await mkdir6(path13.dirname(this.#storePath), { recursive: true });
|
|
6815
5799
|
await writeFile7(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
6816
5800
|
}
|
|
6817
5801
|
};
|
|
@@ -6821,7 +5805,7 @@ function isRecord(value) {
|
|
|
6821
5805
|
|
|
6822
5806
|
// ../host/dist/pins.js
|
|
6823
5807
|
import { mkdir as mkdir7, readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
|
|
6824
|
-
import
|
|
5808
|
+
import path14 from "node:path";
|
|
6825
5809
|
var SessionPins = class {
|
|
6826
5810
|
#pinned = /* @__PURE__ */ new Map();
|
|
6827
5811
|
/**
|
|
@@ -6836,7 +5820,7 @@ var SessionPins = class {
|
|
|
6836
5820
|
#moved = /* @__PURE__ */ new Map();
|
|
6837
5821
|
#storePath;
|
|
6838
5822
|
constructor(dataDir) {
|
|
6839
|
-
this.#storePath =
|
|
5823
|
+
this.#storePath = path14.join(dataDir, "session-pins.json");
|
|
6840
5824
|
}
|
|
6841
5825
|
async load() {
|
|
6842
5826
|
try {
|
|
@@ -6993,7 +5977,7 @@ var SessionPins = class {
|
|
|
6993
5977
|
pinned: Object.fromEntries(this.#pinned),
|
|
6994
5978
|
...this.#moved.size > 0 ? { moved: Object.fromEntries(this.#moved) } : {}
|
|
6995
5979
|
};
|
|
6996
|
-
await mkdir7(
|
|
5980
|
+
await mkdir7(path14.dirname(this.#storePath), { recursive: true });
|
|
6997
5981
|
await writeFile8(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
6998
5982
|
}
|
|
6999
5983
|
};
|
|
@@ -7001,107 +5985,18 @@ function isRecord2(value) {
|
|
|
7001
5985
|
return typeof value === "object" && value !== null && typeof value.workspaceId === "string" && typeof value.at === "number";
|
|
7002
5986
|
}
|
|
7003
5987
|
|
|
7004
|
-
// ../host/dist/session-links.js
|
|
7005
|
-
import { mkdir as mkdir8, readFile as readFile10, rename, writeFile as writeFile9 } from "node:fs/promises";
|
|
7006
|
-
import path17 from "node:path";
|
|
7007
|
-
var STAGES = /* @__PURE__ */ new Set(["research", "implementation", "review", "other"]);
|
|
7008
|
-
var validId = (id) => typeof id === "string" && id.length > 0 && id.length <= 512;
|
|
7009
|
-
var SessionLinks = class {
|
|
7010
|
-
#links = /* @__PURE__ */ new Map();
|
|
7011
|
-
#queue = Promise.resolve();
|
|
7012
|
-
#file;
|
|
7013
|
-
constructor(dataDir) {
|
|
7014
|
-
this.#file = path17.join(dataDir, "session-links.json");
|
|
7015
|
-
}
|
|
7016
|
-
async load() {
|
|
7017
|
-
try {
|
|
7018
|
-
const parsed = JSON.parse(await readFile10(this.#file, "utf8"));
|
|
7019
|
-
if (!Array.isArray(parsed))
|
|
7020
|
-
return;
|
|
7021
|
-
for (const value of parsed) {
|
|
7022
|
-
if (!value || typeof value !== "object")
|
|
7023
|
-
continue;
|
|
7024
|
-
const r = value;
|
|
7025
|
-
if (!validId(r.sessionId) || !validId(r.workspaceId) || !(r.parentId === null || validId(r.parentId)) || !STAGES.has(r.stage) || !["fork", "continuation", "linked"].includes(r.kind) || !Number.isFinite(r.createdAt))
|
|
7026
|
-
continue;
|
|
7027
|
-
this.#links.set(r.sessionId, { ...r });
|
|
7028
|
-
}
|
|
7029
|
-
} catch (error) {
|
|
7030
|
-
if (error.code !== "ENOENT")
|
|
7031
|
-
throw error;
|
|
7032
|
-
}
|
|
7033
|
-
}
|
|
7034
|
-
get all() {
|
|
7035
|
-
return [...this.#links.values()].map((r) => ({ ...r }));
|
|
7036
|
-
}
|
|
7037
|
-
set(link) {
|
|
7038
|
-
return this.#update(() => {
|
|
7039
|
-
if (!validId(link.sessionId) || !validId(link.workspaceId) || !STAGES.has(link.stage))
|
|
7040
|
-
throw new Error("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u0441\u0435\u0441\u0441\u0438\u0439");
|
|
7041
|
-
if (link.parentId !== null && !validId(link.parentId))
|
|
7042
|
-
throw new Error("\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u0430\u044F \u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u0441\u043A\u0430\u044F \u0441\u0435\u0441\u0441\u0438\u044F");
|
|
7043
|
-
const seen = /* @__PURE__ */ new Set([link.sessionId]);
|
|
7044
|
-
let parent = link.parentId;
|
|
7045
|
-
while (parent) {
|
|
7046
|
-
if (seen.has(parent))
|
|
7047
|
-
throw new Error("\u041D\u0435\u043B\u044C\u0437\u044F \u0437\u0430\u043C\u043A\u043D\u0443\u0442\u044C \u0446\u0435\u043F\u043E\u0447\u043A\u0443 \u0441\u0435\u0441\u0441\u0438\u0439 \u0432 \u043A\u0440\u0443\u0433");
|
|
7048
|
-
seen.add(parent);
|
|
7049
|
-
const next = this.#links.get(parent);
|
|
7050
|
-
if (next && next.workspaceId !== link.workspaceId)
|
|
7051
|
-
throw new Error("\u042D\u0442\u0430\u043F\u044B \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043E\u043B\u0436\u043D\u044B \u043F\u0440\u0438\u043D\u0430\u0434\u043B\u0435\u0436\u0430\u0442\u044C \u043E\u0434\u043D\u043E\u043C\u0443 \u043F\u0440\u043E\u0435\u043A\u0442\u0443");
|
|
7052
|
-
parent = next?.parentId ?? null;
|
|
7053
|
-
}
|
|
7054
|
-
this.#links.set(link.sessionId, { ...link, createdAt: this.#links.get(link.sessionId)?.createdAt ?? link.createdAt });
|
|
7055
|
-
});
|
|
7056
|
-
}
|
|
7057
|
-
migrate(from, to) {
|
|
7058
|
-
return this.#update(() => {
|
|
7059
|
-
if (from === to)
|
|
7060
|
-
return;
|
|
7061
|
-
const link = this.#links.get(from);
|
|
7062
|
-
if (link) {
|
|
7063
|
-
this.#links.delete(from);
|
|
7064
|
-
this.#links.set(to, { ...link, sessionId: to, parentId: link.parentId === to ? null : link.parentId });
|
|
7065
|
-
}
|
|
7066
|
-
for (const [id, r] of this.#links) {
|
|
7067
|
-
if (r.parentId === from)
|
|
7068
|
-
this.#links.set(id, { ...r, parentId: id === to ? null : to });
|
|
7069
|
-
}
|
|
7070
|
-
});
|
|
7071
|
-
}
|
|
7072
|
-
#update(change) {
|
|
7073
|
-
const operation = this.#queue.then(async () => {
|
|
7074
|
-
const before = new Map(this.#links);
|
|
7075
|
-
try {
|
|
7076
|
-
change();
|
|
7077
|
-
const next = JSON.stringify(this.all, null, 2);
|
|
7078
|
-
if (next === JSON.stringify([...before.values()], null, 2))
|
|
7079
|
-
return;
|
|
7080
|
-
await mkdir8(path17.dirname(this.#file), { recursive: true });
|
|
7081
|
-
await writeFile9(this.#file + ".tmp", next, "utf8");
|
|
7082
|
-
await rename(this.#file + ".tmp", this.#file);
|
|
7083
|
-
} catch (error) {
|
|
7084
|
-
this.#links = before;
|
|
7085
|
-
throw error;
|
|
7086
|
-
}
|
|
7087
|
-
});
|
|
7088
|
-
this.#queue = operation.catch(() => void 0);
|
|
7089
|
-
return operation;
|
|
7090
|
-
}
|
|
7091
|
-
};
|
|
7092
|
-
|
|
7093
5988
|
// ../host/dist/order.js
|
|
7094
|
-
import { mkdir as
|
|
7095
|
-
import
|
|
5989
|
+
import { mkdir as mkdir8, readFile as readFile10, writeFile as writeFile9 } from "node:fs/promises";
|
|
5990
|
+
import path15 from "node:path";
|
|
7096
5991
|
var ListOrderStore = class {
|
|
7097
5992
|
#order = emptyOrder();
|
|
7098
5993
|
#storePath;
|
|
7099
5994
|
constructor(dataDir) {
|
|
7100
|
-
this.#storePath =
|
|
5995
|
+
this.#storePath = path15.join(dataDir, "list-order.json");
|
|
7101
5996
|
}
|
|
7102
5997
|
async load() {
|
|
7103
5998
|
try {
|
|
7104
|
-
const raw = await
|
|
5999
|
+
const raw = await readFile10(this.#storePath, "utf8");
|
|
7105
6000
|
this.#order = sanitize(JSON.parse(raw));
|
|
7106
6001
|
} catch {
|
|
7107
6002
|
this.#order = emptyOrder();
|
|
@@ -7173,8 +6068,8 @@ var ListOrderStore = class {
|
|
|
7173
6068
|
return changed;
|
|
7174
6069
|
}
|
|
7175
6070
|
async #persist() {
|
|
7176
|
-
await
|
|
7177
|
-
await
|
|
6071
|
+
await mkdir8(path15.dirname(this.#storePath), { recursive: true });
|
|
6072
|
+
await writeFile9(this.#storePath, JSON.stringify(this.#order, null, 2), "utf8");
|
|
7178
6073
|
}
|
|
7179
6074
|
};
|
|
7180
6075
|
function emptyOrder() {
|
|
@@ -7203,9 +6098,9 @@ function sanitize(value) {
|
|
|
7203
6098
|
}
|
|
7204
6099
|
|
|
7205
6100
|
// ../host/dist/folders.js
|
|
7206
|
-
import { mkdir as
|
|
7207
|
-
import
|
|
7208
|
-
import { randomUUID as
|
|
6101
|
+
import { mkdir as mkdir9, readFile as readFile11, writeFile as writeFile10 } from "node:fs/promises";
|
|
6102
|
+
import path16 from "node:path";
|
|
6103
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
7209
6104
|
var COLOR_PATTERN = /^#[0-9a-f]{6}$/i;
|
|
7210
6105
|
var Folders = class {
|
|
7211
6106
|
#workspaceFolders = /* @__PURE__ */ new Map();
|
|
@@ -7216,11 +6111,11 @@ var Folders = class {
|
|
|
7216
6111
|
#pinnedAssignments = /* @__PURE__ */ new Map();
|
|
7217
6112
|
#storePath;
|
|
7218
6113
|
constructor(dataDir) {
|
|
7219
|
-
this.#storePath =
|
|
6114
|
+
this.#storePath = path16.join(dataDir, "folders.json");
|
|
7220
6115
|
}
|
|
7221
6116
|
async load() {
|
|
7222
6117
|
try {
|
|
7223
|
-
const raw = await
|
|
6118
|
+
const raw = await readFile11(this.#storePath, "utf8");
|
|
7224
6119
|
const parsed = JSON.parse(raw);
|
|
7225
6120
|
this.#workspaceFolders = new Map(Object.entries(parsed.workspaceFolders ?? {}).filter(([, r]) => isWorkspaceFolder(r)).map(([id, r]) => [id, withValidColor(r)]));
|
|
7226
6121
|
this.#sessionFolders = new Map(Object.entries(parsed.sessionFolders ?? {}).filter(([, r]) => isSessionFolder(r)).map(([id, r]) => [id, withValidColor(r)]));
|
|
@@ -7305,19 +6200,19 @@ var Folders = class {
|
|
|
7305
6200
|
};
|
|
7306
6201
|
}
|
|
7307
6202
|
async createWorkspaceFolder(name) {
|
|
7308
|
-
const id =
|
|
6203
|
+
const id = randomUUID3();
|
|
7309
6204
|
this.#workspaceFolders.set(id, { name });
|
|
7310
6205
|
await this.#persist();
|
|
7311
6206
|
return id;
|
|
7312
6207
|
}
|
|
7313
6208
|
async createSessionFolder(workspaceId, name) {
|
|
7314
|
-
const id =
|
|
6209
|
+
const id = randomUUID3();
|
|
7315
6210
|
this.#sessionFolders.set(id, { name, workspaceId });
|
|
7316
6211
|
await this.#persist();
|
|
7317
6212
|
return id;
|
|
7318
6213
|
}
|
|
7319
6214
|
async createPinnedFolder(name) {
|
|
7320
|
-
const id =
|
|
6215
|
+
const id = randomUUID3();
|
|
7321
6216
|
this.#pinnedFolders.set(id, { name });
|
|
7322
6217
|
await this.#persist();
|
|
7323
6218
|
return id;
|
|
@@ -7497,8 +6392,8 @@ var Folders = class {
|
|
|
7497
6392
|
sessionAssignments: Object.fromEntries(this.#sessionAssignments),
|
|
7498
6393
|
pinnedAssignments: Object.fromEntries(this.#pinnedAssignments)
|
|
7499
6394
|
};
|
|
7500
|
-
await
|
|
7501
|
-
await
|
|
6395
|
+
await mkdir9(path16.dirname(this.#storePath), { recursive: true });
|
|
6396
|
+
await writeFile10(this.#storePath, JSON.stringify(file, null, 2), "utf8");
|
|
7502
6397
|
}
|
|
7503
6398
|
};
|
|
7504
6399
|
function withValidColor(record) {
|
|
@@ -7519,9 +6414,9 @@ function isPinnedFolder(value) {
|
|
|
7519
6414
|
}
|
|
7520
6415
|
|
|
7521
6416
|
// ../host/dist/app-settings.js
|
|
7522
|
-
import { mkdir as
|
|
7523
|
-
import { homedir as
|
|
7524
|
-
import
|
|
6417
|
+
import { mkdir as mkdir10, readFile as readFile12, writeFile as writeFile11 } from "node:fs/promises";
|
|
6418
|
+
import { homedir as homedir4 } from "node:os";
|
|
6419
|
+
import path17 from "node:path";
|
|
7525
6420
|
var DEFAULT_AUTO_ARCHIVE_AFTER_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
7526
6421
|
var MIN_AUTO_ARCHIVE_AFTER_MS = 60 * 60 * 1e3;
|
|
7527
6422
|
var DEFAULT_AUTO_STOP_AFTER_MS = 10 * 60 * 1e3;
|
|
@@ -7529,7 +6424,7 @@ var MIN_AUTO_STOP_AFTER_MS = 60 * 1e3;
|
|
|
7529
6424
|
var MIN_AUTO_SAVE_AFTER_PAUSE_MS = 500;
|
|
7530
6425
|
var DEFAULT_BLOCKED_COUNTRIES = ["RU", "BY", "CN", "IR", "KP", "SY", "CU"];
|
|
7531
6426
|
var FOLDER_ACCESS = ["all", "projects", "project"];
|
|
7532
|
-
var PROVIDERS = ["claude", "antigravity"
|
|
6427
|
+
var PROVIDERS = ["claude", "antigravity"];
|
|
7533
6428
|
var PERMISSION_MODES = [
|
|
7534
6429
|
"default",
|
|
7535
6430
|
"acceptEdits",
|
|
@@ -7550,8 +6445,6 @@ var DEFAULT_APP_SETTINGS = {
|
|
|
7550
6445
|
// Модель за пользователя не выбираем: пока он не сказал иначе, сессия
|
|
7551
6446
|
// поднимается ровно с той, с которой её поднял бы консольный Claude Code.
|
|
7552
6447
|
startModel: null,
|
|
7553
|
-
startModels: { claude: null, codex: null, antigravity: null },
|
|
7554
|
-
startCodexPermissionMode: "default",
|
|
7555
6448
|
// Тот же режим, с которым сессия стартовала до появления этой настройки.
|
|
7556
6449
|
startPermissionMode: "default",
|
|
7557
6450
|
// Терминал по умолчанию закрыт — его включают, а не выключают: приложение,
|
|
@@ -7565,7 +6458,8 @@ var DEFAULT_APP_SETTINGS = {
|
|
|
7565
6458
|
// несколько дней, и терять их из-за пары процентов жалко.
|
|
7566
6459
|
limitStopFiveHourPct: 95,
|
|
7567
6460
|
limitStopSevenDayPct: 99,
|
|
7568
|
-
|
|
6461
|
+
// Оба: до появления настройки приложение предлагало обоих агентов.
|
|
6462
|
+
enabledProviders: ["claude", "antigravity"],
|
|
7569
6463
|
// Включено: запрос без VPN может стоить аккаунта, а тому, у кого маршрут и
|
|
7570
6464
|
// так из разрешённой страны, защита ничем не мешает.
|
|
7571
6465
|
networkGuardEnabled: true,
|
|
@@ -7574,20 +6468,19 @@ var DEFAULT_APP_SETTINGS = {
|
|
|
7574
6468
|
var AppSettingsStore = class {
|
|
7575
6469
|
#settings = { ...DEFAULT_APP_SETTINGS };
|
|
7576
6470
|
#storePath;
|
|
7577
|
-
#writing = Promise.resolve();
|
|
7578
6471
|
constructor(dataDir) {
|
|
7579
|
-
this.#storePath =
|
|
6472
|
+
this.#storePath = path17.join(dataDir, "app-settings.json");
|
|
7580
6473
|
}
|
|
7581
6474
|
async load() {
|
|
7582
6475
|
try {
|
|
7583
|
-
const raw = await
|
|
6476
|
+
const raw = await readFile12(this.#storePath, "utf8");
|
|
7584
6477
|
this.#settings = sanitize2(JSON.parse(raw), DEFAULT_APP_SETTINGS);
|
|
7585
6478
|
} catch {
|
|
7586
6479
|
this.#settings = { ...DEFAULT_APP_SETTINGS };
|
|
7587
6480
|
}
|
|
7588
6481
|
}
|
|
7589
6482
|
get current() {
|
|
7590
|
-
return { ...this.#settings
|
|
6483
|
+
return { ...this.#settings };
|
|
7591
6484
|
}
|
|
7592
6485
|
/**
|
|
7593
6486
|
* Применить присланное окном.
|
|
@@ -7600,13 +6493,8 @@ var AppSettingsStore = class {
|
|
|
7600
6493
|
async update(patch) {
|
|
7601
6494
|
const next = sanitize2(patch, this.#settings);
|
|
7602
6495
|
this.#settings = next;
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
await writeFile12(this.#storePath, JSON.stringify(next, null, 2), "utf8");
|
|
7606
|
-
});
|
|
7607
|
-
this.#writing = writing.catch(() => {
|
|
7608
|
-
});
|
|
7609
|
-
await writing;
|
|
6496
|
+
await mkdir10(path17.dirname(this.#storePath), { recursive: true });
|
|
6497
|
+
await writeFile11(this.#storePath, JSON.stringify(next, null, 2), "utf8");
|
|
7610
6498
|
return this.current;
|
|
7611
6499
|
}
|
|
7612
6500
|
};
|
|
@@ -7638,26 +6526,10 @@ function sanitize2(value, fallback) {
|
|
|
7638
6526
|
else if (typeof model === "string")
|
|
7639
6527
|
result.startModel = model.trim() || null;
|
|
7640
6528
|
}
|
|
7641
|
-
const models = record.startModels;
|
|
7642
|
-
result.startModels = { ...fallback.startModels };
|
|
7643
|
-
if ("startModel" in record && !(models && typeof models === "object" && "claude" in models))
|
|
7644
|
-
result.startModels.claude = result.startModel;
|
|
7645
|
-
if (models && typeof models === "object" && !Array.isArray(models)) {
|
|
7646
|
-
for (const provider of PROVIDERS) {
|
|
7647
|
-
const model = models[provider];
|
|
7648
|
-
if (model === null || typeof model === "string")
|
|
7649
|
-
result.startModels[provider] = typeof model === "string" ? model.trim() || null : null;
|
|
7650
|
-
}
|
|
7651
|
-
}
|
|
7652
|
-
result.startModel = result.startModels.claude;
|
|
7653
6529
|
const mode = record.startPermissionMode;
|
|
7654
6530
|
if (typeof mode === "string" && PERMISSION_MODES.includes(mode)) {
|
|
7655
6531
|
result.startPermissionMode = mode;
|
|
7656
6532
|
}
|
|
7657
|
-
const codexMode = record.startCodexPermissionMode;
|
|
7658
|
-
if (typeof codexMode === "string" && ["default", "auto", "plan", "bypassPermissions"].includes(codexMode)) {
|
|
7659
|
-
result.startCodexPermissionMode = codexMode;
|
|
7660
|
-
}
|
|
7661
6533
|
if (typeof record.terminalEnabled === "boolean") {
|
|
7662
6534
|
result.terminalEnabled = record.terminalEnabled;
|
|
7663
6535
|
}
|
|
@@ -7688,7 +6560,7 @@ function sanitize2(value, fallback) {
|
|
|
7688
6560
|
return result;
|
|
7689
6561
|
}
|
|
7690
6562
|
function claudeHome() {
|
|
7691
|
-
return
|
|
6563
|
+
return path17.join(homedir4(), ".claude");
|
|
7692
6564
|
}
|
|
7693
6565
|
function writableRoots(mode, cwd, workspacePaths) {
|
|
7694
6566
|
if (mode === "all")
|
|
@@ -7698,7 +6570,7 @@ function writableRoots(mode, cwd, workspacePaths) {
|
|
|
7698
6570
|
return [...roots];
|
|
7699
6571
|
for (const workspace of [cwd, ...workspacePaths]) {
|
|
7700
6572
|
roots.add(workspace);
|
|
7701
|
-
const parent =
|
|
6573
|
+
const parent = path17.dirname(workspace);
|
|
7702
6574
|
if (parent !== workspace)
|
|
7703
6575
|
roots.add(parent);
|
|
7704
6576
|
}
|
|
@@ -7706,19 +6578,19 @@ function writableRoots(mode, cwd, workspacePaths) {
|
|
|
7706
6578
|
}
|
|
7707
6579
|
|
|
7708
6580
|
// ../host/dist/handoff-store.js
|
|
7709
|
-
import { mkdir as
|
|
7710
|
-
import
|
|
6581
|
+
import { mkdir as mkdir11, readFile as readFile13, readdir as readdir3, rm as rm4, writeFile as writeFile12 } from "node:fs/promises";
|
|
6582
|
+
import path18 from "node:path";
|
|
7711
6583
|
var HandoffStore = class {
|
|
7712
6584
|
#dir;
|
|
7713
6585
|
constructor(dataDir) {
|
|
7714
|
-
this.#dir =
|
|
6586
|
+
this.#dir = path18.join(dataDir, "handoffs");
|
|
7715
6587
|
}
|
|
7716
6588
|
async get(sessionId) {
|
|
7717
6589
|
const file = this.#file(sessionId);
|
|
7718
6590
|
if (!file)
|
|
7719
6591
|
return null;
|
|
7720
6592
|
try {
|
|
7721
|
-
const parsed = JSON.parse(await
|
|
6593
|
+
const parsed = JSON.parse(await readFile13(file, "utf8"));
|
|
7722
6594
|
return typeof parsed.text === "string" ? parsed : null;
|
|
7723
6595
|
} catch {
|
|
7724
6596
|
return null;
|
|
@@ -7728,8 +6600,8 @@ var HandoffStore = class {
|
|
|
7728
6600
|
const file = this.#file(handoff.sessionId);
|
|
7729
6601
|
if (!file)
|
|
7730
6602
|
return;
|
|
7731
|
-
await
|
|
7732
|
-
await
|
|
6603
|
+
await mkdir11(this.#dir, { recursive: true });
|
|
6604
|
+
await writeFile12(file, JSON.stringify(handoff, null, 2), "utf8");
|
|
7733
6605
|
}
|
|
7734
6606
|
async remove(sessionId) {
|
|
7735
6607
|
const file = this.#file(sessionId);
|
|
@@ -7748,7 +6620,7 @@ var HandoffStore = class {
|
|
|
7748
6620
|
#file(sessionId) {
|
|
7749
6621
|
if (!/^[\w-]{1,128}$/.test(sessionId))
|
|
7750
6622
|
return null;
|
|
7751
|
-
return
|
|
6623
|
+
return path18.join(this.#dir, `${sessionId}.json`);
|
|
7752
6624
|
}
|
|
7753
6625
|
};
|
|
7754
6626
|
var SAME_WINDOW_MS = 5 * 6e4;
|
|
@@ -7756,11 +6628,11 @@ var LimitStopState = class {
|
|
|
7756
6628
|
#fired = {};
|
|
7757
6629
|
#storePath;
|
|
7758
6630
|
constructor(dataDir) {
|
|
7759
|
-
this.#storePath =
|
|
6631
|
+
this.#storePath = path18.join(dataDir, "limit-stop.json");
|
|
7760
6632
|
}
|
|
7761
6633
|
async load() {
|
|
7762
6634
|
try {
|
|
7763
|
-
const parsed = JSON.parse(await
|
|
6635
|
+
const parsed = JSON.parse(await readFile13(this.#storePath, "utf8"));
|
|
7764
6636
|
this.#fired = {};
|
|
7765
6637
|
for (const key of ["fiveHour", "sevenDay"]) {
|
|
7766
6638
|
const until = parsed[key];
|
|
@@ -7792,8 +6664,8 @@ var LimitStopState = class {
|
|
|
7792
6664
|
/** Запомнить срабатывание до `until` (момент сброса окна). */
|
|
7793
6665
|
async mark(limit, until) {
|
|
7794
6666
|
this.#fired[limit] = until;
|
|
7795
|
-
await
|
|
7796
|
-
await
|
|
6667
|
+
await mkdir11(path18.dirname(this.#storePath), { recursive: true });
|
|
6668
|
+
await writeFile12(this.#storePath, JSON.stringify(this.#fired, null, 2), "utf8");
|
|
7797
6669
|
}
|
|
7798
6670
|
};
|
|
7799
6671
|
|
|
@@ -7897,9 +6769,9 @@ function capitalize(text) {
|
|
|
7897
6769
|
}
|
|
7898
6770
|
|
|
7899
6771
|
// ../host/dist/plugins.js
|
|
7900
|
-
import { readFile as
|
|
7901
|
-
import { homedir as
|
|
7902
|
-
import
|
|
6772
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
6773
|
+
import { homedir as homedir5 } from "node:os";
|
|
6774
|
+
import path19 from "node:path";
|
|
7903
6775
|
var TIMEOUT_MS2 = 12e4;
|
|
7904
6776
|
var SAFE_ARG = /^[A-Za-z0-9][A-Za-z0-9._@/-]*$/;
|
|
7905
6777
|
var PluginCli = class {
|
|
@@ -7998,10 +6870,10 @@ async function readCatalog(markets, installed) {
|
|
|
7998
6870
|
return lists.flat().sort((a, b) => a.name.localeCompare(b.name));
|
|
7999
6871
|
}
|
|
8000
6872
|
async function readMarketplace(market, installed) {
|
|
8001
|
-
const root = market.installLocation ||
|
|
6873
|
+
const root = market.installLocation || path19.join(homedir5(), ".claude", "plugins", "marketplaces", market.name);
|
|
8002
6874
|
let manifest;
|
|
8003
6875
|
try {
|
|
8004
|
-
const text = await
|
|
6876
|
+
const text = await readFile14(path19.join(root, ".claude-plugin", "marketplace.json"), "utf8");
|
|
8005
6877
|
manifest = JSON.parse(text);
|
|
8006
6878
|
} catch {
|
|
8007
6879
|
return [];
|
|
@@ -8044,7 +6916,7 @@ function authorName(raw) {
|
|
|
8044
6916
|
}
|
|
8045
6917
|
|
|
8046
6918
|
// ../host/dist/auth.js
|
|
8047
|
-
import { EventEmitter as
|
|
6919
|
+
import { EventEmitter as EventEmitter4 } from "node:events";
|
|
8048
6920
|
var QUICK_TIMEOUT_MS = 3e4;
|
|
8049
6921
|
var LOGIN_TIMEOUT_MS = 10 * 6e4;
|
|
8050
6922
|
var URL_RE = /https:\/\/\S*\/oauth\/authorize\S*/;
|
|
@@ -8056,7 +6928,7 @@ var IDLE = {
|
|
|
8056
6928
|
output: "",
|
|
8057
6929
|
error: null
|
|
8058
6930
|
};
|
|
8059
|
-
var AuthCli = class extends
|
|
6931
|
+
var AuthCli = class extends EventEmitter4 {
|
|
8060
6932
|
#child = null;
|
|
8061
6933
|
#state = IDLE;
|
|
8062
6934
|
#timer = null;
|
|
@@ -8241,9 +7113,9 @@ function describe5(error) {
|
|
|
8241
7113
|
}
|
|
8242
7114
|
|
|
8243
7115
|
// ../host/dist/relay-link.js
|
|
8244
|
-
import { EventEmitter as
|
|
8245
|
-
import { readFile as
|
|
8246
|
-
import
|
|
7116
|
+
import { EventEmitter as EventEmitter5 } from "node:events";
|
|
7117
|
+
import { readFile as readFile15, writeFile as writeFile13, rm as rm5, mkdir as mkdir12 } from "node:fs/promises";
|
|
7118
|
+
import path20 from "node:path";
|
|
8247
7119
|
import { hostname } from "node:os";
|
|
8248
7120
|
import WebSocket from "ws";
|
|
8249
7121
|
|
|
@@ -8260,7 +7132,7 @@ var SILENCE_TIMEOUT_MS = 95e3;
|
|
|
8260
7132
|
function jitter(delay2) {
|
|
8261
7133
|
return Math.round(delay2 * (0.8 + Math.random() * 0.4));
|
|
8262
7134
|
}
|
|
8263
|
-
var RelayLink = class extends
|
|
7135
|
+
var RelayLink = class extends EventEmitter5 {
|
|
8264
7136
|
#credentials = null;
|
|
8265
7137
|
#socket = null;
|
|
8266
7138
|
#retry = RETRY_MIN_MS;
|
|
@@ -8298,7 +7170,7 @@ var RelayLink = class extends EventEmitter7 {
|
|
|
8298
7170
|
#log;
|
|
8299
7171
|
constructor(options2) {
|
|
8300
7172
|
super();
|
|
8301
|
-
this.#file =
|
|
7173
|
+
this.#file = path20.join(options2.dataDir, "relay.json");
|
|
8302
7174
|
this.#defaultUrl = options2.defaultUrl.replace(/\/+$/, "");
|
|
8303
7175
|
this.#log = options2.log ?? ((msg) => console.log(`[relay] ${msg}`));
|
|
8304
7176
|
}
|
|
@@ -8379,7 +7251,7 @@ var RelayLink = class extends EventEmitter7 {
|
|
|
8379
7251
|
}
|
|
8380
7252
|
async #read() {
|
|
8381
7253
|
try {
|
|
8382
|
-
const raw = await
|
|
7254
|
+
const raw = await readFile15(this.#file, "utf8");
|
|
8383
7255
|
const parsed = JSON.parse(raw);
|
|
8384
7256
|
if (typeof parsed !== "object" || parsed === null)
|
|
8385
7257
|
return null;
|
|
@@ -8392,8 +7264,8 @@ var RelayLink = class extends EventEmitter7 {
|
|
|
8392
7264
|
}
|
|
8393
7265
|
}
|
|
8394
7266
|
async #write(credentials) {
|
|
8395
|
-
await
|
|
8396
|
-
await
|
|
7267
|
+
await mkdir12(path20.dirname(this.#file), { recursive: true });
|
|
7268
|
+
await writeFile13(this.#file, `${JSON.stringify(credentials, null, 2)}
|
|
8397
7269
|
`, {
|
|
8398
7270
|
encoding: "utf8",
|
|
8399
7271
|
mode: 384
|
|
@@ -8648,14 +7520,14 @@ function humanize(error) {
|
|
|
8648
7520
|
}
|
|
8649
7521
|
|
|
8650
7522
|
// ../host/dist/terminal.js
|
|
8651
|
-
import { EventEmitter as
|
|
7523
|
+
import { EventEmitter as EventEmitter6 } from "node:events";
|
|
8652
7524
|
import { access as access2, constants as constants2 } from "node:fs/promises";
|
|
8653
|
-
import
|
|
8654
|
-
import { randomUUID as
|
|
7525
|
+
import path21 from "node:path";
|
|
7526
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
8655
7527
|
var SCROLLBACK_BYTES = 256 * 1024;
|
|
8656
7528
|
var FLUSH_MS = 12;
|
|
8657
7529
|
var MAX_TERMINALS = 24;
|
|
8658
|
-
var TerminalHub = class extends
|
|
7530
|
+
var TerminalHub = class extends EventEmitter6 {
|
|
8659
7531
|
#terminals = /* @__PURE__ */ new Map();
|
|
8660
7532
|
#module = null;
|
|
8661
7533
|
list(workspaceId) {
|
|
@@ -8688,7 +7560,7 @@ var TerminalHub = class extends EventEmitter8 {
|
|
|
8688
7560
|
env: environment()
|
|
8689
7561
|
});
|
|
8690
7562
|
const info = {
|
|
8691
|
-
id:
|
|
7563
|
+
id: randomUUID4(),
|
|
8692
7564
|
workspaceId: options2.workspaceId,
|
|
8693
7565
|
title: shell.title,
|
|
8694
7566
|
shell: shell.file,
|
|
@@ -8820,22 +7692,22 @@ async function defaultShell() {
|
|
|
8820
7692
|
if (pwsh)
|
|
8821
7693
|
return { file: pwsh, args: [], title: "pwsh" };
|
|
8822
7694
|
const system = process.env.SystemRoot ?? "C:\\Windows";
|
|
8823
|
-
const powershell =
|
|
7695
|
+
const powershell = path21.join(system, "System32/WindowsPowerShell/v1.0/powershell.exe");
|
|
8824
7696
|
if (await exists2(powershell))
|
|
8825
7697
|
return { file: powershell, args: [], title: "powershell" };
|
|
8826
7698
|
return { file: process.env.COMSPEC ?? "cmd.exe", args: [], title: "cmd" };
|
|
8827
7699
|
}
|
|
8828
7700
|
const shell = process.env.SHELL;
|
|
8829
7701
|
if (shell && await exists2(shell))
|
|
8830
|
-
return { file: shell, args: [], title:
|
|
7702
|
+
return { file: shell, args: [], title: path21.basename(shell) };
|
|
8831
7703
|
if (await exists2("/bin/bash"))
|
|
8832
7704
|
return { file: "/bin/bash", args: [], title: "bash" };
|
|
8833
7705
|
return { file: "/bin/sh", args: [], title: "sh" };
|
|
8834
7706
|
}
|
|
8835
7707
|
async function findOnPath(name) {
|
|
8836
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
7708
|
+
const dirs = (process.env.PATH ?? "").split(path21.delimiter).filter(Boolean);
|
|
8837
7709
|
for (const dir of dirs) {
|
|
8838
|
-
const candidate =
|
|
7710
|
+
const candidate = path21.join(dir, name);
|
|
8839
7711
|
if (await exists2(candidate))
|
|
8840
7712
|
return candidate;
|
|
8841
7713
|
}
|
|
@@ -8846,10 +7718,10 @@ function exists2(file) {
|
|
|
8846
7718
|
}
|
|
8847
7719
|
|
|
8848
7720
|
// ../host/dist/mcp-config.js
|
|
8849
|
-
import { readFile as
|
|
8850
|
-
import
|
|
7721
|
+
import { readFile as readFile16, writeFile as writeFile14, mkdir as mkdir13 } from "node:fs/promises";
|
|
7722
|
+
import path22 from "node:path";
|
|
8851
7723
|
var MCP_FILE = ".mcp.json";
|
|
8852
|
-
var LOCAL_SETTINGS2 =
|
|
7724
|
+
var LOCAL_SETTINGS2 = path22.join(".claude", "settings.local.json");
|
|
8853
7725
|
var queues = /* @__PURE__ */ new Map();
|
|
8854
7726
|
function serialize(cwd, work) {
|
|
8855
7727
|
const previous = queues.get(cwd) ?? Promise.resolve();
|
|
@@ -8858,7 +7730,7 @@ function serialize(cwd, work) {
|
|
|
8858
7730
|
return next;
|
|
8859
7731
|
}
|
|
8860
7732
|
async function readProjectServers(cwd) {
|
|
8861
|
-
const file = await readJson(
|
|
7733
|
+
const file = await readJson(path22.join(cwd, MCP_FILE));
|
|
8862
7734
|
const servers = file?.mcpServers;
|
|
8863
7735
|
if (!servers || typeof servers !== "object")
|
|
8864
7736
|
return {};
|
|
@@ -8866,23 +7738,23 @@ async function readProjectServers(cwd) {
|
|
|
8866
7738
|
}
|
|
8867
7739
|
function addProjectServer(cwd, name, config) {
|
|
8868
7740
|
return serialize(cwd, async () => {
|
|
8869
|
-
const file = await readJson(
|
|
7741
|
+
const file = await readJson(path22.join(cwd, MCP_FILE)) ?? {};
|
|
8870
7742
|
const servers = file.mcpServers ?? {};
|
|
8871
7743
|
servers[name] = config;
|
|
8872
7744
|
file.mcpServers = servers;
|
|
8873
|
-
await writeJson(
|
|
7745
|
+
await writeJson(path22.join(cwd, MCP_FILE), file);
|
|
8874
7746
|
await approve(cwd, name);
|
|
8875
7747
|
});
|
|
8876
7748
|
}
|
|
8877
7749
|
function removeProjectServer(cwd, name) {
|
|
8878
7750
|
return serialize(cwd, async () => {
|
|
8879
|
-
const file = await readJson(
|
|
7751
|
+
const file = await readJson(path22.join(cwd, MCP_FILE));
|
|
8880
7752
|
const servers = file?.mcpServers;
|
|
8881
7753
|
if (!servers || !(name in servers))
|
|
8882
7754
|
return false;
|
|
8883
7755
|
delete servers[name];
|
|
8884
|
-
await writeJson(
|
|
8885
|
-
const settingsPath =
|
|
7756
|
+
await writeJson(path22.join(cwd, MCP_FILE), file);
|
|
7757
|
+
const settingsPath = path22.join(cwd, LOCAL_SETTINGS2);
|
|
8886
7758
|
const settings = await readJson(settingsPath);
|
|
8887
7759
|
const enabled = settings?.enabledMcpjsonServers;
|
|
8888
7760
|
if (settings && Array.isArray(enabled) && enabled.includes(name)) {
|
|
@@ -8893,7 +7765,7 @@ function removeProjectServer(cwd, name) {
|
|
|
8893
7765
|
});
|
|
8894
7766
|
}
|
|
8895
7767
|
async function approve(cwd, name) {
|
|
8896
|
-
const file =
|
|
7768
|
+
const file = path22.join(cwd, LOCAL_SETTINGS2);
|
|
8897
7769
|
const settings = await readJson(file) ?? {};
|
|
8898
7770
|
const enabled = Array.isArray(settings.enabledMcpjsonServers) ? settings.enabledMcpjsonServers : [];
|
|
8899
7771
|
if (!enabled.includes(name))
|
|
@@ -8932,21 +7804,21 @@ function describeConfig(config) {
|
|
|
8932
7804
|
}
|
|
8933
7805
|
async function readJson(file) {
|
|
8934
7806
|
try {
|
|
8935
|
-
const raw = await
|
|
7807
|
+
const raw = await readFile16(file, "utf8");
|
|
8936
7808
|
const parsed = JSON.parse(raw);
|
|
8937
7809
|
return parsed && typeof parsed === "object" ? parsed : null;
|
|
8938
7810
|
} catch (error) {
|
|
8939
7811
|
if (error.code === "ENOENT")
|
|
8940
7812
|
return null;
|
|
8941
7813
|
if (error instanceof SyntaxError) {
|
|
8942
|
-
throw new Error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C ${
|
|
7814
|
+
throw new Error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u0442\u044C ${path22.basename(file)}: ${error.message}`);
|
|
8943
7815
|
}
|
|
8944
7816
|
throw error;
|
|
8945
7817
|
}
|
|
8946
7818
|
}
|
|
8947
7819
|
async function writeJson(file, data) {
|
|
8948
|
-
await
|
|
8949
|
-
await
|
|
7820
|
+
await mkdir13(path22.dirname(file), { recursive: true });
|
|
7821
|
+
await writeFile14(file, `${JSON.stringify(data, null, 2)}
|
|
8950
7822
|
`, "utf8");
|
|
8951
7823
|
}
|
|
8952
7824
|
|
|
@@ -8968,7 +7840,6 @@ var HostServer = class {
|
|
|
8968
7840
|
#workspaces;
|
|
8969
7841
|
#archive;
|
|
8970
7842
|
#pins;
|
|
8971
|
-
#sessionLinks;
|
|
8972
7843
|
#order;
|
|
8973
7844
|
#folders;
|
|
8974
7845
|
#settings;
|
|
@@ -8977,7 +7848,6 @@ var HostServer = class {
|
|
|
8977
7848
|
/** Опросы статуса для идущих OAuth-входов MCP, ключ — сессия и сервер. */
|
|
8978
7849
|
#mcpAuthWatch = /* @__PURE__ */ new Map();
|
|
8979
7850
|
#antigravity;
|
|
8980
|
-
#codex;
|
|
8981
7851
|
/** Боковые сессии («вопрос на полях») по id родителя — не больше одной на разговор. */
|
|
8982
7852
|
#sides = /* @__PURE__ */ new Map();
|
|
8983
7853
|
/**
|
|
@@ -9025,7 +7895,7 @@ var HostServer = class {
|
|
|
9025
7895
|
#limitHandoffBusy = /* @__PURE__ */ new Set();
|
|
9026
7896
|
/** Живые id сессий, у которых сейчас пишется ручной хэндофф. */
|
|
9027
7897
|
#handoffBusy = /* @__PURE__ */ new Set();
|
|
9028
|
-
#hostId =
|
|
7898
|
+
#hostId = randomUUID5();
|
|
9029
7899
|
#plugins = new PluginCli();
|
|
9030
7900
|
#auth = new AuthCli();
|
|
9031
7901
|
#relay;
|
|
@@ -9045,12 +7915,10 @@ var HostServer = class {
|
|
|
9045
7915
|
this.#workspaces = new WorkspaceRegistry(options2.dataDir);
|
|
9046
7916
|
this.#archive = new SessionArchive(options2.dataDir);
|
|
9047
7917
|
this.#pins = new SessionPins(options2.dataDir);
|
|
9048
|
-
this.#sessionLinks = new SessionLinks(options2.dataDir);
|
|
9049
7918
|
this.#order = new ListOrderStore(options2.dataDir);
|
|
9050
7919
|
this.#folders = new Folders(options2.dataDir);
|
|
9051
7920
|
this.#settings = new AppSettingsStore(options2.dataDir);
|
|
9052
7921
|
this.#antigravity = new AntigravityStore(options2.dataDir);
|
|
9053
|
-
this.#codex = new CodexStore(options2.dataDir);
|
|
9054
7922
|
this.#handoffs = new HandoffStore(options2.dataDir);
|
|
9055
7923
|
this.#limitStop = new LimitStopState(options2.dataDir);
|
|
9056
7924
|
this.#finder = new ProjectFinder(this.#workspaces);
|
|
@@ -9077,11 +7945,9 @@ var HostServer = class {
|
|
|
9077
7945
|
const id = workspaceIdFromPath(dir);
|
|
9078
7946
|
const onDisk = await this.#workspaces.sessionsOnDisk(id);
|
|
9079
7947
|
const antigravity = await this.#antigravity.list(id);
|
|
9080
|
-
|
|
9081
|
-
return [...onDisk.map((s) => s.sessionId), ...antigravity.map((r) => r.id), ...codex.map((r) => r.id)];
|
|
7948
|
+
return [...onDisk.map((s) => s.sessionId), ...antigravity.map((r) => r.id)];
|
|
9082
7949
|
});
|
|
9083
7950
|
await this.#antigravity.remapWorkspaceIds(remap);
|
|
9084
|
-
await this.#codex.remapWorkspaceIds(remap);
|
|
9085
7951
|
await this.#archive.remapWorkspaceIds(remap);
|
|
9086
7952
|
await this.#pins.remapWorkspaceIds(remap);
|
|
9087
7953
|
await this.#order.remapWorkspaceIds(remap);
|
|
@@ -9091,7 +7957,6 @@ var HostServer = class {
|
|
|
9091
7957
|
await this.#workspaces.load();
|
|
9092
7958
|
await this.#archive.load();
|
|
9093
7959
|
await this.#pins.load();
|
|
9094
|
-
await this.#sessionLinks.load();
|
|
9095
7960
|
await this.#order.load();
|
|
9096
7961
|
await this.#folders.load();
|
|
9097
7962
|
await this.#carryOverWorkspaceIds();
|
|
@@ -9260,8 +8125,7 @@ var HostServer = class {
|
|
|
9260
8125
|
client.send({
|
|
9261
8126
|
type: "error",
|
|
9262
8127
|
message: error instanceof Error ? error.message : String(error),
|
|
9263
|
-
context: frame.type
|
|
9264
|
-
..."requestId" in frame && typeof frame.requestId === "string" ? { requestId: frame.requestId } : {}
|
|
8128
|
+
context: frame.type
|
|
9265
8129
|
});
|
|
9266
8130
|
});
|
|
9267
8131
|
}
|
|
@@ -9304,12 +8168,10 @@ var HostServer = class {
|
|
|
9304
8168
|
protocol: PROTOCOL_VERSION,
|
|
9305
8169
|
hostId: this.#hostId,
|
|
9306
8170
|
hostVersion: this.#options.version,
|
|
9307
|
-
platform: process.platform
|
|
9308
|
-
features: ["session-routing", "session-links", "provider-default-models"]
|
|
8171
|
+
platform: process.platform
|
|
9309
8172
|
});
|
|
9310
8173
|
this.#send(socket, { type: "workspace.list", ...this.#workspaceLists() });
|
|
9311
8174
|
this.#sendFolders(socket);
|
|
9312
|
-
this.#send(socket, { type: "session.links", links: this.#sessionLinks.all });
|
|
9313
8175
|
this.#send(socket, { type: "order.state", order: this.#order.current });
|
|
9314
8176
|
this.#sendLive(socket);
|
|
9315
8177
|
this.#auth.status().then((status) => this.#send(socket, { type: "auth.status", status })).catch(() => void 0);
|
|
@@ -9386,27 +8248,6 @@ var HostServer = class {
|
|
|
9386
8248
|
case "session.start":
|
|
9387
8249
|
await this.#startSession(socket, frame);
|
|
9388
8250
|
return;
|
|
9389
|
-
case "session.links.get":
|
|
9390
|
-
this.#send(socket, { type: "session.links", links: this.#sessionLinks.all });
|
|
9391
|
-
return;
|
|
9392
|
-
case "session.link": {
|
|
9393
|
-
const { sessions, archived } = await this.#listSessions(frame.workspaceId);
|
|
9394
|
-
const find = (id) => [...sessions, ...archived].find((s) => s.id === id || s.claudeSessionId === id);
|
|
9395
|
-
const child = find(frame.sessionId);
|
|
9396
|
-
const parent = frame.parentId === null ? null : find(frame.parentId);
|
|
9397
|
-
if (!child || frame.parentId !== null && !parent)
|
|
9398
|
-
throw new Error("\u0421\u0435\u0441\u0441\u0438\u044F \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435");
|
|
9399
|
-
await this.#sessionLinks.set({
|
|
9400
|
-
workspaceId: frame.workspaceId,
|
|
9401
|
-
sessionId: child.claudeSessionId ?? child.id,
|
|
9402
|
-
parentId: parent ? parent.claudeSessionId ?? parent.id : null,
|
|
9403
|
-
stage: frame.stage,
|
|
9404
|
-
kind: "linked",
|
|
9405
|
-
createdAt: Date.now()
|
|
9406
|
-
});
|
|
9407
|
-
this.#broadcast({ type: "session.links", links: this.#sessionLinks.all });
|
|
9408
|
-
return;
|
|
9409
|
-
}
|
|
9410
8251
|
case "session.close":
|
|
9411
8252
|
await this.#dropSession(frame.sessionId, "closed by client");
|
|
9412
8253
|
return;
|
|
@@ -10278,8 +9119,6 @@ var HostServer = class {
|
|
|
10278
9119
|
return false;
|
|
10279
9120
|
await this.#closeSide(sessionId);
|
|
10280
9121
|
await session.close(reason);
|
|
10281
|
-
if (this.#sessions.get(sessionId) !== session)
|
|
10282
|
-
return true;
|
|
10283
9122
|
this.#sessions.delete(sessionId);
|
|
10284
9123
|
this.#limitApproved.delete(sessionId);
|
|
10285
9124
|
this.#broadcast({ type: "session.closed", sessionId, reason });
|
|
@@ -10578,49 +9417,9 @@ var HostServer = class {
|
|
|
10578
9417
|
const workspace = this.#workspaces.find(frame.workspaceId);
|
|
10579
9418
|
if (!workspace)
|
|
10580
9419
|
throw new Error(`\u0412\u043E\u0440\u043A\u0441\u043F\u0435\u0439\u0441 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${frame.workspaceId}`);
|
|
10581
|
-
if (frame.taskParent) {
|
|
10582
|
-
const list = await this.#listSessions(workspace.id);
|
|
10583
|
-
if (![...list.sessions, ...list.archived].some((s) => s.id === frame.taskParent || s.claudeSessionId === frame.taskParent))
|
|
10584
|
-
throw new Error("\u0420\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u0441\u043A\u0430\u044F \u0441\u0435\u0441\u0441\u0438\u044F \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435");
|
|
10585
|
-
}
|
|
10586
9420
|
const provider = frame.provider ?? "claude";
|
|
10587
|
-
const defaultModel = this.#settings.current.startModels[provider];
|
|
10588
|
-
const startModel = frame.model ?? (!frame.resume ? defaultModel ?? void 0 : void 0);
|
|
10589
9421
|
if (!frame.resume && !this.#settings.current.enabledProviders.includes(provider)) {
|
|
10590
|
-
throw new Error(`${provider === "
|
|
10591
|
-
}
|
|
10592
|
-
const codexRecord = frame.resume ? await this.#codex.find(frame.resume) : null;
|
|
10593
|
-
if (codexRecord || provider === "codex") {
|
|
10594
|
-
if (frame.resume && !codexRecord)
|
|
10595
|
-
throw new Error("\u0421\u0435\u0441\u0441\u0438\u044F Codex \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430");
|
|
10596
|
-
if (codexRecord && codexRecord.workspaceId !== workspace.id)
|
|
10597
|
-
throw new Error("\u0421\u0435\u0441\u0441\u0438\u044F \u043F\u0440\u0438\u043D\u0430\u0434\u043B\u0435\u0436\u0438\u0442 \u0434\u0440\u0443\u0433\u043E\u043C\u0443 \u043F\u0440\u043E\u0435\u043A\u0442\u0443");
|
|
10598
|
-
const existing = codexRecord && !frame.fork ? this.#sessions.get(codexRecord.id) : null;
|
|
10599
|
-
if (existing && existing.state !== "closed" && existing.state !== "error") {
|
|
10600
|
-
await this.#announceStarted(socket, frame, existing);
|
|
10601
|
-
return;
|
|
10602
|
-
}
|
|
10603
|
-
if (existing)
|
|
10604
|
-
await existing.close();
|
|
10605
|
-
if (codexRecord)
|
|
10606
|
-
await this.#archive.unarchive([codexRecord.id]);
|
|
10607
|
-
const session2 = new CodexSession({
|
|
10608
|
-
workspaceId: workspace.id,
|
|
10609
|
-
cwd: workspace.path,
|
|
10610
|
-
store: this.#codex,
|
|
10611
|
-
...codexRecord ? { record: codexRecord } : {},
|
|
10612
|
-
fork: frame.fork,
|
|
10613
|
-
permissionMode: frame.permissionMode ?? codexRecord?.permissionMode ?? (!frame.resume ? this.#settings.current.startCodexPermissionMode : "default"),
|
|
10614
|
-
...startModel ? { model: startModel } : {},
|
|
10615
|
-
defaultTitle: workspace.name,
|
|
10616
|
-
writableRoots: () => this.#writableRoots(workspace.path)
|
|
10617
|
-
});
|
|
10618
|
-
this.#wire(session2);
|
|
10619
|
-
this.#sessions.set(session2.id, session2);
|
|
10620
|
-
session2.start();
|
|
10621
|
-
this.#sendLive();
|
|
10622
|
-
await this.#announceStarted(socket, frame, session2);
|
|
10623
|
-
return;
|
|
9422
|
+
throw new Error(`${provider === "antigravity" ? "Antigravity" : "Claude"} \u0432\u044B\u043A\u043B\u044E\u0447\u0435\u043D \u0432 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u0445`);
|
|
10624
9423
|
}
|
|
10625
9424
|
const agyRecord = frame.resume ? await this.#antigravity.find(frame.resume) : null;
|
|
10626
9425
|
if (agyRecord || !frame.resume && frame.provider === "antigravity") {
|
|
@@ -10632,14 +9431,14 @@ var HostServer = class {
|
|
|
10632
9431
|
store: this.#antigravity,
|
|
10633
9432
|
...agyRecord ? { record: agyRecord } : {},
|
|
10634
9433
|
...frame.permissionMode ? { permissionMode: frame.permissionMode } : {},
|
|
10635
|
-
...
|
|
9434
|
+
...frame.model ? { model: frame.model } : {},
|
|
10636
9435
|
defaultTitle: workspace.name
|
|
10637
9436
|
});
|
|
10638
9437
|
this.#wire(session2);
|
|
10639
9438
|
this.#sessions.set(session2.id, session2);
|
|
10640
9439
|
session2.start();
|
|
10641
9440
|
this.#sendLive();
|
|
10642
|
-
|
|
9441
|
+
this.#send(socket, { type: "session.summary", session: session2.summary() });
|
|
10643
9442
|
return;
|
|
10644
9443
|
}
|
|
10645
9444
|
const resumed = frame.resume && !frame.fork ? (await this.#workspaces.sessionsOnDisk(workspace.id)).find((info) => info.sessionId === frame.resume) : void 0;
|
|
@@ -10653,7 +9452,7 @@ var HostServer = class {
|
|
|
10653
9452
|
resume: frame.resume,
|
|
10654
9453
|
fork: frame.fork,
|
|
10655
9454
|
permissionMode: frame.permissionMode ?? startDefaults.startPermissionMode,
|
|
10656
|
-
model: startModel,
|
|
9455
|
+
model: frame.model ?? startDefaults.startModel ?? void 0,
|
|
10657
9456
|
...resumedTitle ? { title: resumedTitle } : {},
|
|
10658
9457
|
// Имя проекта вместо «Без названия»: свежую сессию в списке уже надо
|
|
10659
9458
|
// как-то называть, а сказать о ней пока нечего, кроме того, где она.
|
|
@@ -10664,31 +9463,13 @@ var HostServer = class {
|
|
|
10664
9463
|
this.#sessions.set(session.id, session);
|
|
10665
9464
|
session.start();
|
|
10666
9465
|
this.#sendLive();
|
|
10667
|
-
|
|
9466
|
+
this.#send(socket, { type: "session.summary", session: session.summary() });
|
|
10668
9467
|
if (!frame.continuesFrom)
|
|
10669
9468
|
return;
|
|
10670
9469
|
await this.#carryPin(workspace.id, frame.continuesFrom, session.id);
|
|
10671
9470
|
if (frame.fromHandoff)
|
|
10672
9471
|
await this.#markHandoffContinued(frame.continuesFrom);
|
|
10673
9472
|
}
|
|
10674
|
-
async #announceStarted(socket, frame, session) {
|
|
10675
|
-
const summary = session.summary();
|
|
10676
|
-
const parent = frame.taskParent ?? (frame.fork ? frame.resume : frame.continuesFrom);
|
|
10677
|
-
if (parent && (!frame.resume || frame.fork)) {
|
|
10678
|
-
await this.#sessionLinks.set({
|
|
10679
|
-
workspaceId: frame.workspaceId,
|
|
10680
|
-
sessionId: summary.claudeSessionId ?? summary.id,
|
|
10681
|
-
parentId: parent,
|
|
10682
|
-
stage: frame.taskStage ?? "other",
|
|
10683
|
-
kind: frame.fork ? "fork" : "continuation",
|
|
10684
|
-
createdAt: Date.now()
|
|
10685
|
-
});
|
|
10686
|
-
this.#broadcast({ type: "session.links", links: this.#sessionLinks.all });
|
|
10687
|
-
}
|
|
10688
|
-
this.#send(socket, { type: "session.summary", session: summary });
|
|
10689
|
-
if (frame.requestId)
|
|
10690
|
-
this.#send(socket, { type: "session.started", requestId: frame.requestId, session: summary });
|
|
10691
|
-
}
|
|
10692
9473
|
/**
|
|
10693
9474
|
* Отметить хэндофф продолженным — и сказать об этом всем окнам. Он остаётся
|
|
10694
9475
|
* лежать у прежней сессии, пока его не скроют, и без отметки её баннер звал
|
|
@@ -10772,19 +9553,11 @@ var HostServer = class {
|
|
|
10772
9553
|
});
|
|
10773
9554
|
session.on("summary", (summary) => {
|
|
10774
9555
|
this.#broadcast({ type: "session.summary", session: summary });
|
|
10775
|
-
if (summary.claudeSessionId && summary.claudeSessionId !== summary.id && this.#sessionLinks.all.some((r) => r.sessionId === summary.id || r.parentId === summary.id)) {
|
|
10776
|
-
void this.#sessionLinks.migrate(summary.id, summary.claudeSessionId).then(() => {
|
|
10777
|
-
this.#broadcast({ type: "session.links", links: this.#sessionLinks.all });
|
|
10778
|
-
}).catch((error) => console.error("[session.links]", error));
|
|
10779
|
-
}
|
|
10780
9556
|
if (!summary.claudeSessionId || !this.#pins.has(summary.id))
|
|
10781
9557
|
return;
|
|
10782
9558
|
void this.#migratePin(summary.id, summary.claudeSessionId);
|
|
10783
9559
|
});
|
|
10784
9560
|
session.on("claudeSessionId", ({ from, to }) => {
|
|
10785
|
-
void this.#sessionLinks.migrate(from, to).then(() => {
|
|
10786
|
-
this.#broadcast({ type: "session.links", links: this.#sessionLinks.all });
|
|
10787
|
-
}).catch((error) => console.error("[session.links]", error));
|
|
10788
9561
|
if (!this.#pins.has(from))
|
|
10789
9562
|
return;
|
|
10790
9563
|
void this.#migratePin(from, to);
|
|
@@ -10810,7 +9583,7 @@ var HostServer = class {
|
|
|
10810
9583
|
this.#broadcast({ type: "context.state", sessionId: session.id, context });
|
|
10811
9584
|
});
|
|
10812
9585
|
session.on("stderr", (data) => {
|
|
10813
|
-
const tag = session instanceof
|
|
9586
|
+
const tag = session instanceof AntigravitySession ? "agy" : "claude";
|
|
10814
9587
|
process.stderr.write(`[${tag} ${session.id.slice(0, 8)}] ${data}`);
|
|
10815
9588
|
});
|
|
10816
9589
|
}
|
|
@@ -10830,7 +9603,7 @@ var HostServer = class {
|
|
|
10830
9603
|
* разговора пока и не было.
|
|
10831
9604
|
*/
|
|
10832
9605
|
#ensureSide(parent) {
|
|
10833
|
-
if (
|
|
9606
|
+
if (parent instanceof AntigravitySession) {
|
|
10834
9607
|
throw new Error("\u0412\u043E\u043F\u0440\u043E\u0441 \u043D\u0430 \u043F\u043E\u043B\u044F\u0445 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u0441\u0435\u0441\u0441\u0438\u044F\u0445 Claude");
|
|
10835
9608
|
}
|
|
10836
9609
|
const existing = this.#sides.get(parent.id);
|
|
@@ -10888,7 +9661,7 @@ var HostServer = class {
|
|
|
10888
9661
|
*/
|
|
10889
9662
|
#roots() {
|
|
10890
9663
|
const roots = this.#finder.roots();
|
|
10891
|
-
return roots.length > 0 ? roots : [
|
|
9664
|
+
return roots.length > 0 ? roots : [homedir6()];
|
|
10892
9665
|
}
|
|
10893
9666
|
/**
|
|
10894
9667
|
* Где сессии этого каталога разрешено писать без вопроса.
|
|
@@ -11130,7 +9903,7 @@ var HostServer = class {
|
|
|
11130
9903
|
live.setTitle(title);
|
|
11131
9904
|
return;
|
|
11132
9905
|
}
|
|
11133
|
-
if (await this.#
|
|
9906
|
+
if (await this.#antigravity.rename(sessionId, title)) {
|
|
11134
9907
|
if (workspaceId)
|
|
11135
9908
|
await this.#sendSessionList(workspaceId);
|
|
11136
9909
|
return;
|
|
@@ -11187,24 +9960,17 @@ var HostServer = class {
|
|
|
11187
9960
|
continue;
|
|
11188
9961
|
historical.push(antigravitySummary(record));
|
|
11189
9962
|
}
|
|
11190
|
-
if (workspacePath && this.#settings.current.enabledProviders.includes("codex"))
|
|
11191
|
-
await this.#codex.discover(workspaceId, workspacePath);
|
|
11192
|
-
for (const record of await this.#codex.list(workspaceId)) {
|
|
11193
|
-
if (!liveIds.has(record.id))
|
|
11194
|
-
historical.push({ ...antigravitySummary(record), provider: "codex" });
|
|
11195
|
-
}
|
|
11196
9963
|
const known = /* @__PURE__ */ new Set([...liveIds, ...historical.map((s) => s.id)]);
|
|
11197
9964
|
await this.#archive.sweep(workspaceId, historical.filter((s) => !this.#pins.has(s.id)).map((s) => ({ id: s.id, updatedAt: s.updatedAt })), known, this.#settings.current.autoArchiveAfterMs);
|
|
11198
9965
|
await this.#pins.sweep(workspaceId, known);
|
|
11199
9966
|
const sessions = [];
|
|
11200
9967
|
const archived = [];
|
|
11201
9968
|
for (const base of [...live, ...historical].sort((a, b) => b.updatedAt - a.updatedAt)) {
|
|
11202
|
-
const current = this.#sessions.get(base.id)?.summary() ?? base;
|
|
11203
9969
|
const pin = this.#pins.find(base.claudeSessionId ?? base.id);
|
|
11204
9970
|
const folderId = this.#folders.folderIdForSession(base.claudeSessionId ?? base.id);
|
|
11205
9971
|
const pinnedFolderId = this.#folders.folderIdForPinnedSession(base.claudeSessionId ?? base.id);
|
|
11206
9972
|
const summary = {
|
|
11207
|
-
...
|
|
9973
|
+
...base,
|
|
11208
9974
|
...pin ? { pinned: true, pinnedAt: pin.at } : {},
|
|
11209
9975
|
...folderId ? { folderId } : {},
|
|
11210
9976
|
...pinnedFolderId ? { pinnedFolderId } : {}
|
|
@@ -11240,15 +10006,15 @@ var HostServer = class {
|
|
|
11240
10006
|
}
|
|
11241
10007
|
#serveStatic(req, res) {
|
|
11242
10008
|
const webRoot = this.#options.webRoot;
|
|
11243
|
-
if (!webRoot || !
|
|
10009
|
+
if (!webRoot || !existsSync4(webRoot)) {
|
|
11244
10010
|
res.writeHead(200, { "content-type": "text/plain; charset=utf-8" });
|
|
11245
10011
|
res.end("CCV host is running. UI is served by the Vite dev server.\n");
|
|
11246
10012
|
return;
|
|
11247
10013
|
}
|
|
11248
10014
|
const url2 = new URL(req.url ?? "/", "http://localhost");
|
|
11249
|
-
const requested =
|
|
11250
|
-
const target = requested.startsWith(webRoot) &&
|
|
11251
|
-
if (!
|
|
10015
|
+
const requested = path23.join(webRoot, path23.normalize(url2.pathname));
|
|
10016
|
+
const target = requested.startsWith(webRoot) && existsSync4(requested) && statSync3(requested).isFile() ? requested : path23.join(webRoot, "index.html");
|
|
10017
|
+
if (!existsSync4(target)) {
|
|
11252
10018
|
res.writeHead(404).end("not found");
|
|
11253
10019
|
return;
|
|
11254
10020
|
}
|
|
@@ -11273,7 +10039,7 @@ function contentType(file) {
|
|
|
11273
10039
|
".svg": "image/svg+xml",
|
|
11274
10040
|
".woff2": "font/woff2"
|
|
11275
10041
|
};
|
|
11276
|
-
return types[
|
|
10042
|
+
return types[path23.extname(file)] ?? "application/octet-stream";
|
|
11277
10043
|
}
|
|
11278
10044
|
function antigravitySummary(record) {
|
|
11279
10045
|
return {
|
|
@@ -11302,8 +10068,8 @@ function antigravitySummary(record) {
|
|
|
11302
10068
|
}
|
|
11303
10069
|
|
|
11304
10070
|
// dist/ccv.js
|
|
11305
|
-
var HERE =
|
|
11306
|
-
var PACKAGE_ROOT =
|
|
10071
|
+
var HERE = path24.dirname(fileURLToPath(import.meta.url));
|
|
10072
|
+
var PACKAGE_ROOT = path24.resolve(HERE, "..");
|
|
11307
10073
|
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.
|
|
11308
10074
|
|
|
11309
10075
|
\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435:
|
|
@@ -11314,19 +10080,17 @@ var USAGE = `ccv \u2014 Claude Code Visual: \u043B\u043E\u043A\u0430\u043B\u044C
|
|
|
11314
10080
|
--host <\u0430\u0434\u0440\u0435\u0441> \u0430\u0434\u0440\u0435\u0441 \u043F\u0440\u043E\u0441\u043B\u0443\u0448\u0438\u0432\u0430\u043D\u0438\u044F (\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E 127.0.0.1)
|
|
11315
10081
|
--no-open \u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0442\u044C \u0431\u0440\u0430\u0443\u0437\u0435\u0440
|
|
11316
10082
|
--claude \u0447\u0435\u043C \u0431\u0443\u0434\u0443\u0442 \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0442\u044C\u0441\u044F \u0441\u0435\u0441\u0441\u0438\u0438, \u0438 \u0432\u044B\u0439\u0442\u0438
|
|
11317
|
-
--codex \u043F\u0443\u0442\u044C \u043A Codex CLI, \u0438 \u0432\u044B\u0439\u0442\u0438
|
|
11318
10083
|
-v, --version \u0432\u0435\u0440\u0441\u0438\u044F
|
|
11319
10084
|
-h, --help \u044D\u0442\u0430 \u0441\u043F\u0440\u0430\u0432\u043A\u0430
|
|
11320
10085
|
|
|
11321
10086
|
\u041E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0435: CCV_PORT, CCV_HOST, CCV_DATA_DIR, CCV_WEB_ROOT, CCV_RELAY_URL,
|
|
11322
|
-
CCV_CLAUDE_PATH, CCV_BUNDLED_CLAUDE
|
|
10087
|
+
CCV_CLAUDE_PATH, CCV_BUNDLED_CLAUDE.
|
|
11323
10088
|
\u0424\u043B\u0430\u0433 \u0432\u0430\u0436\u043D\u0435\u0435 \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0439 \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F, \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0430\u044F \u0432\u0430\u0436\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E.`;
|
|
11324
10089
|
var options = {
|
|
11325
10090
|
port: { type: "string", short: "p" },
|
|
11326
10091
|
host: { type: "string" },
|
|
11327
10092
|
open: { type: "boolean", default: true },
|
|
11328
10093
|
claude: { type: "boolean" },
|
|
11329
|
-
codex: { type: "boolean" },
|
|
11330
10094
|
version: { type: "boolean", short: "v" },
|
|
11331
10095
|
help: { type: "boolean", short: "h" }
|
|
11332
10096
|
};
|
|
@@ -11350,11 +10114,6 @@ if (values.version) {
|
|
|
11350
10114
|
}
|
|
11351
10115
|
if (values.claude)
|
|
11352
10116
|
process.exit(await reportClaude());
|
|
11353
|
-
if (values.codex) {
|
|
11354
|
-
const launcher = codexLauncher();
|
|
11355
|
-
console.log(launcher ? `Codex CLI: ${launcher.file}${launcher.args.length ? " " + launcher.args.join(" ") : ""}` : CODEX_MISSING_HINT);
|
|
11356
|
-
process.exit(launcher ? 0 : 1);
|
|
11357
|
-
}
|
|
11358
10117
|
var defaults = envDefaults();
|
|
11359
10118
|
var port = values.port === void 0 ? defaults.port : Number(values.port);
|
|
11360
10119
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
@@ -11377,7 +10136,7 @@ var server = new HostServer({
|
|
|
11377
10136
|
dataDir: defaults.dataDir,
|
|
11378
10137
|
// UI лежит в пакете рядом с бандлом — это и есть разница между установленной
|
|
11379
10138
|
// утилитой и запуском из репозитория, где сборка живёт в `apps/web/dist`.
|
|
11380
|
-
webRoot: process.env.CCV_WEB_ROOT ??
|
|
10139
|
+
webRoot: process.env.CCV_WEB_ROOT ?? path24.join(PACKAGE_ROOT, "web"),
|
|
11381
10140
|
version,
|
|
11382
10141
|
relayUrl: defaults.relayUrl
|
|
11383
10142
|
});
|
|
@@ -11406,7 +10165,7 @@ for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
|
11406
10165
|
}
|
|
11407
10166
|
async function packageVersion() {
|
|
11408
10167
|
try {
|
|
11409
|
-
const text = await
|
|
10168
|
+
const text = await readFile17(path24.join(PACKAGE_ROOT, "package.json"), "utf8");
|
|
11410
10169
|
return JSON.parse(text).version ?? "0.0.0";
|
|
11411
10170
|
} catch {
|
|
11412
10171
|
return "0.0.0";
|
|
@@ -11450,7 +10209,7 @@ function openBrowser(target) {
|
|
|
11450
10209
|
return;
|
|
11451
10210
|
}
|
|
11452
10211
|
const command = process.platform === "win32" ? { file: "cmd", args: ["/c", "start", "", target] } : process.platform === "darwin" ? { file: "open", args: [target] } : { file: "xdg-open", args: [target] };
|
|
11453
|
-
const child =
|
|
10212
|
+
const child = spawn3(command.file, command.args, {
|
|
11454
10213
|
stdio: "ignore",
|
|
11455
10214
|
detached: true,
|
|
11456
10215
|
windowsHide: true
|