@taskless-app/swarm 0.6.81 → 0.6.82

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 (3) hide show
  1. package/dist/cli.js +364 -169
  2. package/dist/overmind.js +499 -296
  3. package/package.json +2 -2
package/dist/overmind.js CHANGED
@@ -722,6 +722,25 @@ var init_modelPolicy = __esm({
722
722
  roles: { executor: "grok-4.7", review: "grok-4.7-build-fast" },
723
723
  models: ["grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5"]
724
724
  },
725
+ // Kimi Code CLI (Moonshot). Каталог — все 5 моделей из конфига владельца (09.11.2026),
726
+ // полные алиасы как в дефолтном config.toml любого kimi-code: ссылки вида
727
+ // `kimi/kimi-code/k3.1-pro` — parseModelRef режет по первому слэшу, моделью уходит
728
+ // `kimi-code/k3.1-pro` (второй слэш — часть имени). Тарифа нет: подписка, CLI цену не
729
+ // сообщает — честный ноль (costUsd=0 с предупреждением) живёт в адаптере (TASWM-630).
730
+ {
731
+ id: "kimi",
732
+ label: "Kimi (Moonshot)",
733
+ executorId: "kimi",
734
+ selectable: true,
735
+ roles: { executor: "kimi-code/k3.1-pro", review: "kimi-code/k3" },
736
+ models: [
737
+ "kimi-code/kimi-for-coding",
738
+ "kimi-code/k3",
739
+ "kimi-code/k3-256k",
740
+ "kimi-code/k3.1-pro",
741
+ "kimi-code/k3.1-pro-highspeed"
742
+ ]
743
+ },
725
744
  // TASWM-565 · шаг 1 из четырёх: провайдер в реестре ЕСТЬ, выбрать его ещё нельзя.
726
745
  // Имён моделей здесь нет СОЗНАТЕЛЬНО: у владельца подписка, состав моделей в ней нам
727
746
  // неизвестен, а выдуманное имя хуже маркера «решает Codex».
@@ -3084,6 +3103,179 @@ ${notice}` : spec.prompt;
3084
3103
  }
3085
3104
  });
3086
3105
 
3106
+ // src/executors/kimi.ts
3107
+ import { copyFileSync as copyFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync4, statSync as statSync5, symlinkSync as symlinkSync3, writeFileSync as writeFileSync5 } from "fs";
3108
+ import { join as join8 } from "path";
3109
+ function resolveKimiBin(env = process.env) {
3110
+ return (env.SWARM_KIMI_BIN ?? "").trim() || "kimi";
3111
+ }
3112
+ function kimiHomePath(worktree, swarmHome = SWARM_HOME) {
3113
+ const key = worktree.replace(/[^A-Za-z0-9]+/g, "-").replace(/^-|-$/g, "") || "worktree";
3114
+ return join8(swarmHome, "executor-state", "kimi", key);
3115
+ }
3116
+ function kimiSessionRoot(worktree, swarmHome = SWARM_HOME) {
3117
+ return join8(kimiHomePath(worktree, swarmHome), "sessions");
3118
+ }
3119
+ function newestKimiSessionMtime(dir, depth = 4) {
3120
+ let entries;
3121
+ try {
3122
+ entries = readdirSync6(dir, { withFileTypes: true });
3123
+ } catch {
3124
+ return null;
3125
+ }
3126
+ let latest = null;
3127
+ for (const entry of entries) {
3128
+ const full = join8(dir, entry.name);
3129
+ try {
3130
+ if (entry.isDirectory()) {
3131
+ if (depth <= 0) continue;
3132
+ const nested = newestKimiSessionMtime(full, depth - 1);
3133
+ if (nested != null && (latest == null || nested > latest)) latest = nested;
3134
+ } else if (entry.isFile()) {
3135
+ const mtime2 = statSync5(full).mtimeMs;
3136
+ if (latest == null || mtime2 > latest) latest = mtime2;
3137
+ }
3138
+ } catch {
3139
+ }
3140
+ }
3141
+ return latest;
3142
+ }
3143
+ function extractModelsBlocks(config) {
3144
+ const lines = config.split(/\r?\n/);
3145
+ const blocks = [];
3146
+ let current = null;
3147
+ for (const line of lines) {
3148
+ if (/^\s*\[/.test(line)) {
3149
+ if (current) blocks.push(current);
3150
+ current = /^\s*\[models\./.test(line) ? [line] : null;
3151
+ continue;
3152
+ }
3153
+ if (current) current.push(line);
3154
+ }
3155
+ if (current) blocks.push(current);
3156
+ return blocks.map((b) => b.join("\n").trimEnd()).filter((b) => b.trim() !== "");
3157
+ }
3158
+ function kimiMcpJson(spec) {
3159
+ return JSON.stringify(
3160
+ { mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
3161
+ null,
3162
+ 2
3163
+ );
3164
+ }
3165
+ function ensureKimiHome(worktree, realHome, env = process.env, swarmHome = SWARM_HOME) {
3166
+ const home = kimiHomePath(worktree, swarmHome);
3167
+ mkdirSync5(home, { recursive: true });
3168
+ const realCreds = join8((env.KIMI_CODE_HOME ?? "").trim() || join8(realHome, ".kimi-code"), "credentials");
3169
+ const link2 = join8(home, "credentials");
3170
+ if (existsSync6(realCreds) && !existsSync6(link2)) {
3171
+ try {
3172
+ symlinkSync3(realCreds, link2, "junction");
3173
+ } catch {
3174
+ try {
3175
+ mkdirSync5(link2, { recursive: true });
3176
+ for (const f of readdirSync6(realCreds)) copyFileSync4(join8(realCreds, f), join8(link2, f));
3177
+ } catch {
3178
+ }
3179
+ }
3180
+ }
3181
+ const realConfig = join8((env.KIMI_CODE_HOME ?? "").trim() || join8(realHome, ".kimi-code"), "config.toml");
3182
+ try {
3183
+ const blocks = extractModelsBlocks(readFileSync4(realConfig, "utf8"));
3184
+ if (blocks.length > 0) writeFileSync5(join8(home, "config.toml"), `${blocks.join("\n\n")}
3185
+ `);
3186
+ } catch {
3187
+ }
3188
+ return home;
3189
+ }
3190
+ function modelArgs2(model) {
3191
+ if (!model || isHarnessDefaultModel(model)) return [];
3192
+ return ["-m", model];
3193
+ }
3194
+ function parseKimiResult(raw) {
3195
+ const trimmed = raw.trim();
3196
+ if (!trimmed) return null;
3197
+ let lastAssistant = null;
3198
+ let sawEvent = false;
3199
+ for (const line of trimmed.split(/\r?\n/)) {
3200
+ const s = line.trim();
3201
+ if (!s) continue;
3202
+ let parsed;
3203
+ try {
3204
+ parsed = JSON.parse(s);
3205
+ } catch {
3206
+ continue;
3207
+ }
3208
+ if (typeof parsed !== "object" || parsed === null) continue;
3209
+ sawEvent = true;
3210
+ const rec = parsed;
3211
+ if (rec.role === "assistant" && typeof rec.content === "string") lastAssistant = rec.content;
3212
+ }
3213
+ if (!sawEvent || lastAssistant === null) return null;
3214
+ return {
3215
+ costUsd: 0,
3216
+ warning: "kimi: CLI \u0441\u0442\u043E\u0438\u043C\u043E\u0441\u0442\u044C \u043D\u0435 \u0441\u043E\u043E\u0431\u0449\u0430\u0435\u0442 (\u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0430) \u2014 \u044D\u0442\u043E \u043D\u0435 \u043D\u043E\u043B\u044C \u0432 \u0441\u043C\u044B\u0441\u043B\u0435 \u0431\u0435\u0441\u043F\u043B\u0430\u0442\u043D\u043E"
3217
+ };
3218
+ }
3219
+ var kimiExecutor;
3220
+ var init_kimi = __esm({
3221
+ "src/executors/kimi.ts"() {
3222
+ "use strict";
3223
+ init_src();
3224
+ init_swarmHome();
3225
+ init_swarmFiles();
3226
+ kimiExecutor = {
3227
+ id: "kimi",
3228
+ title: "Kimi Code CLI (kimi)",
3229
+ binEnv: "SWARM_KIMI_BIN",
3230
+ install: {
3231
+ what: "Kimi Code CLI (Moonshot). \u041E\u0444\u0438\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u0439 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0449\u0438\u043A \u0441 code.kimi.com \u2014 \u041D\u0415 npm-\u043F\u0430\u043A\u0435\u0442 kimi-code (\u044D\u0442\u043E \u0447\u0443\u0436\u043E\u0439 \u043F\u0440\u043E\u043A\u0441\u0438-\u0432\u0440\u0430\u043F\u043F\u0435\u0440).",
3232
+ pkg: "kimi-code",
3233
+ command: "curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash",
3234
+ windowsCommand: "irm https://code.kimi.com/kimi-code/install.ps1 | iex"
3235
+ },
3236
+ resolveBin: (env) => resolveKimiBin(env ?? process.env),
3237
+ plan: (spec) => {
3238
+ const home = ensureKimiHome(spec.worktree, spec.realHome);
3239
+ writeFileSync5(join8(home, "mcp.json"), kimiMcpJson(spec));
3240
+ writeFileSync5(
3241
+ join8(spec.worktree, SWARM_MCP_CONFIG_FILE),
3242
+ JSON.stringify(
3243
+ { mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
3244
+ null,
3245
+ 2
3246
+ )
3247
+ );
3248
+ const args = [
3249
+ // `--add-dir` стоит первым: настоящий флаг kimi, по нему реконсайл узнаёт
3250
+ // worktree живого процесса после рестарта демона (worktreeFromKimiCmd).
3251
+ "--add-dir",
3252
+ spec.worktree,
3253
+ "--output-format",
3254
+ "stream-json",
3255
+ ...spec.skillDirs.flatMap((dir) => ["--skills-dir", dir]),
3256
+ ...spec.continueSession ? ["--continue"] : [],
3257
+ ...modelArgs2(spec.model),
3258
+ "-p",
3259
+ spec.prompt
3260
+ ];
3261
+ return { bin: resolveKimiBin(), args, env: { KIMI_CODE_HOME: home } };
3262
+ },
3263
+ parseResult(raw) {
3264
+ return parseKimiResult(raw);
3265
+ },
3266
+ session: {
3267
+ exists: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree)) !== null,
3268
+ mtimeMs: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree))
3269
+ },
3270
+ probe: {
3271
+ args: ["-p", "ok", "--output-format", "stream-json"],
3272
+ limitPattern: /usage limit|quota|rate.limit|too many requests/i,
3273
+ authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
3274
+ }
3275
+ };
3276
+ }
3277
+ });
3278
+
3087
3279
  // src/liveModels.ts
3088
3280
  import { execFile } from "child_process";
3089
3281
  function parseGrokDefaultModel(out) {
@@ -3211,16 +3403,19 @@ var init_executors = __esm({
3211
3403
  init_claudeCode();
3212
3404
  init_codex();
3213
3405
  init_grok();
3406
+ init_kimi();
3214
3407
  init_swarmModels();
3215
3408
  init_types2();
3216
3409
  init_claudeCode();
3217
3410
  init_codex();
3218
3411
  init_grok();
3412
+ init_kimi();
3219
3413
  DEFAULT_EXECUTOR_ID = "claude-code";
3220
3414
  EXECUTORS = {
3221
3415
  [claudeCodeExecutor.id]: claudeCodeExecutor,
3222
3416
  [codexExecutor.id]: codexExecutor,
3223
- [grokExecutor.id]: grokExecutor
3417
+ [grokExecutor.id]: grokExecutor,
3418
+ [kimiExecutor.id]: kimiExecutor
3224
3419
  };
3225
3420
  }
3226
3421
  });
@@ -3327,8 +3522,8 @@ __export(config_exports, {
3327
3522
  restEndpoint: () => restEndpoint,
3328
3523
  reviewCutoffAt: () => reviewCutoffAt
3329
3524
  });
3330
- import { basename, join as join8, resolve } from "path";
3331
- import { readFileSync as readFileSync4, realpathSync, renameSync as renameSync2, writeFileSync as writeFileSync5 } from "fs";
3525
+ import { basename, join as join9, resolve } from "path";
3526
+ import { readFileSync as readFileSync5, realpathSync, renameSync as renameSync2, writeFileSync as writeFileSync6 } from "fs";
3332
3527
  function normalizeRepo(repo) {
3333
3528
  const r = (repo ?? "").trim();
3334
3529
  if (!r) return "";
@@ -3342,10 +3537,10 @@ function effectiveRepoOf(repo, fallback) {
3342
3537
  return normalizeRepo(repo || fallback || "");
3343
3538
  }
3344
3539
  function droneWorktreePath(worktreesDir, repo, slug) {
3345
- return join8(droneWorktreeRoot(worktreesDir, repo), slug);
3540
+ return join9(droneWorktreeRoot(worktreesDir, repo), slug);
3346
3541
  }
3347
3542
  function droneWorktreeRoot(worktreesDir, repo) {
3348
- return join8(worktreesDir, basename(normalizeRepo(repo)));
3543
+ return join9(worktreesDir, basename(normalizeRepo(repo)));
3349
3544
  }
3350
3545
  function resolveEffectiveWorktreesDir(deps) {
3351
3546
  if (deps.envOverride) return deps.envOverride;
@@ -3393,21 +3588,21 @@ function mcpEndpoint(api, path = TASKLESS_MCP_PATH) {
3393
3588
  }
3394
3589
  function tokenFromFile() {
3395
3590
  try {
3396
- return readFileSync4(join8(SWARM_HOME, "token"), "utf8").trim();
3591
+ return readFileSync5(join9(SWARM_HOME, "token"), "utf8").trim();
3397
3592
  } catch {
3398
3593
  return "";
3399
3594
  }
3400
3595
  }
3401
3596
  function reviewCutoffAt() {
3402
3597
  try {
3403
- const raw = JSON.parse(readFileSync4(REVIEW_CUTOFF_PATH, "utf8"));
3598
+ const raw = JSON.parse(readFileSync5(REVIEW_CUTOFF_PATH, "utf8"));
3404
3599
  if (raw.at) return raw.at;
3405
3600
  } catch {
3406
3601
  }
3407
3602
  const at = stamp();
3408
3603
  try {
3409
3604
  const tmp = `${REVIEW_CUTOFF_PATH}.tmp`;
3410
- writeFileSync5(tmp, JSON.stringify({ at }));
3605
+ writeFileSync6(tmp, JSON.stringify({ at }));
3411
3606
  renameSync2(tmp, REVIEW_CUTOFF_PATH);
3412
3607
  } catch {
3413
3608
  }
@@ -3421,25 +3616,25 @@ var init_config = __esm({
3421
3616
  init_executors();
3422
3617
  init_swarmHome();
3423
3618
  init_swarmHome();
3424
- DB_PATH = process.env.SWARM_DB || join8(SWARM_HOME, "swarm.db");
3619
+ DB_PATH = process.env.SWARM_DB || join9(SWARM_HOME, "swarm.db");
3425
3620
  EXECUTOR = resolveExecutor(process.env.SWARM_EXECUTOR);
3426
- DRONE_HOME = process.env.SWARM_DRONE_HOME || join8(SWARM_HOME, "drone-home");
3621
+ DRONE_HOME = process.env.SWARM_DRONE_HOME || join9(SWARM_HOME, "drone-home");
3427
3622
  DRONE_HOME_ISOLATION = process.env.SWARM_DRONE_ISOLATE_HOME !== "0" && process.platform !== "win32";
3428
3623
  DRONE_ISOLATION = DRONE_HOME_ISOLATION ? { home: DRONE_HOME, swarmHome: SWARM_HOME } : void 0;
3429
- WORKTREES_NOINDEX_DIR = join8(SWARM_HOME, "worktrees.noindex");
3430
- WORKTREES_LEGACY_DIR = join8(SWARM_HOME, "worktrees");
3624
+ WORKTREES_NOINDEX_DIR = join9(SWARM_HOME, "worktrees.noindex");
3625
+ WORKTREES_LEGACY_DIR = join9(SWARM_HOME, "worktrees");
3431
3626
  WORKTREES_DIR = process.env.SWARM_WORKTREES || WORKTREES_NOINDEX_DIR;
3432
- RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS || join8(SWARM_HOME, "run-logs");
3433
- DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG || join8(SWARM_HOME, "overmind.log");
3627
+ RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS || join9(SWARM_HOME, "run-logs");
3628
+ DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG || join9(SWARM_HOME, "overmind.log");
3434
3629
  DAEMON_LOG_MAX_BYTES = envNum("SWARM_DAEMON_LOG_MAX_BYTES", 16 * 1024 * 1024);
3435
3630
  DAEMON_LOG_KEEP = envNum("SWARM_DAEMON_LOG_KEEP", 2);
3436
3631
  DAEMON_LOG_CHECK_MS = envNum("SWARM_DAEMON_LOG_CHECK_MS", 6e4);
3437
3632
  DIST_BUILD = true;
3438
3633
  SWARM_BACKEND = process.env.SWARM_BACKEND === "client" ? "client" : process.env.SWARM_BACKEND === "sqlite" ? "sqlite" : DIST_BUILD ? "client" : "sqlite";
3439
- SWARM_OUTBOX = process.env.SWARM_OUTBOX || join8(SWARM_HOME, "outbox.jsonl");
3634
+ SWARM_OUTBOX = process.env.SWARM_OUTBOX || join9(SWARM_HOME, "outbox.jsonl");
3440
3635
  SWARM_MAX_IN_FLIGHT = Math.trunc(envNum("SWARM_MAX_IN_FLIGHT", 3));
3441
3636
  SWARM_CLAIM_INTERVAL_MS = envNum("SWARM_CLAIM_INTERVAL_MS", 6e4);
3442
- ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR || join8(SWARM_HOME, "env-cache");
3637
+ ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR || join9(SWARM_HOME, "env-cache");
3443
3638
  ENV_CACHE_ENABLED = process.env.SWARM_ENV_CACHE !== "0";
3444
3639
  ENV_CACHE_KEEP = Math.trunc(envNum("SWARM_ENV_CACHE_KEEP", 4));
3445
3640
  SWARM_MAX_LOAD_FACTOR = envNum("SWARM_MAX_LOAD_FACTOR", 0.9);
@@ -3469,15 +3664,15 @@ var init_config = __esm({
3469
3664
  DRONE_CHANNEL_ENABLED = process.env.SWARM_DRONE_CHANNEL !== "0";
3470
3665
  DRONE_CHANNEL_PORT = Number(process.env.SWARM_DRONE_CHANNEL_PORT) || 7421;
3471
3666
  DRONE_CHANNEL_URL = process.env.SWARM_DRONE_CHANNEL_URL || `http://127.0.0.1:${DRONE_CHANNEL_PORT}`;
3472
- DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET || join8(SWARM_HOME, "drone-channel.key");
3667
+ DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET || join9(SWARM_HOME, "drone-channel.key");
3473
3668
  DRONE_CHANNEL_GRACE_MS = envNum("SWARM_DRONE_CHANNEL_GRACE_MS", 12e4);
3474
- HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join8(SWARM_HOME, "overmind.heartbeat");
3669
+ HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join9(SWARM_HOME, "overmind.heartbeat");
3475
3670
  HEARTBEAT_STALE_MS = Number(process.env.SWARM_HEARTBEAT_STALE_MS) || 3e4;
3476
3671
  SWARM_REPO = process.env.SWARM_REPO || "";
3477
3672
  SWARM_SCAN_DEPTH = Number(process.env.SWARM_SCAN_DEPTH) || 3;
3478
3673
  SWARM_REPO_PATHS = (process.env.SWARM_REPOS || SWARM_REPO).split(",").map((s) => s.trim()).filter(Boolean);
3479
3674
  SWARM_SCAN_ROOTS_RAW = process.env.SWARM_SCAN_ROOTS || "";
3480
- REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join8(SWARM_HOME, "repo-map.json");
3675
+ REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join9(SWARM_HOME, "repo-map.json");
3481
3676
  SWARM_REPO_MAP_MS = envNum("SWARM_REPO_MAP_MS", 15 * 6e4);
3482
3677
  SWARM_REPO_SCAN_TTL_MS = envNum("SWARM_REPO_SCAN_TTL_MS", 24 * 60 * 6e4);
3483
3678
  TASKLESS_API = process.env.TASKLESS_API || "https://taskless.ru";
@@ -3492,7 +3687,7 @@ var init_config = __esm({
3492
3687
  SWARM_AUTO_REVIEW = process.env.SWARM_AUTO_REVIEW !== "0";
3493
3688
  SWARM_AUTO_VERIFY = process.env.SWARM_AUTO_VERIFY !== "0";
3494
3689
  SWARM_MERGE_QUEUE = process.env.SWARM_MERGE_QUEUE !== "0";
3495
- REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join8(SWARM_HOME, "review-cutoff.json");
3690
+ REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join9(SWARM_HOME, "review-cutoff.json");
3496
3691
  SWARM_REVIEW_CAP = Math.trunc(envNum("SWARM_REVIEW_CAP", 1));
3497
3692
  SWARM_STORM_URL = process.env.SWARM_STORM_URL || "";
3498
3693
  WEB_PORT = Number(process.env.SWARM_WEB_PORT) || 7420;
@@ -3532,7 +3727,7 @@ var init_quietExec = __esm({
3532
3727
 
3533
3728
  // src/resources.ts
3534
3729
  import os from "os";
3535
- import { readFileSync as readFileSync5, statfsSync } from "fs";
3730
+ import { readFileSync as readFileSync6, statfsSync } from "fs";
3536
3731
  function isTransientResourceError(e) {
3537
3732
  const code = e?.code;
3538
3733
  return code === "ENFILE" || code === "EMFILE" || code === "EAGAIN";
@@ -3590,7 +3785,7 @@ function fileDescriptorLoadRatio() {
3590
3785
  }
3591
3786
  if (process.platform === "linux") {
3592
3787
  try {
3593
- const [allocated, , max] = readFileSync5("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
3788
+ const [allocated, , max] = readFileSync6("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
3594
3789
  if (Number.isFinite(allocated ?? NaN) && Number.isFinite(max ?? NaN) && max) return allocated / max;
3595
3790
  } catch {
3596
3791
  }
@@ -4043,11 +4238,11 @@ var init_store = __esm({
4043
4238
  });
4044
4239
 
4045
4240
  // src/agentToken.ts
4046
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2 } from "fs";
4047
- import { join as join9 } from "path";
4241
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync7, unlinkSync as unlinkSync2 } from "fs";
4242
+ import { join as join10 } from "path";
4048
4243
  function loadAgentToken() {
4049
4244
  try {
4050
- const s = JSON.parse(readFileSync6(STORE_PATH, "utf8"));
4245
+ const s = JSON.parse(readFileSync7(STORE_PATH, "utf8"));
4051
4246
  return s.token ? s : null;
4052
4247
  } catch {
4053
4248
  return null;
@@ -4100,7 +4295,7 @@ var init_agentToken = __esm({
4100
4295
  "src/agentToken.ts"() {
4101
4296
  "use strict";
4102
4297
  init_config();
4103
- STORE_PATH = join9(SWARM_HOME, "agent.json");
4298
+ STORE_PATH = join10(SWARM_HOME, "agent.json");
4104
4299
  base = (api) => api.replace(/\/$/, "");
4105
4300
  TOKEN_PROBE_TIMEOUT_MS = 8e3;
4106
4301
  }
@@ -4214,15 +4409,15 @@ var init_toolFailure = __esm({
4214
4409
  });
4215
4410
 
4216
4411
  // src/heartbeat.ts
4217
- import { readFileSync as readFileSync8, renameSync as renameSync4, writeFileSync as writeFileSync8 } from "fs";
4412
+ import { readFileSync as readFileSync9, renameSync as renameSync4, writeFileSync as writeFileSync9 } from "fs";
4218
4413
  function writeHeartbeat(path, now) {
4219
4414
  const tmp = `${path}.tmp`;
4220
- writeFileSync8(tmp, String(now));
4415
+ writeFileSync9(tmp, String(now));
4221
4416
  renameSync4(tmp, path);
4222
4417
  }
4223
4418
  function readHeartbeat(path) {
4224
4419
  try {
4225
- const ms = Number(readFileSync8(path, "utf8").trim());
4420
+ const ms = Number(readFileSync9(path, "utf8").trim());
4226
4421
  return Number.isFinite(ms) ? ms : null;
4227
4422
  } catch {
4228
4423
  return null;
@@ -4390,7 +4585,7 @@ var init_netTimeout = __esm({
4390
4585
  });
4391
4586
 
4392
4587
  // src/procList.ts
4393
- import { readFileSync as readFileSync15 } from "fs";
4588
+ import { readFileSync as readFileSync16 } from "fs";
4394
4589
  function parsePsRows(out) {
4395
4590
  const rows = [];
4396
4591
  for (const line of out.split("\n")) {
@@ -4500,7 +4695,7 @@ function processStartedAt(pid, opts = {}) {
4500
4695
  const platform = opts.platform ?? process.platform;
4501
4696
  if (!Number.isInteger(pid) || pid <= 0 || platform === "win32") return null;
4502
4697
  if (platform === "linux") {
4503
- const readFile2 = opts.readFile ?? ((p) => readFileSync15(p, "utf8"));
4698
+ const readFile2 = opts.readFile ?? ((p) => readFileSync16(p, "utf8"));
4504
4699
  try {
4505
4700
  const stat2 = readFile2(`/proc/${pid}/stat`);
4506
4701
  const ticks = Number(stat2.slice(stat2.lastIndexOf(")") + 1).trim().split(/\s+/)[19]);
@@ -4752,9 +4947,9 @@ var init_procCleanup = __esm({
4752
4947
  });
4753
4948
 
4754
4949
  // src/git.ts
4755
- import { existsSync as existsSync13, readdirSync as readdirSync13, realpathSync as realpathSync2, statSync as statSync11 } from "fs";
4950
+ import { existsSync as existsSync14, readdirSync as readdirSync14, realpathSync as realpathSync2, statSync as statSync12 } from "fs";
4756
4951
  import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
4757
- import { isAbsolute as isAbsolute3, join as join22, resolve as resolve3, sep as sep2 } from "path";
4952
+ import { isAbsolute as isAbsolute3, join as join23, resolve as resolve3, sep as sep2 } from "path";
4758
4953
  import { $ as $2 } from "execa";
4759
4954
  function gitNet(repo, args, timeoutMs) {
4760
4955
  return withHardTimeout(
@@ -4776,14 +4971,14 @@ async function reclaimStaleWorktree(repo, worktree) {
4776
4971
  await detachWorktree(repo, worktree);
4777
4972
  }
4778
4973
  async function inspectWorktreePath(path) {
4779
- if (!existsSync13(path)) return "free";
4974
+ if (!existsSync14(path)) return "free";
4780
4975
  try {
4781
- if (readdirSync13(path).length === 0) return "free";
4976
+ if (readdirSync14(path).length === 0) return "free";
4782
4977
  } catch {
4783
4978
  return "orphan";
4784
4979
  }
4785
4980
  try {
4786
- if (statSync11(join22(path, ".git")).isDirectory()) return "main-checkout";
4981
+ if (statSync12(join23(path, ".git")).isDirectory()) return "main-checkout";
4787
4982
  } catch {
4788
4983
  }
4789
4984
  const top = await $2({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
@@ -4822,7 +5017,7 @@ async function clearWorktreePath(repo, path, branch, opts = {}) {
4822
5017
  await detachWorktree(repo, path);
4823
5018
  opts.onStaleReclaim?.(path);
4824
5019
  }
4825
- if (!existsSync13(path)) return;
5020
+ if (!existsSync14(path)) return;
4826
5021
  await parkOrphanDir(repo, path, branch);
4827
5022
  }
4828
5023
  async function parkOrphanDir(repo, path, branch) {
@@ -4843,7 +5038,7 @@ async function parkOrphanDir(repo, path, branch) {
4843
5038
  }
4844
5039
  function isLinkedWorktree(dir) {
4845
5040
  try {
4846
- return statSync11(join22(dir, ".git")).isFile();
5041
+ return statSync12(join23(dir, ".git")).isFile();
4847
5042
  } catch {
4848
5043
  return false;
4849
5044
  }
@@ -4855,7 +5050,7 @@ async function detachWorktree(repo, worktree) {
4855
5050
  }
4856
5051
  }
4857
5052
  async function ensureWorktreeDirGone(worktree) {
4858
- if (!existsSync13(worktree)) return false;
5053
+ if (!existsSync14(worktree)) return false;
4859
5054
  if (!isLinkedWorktree(worktree)) {
4860
5055
  console.error(
4861
5056
  `[git] ${worktree} \u2014 \u043D\u0435 \u043F\u0440\u0438\u0441\u0442\u0451\u0433\u043D\u0443\u0442\u044B\u0439 worktree (.git \u043D\u0435 \u0444\u0430\u0439\u043B): \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u041D\u0415 \u0442\u0440\u043E\u0433\u0430\u044E. \u0415\u0441\u043B\u0438 \u044D\u0442\u043E \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E worktree \u0434\u0440\u043E\u043D\u0430 \u2014 \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u0435\u0433\u043E \u0440\u0443\u043A\u0430\u043C\u0438; \u0435\u0441\u043B\u0438 \u044D\u0442\u043E \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0447\u0435\u043A\u0430\u0443\u0442, \u0437\u043D\u0430\u0447\u0438\u0442 \u0432\u0435\u0442\u043A\u0430 \u0441\u043B\u0430\u0433\u0430 \u0447\u0435\u043A\u043D\u0443\u0442\u0430 \u0432 \u043D\u0451\u043C (git checkout <slug>) \u2014 \u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u0435\u0433\u043E \u043D\u0430 \u0434\u0440\u0443\u0433\u0443\u044E \u0432\u0435\u0442\u043A\u0443.`
@@ -4870,7 +5065,7 @@ async function ensureWorktreeDirGone(worktree) {
4870
5065
  );
4871
5066
  return true;
4872
5067
  }
4873
- if (existsSync13(worktree)) {
5068
+ if (existsSync14(worktree)) {
4874
5069
  console.error(`[git] \u043A\u0430\u0442\u0430\u043B\u043E\u0433 worktree ${worktree} \u043F\u0435\u0440\u0435\u0436\u0438\u043B rm \u2014 \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0443\u043A\u0430\u043C\u0438, \u0438\u043D\u0430\u0447\u0435 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u0441\u043F\u0430\u0432\u043D \u0441\u043B\u0430\u0433\u0430 \u0432\u0441\u0442\u0430\u043D\u0435\u0442.`);
4875
5070
  }
4876
5071
  return true;
@@ -4919,7 +5114,7 @@ async function checkoutWorktree(repo, path, branch, opts) {
4919
5114
  }
4920
5115
  const busyAt = await worktreeForBranch(repo, branch);
4921
5116
  if (busyAt) {
4922
- const exists = existsSync13(busyAt);
5117
+ const exists = existsSync14(busyAt);
4923
5118
  const live2 = exists && (opts.isWorktreeHeldLive ? await opts.isWorktreeHeldLive(busyAt) : true);
4924
5119
  if (live2) throw new WorktreeBusyError(branch, busyAt);
4925
5120
  if (exists && await worktreeDirty(busyAt)) throw new WorktreeBusyError(branch, busyAt);
@@ -4955,8 +5150,8 @@ async function ensureGitExcluded(worktree, pattern) {
4955
5150
  try {
4956
5151
  const commonDir = await gitPath(worktree, "--git-common-dir");
4957
5152
  if (!commonDir) return false;
4958
- const infoDir = join22(commonDir, "info");
4959
- const excludeFile = join22(infoDir, "exclude");
5153
+ const infoDir = join23(commonDir, "info");
5154
+ const excludeFile = join23(infoDir, "exclude");
4960
5155
  let current = "";
4961
5156
  try {
4962
5157
  current = await readFile(excludeFile, "utf8");
@@ -4976,7 +5171,7 @@ async function gitPath(worktree, flag) {
4976
5171
  const out = await $2({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
4977
5172
  const raw = out.stdout.trim();
4978
5173
  if (out.exitCode !== 0 || !raw) return null;
4979
- return isAbsolute3(raw) ? raw : join22(worktree, raw);
5174
+ return isAbsolute3(raw) ? raw : join23(worktree, raw);
4980
5175
  }
4981
5176
  async function ensureWorktreeHygiene(worktree) {
4982
5177
  for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
@@ -4986,12 +5181,12 @@ async function installGuardHooks(worktree) {
4986
5181
  try {
4987
5182
  const gitDir = await gitPath(worktree, "--git-dir");
4988
5183
  if (!gitDir) return false;
4989
- const hooksDir = join22(gitDir, "swarm-hooks");
5184
+ const hooksDir = join23(gitDir, "swarm-hooks");
4990
5185
  const prev = await previousHooksPath(worktree);
4991
5186
  await mkdir(hooksDir, { recursive: true });
4992
5187
  for (const hook of GUARD_HOOKS) {
4993
- await writeFile(join22(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
4994
- await chmod(join22(hooksDir, hook), 493);
5188
+ await writeFile(join23(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
5189
+ await chmod(join23(hooksDir, hook), 493);
4995
5190
  }
4996
5191
  await $2`git -C ${worktree} config extensions.worktreeConfig true`;
4997
5192
  await $2`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
@@ -5010,7 +5205,7 @@ async function previousHooksPath(worktree) {
5010
5205
  if (out.exitCode === 0 && value) return value;
5011
5206
  }
5012
5207
  const commonDir = await gitPath(worktree, "--git-common-dir");
5013
- return commonDir ? join22(commonDir, "hooks") : null;
5208
+ return commonDir ? join23(commonDir, "hooks") : null;
5014
5209
  }
5015
5210
  async function removeWorktree(repo, path) {
5016
5211
  const branch = (await $2({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
@@ -5035,7 +5230,7 @@ async function worktreeDirty(path) {
5035
5230
  async function repairMovedWorktrees(targetDir) {
5036
5231
  const subdirs = (dir) => {
5037
5232
  try {
5038
- return readdirSync13(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join22(dir, d.name));
5233
+ return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join23(dir, d.name));
5039
5234
  } catch {
5040
5235
  return [];
5041
5236
  }
@@ -5172,18 +5367,18 @@ __export(droneChannel_exports, {
5172
5367
  verifyLocalCliToken: () => verifyLocalCliToken
5173
5368
  });
5174
5369
  import { createHmac, randomBytes, timingSafeEqual } from "crypto";
5175
- import { chmodSync as chmodSync2, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync13 } from "fs";
5370
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "fs";
5176
5371
  import { dirname as dirname5 } from "path";
5177
5372
  import { serve } from "@hono/node-server";
5178
5373
  function loadChannelSecret(path) {
5179
5374
  try {
5180
- const s = readFileSync20(path, "utf8").trim();
5375
+ const s = readFileSync21(path, "utf8").trim();
5181
5376
  if (s.length >= 32) return s;
5182
5377
  } catch {
5183
5378
  }
5184
5379
  const secret = randomBytes(32).toString("hex");
5185
- mkdirSync11(dirname5(path), { recursive: true });
5186
- writeFileSync13(path, secret, { mode: 384 });
5380
+ mkdirSync12(dirname5(path), { recursive: true });
5381
+ writeFileSync14(path, secret, { mode: 384 });
5187
5382
  try {
5188
5383
  chmodSync2(path, 384);
5189
5384
  } catch {
@@ -5573,7 +5768,7 @@ var init_droneChannel = __esm({
5573
5768
 
5574
5769
  // src/attachments.ts
5575
5770
  import { mkdir as mkdir3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
5576
- import { join as join27 } from "path";
5771
+ import { join as join28 } from "path";
5577
5772
  function attachmentsFromDoc(doc, origin) {
5578
5773
  const out = [];
5579
5774
  const walk2 = (node) => {
@@ -5664,7 +5859,7 @@ async function materializeAttachments(opts) {
5664
5859
  };
5665
5860
  const result = { files: [], skipped: [] };
5666
5861
  if (opts.refs.length === 0) return result;
5667
- const dir = join27(opts.worktree, ATTACHMENTS_DIR);
5862
+ const dir = join28(opts.worktree, ATTACHMENTS_DIR);
5668
5863
  await io.removeDir(dir);
5669
5864
  let dirReady = false;
5670
5865
  let total = 0;
@@ -5710,7 +5905,7 @@ async function materializeAttachments(opts) {
5710
5905
  await io.mkdir(dir);
5711
5906
  dirReady = true;
5712
5907
  }
5713
- await io.writeFile(join27(dir, name), file.bytes);
5908
+ await io.writeFile(join28(dir, name), file.bytes);
5714
5909
  } catch (e) {
5715
5910
  result.skipped.push(`${label2} \u2014 \u043D\u0435 \u0437\u0430\u043F\u0438\u0441\u0430\u043B\u043E\u0441\u044C \u043D\u0430 \u0434\u0438\u0441\u043A (${errText2(e)})`);
5716
5911
  continue;
@@ -5863,7 +6058,7 @@ var init_attachments = __esm({
5863
6058
 
5864
6059
  // src/shotUpload.ts
5865
6060
  import { readFile as fsReadFile } from "fs/promises";
5866
- import { basename as basename4, isAbsolute as isAbsolute4, join as join28 } from "path";
6061
+ import { basename as basename4, isAbsolute as isAbsolute4, join as join29 } from "path";
5867
6062
  function shotMimetype(path) {
5868
6063
  const dot = path.lastIndexOf(".");
5869
6064
  if (dot < 0) return null;
@@ -5889,7 +6084,7 @@ async function readShots(paths, opts) {
5889
6084
  }
5890
6085
  let bytes;
5891
6086
  try {
5892
- bytes = await read(isAbsolute4(path) ? path : join28(opts.worktree, path));
6087
+ bytes = await read(isAbsolute4(path) ? path : join29(opts.worktree, path));
5893
6088
  } catch (e) {
5894
6089
  skipped.push({ path, reason: `\u043D\u0435 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D: ${e instanceof Error ? e.message : String(e)}` });
5895
6090
  continue;
@@ -5970,8 +6165,8 @@ var init_shotUpload = __esm({
5970
6165
 
5971
6166
  // src/oauth.ts
5972
6167
  import { createHash as createHash3, randomBytes as randomBytes2 } from "crypto";
5973
- import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, unlinkSync as unlinkSync4 } from "fs";
5974
- import { join as join29 } from "path";
6168
+ import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, unlinkSync as unlinkSync4 } from "fs";
6169
+ import { join as join30 } from "path";
5975
6170
  function makePkce() {
5976
6171
  const verifier = randomBytes2(48).toString("base64url");
5977
6172
  const challenge = createHash3("sha256").update(verifier).digest("base64url");
@@ -6055,13 +6250,13 @@ function toStore(clientId, t, now) {
6055
6250
  }
6056
6251
  function loadStore() {
6057
6252
  try {
6058
- return JSON.parse(readFileSync21(STORE_PATH2, "utf8"));
6253
+ return JSON.parse(readFileSync22(STORE_PATH2, "utf8"));
6059
6254
  } catch {
6060
6255
  return null;
6061
6256
  }
6062
6257
  }
6063
6258
  function saveStore(s) {
6064
- writeFileSync14(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
6259
+ writeFileSync15(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
6065
6260
  }
6066
6261
  function clearStore() {
6067
6262
  try {
@@ -6071,7 +6266,7 @@ function clearStore() {
6071
6266
  }
6072
6267
  function loadClientId() {
6073
6268
  try {
6074
- return JSON.parse(readFileSync21(CLIENT_PATH, "utf8")).clientId;
6269
+ return JSON.parse(readFileSync22(CLIENT_PATH, "utf8")).clientId;
6075
6270
  } catch {
6076
6271
  return null;
6077
6272
  }
@@ -6080,7 +6275,7 @@ async function ensureClientId(api, redirectUri, fetchFn = fetch) {
6080
6275
  const existing = loadClientId();
6081
6276
  if (existing) return existing;
6082
6277
  const clientId = await registerClient({ api, redirectUri }, fetchFn);
6083
- writeFileSync14(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
6278
+ writeFileSync15(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
6084
6279
  return clientId;
6085
6280
  }
6086
6281
  async function ensureAccess(store, opts = {}) {
@@ -6106,8 +6301,8 @@ var init_oauth = __esm({
6106
6301
  AUTHORIZE = "/api/oauth/authorize";
6107
6302
  TOKEN = "/api/oauth/token";
6108
6303
  SCOPE = "openid profile email taskless:full";
6109
- STORE_PATH2 = join29(SWARM_HOME, "oauth.json");
6110
- CLIENT_PATH = join29(SWARM_HOME, "oauth-client.json");
6304
+ STORE_PATH2 = join30(SWARM_HOME, "oauth.json");
6305
+ CLIENT_PATH = join30(SWARM_HOME, "oauth-client.json");
6111
6306
  base2 = (api) => api.replace(/\/$/, "");
6112
6307
  }
6113
6308
  });
@@ -6194,11 +6389,11 @@ var init_authState = __esm({
6194
6389
  });
6195
6390
 
6196
6391
  // src/workspace.ts
6197
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, unlinkSync as unlinkSync5 } from "fs";
6198
- import { join as join30 } from "path";
6392
+ import { readFileSync as readFileSync23, writeFileSync as writeFileSync16, unlinkSync as unlinkSync5 } from "fs";
6393
+ import { join as join31 } from "path";
6199
6394
  function loadWorkspace() {
6200
6395
  try {
6201
- const w = JSON.parse(readFileSync22(WORKSPACE_PATH, "utf8"));
6396
+ const w = JSON.parse(readFileSync23(WORKSPACE_PATH, "utf8"));
6202
6397
  return w && typeof w.id === "string" && w.id ? w : null;
6203
6398
  } catch {
6204
6399
  return null;
@@ -6212,7 +6407,7 @@ var init_workspace = __esm({
6212
6407
  "src/workspace.ts"() {
6213
6408
  "use strict";
6214
6409
  init_config();
6215
- WORKSPACE_PATH = join30(SWARM_HOME, "workspace.json");
6410
+ WORKSPACE_PATH = join31(SWARM_HOME, "workspace.json");
6216
6411
  }
6217
6412
  });
6218
6413
 
@@ -6852,7 +7047,7 @@ __export(db_exports, {
6852
7047
  });
6853
7048
  import { createRequire as createRequire2 } from "module";
6854
7049
  import { randomUUID as randomUUID3 } from "crypto";
6855
- import { existsSync as existsSync17 } from "fs";
7050
+ import { existsSync as existsSync18 } from "fs";
6856
7051
  import { resolve as resolve4 } from "path";
6857
7052
  function rowToQuestion(row) {
6858
7053
  return {
@@ -7516,7 +7711,7 @@ CREATE TABLE IF NOT EXISTS imports (
7516
7711
  const repoN = normalizeRepo(repo);
7517
7712
  const already = this.db.prepare("SELECT run_count FROM imports WHERE source = ?").get(abs);
7518
7713
  if (already) return { imported: false, runs: already.run_count };
7519
- if (!existsSync17(abs)) throw new Error(`import-db: \u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442: ${abs}`);
7714
+ if (!existsSync18(abs)) throw new Error(`import-db: \u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442: ${abs}`);
7520
7715
  const src = new this.databaseCtor(abs);
7521
7716
  try {
7522
7717
  const runs = src.prepare("SELECT * FROM runs ORDER BY id").all();
@@ -7886,8 +8081,8 @@ var init_droneStore = __esm({
7886
8081
 
7887
8082
  // src/overmind.ts
7888
8083
  import { homedir as homedir7 } from "os";
7889
- import { existsSync as existsSync22, readFileSync as readFileSync26, readdirSync as readdirSync15, renameSync as renameSync12, statSync as statSync14 } from "fs";
7890
- import { basename as basename6, dirname as dirname6, join as join37 } from "path";
8084
+ import { existsSync as existsSync23, readFileSync as readFileSync27, readdirSync as readdirSync16, renameSync as renameSync12, statSync as statSync15 } from "fs";
8085
+ import { basename as basename6, dirname as dirname6, join as join38 } from "path";
7891
8086
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
7892
8087
  import { spawn as spawn4 } from "child_process";
7893
8088
 
@@ -7967,7 +8162,7 @@ init_config();
7967
8162
  init_resources();
7968
8163
  init_names2();
7969
8164
  init_storm();
7970
- import { appendFileSync, existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "fs";
8165
+ import { appendFileSync, existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "fs";
7971
8166
  import { dirname as dirname2 } from "path";
7972
8167
  import { randomUUID } from "crypto";
7973
8168
 
@@ -8026,12 +8221,12 @@ init_store();
8026
8221
  init_toolFailure();
8027
8222
 
8028
8223
  // src/logTail.ts
8029
- import { closeSync, existsSync as existsSync7, openSync, readSync, readdirSync as readdirSync7, statSync as statSync6 } from "fs";
8030
- import { join as join11 } from "path";
8224
+ import { closeSync, existsSync as existsSync8, openSync, readSync, readdirSync as readdirSync8, statSync as statSync7 } from "fs";
8225
+ import { join as join12 } from "path";
8031
8226
 
8032
8227
  // src/runLogDir.ts
8033
- import { existsSync as existsSync6, mkdirSync as mkdirSync6, readdirSync as readdirSync6, renameSync as renameSync3, statSync as statSync5 } from "fs";
8034
- import { join as join10 } from "path";
8228
+ import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync7, renameSync as renameSync3, statSync as statSync6 } from "fs";
8229
+ import { join as join11 } from "path";
8035
8230
  var LEGACY_RUN_LOGS_SUBDIR = "legacy";
8036
8231
  function runLogDirName(runLogKey) {
8037
8232
  const safe2 = runLogKey.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^[-_]+|[-_]+$/g, "");
@@ -8039,12 +8234,12 @@ function runLogDirName(runLogKey) {
8039
8234
  return /^\d+$/.test(safe2) ? `k-${safe2}` : safe2;
8040
8235
  }
8041
8236
  function runLogDirPath(runLogsDir, runLogKey) {
8042
- return join10(runLogsDir, runLogDirName(runLogKey));
8237
+ return join11(runLogsDir, runLogDirName(runLogKey));
8043
8238
  }
8044
8239
  function findRunLogDir(runLogsDir, keys) {
8045
8240
  for (const key of keys) {
8046
8241
  const dir = runLogDirPath(runLogsDir, key);
8047
- if (existsSync6(dir)) return dir;
8242
+ if (existsSync7(dir)) return dir;
8048
8243
  }
8049
8244
  return null;
8050
8245
  }
@@ -8054,10 +8249,10 @@ function runLogDirForWrite(runLogsDir, keys) {
8054
8249
  return findRunLogDir(runLogsDir, keys) ?? runLogDirPath(runLogsDir, canonical);
8055
8250
  }
8056
8251
  function sweepLegacyRunLogs(runLogsDir) {
8057
- const legacyDir = join10(runLogsDir, LEGACY_RUN_LOGS_SUBDIR);
8252
+ const legacyDir = join11(runLogsDir, LEGACY_RUN_LOGS_SUBDIR);
8058
8253
  let entries;
8059
8254
  try {
8060
- entries = readdirSync6(runLogsDir);
8255
+ entries = readdirSync7(runLogsDir);
8061
8256
  } catch {
8062
8257
  return { moved: 0, failed: 0, legacyDir };
8063
8258
  }
@@ -8065,12 +8260,12 @@ function sweepLegacyRunLogs(runLogsDir) {
8065
8260
  let failed = 0;
8066
8261
  for (const name of entries) {
8067
8262
  if (!/^\d+$/.test(name)) continue;
8068
- const from = join10(runLogsDir, name);
8263
+ const from = join11(runLogsDir, name);
8069
8264
  try {
8070
- if (!statSync5(from).isDirectory()) continue;
8071
- mkdirSync6(legacyDir, { recursive: true });
8072
- let to = join10(legacyDir, name);
8073
- for (let n = 2; existsSync6(to) && n < 100; n++) to = join10(legacyDir, `${name}-${n}`);
8265
+ if (!statSync6(from).isDirectory()) continue;
8266
+ mkdirSync7(legacyDir, { recursive: true });
8267
+ let to = join11(legacyDir, name);
8268
+ for (let n = 2; existsSync7(to) && n < 100; n++) to = join11(legacyDir, `${name}-${n}`);
8074
8269
  renameSync3(from, to);
8075
8270
  moved++;
8076
8271
  } catch {
@@ -8090,7 +8285,7 @@ function fileHeader(name, size, shown) {
8090
8285
  function readTail(path, opts) {
8091
8286
  let size;
8092
8287
  try {
8093
- size = statSync6(path).size;
8288
+ size = statSync7(path).size;
8094
8289
  } catch {
8095
8290
  return null;
8096
8291
  }
@@ -8125,7 +8320,7 @@ function latestRunLaunch(runLogsDir, runLogKeys) {
8125
8320
  if (!dir) return null;
8126
8321
  let files;
8127
8322
  try {
8128
- files = readdirSync7(dir);
8323
+ files = readdirSync8(dir);
8129
8324
  } catch {
8130
8325
  return null;
8131
8326
  }
@@ -8136,8 +8331,8 @@ function latestRunLaunch(runLogsDir, runLogKeys) {
8136
8331
  }
8137
8332
  if (indexes.size === 0) return null;
8138
8333
  const index = Math.max(...indexes);
8139
- const out = [join11(dir, `${index}.json`), join11(dir, `${index}.json.done`)].find((p) => existsSync7(p)) ?? null;
8140
- const err = existsSync7(join11(dir, `${index}.err.log`)) ? join11(dir, `${index}.err.log`) : null;
8334
+ const out = [join12(dir, `${index}.json`), join12(dir, `${index}.json.done`)].find((p) => existsSync8(p)) ?? null;
8335
+ const err = existsSync8(join12(dir, `${index}.err.log`)) ? join12(dir, `${index}.err.log`) : null;
8141
8336
  return { index, total: indexes.size, out, err };
8142
8337
  }
8143
8338
  function runLogTail(runLogsDir, runLogKeys, opts) {
@@ -8418,26 +8613,26 @@ var SwarmClient = class _SwarmClient {
8418
8613
  this.repoFullNames = registry.map((e) => e.repoFullName);
8419
8614
  this.repoPathByFullName = new Map(registry.map((e) => [e.repoFullName, normalizeRepo(e.path)]));
8420
8615
  this.host = opts.host ?? null;
8421
- this.repoExists = opts.repoExists ?? existsSync8;
8616
+ this.repoExists = opts.repoExists ?? existsSync9;
8422
8617
  this.questionSyncMs = opts.questionSyncMs ?? 3e3;
8423
8618
  this.executorId = opts.executorId ?? EXECUTOR.id;
8424
8619
  this.outboxPath = opts.outboxPath;
8425
8620
  this.mapPath = `${opts.outboxPath}.prodmap.json`;
8426
8621
  this.stormPath = `${opts.outboxPath}.storm.jsonl`;
8427
- mkdirSync7(dirname2(this.outboxPath), { recursive: true });
8622
+ mkdirSync8(dirname2(this.outboxPath), { recursive: true });
8428
8623
  this.recover();
8429
8624
  }
8430
8625
  // ── рестарт: поднять outbox (незаписанные операции) и карту runKey→prodId ─────
8431
8626
  recover() {
8432
- if (existsSync8(this.mapPath)) {
8627
+ if (existsSync9(this.mapPath)) {
8433
8628
  try {
8434
- const obj = JSON.parse(readFileSync7(this.mapPath, "utf8"));
8629
+ const obj = JSON.parse(readFileSync8(this.mapPath, "utf8"));
8435
8630
  for (const [k, v] of Object.entries(obj)) this.prodIdByKey.set(k, v);
8436
8631
  } catch {
8437
8632
  }
8438
8633
  }
8439
- if (existsSync8(this.outboxPath)) {
8440
- const txt = readFileSync7(this.outboxPath, "utf8");
8634
+ if (existsSync9(this.outboxPath)) {
8635
+ const txt = readFileSync8(this.outboxPath, "utf8");
8441
8636
  for (const line of txt.split("\n")) {
8442
8637
  const s = line.trim();
8443
8638
  if (!s) continue;
@@ -8457,10 +8652,10 @@ var SwarmClient = class _SwarmClient {
8457
8652
  // eventsLog ПЕРВЫМИ (до hydrate), в порядке файла (= хронологический); id
8458
8653
  // переприсваиваем локально (id событий — только порядок, не корреляция с продом).
8459
8654
  replayGlobalEvents() {
8460
- if (!existsSync8(this.stormPath)) return;
8655
+ if (!existsSync9(this.stormPath)) return;
8461
8656
  let txt;
8462
8657
  try {
8463
- txt = readFileSync7(this.stormPath, "utf8");
8658
+ txt = readFileSync8(this.stormPath, "utf8");
8464
8659
  } catch {
8465
8660
  return;
8466
8661
  }
@@ -9457,7 +9652,7 @@ var SwarmClient = class _SwarmClient {
9457
9652
  * транзиентным сбоем ОС, который этот PR должен переживать, а не превращать в мор.
9458
9653
  */
9459
9654
  reconcileRuntime(opts) {
9460
- const wtExists = opts.worktreeExists ?? existsSync8;
9655
+ const wtExists = opts.worktreeExists ?? existsSync9;
9461
9656
  const pidByWorktree = /* @__PURE__ */ new Map();
9462
9657
  try {
9463
9658
  for (const p of opts.listProcesses()) if (p.worktree) pidByWorktree.set(p.worktree, p.pid);
@@ -10725,13 +10920,13 @@ var SwarmClient = class _SwarmClient {
10725
10920
  }
10726
10921
  persistPending() {
10727
10922
  try {
10728
- writeFileSync7(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
10923
+ writeFileSync8(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
10729
10924
  } catch {
10730
10925
  }
10731
10926
  }
10732
10927
  persistMap() {
10733
10928
  try {
10734
- writeFileSync7(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
10929
+ writeFileSync8(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
10735
10930
  } catch {
10736
10931
  }
10737
10932
  }
@@ -10833,20 +11028,20 @@ function slowPassLine(seq, done, thresholdMs = SLOW_PASS_MS) {
10833
11028
  }
10834
11029
 
10835
11030
  // src/logRotate.ts
10836
- import { copyFileSync as copyFileSync4, renameSync as renameSync5, statSync as statSync7, fstatSync, truncateSync, unlinkSync as unlinkSync3, existsSync as existsSync9, openSync as openSync2, writeSync, closeSync as closeSync2 } from "fs";
11031
+ import { copyFileSync as copyFileSync5, renameSync as renameSync5, statSync as statSync8, fstatSync, truncateSync, unlinkSync as unlinkSync3, existsSync as existsSync10, openSync as openSync2, writeSync, closeSync as closeSync2 } from "fs";
10837
11032
  var realIo = {
10838
11033
  size: (path) => {
10839
11034
  try {
10840
- return statSync7(path).size;
11035
+ return statSync8(path).size;
10841
11036
  } catch {
10842
11037
  return null;
10843
11038
  }
10844
11039
  },
10845
- copy: copyFileSync4,
11040
+ copy: copyFileSync5,
10846
11041
  rename: renameSync5,
10847
11042
  truncate: (path) => truncateSync(path, 0),
10848
11043
  unlink: unlinkSync3,
10849
- exists: existsSync9
11044
+ exists: existsSync10
10850
11045
  };
10851
11046
  var realOwnerIo = {
10852
11047
  statFd: (fd) => {
@@ -10859,7 +11054,7 @@ var realOwnerIo = {
10859
11054
  },
10860
11055
  statPath: (path) => {
10861
11056
  try {
10862
- const s = statSync7(path);
11057
+ const s = statSync8(path);
10863
11058
  return { dev: s.dev, ino: s.ino };
10864
11059
  } catch {
10865
11060
  return null;
@@ -10895,7 +11090,7 @@ function rotateDaemonLog(path, opts, io = realIo) {
10895
11090
  var teedTo = null;
10896
11091
 
10897
11092
  // src/daemonLaunch.ts
10898
- import { openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync9 } from "fs";
11093
+ import { openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync10 } from "fs";
10899
11094
  import { spawn } from "child_process";
10900
11095
  var realRespawnIo = {
10901
11096
  isTty: () => process.stdout.isTTY === true,
@@ -10995,13 +11190,13 @@ async function buildRepoRegistry(paths) {
10995
11190
  }
10996
11191
 
10997
11192
  // src/repoMemory.ts
10998
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
10999
- import { join as join12 } from "path";
11193
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
11194
+ import { join as join13 } from "path";
11000
11195
  var FILE = "repos.json";
11001
11196
  function loadRememberedRepos(home) {
11002
11197
  let raw;
11003
11198
  try {
11004
- raw = readFileSync10(join12(home, FILE), "utf8");
11199
+ raw = readFileSync11(join13(home, FILE), "utf8");
11005
11200
  } catch {
11006
11201
  return [];
11007
11202
  }
@@ -11016,7 +11211,7 @@ function loadRememberedRepos(home) {
11016
11211
  function rememberRepos(home, paths, now = () => /* @__PURE__ */ new Date()) {
11017
11212
  const clean = paths.filter((p) => p.trim().length > 0);
11018
11213
  if (clean.length === 0) return;
11019
- writeFileSync9(join12(home, FILE), `${JSON.stringify({ paths: clean, at: now().toISOString() }, null, 2)}
11214
+ writeFileSync10(join13(home, FILE), `${JSON.stringify({ paths: clean, at: now().toISOString() }, null, 2)}
11020
11215
  `);
11021
11216
  }
11022
11217
  function pickRepoPaths(args) {
@@ -11031,12 +11226,12 @@ init_src();
11031
11226
  init_config();
11032
11227
  init_linkFailure();
11033
11228
  import { homedir as homedir5 } from "os";
11034
- import { readFileSync as readFileSync12, renameSync as renameSync6, writeFileSync as writeFileSync10 } from "fs";
11035
- import { isAbsolute, join as join14, resolve as resolve2 } from "path";
11229
+ import { readFileSync as readFileSync13, renameSync as renameSync6, writeFileSync as writeFileSync11 } from "fs";
11230
+ import { isAbsolute, join as join15, resolve as resolve2 } from "path";
11036
11231
 
11037
11232
  // src/repoScan.ts
11038
- import { readdirSync as readdirSync8, readFileSync as readFileSync11, statSync as statSync8 } from "fs";
11039
- import { join as join13 } from "path";
11233
+ import { readdirSync as readdirSync9, readFileSync as readFileSync12, statSync as statSync9 } from "fs";
11234
+ import { join as join14 } from "path";
11040
11235
  var SKIP = /* @__PURE__ */ new Set([
11041
11236
  "node_modules",
11042
11237
  "vendor",
@@ -11066,7 +11261,7 @@ function parseOriginFromGitConfig(text) {
11066
11261
  }
11067
11262
  function originOf(dir) {
11068
11263
  try {
11069
- return parseOriginFromGitConfig(readFileSync11(join13(dir, ".git", "config"), "utf8"));
11264
+ return parseOriginFromGitConfig(readFileSync12(join14(dir, ".git", "config"), "utf8"));
11070
11265
  } catch {
11071
11266
  return null;
11072
11267
  }
@@ -11095,15 +11290,15 @@ function walk(dir, depth, maxDepth, found) {
11095
11290
  }
11096
11291
  let entries;
11097
11292
  try {
11098
- entries = readdirSync8(dir);
11293
+ entries = readdirSync9(dir);
11099
11294
  } catch {
11100
11295
  return;
11101
11296
  }
11102
11297
  for (const name of entries) {
11103
11298
  if (name.startsWith(".") || SKIP.has(name)) continue;
11104
- const child = join13(dir, name);
11299
+ const child = join14(dir, name);
11105
11300
  try {
11106
- if (!statSync8(child).isDirectory()) continue;
11301
+ if (!statSync9(child).isDirectory()) continue;
11107
11302
  } catch {
11108
11303
  continue;
11109
11304
  }
@@ -11123,7 +11318,7 @@ function defaultScanRoots(home, knownPaths = []) {
11123
11318
  if (parent && parent !== p) add(parent);
11124
11319
  }
11125
11320
  for (const name of ["projects", "code", "src", "dev", "work", "repos", "git", "Projects", "Code", "Developer", "Documents/GitHub", "go/src"]) {
11126
- add(join13(home, name));
11321
+ add(join14(home, name));
11127
11322
  }
11128
11323
  return out;
11129
11324
  }
@@ -11137,7 +11332,7 @@ function resolveScanRoots(raw, home = homedir5(), knownPaths = []) {
11137
11332
  for (const part of v.split(",")) {
11138
11333
  const p = part.trim();
11139
11334
  if (!p) continue;
11140
- const abs = p === "~" ? home : p.startsWith("~/") ? join14(home, p.slice(2)) : isAbsolute(p) ? p : resolve2(home, p);
11335
+ const abs = p === "~" ? home : p.startsWith("~/") ? join15(home, p.slice(2)) : isAbsolute(p) ? p : resolve2(home, p);
11141
11336
  if (!out.includes(abs)) out.push(abs);
11142
11337
  }
11143
11338
  return out;
@@ -11351,7 +11546,7 @@ function repoMapRows(state) {
11351
11546
  }
11352
11547
  function loadRepoMapCache(path) {
11353
11548
  try {
11354
- const raw = JSON.parse(readFileSync12(path, "utf8"));
11549
+ const raw = JSON.parse(readFileSync13(path, "utf8"));
11355
11550
  if (!Array.isArray(raw?.entries)) return { scannedAt: null, entries: [] };
11356
11551
  return {
11357
11552
  scannedAt: typeof raw.scannedAt === "string" && raw.scannedAt ? raw.scannedAt : null,
@@ -11366,7 +11561,7 @@ function loadRepoMapCache(path) {
11366
11561
  function writeRepoMapCache(path, entries, scannedAt = stamp()) {
11367
11562
  try {
11368
11563
  const tmp = `${path}.tmp`;
11369
- writeFileSync10(tmp, JSON.stringify({ at: stamp(), scannedAt, entries }, null, 2));
11564
+ writeFileSync11(tmp, JSON.stringify({ at: stamp(), scannedAt, entries }, null, 2));
11370
11565
  renameSync6(tmp, path);
11371
11566
  } catch {
11372
11567
  }
@@ -11374,17 +11569,17 @@ function writeRepoMapCache(path, entries, scannedAt = stamp()) {
11374
11569
 
11375
11570
  // src/hostIdentity.ts
11376
11571
  import { hostname } from "os";
11377
- import { existsSync as existsSync10, readFileSync as readFileSync13, renameSync as renameSync7, writeFileSync as writeFileSync11 } from "fs";
11378
- import { join as join15 } from "path";
11572
+ import { existsSync as existsSync11, readFileSync as readFileSync14, renameSync as renameSync7, writeFileSync as writeFileSync12 } from "fs";
11573
+ import { join as join16 } from "path";
11379
11574
  import { randomUUID as randomUUID2 } from "crypto";
11380
11575
  function hostIdentityPath(home) {
11381
- return join15(home, "host.json");
11576
+ return join16(home, "host.json");
11382
11577
  }
11383
11578
  function loadHostIdentity(deps) {
11384
- const exists = deps.exists ?? existsSync10;
11385
- const readFile2 = deps.readFile ?? ((p) => readFileSync13(p, "utf8"));
11579
+ const exists = deps.exists ?? existsSync11;
11580
+ const readFile2 = deps.readFile ?? ((p) => readFileSync14(p, "utf8"));
11386
11581
  const writeFile4 = deps.writeFile ?? ((p, data) => {
11387
- writeFileSync11(`${p}.tmp`, data);
11582
+ writeFileSync12(`${p}.tmp`, data);
11388
11583
  renameSync7(`${p}.tmp`, p);
11389
11584
  });
11390
11585
  const host = deps.hostname ?? hostname;
@@ -11477,8 +11672,8 @@ function pickResumeCandidate(pausedForRelief) {
11477
11672
  }
11478
11673
 
11479
11674
  // src/reliefLoop.ts
11480
- import { existsSync as existsSync11, readFileSync as readFileSync14, renameSync as renameSync8, writeFileSync as writeFileSync12 } from "fs";
11481
- import { join as join16 } from "path";
11675
+ import { existsSync as existsSync12, readFileSync as readFileSync15, renameSync as renameSync8, writeFileSync as writeFileSync13 } from "fs";
11676
+ import { join as join17 } from "path";
11482
11677
  var numEnv3 = (name, def) => {
11483
11678
  const v = Number(process.env[name]);
11484
11679
  return Number.isFinite(v) && v > 0 ? v : def;
@@ -11513,11 +11708,11 @@ function reliefLoopTripped(entry, cfg = DEFAULT_RELIEF_LOOP_CONFIG) {
11513
11708
  return !!entry && entry.pauses >= cfg.limit;
11514
11709
  }
11515
11710
  function reliefLoopStatePath(home) {
11516
- return join16(home, "relief-loop.json");
11711
+ return join17(home, "relief-loop.json");
11517
11712
  }
11518
11713
  function loadReliefLoopState(home, now = Date.now(), io = {}, cfg = DEFAULT_RELIEF_LOOP_CONFIG) {
11519
- const exists = io.exists ?? existsSync11;
11520
- const readFile2 = io.readFile ?? ((p) => readFileSync14(p, "utf8"));
11714
+ const exists = io.exists ?? existsSync12;
11715
+ const readFile2 = io.readFile ?? ((p) => readFileSync15(p, "utf8"));
11521
11716
  const path = reliefLoopStatePath(home);
11522
11717
  if (!exists(path)) return {};
11523
11718
  try {
@@ -11539,7 +11734,7 @@ function loadReliefLoopState(home, now = Date.now(), io = {}, cfg = DEFAULT_RELI
11539
11734
  function saveReliefLoopState(home, state, io = {}) {
11540
11735
  const path = reliefLoopStatePath(home);
11541
11736
  const writeFile4 = io.writeFile ?? ((p, data) => {
11542
- writeFileSync12(`${p}.tmp`, data);
11737
+ writeFileSync13(`${p}.tmp`, data);
11543
11738
  renameSync8(`${p}.tmp`, p);
11544
11739
  });
11545
11740
  writeFile4(path, JSON.stringify(state, null, 2));
@@ -11701,15 +11896,15 @@ function buildReliefCostCandidates(cost, t, sustainMs, build) {
11701
11896
 
11702
11897
  // src/launcher.ts
11703
11898
  import { spawn as spawn2 } from "child_process";
11704
- import { closeSync as closeSync4, existsSync as existsSync12, mkdirSync as mkdirSync9, openSync as openSync4, readdirSync as readdirSync10 } from "fs";
11899
+ import { closeSync as closeSync4, existsSync as existsSync13, mkdirSync as mkdirSync10, openSync as openSync4, readdirSync as readdirSync11 } from "fs";
11705
11900
  import { createRequire } from "module";
11706
11901
  import { homedir as homedir6 } from "os";
11707
- import { dirname as dirname3, join as join18 } from "path";
11902
+ import { dirname as dirname3, join as join19 } from "path";
11708
11903
  import { fileURLToPath as fileURLToPath2 } from "url";
11709
11904
 
11710
11905
  // src/droneHome.ts
11711
- import { lstatSync, mkdirSync as mkdirSync8, readdirSync as readdirSync9, rmSync, statSync as statSync9, symlinkSync as symlinkSync3 } from "fs";
11712
- import { join as join17, relative, sep } from "path";
11906
+ import { lstatSync, mkdirSync as mkdirSync9, readdirSync as readdirSync10, rmSync, statSync as statSync10, symlinkSync as symlinkSync4 } from "fs";
11907
+ import { join as join18, relative, sep } from "path";
11713
11908
  var DRONE_HOME_DENY_DEFAULT = [".taskless-swarm", ".bash_history", ".zsh_history"];
11714
11909
  function droneHomeDeny(env = process.env) {
11715
11910
  const extra = (env.SWARM_DRONE_HOME_DENY || "").split(",").map((s) => s.trim()).filter(Boolean);
@@ -11727,34 +11922,34 @@ function buildDroneHome(opts) {
11727
11922
  const { realHome, droneHome } = opts;
11728
11923
  const deny = opts.deny ?? droneHomeDeny();
11729
11924
  const platform = opts.platform ?? process.platform;
11730
- mkdirSync8(droneHome, { recursive: true, mode: 448 });
11731
- const wanted = new Set(mirroredEntries(readdirSync9(realHome), deny, platform));
11925
+ mkdirSync9(droneHome, { recursive: true, mode: 448 });
11926
+ const wanted = new Set(mirroredEntries(readdirSync10(realHome), deny, platform));
11732
11927
  const rel = relative(realHome, droneHome);
11733
11928
  if (rel && !rel.startsWith("..") && !rel.includes(sep)) wanted.delete(rel);
11734
- for (const existing of readdirSync9(droneHome)) {
11929
+ for (const existing of readdirSync10(droneHome)) {
11735
11930
  if (wanted.has(existing)) continue;
11736
- const p = join17(droneHome, existing);
11931
+ const p = join18(droneHome, existing);
11737
11932
  try {
11738
11933
  if (lstatSync(p).isSymbolicLink()) rmSync(p);
11739
11934
  } catch {
11740
11935
  }
11741
11936
  }
11742
11937
  for (const name of wanted) {
11743
- const link2 = join17(droneHome, name);
11938
+ const link2 = join18(droneHome, name);
11744
11939
  try {
11745
11940
  lstatSync(link2);
11746
11941
  continue;
11747
11942
  } catch {
11748
11943
  }
11749
- const target = join17(realHome, name);
11944
+ const target = join18(realHome, name);
11750
11945
  let isDir;
11751
11946
  try {
11752
- isDir = statSync9(target).isDirectory();
11947
+ isDir = statSync10(target).isDirectory();
11753
11948
  } catch {
11754
11949
  continue;
11755
11950
  }
11756
11951
  try {
11757
- symlinkSync3(target, link2, isDir ? "junction" : "file");
11952
+ symlinkSync4(target, link2, isDir ? "junction" : "file");
11758
11953
  } catch (e) {
11759
11954
  if (e.code !== "EEXIST") throw e;
11760
11955
  }
@@ -11767,7 +11962,7 @@ var REAL_PATH_ENV_PINS = [
11767
11962
  { env: "YARN_GLOBAL_FOLDER", segments: [".yarn", "berry"] }
11768
11963
  ];
11769
11964
  function realPathEnvPins(realHome) {
11770
- return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join17(realHome, ...segments)]));
11965
+ return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join18(realHome, ...segments)]));
11771
11966
  }
11772
11967
  function dronePrivatePaths(realHome, swarmHome) {
11773
11968
  return [
@@ -11851,7 +12046,7 @@ function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
11851
12046
  const env = { ...base3 };
11852
12047
  const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
11853
12048
  if (isolate && !base3.TURBO_CACHE_DIR) {
11854
- env.TURBO_CACHE_DIR = join18(worktree, ".turbo", "cache");
12049
+ env.TURBO_CACHE_DIR = join19(worktree, ".turbo", "cache");
11855
12050
  }
11856
12051
  Object.assign(env, droneTestEnv(droneCap, base3));
11857
12052
  for (const key of DAEMON_STATE_ENV) delete env[key];
@@ -11882,21 +12077,21 @@ var DAEMON_STATE_ENV = [
11882
12077
  ...PROVIDER_TOKEN_ENV
11883
12078
  ];
11884
12079
  function bundledRoleDir(kind) {
11885
- return join18(dirname3(fileURLToPath2(import.meta.url)), "..", "roles", kind);
12080
+ return join19(dirname3(fileURLToPath2(import.meta.url)), "..", "roles", kind);
11886
12081
  }
11887
12082
  function roleDir(worktree, kind) {
11888
- return join18(worktree, ".claude", "roles", kind);
12083
+ return join19(worktree, ".claude", "roles", kind);
11889
12084
  }
11890
12085
  function roleDirs(worktree, kind) {
11891
- return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync12(dir));
12086
+ return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync13(dir));
11892
12087
  }
11893
12088
  function nextRunLogPath(runLogsDir, runLogKeys) {
11894
12089
  const dir = runLogDirForWrite(runLogsDir, runLogKeys);
11895
12090
  if (!dir) throw new Error("\u043D\u0435\u0447\u0435\u043C \u0430\u0434\u0440\u0435\u0441\u043E\u0432\u0430\u0442\u044C \u043A\u0430\u0442\u0430\u043B\u043E\u0433 run-log'\u043E\u0432: \u0443 \u043F\u0440\u043E\u0433\u043E\u043D\u0430 \u043D\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043B\u044C\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 (SwarmStore.runLogKeys)");
11896
- mkdirSync9(dir, { recursive: true });
12091
+ mkdirSync10(dir, { recursive: true });
11897
12092
  let files = [];
11898
12093
  try {
11899
- files = readdirSync10(dir);
12094
+ files = readdirSync11(dir);
11900
12095
  } catch {
11901
12096
  }
11902
12097
  let next = 0;
@@ -11904,7 +12099,7 @@ function nextRunLogPath(runLogsDir, runLogKeys) {
11904
12099
  const m = /^(\d+)\.json/.exec(f);
11905
12100
  if (m) next = Math.max(next, Number(m[1]) + 1);
11906
12101
  }
11907
- return join18(dir, `${next}.json`);
12102
+ return join19(dir, `${next}.json`);
11908
12103
  }
11909
12104
  function openNextRunLog(runLogsDir, runLogKeys) {
11910
12105
  for (let attempt = 0; attempt < 50; attempt++) {
@@ -11996,9 +12191,9 @@ function makeLauncher(cfg) {
11996
12191
  }
11997
12192
  const realHome = cfg.droneIsolation?.realHome ?? homedir6();
11998
12193
  const home = cfg.droneIsolation ? buildDroneHome({ realHome, droneHome: cfg.droneIsolation.home }) : void 0;
11999
- if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync12(join18(cfg.droneIsolation.swarmHome, "token"))) {
12194
+ if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync13(join19(cfg.droneIsolation.swarmHome, "token"))) {
12000
12195
  console.error(
12001
- `[launcher] TASKLESS_TOKEN \u0437\u0430\u0434\u0430\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 env \u0434\u0435\u043C\u043E\u043D\u0430 \u2014 \u0434\u0440\u043E\u043D\u0443 \u043E\u043D \u043D\u0435 \u043D\u0430\u0441\u043B\u0435\u0434\u0443\u0435\u0442\u0441\u044F (TASWM-289), \u0430 \u0444\u0430\u0439\u043B\u0430 ${join18(cfg.droneIsolation.swarmHome, "token")} \u043D\u0435\u0442. read_task \u0434\u0440\u043E\u043D\u0430 \u0431\u0443\u0434\u0435\u0442 slug-only. \u041F\u043E\u0447\u0438\u043D\u0438: \`swarm login\` (oauth.json) \u0438\u043B\u0438 \u043F\u043E\u043B\u043E\u0436\u0438 \u0442\u043E\u043A\u0435\u043D \u0432 \u044D\u0442\u043E\u0442 \u0444\u0430\u0439\u043B.`
12196
+ `[launcher] TASKLESS_TOKEN \u0437\u0430\u0434\u0430\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 env \u0434\u0435\u043C\u043E\u043D\u0430 \u2014 \u0434\u0440\u043E\u043D\u0443 \u043E\u043D \u043D\u0435 \u043D\u0430\u0441\u043B\u0435\u0434\u0443\u0435\u0442\u0441\u044F (TASWM-289), \u0430 \u0444\u0430\u0439\u043B\u0430 ${join19(cfg.droneIsolation.swarmHome, "token")} \u043D\u0435\u0442. read_task \u0434\u0440\u043E\u043D\u0430 \u0431\u0443\u0434\u0435\u0442 slug-only. \u041F\u043E\u0447\u0438\u043D\u0438: \`swarm login\` (oauth.json) \u0438\u043B\u0438 \u043F\u043E\u043B\u043E\u0436\u0438 \u0442\u043E\u043A\u0435\u043D \u0432 \u044D\u0442\u043E\u0442 \u0444\u0430\u0439\u043B.`
12002
12197
  );
12003
12198
  }
12004
12199
  const executor = cfg.executor ?? executorForRun(run2, cfg.swarmModels?.() ?? null);
@@ -12060,8 +12255,8 @@ function makeLauncher(cfg) {
12060
12255
  init_procCleanup();
12061
12256
 
12062
12257
  // src/cost.ts
12063
- import { readFileSync as readFileSync16, readdirSync as readdirSync11, renameSync as renameSync9, statSync as statSync10 } from "fs";
12064
- import { join as join19 } from "path";
12258
+ import { readFileSync as readFileSync17, readdirSync as readdirSync12, renameSync as renameSync9, statSync as statSync11 } from "fs";
12259
+ import { join as join20 } from "path";
12065
12260
  init_executors();
12066
12261
  init_swarmModels();
12067
12262
  var UNPROCESSED_LOG_RE = /^\d+\.json$/;
@@ -12069,7 +12264,7 @@ var SEGMENT_LOG_RE = /^(\d+)\.json(\.done)?$/;
12069
12264
  var RESCUE_OPEN_WINDOW_MAX_MS = 12 * 60 * 60 * 1e3;
12070
12265
  function unprocessedLogFiles(dir) {
12071
12266
  try {
12072
- return readdirSync11(dir).filter((f) => UNPROCESSED_LOG_RE.test(f));
12267
+ return readdirSync12(dir).filter((f) => UNPROCESSED_LOG_RE.test(f));
12073
12268
  } catch {
12074
12269
  return [];
12075
12270
  }
@@ -12078,7 +12273,7 @@ function segmentStarts(dir) {
12078
12273
  const starts = /* @__PURE__ */ new Map();
12079
12274
  let entries;
12080
12275
  try {
12081
- entries = readdirSync11(dir);
12276
+ entries = readdirSync12(dir);
12082
12277
  } catch {
12083
12278
  return starts;
12084
12279
  }
@@ -12086,7 +12281,7 @@ function segmentStarts(dir) {
12086
12281
  const m = SEGMENT_LOG_RE.exec(f);
12087
12282
  if (!m) continue;
12088
12283
  try {
12089
- const st = statSync10(join19(dir, f));
12284
+ const st = statSync11(join20(dir, f));
12090
12285
  starts.set(Number(m[1]), st.birthtimeMs > 0 ? st.birthtimeMs : st.ctimeMs);
12091
12286
  } catch {
12092
12287
  }
@@ -12139,10 +12334,10 @@ function accountRunCost(deps, run2) {
12139
12334
  let unmeasured = 0;
12140
12335
  const processed = [];
12141
12336
  for (const f of files) {
12142
- const full = join19(dir, f);
12337
+ const full = join20(dir, f);
12143
12338
  let raw = null;
12144
12339
  try {
12145
- raw = readFileSync16(full, "utf8");
12340
+ raw = readFileSync17(full, "utf8");
12146
12341
  } catch {
12147
12342
  continue;
12148
12343
  }
@@ -12196,8 +12391,8 @@ function makeCostSweeper(deps) {
12196
12391
  }
12197
12392
 
12198
12393
  // src/runOutcome.ts
12199
- import { readdirSync as readdirSync12, readFileSync as readFileSync17 } from "fs";
12200
- import { join as join20 } from "path";
12394
+ import { readdirSync as readdirSync13, readFileSync as readFileSync18 } from "fs";
12395
+ import { join as join21 } from "path";
12201
12396
  init_executors();
12202
12397
  function endedItself(outcome) {
12203
12398
  return outcome === "graceful" || outcome === "budget" || outcome === "aborted";
@@ -12211,7 +12406,7 @@ function readLatestResultRaw(runLogsDir, runLogKeys) {
12211
12406
  if (!dir) return null;
12212
12407
  let files;
12213
12408
  try {
12214
- files = readdirSync12(dir);
12409
+ files = readdirSync13(dir);
12215
12410
  } catch {
12216
12411
  return null;
12217
12412
  }
@@ -12224,7 +12419,7 @@ function readLatestResultRaw(runLogsDir, runLogKeys) {
12224
12419
  }
12225
12420
  if (!latest) return null;
12226
12421
  try {
12227
- return readFileSync17(join20(dir, latest.name), "utf8");
12422
+ return readFileSync18(join21(dir, latest.name), "utf8");
12228
12423
  } catch {
12229
12424
  return null;
12230
12425
  }
@@ -12261,7 +12456,7 @@ init_src();
12261
12456
  init_swarmModels();
12262
12457
  init_executors();
12263
12458
  import { accessSync, constants } from "fs";
12264
- import { delimiter, join as join21 } from "path";
12459
+ import { delimiter, join as join22 } from "path";
12265
12460
  function binRunnable(bin, env) {
12266
12461
  if (!bin) return false;
12267
12462
  if (bin.includes("/") || bin.includes("\\")) {
@@ -12277,7 +12472,7 @@ function binRunnable(bin, env) {
12277
12472
  if (!dir) continue;
12278
12473
  for (const ext of exts) {
12279
12474
  try {
12280
- accessSync(join21(dir, bin + ext), constants.X_OK);
12475
+ accessSync(join22(dir, bin + ext), constants.X_OK);
12281
12476
  return true;
12282
12477
  } catch {
12283
12478
  }
@@ -12324,20 +12519,20 @@ init_src();
12324
12519
  init_git();
12325
12520
 
12326
12521
  // src/deps.ts
12327
- import { existsSync as existsSync15, readdirSync as readdirSync14, readFileSync as readFileSync19 } from "fs";
12328
- import { join as join25 } from "path";
12522
+ import { existsSync as existsSync16, readdirSync as readdirSync15, readFileSync as readFileSync20 } from "fs";
12523
+ import { join as join26 } from "path";
12329
12524
  import { execa } from "execa";
12330
12525
 
12331
12526
  // src/prepareLock.ts
12332
12527
  import { createHash } from "crypto";
12333
- import { closeSync as closeSync5, openSync as openSync5, rmSync as rmSync2, statSync as statSync12, writeSync as writeSync2 } from "fs";
12334
- import { join as join23 } from "path";
12528
+ import { closeSync as closeSync5, openSync as openSync5, rmSync as rmSync2, statSync as statSync13, writeSync as writeSync2 } from "fs";
12529
+ import { join as join24 } from "path";
12335
12530
  import { tmpdir } from "os";
12336
12531
  var WAIT_TIMEOUT_MS = 5 * 6e4;
12337
12532
  var POLL_MS = 300;
12338
12533
  var STALE_MS = 20 * 6e4;
12339
12534
  function machineLockPath(key, dir = tmpdir()) {
12340
- return join23(dir, `swarm-prepare-${createHash("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
12535
+ return join24(dir, `swarm-prepare-${createHash("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
12341
12536
  }
12342
12537
  function defaultTryCreate(path, content) {
12343
12538
  try {
@@ -12354,7 +12549,7 @@ function defaultTryCreate(path, content) {
12354
12549
  }
12355
12550
  function defaultAgeMs(path) {
12356
12551
  try {
12357
- return Date.now() - statSync12(path).mtimeMs;
12552
+ return Date.now() - statSync13(path).mtimeMs;
12358
12553
  } catch {
12359
12554
  return null;
12360
12555
  }
@@ -12398,8 +12593,8 @@ init_config();
12398
12593
  init_config();
12399
12594
  import { createHash as createHash2 } from "crypto";
12400
12595
  import { cp, link, lstat, mkdir as mkdir2, readdir, readlink, rename as rename2, rm as rm2, stat, symlink, utimes, writeFile as writeFile2 } from "fs/promises";
12401
- import { existsSync as existsSync14, readFileSync as readFileSync18 } from "fs";
12402
- import { join as join24 } from "path";
12596
+ import { existsSync as existsSync15, readFileSync as readFileSync19 } from "fs";
12597
+ import { join as join25 } from "path";
12403
12598
  function fingerprint(parts) {
12404
12599
  const h = createHash2("sha256");
12405
12600
  for (const p of parts) {
@@ -12413,8 +12608,8 @@ async function cloneTree(src, dst) {
12413
12608
  const entries = await readdir(src, { withFileTypes: true });
12414
12609
  await Promise.all(
12415
12610
  entries.map(async (e) => {
12416
- const from = join24(src, e.name);
12417
- const to = join24(dst, e.name);
12611
+ const from = join25(src, e.name);
12612
+ const to = join25(dst, e.name);
12418
12613
  if (e.isDirectory()) return cloneTree(from, to);
12419
12614
  if (e.isSymbolicLink()) {
12420
12615
  return symlink(await readlink(from), to).catch(() => cp(from, to, { recursive: true, verbatimSymlinks: true }));
@@ -12427,11 +12622,11 @@ function cacheRoot(io) {
12427
12622
  return io.root ?? ENV_CACHE_DIR;
12428
12623
  }
12429
12624
  function snapshotDir(io, key) {
12430
- return join24(cacheRoot(io), key);
12625
+ return join25(cacheRoot(io), key);
12431
12626
  }
12432
12627
  function readManifest(dir) {
12433
12628
  try {
12434
- const parsed = JSON.parse(readFileSync18(join24(dir, "manifest.json"), "utf8"));
12629
+ const parsed = JSON.parse(readFileSync19(join25(dir, "manifest.json"), "utf8"));
12435
12630
  if (!parsed || typeof parsed !== "object") return null;
12436
12631
  const m = parsed;
12437
12632
  if (typeof m.key !== "string" || !Array.isArray(m.dirs)) return null;
@@ -12443,11 +12638,11 @@ function readManifest(dir) {
12443
12638
  }
12444
12639
  }
12445
12640
  function hasEnvSnapshot(key, io = {}) {
12446
- const exists = io.exists ?? existsSync14;
12447
- return exists(join24(snapshotDir(io, key), "manifest.json"));
12641
+ const exists = io.exists ?? existsSync15;
12642
+ return exists(join25(snapshotDir(io, key), "manifest.json"));
12448
12643
  }
12449
12644
  async function restoreEnvSnapshot(worktree, key, io = {}) {
12450
- const exists = io.exists ?? existsSync14;
12645
+ const exists = io.exists ?? existsSync15;
12451
12646
  const clone = io.clone ?? cloneTree;
12452
12647
  const dir = snapshotDir(io, key);
12453
12648
  const manifest = readManifest(dir);
@@ -12456,13 +12651,13 @@ async function restoreEnvSnapshot(worktree, key, io = {}) {
12456
12651
  try {
12457
12652
  for (let i = 0; i < manifest.dirs.length; i++) {
12458
12653
  const rel = manifest.dirs[i] ?? "";
12459
- const target = join24(worktree, rel);
12654
+ const target = join25(worktree, rel);
12460
12655
  if (exists(target)) continue;
12461
- await clone(join24(dir, "trees", String(i)), target);
12656
+ await clone(join25(dir, "trees", String(i)), target);
12462
12657
  made.push(rel);
12463
12658
  }
12464
12659
  } catch {
12465
- for (const rel of made) await rm2(join24(worktree, rel), { recursive: true, force: true }).catch(() => {
12660
+ for (const rel of made) await rm2(join25(worktree, rel), { recursive: true, force: true }).catch(() => {
12466
12661
  });
12467
12662
  return null;
12468
12663
  }
@@ -12475,19 +12670,19 @@ async function touch(dir) {
12475
12670
  });
12476
12671
  }
12477
12672
  async function saveEnvSnapshot(worktree, key, dirs, io = {}) {
12478
- const exists = io.exists ?? existsSync14;
12673
+ const exists = io.exists ?? existsSync15;
12479
12674
  const clone = io.clone ?? cloneTree;
12480
12675
  if (hasEnvSnapshot(key, io)) return true;
12481
- const present = dirs.filter((rel) => exists(join24(worktree, rel)));
12676
+ const present = dirs.filter((rel) => exists(join25(worktree, rel)));
12482
12677
  if (!present.length) return false;
12483
12678
  const root = cacheRoot(io);
12484
- const tmp = join24(root, `.tmp-${key}-${process.pid}`);
12679
+ const tmp = join25(root, `.tmp-${key}-${process.pid}`);
12485
12680
  try {
12486
12681
  await rm2(tmp, { recursive: true, force: true });
12487
- await mkdir2(join24(tmp, "trees"), { recursive: true });
12488
- for (let i = 0; i < present.length; i++) await clone(join24(worktree, present[i] ?? ""), join24(tmp, "trees", String(i)));
12682
+ await mkdir2(join25(tmp, "trees"), { recursive: true });
12683
+ for (let i = 0; i < present.length; i++) await clone(join25(worktree, present[i] ?? ""), join25(tmp, "trees", String(i)));
12489
12684
  const manifest = { key, dirs: present, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
12490
- await writeFile2(join24(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
12685
+ await writeFile2(join25(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
12491
12686
  await rename2(tmp, snapshotDir(io, key));
12492
12687
  return true;
12493
12688
  } catch {
@@ -12507,13 +12702,13 @@ async function pruneEnvSnapshots(io = {}) {
12507
12702
  }
12508
12703
  const withTime = [];
12509
12704
  for (const name of names) {
12510
- const s = await stat(join24(root, name)).catch(() => null);
12705
+ const s = await stat(join25(root, name)).catch(() => null);
12511
12706
  if (s) withTime.push({ name, mtime: s.mtimeMs });
12512
12707
  }
12513
12708
  withTime.sort((a, b) => b.mtime - a.mtime);
12514
12709
  let removed = 0;
12515
12710
  for (const { name } of withTime.slice(Math.max(0, keep))) {
12516
- await rm2(join24(root, name), { recursive: true, force: true }).catch(() => {
12711
+ await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
12517
12712
  });
12518
12713
  removed++;
12519
12714
  }
@@ -12529,9 +12724,9 @@ async function sweepEnvCacheTemp(io = {}) {
12529
12724
  }
12530
12725
  let removed = 0;
12531
12726
  for (const name of names) {
12532
- const s = await lstat(join24(root, name)).catch(() => null);
12727
+ const s = await lstat(join25(root, name)).catch(() => null);
12533
12728
  if (!s || Date.now() - s.mtimeMs < 60 * 6e4) continue;
12534
- await rm2(join24(root, name), { recursive: true, force: true }).catch(() => {
12729
+ await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
12535
12730
  });
12536
12731
  removed++;
12537
12732
  }
@@ -12558,21 +12753,21 @@ async function runCommand(cmd, worktree) {
12558
12753
  }
12559
12754
  function safeReadText(p) {
12560
12755
  try {
12561
- return readFileSync19(p, "utf8");
12756
+ return readFileSync20(p, "utf8");
12562
12757
  } catch {
12563
12758
  return null;
12564
12759
  }
12565
12760
  }
12566
12761
  function safeListDirs(p) {
12567
12762
  try {
12568
- return readdirSync14(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
12763
+ return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
12569
12764
  } catch {
12570
12765
  return [];
12571
12766
  }
12572
12767
  }
12573
12768
  function safeListFiles(p) {
12574
12769
  try {
12575
- return readdirSync14(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
12770
+ return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
12576
12771
  } catch {
12577
12772
  return [];
12578
12773
  }
@@ -12598,21 +12793,21 @@ function overridePlan(override) {
12598
12793
  };
12599
12794
  }
12600
12795
  function detectPackageManager(worktree, io = {}) {
12601
- const exists = io.exists ?? existsSync15;
12796
+ const exists = io.exists ?? existsSync16;
12602
12797
  const readText = io.readText ?? safeReadText;
12603
- const hasPkgJson = exists(join25(worktree, "package.json"));
12798
+ const hasPkgJson = exists(join26(worktree, "package.json"));
12604
12799
  if (!hasPkgJson) {
12605
- if (exists(join25(worktree, "deno.json")) || exists(join25(worktree, "deno.jsonc")) || exists(join25(worktree, "deno.lock"))) return "deno";
12800
+ if (exists(join26(worktree, "deno.json")) || exists(join26(worktree, "deno.jsonc")) || exists(join26(worktree, "deno.lock"))) return "deno";
12606
12801
  return null;
12607
12802
  }
12608
- const pkg = readJson(readText, join25(worktree, "package.json"));
12803
+ const pkg = readJson(readText, join26(worktree, "package.json"));
12609
12804
  const declared = typeof pkg?.packageManager === "string" ? pkg.packageManager.split("@")[0] : void 0;
12610
12805
  if (declared === "pnpm" || declared === "bun" || declared === "npm" || declared === "yarn") return declared;
12611
- if (exists(join25(worktree, "bun.lock")) || exists(join25(worktree, "bun.lockb"))) return "bun";
12612
- if (exists(join25(worktree, "pnpm-lock.yaml"))) return "pnpm";
12613
- if (exists(join25(worktree, "yarn.lock"))) return "yarn";
12614
- if (exists(join25(worktree, "package-lock.json"))) return "npm";
12615
- if (exists(join25(worktree, "deno.lock"))) return "deno";
12806
+ if (exists(join26(worktree, "bun.lock")) || exists(join26(worktree, "bun.lockb"))) return "bun";
12807
+ if (exists(join26(worktree, "pnpm-lock.yaml"))) return "pnpm";
12808
+ if (exists(join26(worktree, "yarn.lock"))) return "yarn";
12809
+ if (exists(join26(worktree, "package-lock.json"))) return "npm";
12810
+ if (exists(join26(worktree, "deno.lock"))) return "deno";
12616
12811
  return "npm";
12617
12812
  }
12618
12813
  function jsInstallCommand(pm) {
@@ -12668,7 +12863,7 @@ var ECOSYSTEM_MARKERS = [
12668
12863
  // конфигурация — дело сборки, не подготовки
12669
12864
  ];
12670
12865
  function detectPlan(worktree, io) {
12671
- const exists = io.exists ?? existsSync15;
12866
+ const exists = io.exists ?? existsSync16;
12672
12867
  const listFiles = io.listFiles ?? safeListFiles;
12673
12868
  const pm = detectPackageManager(worktree, io);
12674
12869
  if (pm) {
@@ -12676,7 +12871,7 @@ function detectPlan(worktree, io) {
12676
12871
  // node_modules на месте — установку пропускаем (быстрый путь переиспользованного worktree).
12677
12872
  // У deno каталога может не быть вовсе (кэш в DENO_DIR) — тогда `deno install` отработает
12678
12873
  // заново, но он дешёвый: тянет из того же общего кэша.
12679
- { label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join25(worktree, "node_modules"), source: "detect" }
12874
+ { label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join26(worktree, "node_modules"), source: "detect" }
12680
12875
  ];
12681
12876
  for (const target of workspaceBuildTargets(worktree, io)) {
12682
12877
  commands.push({ label: `\u0441\u0431\u043E\u0440\u043A\u0430 ${target.name}`, run: jsRunScript(pm, "build"), cwd: target.dir, source: "detect" });
@@ -12685,12 +12880,12 @@ function detectPlan(worktree, io) {
12685
12880
  return { source: "detect", ecosystem: `node/${pm}`, commands };
12686
12881
  }
12687
12882
  for (const marker of ECOSYSTEM_MARKERS) {
12688
- const hit = marker.files.some((f) => exists(join25(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
12883
+ const hit = marker.files.some((f) => exists(join26(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
12689
12884
  if (!hit) continue;
12690
12885
  let ecosystem = marker.ecosystem;
12691
12886
  let command = marker.command;
12692
12887
  for (const refine of marker.refine ?? []) {
12693
- if (!exists(join25(worktree, refine.file))) continue;
12888
+ if (!exists(join26(worktree, refine.file))) continue;
12694
12889
  ecosystem = refine.ecosystem;
12695
12890
  command = refine.command;
12696
12891
  break;
@@ -12747,12 +12942,12 @@ var CI_INSTALL_PATTERNS = [
12747
12942
  function ciWorkflowPlan(worktree, io) {
12748
12943
  const readText = io.readText ?? safeReadText;
12749
12944
  const listFiles = io.listFiles ?? safeListFiles;
12750
- const dir = join25(worktree, ".github", "workflows");
12945
+ const dir = join26(worktree, ".github", "workflows");
12751
12946
  const files = listFiles(dir).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml"));
12752
12947
  const seen = /* @__PURE__ */ new Set();
12753
12948
  const commands = [];
12754
12949
  for (const name of files.sort()) {
12755
- const yaml = readText(join25(dir, name));
12950
+ const yaml = readText(join26(dir, name));
12756
12951
  if (yaml === null) continue;
12757
12952
  for (const raw of workflowRunLines(yaml)) {
12758
12953
  const line = raw.replace(/\s+/g, " ").trim();
@@ -12767,7 +12962,7 @@ function ciWorkflowPlan(worktree, io) {
12767
12962
  return commands.length ? { source: "ci-workflow", ecosystem: "ci-\u043A\u043E\u043D\u0444\u0438\u0433", commands } : null;
12768
12963
  }
12769
12964
  function workspaceGlobs(worktree, readText) {
12770
- const yaml = readText(join25(worktree, "pnpm-workspace.yaml"));
12965
+ const yaml = readText(join26(worktree, "pnpm-workspace.yaml"));
12771
12966
  if (yaml !== null) {
12772
12967
  const globs = [];
12773
12968
  let inPackages = false;
@@ -12787,7 +12982,7 @@ function workspaceGlobs(worktree, readText) {
12787
12982
  }
12788
12983
  if (globs.length) return globs;
12789
12984
  }
12790
- const pkg = readJson(readText, join25(worktree, "package.json"));
12985
+ const pkg = readJson(readText, join26(worktree, "package.json"));
12791
12986
  const ws = pkg?.workspaces;
12792
12987
  const list = Array.isArray(ws) ? ws : Array.isArray(ws?.packages) ? ws.packages : [];
12793
12988
  return list.filter((g) => typeof g === "string");
@@ -12798,14 +12993,14 @@ function workspaceDirs(worktree, globs, io) {
12798
12993
  if (glob.startsWith("!")) continue;
12799
12994
  const star = glob.indexOf("*");
12800
12995
  if (star === -1) {
12801
- const dir = join25(worktree, glob);
12802
- if (io.exists(join25(dir, "package.json"))) dirs.add(dir);
12996
+ const dir = join26(worktree, glob);
12997
+ if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
12803
12998
  continue;
12804
12999
  }
12805
- const base3 = join25(worktree, glob.slice(0, star).replace(/\/$/, ""));
13000
+ const base3 = join26(worktree, glob.slice(0, star).replace(/\/$/, ""));
12806
13001
  for (const name of io.listDirs(base3)) {
12807
- const dir = join25(base3, name);
12808
- if (io.exists(join25(dir, "package.json"))) dirs.add(dir);
13002
+ const dir = join26(base3, name);
13003
+ if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
12809
13004
  }
12810
13005
  }
12811
13006
  return [...dirs];
@@ -12826,18 +13021,18 @@ function entryPaths(pkg) {
12826
13021
  return out;
12827
13022
  }
12828
13023
  function workspaceBuildTargets(worktree, io = {}) {
12829
- const exists = io.exists ?? existsSync15;
13024
+ const exists = io.exists ?? existsSync16;
12830
13025
  const readText = io.readText ?? safeReadText;
12831
13026
  const listDirs = io.listDirs ?? safeListDirs;
12832
13027
  const globs = workspaceGlobs(worktree, readText);
12833
13028
  if (!globs.length) return [];
12834
13029
  const pkgs = [];
12835
13030
  for (const dir of workspaceDirs(worktree, globs, { exists, listDirs })) {
12836
- const pkg = readJson(readText, join25(dir, "package.json"));
13031
+ const pkg = readJson(readText, join26(dir, "package.json"));
12837
13032
  if (!pkg || typeof pkg.name !== "string") continue;
12838
13033
  const scripts = pkg.scripts ?? {};
12839
13034
  const entries = entryPaths(pkg);
12840
- const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join25(dir, e)));
13035
+ const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join26(dir, e)));
12841
13036
  const deps = Object.keys({ ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} });
12842
13037
  pkgs.push({ name: pkg.name, dir, deps, needsBuild });
12843
13038
  }
@@ -12865,7 +13060,7 @@ function devDatabaseUrl(worktree, io = {}) {
12865
13060
  const fromEnv = (io.env ?? process.env).DATABASE_URL;
12866
13061
  if (fromEnv && fromEnv.trim()) return fromEnv.trim();
12867
13062
  for (const file of [".env", ".env.example"]) {
12868
- const raw = readText(join25(worktree, file));
13063
+ const raw = readText(join26(worktree, file));
12869
13064
  if (raw === null) continue;
12870
13065
  const m = /^\s*(?:export\s+)?DATABASE_URL\s*=\s*(.*)$/m.exec(raw);
12871
13066
  const value = (m?.[1] ?? "").trim().replace(/^['"]|['"]$/g, "");
@@ -12881,11 +13076,11 @@ function isLocalDatabase(url) {
12881
13076
  }
12882
13077
  }
12883
13078
  function prismaPackages(worktree, io) {
12884
- const exists = io.exists ?? existsSync15;
13079
+ const exists = io.exists ?? existsSync16;
12885
13080
  const readText = io.readText ?? safeReadText;
12886
13081
  const listDirs = io.listDirs ?? safeListDirs;
12887
13082
  const dirs = [worktree, ...workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs })];
12888
- return dirs.filter((dir) => exists(join25(dir, "prisma", "schema.prisma")) && listDirs(join25(dir, "prisma", "migrations")).length > 0);
13083
+ return dirs.filter((dir) => exists(join26(dir, "prisma", "schema.prisma")) && listDirs(join26(dir, "prisma", "migrations")).length > 0);
12889
13084
  }
12890
13085
  function jsExecBin(pm, command) {
12891
13086
  switch (pm) {
@@ -12915,25 +13110,25 @@ function migrateCommands(worktree, pm, io) {
12915
13110
  var ENV_DEFINING_FILES = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock", "bun.lockb", "deno.lock", "pnpm-workspace.yaml"];
12916
13111
  function envCachePlan(worktree, io = {}) {
12917
13112
  if (!ENV_CACHE_ENABLED) return null;
12918
- const exists = io.exists ?? existsSync15;
13113
+ const exists = io.exists ?? existsSync16;
12919
13114
  const readText = io.readText ?? safeReadText;
12920
13115
  const listDirs = io.listDirs ?? safeListDirs;
12921
13116
  const pm = detectPackageManager(worktree, io);
12922
13117
  if (!pm) return null;
12923
13118
  const parts = [`pm:${pm}`];
12924
13119
  for (const name of ENV_DEFINING_FILES) {
12925
- const raw = readText(join25(worktree, name));
13120
+ const raw = readText(join26(worktree, name));
12926
13121
  if (raw !== null) parts.push(`${name}
12927
13122
  ${raw}`);
12928
13123
  }
12929
13124
  const pkgDirs = workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs });
12930
13125
  const rels = pkgDirs.map((dir) => dir.slice(worktree.length + 1)).sort();
12931
13126
  for (const rel of ["", ...rels]) {
12932
- const raw = readText(join25(worktree, rel, "package.json"));
13127
+ const raw = readText(join26(worktree, rel, "package.json"));
12933
13128
  if (raw !== null) parts.push(`${rel}/package.json
12934
13129
  ${raw}`);
12935
13130
  }
12936
- return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join25(rel, "node_modules"))] };
13131
+ return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join26(rel, "node_modules"))] };
12937
13132
  }
12938
13133
  function planPrepare(worktree, io = {}) {
12939
13134
  const plan = overridePlan(io.override) ?? detectPlan(worktree, io) ?? ciWorkflowPlan(worktree, io);
@@ -12941,7 +13136,7 @@ function planPrepare(worktree, io = {}) {
12941
13136
  return { ...plan, commands: plan.commands.slice(0, MAX_PLAN_COMMANDS) };
12942
13137
  }
12943
13138
  async function ensureWorktreeDeps(worktree, io = {}) {
12944
- const exists = io.exists ?? existsSync15;
13139
+ const exists = io.exists ?? existsSync16;
12945
13140
  const exec = io.exec ?? ((cmd) => runCommand(cmd, worktree));
12946
13141
  const approve = io.approve ?? (() => true);
12947
13142
  const cachePlan = envCachePlan(worktree, io);
@@ -12958,7 +13153,7 @@ async function ensureWorktreeDeps(worktree, io = {}) {
12958
13153
  restored: [],
12959
13154
  cached: false
12960
13155
  };
12961
- if (cachePlan && !exists(join25(worktree, "node_modules"))) {
13156
+ if (cachePlan && !exists(join26(worktree, "node_modules"))) {
12962
13157
  report.restored = await restoreEnvSnapshot(worktree, cachePlan.key, cacheIO) ?? [];
12963
13158
  }
12964
13159
  const plan = planPrepare(worktree, io);
@@ -13045,8 +13240,8 @@ function depsPromptNotice(report) {
13045
13240
 
13046
13241
  // src/orchestrator.ts
13047
13242
  init_config();
13048
- import { existsSync as existsSync16, mkdirSync as mkdirSync10, rmSync as rmSync3 } from "fs";
13049
- import { join as join26, dirname as dirname4 } from "path";
13243
+ import { existsSync as existsSync17, mkdirSync as mkdirSync11, rmSync as rmSync3 } from "fs";
13244
+ import { join as join27, dirname as dirname4 } from "path";
13050
13245
  function droneLaunchedText(workdir, pid) {
13051
13246
  return `\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0432 ${workdir} (pid ${pid})`;
13052
13247
  }
@@ -13055,7 +13250,7 @@ function droneLaunchedPid(text) {
13055
13250
  return m ? Number(m[1]) : null;
13056
13251
  }
13057
13252
  function repolessRunDir(worktreesDir, taskSlug) {
13058
- return join26(dirname4(worktreesDir), "runs", taskSlug);
13253
+ return join27(dirname4(worktreesDir), "runs", taskSlug);
13059
13254
  }
13060
13255
  var WORKTREE_HELD_STATUSES = /* @__PURE__ */ new Set(["running", "blocked", "review", "paused", "storm_dead"]);
13061
13256
  function worktreePathHeldLive(db, path, exceptRunId) {
@@ -13112,11 +13307,11 @@ function healTaskSlug(db, run2, task) {
13112
13307
  async function spawnDrone(deps, run2) {
13113
13308
  if (run2.repoless) {
13114
13309
  const workdir = repolessRunDir(deps.worktreesDir, run2.task_slug);
13115
- if (existsSync16(workdir)) {
13310
+ if (existsSync17(workdir)) {
13116
13311
  rmSync3(workdir, { recursive: true, force: true });
13117
13312
  deps.db.addEvent(run2.id, "step", `\u0440\u0435\u043A\u043B\u0435\u0439\u043C \u043E\u0441\u0438\u0440\u043E\u0442\u0435\u0432\u0448\u0435\u0433\u043E \u0441\u043A\u0440\u0430\u0442\u0447-\u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 ${workdir} (\u0434\u0435\u0440\u0436\u0430\u043B \u043C\u0451\u0440\u0442\u0432\u044B\u0439 \u043F\u0440\u043E\u0433\u043E\u043D)`);
13118
13313
  }
13119
- mkdirSync10(workdir, { recursive: true });
13314
+ mkdirSync11(workdir, { recursive: true });
13120
13315
  if (run2.area && deps.db.runningAreas("").includes(run2.area)) throw new AreaBusyError(run2.area);
13121
13316
  deps.db.addEvent(run2.id, "step", `repoless-\u043F\u0440\u043E\u0433\u043E\u043D: \u0441\u043A\u0440\u0430\u0442\u0447-\u043A\u0430\u0442\u0430\u043B\u043E\u0433 ${workdir} (\u0431\u0435\u0437 worktree/\u0432\u0435\u0442\u043A\u0438/PR \u2014 TASWM-595)`);
13122
13317
  const built2 = await deps.buildPrompt(run2, workdir);
@@ -13333,7 +13528,7 @@ function parkReasonUnretriable(reason) {
13333
13528
  // package.json
13334
13529
  var package_default = {
13335
13530
  name: "@taskless-app/swarm",
13336
- version: "0.6.81",
13531
+ version: "0.6.82",
13337
13532
  type: "module",
13338
13533
  description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
13339
13534
  keywords: [
@@ -13385,7 +13580,7 @@ var package_default = {
13385
13580
  undici: "^7.30.1",
13386
13581
  zod: "3.25.76"
13387
13582
  },
13388
- gitHead: "0a4c6ee0b5f07c122a325e3df3bc3361ee01b312"
13583
+ gitHead: "1ca25b5c37db968ab99a966201fd4a1dd35a2ac1"
13389
13584
  };
13390
13585
 
13391
13586
  // src/version.ts
@@ -14205,8 +14400,8 @@ import { z } from "zod";
14205
14400
  init_git();
14206
14401
 
14207
14402
  // src/diff.ts
14208
- import { statSync as statSync13 } from "fs";
14209
- import { join as join31 } from "path";
14403
+ import { statSync as statSync14 } from "fs";
14404
+ import { join as join32 } from "path";
14210
14405
  import { $ as $4 } from "execa";
14211
14406
  var MAX_FILES = 200;
14212
14407
  var MAX_LINES_PER_FILE = 1500;
@@ -14349,7 +14544,7 @@ async function resolveBase(wt, baseBranch) {
14349
14544
  }
14350
14545
  function mtime(path) {
14351
14546
  try {
14352
- return statSync13(path).mtimeMs;
14547
+ return statSync14(path).mtimeMs;
14353
14548
  } catch {
14354
14549
  return 0;
14355
14550
  }
@@ -14374,7 +14569,7 @@ async function collectRunDiff(worktree, opts = {}) {
14374
14569
  files.push(pf);
14375
14570
  }
14376
14571
  }
14377
- files.sort((a, b) => mtime(join31(worktree, b.path)) - mtime(join31(worktree, a.path)));
14572
+ files.sort((a, b) => mtime(join32(worktree, b.path)) - mtime(join32(worktree, a.path)));
14378
14573
  const truncatedFiles = files.length > MAX_FILES;
14379
14574
  if (truncatedFiles) files = files.slice(0, MAX_FILES);
14380
14575
  const added = files.reduce((s, f) => s + f.added, 0);
@@ -16792,23 +16987,23 @@ async function prodClearMergeIntent(runId, deps = {}) {
16792
16987
  }
16793
16988
 
16794
16989
  // src/envGate.ts
16795
- import { existsSync as existsSync19 } from "fs";
16796
- import { join as join33 } from "path";
16990
+ import { existsSync as existsSync20 } from "fs";
16991
+ import { join as join34 } from "path";
16797
16992
  import { createConnection } from "net";
16798
16993
  import { execa as execa2 } from "execa";
16799
16994
 
16800
16995
  // src/platform.ts
16801
16996
  init_src();
16802
- import { accessSync as accessSync2, constants as constants2, existsSync as existsSync18, readFileSync as readFileSync23, realpathSync as realpathSync3 } from "fs";
16803
- import { delimiter as delimiter2, join as join32, posix as posix2, win32 } from "path";
16997
+ import { accessSync as accessSync2, constants as constants2, existsSync as existsSync19, readFileSync as readFileSync24, realpathSync as realpathSync3 } from "fs";
16998
+ import { delimiter as delimiter2, join as join33, posix as posix2, win32 } from "path";
16804
16999
  function resolveCommandPath(name, env = process.env, platform = process.platform) {
16805
- if (name.includes("/") || name.includes("\\")) return existsSync18(name) ? name : null;
17000
+ if (name.includes("/") || name.includes("\\")) return existsSync19(name) ? name : null;
16806
17001
  const dirs = (env.PATH ?? env.Path ?? "").split(delimiter2).filter(Boolean);
16807
17002
  const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
16808
17003
  for (const dir of dirs) {
16809
17004
  for (const ext of exts) {
16810
- const candidate = join32(dir, name + ext);
16811
- if (existsSync18(candidate)) return candidate;
17005
+ const candidate = join33(dir, name + ext);
17006
+ if (existsSync19(candidate)) return candidate;
16812
17007
  }
16813
17008
  }
16814
17009
  return null;
@@ -16977,8 +17172,8 @@ var COMPOSE_MARKERS = [
16977
17172
  "compose.yaml"
16978
17173
  ];
16979
17174
  function detectRequirements(repo, io = {}) {
16980
- const exists = io.exists ?? existsSync19;
16981
- const marker = COMPOSE_MARKERS.find((f) => exists(join33(repo, f)));
17175
+ const exists = io.exists ?? existsSync20;
17176
+ const marker = COMPOSE_MARKERS.find((f) => exists(join34(repo, f)));
16982
17177
  return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
16983
17178
  }
16984
17179
  function resolveRequirements(repo, declared, io = {}) {
@@ -18734,21 +18929,21 @@ function closeWebServer(server) {
18734
18929
 
18735
18930
  // src/hostCommands.ts
18736
18931
  init_src();
18737
- import { readFileSync as readFileSync24, renameSync as renameSync10, writeFileSync as writeFileSync16 } from "fs";
18738
- import { join as join34 } from "path";
18932
+ import { readFileSync as readFileSync25, renameSync as renameSync10, writeFileSync as writeFileSync17 } from "fs";
18933
+ import { join as join35 } from "path";
18739
18934
  function hostCommandStatePath(home) {
18740
- return join34(home, "host-command.json");
18935
+ return join35(home, "host-command.json");
18741
18936
  }
18742
18937
  function readState(path) {
18743
18938
  try {
18744
- return JSON.parse(readFileSync24(path, "utf8"));
18939
+ return JSON.parse(readFileSync25(path, "utf8"));
18745
18940
  } catch {
18746
18941
  return {};
18747
18942
  }
18748
18943
  }
18749
18944
  function writeState(path, state) {
18750
18945
  try {
18751
- writeFileSync16(`${path}.tmp`, JSON.stringify(state));
18946
+ writeFileSync17(`${path}.tmp`, JSON.stringify(state));
18752
18947
  renameSync10(`${path}.tmp`, path);
18753
18948
  } catch {
18754
18949
  }
@@ -18911,8 +19106,8 @@ async function doRestart(cmd, opts, note) {
18911
19106
 
18912
19107
  // src/selfUpdate.ts
18913
19108
  init_git();
18914
- import { existsSync as existsSync20 } from "fs";
18915
- import { join as join35 } from "path";
19109
+ import { existsSync as existsSync21 } from "fs";
19110
+ import { join as join36 } from "path";
18916
19111
  import { $ as $5 } from "execa";
18917
19112
 
18918
19113
  // src/cliIo.ts
@@ -18945,7 +19140,7 @@ function tail(text, max = 400) {
18945
19140
  }
18946
19141
  async function runSelfUpdate(io) {
18947
19142
  const run2 = io.run ?? defaultRun;
18948
- const exists = io.exists ?? existsSync20;
19143
+ const exists = io.exists ?? existsSync21;
18949
19144
  const repo = io.repo;
18950
19145
  await io.onStep("fetch", "\u0442\u044F\u043D\u0443 \u0441\u0432\u0435\u0436\u0438\u0439 \u043A\u043E\u0434");
18951
19146
  const fetched = await run2("git", ["-C", repo, "fetch", "--quiet", "origin"], repo);
@@ -18974,7 +19169,7 @@ async function runSelfUpdate(io) {
18974
19169
  };
18975
19170
  }
18976
19171
  await io.onStep("install", "\u0441\u0442\u0430\u0432\u043B\u044E \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438");
18977
- if (!exists(join35(repo, "pnpm-lock.yaml"))) {
19172
+ if (!exists(join36(repo, "pnpm-lock.yaml"))) {
18978
19173
  return { ok: false, step: "install", message: "\u0432 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u0434\u0435\u043C\u043E\u043D\u0430 \u043D\u0435\u0442 pnpm-lock.yaml \u2014 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0442\u044C \u0435\u0433\u043E \u044D\u0442\u0438\u043C \u043F\u0443\u0442\u0451\u043C \u043D\u0435 \u0431\u0435\u0440\u0443\u0441\u044C" };
18979
19174
  }
18980
19175
  const installed2 = await run2("pnpm", ["install", "--frozen-lockfile"], repo);
@@ -19145,19 +19340,19 @@ async function fetchExternalStorm(url, opts = {}) {
19145
19340
  }
19146
19341
 
19147
19342
  // src/anomalyState.ts
19148
- import { existsSync as existsSync21, readFileSync as readFileSync25, renameSync as renameSync11, writeFileSync as writeFileSync17 } from "fs";
19149
- import { join as join36 } from "path";
19343
+ import { existsSync as existsSync22, readFileSync as readFileSync26, renameSync as renameSync11, writeFileSync as writeFileSync18 } from "fs";
19344
+ import { join as join37 } from "path";
19150
19345
  var KEY_TTL_MS = 7 * 24 * 60 * 6e4;
19151
19346
  var MAX_RESOLVED = 200;
19152
19347
  function emptyState() {
19153
19348
  return { since: {}, lastFiredAt: {}, fires: {}, resolved: [], stopQuiet: null };
19154
19349
  }
19155
19350
  function anomalyStatePath(home) {
19156
- return join36(home, "anomaly-state.json");
19351
+ return join37(home, "anomaly-state.json");
19157
19352
  }
19158
19353
  function loadAnomalyState(home, now = Date.now(), io = {}) {
19159
- const exists = io.exists ?? existsSync21;
19160
- const readFile2 = io.readFile ?? ((p) => readFileSync25(p, "utf8"));
19354
+ const exists = io.exists ?? existsSync22;
19355
+ const readFile2 = io.readFile ?? ((p) => readFileSync26(p, "utf8"));
19161
19356
  const path = anomalyStatePath(home);
19162
19357
  if (!exists(path)) return emptyState();
19163
19358
  try {
@@ -19187,7 +19382,7 @@ function loadAnomalyState(home, now = Date.now(), io = {}) {
19187
19382
  function saveAnomalyState(home, state, io = {}) {
19188
19383
  const path = anomalyStatePath(home);
19189
19384
  const writeFile4 = io.writeFile ?? ((p, data) => {
19190
- writeFileSync17(`${p}.tmp`, data);
19385
+ writeFileSync18(`${p}.tmp`, data);
19191
19386
  renameSync11(`${p}.tmp`, p);
19192
19387
  });
19193
19388
  writeFile4(path, JSON.stringify(state, null, 2));
@@ -19805,7 +20000,15 @@ function worktreeFromCmd(args) {
19805
20000
  const bare = quoted ? null : args.match(/--mcp-config\s+(\S+[/\\]\.swarm-mcp\.json)/);
19806
20001
  const path = quoted?.[1] ?? bare?.[1];
19807
20002
  if (path) return path.replace(/[/\\]\.swarm-mcp\.json$/, "");
19808
- return worktreeFromGrokCwd(args);
20003
+ return worktreeFromGrokCwd(args) ?? worktreeFromKimiCmd(args);
20004
+ }
20005
+ function worktreeFromKimiCmd(args) {
20006
+ const trimmed = args.trim();
20007
+ const first = trimmed.startsWith('"') ? trimmed.slice(1, trimmed.indexOf('"', 1)) : trimmed.split(/\s/)[0] ?? "";
20008
+ if (!/(?:^|[\\/])kimi(?:\.exe)?$/i.test(first)) return null;
20009
+ const quoted = args.match(/--add-dir\s+"([^"]+)"/);
20010
+ const bare = quoted ? null : args.match(/--add-dir\s+(\S+)/);
20011
+ return quoted?.[1] ?? bare?.[1] ?? null;
19809
20012
  }
19810
20013
  function worktreeFromGrokCwd(args) {
19811
20014
  const trimmed = args.trim();
@@ -20630,10 +20833,10 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
20630
20833
  }
20631
20834
  return parts.join("\n");
20632
20835
  }
20633
- var HERO_CHARTER_PATH = join37(dirname6(THIS_FILE), "..", "docs", "HERO.md");
20836
+ var HERO_CHARTER_PATH = join38(dirname6(THIS_FILE), "..", "docs", "HERO.md");
20634
20837
  function buildHeroPrompt(task, run2, taskContext, attachmentsBlock) {
20635
20838
  const name = run2.name || `#${run2.id}`;
20636
- const charter = readFileSync26(HERO_CHARTER_PATH, "utf8");
20839
+ const charter = readFileSync27(HERO_CHARTER_PATH, "utf8");
20637
20840
  const head = task ? `\u042D\u041F\u0418\u041A ${run2.task_slug}: ${task.title}
20638
20841
 
20639
20842
  ${task.description}` : `\u042D\u041F\u0418\u041A ${run2.task_slug} (\u0442\u0435\u043B\u043E \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u2014 \u0440\u0430\u0431\u043E\u0442\u0430\u0439 \u043F\u043E slug \u0438 \u0437\u0434\u0440\u0430\u0432\u043E\u043C\u0443 \u0441\u043C\u044B\u0441\u043B\u0443).`;
@@ -20693,9 +20896,9 @@ function ciTrustLine(prUrl, verifyMode, ciClosed = null) {
20693
20896
  }
20694
20897
  return `\u041D\u0435 \u043F\u0435\u0440\u0435\u0433\u043E\u043D\u044F\u0439 \u0442\u0435\u0441\u0442-\u0441\u044C\u044E\u0442/typecheck \u0437\u0430\u043D\u043E\u0432\u043E \u2014 \u044D\u0442\u043E \u0443\u0436\u0435 \u0441\u0434\u0435\u043B\u0430\u043B CI \u043D\u0430 \u044D\u0442\u043E\u043C \u0436\u0435 \u043A\u043E\u043C\u043C\u0438\u0442\u0435 (\u0434\u0432\u043E\u0439\u043D\u043E\u0439 \u043F\u0440\u043E\u0433\u043E\u043D \u043D\u0430 \u043C\u0430\u0448\u0438\u043D\u0435 \u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0430 \u043E\u0442\u043C\u0435\u043D\u0451\u043D, TASWM-249). \u041F\u0440\u043E\u0447\u0438\u0442\u0430\u0439 \u0435\u0433\u043E \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442 \u0441\u0430\u043C: ${readChecks}. \u0414\u0430\u043B\u044C\u0448\u0435 \u0442\u0440\u0438 \u0440\u0430\u0437\u043D\u044B\u0445 \u0441\u043B\u0443\u0447\u0430\u044F: \u2460 \u0445\u043E\u0442\u044C \u043E\u0434\u0438\u043D \u0447\u0435\u043A \u0435\u0449\u0451 PENDING \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u043E\u043E\u0431\u0449\u0435 \u043D\u0435 \u0432\u044B\u043D\u043E\u0441\u0438: \u043D\u0435 \u043F\u043E\u0441\u0442\u0438 REQUEST CHANGES, \u043D\u0435 \u0437\u043E\u0432\u0438 done(), \u043F\u0440\u043E\u0441\u0442\u043E \u0437\u0430\u0432\u0435\u0440\u0448\u0438 \u0441\u0435\u0441\u0441\u0438\u044E \u043A\u0430\u043A \u0435\u0441\u0442\u044C \u2014 \u0440\u043E\u0439 \u0441\u0430\u043C \u0437\u0430\u043C\u0435\u0442\u0438\u0442, \u0447\u0442\u043E \u0442\u044B \u0436\u0434\u0451\u0448\u044C CI, \u0438 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u0442 \u0434\u043E\u0434\u0435\u043B\u0430\u0442\u044C \u0440\u0435\u0432\u044C\u044E, \u043A\u043E\u0433\u0434\u0430 \u0432\u0441\u0435 \u0447\u0435\u043A\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u0441\u044F (\u044D\u0442\u043E \u0448\u0442\u0430\u0442\u043D\u044B\u0439 \u043F\u0443\u0442\u044C, \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 \u0437\u0432\u0430\u0442\u044C \u043D\u0435 \u043D\u0443\u0436\u043D\u043E). \u2461 \u0432\u0441\u0435 \u0447\u0435\u043A\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0438\u0441\u044C \u0438 \u0435\u0441\u0442\u044C FAIL \u2014 REQUEST CHANGES, \u043D\u0430\u0437\u043E\u0432\u0438 \u043F\u043E\u0438\u043C\u0451\u043D\u043D\u043E, \u0447\u0442\u043E \u0443\u043F\u0430\u043B\u043E. \u2462 \u043D\u0430 \u044D\u0442\u043E\u043C \u043A\u043E\u043C\u043C\u0438\u0442\u0435 \u0447\u0435\u043A\u043E\u0432 \u043D\u0435\u0442 \u0432\u043E\u0432\u0441\u0435 \u2014 \u0442\u043E \u0436\u0435, \u0447\u0442\u043E \u2460: \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u043D\u0435 \u0432\u044B\u043D\u043E\u0441\u0438, \u043D\u0435 \u043F\u0438\u0448\u0438 REQUEST CHANGES, \u043D\u0435 \u0437\u043E\u0432\u0438 done(), \u043F\u0440\u043E\u0441\u0442\u043E \u0437\u0430\u0432\u0435\u0440\u0448\u0438 \u0441\u0435\u0441\u0441\u0438\u044E. \u0427\u0435\u043A\u043E\u0432 \u043C\u043E\u0436\u0435\u0442 \u043D\u0435 \u0431\u044B\u0442\u044C, \u043F\u043E\u0442\u043E\u043C\u0443 \u0447\u0442\u043E \u0441\u0442\u0430\u0440\u044B\u0439 \u043F\u0440\u043E\u0433\u043E\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0442\u043E \u043E\u0442\u043C\u0435\u043D\u0451\u043D \u043D\u043E\u0432\u044B\u043C \u043F\u0443\u0448\u0435\u043C \u0438\u043B\u0438 \u0440\u0430\u043D\u043D\u0435\u0440\u044B \u0437\u0430\u043D\u044F\u0442\u044B. \u0420\u043E\u0439 \u0441\u0430\u043C \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u0442, \u043A\u043E\u0433\u0434\u0430 \u0447\u0435\u043A\u0438 \u043F\u043E\u044F\u0432\u044F\u0442\u0441\u044F \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u0441\u044F, \u0438\u043B\u0438 \u0441\u043A\u0430\u0436\u0435\u0442, \u0447\u0442\u043E \u0438\u0445 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442. ${dontTrustAuthor}`;
20695
20898
  }
20696
- var REVIEW_SKILL_PATH = join37(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
20899
+ var REVIEW_SKILL_PATH = join38(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
20697
20900
  function reviewDefectClasses(skillPath = REVIEW_SKILL_PATH) {
20698
- const text = readFileSync26(skillPath, "utf8");
20901
+ const text = readFileSync27(skillPath, "utf8");
20699
20902
  const m = /^## Классы дефектов\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(text);
20700
20903
  if (!m) throw new Error(`${skillPath}: \u043D\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043B\u0430 \xAB## \u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432\xBB \u2014 \u0444\u043E\u0440\u043C\u0430\u0442 skill taskless-review \u043F\u043E\u043C\u0435\u043D\u044F\u043B\u0441\u044F?`);
20701
20904
  return `\u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 (skill taskless-review):
@@ -21148,7 +21351,7 @@ async function wakeRun(deps, runId, opts = {}) {
21148
21351
  if (run2.status === "review" && run2.pr_url && !needsFixIteration(run2) && !stoppedForHuman) {
21149
21352
  return { ok: false, why: `\u043F\u0440\u043E\u0433\u043E\u043D #${runId} \u0443\u0436\u0435 \u0441\u0434\u0430\u043D \u043D\u0430 \u0440\u0435\u0432\u044C\u044E (${run2.pr_url}) \u2014 \u0431\u0443\u0434\u0438\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E; \u043F\u0440\u0430\u0432\u043A\u0438 \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442 \u0440\u043E\u0439 \u043F\u043E \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0443` };
21150
21353
  }
21151
- const worktreeExists = deps.worktreeExists ?? existsSync22;
21354
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
21152
21355
  const hasTranscript = deps.hasTranscript ?? executorHasSession;
21153
21356
  const wt = run2.worktree_path;
21154
21357
  const canContinue = !!wt && worktreeExists(wt) && hasTranscript(run2);
@@ -21279,9 +21482,9 @@ function repoHasCi(deps, run2) {
21279
21482
  function repoHasCiWorkflows(worktreePath, repo) {
21280
21483
  for (const base3 of [worktreePath, repo]) {
21281
21484
  if (!base3) continue;
21282
- const dir = join37(base3, ".github", "workflows");
21485
+ const dir = join38(base3, ".github", "workflows");
21283
21486
  try {
21284
- if (readdirSync15(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
21487
+ if (readdirSync16(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
21285
21488
  } catch {
21286
21489
  }
21287
21490
  }
@@ -21503,7 +21706,7 @@ async function wakeReviewerOnCiReady(deps, run2, over) {
21503
21706
  return true;
21504
21707
  }
21505
21708
  function worktreeAndTranscriptAlive(deps, run2) {
21506
- const exists = deps.worktreeExists ?? existsSync22;
21709
+ const exists = deps.worktreeExists ?? existsSync23;
21507
21710
  const transcript = deps.hasTranscript ?? executorHasSession;
21508
21711
  const wt = run2.worktree_path;
21509
21712
  return !!wt && exists(wt) && transcript(run2);
@@ -21693,7 +21896,7 @@ async function wakeAuthorOnChanges(deps, snapshot, now, droneCap) {
21693
21896
  }
21694
21897
  const wt = run2.worktree_path;
21695
21898
  const wtPath = wt || (deps.worktreesDir ? droneWorktreePath(deps.worktreesDir, normalizeRepo(run2.repo || deps.repoFallback || ""), run2.task_slug) : null);
21696
- const worktreeReady = !!wtPath && (deps.worktreeExists ?? existsSync22)(wtPath);
21899
+ const worktreeReady = !!wtPath && (deps.worktreeExists ?? existsSync23)(wtPath);
21697
21900
  if (!worktreeReady) {
21698
21901
  const why = await freshChangesWakeBlock(deps, run2, prUrl, now);
21699
21902
  if (why) return blockFix(run2, why);
@@ -21784,7 +21987,7 @@ async function zoneConflictFor(db, models, activeFiles, run2, repo, repoFallback
21784
21987
  activeFiles.prune(holders.map((r) => r.id));
21785
21988
  const fileExists = (p) => {
21786
21989
  try {
21787
- return statSync14(join37(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
21990
+ return statSync15(join38(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
21788
21991
  } catch {
21789
21992
  return false;
21790
21993
  }
@@ -22222,7 +22425,7 @@ async function liftReturners(deps, returners, now, droneCap) {
22222
22425
  deps.returners?.delete(run2.id);
22223
22426
  continue;
22224
22427
  }
22225
- lifted = await wakeAuthorOnRedCi(deps, run2, now, entry.ci, deps.worktreeExists ?? existsSync22, deps.hasTranscript ?? executorHasSession, droneCap);
22428
+ lifted = await wakeAuthorOnRedCi(deps, run2, now, entry.ci, deps.worktreeExists ?? existsSync23, deps.hasTranscript ?? executorHasSession, droneCap);
22226
22429
  }
22227
22430
  if (lifted) deps.returners?.delete(run2.id);
22228
22431
  }
@@ -22246,7 +22449,7 @@ async function resumeWatchdogParked(deps, droneCap) {
22246
22449
  await handOffAtCycleCap(deps, candidate, capHolder, "\u0432\u043E\u0437\u0432\u0440\u0430\u0442 \u0438\u0437 \u043F\u0430\u0440\u043A\u043E\u0432\u043A\u0438 \u0441\u0442\u043E\u0440\u043E\u0436\u0430");
22247
22450
  return;
22248
22451
  }
22249
- const worktreeExists = deps.worktreeExists ?? existsSync22;
22452
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
22250
22453
  const hasTranscript = deps.hasTranscript ?? executorHasSession;
22251
22454
  const wt = candidate.worktree_path;
22252
22455
  const canContinue = !!wt && worktreeExists(wt) && hasTranscript(candidate);
@@ -23117,7 +23320,7 @@ async function tickOnce(deps) {
23117
23320
  const now = deps.now ? deps.now() : Date.now();
23118
23321
  draftHeldThisTick.clear();
23119
23322
  fixBlockedThisTick.clear();
23120
- const worktreeExists = deps.worktreeExists ?? existsSync22;
23323
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
23121
23324
  const hasTranscript = deps.hasTranscript ?? executorHasSession;
23122
23325
  deps.stepClock?.mark("0 \u0437\u0430\u043C\u0435\u0440 \u0445\u043E\u0441\u0442\u0430");
23123
23326
  deps.sampleHost?.();
@@ -24085,7 +24288,7 @@ async function resolveConflict(deps, reviewRun) {
24085
24288
  model: reviewRun.model,
24086
24289
  review_model: reviewRun.review_model
24087
24290
  });
24088
- const wt = join37(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
24291
+ const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
24089
24292
  try {
24090
24293
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24091
24294
  await deps.git.setWorktreeIdentity(wt, resolver.name);
@@ -24166,7 +24369,7 @@ async function spawnReviewer(deps, reviewRun, files) {
24166
24369
  // (своей у ревьюера нет, TASWM-204), и коммент с вердиктом должен уехать именно туда.
24167
24370
  workspace_id: reviewRun.workspace_id
24168
24371
  });
24169
- const wt = join37(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
24372
+ const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
24170
24373
  try {
24171
24374
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24172
24375
  await deps.git.setWorktreeIdentity(wt, reviewer.name);
@@ -24247,7 +24450,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
24247
24450
  // штамп цикла: фикс-итерацию проверяет свежий верификатор
24248
24451
  workspace_id: verifiedRun.workspace_id
24249
24452
  });
24250
- const wt = join37(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
24453
+ const wt = join38(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
24251
24454
  try {
24252
24455
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24253
24456
  await deps.git.setWorktreeIdentity(wt, verifier.name);
@@ -24341,7 +24544,7 @@ async function respawnRun(deps, run2, mode, nudge) {
24341
24544
  ]);
24342
24545
  const base3 = effectiveBaseBranch(run2.base_branch, projectBase);
24343
24546
  const runToSpawn = base3 && run2.base_branch !== base3 ? deps.db.updateRun(run2.id, { base_branch: base3 }) ?? run2 : run2;
24344
- if (!existsSync22(wt)) {
24547
+ if (!existsSync23(wt)) {
24345
24548
  const branch = runToSpawn.branch || runToSpawn.task_slug;
24346
24549
  const source = await addWorktree(repo, wt, branch, {
24347
24550
  ...base3 ? { base: await remoteBaseRef(repo, base3) } : {},
@@ -24383,7 +24586,7 @@ function worktreePathPatch(run2, wt) {
24383
24586
  return run2.worktree_path === wt ? {} : { worktree_path: wt };
24384
24587
  }
24385
24588
  async function syncCrashedOnStartup(deps) {
24386
- const worktreeExists = deps.worktreeExists ?? existsSync22;
24589
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
24387
24590
  let orphaned = 0;
24388
24591
  let merged = 0;
24389
24592
  let requeued = 0;
@@ -24541,10 +24744,10 @@ async function migrateWorktreesAtStartup() {
24541
24744
  legacyDir: WORKTREES_LEGACY_DIR,
24542
24745
  targetDir: WORKTREES_DIR,
24543
24746
  envOverride: process.env.SWARM_WORKTREES || "",
24544
- exists: (d) => existsSync22(d),
24747
+ exists: (d) => existsSync23(d),
24545
24748
  isNonEmptyDir: (d) => {
24546
24749
  try {
24547
- return readdirSync15(d).length > 0;
24750
+ return readdirSync16(d).length > 0;
24548
24751
  } catch {
24549
24752
  return false;
24550
24753
  }
@@ -24556,7 +24759,7 @@ async function migrateWorktreesAtStartup() {
24556
24759
  });
24557
24760
  } catch (e) {
24558
24761
  console.error("[migrate] \u043C\u0438\u0433\u0440\u0430\u0446\u0438\u044F worktrees \u0441\u043E\u0440\u0432\u0430\u043B\u0430\u0441\u044C \u2014 \u0444\u043E\u043B\u0431\u044D\u043A:", e);
24559
- return existsSync22(WORKTREES_DIR) ? WORKTREES_DIR : WORKTREES_LEGACY_DIR;
24762
+ return existsSync23(WORKTREES_DIR) ? WORKTREES_DIR : WORKTREES_LEGACY_DIR;
24560
24763
  }
24561
24764
  }
24562
24765
  async function reportWorkspaceAccess(tl, db) {
@@ -25258,7 +25461,7 @@ async function runDaemon(opts) {
25258
25461
  isDirty: (p) => worktreeDirty(p),
25259
25462
  releaseWorktree: (repo, p) => releaseWorktree(repo || opts.repo, p),
25260
25463
  pruneWorktrees: (repo) => pruneWorktrees(repo || opts.repo),
25261
- worktreeExists: existsSync22,
25464
+ worktreeExists: existsSync23,
25262
25465
  liveWorktrees: () => new Set(listDroneProcesses().map((p) => p.worktree)),
25263
25466
  narrate: narrator.narrate
25264
25467
  });
@@ -25399,7 +25602,7 @@ async function runDaemon(opts) {
25399
25602
  mode,
25400
25603
  nudge
25401
25604
  ),
25402
- worktreeExists: (p) => existsSync22(p),
25605
+ worktreeExists: (p) => existsSync23(p),
25403
25606
  // TASWM-514: с этого момента считаем попытки спавна — счётчик живёт ровно одну жизнь
25404
25607
  // процесса демона и рестарт не переживает (см. preStartAttempts).
25405
25608
  startedAt: Date.now(),