@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/cli.js CHANGED
@@ -735,6 +735,25 @@ var init_modelPolicy = __esm({
735
735
  roles: { executor: "grok-4.7", review: "grok-4.7-build-fast" },
736
736
  models: ["grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5"]
737
737
  },
738
+ // Kimi Code CLI (Moonshot). Каталог — все 5 моделей из конфига владельца (09.11.2026),
739
+ // полные алиасы как в дефолтном config.toml любого kimi-code: ссылки вида
740
+ // `kimi/kimi-code/k3.1-pro` — parseModelRef режет по первому слэшу, моделью уходит
741
+ // `kimi-code/k3.1-pro` (второй слэш — часть имени). Тарифа нет: подписка, CLI цену не
742
+ // сообщает — честный ноль (costUsd=0 с предупреждением) живёт в адаптере (TASWM-630).
743
+ {
744
+ id: "kimi",
745
+ label: "Kimi (Moonshot)",
746
+ executorId: "kimi",
747
+ selectable: true,
748
+ roles: { executor: "kimi-code/k3.1-pro", review: "kimi-code/k3" },
749
+ models: [
750
+ "kimi-code/kimi-for-coding",
751
+ "kimi-code/k3",
752
+ "kimi-code/k3-256k",
753
+ "kimi-code/k3.1-pro",
754
+ "kimi-code/k3.1-pro-highspeed"
755
+ ]
756
+ },
738
757
  // TASWM-565 · шаг 1 из четырёх: провайдер в реестре ЕСТЬ, выбрать его ещё нельзя.
739
758
  // Имён моделей здесь нет СОЗНАТЕЛЬНО: у владельца подписка, состав моделей в ней нам
740
759
  // неизвестен, а выдуманное имя хуже маркера «решает Codex».
@@ -2873,6 +2892,187 @@ ${notice}` : spec.prompt;
2873
2892
  }
2874
2893
  });
2875
2894
 
2895
+ // src/executors/kimi.ts
2896
+ import { copyFileSync as copyFileSync4, existsSync as existsSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync3, statSync as statSync5, symlinkSync as symlinkSync3, writeFileSync as writeFileSync4 } from "fs";
2897
+ import { join as join7 } from "path";
2898
+ function resolveKimiBin(env = process.env) {
2899
+ return (env.SWARM_KIMI_BIN ?? "").trim() || "kimi";
2900
+ }
2901
+ function kimiHomePath(worktree, swarmHome = SWARM_HOME) {
2902
+ const key = worktree.replace(/[^A-Za-z0-9]+/g, "-").replace(/^-|-$/g, "") || "worktree";
2903
+ return join7(swarmHome, "executor-state", "kimi", key);
2904
+ }
2905
+ function kimiSessionRoot(worktree, swarmHome = SWARM_HOME) {
2906
+ return join7(kimiHomePath(worktree, swarmHome), "sessions");
2907
+ }
2908
+ function newestKimiSessionMtime(dir, depth = 4) {
2909
+ let entries;
2910
+ try {
2911
+ entries = readdirSync6(dir, { withFileTypes: true });
2912
+ } catch {
2913
+ return null;
2914
+ }
2915
+ let latest = null;
2916
+ for (const entry of entries) {
2917
+ const full = join7(dir, entry.name);
2918
+ try {
2919
+ if (entry.isDirectory()) {
2920
+ if (depth <= 0) continue;
2921
+ const nested = newestKimiSessionMtime(full, depth - 1);
2922
+ if (nested != null && (latest == null || nested > latest)) latest = nested;
2923
+ } else if (entry.isFile()) {
2924
+ const mtime2 = statSync5(full).mtimeMs;
2925
+ if (latest == null || mtime2 > latest) latest = mtime2;
2926
+ }
2927
+ } catch {
2928
+ }
2929
+ }
2930
+ return latest;
2931
+ }
2932
+ function extractModelsBlocks(config) {
2933
+ const lines = config.split(/\r?\n/);
2934
+ const blocks = [];
2935
+ let current = null;
2936
+ for (const line of lines) {
2937
+ if (/^\s*\[/.test(line)) {
2938
+ if (current) blocks.push(current);
2939
+ current = /^\s*\[(?:models|providers)\./.test(line) ? [line] : null;
2940
+ continue;
2941
+ }
2942
+ if (current) current.push(line);
2943
+ }
2944
+ if (current) blocks.push(current);
2945
+ return blocks.map((b) => b.join("\n").trimEnd()).filter((b) => b.trim() !== "");
2946
+ }
2947
+ function kimiMcpJson(spec) {
2948
+ return JSON.stringify(
2949
+ { mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
2950
+ null,
2951
+ 2
2952
+ );
2953
+ }
2954
+ function ensureKimiHome(worktree, realHome, env = process.env, swarmHome = SWARM_HOME) {
2955
+ const home = kimiHomePath(worktree, swarmHome);
2956
+ mkdirSync5(home, { recursive: true });
2957
+ const realCreds = join7((env.KIMI_CODE_HOME ?? "").trim() || join7(realHome, ".kimi-code"), "credentials");
2958
+ const link = join7(home, "credentials");
2959
+ if (existsSync5(realCreds) && !existsSync5(link)) {
2960
+ try {
2961
+ symlinkSync3(realCreds, link, "junction");
2962
+ } catch {
2963
+ try {
2964
+ mkdirSync5(link, { recursive: true });
2965
+ for (const f of readdirSync6(realCreds)) copyFileSync4(join7(realCreds, f), join7(link, f));
2966
+ } catch {
2967
+ }
2968
+ }
2969
+ }
2970
+ const realConfig = join7((env.KIMI_CODE_HOME ?? "").trim() || join7(realHome, ".kimi-code"), "config.toml");
2971
+ try {
2972
+ const raw = readFileSync3(realConfig, "utf8");
2973
+ const blocks = extractModelsBlocks(raw);
2974
+ const defaultModel = resolveShadowDefaultModel(raw, blocks);
2975
+ if (blocks.length > 0) {
2976
+ const head = defaultModel ? `default_model = "${defaultModel}"
2977
+
2978
+ ` : "";
2979
+ writeFileSync4(join7(home, "config.toml"), `${head}${blocks.join("\n\n")}
2980
+ `);
2981
+ }
2982
+ } catch {
2983
+ }
2984
+ return home;
2985
+ }
2986
+ function resolveShadowDefaultModel(config, blocks) {
2987
+ const declared = /^default_model\s*=\s*"([^"]+)"/m.exec(config)?.[1];
2988
+ if (declared?.trim()) return declared.trim();
2989
+ const firstModel = blocks.find((b) => /^\s*\[models\./.test(b));
2990
+ const alias = /^\s*\[models\."([^"]+)"\]/.exec(firstModel ?? "")?.[1];
2991
+ return alias?.trim() || null;
2992
+ }
2993
+ function modelArgs2(model) {
2994
+ if (!model || isHarnessDefaultModel(model)) return [];
2995
+ return ["-m", model];
2996
+ }
2997
+ function parseKimiResult(raw) {
2998
+ const trimmed = raw.trim();
2999
+ if (!trimmed) return null;
3000
+ let lastAssistant = null;
3001
+ let sawEvent = false;
3002
+ for (const line of trimmed.split(/\r?\n/)) {
3003
+ const s = line.trim();
3004
+ if (!s) continue;
3005
+ let parsed;
3006
+ try {
3007
+ parsed = JSON.parse(s);
3008
+ } catch {
3009
+ continue;
3010
+ }
3011
+ if (typeof parsed !== "object" || parsed === null) continue;
3012
+ sawEvent = true;
3013
+ const rec = parsed;
3014
+ if (rec.role === "assistant" && typeof rec.content === "string") lastAssistant = rec.content;
3015
+ }
3016
+ if (!sawEvent || lastAssistant === null) return null;
3017
+ return {
3018
+ costUsd: 0,
3019
+ 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"
3020
+ };
3021
+ }
3022
+ var kimiExecutor;
3023
+ var init_kimi = __esm({
3024
+ "src/executors/kimi.ts"() {
3025
+ "use strict";
3026
+ init_src();
3027
+ init_swarmHome();
3028
+ init_swarmFiles();
3029
+ kimiExecutor = {
3030
+ id: "kimi",
3031
+ title: "Kimi Code CLI (kimi)",
3032
+ binEnv: "SWARM_KIMI_BIN",
3033
+ install: {
3034
+ 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).",
3035
+ pkg: "kimi-code",
3036
+ command: "curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash",
3037
+ windowsCommand: "irm https://code.kimi.com/kimi-code/install.ps1 | iex"
3038
+ },
3039
+ resolveBin: (env) => resolveKimiBin(env ?? process.env),
3040
+ plan: (spec) => {
3041
+ const home = ensureKimiHome(spec.worktree, spec.realHome);
3042
+ const mcpJson = kimiMcpJson(spec);
3043
+ writeFileSync4(join7(home, "mcp.json"), mcpJson);
3044
+ writeFileSync4(join7(spec.worktree, SWARM_MCP_CONFIG_FILE), mcpJson);
3045
+ const args = [
3046
+ // `--add-dir` стоит первым: настоящий флаг kimi, по нему реконсайл узнаёт
3047
+ // worktree живого процесса после рестарта демона (worktreeFromKimiCmd).
3048
+ "--add-dir",
3049
+ spec.worktree,
3050
+ "--output-format",
3051
+ "stream-json",
3052
+ ...spec.skillDirs.flatMap((dir) => ["--skills-dir", dir]),
3053
+ ...spec.continueSession ? ["--continue"] : [],
3054
+ ...modelArgs2(spec.model),
3055
+ "-p",
3056
+ spec.prompt
3057
+ ];
3058
+ return { bin: resolveKimiBin(), args, env: { KIMI_CODE_HOME: home } };
3059
+ },
3060
+ parseResult(raw) {
3061
+ return parseKimiResult(raw);
3062
+ },
3063
+ session: {
3064
+ exists: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree)) !== null,
3065
+ mtimeMs: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree))
3066
+ },
3067
+ probe: {
3068
+ args: ["-p", "ok", "--output-format", "stream-json"],
3069
+ limitPattern: /usage limit|quota|rate.limit|too many requests/i,
3070
+ authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
3071
+ }
3072
+ };
3073
+ }
3074
+ });
3075
+
2876
3076
  // src/liveModels.ts
2877
3077
  import { execFile } from "child_process";
2878
3078
  function liveDefaultModel(providerId) {
@@ -2970,23 +3170,26 @@ var init_executors = __esm({
2970
3170
  init_claudeCode();
2971
3171
  init_codex();
2972
3172
  init_grok();
3173
+ init_kimi();
2973
3174
  init_swarmModels();
2974
3175
  init_types2();
2975
3176
  init_claudeCode();
2976
3177
  init_codex();
2977
3178
  init_grok();
3179
+ init_kimi();
2978
3180
  DEFAULT_EXECUTOR_ID = "claude-code";
2979
3181
  EXECUTORS = {
2980
3182
  [claudeCodeExecutor.id]: claudeCodeExecutor,
2981
3183
  [codexExecutor.id]: codexExecutor,
2982
- [grokExecutor.id]: grokExecutor
3184
+ [grokExecutor.id]: grokExecutor,
3185
+ [kimiExecutor.id]: kimiExecutor
2983
3186
  };
2984
3187
  }
2985
3188
  });
2986
3189
 
2987
3190
  // src/config.ts
2988
- import { basename, join as join7, resolve } from "path";
2989
- import { readFileSync as readFileSync3, realpathSync, renameSync, writeFileSync as writeFileSync4 } from "fs";
3191
+ import { basename, join as join8, resolve } from "path";
3192
+ import { readFileSync as readFileSync4, realpathSync, renameSync, writeFileSync as writeFileSync5 } from "fs";
2990
3193
  function normalizeRepo(repo) {
2991
3194
  const r = (repo ?? "").trim();
2992
3195
  if (!r) return "";
@@ -3000,10 +3203,10 @@ function effectiveRepoOf(repo, fallback) {
3000
3203
  return normalizeRepo(repo || fallback || "");
3001
3204
  }
3002
3205
  function droneWorktreePath(worktreesDir, repo, slug) {
3003
- return join7(droneWorktreeRoot(worktreesDir, repo), slug);
3206
+ return join8(droneWorktreeRoot(worktreesDir, repo), slug);
3004
3207
  }
3005
3208
  function droneWorktreeRoot(worktreesDir, repo) {
3006
- return join7(worktreesDir, basename(normalizeRepo(repo)));
3209
+ return join8(worktreesDir, basename(normalizeRepo(repo)));
3007
3210
  }
3008
3211
  function resolveEffectiveWorktreesDir(deps) {
3009
3212
  if (deps.envOverride) return deps.envOverride;
@@ -3030,7 +3233,7 @@ function mcpEndpoint(api, path = TASKLESS_MCP_PATH) {
3030
3233
  }
3031
3234
  function tokenFromFile() {
3032
3235
  try {
3033
- return readFileSync3(join7(SWARM_HOME, "token"), "utf8").trim();
3236
+ return readFileSync4(join8(SWARM_HOME, "token"), "utf8").trim();
3034
3237
  } catch {
3035
3238
  return "";
3036
3239
  }
@@ -3043,25 +3246,25 @@ var init_config = __esm({
3043
3246
  init_executors();
3044
3247
  init_swarmHome();
3045
3248
  init_swarmHome();
3046
- DB_PATH = process.env.SWARM_DB || join7(SWARM_HOME, "swarm.db");
3249
+ DB_PATH = process.env.SWARM_DB || join8(SWARM_HOME, "swarm.db");
3047
3250
  EXECUTOR = resolveExecutor(process.env.SWARM_EXECUTOR);
3048
- DRONE_HOME = process.env.SWARM_DRONE_HOME || join7(SWARM_HOME, "drone-home");
3251
+ DRONE_HOME = process.env.SWARM_DRONE_HOME || join8(SWARM_HOME, "drone-home");
3049
3252
  DRONE_HOME_ISOLATION = process.env.SWARM_DRONE_ISOLATE_HOME !== "0" && process.platform !== "win32";
3050
3253
  DRONE_ISOLATION = DRONE_HOME_ISOLATION ? { home: DRONE_HOME, swarmHome: SWARM_HOME } : void 0;
3051
- WORKTREES_NOINDEX_DIR = join7(SWARM_HOME, "worktrees.noindex");
3052
- WORKTREES_LEGACY_DIR = join7(SWARM_HOME, "worktrees");
3254
+ WORKTREES_NOINDEX_DIR = join8(SWARM_HOME, "worktrees.noindex");
3255
+ WORKTREES_LEGACY_DIR = join8(SWARM_HOME, "worktrees");
3053
3256
  WORKTREES_DIR = process.env.SWARM_WORKTREES || WORKTREES_NOINDEX_DIR;
3054
- RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS || join7(SWARM_HOME, "run-logs");
3055
- DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG || join7(SWARM_HOME, "overmind.log");
3257
+ RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS || join8(SWARM_HOME, "run-logs");
3258
+ DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG || join8(SWARM_HOME, "overmind.log");
3056
3259
  DAEMON_LOG_MAX_BYTES = envNum("SWARM_DAEMON_LOG_MAX_BYTES", 16 * 1024 * 1024);
3057
3260
  DAEMON_LOG_KEEP = envNum("SWARM_DAEMON_LOG_KEEP", 2);
3058
3261
  DAEMON_LOG_CHECK_MS = envNum("SWARM_DAEMON_LOG_CHECK_MS", 6e4);
3059
3262
  DIST_BUILD = true;
3060
3263
  SWARM_BACKEND = process.env.SWARM_BACKEND === "client" ? "client" : process.env.SWARM_BACKEND === "sqlite" ? "sqlite" : DIST_BUILD ? "client" : "sqlite";
3061
- SWARM_OUTBOX = process.env.SWARM_OUTBOX || join7(SWARM_HOME, "outbox.jsonl");
3264
+ SWARM_OUTBOX = process.env.SWARM_OUTBOX || join8(SWARM_HOME, "outbox.jsonl");
3062
3265
  SWARM_MAX_IN_FLIGHT = Math.trunc(envNum("SWARM_MAX_IN_FLIGHT", 3));
3063
3266
  SWARM_CLAIM_INTERVAL_MS = envNum("SWARM_CLAIM_INTERVAL_MS", 6e4);
3064
- ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR || join7(SWARM_HOME, "env-cache");
3267
+ ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR || join8(SWARM_HOME, "env-cache");
3065
3268
  ENV_CACHE_ENABLED = process.env.SWARM_ENV_CACHE !== "0";
3066
3269
  ENV_CACHE_KEEP = Math.trunc(envNum("SWARM_ENV_CACHE_KEEP", 4));
3067
3270
  SWARM_MAX_LOAD_FACTOR = envNum("SWARM_MAX_LOAD_FACTOR", 0.9);
@@ -3091,15 +3294,15 @@ var init_config = __esm({
3091
3294
  DRONE_CHANNEL_ENABLED = process.env.SWARM_DRONE_CHANNEL !== "0";
3092
3295
  DRONE_CHANNEL_PORT = Number(process.env.SWARM_DRONE_CHANNEL_PORT) || 7421;
3093
3296
  DRONE_CHANNEL_URL = process.env.SWARM_DRONE_CHANNEL_URL || `http://127.0.0.1:${DRONE_CHANNEL_PORT}`;
3094
- DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET || join7(SWARM_HOME, "drone-channel.key");
3297
+ DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET || join8(SWARM_HOME, "drone-channel.key");
3095
3298
  DRONE_CHANNEL_GRACE_MS = envNum("SWARM_DRONE_CHANNEL_GRACE_MS", 12e4);
3096
- HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join7(SWARM_HOME, "overmind.heartbeat");
3299
+ HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join8(SWARM_HOME, "overmind.heartbeat");
3097
3300
  HEARTBEAT_STALE_MS = Number(process.env.SWARM_HEARTBEAT_STALE_MS) || 3e4;
3098
3301
  SWARM_REPO = process.env.SWARM_REPO || "";
3099
3302
  SWARM_SCAN_DEPTH = Number(process.env.SWARM_SCAN_DEPTH) || 3;
3100
3303
  SWARM_REPO_PATHS = (process.env.SWARM_REPOS || SWARM_REPO).split(",").map((s) => s.trim()).filter(Boolean);
3101
3304
  SWARM_SCAN_ROOTS_RAW = process.env.SWARM_SCAN_ROOTS || "";
3102
- REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join7(SWARM_HOME, "repo-map.json");
3305
+ REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join8(SWARM_HOME, "repo-map.json");
3103
3306
  SWARM_REPO_MAP_MS = envNum("SWARM_REPO_MAP_MS", 15 * 6e4);
3104
3307
  SWARM_REPO_SCAN_TTL_MS = envNum("SWARM_REPO_SCAN_TTL_MS", 24 * 60 * 6e4);
3105
3308
  TASKLESS_API = process.env.TASKLESS_API || "https://taskless.ru";
@@ -3114,7 +3317,7 @@ var init_config = __esm({
3114
3317
  SWARM_AUTO_REVIEW = process.env.SWARM_AUTO_REVIEW !== "0";
3115
3318
  SWARM_AUTO_VERIFY = process.env.SWARM_AUTO_VERIFY !== "0";
3116
3319
  SWARM_MERGE_QUEUE = process.env.SWARM_MERGE_QUEUE !== "0";
3117
- REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join7(SWARM_HOME, "review-cutoff.json");
3320
+ REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join8(SWARM_HOME, "review-cutoff.json");
3118
3321
  SWARM_REVIEW_CAP = Math.trunc(envNum("SWARM_REVIEW_CAP", 1));
3119
3322
  SWARM_STORM_URL = process.env.SWARM_STORM_URL || "";
3120
3323
  WEB_PORT = Number(process.env.SWARM_WEB_PORT) || 7420;
@@ -3154,7 +3357,7 @@ var init_quietExec = __esm({
3154
3357
 
3155
3358
  // src/resources.ts
3156
3359
  import os from "os";
3157
- import { readFileSync as readFileSync4, statfsSync } from "fs";
3360
+ import { readFileSync as readFileSync5, statfsSync } from "fs";
3158
3361
  function isTransientResourceError(e) {
3159
3362
  const code = e?.code;
3160
3363
  return code === "ENFILE" || code === "EMFILE" || code === "EAGAIN";
@@ -3206,7 +3409,7 @@ function fileDescriptorLoadRatio() {
3206
3409
  }
3207
3410
  if (process.platform === "linux") {
3208
3411
  try {
3209
- const [allocated, , max] = readFileSync4("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
3412
+ const [allocated, , max] = readFileSync5("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
3210
3413
  if (Number.isFinite(allocated ?? NaN) && Number.isFinite(max ?? NaN) && max) return allocated / max;
3211
3414
  } catch {
3212
3415
  }
@@ -3469,18 +3672,18 @@ var init_store = __esm({
3469
3672
  });
3470
3673
 
3471
3674
  // src/agentToken.ts
3472
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, unlinkSync } from "fs";
3473
- import { join as join8 } from "path";
3675
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, unlinkSync } from "fs";
3676
+ import { join as join9 } from "path";
3474
3677
  function loadAgentToken() {
3475
3678
  try {
3476
- const s = JSON.parse(readFileSync5(STORE_PATH, "utf8"));
3679
+ const s = JSON.parse(readFileSync6(STORE_PATH, "utf8"));
3477
3680
  return s.token ? s : null;
3478
3681
  } catch {
3479
3682
  return null;
3480
3683
  }
3481
3684
  }
3482
3685
  function saveAgentToken(s) {
3483
- writeFileSync5(STORE_PATH, JSON.stringify(s, null, 2), { mode: 384 });
3686
+ writeFileSync6(STORE_PATH, JSON.stringify(s, null, 2), { mode: 384 });
3484
3687
  }
3485
3688
  function clearAgentToken() {
3486
3689
  try {
@@ -3551,7 +3754,7 @@ var init_agentToken = __esm({
3551
3754
  "src/agentToken.ts"() {
3552
3755
  "use strict";
3553
3756
  init_config();
3554
- STORE_PATH = join8(SWARM_HOME, "agent.json");
3757
+ STORE_PATH = join9(SWARM_HOME, "agent.json");
3555
3758
  base = (api) => api.replace(/\/$/, "");
3556
3759
  TOKEN_PROBE_TIMEOUT_MS = 8e3;
3557
3760
  }
@@ -3655,7 +3858,7 @@ var init_toolFailure = __esm({
3655
3858
  });
3656
3859
 
3657
3860
  // src/procList.ts
3658
- import { readFileSync as readFileSync8 } from "fs";
3861
+ import { readFileSync as readFileSync9 } from "fs";
3659
3862
  function parsePsRows(out) {
3660
3863
  const rows = [];
3661
3864
  for (const line of out.split("\n")) {
@@ -3938,7 +4141,7 @@ var init_package = __esm({
3938
4141
  "package.json"() {
3939
4142
  package_default = {
3940
4143
  name: "@taskless-app/swarm",
3941
- version: "0.6.81",
4144
+ version: "0.6.83",
3942
4145
  type: "module",
3943
4146
  description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
3944
4147
  keywords: [
@@ -3990,7 +4193,7 @@ var init_package = __esm({
3990
4193
  undici: "^7.30.1",
3991
4194
  zod: "3.25.76"
3992
4195
  },
3993
- gitHead: "0a4c6ee0b5f07c122a325e3df3bc3361ee01b312"
4196
+ gitHead: "8fd42459bb1cbcdad50ebef72bcb3c36a5e2d1c6"
3994
4197
  };
3995
4198
  }
3996
4199
  });
@@ -4156,18 +4359,18 @@ var init_netTimeout = __esm({
4156
4359
 
4157
4360
  // src/droneChannel.ts
4158
4361
  import { createHmac, randomBytes, timingSafeEqual } from "crypto";
4159
- import { chmodSync as chmodSync2, mkdirSync as mkdirSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "fs";
4362
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync9 } from "fs";
4160
4363
  import { dirname as dirname3 } from "path";
4161
4364
  import { serve } from "@hono/node-server";
4162
4365
  function loadChannelSecret(path) {
4163
4366
  try {
4164
- const s = readFileSync10(path, "utf8").trim();
4367
+ const s = readFileSync11(path, "utf8").trim();
4165
4368
  if (s.length >= 32) return s;
4166
4369
  } catch {
4167
4370
  }
4168
4371
  const secret = randomBytes(32).toString("hex");
4169
- mkdirSync8(dirname3(path), { recursive: true });
4170
- writeFileSync8(path, secret, { mode: 384 });
4372
+ mkdirSync9(dirname3(path), { recursive: true });
4373
+ writeFileSync9(path, secret, { mode: 384 });
4171
4374
  try {
4172
4375
  chmodSync2(path, 384);
4173
4376
  } catch {
@@ -4244,8 +4447,8 @@ var init_authState = __esm({
4244
4447
 
4245
4448
  // src/oauth.ts
4246
4449
  import { createHash, randomBytes as randomBytes2 } from "crypto";
4247
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3 } from "fs";
4248
- import { join as join13 } from "path";
4450
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync10, unlinkSync as unlinkSync3 } from "fs";
4451
+ import { join as join14 } from "path";
4249
4452
  function makePkce() {
4250
4453
  const verifier = randomBytes2(48).toString("base64url");
4251
4454
  const challenge = createHash("sha256").update(verifier).digest("base64url");
@@ -4329,13 +4532,13 @@ function toStore(clientId, t, now) {
4329
4532
  }
4330
4533
  function loadStore() {
4331
4534
  try {
4332
- return JSON.parse(readFileSync11(STORE_PATH2, "utf8"));
4535
+ return JSON.parse(readFileSync12(STORE_PATH2, "utf8"));
4333
4536
  } catch {
4334
4537
  return null;
4335
4538
  }
4336
4539
  }
4337
4540
  function saveStore(s) {
4338
- writeFileSync9(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
4541
+ writeFileSync10(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
4339
4542
  }
4340
4543
  function clearStore() {
4341
4544
  try {
@@ -4345,7 +4548,7 @@ function clearStore() {
4345
4548
  }
4346
4549
  function loadClientId() {
4347
4550
  try {
4348
- return JSON.parse(readFileSync11(CLIENT_PATH, "utf8")).clientId;
4551
+ return JSON.parse(readFileSync12(CLIENT_PATH, "utf8")).clientId;
4349
4552
  } catch {
4350
4553
  return null;
4351
4554
  }
@@ -4354,7 +4557,7 @@ async function ensureClientId(api, redirectUri, fetchFn = fetch) {
4354
4557
  const existing = loadClientId();
4355
4558
  if (existing) return existing;
4356
4559
  const clientId = await registerClient({ api, redirectUri }, fetchFn);
4357
- writeFileSync9(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
4560
+ writeFileSync10(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
4358
4561
  return clientId;
4359
4562
  }
4360
4563
  async function ensureAccess(store, opts = {}) {
@@ -4380,16 +4583,16 @@ var init_oauth = __esm({
4380
4583
  AUTHORIZE = "/api/oauth/authorize";
4381
4584
  TOKEN = "/api/oauth/token";
4382
4585
  SCOPE = "openid profile email taskless:full";
4383
- STORE_PATH2 = join13(SWARM_HOME, "oauth.json");
4384
- CLIENT_PATH = join13(SWARM_HOME, "oauth-client.json");
4586
+ STORE_PATH2 = join14(SWARM_HOME, "oauth.json");
4587
+ CLIENT_PATH = join14(SWARM_HOME, "oauth-client.json");
4385
4588
  base2 = (api) => api.replace(/\/$/, "");
4386
4589
  }
4387
4590
  });
4388
4591
 
4389
4592
  // src/git.ts
4390
- import { existsSync as existsSync11, readdirSync as readdirSync10, realpathSync as realpathSync2, statSync as statSync10 } from "fs";
4593
+ import { existsSync as existsSync12, readdirSync as readdirSync11, realpathSync as realpathSync2, statSync as statSync11 } from "fs";
4391
4594
  import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
4392
- import { isAbsolute, join as join16, resolve as resolve2, sep as sep2 } from "path";
4595
+ import { isAbsolute, join as join17, resolve as resolve2, sep as sep2 } from "path";
4393
4596
  import { $ as $5 } from "execa";
4394
4597
  function gitNet(repo, args, timeoutMs) {
4395
4598
  return withHardTimeout(
@@ -4403,14 +4606,14 @@ async function reclaimStaleWorktree(repo, worktree) {
4403
4606
  await detachWorktree(repo, worktree);
4404
4607
  }
4405
4608
  async function inspectWorktreePath(path) {
4406
- if (!existsSync11(path)) return "free";
4609
+ if (!existsSync12(path)) return "free";
4407
4610
  try {
4408
- if (readdirSync10(path).length === 0) return "free";
4611
+ if (readdirSync11(path).length === 0) return "free";
4409
4612
  } catch {
4410
4613
  return "orphan";
4411
4614
  }
4412
4615
  try {
4413
- if (statSync10(join16(path, ".git")).isDirectory()) return "main-checkout";
4616
+ if (statSync11(join17(path, ".git")).isDirectory()) return "main-checkout";
4414
4617
  } catch {
4415
4618
  }
4416
4619
  const top = await $5({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
@@ -4449,7 +4652,7 @@ async function clearWorktreePath(repo, path, branch, opts = {}) {
4449
4652
  await detachWorktree(repo, path);
4450
4653
  opts.onStaleReclaim?.(path);
4451
4654
  }
4452
- if (!existsSync11(path)) return;
4655
+ if (!existsSync12(path)) return;
4453
4656
  await parkOrphanDir(repo, path, branch);
4454
4657
  }
4455
4658
  async function parkOrphanDir(repo, path, branch) {
@@ -4470,7 +4673,7 @@ async function parkOrphanDir(repo, path, branch) {
4470
4673
  }
4471
4674
  function isLinkedWorktree(dir) {
4472
4675
  try {
4473
- return statSync10(join16(dir, ".git")).isFile();
4676
+ return statSync11(join17(dir, ".git")).isFile();
4474
4677
  } catch {
4475
4678
  return false;
4476
4679
  }
@@ -4482,7 +4685,7 @@ async function detachWorktree(repo, worktree) {
4482
4685
  }
4483
4686
  }
4484
4687
  async function ensureWorktreeDirGone(worktree) {
4485
- if (!existsSync11(worktree)) return false;
4688
+ if (!existsSync12(worktree)) return false;
4486
4689
  if (!isLinkedWorktree(worktree)) {
4487
4690
  console.error(
4488
4691
  `[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.`
@@ -4497,7 +4700,7 @@ async function ensureWorktreeDirGone(worktree) {
4497
4700
  );
4498
4701
  return true;
4499
4702
  }
4500
- if (existsSync11(worktree)) {
4703
+ if (existsSync12(worktree)) {
4501
4704
  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.`);
4502
4705
  }
4503
4706
  return true;
@@ -4546,7 +4749,7 @@ async function checkoutWorktree(repo, path, branch, opts) {
4546
4749
  }
4547
4750
  const busyAt = await worktreeForBranch(repo, branch);
4548
4751
  if (busyAt) {
4549
- const exists = existsSync11(busyAt);
4752
+ const exists = existsSync12(busyAt);
4550
4753
  const live2 = exists && (opts.isWorktreeHeldLive ? await opts.isWorktreeHeldLive(busyAt) : true);
4551
4754
  if (live2) throw new WorktreeBusyError(branch, busyAt);
4552
4755
  if (exists && await worktreeDirty(busyAt)) throw new WorktreeBusyError(branch, busyAt);
@@ -4577,8 +4780,8 @@ async function ensureGitExcluded(worktree, pattern) {
4577
4780
  try {
4578
4781
  const commonDir = await gitPath(worktree, "--git-common-dir");
4579
4782
  if (!commonDir) return false;
4580
- const infoDir = join16(commonDir, "info");
4581
- const excludeFile = join16(infoDir, "exclude");
4783
+ const infoDir = join17(commonDir, "info");
4784
+ const excludeFile = join17(infoDir, "exclude");
4582
4785
  let current = "";
4583
4786
  try {
4584
4787
  current = await readFile(excludeFile, "utf8");
@@ -4598,7 +4801,7 @@ async function gitPath(worktree, flag) {
4598
4801
  const out = await $5({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
4599
4802
  const raw = out.stdout.trim();
4600
4803
  if (out.exitCode !== 0 || !raw) return null;
4601
- return isAbsolute(raw) ? raw : join16(worktree, raw);
4804
+ return isAbsolute(raw) ? raw : join17(worktree, raw);
4602
4805
  }
4603
4806
  async function ensureWorktreeHygiene(worktree) {
4604
4807
  for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
@@ -4608,12 +4811,12 @@ async function installGuardHooks(worktree) {
4608
4811
  try {
4609
4812
  const gitDir = await gitPath(worktree, "--git-dir");
4610
4813
  if (!gitDir) return false;
4611
- const hooksDir = join16(gitDir, "swarm-hooks");
4814
+ const hooksDir = join17(gitDir, "swarm-hooks");
4612
4815
  const prev = await previousHooksPath(worktree);
4613
4816
  await mkdir(hooksDir, { recursive: true });
4614
4817
  for (const hook of GUARD_HOOKS) {
4615
- await writeFile(join16(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
4616
- await chmod(join16(hooksDir, hook), 493);
4818
+ await writeFile(join17(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
4819
+ await chmod(join17(hooksDir, hook), 493);
4617
4820
  }
4618
4821
  await $5`git -C ${worktree} config extensions.worktreeConfig true`;
4619
4822
  await $5`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
@@ -4632,7 +4835,7 @@ async function previousHooksPath(worktree) {
4632
4835
  if (out.exitCode === 0 && value) return value;
4633
4836
  }
4634
4837
  const commonDir = await gitPath(worktree, "--git-common-dir");
4635
- return commonDir ? join16(commonDir, "hooks") : null;
4838
+ return commonDir ? join17(commonDir, "hooks") : null;
4636
4839
  }
4637
4840
  async function removeWorktree(repo, path) {
4638
4841
  const branch = (await $5({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
@@ -4695,7 +4898,7 @@ var init_git = __esm({
4695
4898
 
4696
4899
  // src/attachments.ts
4697
4900
  import { mkdir as mkdir2, rm as rm2, writeFile as writeFile2 } from "fs/promises";
4698
- import { join as join17 } from "path";
4901
+ import { join as join18 } from "path";
4699
4902
  var ATTACHMENTS_DIR, ATTACH_MAX_TOTAL_BYTES, ATTACH_MAX_FILE_BYTES, IMAGE_EXT, DOC_EXT, TEXT_EXT, KNOWN_EXT;
4700
4903
  var init_attachments = __esm({
4701
4904
  "src/attachments.ts"() {
@@ -4714,7 +4917,7 @@ var init_attachments = __esm({
4714
4917
 
4715
4918
  // src/shotUpload.ts
4716
4919
  import { readFile as fsReadFile } from "fs/promises";
4717
- import { basename as basename5, isAbsolute as isAbsolute2, join as join18 } from "path";
4920
+ import { basename as basename5, isAbsolute as isAbsolute2, join as join19 } from "path";
4718
4921
  var SHOT_MAX_FILE_BYTES;
4719
4922
  var init_shotUpload = __esm({
4720
4923
  "src/shotUpload.ts"() {
@@ -4765,18 +4968,18 @@ var init_prodHttp = __esm({
4765
4968
  });
4766
4969
 
4767
4970
  // src/workspace.ts
4768
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync10, unlinkSync as unlinkSync4 } from "fs";
4769
- import { join as join19 } from "path";
4971
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync11, unlinkSync as unlinkSync4 } from "fs";
4972
+ import { join as join20 } from "path";
4770
4973
  function loadWorkspace() {
4771
4974
  try {
4772
- const w = JSON.parse(readFileSync12(WORKSPACE_PATH, "utf8"));
4975
+ const w = JSON.parse(readFileSync13(WORKSPACE_PATH, "utf8"));
4773
4976
  return w && typeof w.id === "string" && w.id ? w : null;
4774
4977
  } catch {
4775
4978
  return null;
4776
4979
  }
4777
4980
  }
4778
4981
  function saveWorkspace(w) {
4779
- writeFileSync10(WORKSPACE_PATH, JSON.stringify(w, null, 2), { mode: 384 });
4982
+ writeFileSync11(WORKSPACE_PATH, JSON.stringify(w, null, 2), { mode: 384 });
4780
4983
  }
4781
4984
  function clearWorkspace() {
4782
4985
  try {
@@ -4792,7 +4995,7 @@ var init_workspace = __esm({
4792
4995
  "src/workspace.ts"() {
4793
4996
  "use strict";
4794
4997
  init_config();
4795
- WORKSPACE_PATH = join19(SWARM_HOME, "workspace.json");
4998
+ WORKSPACE_PATH = join20(SWARM_HOME, "workspace.json");
4796
4999
  }
4797
5000
  });
4798
5001
 
@@ -5233,14 +5436,14 @@ var init_daemonLink = __esm({
5233
5436
  });
5234
5437
 
5235
5438
  // src/pauseState.ts
5236
- import { existsSync as existsSync12, readFileSync as readFileSync13, renameSync as renameSync5, unlinkSync as unlinkSync5, writeFileSync as writeFileSync11 } from "fs";
5237
- import { join as join20 } from "path";
5439
+ import { existsSync as existsSync13, readFileSync as readFileSync14, renameSync as renameSync5, unlinkSync as unlinkSync5, writeFileSync as writeFileSync12 } from "fs";
5440
+ import { join as join21 } from "path";
5238
5441
  function pauseStatePath(home) {
5239
- return join20(home, "pause.json");
5442
+ return join21(home, "pause.json");
5240
5443
  }
5241
5444
  function loadPauseState(home, io = {}) {
5242
- const exists = io.exists ?? existsSync12;
5243
- const readFile2 = io.readFile ?? ((p) => readFileSync13(p, "utf8"));
5445
+ const exists = io.exists ?? existsSync13;
5446
+ const readFile2 = io.readFile ?? ((p) => readFileSync14(p, "utf8"));
5244
5447
  const path = pauseStatePath(home);
5245
5448
  if (!exists(path)) return ACTIVE;
5246
5449
  try {
@@ -5259,12 +5462,12 @@ function loadPauseState(home, io = {}) {
5259
5462
  function savePauseState(home, state, io = {}) {
5260
5463
  const path = pauseStatePath(home);
5261
5464
  if (!state.paused) {
5262
- const remove = io.remove ?? ((p) => existsSync12(p) && unlinkSync5(p));
5465
+ const remove = io.remove ?? ((p) => existsSync13(p) && unlinkSync5(p));
5263
5466
  remove(path);
5264
5467
  return;
5265
5468
  }
5266
5469
  const writeFile3 = io.writeFile ?? ((p, data) => {
5267
- writeFileSync11(`${p}.tmp`, data);
5470
+ writeFileSync12(`${p}.tmp`, data);
5268
5471
  renameSync5(`${p}.tmp`, p);
5269
5472
  });
5270
5473
  writeFile3(path, JSON.stringify(state, null, 2));
@@ -5301,10 +5504,10 @@ var init_pauseState = __esm({
5301
5504
  });
5302
5505
 
5303
5506
  // src/heartbeat.ts
5304
- import { readFileSync as readFileSync14, renameSync as renameSync6, writeFileSync as writeFileSync12 } from "fs";
5507
+ import { readFileSync as readFileSync15, renameSync as renameSync6, writeFileSync as writeFileSync13 } from "fs";
5305
5508
  function readHeartbeat(path) {
5306
5509
  try {
5307
- const ms = Number(readFileSync14(path, "utf8").trim());
5510
+ const ms = Number(readFileSync15(path, "utf8").trim());
5308
5511
  return Number.isFinite(ms) ? ms : null;
5309
5512
  } catch {
5310
5513
  return null;
@@ -5323,7 +5526,7 @@ __export(db_exports, {
5323
5526
  });
5324
5527
  import { createRequire as createRequire2 } from "module";
5325
5528
  import { randomUUID as randomUUID3 } from "crypto";
5326
- import { existsSync as existsSync13 } from "fs";
5529
+ import { existsSync as existsSync14 } from "fs";
5327
5530
  import { resolve as resolve3 } from "path";
5328
5531
  function rowToQuestion(row) {
5329
5532
  return {
@@ -5987,7 +6190,7 @@ CREATE TABLE IF NOT EXISTS imports (
5987
6190
  const repoN = normalizeRepo(repo);
5988
6191
  const already = this.db.prepare("SELECT run_count FROM imports WHERE source = ?").get(abs);
5989
6192
  if (already) return { imported: false, runs: already.run_count };
5990
- if (!existsSync13(abs)) throw new Error(`import-db: \u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442: ${abs}`);
6193
+ if (!existsSync14(abs)) throw new Error(`import-db: \u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442: ${abs}`);
5991
6194
  const src = new this.databaseCtor(abs);
5992
6195
  try {
5993
6196
  const runs = src.prepare("SELECT * FROM runs ORDER BY id").all();
@@ -6315,8 +6518,8 @@ CREATE TABLE IF NOT EXISTS imports (
6315
6518
  });
6316
6519
 
6317
6520
  // src/repoScan.ts
6318
- import { readdirSync as readdirSync11, readFileSync as readFileSync15, statSync as statSync11 } from "fs";
6319
- import { join as join21 } from "path";
6521
+ import { readdirSync as readdirSync12, readFileSync as readFileSync16, statSync as statSync12 } from "fs";
6522
+ import { join as join22 } from "path";
6320
6523
  var init_repoScan = __esm({
6321
6524
  "src/repoScan.ts"() {
6322
6525
  "use strict";
@@ -6326,8 +6529,8 @@ var init_repoScan = __esm({
6326
6529
 
6327
6530
  // src/repoDiscovery.ts
6328
6531
  import { homedir as homedir6 } from "os";
6329
- import { readFileSync as readFileSync16, renameSync as renameSync7, writeFileSync as writeFileSync13 } from "fs";
6330
- import { isAbsolute as isAbsolute3, join as join22, resolve as resolve4 } from "path";
6532
+ import { readFileSync as readFileSync17, renameSync as renameSync7, writeFileSync as writeFileSync14 } from "fs";
6533
+ import { isAbsolute as isAbsolute3, join as join23, resolve as resolve4 } from "path";
6331
6534
  function repoMapLines(rows) {
6332
6535
  if (!rows?.length) return [];
6333
6536
  const missing = rows.filter((r) => !r.path).length;
@@ -6342,7 +6545,7 @@ function repoMapLines(rows) {
6342
6545
  }
6343
6546
  function loadRepoMapCache(path) {
6344
6547
  try {
6345
- const raw = JSON.parse(readFileSync16(path, "utf8"));
6548
+ const raw = JSON.parse(readFileSync17(path, "utf8"));
6346
6549
  if (!Array.isArray(raw?.entries)) return { scannedAt: null, entries: [] };
6347
6550
  return {
6348
6551
  scannedAt: typeof raw.scannedAt === "string" && raw.scannedAt ? raw.scannedAt : null,
@@ -6718,11 +6921,11 @@ __export(statusCli_exports, {
6718
6921
  probeLink: () => probeLink,
6719
6922
  runStatusCli: () => runStatusCli
6720
6923
  });
6721
- import { existsSync as existsSync14, readFileSync as readFileSync17 } from "fs";
6924
+ import { existsSync as existsSync15, readFileSync as readFileSync18 } from "fs";
6722
6925
  function outboxPending(path) {
6723
6926
  try {
6724
- if (!existsSync14(path)) return 0;
6725
- return readFileSync17(path, "utf8").split("\n").filter((l) => l.trim()).length;
6927
+ if (!existsSync15(path)) return 0;
6928
+ return readFileSync18(path, "utf8").split("\n").filter((l) => l.trim()).length;
6726
6929
  } catch {
6727
6930
  return null;
6728
6931
  }
@@ -6929,23 +7132,23 @@ var init_prodMergeGate = __esm({
6929
7132
  });
6930
7133
 
6931
7134
  // src/platform.ts
6932
- import { accessSync, constants, existsSync as existsSync15, readFileSync as readFileSync18, realpathSync as realpathSync3 } from "fs";
6933
- import { delimiter, join as join23, posix as posix2, win32 } from "path";
7135
+ import { accessSync, constants, existsSync as existsSync16, readFileSync as readFileSync19, realpathSync as realpathSync3 } from "fs";
7136
+ import { delimiter, join as join24, posix as posix2, win32 } from "path";
6934
7137
  function safeReadText(path) {
6935
7138
  try {
6936
- return readFileSync18(path, "utf8");
7139
+ return readFileSync19(path, "utf8");
6937
7140
  } catch {
6938
7141
  return null;
6939
7142
  }
6940
7143
  }
6941
7144
  function resolveCommandPath(name, env = process.env, platform = process.platform) {
6942
- if (name.includes("/") || name.includes("\\")) return existsSync15(name) ? name : null;
7145
+ if (name.includes("/") || name.includes("\\")) return existsSync16(name) ? name : null;
6943
7146
  const dirs = (env.PATH ?? env.Path ?? "").split(delimiter).filter(Boolean);
6944
7147
  const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
6945
7148
  for (const dir of dirs) {
6946
7149
  for (const ext of exts) {
6947
- const candidate = join23(dir, name + ext);
6948
- if (existsSync15(candidate)) return candidate;
7150
+ const candidate = join24(dir, name + ext);
7151
+ if (existsSync16(candidate)) return candidate;
6949
7152
  }
6950
7153
  }
6951
7154
  return null;
@@ -7135,13 +7338,13 @@ var init_platform = __esm({
7135
7338
  });
7136
7339
 
7137
7340
  // src/envGate.ts
7138
- import { existsSync as existsSync16 } from "fs";
7139
- import { join as join24 } from "path";
7341
+ import { existsSync as existsSync17 } from "fs";
7342
+ import { join as join25 } from "path";
7140
7343
  import { createConnection } from "net";
7141
7344
  import { execa as execa3 } from "execa";
7142
7345
  function detectRequirements(repo, io = {}) {
7143
- const exists = io.exists ?? existsSync16;
7144
- const marker = COMPOSE_MARKERS.find((f) => exists(join24(repo, f)));
7346
+ const exists = io.exists ?? existsSync17;
7347
+ const marker = COMPOSE_MARKERS.find((f) => exists(join25(repo, f)));
7145
7348
  return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
7146
7349
  }
7147
7350
  async function dockerAlive() {
@@ -7173,7 +7376,7 @@ var init_envGate = __esm({
7173
7376
  });
7174
7377
 
7175
7378
  // src/doctor.ts
7176
- import { isAbsolute as isAbsolute4, join as join25 } from "path";
7379
+ import { isAbsolute as isAbsolute4, join as join26 } from "path";
7177
7380
  function ok(id, title, detail) {
7178
7381
  return { id, title, status: "ok", detail, remedies: [], critical: false };
7179
7382
  }
@@ -7382,7 +7585,7 @@ function checkRepos(io, snap) {
7382
7585
  critical: true
7383
7586
  };
7384
7587
  }
7385
- if (env && !io.exists(join25(env, ".git"))) {
7588
+ if (env && !io.exists(join26(env, ".git"))) {
7386
7589
  return {
7387
7590
  id: "repos",
7388
7591
  title,
@@ -7392,7 +7595,7 @@ function checkRepos(io, snap) {
7392
7595
  critical: true
7393
7596
  };
7394
7597
  }
7395
- const broken = snap.paths.filter((p) => !io.exists(join25(p, ".git")));
7598
+ const broken = snap.paths.filter((p) => !io.exists(join26(p, ".git")));
7396
7599
  if (broken.length) {
7397
7600
  return {
7398
7601
  id: "repos",
@@ -7582,12 +7785,12 @@ var init_doctor = __esm({
7582
7785
  });
7583
7786
 
7584
7787
  // src/repoMemory.ts
7585
- import { readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "fs";
7586
- import { join as join26 } from "path";
7788
+ import { readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "fs";
7789
+ import { join as join27 } from "path";
7587
7790
  function loadRememberedRepos(home) {
7588
7791
  let raw;
7589
7792
  try {
7590
- raw = readFileSync19(join26(home, FILE), "utf8");
7793
+ raw = readFileSync20(join27(home, FILE), "utf8");
7591
7794
  } catch {
7592
7795
  return [];
7593
7796
  }
@@ -7623,7 +7826,7 @@ __export(installCli_exports, {
7623
7826
  runInstallHookCli: () => runInstallHookCli,
7624
7827
  shortenError: () => shortenError
7625
7828
  });
7626
- import { existsSync as existsSync17 } from "fs";
7829
+ import { existsSync as existsSync18 } from "fs";
7627
7830
  function classifyChromiumError(message) {
7628
7831
  if (/playwright-core не установлен|Cannot find (module|package)/i.test(message)) return "no-module";
7629
7832
  if (/error while loading shared libraries|cannot open shared object file|missing dependencies|\blib[\w.+-]*\.so[.\d]*\b/i.test(message)) return "no-libs";
@@ -7678,7 +7881,7 @@ function defaultDoctorIO(packageVersion) {
7678
7881
  packageVersion,
7679
7882
  entry,
7680
7883
  hasCommand: (name) => hasCommandInPath(name),
7681
- exists: existsSync17,
7884
+ exists: existsSync18,
7682
7885
  run: (command) => runQuiet(command),
7683
7886
  latestVersion: () => latestMemo ??= fetchLatestVersion(),
7684
7887
  probeChromium: () => probeChromium(),
@@ -7918,8 +8121,8 @@ var init_updateCli = __esm({
7918
8121
 
7919
8122
  // src/cli.ts
7920
8123
  init_cliIo();
7921
- import { basename as basename6, dirname as dirname5, join as join27 } from "path";
7922
- import { existsSync as existsSync18, readFileSync as readFileSync20, writeFileSync as writeFileSync15, mkdirSync as mkdirSync11, readdirSync as readdirSync12, statSync as statSync12, openSync as openSync5, readSync as readSync2, closeSync as closeSync5 } from "fs";
8124
+ import { basename as basename6, dirname as dirname5, join as join28 } from "path";
8125
+ import { existsSync as existsSync19, readFileSync as readFileSync21, writeFileSync as writeFileSync16, mkdirSync as mkdirSync12, readdirSync as readdirSync13, statSync as statSync13, openSync as openSync5, readSync as readSync2, closeSync as closeSync5 } from "fs";
7923
8126
  import { setTimeout as sleep2 } from "timers/promises";
7924
8127
 
7925
8128
  // src/swarmClient.ts
@@ -7927,7 +8130,7 @@ init_config();
7927
8130
  init_resources();
7928
8131
  init_names2();
7929
8132
  init_storm();
7930
- import { appendFileSync, existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
8133
+ import { appendFileSync, existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "fs";
7931
8134
  import { dirname as dirname2 } from "path";
7932
8135
  import { randomUUID } from "crypto";
7933
8136
 
@@ -7961,24 +8164,24 @@ init_store();
7961
8164
  init_toolFailure();
7962
8165
 
7963
8166
  // src/logTail.ts
7964
- import { closeSync, existsSync as existsSync6, openSync, readSync, readdirSync as readdirSync7, statSync as statSync6 } from "fs";
7965
- import { join as join10 } from "path";
8167
+ import { closeSync, existsSync as existsSync7, openSync, readSync, readdirSync as readdirSync8, statSync as statSync7 } from "fs";
8168
+ import { join as join11 } from "path";
7966
8169
 
7967
8170
  // src/runLogDir.ts
7968
- import { existsSync as existsSync5, mkdirSync as mkdirSync6, readdirSync as readdirSync6, renameSync as renameSync2, statSync as statSync5 } from "fs";
7969
- import { join as join9 } from "path";
8171
+ import { existsSync as existsSync6, mkdirSync as mkdirSync7, readdirSync as readdirSync7, renameSync as renameSync2, statSync as statSync6 } from "fs";
8172
+ import { join as join10 } from "path";
7970
8173
  function runLogDirName(runLogKey) {
7971
8174
  const safe = runLogKey.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^[-_]+|[-_]+$/g, "");
7972
8175
  if (!safe) throw new Error(`\u043A\u043B\u044E\u0447 \u043F\u0440\u043E\u0433\u043E\u043D\u0430 \u043D\u0435 \u0433\u043E\u0434\u0438\u0442\u0441\u044F \u0432 \u0438\u043C\u044F \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 run-log'\u043E\u0432: ${JSON.stringify(runLogKey)}`);
7973
8176
  return /^\d+$/.test(safe) ? `k-${safe}` : safe;
7974
8177
  }
7975
8178
  function runLogDirPath(runLogsDir, runLogKey) {
7976
- return join9(runLogsDir, runLogDirName(runLogKey));
8179
+ return join10(runLogsDir, runLogDirName(runLogKey));
7977
8180
  }
7978
8181
  function findRunLogDir(runLogsDir, keys) {
7979
8182
  for (const key of keys) {
7980
8183
  const dir = runLogDirPath(runLogsDir, key);
7981
- if (existsSync5(dir)) return dir;
8184
+ if (existsSync6(dir)) return dir;
7982
8185
  }
7983
8186
  return null;
7984
8187
  }
@@ -8079,8 +8282,8 @@ var SwarmClient = class _SwarmClient {
8079
8282
  // предикат «репо есть локально» для решения, брать ли свободный прогон.
8080
8283
  host;
8081
8284
  repoExists;
8082
- // TASWM-398: ЧЕМ эта машина исполняет прогоны — id адаптера (claude-code|codex).
8083
8285
  executorId;
8286
+ executorFor;
8084
8287
  // Зеркало.
8085
8288
  runs = /* @__PURE__ */ new Map();
8086
8289
  runtime = /* @__PURE__ */ new Map();
@@ -8195,26 +8398,27 @@ var SwarmClient = class _SwarmClient {
8195
8398
  this.repoFullNames = registry.map((e) => e.repoFullName);
8196
8399
  this.repoPathByFullName = new Map(registry.map((e) => [e.repoFullName, normalizeRepo(e.path)]));
8197
8400
  this.host = opts.host ?? null;
8198
- this.repoExists = opts.repoExists ?? existsSync7;
8401
+ this.repoExists = opts.repoExists ?? existsSync8;
8199
8402
  this.questionSyncMs = opts.questionSyncMs ?? 3e3;
8200
8403
  this.executorId = opts.executorId ?? EXECUTOR.id;
8404
+ this.executorFor = opts.executorFor;
8201
8405
  this.outboxPath = opts.outboxPath;
8202
8406
  this.mapPath = `${opts.outboxPath}.prodmap.json`;
8203
8407
  this.stormPath = `${opts.outboxPath}.storm.jsonl`;
8204
- mkdirSync7(dirname2(this.outboxPath), { recursive: true });
8408
+ mkdirSync8(dirname2(this.outboxPath), { recursive: true });
8205
8409
  this.recover();
8206
8410
  }
8207
8411
  // ── рестарт: поднять outbox (незаписанные операции) и карту runKey→prodId ─────
8208
8412
  recover() {
8209
- if (existsSync7(this.mapPath)) {
8413
+ if (existsSync8(this.mapPath)) {
8210
8414
  try {
8211
- const obj = JSON.parse(readFileSync6(this.mapPath, "utf8"));
8415
+ const obj = JSON.parse(readFileSync7(this.mapPath, "utf8"));
8212
8416
  for (const [k, v] of Object.entries(obj)) this.prodIdByKey.set(k, v);
8213
8417
  } catch {
8214
8418
  }
8215
8419
  }
8216
- if (existsSync7(this.outboxPath)) {
8217
- const txt = readFileSync6(this.outboxPath, "utf8");
8420
+ if (existsSync8(this.outboxPath)) {
8421
+ const txt = readFileSync7(this.outboxPath, "utf8");
8218
8422
  for (const line of txt.split("\n")) {
8219
8423
  const s = line.trim();
8220
8424
  if (!s) continue;
@@ -8234,10 +8438,10 @@ var SwarmClient = class _SwarmClient {
8234
8438
  // eventsLog ПЕРВЫМИ (до hydrate), в порядке файла (= хронологический); id
8235
8439
  // переприсваиваем локально (id событий — только порядок, не корреляция с продом).
8236
8440
  replayGlobalEvents() {
8237
- if (!existsSync7(this.stormPath)) return;
8441
+ if (!existsSync8(this.stormPath)) return;
8238
8442
  let txt;
8239
8443
  try {
8240
- txt = readFileSync6(this.stormPath, "utf8");
8444
+ txt = readFileSync7(this.stormPath, "utf8");
8241
8445
  } catch {
8242
8446
  return;
8243
8447
  }
@@ -8308,10 +8512,16 @@ var SwarmClient = class _SwarmClient {
8308
8512
  // в прод НЕ уходят. kind → role (плоский enum). Self-ref
8309
8513
  // прогонов hero_run_id/resolves_run_id/superseded_by → heroId/resolvesRunId/
8310
8514
  // supersededById как ОТЛОЖЕННЫЕ ссылки (RunRef) — cuid резолвится на флаше.
8311
- runFields(patch) {
8515
+ runFields(patch, run) {
8312
8516
  const out = {};
8313
8517
  if ("status" in patch && patch.status !== void 0) out.status = patch.status;
8314
- if (patch.status === "running") out.executor = this.executorId;
8518
+ if (patch.status === "running") {
8519
+ try {
8520
+ out.executor = run && this.executorFor ? this.executorFor(run) : this.executorId;
8521
+ } catch {
8522
+ out.executor = this.executorId;
8523
+ }
8524
+ }
8315
8525
  if ("area" in patch) out.area = normalizeZoneLabel(patch.area) || null;
8316
8526
  if ("model" in patch) out.model = patch.model ?? null;
8317
8527
  if ("review_model" in patch) out.reviewModel = patch.review_model ?? null;
@@ -8563,7 +8773,7 @@ var SwarmClient = class _SwarmClient {
8563
8773
  d[k] = v;
8564
8774
  }
8565
8775
  d.updated_at = stamp();
8566
- this.enqueueRun(d, this.runFields(patch));
8776
+ this.enqueueRun(d, this.runFields(patch, this.mat(d)));
8567
8777
  return this.mat(d);
8568
8778
  }
8569
8779
  incRespawn(id) {
@@ -9234,7 +9444,7 @@ var SwarmClient = class _SwarmClient {
9234
9444
  * транзиентным сбоем ОС, который этот PR должен переживать, а не превращать в мор.
9235
9445
  */
9236
9446
  reconcileRuntime(opts) {
9237
- const wtExists = opts.worktreeExists ?? existsSync7;
9447
+ const wtExists = opts.worktreeExists ?? existsSync8;
9238
9448
  const pidByWorktree = /* @__PURE__ */ new Map();
9239
9449
  try {
9240
9450
  for (const p of opts.listProcesses()) if (p.worktree) pidByWorktree.set(p.worktree, p.pid);
@@ -10502,13 +10712,13 @@ var SwarmClient = class _SwarmClient {
10502
10712
  }
10503
10713
  persistPending() {
10504
10714
  try {
10505
- writeFileSync6(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
10715
+ writeFileSync7(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
10506
10716
  } catch {
10507
10717
  }
10508
10718
  }
10509
10719
  persistMap() {
10510
10720
  try {
10511
- writeFileSync6(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
10721
+ writeFileSync7(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
10512
10722
  } catch {
10513
10723
  }
10514
10724
  }
@@ -10641,7 +10851,7 @@ init_config();
10641
10851
  import { $ as $6 } from "execa";
10642
10852
 
10643
10853
  // src/daemonLaunch.ts
10644
- import { openSync as openSync2, closeSync as closeSync2, readFileSync as readFileSync7 } from "fs";
10854
+ import { openSync as openSync2, closeSync as closeSync2, readFileSync as readFileSync8 } from "fs";
10645
10855
  import { spawn } from "child_process";
10646
10856
  var FOREGROUND_FLAGS = /* @__PURE__ */ new Set(["--foreground", "-f", "--attach"]);
10647
10857
  function parseStartMode(argv) {
@@ -10701,27 +10911,27 @@ function launchDetached(opts) {
10701
10911
  }
10702
10912
  function tailFile(path, lines) {
10703
10913
  try {
10704
- return tailText(readFileSync7(path, "utf8"), lines);
10914
+ return tailText(readFileSync8(path, "utf8"), lines);
10705
10915
  } catch {
10706
10916
  return "";
10707
10917
  }
10708
10918
  }
10709
10919
 
10710
10920
  // src/logRotate.ts
10711
- import { copyFileSync as copyFileSync4, renameSync as renameSync3, statSync as statSync7, fstatSync, truncateSync, unlinkSync as unlinkSync2, existsSync as existsSync8, openSync as openSync3, writeSync, closeSync as closeSync3 } from "fs";
10921
+ import { copyFileSync as copyFileSync5, renameSync as renameSync3, statSync as statSync8, fstatSync, truncateSync, unlinkSync as unlinkSync2, existsSync as existsSync9, openSync as openSync3, writeSync, closeSync as closeSync3 } from "fs";
10712
10922
  var realIo = {
10713
10923
  size: (path) => {
10714
10924
  try {
10715
- return statSync7(path).size;
10925
+ return statSync8(path).size;
10716
10926
  } catch {
10717
10927
  return null;
10718
10928
  }
10719
10929
  },
10720
- copy: copyFileSync4,
10930
+ copy: copyFileSync5,
10721
10931
  rename: renameSync3,
10722
10932
  truncate: (path) => truncateSync(path, 0),
10723
10933
  unlink: unlinkSync2,
10724
- exists: existsSync8
10934
+ exists: existsSync9
10725
10935
  };
10726
10936
  var realOwnerIo = {
10727
10937
  statFd: (fd) => {
@@ -10734,7 +10944,7 @@ var realOwnerIo = {
10734
10944
  },
10735
10945
  statPath: (path) => {
10736
10946
  try {
10737
- const s = statSync7(path);
10947
+ const s = statSync8(path);
10738
10948
  return { dev: s.dev, ino: s.ino };
10739
10949
  } catch {
10740
10950
  return null;
@@ -10801,17 +11011,17 @@ init_repoRegistry();
10801
11011
 
10802
11012
  // src/hostIdentity.ts
10803
11013
  import { hostname } from "os";
10804
- import { existsSync as existsSync9, readFileSync as readFileSync9, renameSync as renameSync4, writeFileSync as writeFileSync7 } from "fs";
10805
- import { join as join11 } from "path";
11014
+ import { existsSync as existsSync10, readFileSync as readFileSync10, renameSync as renameSync4, writeFileSync as writeFileSync8 } from "fs";
11015
+ import { join as join12 } from "path";
10806
11016
  import { randomUUID as randomUUID2 } from "crypto";
10807
11017
  function hostIdentityPath(home) {
10808
- return join11(home, "host.json");
11018
+ return join12(home, "host.json");
10809
11019
  }
10810
11020
  function loadHostIdentity(deps) {
10811
- const exists = deps.exists ?? existsSync9;
10812
- const readFile2 = deps.readFile ?? ((p) => readFileSync9(p, "utf8"));
11021
+ const exists = deps.exists ?? existsSync10;
11022
+ const readFile2 = deps.readFile ?? ((p) => readFileSync10(p, "utf8"));
10813
11023
  const writeFile3 = deps.writeFile ?? ((p, data) => {
10814
- writeFileSync7(`${p}.tmp`, data);
11024
+ writeFileSync8(`${p}.tmp`, data);
10815
11025
  renameSync4(`${p}.tmp`, p);
10816
11026
  });
10817
11027
  const host = deps.hostname ?? hostname;
@@ -10926,8 +11136,8 @@ import { basename as basename4 } from "path";
10926
11136
  import { serve as serve2 } from "@hono/node-server";
10927
11137
 
10928
11138
  // src/diff.ts
10929
- import { statSync as statSync8 } from "fs";
10930
- import { join as join12 } from "path";
11139
+ import { statSync as statSync9 } from "fs";
11140
+ import { join as join13 } from "path";
10931
11141
  import { $ as $3 } from "execa";
10932
11142
  var MAX_FILES = 200;
10933
11143
  var MAX_LINES_PER_FILE = 1500;
@@ -11070,7 +11280,7 @@ async function resolveBase(wt, baseBranch) {
11070
11280
  }
11071
11281
  function mtime(path) {
11072
11282
  try {
11073
- return statSync8(path).mtimeMs;
11283
+ return statSync9(path).mtimeMs;
11074
11284
  } catch {
11075
11285
  return 0;
11076
11286
  }
@@ -11095,7 +11305,7 @@ async function collectRunDiff(worktree, opts = {}) {
11095
11305
  files.push(pf);
11096
11306
  }
11097
11307
  }
11098
- files.sort((a, b) => mtime(join12(worktree, b.path)) - mtime(join12(worktree, a.path)));
11308
+ files.sort((a, b) => mtime(join13(worktree, b.path)) - mtime(join13(worktree, a.path)));
11099
11309
  const truncatedFiles = files.length > MAX_FILES;
11100
11310
  if (truncatedFiles) files = files.slice(0, MAX_FILES);
11101
11311
  const added = files.reduce((s, f) => s + f.added, 0);
@@ -13257,15 +13467,15 @@ import { cancelRun, respawnRun, runDaemon, wakeRun, OVERMIND_ENTRY, listDronePro
13257
13467
 
13258
13468
  // src/launcher.ts
13259
13469
  import { spawn as spawn2 } from "child_process";
13260
- import { closeSync as closeSync4, existsSync as existsSync10, mkdirSync as mkdirSync10, openSync as openSync4, readdirSync as readdirSync9 } from "fs";
13470
+ import { closeSync as closeSync4, existsSync as existsSync11, mkdirSync as mkdirSync11, openSync as openSync4, readdirSync as readdirSync10 } from "fs";
13261
13471
  import { createRequire } from "module";
13262
13472
  import { homedir as homedir5 } from "os";
13263
- import { dirname as dirname4, join as join15 } from "path";
13473
+ import { dirname as dirname4, join as join16 } from "path";
13264
13474
  import { fileURLToPath as fileURLToPath2 } from "url";
13265
13475
 
13266
13476
  // src/droneHome.ts
13267
- import { lstatSync, mkdirSync as mkdirSync9, readdirSync as readdirSync8, rmSync, statSync as statSync9, symlinkSync as symlinkSync3 } from "fs";
13268
- import { join as join14, relative, sep } from "path";
13477
+ import { lstatSync, mkdirSync as mkdirSync10, readdirSync as readdirSync9, rmSync, statSync as statSync10, symlinkSync as symlinkSync4 } from "fs";
13478
+ import { join as join15, relative, sep } from "path";
13269
13479
  var DRONE_HOME_DENY_DEFAULT = [".taskless-swarm", ".bash_history", ".zsh_history"];
13270
13480
  function droneHomeDeny(env = process.env) {
13271
13481
  const extra = (env.SWARM_DRONE_HOME_DENY || "").split(",").map((s) => s.trim()).filter(Boolean);
@@ -13283,34 +13493,34 @@ function buildDroneHome(opts) {
13283
13493
  const { realHome, droneHome } = opts;
13284
13494
  const deny = opts.deny ?? droneHomeDeny();
13285
13495
  const platform = opts.platform ?? process.platform;
13286
- mkdirSync9(droneHome, { recursive: true, mode: 448 });
13287
- const wanted = new Set(mirroredEntries(readdirSync8(realHome), deny, platform));
13496
+ mkdirSync10(droneHome, { recursive: true, mode: 448 });
13497
+ const wanted = new Set(mirroredEntries(readdirSync9(realHome), deny, platform));
13288
13498
  const rel = relative(realHome, droneHome);
13289
13499
  if (rel && !rel.startsWith("..") && !rel.includes(sep)) wanted.delete(rel);
13290
- for (const existing of readdirSync8(droneHome)) {
13500
+ for (const existing of readdirSync9(droneHome)) {
13291
13501
  if (wanted.has(existing)) continue;
13292
- const p = join14(droneHome, existing);
13502
+ const p = join15(droneHome, existing);
13293
13503
  try {
13294
13504
  if (lstatSync(p).isSymbolicLink()) rmSync(p);
13295
13505
  } catch {
13296
13506
  }
13297
13507
  }
13298
13508
  for (const name of wanted) {
13299
- const link = join14(droneHome, name);
13509
+ const link = join15(droneHome, name);
13300
13510
  try {
13301
13511
  lstatSync(link);
13302
13512
  continue;
13303
13513
  } catch {
13304
13514
  }
13305
- const target = join14(realHome, name);
13515
+ const target = join15(realHome, name);
13306
13516
  let isDir;
13307
13517
  try {
13308
- isDir = statSync9(target).isDirectory();
13518
+ isDir = statSync10(target).isDirectory();
13309
13519
  } catch {
13310
13520
  continue;
13311
13521
  }
13312
13522
  try {
13313
- symlinkSync3(target, link, isDir ? "junction" : "file");
13523
+ symlinkSync4(target, link, isDir ? "junction" : "file");
13314
13524
  } catch (e) {
13315
13525
  if (e.code !== "EEXIST") throw e;
13316
13526
  }
@@ -13323,7 +13533,7 @@ var REAL_PATH_ENV_PINS = [
13323
13533
  { env: "YARN_GLOBAL_FOLDER", segments: [".yarn", "berry"] }
13324
13534
  ];
13325
13535
  function realPathEnvPins(realHome) {
13326
- return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join14(realHome, ...segments)]));
13536
+ return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join15(realHome, ...segments)]));
13327
13537
  }
13328
13538
  function dronePrivatePaths(realHome, swarmHome) {
13329
13539
  return [
@@ -13407,7 +13617,7 @@ function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
13407
13617
  const env = { ...base3 };
13408
13618
  const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
13409
13619
  if (isolate && !base3.TURBO_CACHE_DIR) {
13410
- env.TURBO_CACHE_DIR = join15(worktree, ".turbo", "cache");
13620
+ env.TURBO_CACHE_DIR = join16(worktree, ".turbo", "cache");
13411
13621
  }
13412
13622
  Object.assign(env, droneTestEnv(droneCap, base3));
13413
13623
  for (const key of DAEMON_STATE_ENV) delete env[key];
@@ -13438,21 +13648,21 @@ var DAEMON_STATE_ENV = [
13438
13648
  ...PROVIDER_TOKEN_ENV
13439
13649
  ];
13440
13650
  function bundledRoleDir(kind) {
13441
- return join15(dirname4(fileURLToPath2(import.meta.url)), "..", "roles", kind);
13651
+ return join16(dirname4(fileURLToPath2(import.meta.url)), "..", "roles", kind);
13442
13652
  }
13443
13653
  function roleDir(worktree, kind) {
13444
- return join15(worktree, ".claude", "roles", kind);
13654
+ return join16(worktree, ".claude", "roles", kind);
13445
13655
  }
13446
13656
  function roleDirs(worktree, kind) {
13447
- return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync10(dir));
13657
+ return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync11(dir));
13448
13658
  }
13449
13659
  function nextRunLogPath(runLogsDir, runLogKeys) {
13450
13660
  const dir = runLogDirForWrite(runLogsDir, runLogKeys);
13451
13661
  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)");
13452
- mkdirSync10(dir, { recursive: true });
13662
+ mkdirSync11(dir, { recursive: true });
13453
13663
  let files = [];
13454
13664
  try {
13455
- files = readdirSync9(dir);
13665
+ files = readdirSync10(dir);
13456
13666
  } catch {
13457
13667
  }
13458
13668
  let next = 0;
@@ -13460,7 +13670,7 @@ function nextRunLogPath(runLogsDir, runLogKeys) {
13460
13670
  const m = /^(\d+)\.json/.exec(f);
13461
13671
  if (m) next = Math.max(next, Number(m[1]) + 1);
13462
13672
  }
13463
- return join15(dir, `${next}.json`);
13673
+ return join16(dir, `${next}.json`);
13464
13674
  }
13465
13675
  function openNextRunLog(runLogsDir, runLogKeys) {
13466
13676
  for (let attempt = 0; attempt < 50; attempt++) {
@@ -13552,9 +13762,9 @@ function makeLauncher(cfg) {
13552
13762
  }
13553
13763
  const realHome = cfg.droneIsolation?.realHome ?? homedir5();
13554
13764
  const home = cfg.droneIsolation ? buildDroneHome({ realHome, droneHome: cfg.droneIsolation.home }) : void 0;
13555
- if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync10(join15(cfg.droneIsolation.swarmHome, "token"))) {
13765
+ if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync11(join16(cfg.droneIsolation.swarmHome, "token"))) {
13556
13766
  console.error(
13557
- `[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 ${join15(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.`
13767
+ `[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 ${join16(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.`
13558
13768
  );
13559
13769
  }
13560
13770
  const executor = cfg.executor ?? executorForRun(run, cfg.swarmModels?.() ?? null);
@@ -14485,7 +14695,7 @@ async function runDaemonLogs(argv) {
14485
14695
  console.error(`\u043B\u043E\u0433 \u041F\u0420\u041E\u0413\u041E\u041D\u0410 \u2014 \u044D\u0442\u043E \xABswarm log ${stray}\xBB (\u0431\u0435\u0437 s). \xABswarm logs\xBB \u043F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0435\u0442 \u043B\u043E\u0433 \u0434\u0435\u043C\u043E\u043D\u0430; \u0447\u0438\u0441\u043B\u043E \u0441\u0442\u0440\u043E\u043A \u2014 \xABswarm logs -n 200\xBB.`);
14486
14696
  return 1;
14487
14697
  }
14488
- if (!existsSync18(DAEMON_LOG_PATH)) {
14698
+ if (!existsSync19(DAEMON_LOG_PATH)) {
14489
14699
  console.error(`\u043B\u043E\u0433\u0430 \u0434\u0435\u043C\u043E\u043D\u0430 \u043D\u0435\u0442: ${DAEMON_LOG_PATH}`);
14490
14700
  console.error("\u043E\u043D \u043F\u0438\u0448\u0435\u0442\u0441\u044F \u043F\u0440\u0438 \u0444\u043E\u043D\u043E\u0432\u043E\u043C \u0437\u0430\u043F\u0443\u0441\u043A\u0435 (swarm start). \u0414\u0435\u043C\u043E\u043D \u043F\u043E\u0434\u043D\u044F\u0442 \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435 (--foreground) \u2014 \u0432\u044B\u0432\u043E\u0434 \u0438\u0434\u0451\u0442 \u0442\u0443\u0434\u0430.");
14491
14701
  return 1;
@@ -14493,12 +14703,12 @@ async function runDaemonLogs(argv) {
14493
14703
  const head = tailFile(DAEMON_LOG_PATH, lines);
14494
14704
  if (head) console.log(head);
14495
14705
  if (!follow) return 0;
14496
- let pos = statSync12(DAEMON_LOG_PATH).size;
14706
+ let pos = statSync13(DAEMON_LOG_PATH).size;
14497
14707
  for (; ; ) {
14498
14708
  await sleep2(500);
14499
14709
  let size;
14500
14710
  try {
14501
- size = statSync12(DAEMON_LOG_PATH).size;
14711
+ size = statSync13(DAEMON_LOG_PATH).size;
14502
14712
  } catch {
14503
14713
  continue;
14504
14714
  }
@@ -14767,10 +14977,10 @@ function effectiveWorktreesDir() {
14767
14977
  legacyDir: WORKTREES_LEGACY_DIR,
14768
14978
  targetDir: WORKTREES_DIR,
14769
14979
  envOverride: process.env.SWARM_WORKTREES || "",
14770
- exists: (d) => existsSync18(d),
14980
+ exists: (d) => existsSync19(d),
14771
14981
  isNonEmptyDir: (d) => {
14772
14982
  try {
14773
- return readdirSync12(d).length > 0;
14983
+ return readdirSync13(d).length > 0;
14774
14984
  } catch {
14775
14985
  return false;
14776
14986
  }
@@ -14826,15 +15036,15 @@ async function scoutRepo(repo) {
14826
15036
  await $6({ reject: false })`git -C ${worktree} reset --hard ${baseRef}`;
14827
15037
  }
14828
15038
  await setWorktreeIdentity(worktree, name);
14829
- const abs = (rel) => join27(worktree, rel);
15039
+ const abs = (rel) => join28(worktree, rel);
14830
15040
  const code = await runRepoScout({
14831
15041
  repoFullName,
14832
15042
  repoPath: worktree,
14833
15043
  name,
14834
- readFile: (rel) => existsSync18(abs(rel)) ? readFileSync20(abs(rel), "utf8") : null,
15044
+ readFile: (rel) => existsSync19(abs(rel)) ? readFileSync21(abs(rel), "utf8") : null,
14835
15045
  writeFile: (rel, text) => {
14836
- mkdirSync11(dirname5(abs(rel)), { recursive: true });
14837
- writeFileSync15(abs(rel), text);
15046
+ mkdirSync12(dirname5(abs(rel)), { recursive: true });
15047
+ writeFileSync16(abs(rel), text);
14838
15048
  },
14839
15049
  runScout: (prompt) => new Promise((resolve5) => {
14840
15050
  const child = spawn3(bin, [...ISOLATION_FLAGS, "--dangerously-skip-permissions", "-p", prompt], {