@i14ks/ccv 0.12.1 → 0.12.3

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.
Files changed (2) hide show
  1. package/bundle/ccv.mjs +20 -2
  2. package/package.json +1 -1
package/bundle/ccv.mjs CHANGED
@@ -1039,6 +1039,7 @@ var STOPPED_REASONS = /* @__PURE__ */ new Set([
1039
1039
  var API_ERROR_REASON = "api_error";
1040
1040
  var PERMANENT_API_STATUS = /* @__PURE__ */ new Set([400, 404, 413, 422, 429]);
1041
1041
  var RECONNECT_DELAYS_MS = [1e3, 5e3, 2e4, 6e4];
1042
+ var RESUME_TIMEOUT_MS = 3e4;
1042
1043
  function turnOutcome(terminalReason, subtype, interruptRequested) {
1043
1044
  if (terminalReason && ABORTED_REASONS.has(terminalReason))
1044
1045
  return "interrupted";
@@ -1450,9 +1451,23 @@ var ClaudeSession = class extends EventEmitter {
1450
1451
  * первым ответом, то есть уже после промпта, — и сессия, которая ждала бы
1451
1452
  * его, чтобы промпт отправить, ждала бы вечно. `initializationResult()`,
1452
1453
  * наоборот, поднимает CLI сам и не требует, чтобы его о чём-то спросили.
1454
+ *
1455
+ * Гонка с тайм-аутом (`RESUME_TIMEOUT_MS`) нужна на случай, если новый
1456
+ * процесс завис на той же мёртвой сети, из-за которой оборвался прошлый:
1457
+ * без предела `await` не отличил бы это от «ещё думает» и просто не
1458
+ * вернулся бы, оставив реконнект без попытки №2.
1453
1459
  */
1454
1460
  async #resume(q) {
1455
- const ready = await q.initializationResult().then(() => true, () => false);
1461
+ let timer;
1462
+ const timedOut = new Promise((resolve) => {
1463
+ timer = setTimeout(() => resolve(false), RESUME_TIMEOUT_MS);
1464
+ timer.unref?.();
1465
+ });
1466
+ const ready = await Promise.race([
1467
+ q.initializationResult().then(() => true, () => false),
1468
+ timedOut
1469
+ ]);
1470
+ clearTimeout(timer);
1456
1471
  if (q !== this.#query)
1457
1472
  return;
1458
1473
  if (!ready) {
@@ -2276,7 +2291,7 @@ var ClaudeSession = class extends EventEmitter {
2276
2291
  this.#capabilities = {
2277
2292
  ...this.#capabilities ?? this.#baseCapabilities(),
2278
2293
  commands: init.commands.map(toSlashCommand),
2279
- models: init.models.map((m) => ({
2294
+ models: init.models.filter((m) => isPlainModel(m.value)).map((m) => ({
2280
2295
  value: m.value,
2281
2296
  resolvedModel: m.resolvedModel ?? null,
2282
2297
  displayName: m.displayName,
@@ -2384,6 +2399,9 @@ function isApiErrorMessage(message) {
2384
2399
  function apiErrorReason(status) {
2385
2400
  return status === void 0 ? "\u0437\u0430\u043F\u0440\u043E\u0441 \u043A API \u043D\u0435 \u0434\u043E\u0448\u0451\u043B" : `API \u043E\u0442\u0432\u0435\u0442\u0438\u043B ${status}`;
2386
2401
  }
2402
+ function isPlainModel(value) {
2403
+ return /^[a-z]+$/.test(value);
2404
+ }
2387
2405
  function toSlashCommand(command) {
2388
2406
  return {
2389
2407
  name: command.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i14ks/ccv",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "license": "UNLICENSED",
5
5
  "description": "GUI для Claude Code: сессии агента в каталогах проектов, дерево файлов и редактор рядом с разговором.",
6
6
  "homepage": "https://claudevisual.com",