@taskless-app/swarm 0.6.81 → 0.6.83

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 +383 -173
  2. package/dist/overmind.js +535 -305
  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,187 @@ ${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|providers)\./.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 raw = readFileSync4(realConfig, "utf8");
3184
+ const blocks = extractModelsBlocks(raw);
3185
+ const defaultModel = resolveShadowDefaultModel(raw, blocks);
3186
+ if (blocks.length > 0) {
3187
+ const head = defaultModel ? `default_model = "${defaultModel}"
3188
+
3189
+ ` : "";
3190
+ writeFileSync5(join8(home, "config.toml"), `${head}${blocks.join("\n\n")}
3191
+ `);
3192
+ }
3193
+ } catch {
3194
+ }
3195
+ return home;
3196
+ }
3197
+ function resolveShadowDefaultModel(config, blocks) {
3198
+ const declared = /^default_model\s*=\s*"([^"]+)"/m.exec(config)?.[1];
3199
+ if (declared?.trim()) return declared.trim();
3200
+ const firstModel = blocks.find((b) => /^\s*\[models\./.test(b));
3201
+ const alias = /^\s*\[models\."([^"]+)"\]/.exec(firstModel ?? "")?.[1];
3202
+ return alias?.trim() || null;
3203
+ }
3204
+ function modelArgs2(model) {
3205
+ if (!model || isHarnessDefaultModel(model)) return [];
3206
+ return ["-m", model];
3207
+ }
3208
+ function parseKimiResult(raw) {
3209
+ const trimmed = raw.trim();
3210
+ if (!trimmed) return null;
3211
+ let lastAssistant = null;
3212
+ let sawEvent = false;
3213
+ for (const line of trimmed.split(/\r?\n/)) {
3214
+ const s = line.trim();
3215
+ if (!s) continue;
3216
+ let parsed;
3217
+ try {
3218
+ parsed = JSON.parse(s);
3219
+ } catch {
3220
+ continue;
3221
+ }
3222
+ if (typeof parsed !== "object" || parsed === null) continue;
3223
+ sawEvent = true;
3224
+ const rec = parsed;
3225
+ if (rec.role === "assistant" && typeof rec.content === "string") lastAssistant = rec.content;
3226
+ }
3227
+ if (!sawEvent || lastAssistant === null) return null;
3228
+ return {
3229
+ costUsd: 0,
3230
+ 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"
3231
+ };
3232
+ }
3233
+ var kimiExecutor;
3234
+ var init_kimi = __esm({
3235
+ "src/executors/kimi.ts"() {
3236
+ "use strict";
3237
+ init_src();
3238
+ init_swarmHome();
3239
+ init_swarmFiles();
3240
+ kimiExecutor = {
3241
+ id: "kimi",
3242
+ title: "Kimi Code CLI (kimi)",
3243
+ binEnv: "SWARM_KIMI_BIN",
3244
+ install: {
3245
+ 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).",
3246
+ pkg: "kimi-code",
3247
+ command: "curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash",
3248
+ windowsCommand: "irm https://code.kimi.com/kimi-code/install.ps1 | iex"
3249
+ },
3250
+ resolveBin: (env) => resolveKimiBin(env ?? process.env),
3251
+ plan: (spec) => {
3252
+ const home = ensureKimiHome(spec.worktree, spec.realHome);
3253
+ const mcpJson = kimiMcpJson(spec);
3254
+ writeFileSync5(join8(home, "mcp.json"), mcpJson);
3255
+ writeFileSync5(join8(spec.worktree, SWARM_MCP_CONFIG_FILE), mcpJson);
3256
+ const args = [
3257
+ // `--add-dir` стоит первым: настоящий флаг kimi, по нему реконсайл узнаёт
3258
+ // worktree живого процесса после рестарта демона (worktreeFromKimiCmd).
3259
+ "--add-dir",
3260
+ spec.worktree,
3261
+ "--output-format",
3262
+ "stream-json",
3263
+ ...spec.skillDirs.flatMap((dir) => ["--skills-dir", dir]),
3264
+ ...spec.continueSession ? ["--continue"] : [],
3265
+ ...modelArgs2(spec.model),
3266
+ "-p",
3267
+ spec.prompt
3268
+ ];
3269
+ return { bin: resolveKimiBin(), args, env: { KIMI_CODE_HOME: home } };
3270
+ },
3271
+ parseResult(raw) {
3272
+ return parseKimiResult(raw);
3273
+ },
3274
+ session: {
3275
+ exists: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree)) !== null,
3276
+ mtimeMs: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree))
3277
+ },
3278
+ probe: {
3279
+ args: ["-p", "ok", "--output-format", "stream-json"],
3280
+ limitPattern: /usage limit|quota|rate.limit|too many requests/i,
3281
+ authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
3282
+ }
3283
+ };
3284
+ }
3285
+ });
3286
+
3087
3287
  // src/liveModels.ts
3088
3288
  import { execFile } from "child_process";
3089
3289
  function parseGrokDefaultModel(out) {
@@ -3211,16 +3411,19 @@ var init_executors = __esm({
3211
3411
  init_claudeCode();
3212
3412
  init_codex();
3213
3413
  init_grok();
3414
+ init_kimi();
3214
3415
  init_swarmModels();
3215
3416
  init_types2();
3216
3417
  init_claudeCode();
3217
3418
  init_codex();
3218
3419
  init_grok();
3420
+ init_kimi();
3219
3421
  DEFAULT_EXECUTOR_ID = "claude-code";
3220
3422
  EXECUTORS = {
3221
3423
  [claudeCodeExecutor.id]: claudeCodeExecutor,
3222
3424
  [codexExecutor.id]: codexExecutor,
3223
- [grokExecutor.id]: grokExecutor
3425
+ [grokExecutor.id]: grokExecutor,
3426
+ [kimiExecutor.id]: kimiExecutor
3224
3427
  };
3225
3428
  }
3226
3429
  });
@@ -3327,8 +3530,8 @@ __export(config_exports, {
3327
3530
  restEndpoint: () => restEndpoint,
3328
3531
  reviewCutoffAt: () => reviewCutoffAt
3329
3532
  });
3330
- import { basename, join as join8, resolve } from "path";
3331
- import { readFileSync as readFileSync4, realpathSync, renameSync as renameSync2, writeFileSync as writeFileSync5 } from "fs";
3533
+ import { basename, join as join9, resolve } from "path";
3534
+ import { readFileSync as readFileSync5, realpathSync, renameSync as renameSync2, writeFileSync as writeFileSync6 } from "fs";
3332
3535
  function normalizeRepo(repo) {
3333
3536
  const r = (repo ?? "").trim();
3334
3537
  if (!r) return "";
@@ -3342,10 +3545,10 @@ function effectiveRepoOf(repo, fallback) {
3342
3545
  return normalizeRepo(repo || fallback || "");
3343
3546
  }
3344
3547
  function droneWorktreePath(worktreesDir, repo, slug) {
3345
- return join8(droneWorktreeRoot(worktreesDir, repo), slug);
3548
+ return join9(droneWorktreeRoot(worktreesDir, repo), slug);
3346
3549
  }
3347
3550
  function droneWorktreeRoot(worktreesDir, repo) {
3348
- return join8(worktreesDir, basename(normalizeRepo(repo)));
3551
+ return join9(worktreesDir, basename(normalizeRepo(repo)));
3349
3552
  }
3350
3553
  function resolveEffectiveWorktreesDir(deps) {
3351
3554
  if (deps.envOverride) return deps.envOverride;
@@ -3393,21 +3596,21 @@ function mcpEndpoint(api, path = TASKLESS_MCP_PATH) {
3393
3596
  }
3394
3597
  function tokenFromFile() {
3395
3598
  try {
3396
- return readFileSync4(join8(SWARM_HOME, "token"), "utf8").trim();
3599
+ return readFileSync5(join9(SWARM_HOME, "token"), "utf8").trim();
3397
3600
  } catch {
3398
3601
  return "";
3399
3602
  }
3400
3603
  }
3401
3604
  function reviewCutoffAt() {
3402
3605
  try {
3403
- const raw = JSON.parse(readFileSync4(REVIEW_CUTOFF_PATH, "utf8"));
3606
+ const raw = JSON.parse(readFileSync5(REVIEW_CUTOFF_PATH, "utf8"));
3404
3607
  if (raw.at) return raw.at;
3405
3608
  } catch {
3406
3609
  }
3407
3610
  const at = stamp();
3408
3611
  try {
3409
3612
  const tmp = `${REVIEW_CUTOFF_PATH}.tmp`;
3410
- writeFileSync5(tmp, JSON.stringify({ at }));
3613
+ writeFileSync6(tmp, JSON.stringify({ at }));
3411
3614
  renameSync2(tmp, REVIEW_CUTOFF_PATH);
3412
3615
  } catch {
3413
3616
  }
@@ -3421,25 +3624,25 @@ var init_config = __esm({
3421
3624
  init_executors();
3422
3625
  init_swarmHome();
3423
3626
  init_swarmHome();
3424
- DB_PATH = process.env.SWARM_DB || join8(SWARM_HOME, "swarm.db");
3627
+ DB_PATH = process.env.SWARM_DB || join9(SWARM_HOME, "swarm.db");
3425
3628
  EXECUTOR = resolveExecutor(process.env.SWARM_EXECUTOR);
3426
- DRONE_HOME = process.env.SWARM_DRONE_HOME || join8(SWARM_HOME, "drone-home");
3629
+ DRONE_HOME = process.env.SWARM_DRONE_HOME || join9(SWARM_HOME, "drone-home");
3427
3630
  DRONE_HOME_ISOLATION = process.env.SWARM_DRONE_ISOLATE_HOME !== "0" && process.platform !== "win32";
3428
3631
  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");
3632
+ WORKTREES_NOINDEX_DIR = join9(SWARM_HOME, "worktrees.noindex");
3633
+ WORKTREES_LEGACY_DIR = join9(SWARM_HOME, "worktrees");
3431
3634
  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");
3635
+ RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS || join9(SWARM_HOME, "run-logs");
3636
+ DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG || join9(SWARM_HOME, "overmind.log");
3434
3637
  DAEMON_LOG_MAX_BYTES = envNum("SWARM_DAEMON_LOG_MAX_BYTES", 16 * 1024 * 1024);
3435
3638
  DAEMON_LOG_KEEP = envNum("SWARM_DAEMON_LOG_KEEP", 2);
3436
3639
  DAEMON_LOG_CHECK_MS = envNum("SWARM_DAEMON_LOG_CHECK_MS", 6e4);
3437
3640
  DIST_BUILD = true;
3438
3641
  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");
3642
+ SWARM_OUTBOX = process.env.SWARM_OUTBOX || join9(SWARM_HOME, "outbox.jsonl");
3440
3643
  SWARM_MAX_IN_FLIGHT = Math.trunc(envNum("SWARM_MAX_IN_FLIGHT", 3));
3441
3644
  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");
3645
+ ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR || join9(SWARM_HOME, "env-cache");
3443
3646
  ENV_CACHE_ENABLED = process.env.SWARM_ENV_CACHE !== "0";
3444
3647
  ENV_CACHE_KEEP = Math.trunc(envNum("SWARM_ENV_CACHE_KEEP", 4));
3445
3648
  SWARM_MAX_LOAD_FACTOR = envNum("SWARM_MAX_LOAD_FACTOR", 0.9);
@@ -3469,15 +3672,15 @@ var init_config = __esm({
3469
3672
  DRONE_CHANNEL_ENABLED = process.env.SWARM_DRONE_CHANNEL !== "0";
3470
3673
  DRONE_CHANNEL_PORT = Number(process.env.SWARM_DRONE_CHANNEL_PORT) || 7421;
3471
3674
  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");
3675
+ DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET || join9(SWARM_HOME, "drone-channel.key");
3473
3676
  DRONE_CHANNEL_GRACE_MS = envNum("SWARM_DRONE_CHANNEL_GRACE_MS", 12e4);
3474
- HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join8(SWARM_HOME, "overmind.heartbeat");
3677
+ HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join9(SWARM_HOME, "overmind.heartbeat");
3475
3678
  HEARTBEAT_STALE_MS = Number(process.env.SWARM_HEARTBEAT_STALE_MS) || 3e4;
3476
3679
  SWARM_REPO = process.env.SWARM_REPO || "";
3477
3680
  SWARM_SCAN_DEPTH = Number(process.env.SWARM_SCAN_DEPTH) || 3;
3478
3681
  SWARM_REPO_PATHS = (process.env.SWARM_REPOS || SWARM_REPO).split(",").map((s) => s.trim()).filter(Boolean);
3479
3682
  SWARM_SCAN_ROOTS_RAW = process.env.SWARM_SCAN_ROOTS || "";
3480
- REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join8(SWARM_HOME, "repo-map.json");
3683
+ REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join9(SWARM_HOME, "repo-map.json");
3481
3684
  SWARM_REPO_MAP_MS = envNum("SWARM_REPO_MAP_MS", 15 * 6e4);
3482
3685
  SWARM_REPO_SCAN_TTL_MS = envNum("SWARM_REPO_SCAN_TTL_MS", 24 * 60 * 6e4);
3483
3686
  TASKLESS_API = process.env.TASKLESS_API || "https://taskless.ru";
@@ -3492,7 +3695,7 @@ var init_config = __esm({
3492
3695
  SWARM_AUTO_REVIEW = process.env.SWARM_AUTO_REVIEW !== "0";
3493
3696
  SWARM_AUTO_VERIFY = process.env.SWARM_AUTO_VERIFY !== "0";
3494
3697
  SWARM_MERGE_QUEUE = process.env.SWARM_MERGE_QUEUE !== "0";
3495
- REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join8(SWARM_HOME, "review-cutoff.json");
3698
+ REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join9(SWARM_HOME, "review-cutoff.json");
3496
3699
  SWARM_REVIEW_CAP = Math.trunc(envNum("SWARM_REVIEW_CAP", 1));
3497
3700
  SWARM_STORM_URL = process.env.SWARM_STORM_URL || "";
3498
3701
  WEB_PORT = Number(process.env.SWARM_WEB_PORT) || 7420;
@@ -3532,7 +3735,7 @@ var init_quietExec = __esm({
3532
3735
 
3533
3736
  // src/resources.ts
3534
3737
  import os from "os";
3535
- import { readFileSync as readFileSync5, statfsSync } from "fs";
3738
+ import { readFileSync as readFileSync6, statfsSync } from "fs";
3536
3739
  function isTransientResourceError(e) {
3537
3740
  const code = e?.code;
3538
3741
  return code === "ENFILE" || code === "EMFILE" || code === "EAGAIN";
@@ -3590,7 +3793,7 @@ function fileDescriptorLoadRatio() {
3590
3793
  }
3591
3794
  if (process.platform === "linux") {
3592
3795
  try {
3593
- const [allocated, , max] = readFileSync5("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
3796
+ const [allocated, , max] = readFileSync6("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
3594
3797
  if (Number.isFinite(allocated ?? NaN) && Number.isFinite(max ?? NaN) && max) return allocated / max;
3595
3798
  } catch {
3596
3799
  }
@@ -4043,11 +4246,11 @@ var init_store = __esm({
4043
4246
  });
4044
4247
 
4045
4248
  // src/agentToken.ts
4046
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2 } from "fs";
4047
- import { join as join9 } from "path";
4249
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync7, unlinkSync as unlinkSync2 } from "fs";
4250
+ import { join as join10 } from "path";
4048
4251
  function loadAgentToken() {
4049
4252
  try {
4050
- const s = JSON.parse(readFileSync6(STORE_PATH, "utf8"));
4253
+ const s = JSON.parse(readFileSync7(STORE_PATH, "utf8"));
4051
4254
  return s.token ? s : null;
4052
4255
  } catch {
4053
4256
  return null;
@@ -4100,7 +4303,7 @@ var init_agentToken = __esm({
4100
4303
  "src/agentToken.ts"() {
4101
4304
  "use strict";
4102
4305
  init_config();
4103
- STORE_PATH = join9(SWARM_HOME, "agent.json");
4306
+ STORE_PATH = join10(SWARM_HOME, "agent.json");
4104
4307
  base = (api) => api.replace(/\/$/, "");
4105
4308
  TOKEN_PROBE_TIMEOUT_MS = 8e3;
4106
4309
  }
@@ -4214,15 +4417,15 @@ var init_toolFailure = __esm({
4214
4417
  });
4215
4418
 
4216
4419
  // src/heartbeat.ts
4217
- import { readFileSync as readFileSync8, renameSync as renameSync4, writeFileSync as writeFileSync8 } from "fs";
4420
+ import { readFileSync as readFileSync9, renameSync as renameSync4, writeFileSync as writeFileSync9 } from "fs";
4218
4421
  function writeHeartbeat(path, now) {
4219
4422
  const tmp = `${path}.tmp`;
4220
- writeFileSync8(tmp, String(now));
4423
+ writeFileSync9(tmp, String(now));
4221
4424
  renameSync4(tmp, path);
4222
4425
  }
4223
4426
  function readHeartbeat(path) {
4224
4427
  try {
4225
- const ms = Number(readFileSync8(path, "utf8").trim());
4428
+ const ms = Number(readFileSync9(path, "utf8").trim());
4226
4429
  return Number.isFinite(ms) ? ms : null;
4227
4430
  } catch {
4228
4431
  return null;
@@ -4390,7 +4593,7 @@ var init_netTimeout = __esm({
4390
4593
  });
4391
4594
 
4392
4595
  // src/procList.ts
4393
- import { readFileSync as readFileSync15 } from "fs";
4596
+ import { readFileSync as readFileSync16 } from "fs";
4394
4597
  function parsePsRows(out) {
4395
4598
  const rows = [];
4396
4599
  for (const line of out.split("\n")) {
@@ -4500,7 +4703,7 @@ function processStartedAt(pid, opts = {}) {
4500
4703
  const platform = opts.platform ?? process.platform;
4501
4704
  if (!Number.isInteger(pid) || pid <= 0 || platform === "win32") return null;
4502
4705
  if (platform === "linux") {
4503
- const readFile2 = opts.readFile ?? ((p) => readFileSync15(p, "utf8"));
4706
+ const readFile2 = opts.readFile ?? ((p) => readFileSync16(p, "utf8"));
4504
4707
  try {
4505
4708
  const stat2 = readFile2(`/proc/${pid}/stat`);
4506
4709
  const ticks = Number(stat2.slice(stat2.lastIndexOf(")") + 1).trim().split(/\s+/)[19]);
@@ -4752,9 +4955,9 @@ var init_procCleanup = __esm({
4752
4955
  });
4753
4956
 
4754
4957
  // src/git.ts
4755
- import { existsSync as existsSync13, readdirSync as readdirSync13, realpathSync as realpathSync2, statSync as statSync11 } from "fs";
4958
+ import { existsSync as existsSync14, readdirSync as readdirSync14, realpathSync as realpathSync2, statSync as statSync12 } from "fs";
4756
4959
  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";
4960
+ import { isAbsolute as isAbsolute3, join as join23, resolve as resolve3, sep as sep2 } from "path";
4758
4961
  import { $ as $2 } from "execa";
4759
4962
  function gitNet(repo, args, timeoutMs) {
4760
4963
  return withHardTimeout(
@@ -4776,14 +4979,14 @@ async function reclaimStaleWorktree(repo, worktree) {
4776
4979
  await detachWorktree(repo, worktree);
4777
4980
  }
4778
4981
  async function inspectWorktreePath(path) {
4779
- if (!existsSync13(path)) return "free";
4982
+ if (!existsSync14(path)) return "free";
4780
4983
  try {
4781
- if (readdirSync13(path).length === 0) return "free";
4984
+ if (readdirSync14(path).length === 0) return "free";
4782
4985
  } catch {
4783
4986
  return "orphan";
4784
4987
  }
4785
4988
  try {
4786
- if (statSync11(join22(path, ".git")).isDirectory()) return "main-checkout";
4989
+ if (statSync12(join23(path, ".git")).isDirectory()) return "main-checkout";
4787
4990
  } catch {
4788
4991
  }
4789
4992
  const top = await $2({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
@@ -4822,7 +5025,7 @@ async function clearWorktreePath(repo, path, branch, opts = {}) {
4822
5025
  await detachWorktree(repo, path);
4823
5026
  opts.onStaleReclaim?.(path);
4824
5027
  }
4825
- if (!existsSync13(path)) return;
5028
+ if (!existsSync14(path)) return;
4826
5029
  await parkOrphanDir(repo, path, branch);
4827
5030
  }
4828
5031
  async function parkOrphanDir(repo, path, branch) {
@@ -4843,7 +5046,7 @@ async function parkOrphanDir(repo, path, branch) {
4843
5046
  }
4844
5047
  function isLinkedWorktree(dir) {
4845
5048
  try {
4846
- return statSync11(join22(dir, ".git")).isFile();
5049
+ return statSync12(join23(dir, ".git")).isFile();
4847
5050
  } catch {
4848
5051
  return false;
4849
5052
  }
@@ -4855,7 +5058,7 @@ async function detachWorktree(repo, worktree) {
4855
5058
  }
4856
5059
  }
4857
5060
  async function ensureWorktreeDirGone(worktree) {
4858
- if (!existsSync13(worktree)) return false;
5061
+ if (!existsSync14(worktree)) return false;
4859
5062
  if (!isLinkedWorktree(worktree)) {
4860
5063
  console.error(
4861
5064
  `[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 +5073,7 @@ async function ensureWorktreeDirGone(worktree) {
4870
5073
  );
4871
5074
  return true;
4872
5075
  }
4873
- if (existsSync13(worktree)) {
5076
+ if (existsSync14(worktree)) {
4874
5077
  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
5078
  }
4876
5079
  return true;
@@ -4919,7 +5122,7 @@ async function checkoutWorktree(repo, path, branch, opts) {
4919
5122
  }
4920
5123
  const busyAt = await worktreeForBranch(repo, branch);
4921
5124
  if (busyAt) {
4922
- const exists = existsSync13(busyAt);
5125
+ const exists = existsSync14(busyAt);
4923
5126
  const live2 = exists && (opts.isWorktreeHeldLive ? await opts.isWorktreeHeldLive(busyAt) : true);
4924
5127
  if (live2) throw new WorktreeBusyError(branch, busyAt);
4925
5128
  if (exists && await worktreeDirty(busyAt)) throw new WorktreeBusyError(branch, busyAt);
@@ -4955,8 +5158,8 @@ async function ensureGitExcluded(worktree, pattern) {
4955
5158
  try {
4956
5159
  const commonDir = await gitPath(worktree, "--git-common-dir");
4957
5160
  if (!commonDir) return false;
4958
- const infoDir = join22(commonDir, "info");
4959
- const excludeFile = join22(infoDir, "exclude");
5161
+ const infoDir = join23(commonDir, "info");
5162
+ const excludeFile = join23(infoDir, "exclude");
4960
5163
  let current = "";
4961
5164
  try {
4962
5165
  current = await readFile(excludeFile, "utf8");
@@ -4976,7 +5179,7 @@ async function gitPath(worktree, flag) {
4976
5179
  const out = await $2({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
4977
5180
  const raw = out.stdout.trim();
4978
5181
  if (out.exitCode !== 0 || !raw) return null;
4979
- return isAbsolute3(raw) ? raw : join22(worktree, raw);
5182
+ return isAbsolute3(raw) ? raw : join23(worktree, raw);
4980
5183
  }
4981
5184
  async function ensureWorktreeHygiene(worktree) {
4982
5185
  for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
@@ -4986,12 +5189,12 @@ async function installGuardHooks(worktree) {
4986
5189
  try {
4987
5190
  const gitDir = await gitPath(worktree, "--git-dir");
4988
5191
  if (!gitDir) return false;
4989
- const hooksDir = join22(gitDir, "swarm-hooks");
5192
+ const hooksDir = join23(gitDir, "swarm-hooks");
4990
5193
  const prev = await previousHooksPath(worktree);
4991
5194
  await mkdir(hooksDir, { recursive: true });
4992
5195
  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);
5196
+ await writeFile(join23(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
5197
+ await chmod(join23(hooksDir, hook), 493);
4995
5198
  }
4996
5199
  await $2`git -C ${worktree} config extensions.worktreeConfig true`;
4997
5200
  await $2`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
@@ -5010,7 +5213,7 @@ async function previousHooksPath(worktree) {
5010
5213
  if (out.exitCode === 0 && value) return value;
5011
5214
  }
5012
5215
  const commonDir = await gitPath(worktree, "--git-common-dir");
5013
- return commonDir ? join22(commonDir, "hooks") : null;
5216
+ return commonDir ? join23(commonDir, "hooks") : null;
5014
5217
  }
5015
5218
  async function removeWorktree(repo, path) {
5016
5219
  const branch = (await $2({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
@@ -5035,7 +5238,7 @@ async function worktreeDirty(path) {
5035
5238
  async function repairMovedWorktrees(targetDir) {
5036
5239
  const subdirs = (dir) => {
5037
5240
  try {
5038
- return readdirSync13(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join22(dir, d.name));
5241
+ return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join23(dir, d.name));
5039
5242
  } catch {
5040
5243
  return [];
5041
5244
  }
@@ -5172,18 +5375,18 @@ __export(droneChannel_exports, {
5172
5375
  verifyLocalCliToken: () => verifyLocalCliToken
5173
5376
  });
5174
5377
  import { createHmac, randomBytes, timingSafeEqual } from "crypto";
5175
- import { chmodSync as chmodSync2, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync13 } from "fs";
5378
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "fs";
5176
5379
  import { dirname as dirname5 } from "path";
5177
5380
  import { serve } from "@hono/node-server";
5178
5381
  function loadChannelSecret(path) {
5179
5382
  try {
5180
- const s = readFileSync20(path, "utf8").trim();
5383
+ const s = readFileSync21(path, "utf8").trim();
5181
5384
  if (s.length >= 32) return s;
5182
5385
  } catch {
5183
5386
  }
5184
5387
  const secret = randomBytes(32).toString("hex");
5185
- mkdirSync11(dirname5(path), { recursive: true });
5186
- writeFileSync13(path, secret, { mode: 384 });
5388
+ mkdirSync12(dirname5(path), { recursive: true });
5389
+ writeFileSync14(path, secret, { mode: 384 });
5187
5390
  try {
5188
5391
  chmodSync2(path, 384);
5189
5392
  } catch {
@@ -5573,7 +5776,7 @@ var init_droneChannel = __esm({
5573
5776
 
5574
5777
  // src/attachments.ts
5575
5778
  import { mkdir as mkdir3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
5576
- import { join as join27 } from "path";
5779
+ import { join as join28 } from "path";
5577
5780
  function attachmentsFromDoc(doc, origin) {
5578
5781
  const out = [];
5579
5782
  const walk2 = (node) => {
@@ -5664,7 +5867,7 @@ async function materializeAttachments(opts) {
5664
5867
  };
5665
5868
  const result = { files: [], skipped: [] };
5666
5869
  if (opts.refs.length === 0) return result;
5667
- const dir = join27(opts.worktree, ATTACHMENTS_DIR);
5870
+ const dir = join28(opts.worktree, ATTACHMENTS_DIR);
5668
5871
  await io.removeDir(dir);
5669
5872
  let dirReady = false;
5670
5873
  let total = 0;
@@ -5710,7 +5913,7 @@ async function materializeAttachments(opts) {
5710
5913
  await io.mkdir(dir);
5711
5914
  dirReady = true;
5712
5915
  }
5713
- await io.writeFile(join27(dir, name), file.bytes);
5916
+ await io.writeFile(join28(dir, name), file.bytes);
5714
5917
  } catch (e) {
5715
5918
  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
5919
  continue;
@@ -5863,7 +6066,7 @@ var init_attachments = __esm({
5863
6066
 
5864
6067
  // src/shotUpload.ts
5865
6068
  import { readFile as fsReadFile } from "fs/promises";
5866
- import { basename as basename4, isAbsolute as isAbsolute4, join as join28 } from "path";
6069
+ import { basename as basename4, isAbsolute as isAbsolute4, join as join29 } from "path";
5867
6070
  function shotMimetype(path) {
5868
6071
  const dot = path.lastIndexOf(".");
5869
6072
  if (dot < 0) return null;
@@ -5889,7 +6092,7 @@ async function readShots(paths, opts) {
5889
6092
  }
5890
6093
  let bytes;
5891
6094
  try {
5892
- bytes = await read(isAbsolute4(path) ? path : join28(opts.worktree, path));
6095
+ bytes = await read(isAbsolute4(path) ? path : join29(opts.worktree, path));
5893
6096
  } catch (e) {
5894
6097
  skipped.push({ path, reason: `\u043D\u0435 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D: ${e instanceof Error ? e.message : String(e)}` });
5895
6098
  continue;
@@ -5970,8 +6173,8 @@ var init_shotUpload = __esm({
5970
6173
 
5971
6174
  // src/oauth.ts
5972
6175
  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";
6176
+ import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, unlinkSync as unlinkSync4 } from "fs";
6177
+ import { join as join30 } from "path";
5975
6178
  function makePkce() {
5976
6179
  const verifier = randomBytes2(48).toString("base64url");
5977
6180
  const challenge = createHash3("sha256").update(verifier).digest("base64url");
@@ -6055,13 +6258,13 @@ function toStore(clientId, t, now) {
6055
6258
  }
6056
6259
  function loadStore() {
6057
6260
  try {
6058
- return JSON.parse(readFileSync21(STORE_PATH2, "utf8"));
6261
+ return JSON.parse(readFileSync22(STORE_PATH2, "utf8"));
6059
6262
  } catch {
6060
6263
  return null;
6061
6264
  }
6062
6265
  }
6063
6266
  function saveStore(s) {
6064
- writeFileSync14(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
6267
+ writeFileSync15(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
6065
6268
  }
6066
6269
  function clearStore() {
6067
6270
  try {
@@ -6071,7 +6274,7 @@ function clearStore() {
6071
6274
  }
6072
6275
  function loadClientId() {
6073
6276
  try {
6074
- return JSON.parse(readFileSync21(CLIENT_PATH, "utf8")).clientId;
6277
+ return JSON.parse(readFileSync22(CLIENT_PATH, "utf8")).clientId;
6075
6278
  } catch {
6076
6279
  return null;
6077
6280
  }
@@ -6080,7 +6283,7 @@ async function ensureClientId(api, redirectUri, fetchFn = fetch) {
6080
6283
  const existing = loadClientId();
6081
6284
  if (existing) return existing;
6082
6285
  const clientId = await registerClient({ api, redirectUri }, fetchFn);
6083
- writeFileSync14(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
6286
+ writeFileSync15(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
6084
6287
  return clientId;
6085
6288
  }
6086
6289
  async function ensureAccess(store, opts = {}) {
@@ -6106,8 +6309,8 @@ var init_oauth = __esm({
6106
6309
  AUTHORIZE = "/api/oauth/authorize";
6107
6310
  TOKEN = "/api/oauth/token";
6108
6311
  SCOPE = "openid profile email taskless:full";
6109
- STORE_PATH2 = join29(SWARM_HOME, "oauth.json");
6110
- CLIENT_PATH = join29(SWARM_HOME, "oauth-client.json");
6312
+ STORE_PATH2 = join30(SWARM_HOME, "oauth.json");
6313
+ CLIENT_PATH = join30(SWARM_HOME, "oauth-client.json");
6111
6314
  base2 = (api) => api.replace(/\/$/, "");
6112
6315
  }
6113
6316
  });
@@ -6194,11 +6397,11 @@ var init_authState = __esm({
6194
6397
  });
6195
6398
 
6196
6399
  // src/workspace.ts
6197
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, unlinkSync as unlinkSync5 } from "fs";
6198
- import { join as join30 } from "path";
6400
+ import { readFileSync as readFileSync23, writeFileSync as writeFileSync16, unlinkSync as unlinkSync5 } from "fs";
6401
+ import { join as join31 } from "path";
6199
6402
  function loadWorkspace() {
6200
6403
  try {
6201
- const w = JSON.parse(readFileSync22(WORKSPACE_PATH, "utf8"));
6404
+ const w = JSON.parse(readFileSync23(WORKSPACE_PATH, "utf8"));
6202
6405
  return w && typeof w.id === "string" && w.id ? w : null;
6203
6406
  } catch {
6204
6407
  return null;
@@ -6212,7 +6415,7 @@ var init_workspace = __esm({
6212
6415
  "src/workspace.ts"() {
6213
6416
  "use strict";
6214
6417
  init_config();
6215
- WORKSPACE_PATH = join30(SWARM_HOME, "workspace.json");
6418
+ WORKSPACE_PATH = join31(SWARM_HOME, "workspace.json");
6216
6419
  }
6217
6420
  });
6218
6421
 
@@ -6852,7 +7055,7 @@ __export(db_exports, {
6852
7055
  });
6853
7056
  import { createRequire as createRequire2 } from "module";
6854
7057
  import { randomUUID as randomUUID3 } from "crypto";
6855
- import { existsSync as existsSync17 } from "fs";
7058
+ import { existsSync as existsSync18 } from "fs";
6856
7059
  import { resolve as resolve4 } from "path";
6857
7060
  function rowToQuestion(row) {
6858
7061
  return {
@@ -7516,7 +7719,7 @@ CREATE TABLE IF NOT EXISTS imports (
7516
7719
  const repoN = normalizeRepo(repo);
7517
7720
  const already = this.db.prepare("SELECT run_count FROM imports WHERE source = ?").get(abs);
7518
7721
  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}`);
7722
+ if (!existsSync18(abs)) throw new Error(`import-db: \u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442: ${abs}`);
7520
7723
  const src = new this.databaseCtor(abs);
7521
7724
  try {
7522
7725
  const runs = src.prepare("SELECT * FROM runs ORDER BY id").all();
@@ -7886,8 +8089,8 @@ var init_droneStore = __esm({
7886
8089
 
7887
8090
  // src/overmind.ts
7888
8091
  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";
8092
+ import { existsSync as existsSync23, readFileSync as readFileSync27, readdirSync as readdirSync16, renameSync as renameSync12, statSync as statSync15 } from "fs";
8093
+ import { basename as basename6, dirname as dirname6, join as join38 } from "path";
7891
8094
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
7892
8095
  import { spawn as spawn4 } from "child_process";
7893
8096
 
@@ -7967,7 +8170,7 @@ init_config();
7967
8170
  init_resources();
7968
8171
  init_names2();
7969
8172
  init_storm();
7970
- import { appendFileSync, existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "fs";
8173
+ import { appendFileSync, existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "fs";
7971
8174
  import { dirname as dirname2 } from "path";
7972
8175
  import { randomUUID } from "crypto";
7973
8176
 
@@ -8026,12 +8229,12 @@ init_store();
8026
8229
  init_toolFailure();
8027
8230
 
8028
8231
  // 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";
8232
+ import { closeSync, existsSync as existsSync8, openSync, readSync, readdirSync as readdirSync8, statSync as statSync7 } from "fs";
8233
+ import { join as join12 } from "path";
8031
8234
 
8032
8235
  // 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";
8236
+ import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync7, renameSync as renameSync3, statSync as statSync6 } from "fs";
8237
+ import { join as join11 } from "path";
8035
8238
  var LEGACY_RUN_LOGS_SUBDIR = "legacy";
8036
8239
  function runLogDirName(runLogKey) {
8037
8240
  const safe2 = runLogKey.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^[-_]+|[-_]+$/g, "");
@@ -8039,12 +8242,12 @@ function runLogDirName(runLogKey) {
8039
8242
  return /^\d+$/.test(safe2) ? `k-${safe2}` : safe2;
8040
8243
  }
8041
8244
  function runLogDirPath(runLogsDir, runLogKey) {
8042
- return join10(runLogsDir, runLogDirName(runLogKey));
8245
+ return join11(runLogsDir, runLogDirName(runLogKey));
8043
8246
  }
8044
8247
  function findRunLogDir(runLogsDir, keys) {
8045
8248
  for (const key of keys) {
8046
8249
  const dir = runLogDirPath(runLogsDir, key);
8047
- if (existsSync6(dir)) return dir;
8250
+ if (existsSync7(dir)) return dir;
8048
8251
  }
8049
8252
  return null;
8050
8253
  }
@@ -8054,10 +8257,10 @@ function runLogDirForWrite(runLogsDir, keys) {
8054
8257
  return findRunLogDir(runLogsDir, keys) ?? runLogDirPath(runLogsDir, canonical);
8055
8258
  }
8056
8259
  function sweepLegacyRunLogs(runLogsDir) {
8057
- const legacyDir = join10(runLogsDir, LEGACY_RUN_LOGS_SUBDIR);
8260
+ const legacyDir = join11(runLogsDir, LEGACY_RUN_LOGS_SUBDIR);
8058
8261
  let entries;
8059
8262
  try {
8060
- entries = readdirSync6(runLogsDir);
8263
+ entries = readdirSync7(runLogsDir);
8061
8264
  } catch {
8062
8265
  return { moved: 0, failed: 0, legacyDir };
8063
8266
  }
@@ -8065,12 +8268,12 @@ function sweepLegacyRunLogs(runLogsDir) {
8065
8268
  let failed = 0;
8066
8269
  for (const name of entries) {
8067
8270
  if (!/^\d+$/.test(name)) continue;
8068
- const from = join10(runLogsDir, name);
8271
+ const from = join11(runLogsDir, name);
8069
8272
  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}`);
8273
+ if (!statSync6(from).isDirectory()) continue;
8274
+ mkdirSync7(legacyDir, { recursive: true });
8275
+ let to = join11(legacyDir, name);
8276
+ for (let n = 2; existsSync7(to) && n < 100; n++) to = join11(legacyDir, `${name}-${n}`);
8074
8277
  renameSync3(from, to);
8075
8278
  moved++;
8076
8279
  } catch {
@@ -8090,7 +8293,7 @@ function fileHeader(name, size, shown) {
8090
8293
  function readTail(path, opts) {
8091
8294
  let size;
8092
8295
  try {
8093
- size = statSync6(path).size;
8296
+ size = statSync7(path).size;
8094
8297
  } catch {
8095
8298
  return null;
8096
8299
  }
@@ -8125,7 +8328,7 @@ function latestRunLaunch(runLogsDir, runLogKeys) {
8125
8328
  if (!dir) return null;
8126
8329
  let files;
8127
8330
  try {
8128
- files = readdirSync7(dir);
8331
+ files = readdirSync8(dir);
8129
8332
  } catch {
8130
8333
  return null;
8131
8334
  }
@@ -8136,8 +8339,8 @@ function latestRunLaunch(runLogsDir, runLogKeys) {
8136
8339
  }
8137
8340
  if (indexes.size === 0) return null;
8138
8341
  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;
8342
+ const out = [join12(dir, `${index}.json`), join12(dir, `${index}.json.done`)].find((p) => existsSync8(p)) ?? null;
8343
+ const err = existsSync8(join12(dir, `${index}.err.log`)) ? join12(dir, `${index}.err.log`) : null;
8141
8344
  return { index, total: indexes.size, out, err };
8142
8345
  }
8143
8346
  function runLogTail(runLogsDir, runLogKeys, opts) {
@@ -8302,8 +8505,8 @@ var SwarmClient = class _SwarmClient {
8302
8505
  // предикат «репо есть локально» для решения, брать ли свободный прогон.
8303
8506
  host;
8304
8507
  repoExists;
8305
- // TASWM-398: ЧЕМ эта машина исполняет прогоны — id адаптера (claude-code|codex).
8306
8508
  executorId;
8509
+ executorFor;
8307
8510
  // Зеркало.
8308
8511
  runs = /* @__PURE__ */ new Map();
8309
8512
  runtime = /* @__PURE__ */ new Map();
@@ -8418,26 +8621,27 @@ var SwarmClient = class _SwarmClient {
8418
8621
  this.repoFullNames = registry.map((e) => e.repoFullName);
8419
8622
  this.repoPathByFullName = new Map(registry.map((e) => [e.repoFullName, normalizeRepo(e.path)]));
8420
8623
  this.host = opts.host ?? null;
8421
- this.repoExists = opts.repoExists ?? existsSync8;
8624
+ this.repoExists = opts.repoExists ?? existsSync9;
8422
8625
  this.questionSyncMs = opts.questionSyncMs ?? 3e3;
8423
8626
  this.executorId = opts.executorId ?? EXECUTOR.id;
8627
+ this.executorFor = opts.executorFor;
8424
8628
  this.outboxPath = opts.outboxPath;
8425
8629
  this.mapPath = `${opts.outboxPath}.prodmap.json`;
8426
8630
  this.stormPath = `${opts.outboxPath}.storm.jsonl`;
8427
- mkdirSync7(dirname2(this.outboxPath), { recursive: true });
8631
+ mkdirSync8(dirname2(this.outboxPath), { recursive: true });
8428
8632
  this.recover();
8429
8633
  }
8430
8634
  // ── рестарт: поднять outbox (незаписанные операции) и карту runKey→prodId ─────
8431
8635
  recover() {
8432
- if (existsSync8(this.mapPath)) {
8636
+ if (existsSync9(this.mapPath)) {
8433
8637
  try {
8434
- const obj = JSON.parse(readFileSync7(this.mapPath, "utf8"));
8638
+ const obj = JSON.parse(readFileSync8(this.mapPath, "utf8"));
8435
8639
  for (const [k, v] of Object.entries(obj)) this.prodIdByKey.set(k, v);
8436
8640
  } catch {
8437
8641
  }
8438
8642
  }
8439
- if (existsSync8(this.outboxPath)) {
8440
- const txt = readFileSync7(this.outboxPath, "utf8");
8643
+ if (existsSync9(this.outboxPath)) {
8644
+ const txt = readFileSync8(this.outboxPath, "utf8");
8441
8645
  for (const line of txt.split("\n")) {
8442
8646
  const s = line.trim();
8443
8647
  if (!s) continue;
@@ -8457,10 +8661,10 @@ var SwarmClient = class _SwarmClient {
8457
8661
  // eventsLog ПЕРВЫМИ (до hydrate), в порядке файла (= хронологический); id
8458
8662
  // переприсваиваем локально (id событий — только порядок, не корреляция с продом).
8459
8663
  replayGlobalEvents() {
8460
- if (!existsSync8(this.stormPath)) return;
8664
+ if (!existsSync9(this.stormPath)) return;
8461
8665
  let txt;
8462
8666
  try {
8463
- txt = readFileSync7(this.stormPath, "utf8");
8667
+ txt = readFileSync8(this.stormPath, "utf8");
8464
8668
  } catch {
8465
8669
  return;
8466
8670
  }
@@ -8531,10 +8735,16 @@ var SwarmClient = class _SwarmClient {
8531
8735
  // в прод НЕ уходят. kind → role (плоский enum). Self-ref
8532
8736
  // прогонов hero_run_id/resolves_run_id/superseded_by → heroId/resolvesRunId/
8533
8737
  // supersededById как ОТЛОЖЕННЫЕ ссылки (RunRef) — cuid резолвится на флаше.
8534
- runFields(patch) {
8738
+ runFields(patch, run2) {
8535
8739
  const out = {};
8536
8740
  if ("status" in patch && patch.status !== void 0) out.status = patch.status;
8537
- if (patch.status === "running") out.executor = this.executorId;
8741
+ if (patch.status === "running") {
8742
+ try {
8743
+ out.executor = run2 && this.executorFor ? this.executorFor(run2) : this.executorId;
8744
+ } catch {
8745
+ out.executor = this.executorId;
8746
+ }
8747
+ }
8538
8748
  if ("area" in patch) out.area = normalizeZoneLabel(patch.area) || null;
8539
8749
  if ("model" in patch) out.model = patch.model ?? null;
8540
8750
  if ("review_model" in patch) out.reviewModel = patch.review_model ?? null;
@@ -8786,7 +8996,7 @@ var SwarmClient = class _SwarmClient {
8786
8996
  d[k] = v;
8787
8997
  }
8788
8998
  d.updated_at = stamp();
8789
- this.enqueueRun(d, this.runFields(patch));
8999
+ this.enqueueRun(d, this.runFields(patch, this.mat(d)));
8790
9000
  return this.mat(d);
8791
9001
  }
8792
9002
  incRespawn(id) {
@@ -9457,7 +9667,7 @@ var SwarmClient = class _SwarmClient {
9457
9667
  * транзиентным сбоем ОС, который этот PR должен переживать, а не превращать в мор.
9458
9668
  */
9459
9669
  reconcileRuntime(opts) {
9460
- const wtExists = opts.worktreeExists ?? existsSync8;
9670
+ const wtExists = opts.worktreeExists ?? existsSync9;
9461
9671
  const pidByWorktree = /* @__PURE__ */ new Map();
9462
9672
  try {
9463
9673
  for (const p of opts.listProcesses()) if (p.worktree) pidByWorktree.set(p.worktree, p.pid);
@@ -10725,13 +10935,13 @@ var SwarmClient = class _SwarmClient {
10725
10935
  }
10726
10936
  persistPending() {
10727
10937
  try {
10728
- writeFileSync7(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
10938
+ writeFileSync8(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
10729
10939
  } catch {
10730
10940
  }
10731
10941
  }
10732
10942
  persistMap() {
10733
10943
  try {
10734
- writeFileSync7(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
10944
+ writeFileSync8(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
10735
10945
  } catch {
10736
10946
  }
10737
10947
  }
@@ -10833,20 +11043,20 @@ function slowPassLine(seq, done, thresholdMs = SLOW_PASS_MS) {
10833
11043
  }
10834
11044
 
10835
11045
  // 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";
11046
+ 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
11047
  var realIo = {
10838
11048
  size: (path) => {
10839
11049
  try {
10840
- return statSync7(path).size;
11050
+ return statSync8(path).size;
10841
11051
  } catch {
10842
11052
  return null;
10843
11053
  }
10844
11054
  },
10845
- copy: copyFileSync4,
11055
+ copy: copyFileSync5,
10846
11056
  rename: renameSync5,
10847
11057
  truncate: (path) => truncateSync(path, 0),
10848
11058
  unlink: unlinkSync3,
10849
- exists: existsSync9
11059
+ exists: existsSync10
10850
11060
  };
10851
11061
  var realOwnerIo = {
10852
11062
  statFd: (fd) => {
@@ -10859,7 +11069,7 @@ var realOwnerIo = {
10859
11069
  },
10860
11070
  statPath: (path) => {
10861
11071
  try {
10862
- const s = statSync7(path);
11072
+ const s = statSync8(path);
10863
11073
  return { dev: s.dev, ino: s.ino };
10864
11074
  } catch {
10865
11075
  return null;
@@ -10895,7 +11105,7 @@ function rotateDaemonLog(path, opts, io = realIo) {
10895
11105
  var teedTo = null;
10896
11106
 
10897
11107
  // src/daemonLaunch.ts
10898
- import { openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync9 } from "fs";
11108
+ import { openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync10 } from "fs";
10899
11109
  import { spawn } from "child_process";
10900
11110
  var realRespawnIo = {
10901
11111
  isTty: () => process.stdout.isTTY === true,
@@ -10995,13 +11205,13 @@ async function buildRepoRegistry(paths) {
10995
11205
  }
10996
11206
 
10997
11207
  // src/repoMemory.ts
10998
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
10999
- import { join as join12 } from "path";
11208
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
11209
+ import { join as join13 } from "path";
11000
11210
  var FILE = "repos.json";
11001
11211
  function loadRememberedRepos(home) {
11002
11212
  let raw;
11003
11213
  try {
11004
- raw = readFileSync10(join12(home, FILE), "utf8");
11214
+ raw = readFileSync11(join13(home, FILE), "utf8");
11005
11215
  } catch {
11006
11216
  return [];
11007
11217
  }
@@ -11016,7 +11226,7 @@ function loadRememberedRepos(home) {
11016
11226
  function rememberRepos(home, paths, now = () => /* @__PURE__ */ new Date()) {
11017
11227
  const clean = paths.filter((p) => p.trim().length > 0);
11018
11228
  if (clean.length === 0) return;
11019
- writeFileSync9(join12(home, FILE), `${JSON.stringify({ paths: clean, at: now().toISOString() }, null, 2)}
11229
+ writeFileSync10(join13(home, FILE), `${JSON.stringify({ paths: clean, at: now().toISOString() }, null, 2)}
11020
11230
  `);
11021
11231
  }
11022
11232
  function pickRepoPaths(args) {
@@ -11031,12 +11241,12 @@ init_src();
11031
11241
  init_config();
11032
11242
  init_linkFailure();
11033
11243
  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";
11244
+ import { readFileSync as readFileSync13, renameSync as renameSync6, writeFileSync as writeFileSync11 } from "fs";
11245
+ import { isAbsolute, join as join15, resolve as resolve2 } from "path";
11036
11246
 
11037
11247
  // src/repoScan.ts
11038
- import { readdirSync as readdirSync8, readFileSync as readFileSync11, statSync as statSync8 } from "fs";
11039
- import { join as join13 } from "path";
11248
+ import { readdirSync as readdirSync9, readFileSync as readFileSync12, statSync as statSync9 } from "fs";
11249
+ import { join as join14 } from "path";
11040
11250
  var SKIP = /* @__PURE__ */ new Set([
11041
11251
  "node_modules",
11042
11252
  "vendor",
@@ -11066,7 +11276,7 @@ function parseOriginFromGitConfig(text) {
11066
11276
  }
11067
11277
  function originOf(dir) {
11068
11278
  try {
11069
- return parseOriginFromGitConfig(readFileSync11(join13(dir, ".git", "config"), "utf8"));
11279
+ return parseOriginFromGitConfig(readFileSync12(join14(dir, ".git", "config"), "utf8"));
11070
11280
  } catch {
11071
11281
  return null;
11072
11282
  }
@@ -11095,15 +11305,15 @@ function walk(dir, depth, maxDepth, found) {
11095
11305
  }
11096
11306
  let entries;
11097
11307
  try {
11098
- entries = readdirSync8(dir);
11308
+ entries = readdirSync9(dir);
11099
11309
  } catch {
11100
11310
  return;
11101
11311
  }
11102
11312
  for (const name of entries) {
11103
11313
  if (name.startsWith(".") || SKIP.has(name)) continue;
11104
- const child = join13(dir, name);
11314
+ const child = join14(dir, name);
11105
11315
  try {
11106
- if (!statSync8(child).isDirectory()) continue;
11316
+ if (!statSync9(child).isDirectory()) continue;
11107
11317
  } catch {
11108
11318
  continue;
11109
11319
  }
@@ -11123,7 +11333,7 @@ function defaultScanRoots(home, knownPaths = []) {
11123
11333
  if (parent && parent !== p) add(parent);
11124
11334
  }
11125
11335
  for (const name of ["projects", "code", "src", "dev", "work", "repos", "git", "Projects", "Code", "Developer", "Documents/GitHub", "go/src"]) {
11126
- add(join13(home, name));
11336
+ add(join14(home, name));
11127
11337
  }
11128
11338
  return out;
11129
11339
  }
@@ -11137,7 +11347,7 @@ function resolveScanRoots(raw, home = homedir5(), knownPaths = []) {
11137
11347
  for (const part of v.split(",")) {
11138
11348
  const p = part.trim();
11139
11349
  if (!p) continue;
11140
- const abs = p === "~" ? home : p.startsWith("~/") ? join14(home, p.slice(2)) : isAbsolute(p) ? p : resolve2(home, p);
11350
+ const abs = p === "~" ? home : p.startsWith("~/") ? join15(home, p.slice(2)) : isAbsolute(p) ? p : resolve2(home, p);
11141
11351
  if (!out.includes(abs)) out.push(abs);
11142
11352
  }
11143
11353
  return out;
@@ -11351,7 +11561,7 @@ function repoMapRows(state) {
11351
11561
  }
11352
11562
  function loadRepoMapCache(path) {
11353
11563
  try {
11354
- const raw = JSON.parse(readFileSync12(path, "utf8"));
11564
+ const raw = JSON.parse(readFileSync13(path, "utf8"));
11355
11565
  if (!Array.isArray(raw?.entries)) return { scannedAt: null, entries: [] };
11356
11566
  return {
11357
11567
  scannedAt: typeof raw.scannedAt === "string" && raw.scannedAt ? raw.scannedAt : null,
@@ -11366,7 +11576,7 @@ function loadRepoMapCache(path) {
11366
11576
  function writeRepoMapCache(path, entries, scannedAt = stamp()) {
11367
11577
  try {
11368
11578
  const tmp = `${path}.tmp`;
11369
- writeFileSync10(tmp, JSON.stringify({ at: stamp(), scannedAt, entries }, null, 2));
11579
+ writeFileSync11(tmp, JSON.stringify({ at: stamp(), scannedAt, entries }, null, 2));
11370
11580
  renameSync6(tmp, path);
11371
11581
  } catch {
11372
11582
  }
@@ -11374,17 +11584,17 @@ function writeRepoMapCache(path, entries, scannedAt = stamp()) {
11374
11584
 
11375
11585
  // src/hostIdentity.ts
11376
11586
  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";
11587
+ import { existsSync as existsSync11, readFileSync as readFileSync14, renameSync as renameSync7, writeFileSync as writeFileSync12 } from "fs";
11588
+ import { join as join16 } from "path";
11379
11589
  import { randomUUID as randomUUID2 } from "crypto";
11380
11590
  function hostIdentityPath(home) {
11381
- return join15(home, "host.json");
11591
+ return join16(home, "host.json");
11382
11592
  }
11383
11593
  function loadHostIdentity(deps) {
11384
- const exists = deps.exists ?? existsSync10;
11385
- const readFile2 = deps.readFile ?? ((p) => readFileSync13(p, "utf8"));
11594
+ const exists = deps.exists ?? existsSync11;
11595
+ const readFile2 = deps.readFile ?? ((p) => readFileSync14(p, "utf8"));
11386
11596
  const writeFile4 = deps.writeFile ?? ((p, data) => {
11387
- writeFileSync11(`${p}.tmp`, data);
11597
+ writeFileSync12(`${p}.tmp`, data);
11388
11598
  renameSync7(`${p}.tmp`, p);
11389
11599
  });
11390
11600
  const host = deps.hostname ?? hostname;
@@ -11477,8 +11687,8 @@ function pickResumeCandidate(pausedForRelief) {
11477
11687
  }
11478
11688
 
11479
11689
  // 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";
11690
+ import { existsSync as existsSync12, readFileSync as readFileSync15, renameSync as renameSync8, writeFileSync as writeFileSync13 } from "fs";
11691
+ import { join as join17 } from "path";
11482
11692
  var numEnv3 = (name, def) => {
11483
11693
  const v = Number(process.env[name]);
11484
11694
  return Number.isFinite(v) && v > 0 ? v : def;
@@ -11513,11 +11723,11 @@ function reliefLoopTripped(entry, cfg = DEFAULT_RELIEF_LOOP_CONFIG) {
11513
11723
  return !!entry && entry.pauses >= cfg.limit;
11514
11724
  }
11515
11725
  function reliefLoopStatePath(home) {
11516
- return join16(home, "relief-loop.json");
11726
+ return join17(home, "relief-loop.json");
11517
11727
  }
11518
11728
  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"));
11729
+ const exists = io.exists ?? existsSync12;
11730
+ const readFile2 = io.readFile ?? ((p) => readFileSync15(p, "utf8"));
11521
11731
  const path = reliefLoopStatePath(home);
11522
11732
  if (!exists(path)) return {};
11523
11733
  try {
@@ -11539,7 +11749,7 @@ function loadReliefLoopState(home, now = Date.now(), io = {}, cfg = DEFAULT_RELI
11539
11749
  function saveReliefLoopState(home, state, io = {}) {
11540
11750
  const path = reliefLoopStatePath(home);
11541
11751
  const writeFile4 = io.writeFile ?? ((p, data) => {
11542
- writeFileSync12(`${p}.tmp`, data);
11752
+ writeFileSync13(`${p}.tmp`, data);
11543
11753
  renameSync8(`${p}.tmp`, p);
11544
11754
  });
11545
11755
  writeFile4(path, JSON.stringify(state, null, 2));
@@ -11701,15 +11911,15 @@ function buildReliefCostCandidates(cost, t, sustainMs, build) {
11701
11911
 
11702
11912
  // src/launcher.ts
11703
11913
  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";
11914
+ import { closeSync as closeSync4, existsSync as existsSync13, mkdirSync as mkdirSync10, openSync as openSync4, readdirSync as readdirSync11 } from "fs";
11705
11915
  import { createRequire } from "module";
11706
11916
  import { homedir as homedir6 } from "os";
11707
- import { dirname as dirname3, join as join18 } from "path";
11917
+ import { dirname as dirname3, join as join19 } from "path";
11708
11918
  import { fileURLToPath as fileURLToPath2 } from "url";
11709
11919
 
11710
11920
  // 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";
11921
+ import { lstatSync, mkdirSync as mkdirSync9, readdirSync as readdirSync10, rmSync, statSync as statSync10, symlinkSync as symlinkSync4 } from "fs";
11922
+ import { join as join18, relative, sep } from "path";
11713
11923
  var DRONE_HOME_DENY_DEFAULT = [".taskless-swarm", ".bash_history", ".zsh_history"];
11714
11924
  function droneHomeDeny(env = process.env) {
11715
11925
  const extra = (env.SWARM_DRONE_HOME_DENY || "").split(",").map((s) => s.trim()).filter(Boolean);
@@ -11727,34 +11937,34 @@ function buildDroneHome(opts) {
11727
11937
  const { realHome, droneHome } = opts;
11728
11938
  const deny = opts.deny ?? droneHomeDeny();
11729
11939
  const platform = opts.platform ?? process.platform;
11730
- mkdirSync8(droneHome, { recursive: true, mode: 448 });
11731
- const wanted = new Set(mirroredEntries(readdirSync9(realHome), deny, platform));
11940
+ mkdirSync9(droneHome, { recursive: true, mode: 448 });
11941
+ const wanted = new Set(mirroredEntries(readdirSync10(realHome), deny, platform));
11732
11942
  const rel = relative(realHome, droneHome);
11733
11943
  if (rel && !rel.startsWith("..") && !rel.includes(sep)) wanted.delete(rel);
11734
- for (const existing of readdirSync9(droneHome)) {
11944
+ for (const existing of readdirSync10(droneHome)) {
11735
11945
  if (wanted.has(existing)) continue;
11736
- const p = join17(droneHome, existing);
11946
+ const p = join18(droneHome, existing);
11737
11947
  try {
11738
11948
  if (lstatSync(p).isSymbolicLink()) rmSync(p);
11739
11949
  } catch {
11740
11950
  }
11741
11951
  }
11742
11952
  for (const name of wanted) {
11743
- const link2 = join17(droneHome, name);
11953
+ const link2 = join18(droneHome, name);
11744
11954
  try {
11745
11955
  lstatSync(link2);
11746
11956
  continue;
11747
11957
  } catch {
11748
11958
  }
11749
- const target = join17(realHome, name);
11959
+ const target = join18(realHome, name);
11750
11960
  let isDir;
11751
11961
  try {
11752
- isDir = statSync9(target).isDirectory();
11962
+ isDir = statSync10(target).isDirectory();
11753
11963
  } catch {
11754
11964
  continue;
11755
11965
  }
11756
11966
  try {
11757
- symlinkSync3(target, link2, isDir ? "junction" : "file");
11967
+ symlinkSync4(target, link2, isDir ? "junction" : "file");
11758
11968
  } catch (e) {
11759
11969
  if (e.code !== "EEXIST") throw e;
11760
11970
  }
@@ -11767,7 +11977,7 @@ var REAL_PATH_ENV_PINS = [
11767
11977
  { env: "YARN_GLOBAL_FOLDER", segments: [".yarn", "berry"] }
11768
11978
  ];
11769
11979
  function realPathEnvPins(realHome) {
11770
- return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join17(realHome, ...segments)]));
11980
+ return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join18(realHome, ...segments)]));
11771
11981
  }
11772
11982
  function dronePrivatePaths(realHome, swarmHome) {
11773
11983
  return [
@@ -11851,7 +12061,7 @@ function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
11851
12061
  const env = { ...base3 };
11852
12062
  const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
11853
12063
  if (isolate && !base3.TURBO_CACHE_DIR) {
11854
- env.TURBO_CACHE_DIR = join18(worktree, ".turbo", "cache");
12064
+ env.TURBO_CACHE_DIR = join19(worktree, ".turbo", "cache");
11855
12065
  }
11856
12066
  Object.assign(env, droneTestEnv(droneCap, base3));
11857
12067
  for (const key of DAEMON_STATE_ENV) delete env[key];
@@ -11882,21 +12092,21 @@ var DAEMON_STATE_ENV = [
11882
12092
  ...PROVIDER_TOKEN_ENV
11883
12093
  ];
11884
12094
  function bundledRoleDir(kind) {
11885
- return join18(dirname3(fileURLToPath2(import.meta.url)), "..", "roles", kind);
12095
+ return join19(dirname3(fileURLToPath2(import.meta.url)), "..", "roles", kind);
11886
12096
  }
11887
12097
  function roleDir(worktree, kind) {
11888
- return join18(worktree, ".claude", "roles", kind);
12098
+ return join19(worktree, ".claude", "roles", kind);
11889
12099
  }
11890
12100
  function roleDirs(worktree, kind) {
11891
- return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync12(dir));
12101
+ return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync13(dir));
11892
12102
  }
11893
12103
  function nextRunLogPath(runLogsDir, runLogKeys) {
11894
12104
  const dir = runLogDirForWrite(runLogsDir, runLogKeys);
11895
12105
  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 });
12106
+ mkdirSync10(dir, { recursive: true });
11897
12107
  let files = [];
11898
12108
  try {
11899
- files = readdirSync10(dir);
12109
+ files = readdirSync11(dir);
11900
12110
  } catch {
11901
12111
  }
11902
12112
  let next = 0;
@@ -11904,7 +12114,7 @@ function nextRunLogPath(runLogsDir, runLogKeys) {
11904
12114
  const m = /^(\d+)\.json/.exec(f);
11905
12115
  if (m) next = Math.max(next, Number(m[1]) + 1);
11906
12116
  }
11907
- return join18(dir, `${next}.json`);
12117
+ return join19(dir, `${next}.json`);
11908
12118
  }
11909
12119
  function openNextRunLog(runLogsDir, runLogKeys) {
11910
12120
  for (let attempt = 0; attempt < 50; attempt++) {
@@ -11996,9 +12206,9 @@ function makeLauncher(cfg) {
11996
12206
  }
11997
12207
  const realHome = cfg.droneIsolation?.realHome ?? homedir6();
11998
12208
  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"))) {
12209
+ if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync13(join19(cfg.droneIsolation.swarmHome, "token"))) {
12000
12210
  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.`
12211
+ `[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
12212
  );
12003
12213
  }
12004
12214
  const executor = cfg.executor ?? executorForRun(run2, cfg.swarmModels?.() ?? null);
@@ -12060,8 +12270,8 @@ function makeLauncher(cfg) {
12060
12270
  init_procCleanup();
12061
12271
 
12062
12272
  // 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";
12273
+ import { readFileSync as readFileSync17, readdirSync as readdirSync12, renameSync as renameSync9, statSync as statSync11 } from "fs";
12274
+ import { join as join20 } from "path";
12065
12275
  init_executors();
12066
12276
  init_swarmModels();
12067
12277
  var UNPROCESSED_LOG_RE = /^\d+\.json$/;
@@ -12069,7 +12279,7 @@ var SEGMENT_LOG_RE = /^(\d+)\.json(\.done)?$/;
12069
12279
  var RESCUE_OPEN_WINDOW_MAX_MS = 12 * 60 * 60 * 1e3;
12070
12280
  function unprocessedLogFiles(dir) {
12071
12281
  try {
12072
- return readdirSync11(dir).filter((f) => UNPROCESSED_LOG_RE.test(f));
12282
+ return readdirSync12(dir).filter((f) => UNPROCESSED_LOG_RE.test(f));
12073
12283
  } catch {
12074
12284
  return [];
12075
12285
  }
@@ -12078,7 +12288,7 @@ function segmentStarts(dir) {
12078
12288
  const starts = /* @__PURE__ */ new Map();
12079
12289
  let entries;
12080
12290
  try {
12081
- entries = readdirSync11(dir);
12291
+ entries = readdirSync12(dir);
12082
12292
  } catch {
12083
12293
  return starts;
12084
12294
  }
@@ -12086,7 +12296,7 @@ function segmentStarts(dir) {
12086
12296
  const m = SEGMENT_LOG_RE.exec(f);
12087
12297
  if (!m) continue;
12088
12298
  try {
12089
- const st = statSync10(join19(dir, f));
12299
+ const st = statSync11(join20(dir, f));
12090
12300
  starts.set(Number(m[1]), st.birthtimeMs > 0 ? st.birthtimeMs : st.ctimeMs);
12091
12301
  } catch {
12092
12302
  }
@@ -12139,10 +12349,10 @@ function accountRunCost(deps, run2) {
12139
12349
  let unmeasured = 0;
12140
12350
  const processed = [];
12141
12351
  for (const f of files) {
12142
- const full = join19(dir, f);
12352
+ const full = join20(dir, f);
12143
12353
  let raw = null;
12144
12354
  try {
12145
- raw = readFileSync16(full, "utf8");
12355
+ raw = readFileSync17(full, "utf8");
12146
12356
  } catch {
12147
12357
  continue;
12148
12358
  }
@@ -12196,8 +12406,8 @@ function makeCostSweeper(deps) {
12196
12406
  }
12197
12407
 
12198
12408
  // src/runOutcome.ts
12199
- import { readdirSync as readdirSync12, readFileSync as readFileSync17 } from "fs";
12200
- import { join as join20 } from "path";
12409
+ import { readdirSync as readdirSync13, readFileSync as readFileSync18 } from "fs";
12410
+ import { join as join21 } from "path";
12201
12411
  init_executors();
12202
12412
  function endedItself(outcome) {
12203
12413
  return outcome === "graceful" || outcome === "budget" || outcome === "aborted";
@@ -12211,7 +12421,7 @@ function readLatestResultRaw(runLogsDir, runLogKeys) {
12211
12421
  if (!dir) return null;
12212
12422
  let files;
12213
12423
  try {
12214
- files = readdirSync12(dir);
12424
+ files = readdirSync13(dir);
12215
12425
  } catch {
12216
12426
  return null;
12217
12427
  }
@@ -12224,7 +12434,7 @@ function readLatestResultRaw(runLogsDir, runLogKeys) {
12224
12434
  }
12225
12435
  if (!latest) return null;
12226
12436
  try {
12227
- return readFileSync17(join20(dir, latest.name), "utf8");
12437
+ return readFileSync18(join21(dir, latest.name), "utf8");
12228
12438
  } catch {
12229
12439
  return null;
12230
12440
  }
@@ -12261,7 +12471,7 @@ init_src();
12261
12471
  init_swarmModels();
12262
12472
  init_executors();
12263
12473
  import { accessSync, constants } from "fs";
12264
- import { delimiter, join as join21 } from "path";
12474
+ import { delimiter, join as join22 } from "path";
12265
12475
  function binRunnable(bin, env) {
12266
12476
  if (!bin) return false;
12267
12477
  if (bin.includes("/") || bin.includes("\\")) {
@@ -12277,7 +12487,7 @@ function binRunnable(bin, env) {
12277
12487
  if (!dir) continue;
12278
12488
  for (const ext of exts) {
12279
12489
  try {
12280
- accessSync(join21(dir, bin + ext), constants.X_OK);
12490
+ accessSync(join22(dir, bin + ext), constants.X_OK);
12281
12491
  return true;
12282
12492
  } catch {
12283
12493
  }
@@ -12324,20 +12534,20 @@ init_src();
12324
12534
  init_git();
12325
12535
 
12326
12536
  // src/deps.ts
12327
- import { existsSync as existsSync15, readdirSync as readdirSync14, readFileSync as readFileSync19 } from "fs";
12328
- import { join as join25 } from "path";
12537
+ import { existsSync as existsSync16, readdirSync as readdirSync15, readFileSync as readFileSync20 } from "fs";
12538
+ import { join as join26 } from "path";
12329
12539
  import { execa } from "execa";
12330
12540
 
12331
12541
  // src/prepareLock.ts
12332
12542
  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";
12543
+ import { closeSync as closeSync5, openSync as openSync5, rmSync as rmSync2, statSync as statSync13, writeSync as writeSync2 } from "fs";
12544
+ import { join as join24 } from "path";
12335
12545
  import { tmpdir } from "os";
12336
12546
  var WAIT_TIMEOUT_MS = 5 * 6e4;
12337
12547
  var POLL_MS = 300;
12338
12548
  var STALE_MS = 20 * 6e4;
12339
12549
  function machineLockPath(key, dir = tmpdir()) {
12340
- return join23(dir, `swarm-prepare-${createHash("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
12550
+ return join24(dir, `swarm-prepare-${createHash("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
12341
12551
  }
12342
12552
  function defaultTryCreate(path, content) {
12343
12553
  try {
@@ -12354,7 +12564,7 @@ function defaultTryCreate(path, content) {
12354
12564
  }
12355
12565
  function defaultAgeMs(path) {
12356
12566
  try {
12357
- return Date.now() - statSync12(path).mtimeMs;
12567
+ return Date.now() - statSync13(path).mtimeMs;
12358
12568
  } catch {
12359
12569
  return null;
12360
12570
  }
@@ -12398,8 +12608,8 @@ init_config();
12398
12608
  init_config();
12399
12609
  import { createHash as createHash2 } from "crypto";
12400
12610
  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";
12611
+ import { existsSync as existsSync15, readFileSync as readFileSync19 } from "fs";
12612
+ import { join as join25 } from "path";
12403
12613
  function fingerprint(parts) {
12404
12614
  const h = createHash2("sha256");
12405
12615
  for (const p of parts) {
@@ -12413,8 +12623,8 @@ async function cloneTree(src, dst) {
12413
12623
  const entries = await readdir(src, { withFileTypes: true });
12414
12624
  await Promise.all(
12415
12625
  entries.map(async (e) => {
12416
- const from = join24(src, e.name);
12417
- const to = join24(dst, e.name);
12626
+ const from = join25(src, e.name);
12627
+ const to = join25(dst, e.name);
12418
12628
  if (e.isDirectory()) return cloneTree(from, to);
12419
12629
  if (e.isSymbolicLink()) {
12420
12630
  return symlink(await readlink(from), to).catch(() => cp(from, to, { recursive: true, verbatimSymlinks: true }));
@@ -12427,11 +12637,11 @@ function cacheRoot(io) {
12427
12637
  return io.root ?? ENV_CACHE_DIR;
12428
12638
  }
12429
12639
  function snapshotDir(io, key) {
12430
- return join24(cacheRoot(io), key);
12640
+ return join25(cacheRoot(io), key);
12431
12641
  }
12432
12642
  function readManifest(dir) {
12433
12643
  try {
12434
- const parsed = JSON.parse(readFileSync18(join24(dir, "manifest.json"), "utf8"));
12644
+ const parsed = JSON.parse(readFileSync19(join25(dir, "manifest.json"), "utf8"));
12435
12645
  if (!parsed || typeof parsed !== "object") return null;
12436
12646
  const m = parsed;
12437
12647
  if (typeof m.key !== "string" || !Array.isArray(m.dirs)) return null;
@@ -12443,11 +12653,11 @@ function readManifest(dir) {
12443
12653
  }
12444
12654
  }
12445
12655
  function hasEnvSnapshot(key, io = {}) {
12446
- const exists = io.exists ?? existsSync14;
12447
- return exists(join24(snapshotDir(io, key), "manifest.json"));
12656
+ const exists = io.exists ?? existsSync15;
12657
+ return exists(join25(snapshotDir(io, key), "manifest.json"));
12448
12658
  }
12449
12659
  async function restoreEnvSnapshot(worktree, key, io = {}) {
12450
- const exists = io.exists ?? existsSync14;
12660
+ const exists = io.exists ?? existsSync15;
12451
12661
  const clone = io.clone ?? cloneTree;
12452
12662
  const dir = snapshotDir(io, key);
12453
12663
  const manifest = readManifest(dir);
@@ -12456,13 +12666,13 @@ async function restoreEnvSnapshot(worktree, key, io = {}) {
12456
12666
  try {
12457
12667
  for (let i = 0; i < manifest.dirs.length; i++) {
12458
12668
  const rel = manifest.dirs[i] ?? "";
12459
- const target = join24(worktree, rel);
12669
+ const target = join25(worktree, rel);
12460
12670
  if (exists(target)) continue;
12461
- await clone(join24(dir, "trees", String(i)), target);
12671
+ await clone(join25(dir, "trees", String(i)), target);
12462
12672
  made.push(rel);
12463
12673
  }
12464
12674
  } catch {
12465
- for (const rel of made) await rm2(join24(worktree, rel), { recursive: true, force: true }).catch(() => {
12675
+ for (const rel of made) await rm2(join25(worktree, rel), { recursive: true, force: true }).catch(() => {
12466
12676
  });
12467
12677
  return null;
12468
12678
  }
@@ -12475,19 +12685,19 @@ async function touch(dir) {
12475
12685
  });
12476
12686
  }
12477
12687
  async function saveEnvSnapshot(worktree, key, dirs, io = {}) {
12478
- const exists = io.exists ?? existsSync14;
12688
+ const exists = io.exists ?? existsSync15;
12479
12689
  const clone = io.clone ?? cloneTree;
12480
12690
  if (hasEnvSnapshot(key, io)) return true;
12481
- const present = dirs.filter((rel) => exists(join24(worktree, rel)));
12691
+ const present = dirs.filter((rel) => exists(join25(worktree, rel)));
12482
12692
  if (!present.length) return false;
12483
12693
  const root = cacheRoot(io);
12484
- const tmp = join24(root, `.tmp-${key}-${process.pid}`);
12694
+ const tmp = join25(root, `.tmp-${key}-${process.pid}`);
12485
12695
  try {
12486
12696
  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)));
12697
+ await mkdir2(join25(tmp, "trees"), { recursive: true });
12698
+ for (let i = 0; i < present.length; i++) await clone(join25(worktree, present[i] ?? ""), join25(tmp, "trees", String(i)));
12489
12699
  const manifest = { key, dirs: present, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
12490
- await writeFile2(join24(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
12700
+ await writeFile2(join25(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
12491
12701
  await rename2(tmp, snapshotDir(io, key));
12492
12702
  return true;
12493
12703
  } catch {
@@ -12507,13 +12717,13 @@ async function pruneEnvSnapshots(io = {}) {
12507
12717
  }
12508
12718
  const withTime = [];
12509
12719
  for (const name of names) {
12510
- const s = await stat(join24(root, name)).catch(() => null);
12720
+ const s = await stat(join25(root, name)).catch(() => null);
12511
12721
  if (s) withTime.push({ name, mtime: s.mtimeMs });
12512
12722
  }
12513
12723
  withTime.sort((a, b) => b.mtime - a.mtime);
12514
12724
  let removed = 0;
12515
12725
  for (const { name } of withTime.slice(Math.max(0, keep))) {
12516
- await rm2(join24(root, name), { recursive: true, force: true }).catch(() => {
12726
+ await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
12517
12727
  });
12518
12728
  removed++;
12519
12729
  }
@@ -12529,9 +12739,9 @@ async function sweepEnvCacheTemp(io = {}) {
12529
12739
  }
12530
12740
  let removed = 0;
12531
12741
  for (const name of names) {
12532
- const s = await lstat(join24(root, name)).catch(() => null);
12742
+ const s = await lstat(join25(root, name)).catch(() => null);
12533
12743
  if (!s || Date.now() - s.mtimeMs < 60 * 6e4) continue;
12534
- await rm2(join24(root, name), { recursive: true, force: true }).catch(() => {
12744
+ await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
12535
12745
  });
12536
12746
  removed++;
12537
12747
  }
@@ -12558,21 +12768,21 @@ async function runCommand(cmd, worktree) {
12558
12768
  }
12559
12769
  function safeReadText(p) {
12560
12770
  try {
12561
- return readFileSync19(p, "utf8");
12771
+ return readFileSync20(p, "utf8");
12562
12772
  } catch {
12563
12773
  return null;
12564
12774
  }
12565
12775
  }
12566
12776
  function safeListDirs(p) {
12567
12777
  try {
12568
- return readdirSync14(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
12778
+ return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
12569
12779
  } catch {
12570
12780
  return [];
12571
12781
  }
12572
12782
  }
12573
12783
  function safeListFiles(p) {
12574
12784
  try {
12575
- return readdirSync14(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
12785
+ return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
12576
12786
  } catch {
12577
12787
  return [];
12578
12788
  }
@@ -12598,21 +12808,21 @@ function overridePlan(override) {
12598
12808
  };
12599
12809
  }
12600
12810
  function detectPackageManager(worktree, io = {}) {
12601
- const exists = io.exists ?? existsSync15;
12811
+ const exists = io.exists ?? existsSync16;
12602
12812
  const readText = io.readText ?? safeReadText;
12603
- const hasPkgJson = exists(join25(worktree, "package.json"));
12813
+ const hasPkgJson = exists(join26(worktree, "package.json"));
12604
12814
  if (!hasPkgJson) {
12605
- if (exists(join25(worktree, "deno.json")) || exists(join25(worktree, "deno.jsonc")) || exists(join25(worktree, "deno.lock"))) return "deno";
12815
+ if (exists(join26(worktree, "deno.json")) || exists(join26(worktree, "deno.jsonc")) || exists(join26(worktree, "deno.lock"))) return "deno";
12606
12816
  return null;
12607
12817
  }
12608
- const pkg = readJson(readText, join25(worktree, "package.json"));
12818
+ const pkg = readJson(readText, join26(worktree, "package.json"));
12609
12819
  const declared = typeof pkg?.packageManager === "string" ? pkg.packageManager.split("@")[0] : void 0;
12610
12820
  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";
12821
+ if (exists(join26(worktree, "bun.lock")) || exists(join26(worktree, "bun.lockb"))) return "bun";
12822
+ if (exists(join26(worktree, "pnpm-lock.yaml"))) return "pnpm";
12823
+ if (exists(join26(worktree, "yarn.lock"))) return "yarn";
12824
+ if (exists(join26(worktree, "package-lock.json"))) return "npm";
12825
+ if (exists(join26(worktree, "deno.lock"))) return "deno";
12616
12826
  return "npm";
12617
12827
  }
12618
12828
  function jsInstallCommand(pm) {
@@ -12668,7 +12878,7 @@ var ECOSYSTEM_MARKERS = [
12668
12878
  // конфигурация — дело сборки, не подготовки
12669
12879
  ];
12670
12880
  function detectPlan(worktree, io) {
12671
- const exists = io.exists ?? existsSync15;
12881
+ const exists = io.exists ?? existsSync16;
12672
12882
  const listFiles = io.listFiles ?? safeListFiles;
12673
12883
  const pm = detectPackageManager(worktree, io);
12674
12884
  if (pm) {
@@ -12676,7 +12886,7 @@ function detectPlan(worktree, io) {
12676
12886
  // node_modules на месте — установку пропускаем (быстрый путь переиспользованного worktree).
12677
12887
  // У deno каталога может не быть вовсе (кэш в DENO_DIR) — тогда `deno install` отработает
12678
12888
  // заново, но он дешёвый: тянет из того же общего кэша.
12679
- { label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join25(worktree, "node_modules"), source: "detect" }
12889
+ { label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join26(worktree, "node_modules"), source: "detect" }
12680
12890
  ];
12681
12891
  for (const target of workspaceBuildTargets(worktree, io)) {
12682
12892
  commands.push({ label: `\u0441\u0431\u043E\u0440\u043A\u0430 ${target.name}`, run: jsRunScript(pm, "build"), cwd: target.dir, source: "detect" });
@@ -12685,12 +12895,12 @@ function detectPlan(worktree, io) {
12685
12895
  return { source: "detect", ecosystem: `node/${pm}`, commands };
12686
12896
  }
12687
12897
  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));
12898
+ const hit = marker.files.some((f) => exists(join26(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
12689
12899
  if (!hit) continue;
12690
12900
  let ecosystem = marker.ecosystem;
12691
12901
  let command = marker.command;
12692
12902
  for (const refine of marker.refine ?? []) {
12693
- if (!exists(join25(worktree, refine.file))) continue;
12903
+ if (!exists(join26(worktree, refine.file))) continue;
12694
12904
  ecosystem = refine.ecosystem;
12695
12905
  command = refine.command;
12696
12906
  break;
@@ -12747,12 +12957,12 @@ var CI_INSTALL_PATTERNS = [
12747
12957
  function ciWorkflowPlan(worktree, io) {
12748
12958
  const readText = io.readText ?? safeReadText;
12749
12959
  const listFiles = io.listFiles ?? safeListFiles;
12750
- const dir = join25(worktree, ".github", "workflows");
12960
+ const dir = join26(worktree, ".github", "workflows");
12751
12961
  const files = listFiles(dir).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml"));
12752
12962
  const seen = /* @__PURE__ */ new Set();
12753
12963
  const commands = [];
12754
12964
  for (const name of files.sort()) {
12755
- const yaml = readText(join25(dir, name));
12965
+ const yaml = readText(join26(dir, name));
12756
12966
  if (yaml === null) continue;
12757
12967
  for (const raw of workflowRunLines(yaml)) {
12758
12968
  const line = raw.replace(/\s+/g, " ").trim();
@@ -12767,7 +12977,7 @@ function ciWorkflowPlan(worktree, io) {
12767
12977
  return commands.length ? { source: "ci-workflow", ecosystem: "ci-\u043A\u043E\u043D\u0444\u0438\u0433", commands } : null;
12768
12978
  }
12769
12979
  function workspaceGlobs(worktree, readText) {
12770
- const yaml = readText(join25(worktree, "pnpm-workspace.yaml"));
12980
+ const yaml = readText(join26(worktree, "pnpm-workspace.yaml"));
12771
12981
  if (yaml !== null) {
12772
12982
  const globs = [];
12773
12983
  let inPackages = false;
@@ -12787,7 +12997,7 @@ function workspaceGlobs(worktree, readText) {
12787
12997
  }
12788
12998
  if (globs.length) return globs;
12789
12999
  }
12790
- const pkg = readJson(readText, join25(worktree, "package.json"));
13000
+ const pkg = readJson(readText, join26(worktree, "package.json"));
12791
13001
  const ws = pkg?.workspaces;
12792
13002
  const list = Array.isArray(ws) ? ws : Array.isArray(ws?.packages) ? ws.packages : [];
12793
13003
  return list.filter((g) => typeof g === "string");
@@ -12798,14 +13008,14 @@ function workspaceDirs(worktree, globs, io) {
12798
13008
  if (glob.startsWith("!")) continue;
12799
13009
  const star = glob.indexOf("*");
12800
13010
  if (star === -1) {
12801
- const dir = join25(worktree, glob);
12802
- if (io.exists(join25(dir, "package.json"))) dirs.add(dir);
13011
+ const dir = join26(worktree, glob);
13012
+ if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
12803
13013
  continue;
12804
13014
  }
12805
- const base3 = join25(worktree, glob.slice(0, star).replace(/\/$/, ""));
13015
+ const base3 = join26(worktree, glob.slice(0, star).replace(/\/$/, ""));
12806
13016
  for (const name of io.listDirs(base3)) {
12807
- const dir = join25(base3, name);
12808
- if (io.exists(join25(dir, "package.json"))) dirs.add(dir);
13017
+ const dir = join26(base3, name);
13018
+ if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
12809
13019
  }
12810
13020
  }
12811
13021
  return [...dirs];
@@ -12826,18 +13036,18 @@ function entryPaths(pkg) {
12826
13036
  return out;
12827
13037
  }
12828
13038
  function workspaceBuildTargets(worktree, io = {}) {
12829
- const exists = io.exists ?? existsSync15;
13039
+ const exists = io.exists ?? existsSync16;
12830
13040
  const readText = io.readText ?? safeReadText;
12831
13041
  const listDirs = io.listDirs ?? safeListDirs;
12832
13042
  const globs = workspaceGlobs(worktree, readText);
12833
13043
  if (!globs.length) return [];
12834
13044
  const pkgs = [];
12835
13045
  for (const dir of workspaceDirs(worktree, globs, { exists, listDirs })) {
12836
- const pkg = readJson(readText, join25(dir, "package.json"));
13046
+ const pkg = readJson(readText, join26(dir, "package.json"));
12837
13047
  if (!pkg || typeof pkg.name !== "string") continue;
12838
13048
  const scripts = pkg.scripts ?? {};
12839
13049
  const entries = entryPaths(pkg);
12840
- const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join25(dir, e)));
13050
+ const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join26(dir, e)));
12841
13051
  const deps = Object.keys({ ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} });
12842
13052
  pkgs.push({ name: pkg.name, dir, deps, needsBuild });
12843
13053
  }
@@ -12865,7 +13075,7 @@ function devDatabaseUrl(worktree, io = {}) {
12865
13075
  const fromEnv = (io.env ?? process.env).DATABASE_URL;
12866
13076
  if (fromEnv && fromEnv.trim()) return fromEnv.trim();
12867
13077
  for (const file of [".env", ".env.example"]) {
12868
- const raw = readText(join25(worktree, file));
13078
+ const raw = readText(join26(worktree, file));
12869
13079
  if (raw === null) continue;
12870
13080
  const m = /^\s*(?:export\s+)?DATABASE_URL\s*=\s*(.*)$/m.exec(raw);
12871
13081
  const value = (m?.[1] ?? "").trim().replace(/^['"]|['"]$/g, "");
@@ -12881,11 +13091,11 @@ function isLocalDatabase(url) {
12881
13091
  }
12882
13092
  }
12883
13093
  function prismaPackages(worktree, io) {
12884
- const exists = io.exists ?? existsSync15;
13094
+ const exists = io.exists ?? existsSync16;
12885
13095
  const readText = io.readText ?? safeReadText;
12886
13096
  const listDirs = io.listDirs ?? safeListDirs;
12887
13097
  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);
13098
+ return dirs.filter((dir) => exists(join26(dir, "prisma", "schema.prisma")) && listDirs(join26(dir, "prisma", "migrations")).length > 0);
12889
13099
  }
12890
13100
  function jsExecBin(pm, command) {
12891
13101
  switch (pm) {
@@ -12915,25 +13125,25 @@ function migrateCommands(worktree, pm, io) {
12915
13125
  var ENV_DEFINING_FILES = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock", "bun.lockb", "deno.lock", "pnpm-workspace.yaml"];
12916
13126
  function envCachePlan(worktree, io = {}) {
12917
13127
  if (!ENV_CACHE_ENABLED) return null;
12918
- const exists = io.exists ?? existsSync15;
13128
+ const exists = io.exists ?? existsSync16;
12919
13129
  const readText = io.readText ?? safeReadText;
12920
13130
  const listDirs = io.listDirs ?? safeListDirs;
12921
13131
  const pm = detectPackageManager(worktree, io);
12922
13132
  if (!pm) return null;
12923
13133
  const parts = [`pm:${pm}`];
12924
13134
  for (const name of ENV_DEFINING_FILES) {
12925
- const raw = readText(join25(worktree, name));
13135
+ const raw = readText(join26(worktree, name));
12926
13136
  if (raw !== null) parts.push(`${name}
12927
13137
  ${raw}`);
12928
13138
  }
12929
13139
  const pkgDirs = workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs });
12930
13140
  const rels = pkgDirs.map((dir) => dir.slice(worktree.length + 1)).sort();
12931
13141
  for (const rel of ["", ...rels]) {
12932
- const raw = readText(join25(worktree, rel, "package.json"));
13142
+ const raw = readText(join26(worktree, rel, "package.json"));
12933
13143
  if (raw !== null) parts.push(`${rel}/package.json
12934
13144
  ${raw}`);
12935
13145
  }
12936
- return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join25(rel, "node_modules"))] };
13146
+ return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join26(rel, "node_modules"))] };
12937
13147
  }
12938
13148
  function planPrepare(worktree, io = {}) {
12939
13149
  const plan = overridePlan(io.override) ?? detectPlan(worktree, io) ?? ciWorkflowPlan(worktree, io);
@@ -12941,7 +13151,7 @@ function planPrepare(worktree, io = {}) {
12941
13151
  return { ...plan, commands: plan.commands.slice(0, MAX_PLAN_COMMANDS) };
12942
13152
  }
12943
13153
  async function ensureWorktreeDeps(worktree, io = {}) {
12944
- const exists = io.exists ?? existsSync15;
13154
+ const exists = io.exists ?? existsSync16;
12945
13155
  const exec = io.exec ?? ((cmd) => runCommand(cmd, worktree));
12946
13156
  const approve = io.approve ?? (() => true);
12947
13157
  const cachePlan = envCachePlan(worktree, io);
@@ -12958,7 +13168,7 @@ async function ensureWorktreeDeps(worktree, io = {}) {
12958
13168
  restored: [],
12959
13169
  cached: false
12960
13170
  };
12961
- if (cachePlan && !exists(join25(worktree, "node_modules"))) {
13171
+ if (cachePlan && !exists(join26(worktree, "node_modules"))) {
12962
13172
  report.restored = await restoreEnvSnapshot(worktree, cachePlan.key, cacheIO) ?? [];
12963
13173
  }
12964
13174
  const plan = planPrepare(worktree, io);
@@ -13045,8 +13255,8 @@ function depsPromptNotice(report) {
13045
13255
 
13046
13256
  // src/orchestrator.ts
13047
13257
  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";
13258
+ import { existsSync as existsSync17, mkdirSync as mkdirSync11, rmSync as rmSync3 } from "fs";
13259
+ import { join as join27, dirname as dirname4 } from "path";
13050
13260
  function droneLaunchedText(workdir, pid) {
13051
13261
  return `\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0432 ${workdir} (pid ${pid})`;
13052
13262
  }
@@ -13055,7 +13265,7 @@ function droneLaunchedPid(text) {
13055
13265
  return m ? Number(m[1]) : null;
13056
13266
  }
13057
13267
  function repolessRunDir(worktreesDir, taskSlug) {
13058
- return join26(dirname4(worktreesDir), "runs", taskSlug);
13268
+ return join27(dirname4(worktreesDir), "runs", taskSlug);
13059
13269
  }
13060
13270
  var WORKTREE_HELD_STATUSES = /* @__PURE__ */ new Set(["running", "blocked", "review", "paused", "storm_dead"]);
13061
13271
  function worktreePathHeldLive(db, path, exceptRunId) {
@@ -13112,11 +13322,11 @@ function healTaskSlug(db, run2, task) {
13112
13322
  async function spawnDrone(deps, run2) {
13113
13323
  if (run2.repoless) {
13114
13324
  const workdir = repolessRunDir(deps.worktreesDir, run2.task_slug);
13115
- if (existsSync16(workdir)) {
13325
+ if (existsSync17(workdir)) {
13116
13326
  rmSync3(workdir, { recursive: true, force: true });
13117
13327
  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
13328
  }
13119
- mkdirSync10(workdir, { recursive: true });
13329
+ mkdirSync11(workdir, { recursive: true });
13120
13330
  if (run2.area && deps.db.runningAreas("").includes(run2.area)) throw new AreaBusyError(run2.area);
13121
13331
  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
13332
  const built2 = await deps.buildPrompt(run2, workdir);
@@ -13333,7 +13543,7 @@ function parkReasonUnretriable(reason) {
13333
13543
  // package.json
13334
13544
  var package_default = {
13335
13545
  name: "@taskless-app/swarm",
13336
- version: "0.6.81",
13546
+ version: "0.6.83",
13337
13547
  type: "module",
13338
13548
  description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
13339
13549
  keywords: [
@@ -13385,7 +13595,7 @@ var package_default = {
13385
13595
  undici: "^7.30.1",
13386
13596
  zod: "3.25.76"
13387
13597
  },
13388
- gitHead: "0a4c6ee0b5f07c122a325e3df3bc3361ee01b312"
13598
+ gitHead: "8fd42459bb1cbcdad50ebef72bcb3c36a5e2d1c6"
13389
13599
  };
13390
13600
 
13391
13601
  // src/version.ts
@@ -14205,8 +14415,8 @@ import { z } from "zod";
14205
14415
  init_git();
14206
14416
 
14207
14417
  // src/diff.ts
14208
- import { statSync as statSync13 } from "fs";
14209
- import { join as join31 } from "path";
14418
+ import { statSync as statSync14 } from "fs";
14419
+ import { join as join32 } from "path";
14210
14420
  import { $ as $4 } from "execa";
14211
14421
  var MAX_FILES = 200;
14212
14422
  var MAX_LINES_PER_FILE = 1500;
@@ -14349,7 +14559,7 @@ async function resolveBase(wt, baseBranch) {
14349
14559
  }
14350
14560
  function mtime(path) {
14351
14561
  try {
14352
- return statSync13(path).mtimeMs;
14562
+ return statSync14(path).mtimeMs;
14353
14563
  } catch {
14354
14564
  return 0;
14355
14565
  }
@@ -14374,7 +14584,7 @@ async function collectRunDiff(worktree, opts = {}) {
14374
14584
  files.push(pf);
14375
14585
  }
14376
14586
  }
14377
- files.sort((a, b) => mtime(join31(worktree, b.path)) - mtime(join31(worktree, a.path)));
14587
+ files.sort((a, b) => mtime(join32(worktree, b.path)) - mtime(join32(worktree, a.path)));
14378
14588
  const truncatedFiles = files.length > MAX_FILES;
14379
14589
  if (truncatedFiles) files = files.slice(0, MAX_FILES);
14380
14590
  const added = files.reduce((s, f) => s + f.added, 0);
@@ -16792,23 +17002,23 @@ async function prodClearMergeIntent(runId, deps = {}) {
16792
17002
  }
16793
17003
 
16794
17004
  // src/envGate.ts
16795
- import { existsSync as existsSync19 } from "fs";
16796
- import { join as join33 } from "path";
17005
+ import { existsSync as existsSync20 } from "fs";
17006
+ import { join as join34 } from "path";
16797
17007
  import { createConnection } from "net";
16798
17008
  import { execa as execa2 } from "execa";
16799
17009
 
16800
17010
  // src/platform.ts
16801
17011
  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";
17012
+ import { accessSync as accessSync2, constants as constants2, existsSync as existsSync19, readFileSync as readFileSync24, realpathSync as realpathSync3 } from "fs";
17013
+ import { delimiter as delimiter2, join as join33, posix as posix2, win32 } from "path";
16804
17014
  function resolveCommandPath(name, env = process.env, platform = process.platform) {
16805
- if (name.includes("/") || name.includes("\\")) return existsSync18(name) ? name : null;
17015
+ if (name.includes("/") || name.includes("\\")) return existsSync19(name) ? name : null;
16806
17016
  const dirs = (env.PATH ?? env.Path ?? "").split(delimiter2).filter(Boolean);
16807
17017
  const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
16808
17018
  for (const dir of dirs) {
16809
17019
  for (const ext of exts) {
16810
- const candidate = join32(dir, name + ext);
16811
- if (existsSync18(candidate)) return candidate;
17020
+ const candidate = join33(dir, name + ext);
17021
+ if (existsSync19(candidate)) return candidate;
16812
17022
  }
16813
17023
  }
16814
17024
  return null;
@@ -16977,8 +17187,8 @@ var COMPOSE_MARKERS = [
16977
17187
  "compose.yaml"
16978
17188
  ];
16979
17189
  function detectRequirements(repo, io = {}) {
16980
- const exists = io.exists ?? existsSync19;
16981
- const marker = COMPOSE_MARKERS.find((f) => exists(join33(repo, f)));
17190
+ const exists = io.exists ?? existsSync20;
17191
+ const marker = COMPOSE_MARKERS.find((f) => exists(join34(repo, f)));
16982
17192
  return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
16983
17193
  }
16984
17194
  function resolveRequirements(repo, declared, io = {}) {
@@ -18734,21 +18944,21 @@ function closeWebServer(server) {
18734
18944
 
18735
18945
  // src/hostCommands.ts
18736
18946
  init_src();
18737
- import { readFileSync as readFileSync24, renameSync as renameSync10, writeFileSync as writeFileSync16 } from "fs";
18738
- import { join as join34 } from "path";
18947
+ import { readFileSync as readFileSync25, renameSync as renameSync10, writeFileSync as writeFileSync17 } from "fs";
18948
+ import { join as join35 } from "path";
18739
18949
  function hostCommandStatePath(home) {
18740
- return join34(home, "host-command.json");
18950
+ return join35(home, "host-command.json");
18741
18951
  }
18742
18952
  function readState(path) {
18743
18953
  try {
18744
- return JSON.parse(readFileSync24(path, "utf8"));
18954
+ return JSON.parse(readFileSync25(path, "utf8"));
18745
18955
  } catch {
18746
18956
  return {};
18747
18957
  }
18748
18958
  }
18749
18959
  function writeState(path, state) {
18750
18960
  try {
18751
- writeFileSync16(`${path}.tmp`, JSON.stringify(state));
18961
+ writeFileSync17(`${path}.tmp`, JSON.stringify(state));
18752
18962
  renameSync10(`${path}.tmp`, path);
18753
18963
  } catch {
18754
18964
  }
@@ -18911,8 +19121,8 @@ async function doRestart(cmd, opts, note) {
18911
19121
 
18912
19122
  // src/selfUpdate.ts
18913
19123
  init_git();
18914
- import { existsSync as existsSync20 } from "fs";
18915
- import { join as join35 } from "path";
19124
+ import { existsSync as existsSync21 } from "fs";
19125
+ import { join as join36 } from "path";
18916
19126
  import { $ as $5 } from "execa";
18917
19127
 
18918
19128
  // src/cliIo.ts
@@ -18945,7 +19155,7 @@ function tail(text, max = 400) {
18945
19155
  }
18946
19156
  async function runSelfUpdate(io) {
18947
19157
  const run2 = io.run ?? defaultRun;
18948
- const exists = io.exists ?? existsSync20;
19158
+ const exists = io.exists ?? existsSync21;
18949
19159
  const repo = io.repo;
18950
19160
  await io.onStep("fetch", "\u0442\u044F\u043D\u0443 \u0441\u0432\u0435\u0436\u0438\u0439 \u043A\u043E\u0434");
18951
19161
  const fetched = await run2("git", ["-C", repo, "fetch", "--quiet", "origin"], repo);
@@ -18974,7 +19184,7 @@ async function runSelfUpdate(io) {
18974
19184
  };
18975
19185
  }
18976
19186
  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"))) {
19187
+ if (!exists(join36(repo, "pnpm-lock.yaml"))) {
18978
19188
  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
19189
  }
18980
19190
  const installed2 = await run2("pnpm", ["install", "--frozen-lockfile"], repo);
@@ -19145,19 +19355,19 @@ async function fetchExternalStorm(url, opts = {}) {
19145
19355
  }
19146
19356
 
19147
19357
  // 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";
19358
+ import { existsSync as existsSync22, readFileSync as readFileSync26, renameSync as renameSync11, writeFileSync as writeFileSync18 } from "fs";
19359
+ import { join as join37 } from "path";
19150
19360
  var KEY_TTL_MS = 7 * 24 * 60 * 6e4;
19151
19361
  var MAX_RESOLVED = 200;
19152
19362
  function emptyState() {
19153
19363
  return { since: {}, lastFiredAt: {}, fires: {}, resolved: [], stopQuiet: null };
19154
19364
  }
19155
19365
  function anomalyStatePath(home) {
19156
- return join36(home, "anomaly-state.json");
19366
+ return join37(home, "anomaly-state.json");
19157
19367
  }
19158
19368
  function loadAnomalyState(home, now = Date.now(), io = {}) {
19159
- const exists = io.exists ?? existsSync21;
19160
- const readFile2 = io.readFile ?? ((p) => readFileSync25(p, "utf8"));
19369
+ const exists = io.exists ?? existsSync22;
19370
+ const readFile2 = io.readFile ?? ((p) => readFileSync26(p, "utf8"));
19161
19371
  const path = anomalyStatePath(home);
19162
19372
  if (!exists(path)) return emptyState();
19163
19373
  try {
@@ -19187,7 +19397,7 @@ function loadAnomalyState(home, now = Date.now(), io = {}) {
19187
19397
  function saveAnomalyState(home, state, io = {}) {
19188
19398
  const path = anomalyStatePath(home);
19189
19399
  const writeFile4 = io.writeFile ?? ((p, data) => {
19190
- writeFileSync17(`${p}.tmp`, data);
19400
+ writeFileSync18(`${p}.tmp`, data);
19191
19401
  renameSync11(`${p}.tmp`, p);
19192
19402
  });
19193
19403
  writeFile4(path, JSON.stringify(state, null, 2));
@@ -19805,7 +20015,15 @@ function worktreeFromCmd(args) {
19805
20015
  const bare = quoted ? null : args.match(/--mcp-config\s+(\S+[/\\]\.swarm-mcp\.json)/);
19806
20016
  const path = quoted?.[1] ?? bare?.[1];
19807
20017
  if (path) return path.replace(/[/\\]\.swarm-mcp\.json$/, "");
19808
- return worktreeFromGrokCwd(args);
20018
+ return worktreeFromGrokCwd(args) ?? worktreeFromKimiCmd(args);
20019
+ }
20020
+ function worktreeFromKimiCmd(args) {
20021
+ const trimmed = args.trim();
20022
+ const first = trimmed.startsWith('"') ? trimmed.slice(1, trimmed.indexOf('"', 1)) : trimmed.split(/\s/)[0] ?? "";
20023
+ if (!/(?:^|[\\/])kimi(?:\.exe)?$/i.test(first)) return null;
20024
+ const quoted = args.match(/--add-dir\s+"([^"]+)"/);
20025
+ const bare = quoted ? null : args.match(/--add-dir\s+(\S+)/);
20026
+ return quoted?.[1] ?? bare?.[1] ?? null;
19809
20027
  }
19810
20028
  function worktreeFromGrokCwd(args) {
19811
20029
  const trimmed = args.trim();
@@ -20630,10 +20848,10 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
20630
20848
  }
20631
20849
  return parts.join("\n");
20632
20850
  }
20633
- var HERO_CHARTER_PATH = join37(dirname6(THIS_FILE), "..", "docs", "HERO.md");
20851
+ var HERO_CHARTER_PATH = join38(dirname6(THIS_FILE), "..", "docs", "HERO.md");
20634
20852
  function buildHeroPrompt(task, run2, taskContext, attachmentsBlock) {
20635
20853
  const name = run2.name || `#${run2.id}`;
20636
- const charter = readFileSync26(HERO_CHARTER_PATH, "utf8");
20854
+ const charter = readFileSync27(HERO_CHARTER_PATH, "utf8");
20637
20855
  const head = task ? `\u042D\u041F\u0418\u041A ${run2.task_slug}: ${task.title}
20638
20856
 
20639
20857
  ${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 +20911,9 @@ function ciTrustLine(prUrl, verifyMode, ciClosed = null) {
20693
20911
  }
20694
20912
  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
20913
  }
20696
- var REVIEW_SKILL_PATH = join37(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
20914
+ var REVIEW_SKILL_PATH = join38(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
20697
20915
  function reviewDefectClasses(skillPath = REVIEW_SKILL_PATH) {
20698
- const text = readFileSync26(skillPath, "utf8");
20916
+ const text = readFileSync27(skillPath, "utf8");
20699
20917
  const m = /^## Классы дефектов\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(text);
20700
20918
  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
20919
  return `\u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 (skill taskless-review):
@@ -21148,7 +21366,7 @@ async function wakeRun(deps, runId, opts = {}) {
21148
21366
  if (run2.status === "review" && run2.pr_url && !needsFixIteration(run2) && !stoppedForHuman) {
21149
21367
  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
21368
  }
21151
- const worktreeExists = deps.worktreeExists ?? existsSync22;
21369
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
21152
21370
  const hasTranscript = deps.hasTranscript ?? executorHasSession;
21153
21371
  const wt = run2.worktree_path;
21154
21372
  const canContinue = !!wt && worktreeExists(wt) && hasTranscript(run2);
@@ -21279,9 +21497,9 @@ function repoHasCi(deps, run2) {
21279
21497
  function repoHasCiWorkflows(worktreePath, repo) {
21280
21498
  for (const base3 of [worktreePath, repo]) {
21281
21499
  if (!base3) continue;
21282
- const dir = join37(base3, ".github", "workflows");
21500
+ const dir = join38(base3, ".github", "workflows");
21283
21501
  try {
21284
- if (readdirSync15(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
21502
+ if (readdirSync16(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
21285
21503
  } catch {
21286
21504
  }
21287
21505
  }
@@ -21503,7 +21721,7 @@ async function wakeReviewerOnCiReady(deps, run2, over) {
21503
21721
  return true;
21504
21722
  }
21505
21723
  function worktreeAndTranscriptAlive(deps, run2) {
21506
- const exists = deps.worktreeExists ?? existsSync22;
21724
+ const exists = deps.worktreeExists ?? existsSync23;
21507
21725
  const transcript = deps.hasTranscript ?? executorHasSession;
21508
21726
  const wt = run2.worktree_path;
21509
21727
  return !!wt && exists(wt) && transcript(run2);
@@ -21693,7 +21911,7 @@ async function wakeAuthorOnChanges(deps, snapshot, now, droneCap) {
21693
21911
  }
21694
21912
  const wt = run2.worktree_path;
21695
21913
  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);
21914
+ const worktreeReady = !!wtPath && (deps.worktreeExists ?? existsSync23)(wtPath);
21697
21915
  if (!worktreeReady) {
21698
21916
  const why = await freshChangesWakeBlock(deps, run2, prUrl, now);
21699
21917
  if (why) return blockFix(run2, why);
@@ -21784,7 +22002,7 @@ async function zoneConflictFor(db, models, activeFiles, run2, repo, repoFallback
21784
22002
  activeFiles.prune(holders.map((r) => r.id));
21785
22003
  const fileExists = (p) => {
21786
22004
  try {
21787
- return statSync14(join37(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
22005
+ return statSync15(join38(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
21788
22006
  } catch {
21789
22007
  return false;
21790
22008
  }
@@ -22222,7 +22440,7 @@ async function liftReturners(deps, returners, now, droneCap) {
22222
22440
  deps.returners?.delete(run2.id);
22223
22441
  continue;
22224
22442
  }
22225
- lifted = await wakeAuthorOnRedCi(deps, run2, now, entry.ci, deps.worktreeExists ?? existsSync22, deps.hasTranscript ?? executorHasSession, droneCap);
22443
+ lifted = await wakeAuthorOnRedCi(deps, run2, now, entry.ci, deps.worktreeExists ?? existsSync23, deps.hasTranscript ?? executorHasSession, droneCap);
22226
22444
  }
22227
22445
  if (lifted) deps.returners?.delete(run2.id);
22228
22446
  }
@@ -22246,7 +22464,7 @@ async function resumeWatchdogParked(deps, droneCap) {
22246
22464
  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
22465
  return;
22248
22466
  }
22249
- const worktreeExists = deps.worktreeExists ?? existsSync22;
22467
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
22250
22468
  const hasTranscript = deps.hasTranscript ?? executorHasSession;
22251
22469
  const wt = candidate.worktree_path;
22252
22470
  const canContinue = !!wt && worktreeExists(wt) && hasTranscript(candidate);
@@ -23117,7 +23335,7 @@ async function tickOnce(deps) {
23117
23335
  const now = deps.now ? deps.now() : Date.now();
23118
23336
  draftHeldThisTick.clear();
23119
23337
  fixBlockedThisTick.clear();
23120
- const worktreeExists = deps.worktreeExists ?? existsSync22;
23338
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
23121
23339
  const hasTranscript = deps.hasTranscript ?? executorHasSession;
23122
23340
  deps.stepClock?.mark("0 \u0437\u0430\u043C\u0435\u0440 \u0445\u043E\u0441\u0442\u0430");
23123
23341
  deps.sampleHost?.();
@@ -24085,7 +24303,7 @@ async function resolveConflict(deps, reviewRun) {
24085
24303
  model: reviewRun.model,
24086
24304
  review_model: reviewRun.review_model
24087
24305
  });
24088
- const wt = join37(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
24306
+ const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
24089
24307
  try {
24090
24308
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24091
24309
  await deps.git.setWorktreeIdentity(wt, resolver.name);
@@ -24166,7 +24384,7 @@ async function spawnReviewer(deps, reviewRun, files) {
24166
24384
  // (своей у ревьюера нет, TASWM-204), и коммент с вердиктом должен уехать именно туда.
24167
24385
  workspace_id: reviewRun.workspace_id
24168
24386
  });
24169
- const wt = join37(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
24387
+ const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
24170
24388
  try {
24171
24389
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24172
24390
  await deps.git.setWorktreeIdentity(wt, reviewer.name);
@@ -24247,7 +24465,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
24247
24465
  // штамп цикла: фикс-итерацию проверяет свежий верификатор
24248
24466
  workspace_id: verifiedRun.workspace_id
24249
24467
  });
24250
- const wt = join37(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
24468
+ const wt = join38(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
24251
24469
  try {
24252
24470
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24253
24471
  await deps.git.setWorktreeIdentity(wt, verifier.name);
@@ -24341,7 +24559,7 @@ async function respawnRun(deps, run2, mode, nudge) {
24341
24559
  ]);
24342
24560
  const base3 = effectiveBaseBranch(run2.base_branch, projectBase);
24343
24561
  const runToSpawn = base3 && run2.base_branch !== base3 ? deps.db.updateRun(run2.id, { base_branch: base3 }) ?? run2 : run2;
24344
- if (!existsSync22(wt)) {
24562
+ if (!existsSync23(wt)) {
24345
24563
  const branch = runToSpawn.branch || runToSpawn.task_slug;
24346
24564
  const source = await addWorktree(repo, wt, branch, {
24347
24565
  ...base3 ? { base: await remoteBaseRef(repo, base3) } : {},
@@ -24383,7 +24601,7 @@ function worktreePathPatch(run2, wt) {
24383
24601
  return run2.worktree_path === wt ? {} : { worktree_path: wt };
24384
24602
  }
24385
24603
  async function syncCrashedOnStartup(deps) {
24386
- const worktreeExists = deps.worktreeExists ?? existsSync22;
24604
+ const worktreeExists = deps.worktreeExists ?? existsSync23;
24387
24605
  let orphaned = 0;
24388
24606
  let merged = 0;
24389
24607
  let requeued = 0;
@@ -24423,7 +24641,7 @@ async function loadSqlite() {
24423
24641
  );
24424
24642
  }
24425
24643
  }
24426
- async function makeStore(repo, worktreesDir, repoFlag) {
24644
+ async function makeStore(repo, worktreesDir, repoFlag, executorFor) {
24427
24645
  const host = loadHostIdentity({
24428
24646
  home: SWARM_HOME,
24429
24647
  envHostId: process.env.SWARM_HOST_ID,
@@ -24489,7 +24707,14 @@ async function makeStore(repo, worktreesDir, repoFlag) {
24489
24707
  (repoMap.unknown ? "\u041F\u0440\u043E\u0434 \u043D\u0435 \u0441\u043A\u0430\u0437\u0430\u043B, \u043A\u0430\u043A\u0438\u0435 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u0443 \u0440\u043E\u044F, \u2014 \u043F\u0440\u043E\u0432\u0435\u0440\u044C `swarm login` \u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0441\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440\u0430. " : repoMap.missing.length ? `\u041D\u0438 \u043E\u0434\u043D\u043E\u0433\u043E \u0438\u0437 ${repoMap.missing.length} \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0435\u0432 \u0440\u043E\u044F \u0442\u0443\u0442 \u043D\u0435\u0442. ` : "\u0423 \u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0430 \u043D\u0435\u0442 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432 \u0441 \u0432\u043A\u043B\u044E\u0447\u0451\u043D\u043D\u044B\u043C \u0440\u043E\u0435\u043C. ") + "\u0415\u0441\u043B\u0438 \u043A\u043B\u043E\u043D\u044B \u043B\u0435\u0436\u0430\u0442 \u0432 \u0434\u0440\u0443\u0433\u043E\u043C \u043C\u0435\u0441\u0442\u0435 \u2014 \u0443\u043A\u0430\u0436\u0438: swarm start --repo <\u043F\u0443\u0442\u044C \u043A \u0440\u0435\u043F\u043E> (\u0437\u0430\u043F\u043E\u043C\u043D\u0438\u0442\u0441\u044F)."
24490
24708
  );
24491
24709
  }
24492
- const client = new SwarmClient({ call, outboxPath: SWARM_OUTBOX, defaultRepo: repo, repoRegistry, host });
24710
+ const client = new SwarmClient({
24711
+ call,
24712
+ outboxPath: SWARM_OUTBOX,
24713
+ defaultRepo: repo,
24714
+ repoRegistry,
24715
+ host,
24716
+ ...executorFor ? { executorFor } : {}
24717
+ });
24493
24718
  await client.hydrate();
24494
24719
  const rec = client.reconcileRuntime({ worktreesDir, listProcesses: listDroneProcesses });
24495
24720
  const adopted = await client.takeRunningLocally();
@@ -24541,10 +24766,10 @@ async function migrateWorktreesAtStartup() {
24541
24766
  legacyDir: WORKTREES_LEGACY_DIR,
24542
24767
  targetDir: WORKTREES_DIR,
24543
24768
  envOverride: process.env.SWARM_WORKTREES || "",
24544
- exists: (d) => existsSync22(d),
24769
+ exists: (d) => existsSync23(d),
24545
24770
  isNonEmptyDir: (d) => {
24546
24771
  try {
24547
- return readdirSync15(d).length > 0;
24772
+ return readdirSync16(d).length > 0;
24548
24773
  } catch {
24549
24774
  return false;
24550
24775
  }
@@ -24556,7 +24781,7 @@ async function migrateWorktreesAtStartup() {
24556
24781
  });
24557
24782
  } catch (e) {
24558
24783
  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;
24784
+ return existsSync23(WORKTREES_DIR) ? WORKTREES_DIR : WORKTREES_LEGACY_DIR;
24560
24785
  }
24561
24786
  }
24562
24787
  async function reportWorkspaceAccess(tl, db) {
@@ -24590,6 +24815,8 @@ async function runDaemon(opts) {
24590
24815
  const remembered = effectiveRepoPaths("", loadRememberedRepos(SWARM_HOME))[0];
24591
24816
  if (remembered) opts.repo = remembered;
24592
24817
  }
24818
+ let lastSwarmModels = null;
24819
+ const runModelRefPin = /* @__PURE__ */ new Map();
24593
24820
  const {
24594
24821
  store: db,
24595
24822
  reconciled,
@@ -24599,7 +24826,12 @@ async function runDaemon(opts) {
24599
24826
  prodMcp,
24600
24827
  reposServed,
24601
24828
  repoFullNameOf
24602
- } = await makeStore(opts.repo, worktreesDir, opts.repoFlag);
24829
+ } = await makeStore(
24830
+ opts.repo,
24831
+ worktreesDir,
24832
+ opts.repoFlag,
24833
+ (run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null).id
24834
+ );
24603
24835
  await preflightAuth();
24604
24836
  const outdated = outdatedLine(PACKAGE_VERSION, await latestRelease);
24605
24837
  if (outdated) console.warn(`[overmind] ${outdated}`);
@@ -24633,8 +24865,6 @@ async function runDaemon(opts) {
24633
24865
  }
24634
24866
  } : void 0;
24635
24867
  let lastDroneCap = null;
24636
- let lastSwarmModels = null;
24637
- const runModelRefPin = /* @__PURE__ */ new Map();
24638
24868
  let lastSwarmEfforts = null;
24639
24869
  let lastMaxCostUsd = null;
24640
24870
  let lastOwnCapacity = null;
@@ -25258,7 +25488,7 @@ async function runDaemon(opts) {
25258
25488
  isDirty: (p) => worktreeDirty(p),
25259
25489
  releaseWorktree: (repo, p) => releaseWorktree(repo || opts.repo, p),
25260
25490
  pruneWorktrees: (repo) => pruneWorktrees(repo || opts.repo),
25261
- worktreeExists: existsSync22,
25491
+ worktreeExists: existsSync23,
25262
25492
  liveWorktrees: () => new Set(listDroneProcesses().map((p) => p.worktree)),
25263
25493
  narrate: narrator.narrate
25264
25494
  });
@@ -25399,7 +25629,7 @@ async function runDaemon(opts) {
25399
25629
  mode,
25400
25630
  nudge
25401
25631
  ),
25402
- worktreeExists: (p) => existsSync22(p),
25632
+ worktreeExists: (p) => existsSync23(p),
25403
25633
  // TASWM-514: с этого момента считаем попытки спавна — счётчик живёт ровно одну жизнь
25404
25634
  // процесса демона и рестарт не переживает (см. preStartAttempts).
25405
25635
  startedAt: Date.now(),