@taskless-app/swarm 0.6.83 → 0.6.84

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 +42 -13
  2. package/dist/overmind.js +667 -163
  3. package/package.json +2 -2
package/dist/overmind.js CHANGED
@@ -756,6 +756,44 @@ var init_modelPolicy = __esm({
756
756
  }
757
757
  });
758
758
 
759
+ // ../swarm-core/src/modelLimits.ts
760
+ function limitWindowState(w) {
761
+ if (w.usedPct >= 100) return "out";
762
+ if (w.usedPct > LIMIT_NEAR_PCT) return "near";
763
+ return "ok";
764
+ }
765
+ function executorLimitLabel(id) {
766
+ return Object.hasOwn(EXECUTOR_LIMIT_LABEL, id) ? EXECUTOR_LIMIT_LABEL[id] : { card: id, short: id };
767
+ }
768
+ function limitWaitReason(input) {
769
+ const resetsAt = new Date(input.resetsAt).toISOString();
770
+ const text = input.text ?? `\u0423\u043F\u0451\u0440\u0441\u044F \u0432 \u043B\u0438\u043C\u0438\u0442 ${executorLimitLabel(input.executor).short}, \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442 \u043F\u043E\u0441\u043B\u0435 \u0441\u0431\u0440\u043E\u0441\u0430`;
771
+ return `limit-wait: ${input.executor} \u0434\u043E ${resetsAt}; ${text}`;
772
+ }
773
+ function parseLimitWait(stopReason) {
774
+ if (!stopReason) return null;
775
+ const match = /^limit-wait: (\S+) до (\S+);(?: |$)/.exec(stopReason);
776
+ if (!match || Number.isNaN(Date.parse(match[2]))) return null;
777
+ return { executor: match[1], resetsAt: match[2] };
778
+ }
779
+ function isLimitWait(stopReason) {
780
+ return parseLimitWait(stopReason) !== null;
781
+ }
782
+ var LIMIT_NEAR_PCT, LIMITS_STALE_MS, EXECUTOR_LIMIT_LABEL;
783
+ var init_modelLimits = __esm({
784
+ "../swarm-core/src/modelLimits.ts"() {
785
+ "use strict";
786
+ LIMIT_NEAR_PCT = 80;
787
+ LIMITS_STALE_MS = 20 * 6e4;
788
+ EXECUTOR_LIMIT_LABEL = {
789
+ kimi: { card: "Kimi Code", short: "Kimi" },
790
+ "claude-code": { card: "Claude Code", short: "Claude" },
791
+ codex: { card: "Codex", short: "Codex" },
792
+ grok: { card: "Grok", short: "Grok" }
793
+ };
794
+ }
795
+ });
796
+
759
797
  // ../swarm-core/src/status.ts
760
798
  function isAwaitingCi(status, stopReason) {
761
799
  return status === "paused" && stopReason === AWAITING_CI_REASON;
@@ -2164,6 +2202,7 @@ var init_src = __esm({
2164
2202
  init_verifyVerdict();
2165
2203
  init_returnReason();
2166
2204
  init_modelPolicy();
2205
+ init_modelLimits();
2167
2206
  init_status();
2168
2207
  init_deps();
2169
2208
  init_time();
@@ -3277,7 +3316,7 @@ var init_kimi = __esm({
3277
3316
  },
3278
3317
  probe: {
3279
3318
  args: ["-p", "ok", "--output-format", "stream-json"],
3280
- limitPattern: /usage limit|quota|rate.limit|too many requests/i,
3319
+ limitPattern: /usage limit|insufficient[_ ]quota/i,
3281
3320
  authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
3282
3321
  }
3283
3322
  };
@@ -4102,14 +4141,25 @@ function plural(n, forms) {
4102
4141
  const d = n % 10;
4103
4142
  return forms[m >= 11 && m <= 14 ? 2 : d === 1 ? 0 : d >= 2 && d <= 4 ? 1 : 2];
4104
4143
  }
4105
- function stormStartReason(s, cfg) {
4144
+ function stormStartText(providerName) {
4145
+ return `\u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (${providerName} \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442)`;
4146
+ }
4147
+ function stormDeadText(providerName) {
4148
+ return `${stormStartText(providerName)} \u2014 \u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435, worktree \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D, \u043F\u043E\u0434\u044A\u0451\u043C \u043F\u043E\u0441\u043B\u0435 \u043E\u0442\u0431\u043E\u044F`;
4149
+ }
4150
+ function stormStartReason(s, cfg, providerName) {
4106
4151
  const why = [];
4107
4152
  if (s.deaths >= cfg.deathThreshold)
4108
4153
  why.push(`${s.deaths} ${plural(s.deaths, ["\u0441\u043C\u0435\u0440\u0442\u044C", "\u0441\u043C\u0435\u0440\u0442\u0438", "\u0441\u043C\u0435\u0440\u0442\u0435\u0439"])} \u0434\u0440\u043E\u043D\u043E\u0432 \u0437\u0430 ${Math.round(cfg.windowMs / 6e4)} \u043C\u0438\u043D`);
4109
4154
  if (s.spawnFails >= cfg.spawnFailThreshold)
4110
4155
  why.push(`${s.spawnFails} ${plural(s.spawnFails, ["\u0441\u043F\u0430\u0432\u043D-\u0444\u0435\u0439\u043B", "\u0441\u043F\u0430\u0432\u043D-\u0444\u0435\u0439\u043B\u0430", "\u0441\u043F\u0430\u0432\u043D-\u0444\u0435\u0439\u043B\u043E\u0432"])} \u043F\u043E\u0434\u0440\u044F\u0434`);
4111
- if (s.externalDown) why.push("\u0432\u043D\u0435\u0448\u043D\u0438\u0439 \u0441\u0438\u0433\u043D\u0430\u043B: Anthropic down");
4112
- return `${STORM_START_TEXT} \u2014 ${why.join("; ") || "\u044D\u0432\u0440\u0438\u0441\u0442\u0438\u043A\u0430"}`;
4156
+ if (s.externalDown) why.push(`\u0432\u043D\u0435\u0448\u043D\u0438\u0439 \u0441\u0438\u0433\u043D\u0430\u043B: ${providerName} down`);
4157
+ return `${stormStartText(providerName)} \u2014 ${why.join("; ") || "\u044D\u0432\u0440\u0438\u0441\u0442\u0438\u043A\u0430"}`;
4158
+ }
4159
+ function stormLongText(input) {
4160
+ const minutes = Math.max(1, Math.round((input.now - input.startedAtMs) / 6e4));
4161
+ const since = new Date(input.startedAtMs).toISOString().slice(0, 16).replace("T", " ");
4162
+ return `${input.hostName} \u0441\u0442\u043E\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C\u0435 ${minutes} ${plural(minutes, ["\u043C\u0438\u043D\u0443\u0442\u0443", "\u043C\u0438\u043D\u0443\u0442\u044B", "\u043C\u0438\u043D\u0443\u0442"])} (\u0441 ${since} UTC): \u043F\u0440\u043E\u0431\u0430 ${input.providerName} \u043D\u0435 \u043F\u0440\u043E\u0445\u043E\u0434\u0438\u0442 (${input.reason}). \u041F\u0440\u043E\u0432\u0435\u0440\u044C \u043C\u043E\u0434\u0435\u043B\u044C \u0434\u0440\u043E\u043D\u043E\u0432 \u0432 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u0445 \u0440\u043E\u044F.`;
4113
4163
  }
4114
4164
  function trailingProbeSuccesses(recs) {
4115
4165
  let n = 0;
@@ -4128,7 +4178,7 @@ function lastExternalDown(recs) {
4128
4178
  function stormShouldEnd(s, cfg) {
4129
4179
  return s.consecutiveProbeOk >= cfg.probeSuccessesToClear && !s.externalDown;
4130
4180
  }
4131
- var numEnv, DEFAULT_STORM_CONFIG, STORM_START_TEXT, STORM_END_TEXT, STORM_HEALTHY_DEATHS_TEXT, STORM_DEAD_TEXT, STORM_RESUME_CONTINUE_TEXT, STORM_RESUME_FRESH_TEXT;
4181
+ var numEnv, DEFAULT_STORM_CONFIG, STORM_END_TEXT, STORM_HEALTHY_DEATHS_TEXT, STORM_RESUME_CONTINUE_TEXT, STORM_RESUME_FRESH_TEXT;
4132
4182
  var init_storm = __esm({
4133
4183
  "src/storm.ts"() {
4134
4184
  "use strict";
@@ -4144,12 +4194,11 @@ var init_storm = __esm({
4144
4194
  probeIntervalMs: numEnv("SWARM_STORM_PROBE_INTERVAL_MS", 60 * 1e3),
4145
4195
  probeSuccessesToClear: numEnv("SWARM_STORM_PROBE_CLEAR", 2),
4146
4196
  probeTimeoutMs: numEnv("SWARM_STORM_PROBE_TIMEOUT_MS", 20 * 1e3),
4147
- restartCooldownMs: numEnv("SWARM_STORM_RESTART_COOLDOWN_MS", 3 * 60 * 1e3)
4197
+ restartCooldownMs: numEnv("SWARM_STORM_RESTART_COOLDOWN_MS", 3 * 60 * 1e3),
4198
+ notifyMs: numEnv("SWARM_STORM_NOTIFY_MS", 30 * 60 * 1e3)
4148
4199
  };
4149
- STORM_START_TEXT = "\u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442)";
4150
4200
  STORM_END_TEXT = "\u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u2014 \u0420\u043E\u0439 \u043F\u0440\u043E\u0431\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044F";
4151
4201
  STORM_HEALTHY_DEATHS_TEXT = "\u0434\u0440\u043E\u043D\u044B \u043C\u0440\u0443\u0442 \u043F\u0440\u0438 \u0436\u0438\u0432\u043E\u043C API (health-probe \u0437\u0435\u043B\u0451\u043D\u0430\u044F) \u2014 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u0430\u044F \u043F\u0440\u043E\u0431\u043B\u0435\u043C\u0430, \u0441\u043C\u043E\u0442\u0440\u0438 \u043B\u043E\u0433\u0438 \u0440\u043E\u044F; \u0432 \u0448\u0442\u043E\u0440\u043C \u043D\u0435 \u0443\u0445\u043E\u0436\u0443";
4152
- STORM_DEAD_TEXT = "\u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442) \u2014 \u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435, worktree \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D, \u043F\u043E\u0434\u044A\u0451\u043C \u043F\u043E\u0441\u043B\u0435 \u043E\u0442\u0431\u043E\u044F";
4153
4202
  STORM_RESUME_CONTINUE_TEXT = "\u0434\u0440\u043E\u043D \u0432\u044B\u0448\u0435\u043B \u0438\u0437 \u043A\u043E\u043A\u043E\u043D\u0430 \u2014 \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0435\u0442 \u0441 \u043C\u0435\u0441\u0442\u0430 \u043E\u0431\u0440\u044B\u0432\u0430 (--continue)";
4154
4203
  STORM_RESUME_FRESH_TEXT = "\u0434\u0440\u043E\u043D \u0432\u044B\u0448\u0435\u043B \u0438\u0437 \u043A\u043E\u043A\u043E\u043D\u0430 \u2014 \u0441\u0442\u0430\u0440\u0442 \u0437\u0430\u043D\u043E\u0432\u043E (\u0441\u0435\u0441\u0441\u0438\u044F/worktree \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B, \u0440\u0430\u0431\u043E\u0442\u0430 \u0432 origin)";
4155
4204
  }
@@ -4955,9 +5004,9 @@ var init_procCleanup = __esm({
4955
5004
  });
4956
5005
 
4957
5006
  // src/git.ts
4958
- import { existsSync as existsSync14, readdirSync as readdirSync14, realpathSync as realpathSync2, statSync as statSync12 } from "fs";
5007
+ import { existsSync as existsSync14, readdirSync as readdirSync16, realpathSync as realpathSync2, statSync as statSync13 } from "fs";
4959
5008
  import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
4960
- import { isAbsolute as isAbsolute3, join as join23, resolve as resolve3, sep as sep2 } from "path";
5009
+ import { isAbsolute as isAbsolute3, join as join25, resolve as resolve3, sep as sep2 } from "path";
4961
5010
  import { $ as $2 } from "execa";
4962
5011
  function gitNet(repo, args, timeoutMs) {
4963
5012
  return withHardTimeout(
@@ -4981,12 +5030,12 @@ async function reclaimStaleWorktree(repo, worktree) {
4981
5030
  async function inspectWorktreePath(path) {
4982
5031
  if (!existsSync14(path)) return "free";
4983
5032
  try {
4984
- if (readdirSync14(path).length === 0) return "free";
5033
+ if (readdirSync16(path).length === 0) return "free";
4985
5034
  } catch {
4986
5035
  return "orphan";
4987
5036
  }
4988
5037
  try {
4989
- if (statSync12(join23(path, ".git")).isDirectory()) return "main-checkout";
5038
+ if (statSync13(join25(path, ".git")).isDirectory()) return "main-checkout";
4990
5039
  } catch {
4991
5040
  }
4992
5041
  const top = await $2({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
@@ -5046,7 +5095,7 @@ async function parkOrphanDir(repo, path, branch) {
5046
5095
  }
5047
5096
  function isLinkedWorktree(dir) {
5048
5097
  try {
5049
- return statSync12(join23(dir, ".git")).isFile();
5098
+ return statSync13(join25(dir, ".git")).isFile();
5050
5099
  } catch {
5051
5100
  return false;
5052
5101
  }
@@ -5158,8 +5207,8 @@ async function ensureGitExcluded(worktree, pattern) {
5158
5207
  try {
5159
5208
  const commonDir = await gitPath(worktree, "--git-common-dir");
5160
5209
  if (!commonDir) return false;
5161
- const infoDir = join23(commonDir, "info");
5162
- const excludeFile = join23(infoDir, "exclude");
5210
+ const infoDir = join25(commonDir, "info");
5211
+ const excludeFile = join25(infoDir, "exclude");
5163
5212
  let current = "";
5164
5213
  try {
5165
5214
  current = await readFile(excludeFile, "utf8");
@@ -5179,7 +5228,7 @@ async function gitPath(worktree, flag) {
5179
5228
  const out = await $2({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
5180
5229
  const raw = out.stdout.trim();
5181
5230
  if (out.exitCode !== 0 || !raw) return null;
5182
- return isAbsolute3(raw) ? raw : join23(worktree, raw);
5231
+ return isAbsolute3(raw) ? raw : join25(worktree, raw);
5183
5232
  }
5184
5233
  async function ensureWorktreeHygiene(worktree) {
5185
5234
  for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
@@ -5189,12 +5238,12 @@ async function installGuardHooks(worktree) {
5189
5238
  try {
5190
5239
  const gitDir = await gitPath(worktree, "--git-dir");
5191
5240
  if (!gitDir) return false;
5192
- const hooksDir = join23(gitDir, "swarm-hooks");
5241
+ const hooksDir = join25(gitDir, "swarm-hooks");
5193
5242
  const prev = await previousHooksPath(worktree);
5194
5243
  await mkdir(hooksDir, { recursive: true });
5195
5244
  for (const hook of GUARD_HOOKS) {
5196
- await writeFile(join23(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
5197
- await chmod(join23(hooksDir, hook), 493);
5245
+ await writeFile(join25(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
5246
+ await chmod(join25(hooksDir, hook), 493);
5198
5247
  }
5199
5248
  await $2`git -C ${worktree} config extensions.worktreeConfig true`;
5200
5249
  await $2`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
@@ -5213,7 +5262,7 @@ async function previousHooksPath(worktree) {
5213
5262
  if (out.exitCode === 0 && value) return value;
5214
5263
  }
5215
5264
  const commonDir = await gitPath(worktree, "--git-common-dir");
5216
- return commonDir ? join23(commonDir, "hooks") : null;
5265
+ return commonDir ? join25(commonDir, "hooks") : null;
5217
5266
  }
5218
5267
  async function removeWorktree(repo, path) {
5219
5268
  const branch = (await $2({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
@@ -5238,7 +5287,7 @@ async function worktreeDirty(path) {
5238
5287
  async function repairMovedWorktrees(targetDir) {
5239
5288
  const subdirs = (dir) => {
5240
5289
  try {
5241
- return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join23(dir, d.name));
5290
+ return readdirSync16(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join25(dir, d.name));
5242
5291
  } catch {
5243
5292
  return [];
5244
5293
  }
@@ -5375,12 +5424,12 @@ __export(droneChannel_exports, {
5375
5424
  verifyLocalCliToken: () => verifyLocalCliToken
5376
5425
  });
5377
5426
  import { createHmac, randomBytes, timingSafeEqual } from "crypto";
5378
- import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "fs";
5427
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "fs";
5379
5428
  import { dirname as dirname5 } from "path";
5380
5429
  import { serve } from "@hono/node-server";
5381
5430
  function loadChannelSecret(path) {
5382
5431
  try {
5383
- const s = readFileSync21(path, "utf8").trim();
5432
+ const s = readFileSync22(path, "utf8").trim();
5384
5433
  if (s.length >= 32) return s;
5385
5434
  } catch {
5386
5435
  }
@@ -5776,7 +5825,7 @@ var init_droneChannel = __esm({
5776
5825
 
5777
5826
  // src/attachments.ts
5778
5827
  import { mkdir as mkdir3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
5779
- import { join as join28 } from "path";
5828
+ import { join as join30 } from "path";
5780
5829
  function attachmentsFromDoc(doc, origin) {
5781
5830
  const out = [];
5782
5831
  const walk2 = (node) => {
@@ -5867,7 +5916,7 @@ async function materializeAttachments(opts) {
5867
5916
  };
5868
5917
  const result = { files: [], skipped: [] };
5869
5918
  if (opts.refs.length === 0) return result;
5870
- const dir = join28(opts.worktree, ATTACHMENTS_DIR);
5919
+ const dir = join30(opts.worktree, ATTACHMENTS_DIR);
5871
5920
  await io.removeDir(dir);
5872
5921
  let dirReady = false;
5873
5922
  let total = 0;
@@ -5913,7 +5962,7 @@ async function materializeAttachments(opts) {
5913
5962
  await io.mkdir(dir);
5914
5963
  dirReady = true;
5915
5964
  }
5916
- await io.writeFile(join28(dir, name), file.bytes);
5965
+ await io.writeFile(join30(dir, name), file.bytes);
5917
5966
  } catch (e) {
5918
5967
  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)})`);
5919
5968
  continue;
@@ -6066,7 +6115,7 @@ var init_attachments = __esm({
6066
6115
 
6067
6116
  // src/shotUpload.ts
6068
6117
  import { readFile as fsReadFile } from "fs/promises";
6069
- import { basename as basename4, isAbsolute as isAbsolute4, join as join29 } from "path";
6118
+ import { basename as basename4, isAbsolute as isAbsolute4, join as join31 } from "path";
6070
6119
  function shotMimetype(path) {
6071
6120
  const dot = path.lastIndexOf(".");
6072
6121
  if (dot < 0) return null;
@@ -6092,7 +6141,7 @@ async function readShots(paths, opts) {
6092
6141
  }
6093
6142
  let bytes;
6094
6143
  try {
6095
- bytes = await read(isAbsolute4(path) ? path : join29(opts.worktree, path));
6144
+ bytes = await read(isAbsolute4(path) ? path : join31(opts.worktree, path));
6096
6145
  } catch (e) {
6097
6146
  skipped.push({ path, reason: `\u043D\u0435 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D: ${e instanceof Error ? e.message : String(e)}` });
6098
6147
  continue;
@@ -6172,12 +6221,12 @@ var init_shotUpload = __esm({
6172
6221
  });
6173
6222
 
6174
6223
  // src/oauth.ts
6175
- import { createHash as createHash3, randomBytes as randomBytes2 } from "crypto";
6176
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, unlinkSync as unlinkSync4 } from "fs";
6177
- import { join as join30 } from "path";
6224
+ import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
6225
+ import { readFileSync as readFileSync23, writeFileSync as writeFileSync15, unlinkSync as unlinkSync4 } from "fs";
6226
+ import { join as join32 } from "path";
6178
6227
  function makePkce() {
6179
6228
  const verifier = randomBytes2(48).toString("base64url");
6180
- const challenge = createHash3("sha256").update(verifier).digest("base64url");
6229
+ const challenge = createHash4("sha256").update(verifier).digest("base64url");
6181
6230
  return { verifier, challenge };
6182
6231
  }
6183
6232
  async function registerClient(args, fetchFn = fetch) {
@@ -6258,7 +6307,7 @@ function toStore(clientId, t, now) {
6258
6307
  }
6259
6308
  function loadStore() {
6260
6309
  try {
6261
- return JSON.parse(readFileSync22(STORE_PATH2, "utf8"));
6310
+ return JSON.parse(readFileSync23(STORE_PATH2, "utf8"));
6262
6311
  } catch {
6263
6312
  return null;
6264
6313
  }
@@ -6274,7 +6323,7 @@ function clearStore() {
6274
6323
  }
6275
6324
  function loadClientId() {
6276
6325
  try {
6277
- return JSON.parse(readFileSync22(CLIENT_PATH, "utf8")).clientId;
6326
+ return JSON.parse(readFileSync23(CLIENT_PATH, "utf8")).clientId;
6278
6327
  } catch {
6279
6328
  return null;
6280
6329
  }
@@ -6309,8 +6358,8 @@ var init_oauth = __esm({
6309
6358
  AUTHORIZE = "/api/oauth/authorize";
6310
6359
  TOKEN = "/api/oauth/token";
6311
6360
  SCOPE = "openid profile email taskless:full";
6312
- STORE_PATH2 = join30(SWARM_HOME, "oauth.json");
6313
- CLIENT_PATH = join30(SWARM_HOME, "oauth-client.json");
6361
+ STORE_PATH2 = join32(SWARM_HOME, "oauth.json");
6362
+ CLIENT_PATH = join32(SWARM_HOME, "oauth-client.json");
6314
6363
  base2 = (api) => api.replace(/\/$/, "");
6315
6364
  }
6316
6365
  });
@@ -6397,11 +6446,11 @@ var init_authState = __esm({
6397
6446
  });
6398
6447
 
6399
6448
  // src/workspace.ts
6400
- import { readFileSync as readFileSync23, writeFileSync as writeFileSync16, unlinkSync as unlinkSync5 } from "fs";
6401
- import { join as join31 } from "path";
6449
+ import { readFileSync as readFileSync24, writeFileSync as writeFileSync16, unlinkSync as unlinkSync5 } from "fs";
6450
+ import { join as join33 } from "path";
6402
6451
  function loadWorkspace() {
6403
6452
  try {
6404
- const w = JSON.parse(readFileSync23(WORKSPACE_PATH, "utf8"));
6453
+ const w = JSON.parse(readFileSync24(WORKSPACE_PATH, "utf8"));
6405
6454
  return w && typeof w.id === "string" && w.id ? w : null;
6406
6455
  } catch {
6407
6456
  return null;
@@ -6415,7 +6464,7 @@ var init_workspace = __esm({
6415
6464
  "src/workspace.ts"() {
6416
6465
  "use strict";
6417
6466
  init_config();
6418
- WORKSPACE_PATH = join31(SWARM_HOME, "workspace.json");
6467
+ WORKSPACE_PATH = join33(SWARM_HOME, "workspace.json");
6419
6468
  }
6420
6469
  });
6421
6470
 
@@ -8088,9 +8137,9 @@ var init_droneStore = __esm({
8088
8137
  });
8089
8138
 
8090
8139
  // src/overmind.ts
8091
- import { homedir as homedir7 } from "os";
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";
8140
+ import { homedir as homedir8 } from "os";
8141
+ import { existsSync as existsSync23, readFileSync as readFileSync28, readdirSync as readdirSync18, renameSync as renameSync12, statSync as statSync16 } from "fs";
8142
+ import { basename as basename6, dirname as dirname6, join as join40 } from "path";
8094
8143
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
8095
8144
  import { spawn as spawn4 } from "child_process";
8096
8145
 
@@ -8568,6 +8617,8 @@ var SwarmClient = class _SwarmClient {
8568
8617
  // TAS-956: момент отказа taskSlug по тулу. Окно и детектор — slugRetry.
8569
8618
  // Свой экземпляр: отказ этого клиента не общий с makeTasklessClient.
8570
8619
  slugRetry;
8620
+ // TASWM-643: старый прод может не знать modelLimits; окно повторной пробы отдельное от taskSlug.
8621
+ modelLimitsRetry;
8571
8622
  // Корреляция с продом.
8572
8623
  keyByLocal = /* @__PURE__ */ new Map();
8573
8624
  // local run id → runKey
@@ -8612,6 +8663,7 @@ var SwarmClient = class _SwarmClient {
8612
8663
  constructor(opts) {
8613
8664
  this.now = opts.now ?? Date.now;
8614
8665
  this.slugRetry = new SlugUnsupportedAt(this.now);
8666
+ this.modelLimitsRetry = new SlugUnsupportedAt(this.now);
8615
8667
  this.call = opts.call;
8616
8668
  this.defaultRepo = normalizeRepo(opts.defaultRepo ?? "");
8617
8669
  this.autoFlush = opts.autoFlush ?? true;
@@ -10307,7 +10359,7 @@ var SwarmClient = class _SwarmClient {
10307
10359
  *
10308
10360
  * Прод недоступен / ответ без поручений → пустые списки (демон работает дальше).
10309
10361
  */
10310
- async heartbeat(daemonVersion, pause, capacity, resources, storm, worktreesDir, signIn, tick, executors, providers) {
10362
+ async heartbeat(daemonVersion, pause, capacity, resources, storm, worktreesDir, signIn, tick, executors, providers, modelLimits) {
10311
10363
  try {
10312
10364
  const args = this.repoFullNames.length ? { repoFullNames: this.repoFullNames } : {};
10313
10365
  if (daemonVersion) args.daemonVersion = daemonVersion;
@@ -10339,7 +10391,14 @@ var SwarmClient = class _SwarmClient {
10339
10391
  }
10340
10392
  if (executors) args.executorsAvailable = executors;
10341
10393
  if (providers) args.providersAvailable = providers;
10342
- const res = await this.call("swarm_heartbeat", args);
10394
+ if (modelLimits && !this.modelLimitsRetry.within("modelLimits")) args.modelLimits = modelLimits;
10395
+ let res = await this.call("swarm_heartbeat", args);
10396
+ if (res?.isError && args.modelLimits !== void 0 && unknownArg(toolErrorText(res), "modelLimits")) {
10397
+ this.modelLimitsRetry.note("modelLimits");
10398
+ const retryArgs = { ...args };
10399
+ delete retryArgs.modelLimits;
10400
+ res = await this.call("swarm_heartbeat", retryArgs);
10401
+ }
10343
10402
  if (res?.isError) return EMPTY_HEARTBEAT_REPLY;
10344
10403
  this.heartbeatOkAt = this.now();
10345
10404
  const data = res?.structuredContent ?? {};
@@ -12058,7 +12117,7 @@ function envCapUsd(env) {
12058
12117
  return Number.isFinite(n) && n >= 0 ? n : DEFAULT_RUN_LIMITS.maxCostUsd;
12059
12118
  }
12060
12119
  function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
12061
- const env = { ...base3 };
12120
+ const env = { ...base3, TASKLESS_SWARM_DRONE: "1" };
12062
12121
  const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
12063
12122
  if (isolate && !base3.TURBO_CACHE_DIR) {
12064
12123
  env.TURBO_CACHE_DIR = join19(worktree, ".turbo", "cache");
@@ -12460,6 +12519,154 @@ function makeAbortReader(runLogsDir, runLogKeys, executorFor = () => resolveExec
12460
12519
  return (run2) => abortOfExit(runLogsDir, runLogKeys(run2.id), executorFor(run2));
12461
12520
  }
12462
12521
 
12522
+ // src/limitWait.ts
12523
+ init_src();
12524
+ import { closeSync as closeSync5, fstatSync as fstatSync2, openSync as openSync5, readdirSync as readdirSync14, readSync as readSync2 } from "fs";
12525
+ import { join as join22 } from "path";
12526
+ var TAIL_BYTES = 8 * 1024;
12527
+ var SNAPSHOT_FRESH_MS = 15 * 6e4;
12528
+ var RESULT_FILE_RE2 = /^(\d+)\.json(\.done)?$/;
12529
+ var STDERR_FILE_RE = /^(\d+)\.err\.log$/;
12530
+ var RESET_RE = /resets[^\n]*/i;
12531
+ function readTail2(path, dropPartialFirstLine = false) {
12532
+ let fd;
12533
+ try {
12534
+ fd = openSync5(path, "r");
12535
+ } catch {
12536
+ return null;
12537
+ }
12538
+ try {
12539
+ const size = fstatSync2(fd).size;
12540
+ const length = Math.min(size, TAIL_BYTES);
12541
+ const buffer = Buffer.alloc(length);
12542
+ readSync2(fd, buffer, 0, length, Math.max(0, size - length));
12543
+ const text = buffer.toString("utf8");
12544
+ return dropPartialFirstLine && size > TAIL_BYTES ? text.replace(/^[^\n]*(?:\n|$)/, "") : text;
12545
+ } catch {
12546
+ return null;
12547
+ } finally {
12548
+ closeSync5(fd);
12549
+ }
12550
+ }
12551
+ function latestLaunch(logsDir, keys) {
12552
+ const dir = findRunLogDir(logsDir, keys);
12553
+ if (!dir) return null;
12554
+ let latest = null;
12555
+ let files;
12556
+ try {
12557
+ files = readdirSync14(dir);
12558
+ } catch {
12559
+ return null;
12560
+ }
12561
+ for (const name of files) {
12562
+ const result = RESULT_FILE_RE2.exec(name);
12563
+ const stderr = STDERR_FILE_RE.exec(name);
12564
+ if (!result && !stderr) continue;
12565
+ const index = Number((result ?? stderr)[1]);
12566
+ if (!latest || index > latest.index) latest = { index, stdoutName: result ? name : null };
12567
+ else if (index === latest.index && result) latest.stdoutName = name;
12568
+ }
12569
+ return latest ? { dir, ...latest } : null;
12570
+ }
12571
+ function matchesLimit(pattern, text) {
12572
+ pattern.lastIndex = 0;
12573
+ return pattern.test(text);
12574
+ }
12575
+ function nonJsonLines(raw) {
12576
+ const lines = raw.split(/\r?\n/);
12577
+ if (!/\r?\n$/.test(raw)) lines.pop();
12578
+ return lines.filter((line) => {
12579
+ const trimmed = line.trim();
12580
+ if (!trimmed) return false;
12581
+ try {
12582
+ const parsed = JSON.parse(trimmed);
12583
+ return parsed === null || typeof parsed !== "object" || Array.isArray(parsed);
12584
+ } catch {
12585
+ return true;
12586
+ }
12587
+ }).join("\n");
12588
+ }
12589
+ function exhaustedWindows(report, executor) {
12590
+ const model = report?.models.find((item) => item.executor === executor);
12591
+ return model?.windows.filter((window) => limitWindowState(window) === "out") ?? [];
12592
+ }
12593
+ function latestExhaustedWindow(report, executor) {
12594
+ const windows = exhaustedWindows(report, executor);
12595
+ let latest = null;
12596
+ for (const window of windows) {
12597
+ const resetMs = window.resetsAt ? Date.parse(window.resetsAt) : Number.NaN;
12598
+ if (!Number.isFinite(resetMs)) continue;
12599
+ if (!latest || resetMs > latest.resetMs) latest = { window, resetMs };
12600
+ }
12601
+ return latest?.window ?? windows[0] ?? null;
12602
+ }
12603
+ function resetFromHint(resetHint, nowMs) {
12604
+ const relative2 = /resets\s+in\s+(?:(\d+)\s*h)?\s*(?:(\d+)\s*m)?/i.exec(resetHint);
12605
+ if (relative2 && (relative2[1] || relative2[2])) {
12606
+ return nowMs + (Number(relative2[1] ?? 0) * 60 + Number(relative2[2] ?? 0)) * 6e4;
12607
+ }
12608
+ const clock = /resets(?:\s+at)?\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/i.exec(resetHint);
12609
+ if (!clock) return null;
12610
+ let hour = Number(clock[1]);
12611
+ const minute = Number(clock[2] ?? 0);
12612
+ const meridiem = clock[3]?.toLowerCase();
12613
+ if (minute >= 60 || (meridiem ? hour < 1 || hour > 12 : hour >= 24)) return null;
12614
+ if (meridiem === "pm" && hour !== 12) hour += 12;
12615
+ if (meridiem === "am" && hour === 12) hour = 0;
12616
+ const reset = new Date(nowMs);
12617
+ reset.setHours(hour, minute, 0, 0);
12618
+ if (reset.getTime() <= nowMs) reset.setDate(reset.getDate() + 1);
12619
+ return reset.getTime();
12620
+ }
12621
+ function makeLimitReader(logsDir, logKeys, executorOf, snapshot = () => null) {
12622
+ return (run2) => {
12623
+ const executor = executorOf(run2);
12624
+ const launch = latestLaunch(logsDir, logKeys(run2.id));
12625
+ if (!launch) return null;
12626
+ const stderr = readTail2(join22(launch.dir, `${launch.index}.err.log`)) ?? "";
12627
+ const stdout = launch.stdoutName ? readTail2(join22(launch.dir, launch.stdoutName), true) ?? "" : "";
12628
+ const stdoutText = nonJsonLines(stdout);
12629
+ const limitText = matchesLimit(executor.probe.limitPattern, stderr) ? stderr : matchesLimit(executor.probe.limitPattern, stdoutText) ? stdoutText : null;
12630
+ if (limitText !== null) {
12631
+ return { executor: executor.id, resetHint: limitText.match(RESET_RE)?.[0]?.trim() ?? null };
12632
+ }
12633
+ if (executor.id === "kimi") {
12634
+ const report = snapshot();
12635
+ const model = report?.models.find((item) => item.executor === "kimi");
12636
+ const fetchedMs = model?.fetchedAt ? Date.parse(model.fetchedAt) : Number.NaN;
12637
+ if (Number.isFinite(fetchedMs) && Date.now() - fetchedMs <= SNAPSHOT_FRESH_MS && exhaustedWindows(report, "kimi").length > 0) {
12638
+ return { executor: "kimi", resetHint: null };
12639
+ }
12640
+ if (stderr.trim()) {
12641
+ console.error(`[overmind] Kimi #${run2.id} \u0443\u043C\u0435\u0440 \u0431\u0435\u0437 \u0438\u0437\u0432\u0435\u0441\u0442\u043D\u043E\u0439 \u0444\u0440\u0430\u0437\u044B \u043B\u0438\u043C\u0438\u0442\u0430; err.log: ${stderr.slice(0, 300).replace(/[\r\n]+/g, " ")}`);
12642
+ }
12643
+ }
12644
+ return null;
12645
+ };
12646
+ }
12647
+ function limitResetAt(input) {
12648
+ const model = input.report?.models.find((item) => item.executor === input.executor);
12649
+ const fetchedMs = model?.fetchedAt ? Date.parse(model.fetchedAt) : Number.NaN;
12650
+ const fresh = Number.isFinite(fetchedMs) && input.nowMs - fetchedMs <= SNAPSHOT_FRESH_MS;
12651
+ const latest = fresh ? latestExhaustedWindow(input.report, input.executor) : null;
12652
+ const reportResetMs = latest?.resetsAt ? Date.parse(latest.resetsAt) : Number.NaN;
12653
+ if (Number.isFinite(reportResetMs) && reportResetMs > input.nowMs) return new Date(reportResetMs).toISOString();
12654
+ const hintResetMs = input.resetHint ? resetFromHint(input.resetHint, input.nowMs) : null;
12655
+ return new Date(hintResetMs !== null && hintResetMs > input.nowMs ? hintResetMs : input.nowMs + 30 * 6e4).toISOString();
12656
+ }
12657
+ function limitWaitWindow(report, executor) {
12658
+ return latestExhaustedWindow(report, executor)?.window ?? null;
12659
+ }
12660
+ function limitWaitText(executor, window) {
12661
+ const label2 = executorLimitLabel(executor).short;
12662
+ const period = window === "5h" ? " \u0437\u0430 5 \u0447\u0430\u0441\u043E\u0432" : window === "week" ? " \u0437\u0430 \u043D\u0435\u0434\u0435\u043B\u044E" : window === "month" ? " \u0437\u0430 \u043C\u0435\u0441\u044F\u0446" : "";
12663
+ return `\u0423\u043F\u0451\u0440\u0441\u044F \u0432 \u043B\u0438\u043C\u0438\u0442 ${label2}${period}, \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442 \u043F\u043E\u0441\u043B\u0435 \u0441\u0431\u0440\u043E\u0441\u0430`;
12664
+ }
12665
+ function isLimitWaitDue(stopReason, nowMs) {
12666
+ const wait = parseLimitWait(stopReason);
12667
+ return wait !== null && Date.parse(wait.resetsAt) <= nowMs;
12668
+ }
12669
+
12463
12670
  // src/overmind.ts
12464
12671
  init_executors();
12465
12672
  init_claudeCode();
@@ -12471,7 +12678,7 @@ init_src();
12471
12678
  init_swarmModels();
12472
12679
  init_executors();
12473
12680
  import { accessSync, constants } from "fs";
12474
- import { delimiter, join as join22 } from "path";
12681
+ import { delimiter, join as join23 } from "path";
12475
12682
  function binRunnable(bin, env) {
12476
12683
  if (!bin) return false;
12477
12684
  if (bin.includes("/") || bin.includes("\\")) {
@@ -12487,7 +12694,7 @@ function binRunnable(bin, env) {
12487
12694
  if (!dir) continue;
12488
12695
  for (const ext of exts) {
12489
12696
  try {
12490
- accessSync(join22(dir, bin + ext), constants.X_OK);
12697
+ accessSync(join23(dir, bin + ext), constants.X_OK);
12491
12698
  return true;
12492
12699
  } catch {
12493
12700
  }
@@ -12529,33 +12736,198 @@ function providerUnavailableReason(providerId, available) {
12529
12736
  return `provider_unavailable: \u043C\u043E\u0434\u0435\u043B\u044C \u043F\u0440\u043E\u0433\u043E\u043D\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \xAB${providerId}\xBB, \u0430 \u043D\u0430 \u044D\u0442\u043E\u0439 \u043C\u0430\u0448\u0438\u043D\u0435 \u0442\u043E\u043B\u044C\u043A\u043E ${available.join(", ")} \u2014 \u043F\u0440\u043E\u0433\u043E\u043D \u043D\u0435 \u0431\u0435\u0440\u0443, \u0435\u0433\u043E \u0432\u043E\u0437\u044C\u043C\u0451\u0442 \u0434\u0440\u0443\u0433\u0430\u044F \u043C\u0430\u0448\u0438\u043D\u0430`;
12530
12737
  }
12531
12738
 
12739
+ // src/modelLimits.ts
12740
+ import { createHash } from "crypto";
12741
+ import { readFileSync as readFileSync19, readdirSync as readdirSync15, statSync as statSync12 } from "fs";
12742
+ import { homedir as homedir7 } from "os";
12743
+ import { join as join24 } from "path";
12744
+ var KIMI_USAGES_URL = "https://api.kimi.com/coding/v1/usages";
12745
+ var DEFAULT_POLL_MS = 3e5;
12746
+ var FETCH_TIMEOUT_MS = 1e4;
12747
+ function record(value) {
12748
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
12749
+ }
12750
+ function jwtUserId(token) {
12751
+ try {
12752
+ const payload = token.split(".")[1];
12753
+ if (!payload) return null;
12754
+ const parsed = record(JSON.parse(Buffer.from(payload, "base64url").toString("utf8")));
12755
+ const id = [parsed?.user_id, parsed?.sub].find((v) => typeof v === "string" && v);
12756
+ return typeof id === "string" && id ? id : null;
12757
+ } catch {
12758
+ return null;
12759
+ }
12760
+ }
12761
+ function accountKey(userId) {
12762
+ return userId ? createHash("sha256").update(userId).digest("hex").slice(0, 16) : null;
12763
+ }
12764
+ function readKimiCredentials(env = process.env) {
12765
+ try {
12766
+ const root = env.KIMI_CODE_HOME?.trim() || join24(homedir7(), ".kimi-code");
12767
+ const dir = join24(root, "credentials");
12768
+ const files = readdirSync15(dir).filter((name) => name.endsWith(".json")).map((name) => ({ name, path: join24(dir, name) })).filter((entry) => statSync12(entry.path).isFile());
12769
+ const preferred = files.filter((entry) => entry.name.startsWith("kimi-code-env-"));
12770
+ const candidates = preferred.length ? preferred : files;
12771
+ candidates.sort((a, b) => statSync12(b.path).mtimeMs - statSync12(a.path).mtimeMs || a.name.localeCompare(b.name));
12772
+ const newest2 = candidates[0];
12773
+ if (!newest2) return null;
12774
+ const body = record(JSON.parse(readFileSync19(newest2.path, "utf8")));
12775
+ if (typeof body?.access_token !== "string" || !body.access_token) return null;
12776
+ const userId = jwtUserId(body.access_token);
12777
+ return { accessToken: body.access_token, accountKey: accountKey(userId) };
12778
+ } catch {
12779
+ return null;
12780
+ }
12781
+ }
12782
+ function finiteNumber(value) {
12783
+ if (typeof value !== "number" && typeof value !== "string") return null;
12784
+ if (typeof value === "string" && !value.trim()) return null;
12785
+ const parsed = Number(value);
12786
+ return Number.isFinite(parsed) ? parsed : null;
12787
+ }
12788
+ function isoOrNull2(value) {
12789
+ if (typeof value !== "string") return null;
12790
+ const normalized = value.replace(/\.(\d{3})\d+(?=(?:Z|[+-]\d{2}:?\d{2})$)/, ".$1");
12791
+ const date = new Date(normalized);
12792
+ return Number.isNaN(date.getTime()) ? null : date.toISOString();
12793
+ }
12794
+ function ratioWindow(kind, raw) {
12795
+ const value = record(raw);
12796
+ const ratio = finiteNumber(value?.used_ratio);
12797
+ if (ratio === null) return null;
12798
+ const usedPct = Math.floor(Math.round(Math.min(1, Math.max(0, ratio)) * 1e6) / 1e4);
12799
+ return { window: kind, usedPct, resetsAt: isoOrNull2(value?.reset_time) };
12800
+ }
12801
+ function fiveHourDetail(body) {
12802
+ if (!Array.isArray(body.limits)) return null;
12803
+ for (const raw of body.limits) {
12804
+ const item = record(raw);
12805
+ const window = record(item?.window);
12806
+ const detail = record(item?.detail);
12807
+ if (window?.duration !== 300 || window.timeUnit !== "TIME_UNIT_MINUTE" && window.timeUnit !== "MINUTE") continue;
12808
+ const limit = finiteNumber(detail?.limit);
12809
+ const used = finiteNumber(detail?.used);
12810
+ if (limit === null || used === null || limit <= 0) continue;
12811
+ const usedPct = Math.min(100, Math.max(0, Math.floor(used * 100 / limit)));
12812
+ return { window: "5h", usedPct, resetsAt: isoOrNull2(detail?.resetTime) };
12813
+ }
12814
+ return null;
12815
+ }
12816
+ function parseKimiUsages(body, nowIso) {
12817
+ const root = record(body);
12818
+ const usages = record(root?.usages);
12819
+ const fiveHours = root ? fiveHourDetail(root) ?? ratioWindow("5h", usages?.limit_5h) : null;
12820
+ const month = ratioWindow("month", usages?.limit_month_code) ?? ratioWindow("month", usages?.limit_month_total);
12821
+ const windows = [fiveHours, month].filter((window) => window !== null);
12822
+ if (!windows.length) throw new Error("Kimi usages: no known windows");
12823
+ return {
12824
+ executor: "kimi",
12825
+ state: "ok",
12826
+ accountKey: null,
12827
+ accountLabel: null,
12828
+ windows,
12829
+ fetchedAt: nowIso
12830
+ };
12831
+ }
12832
+ function noneModel(executor) {
12833
+ return { executor, state: "none", accountKey: null, accountLabel: null, windows: [], fetchedAt: null };
12834
+ }
12835
+ function accountLabel(env) {
12836
+ const label2 = env.SWARM_KIMI_ACCOUNT_LABEL?.trim() ?? "";
12837
+ return label2 ? Array.from(label2).slice(0, 40).join("") : null;
12838
+ }
12839
+ function pollPeriod(env) {
12840
+ const configured = Number(env.SWARM_LIMITS_POLL_MS);
12841
+ return Number.isFinite(configured) && configured > 0 ? Math.max(DEFAULT_POLL_MS, configured) : DEFAULT_POLL_MS;
12842
+ }
12843
+ function createModelLimitsPoller(options) {
12844
+ const env = options.env ?? process.env;
12845
+ const fetchImpl = options.fetch ?? globalThis.fetch;
12846
+ const now = options.now ?? (() => /* @__PURE__ */ new Date());
12847
+ const periodMs = options.periodMs ?? pollPeriod(env);
12848
+ let lastAttemptMs = Number.NEGATIVE_INFINITY;
12849
+ let inFlight = null;
12850
+ let lastKimi = null;
12851
+ async function poll() {
12852
+ try {
12853
+ const credentials = readKimiCredentials(env);
12854
+ if (!credentials) {
12855
+ console.warn("[model-limits] \u043E\u043F\u0440\u043E\u0441 Kimi: \u043A\u0440\u0435\u0434\u044B CLI \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B; \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u043F\u0440\u043E\u0448\u043B\u044B\u0439 \u0441\u043D\u0438\u043C\u043E\u043A");
12856
+ return;
12857
+ }
12858
+ const controller = new AbortController();
12859
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
12860
+ timeout.unref();
12861
+ try {
12862
+ const response = await fetchImpl(KIMI_USAGES_URL, {
12863
+ headers: { Authorization: `Bearer ${credentials.accessToken}` },
12864
+ signal: controller.signal
12865
+ });
12866
+ if (!response.ok) throw new Error(`http_${response.status}`);
12867
+ const parsed = parseKimiUsages(await response.json(), now().toISOString());
12868
+ lastKimi = { ...parsed, accountKey: credentials.accountKey, accountLabel: accountLabel(env) };
12869
+ } finally {
12870
+ clearTimeout(timeout);
12871
+ }
12872
+ } catch (error) {
12873
+ const name = record(error)?.name;
12874
+ const message = record(error)?.message;
12875
+ const reason = name === "AbortError" ? "\u0442\u0430\u0439\u043C\u0430\u0443\u0442 10 \u0441" : typeof message === "string" && /^http_\d+$/.test(message) ? `HTTP ${message.slice(5)}` : "\u0441\u0435\u0442\u0435\u0432\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430 \u0438\u043B\u0438 \u043D\u0435\u043E\u0436\u0438\u0434\u0430\u043D\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442";
12876
+ console.warn(`[model-limits] \u043E\u043F\u0440\u043E\u0441 Kimi: ${reason}; \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u043F\u0440\u043E\u0448\u043B\u044B\u0439 \u0441\u043D\u0438\u043C\u043E\u043A`);
12877
+ }
12878
+ }
12879
+ return {
12880
+ maybePoll() {
12881
+ if (!options.installed().includes("kimi")) return null;
12882
+ const nowMs = now().getTime();
12883
+ if (inFlight || nowMs - lastAttemptMs <= periodMs) return inFlight;
12884
+ lastAttemptMs = nowMs;
12885
+ inFlight = poll().finally(() => {
12886
+ inFlight = null;
12887
+ });
12888
+ return inFlight;
12889
+ },
12890
+ report() {
12891
+ const installed2 = options.installed();
12892
+ if (!installed2.length) return null;
12893
+ return {
12894
+ sentAt: now().toISOString(),
12895
+ models: installed2.map((executor) => executor === "kimi" && lastKimi ? lastKimi : noneModel(executor))
12896
+ };
12897
+ }
12898
+ };
12899
+ }
12900
+
12901
+ // src/overmind.ts
12902
+ init_src();
12903
+
12532
12904
  // src/orchestrator.ts
12533
12905
  init_src();
12534
12906
  init_git();
12535
12907
 
12536
12908
  // src/deps.ts
12537
- import { existsSync as existsSync16, readdirSync as readdirSync15, readFileSync as readFileSync20 } from "fs";
12538
- import { join as join26 } from "path";
12909
+ import { existsSync as existsSync16, readdirSync as readdirSync17, readFileSync as readFileSync21 } from "fs";
12910
+ import { join as join28 } from "path";
12539
12911
  import { execa } from "execa";
12540
12912
 
12541
12913
  // src/prepareLock.ts
12542
- import { createHash } from "crypto";
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";
12914
+ import { createHash as createHash2 } from "crypto";
12915
+ import { closeSync as closeSync6, openSync as openSync6, rmSync as rmSync2, statSync as statSync14, writeSync as writeSync2 } from "fs";
12916
+ import { join as join26 } from "path";
12545
12917
  import { tmpdir } from "os";
12546
12918
  var WAIT_TIMEOUT_MS = 5 * 6e4;
12547
12919
  var POLL_MS = 300;
12548
12920
  var STALE_MS = 20 * 6e4;
12549
12921
  function machineLockPath(key, dir = tmpdir()) {
12550
- return join24(dir, `swarm-prepare-${createHash("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
12922
+ return join26(dir, `swarm-prepare-${createHash2("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
12551
12923
  }
12552
12924
  function defaultTryCreate(path, content) {
12553
12925
  try {
12554
- const fd = openSync5(path, "wx");
12926
+ const fd = openSync6(path, "wx");
12555
12927
  try {
12556
12928
  writeSync2(fd, content);
12557
12929
  } finally {
12558
- closeSync5(fd);
12930
+ closeSync6(fd);
12559
12931
  }
12560
12932
  return true;
12561
12933
  } catch {
@@ -12564,7 +12936,7 @@ function defaultTryCreate(path, content) {
12564
12936
  }
12565
12937
  function defaultAgeMs(path) {
12566
12938
  try {
12567
- return Date.now() - statSync13(path).mtimeMs;
12939
+ return Date.now() - statSync14(path).mtimeMs;
12568
12940
  } catch {
12569
12941
  return null;
12570
12942
  }
@@ -12606,12 +12978,12 @@ init_config();
12606
12978
 
12607
12979
  // src/envCache.ts
12608
12980
  init_config();
12609
- import { createHash as createHash2 } from "crypto";
12981
+ import { createHash as createHash3 } from "crypto";
12610
12982
  import { cp, link, lstat, mkdir as mkdir2, readdir, readlink, rename as rename2, rm as rm2, stat, symlink, utimes, writeFile as writeFile2 } from "fs/promises";
12611
- import { existsSync as existsSync15, readFileSync as readFileSync19 } from "fs";
12612
- import { join as join25 } from "path";
12983
+ import { existsSync as existsSync15, readFileSync as readFileSync20 } from "fs";
12984
+ import { join as join27 } from "path";
12613
12985
  function fingerprint(parts) {
12614
- const h = createHash2("sha256");
12986
+ const h = createHash3("sha256");
12615
12987
  for (const p of parts) {
12616
12988
  h.update(p);
12617
12989
  h.update("\0");
@@ -12623,8 +12995,8 @@ async function cloneTree(src, dst) {
12623
12995
  const entries = await readdir(src, { withFileTypes: true });
12624
12996
  await Promise.all(
12625
12997
  entries.map(async (e) => {
12626
- const from = join25(src, e.name);
12627
- const to = join25(dst, e.name);
12998
+ const from = join27(src, e.name);
12999
+ const to = join27(dst, e.name);
12628
13000
  if (e.isDirectory()) return cloneTree(from, to);
12629
13001
  if (e.isSymbolicLink()) {
12630
13002
  return symlink(await readlink(from), to).catch(() => cp(from, to, { recursive: true, verbatimSymlinks: true }));
@@ -12637,11 +13009,11 @@ function cacheRoot(io) {
12637
13009
  return io.root ?? ENV_CACHE_DIR;
12638
13010
  }
12639
13011
  function snapshotDir(io, key) {
12640
- return join25(cacheRoot(io), key);
13012
+ return join27(cacheRoot(io), key);
12641
13013
  }
12642
13014
  function readManifest(dir) {
12643
13015
  try {
12644
- const parsed = JSON.parse(readFileSync19(join25(dir, "manifest.json"), "utf8"));
13016
+ const parsed = JSON.parse(readFileSync20(join27(dir, "manifest.json"), "utf8"));
12645
13017
  if (!parsed || typeof parsed !== "object") return null;
12646
13018
  const m = parsed;
12647
13019
  if (typeof m.key !== "string" || !Array.isArray(m.dirs)) return null;
@@ -12654,7 +13026,7 @@ function readManifest(dir) {
12654
13026
  }
12655
13027
  function hasEnvSnapshot(key, io = {}) {
12656
13028
  const exists = io.exists ?? existsSync15;
12657
- return exists(join25(snapshotDir(io, key), "manifest.json"));
13029
+ return exists(join27(snapshotDir(io, key), "manifest.json"));
12658
13030
  }
12659
13031
  async function restoreEnvSnapshot(worktree, key, io = {}) {
12660
13032
  const exists = io.exists ?? existsSync15;
@@ -12666,13 +13038,13 @@ async function restoreEnvSnapshot(worktree, key, io = {}) {
12666
13038
  try {
12667
13039
  for (let i = 0; i < manifest.dirs.length; i++) {
12668
13040
  const rel = manifest.dirs[i] ?? "";
12669
- const target = join25(worktree, rel);
13041
+ const target = join27(worktree, rel);
12670
13042
  if (exists(target)) continue;
12671
- await clone(join25(dir, "trees", String(i)), target);
13043
+ await clone(join27(dir, "trees", String(i)), target);
12672
13044
  made.push(rel);
12673
13045
  }
12674
13046
  } catch {
12675
- for (const rel of made) await rm2(join25(worktree, rel), { recursive: true, force: true }).catch(() => {
13047
+ for (const rel of made) await rm2(join27(worktree, rel), { recursive: true, force: true }).catch(() => {
12676
13048
  });
12677
13049
  return null;
12678
13050
  }
@@ -12688,16 +13060,16 @@ async function saveEnvSnapshot(worktree, key, dirs, io = {}) {
12688
13060
  const exists = io.exists ?? existsSync15;
12689
13061
  const clone = io.clone ?? cloneTree;
12690
13062
  if (hasEnvSnapshot(key, io)) return true;
12691
- const present = dirs.filter((rel) => exists(join25(worktree, rel)));
13063
+ const present = dirs.filter((rel) => exists(join27(worktree, rel)));
12692
13064
  if (!present.length) return false;
12693
13065
  const root = cacheRoot(io);
12694
- const tmp = join25(root, `.tmp-${key}-${process.pid}`);
13066
+ const tmp = join27(root, `.tmp-${key}-${process.pid}`);
12695
13067
  try {
12696
13068
  await rm2(tmp, { recursive: true, force: true });
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)));
13069
+ await mkdir2(join27(tmp, "trees"), { recursive: true });
13070
+ for (let i = 0; i < present.length; i++) await clone(join27(worktree, present[i] ?? ""), join27(tmp, "trees", String(i)));
12699
13071
  const manifest = { key, dirs: present, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
12700
- await writeFile2(join25(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
13072
+ await writeFile2(join27(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
12701
13073
  await rename2(tmp, snapshotDir(io, key));
12702
13074
  return true;
12703
13075
  } catch {
@@ -12717,13 +13089,13 @@ async function pruneEnvSnapshots(io = {}) {
12717
13089
  }
12718
13090
  const withTime = [];
12719
13091
  for (const name of names) {
12720
- const s = await stat(join25(root, name)).catch(() => null);
13092
+ const s = await stat(join27(root, name)).catch(() => null);
12721
13093
  if (s) withTime.push({ name, mtime: s.mtimeMs });
12722
13094
  }
12723
13095
  withTime.sort((a, b) => b.mtime - a.mtime);
12724
13096
  let removed = 0;
12725
13097
  for (const { name } of withTime.slice(Math.max(0, keep))) {
12726
- await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
13098
+ await rm2(join27(root, name), { recursive: true, force: true }).catch(() => {
12727
13099
  });
12728
13100
  removed++;
12729
13101
  }
@@ -12739,9 +13111,9 @@ async function sweepEnvCacheTemp(io = {}) {
12739
13111
  }
12740
13112
  let removed = 0;
12741
13113
  for (const name of names) {
12742
- const s = await lstat(join25(root, name)).catch(() => null);
13114
+ const s = await lstat(join27(root, name)).catch(() => null);
12743
13115
  if (!s || Date.now() - s.mtimeMs < 60 * 6e4) continue;
12744
- await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
13116
+ await rm2(join27(root, name), { recursive: true, force: true }).catch(() => {
12745
13117
  });
12746
13118
  removed++;
12747
13119
  }
@@ -12768,21 +13140,21 @@ async function runCommand(cmd, worktree) {
12768
13140
  }
12769
13141
  function safeReadText(p) {
12770
13142
  try {
12771
- return readFileSync20(p, "utf8");
13143
+ return readFileSync21(p, "utf8");
12772
13144
  } catch {
12773
13145
  return null;
12774
13146
  }
12775
13147
  }
12776
13148
  function safeListDirs(p) {
12777
13149
  try {
12778
- return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
13150
+ return readdirSync17(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
12779
13151
  } catch {
12780
13152
  return [];
12781
13153
  }
12782
13154
  }
12783
13155
  function safeListFiles(p) {
12784
13156
  try {
12785
- return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
13157
+ return readdirSync17(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
12786
13158
  } catch {
12787
13159
  return [];
12788
13160
  }
@@ -12810,19 +13182,19 @@ function overridePlan(override) {
12810
13182
  function detectPackageManager(worktree, io = {}) {
12811
13183
  const exists = io.exists ?? existsSync16;
12812
13184
  const readText = io.readText ?? safeReadText;
12813
- const hasPkgJson = exists(join26(worktree, "package.json"));
13185
+ const hasPkgJson = exists(join28(worktree, "package.json"));
12814
13186
  if (!hasPkgJson) {
12815
- if (exists(join26(worktree, "deno.json")) || exists(join26(worktree, "deno.jsonc")) || exists(join26(worktree, "deno.lock"))) return "deno";
13187
+ if (exists(join28(worktree, "deno.json")) || exists(join28(worktree, "deno.jsonc")) || exists(join28(worktree, "deno.lock"))) return "deno";
12816
13188
  return null;
12817
13189
  }
12818
- const pkg = readJson(readText, join26(worktree, "package.json"));
13190
+ const pkg = readJson(readText, join28(worktree, "package.json"));
12819
13191
  const declared = typeof pkg?.packageManager === "string" ? pkg.packageManager.split("@")[0] : void 0;
12820
13192
  if (declared === "pnpm" || declared === "bun" || declared === "npm" || declared === "yarn") return declared;
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";
13193
+ if (exists(join28(worktree, "bun.lock")) || exists(join28(worktree, "bun.lockb"))) return "bun";
13194
+ if (exists(join28(worktree, "pnpm-lock.yaml"))) return "pnpm";
13195
+ if (exists(join28(worktree, "yarn.lock"))) return "yarn";
13196
+ if (exists(join28(worktree, "package-lock.json"))) return "npm";
13197
+ if (exists(join28(worktree, "deno.lock"))) return "deno";
12826
13198
  return "npm";
12827
13199
  }
12828
13200
  function jsInstallCommand(pm) {
@@ -12886,7 +13258,7 @@ function detectPlan(worktree, io) {
12886
13258
  // node_modules на месте — установку пропускаем (быстрый путь переиспользованного worktree).
12887
13259
  // У deno каталога может не быть вовсе (кэш в DENO_DIR) — тогда `deno install` отработает
12888
13260
  // заново, но он дешёвый: тянет из того же общего кэша.
12889
- { label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join26(worktree, "node_modules"), source: "detect" }
13261
+ { label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join28(worktree, "node_modules"), source: "detect" }
12890
13262
  ];
12891
13263
  for (const target of workspaceBuildTargets(worktree, io)) {
12892
13264
  commands.push({ label: `\u0441\u0431\u043E\u0440\u043A\u0430 ${target.name}`, run: jsRunScript(pm, "build"), cwd: target.dir, source: "detect" });
@@ -12895,12 +13267,12 @@ function detectPlan(worktree, io) {
12895
13267
  return { source: "detect", ecosystem: `node/${pm}`, commands };
12896
13268
  }
12897
13269
  for (const marker of ECOSYSTEM_MARKERS) {
12898
- const hit = marker.files.some((f) => exists(join26(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
13270
+ const hit = marker.files.some((f) => exists(join28(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
12899
13271
  if (!hit) continue;
12900
13272
  let ecosystem = marker.ecosystem;
12901
13273
  let command = marker.command;
12902
13274
  for (const refine of marker.refine ?? []) {
12903
- if (!exists(join26(worktree, refine.file))) continue;
13275
+ if (!exists(join28(worktree, refine.file))) continue;
12904
13276
  ecosystem = refine.ecosystem;
12905
13277
  command = refine.command;
12906
13278
  break;
@@ -12957,12 +13329,12 @@ var CI_INSTALL_PATTERNS = [
12957
13329
  function ciWorkflowPlan(worktree, io) {
12958
13330
  const readText = io.readText ?? safeReadText;
12959
13331
  const listFiles = io.listFiles ?? safeListFiles;
12960
- const dir = join26(worktree, ".github", "workflows");
13332
+ const dir = join28(worktree, ".github", "workflows");
12961
13333
  const files = listFiles(dir).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml"));
12962
13334
  const seen = /* @__PURE__ */ new Set();
12963
13335
  const commands = [];
12964
13336
  for (const name of files.sort()) {
12965
- const yaml = readText(join26(dir, name));
13337
+ const yaml = readText(join28(dir, name));
12966
13338
  if (yaml === null) continue;
12967
13339
  for (const raw of workflowRunLines(yaml)) {
12968
13340
  const line = raw.replace(/\s+/g, " ").trim();
@@ -12977,7 +13349,7 @@ function ciWorkflowPlan(worktree, io) {
12977
13349
  return commands.length ? { source: "ci-workflow", ecosystem: "ci-\u043A\u043E\u043D\u0444\u0438\u0433", commands } : null;
12978
13350
  }
12979
13351
  function workspaceGlobs(worktree, readText) {
12980
- const yaml = readText(join26(worktree, "pnpm-workspace.yaml"));
13352
+ const yaml = readText(join28(worktree, "pnpm-workspace.yaml"));
12981
13353
  if (yaml !== null) {
12982
13354
  const globs = [];
12983
13355
  let inPackages = false;
@@ -12997,7 +13369,7 @@ function workspaceGlobs(worktree, readText) {
12997
13369
  }
12998
13370
  if (globs.length) return globs;
12999
13371
  }
13000
- const pkg = readJson(readText, join26(worktree, "package.json"));
13372
+ const pkg = readJson(readText, join28(worktree, "package.json"));
13001
13373
  const ws = pkg?.workspaces;
13002
13374
  const list = Array.isArray(ws) ? ws : Array.isArray(ws?.packages) ? ws.packages : [];
13003
13375
  return list.filter((g) => typeof g === "string");
@@ -13008,14 +13380,14 @@ function workspaceDirs(worktree, globs, io) {
13008
13380
  if (glob.startsWith("!")) continue;
13009
13381
  const star = glob.indexOf("*");
13010
13382
  if (star === -1) {
13011
- const dir = join26(worktree, glob);
13012
- if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
13383
+ const dir = join28(worktree, glob);
13384
+ if (io.exists(join28(dir, "package.json"))) dirs.add(dir);
13013
13385
  continue;
13014
13386
  }
13015
- const base3 = join26(worktree, glob.slice(0, star).replace(/\/$/, ""));
13387
+ const base3 = join28(worktree, glob.slice(0, star).replace(/\/$/, ""));
13016
13388
  for (const name of io.listDirs(base3)) {
13017
- const dir = join26(base3, name);
13018
- if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
13389
+ const dir = join28(base3, name);
13390
+ if (io.exists(join28(dir, "package.json"))) dirs.add(dir);
13019
13391
  }
13020
13392
  }
13021
13393
  return [...dirs];
@@ -13043,11 +13415,11 @@ function workspaceBuildTargets(worktree, io = {}) {
13043
13415
  if (!globs.length) return [];
13044
13416
  const pkgs = [];
13045
13417
  for (const dir of workspaceDirs(worktree, globs, { exists, listDirs })) {
13046
- const pkg = readJson(readText, join26(dir, "package.json"));
13418
+ const pkg = readJson(readText, join28(dir, "package.json"));
13047
13419
  if (!pkg || typeof pkg.name !== "string") continue;
13048
13420
  const scripts = pkg.scripts ?? {};
13049
13421
  const entries = entryPaths(pkg);
13050
- const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join26(dir, e)));
13422
+ const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join28(dir, e)));
13051
13423
  const deps = Object.keys({ ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} });
13052
13424
  pkgs.push({ name: pkg.name, dir, deps, needsBuild });
13053
13425
  }
@@ -13075,7 +13447,7 @@ function devDatabaseUrl(worktree, io = {}) {
13075
13447
  const fromEnv = (io.env ?? process.env).DATABASE_URL;
13076
13448
  if (fromEnv && fromEnv.trim()) return fromEnv.trim();
13077
13449
  for (const file of [".env", ".env.example"]) {
13078
- const raw = readText(join26(worktree, file));
13450
+ const raw = readText(join28(worktree, file));
13079
13451
  if (raw === null) continue;
13080
13452
  const m = /^\s*(?:export\s+)?DATABASE_URL\s*=\s*(.*)$/m.exec(raw);
13081
13453
  const value = (m?.[1] ?? "").trim().replace(/^['"]|['"]$/g, "");
@@ -13095,7 +13467,7 @@ function prismaPackages(worktree, io) {
13095
13467
  const readText = io.readText ?? safeReadText;
13096
13468
  const listDirs = io.listDirs ?? safeListDirs;
13097
13469
  const dirs = [worktree, ...workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs })];
13098
- return dirs.filter((dir) => exists(join26(dir, "prisma", "schema.prisma")) && listDirs(join26(dir, "prisma", "migrations")).length > 0);
13470
+ return dirs.filter((dir) => exists(join28(dir, "prisma", "schema.prisma")) && listDirs(join28(dir, "prisma", "migrations")).length > 0);
13099
13471
  }
13100
13472
  function jsExecBin(pm, command) {
13101
13473
  switch (pm) {
@@ -13132,18 +13504,18 @@ function envCachePlan(worktree, io = {}) {
13132
13504
  if (!pm) return null;
13133
13505
  const parts = [`pm:${pm}`];
13134
13506
  for (const name of ENV_DEFINING_FILES) {
13135
- const raw = readText(join26(worktree, name));
13507
+ const raw = readText(join28(worktree, name));
13136
13508
  if (raw !== null) parts.push(`${name}
13137
13509
  ${raw}`);
13138
13510
  }
13139
13511
  const pkgDirs = workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs });
13140
13512
  const rels = pkgDirs.map((dir) => dir.slice(worktree.length + 1)).sort();
13141
13513
  for (const rel of ["", ...rels]) {
13142
- const raw = readText(join26(worktree, rel, "package.json"));
13514
+ const raw = readText(join28(worktree, rel, "package.json"));
13143
13515
  if (raw !== null) parts.push(`${rel}/package.json
13144
13516
  ${raw}`);
13145
13517
  }
13146
- return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join26(rel, "node_modules"))] };
13518
+ return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join28(rel, "node_modules"))] };
13147
13519
  }
13148
13520
  function planPrepare(worktree, io = {}) {
13149
13521
  const plan = overridePlan(io.override) ?? detectPlan(worktree, io) ?? ciWorkflowPlan(worktree, io);
@@ -13168,7 +13540,7 @@ async function ensureWorktreeDeps(worktree, io = {}) {
13168
13540
  restored: [],
13169
13541
  cached: false
13170
13542
  };
13171
- if (cachePlan && !exists(join26(worktree, "node_modules"))) {
13543
+ if (cachePlan && !exists(join28(worktree, "node_modules"))) {
13172
13544
  report.restored = await restoreEnvSnapshot(worktree, cachePlan.key, cacheIO) ?? [];
13173
13545
  }
13174
13546
  const plan = planPrepare(worktree, io);
@@ -13256,7 +13628,7 @@ function depsPromptNotice(report) {
13256
13628
  // src/orchestrator.ts
13257
13629
  init_config();
13258
13630
  import { existsSync as existsSync17, mkdirSync as mkdirSync11, rmSync as rmSync3 } from "fs";
13259
- import { join as join27, dirname as dirname4 } from "path";
13631
+ import { join as join29, dirname as dirname4 } from "path";
13260
13632
  function droneLaunchedText(workdir, pid) {
13261
13633
  return `\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0432 ${workdir} (pid ${pid})`;
13262
13634
  }
@@ -13265,7 +13637,7 @@ function droneLaunchedPid(text) {
13265
13637
  return m ? Number(m[1]) : null;
13266
13638
  }
13267
13639
  function repolessRunDir(worktreesDir, taskSlug) {
13268
- return join27(dirname4(worktreesDir), "runs", taskSlug);
13640
+ return join29(dirname4(worktreesDir), "runs", taskSlug);
13269
13641
  }
13270
13642
  var WORKTREE_HELD_STATUSES = /* @__PURE__ */ new Set(["running", "blocked", "review", "paused", "storm_dead"]);
13271
13643
  function worktreePathHeldLive(db, path, exceptRunId) {
@@ -13543,7 +13915,7 @@ function parkReasonUnretriable(reason) {
13543
13915
  // package.json
13544
13916
  var package_default = {
13545
13917
  name: "@taskless-app/swarm",
13546
- version: "0.6.83",
13918
+ version: "0.6.84",
13547
13919
  type: "module",
13548
13920
  description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
13549
13921
  keywords: [
@@ -13595,7 +13967,7 @@ var package_default = {
13595
13967
  undici: "^7.30.1",
13596
13968
  zod: "3.25.76"
13597
13969
  },
13598
- gitHead: "8fd42459bb1cbcdad50ebef72bcb3c36a5e2d1c6"
13970
+ gitHead: "ca2ec899dc2136ad1d23130849fed378b2819ee7"
13599
13971
  };
13600
13972
 
13601
13973
  // src/version.ts
@@ -14415,8 +14787,8 @@ import { z } from "zod";
14415
14787
  init_git();
14416
14788
 
14417
14789
  // src/diff.ts
14418
- import { statSync as statSync14 } from "fs";
14419
- import { join as join32 } from "path";
14790
+ import { statSync as statSync15 } from "fs";
14791
+ import { join as join34 } from "path";
14420
14792
  import { $ as $4 } from "execa";
14421
14793
  var MAX_FILES = 200;
14422
14794
  var MAX_LINES_PER_FILE = 1500;
@@ -14559,7 +14931,7 @@ async function resolveBase(wt, baseBranch) {
14559
14931
  }
14560
14932
  function mtime(path) {
14561
14933
  try {
14562
- return statSync14(path).mtimeMs;
14934
+ return statSync15(path).mtimeMs;
14563
14935
  } catch {
14564
14936
  return 0;
14565
14937
  }
@@ -14584,7 +14956,7 @@ async function collectRunDiff(worktree, opts = {}) {
14584
14956
  files.push(pf);
14585
14957
  }
14586
14958
  }
14587
- files.sort((a, b) => mtime(join32(worktree, b.path)) - mtime(join32(worktree, a.path)));
14959
+ files.sort((a, b) => mtime(join34(worktree, b.path)) - mtime(join34(worktree, a.path)));
14588
14960
  const truncatedFiles = files.length > MAX_FILES;
14589
14961
  if (truncatedFiles) files = files.slice(0, MAX_FILES);
14590
14962
  const added = files.reduce((s, f) => s + f.added, 0);
@@ -15675,7 +16047,7 @@ async function runDroneServer(runId) {
15675
16047
 
15676
16048
  // src/droneBridge.ts
15677
16049
  init_src();
15678
- import { createHash as createHash4 } from "crypto";
16050
+ import { createHash as createHash5 } from "crypto";
15679
16051
 
15680
16052
  // src/anomalies.ts
15681
16053
  init_src();
@@ -15807,7 +16179,7 @@ var AnomalyTracker = class {
15807
16179
  if (now - startedAt < c.minDurationMs) continue;
15808
16180
  const lastFired = this.lastFiredAt.get(c.key);
15809
16181
  if (lastFired != null && now - lastFired < this.renotifyCooldownMs) continue;
15810
- if ((this.fires.get(c.key) ?? 0) >= this.maxRepeats) continue;
16182
+ if ((this.fires.get(c.key) ?? 0) >= (c.once ? 1 : this.maxRepeats)) continue;
15811
16183
  result.push(c);
15812
16184
  }
15813
16185
  let pruned = false;
@@ -16209,7 +16581,7 @@ function questionKey(runId, text) {
16209
16581
  return `${runId} ${text.trim().replace(/\s+/g, " ")}`;
16210
16582
  }
16211
16583
  function noteKey(runId, text) {
16212
- return `note:${runId}:${createHash4("sha1").update(questionKey(runId, text)).digest("hex").slice(0, 16)}`;
16584
+ return `note:${runId}:${createHash5("sha1").update(questionKey(runId, text)).digest("hex").slice(0, 16)}`;
16213
16585
  }
16214
16586
  async function syncDroneChannel(opts) {
16215
16587
  const result = { imported: [], answered: [], notes: [] };
@@ -17003,21 +17375,21 @@ async function prodClearMergeIntent(runId, deps = {}) {
17003
17375
 
17004
17376
  // src/envGate.ts
17005
17377
  import { existsSync as existsSync20 } from "fs";
17006
- import { join as join34 } from "path";
17378
+ import { join as join36 } from "path";
17007
17379
  import { createConnection } from "net";
17008
17380
  import { execa as execa2 } from "execa";
17009
17381
 
17010
17382
  // src/platform.ts
17011
17383
  init_src();
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";
17384
+ import { accessSync as accessSync2, constants as constants2, existsSync as existsSync19, readFileSync as readFileSync25, realpathSync as realpathSync3 } from "fs";
17385
+ import { delimiter as delimiter2, join as join35, posix as posix2, win32 } from "path";
17014
17386
  function resolveCommandPath(name, env = process.env, platform = process.platform) {
17015
17387
  if (name.includes("/") || name.includes("\\")) return existsSync19(name) ? name : null;
17016
17388
  const dirs = (env.PATH ?? env.Path ?? "").split(delimiter2).filter(Boolean);
17017
17389
  const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
17018
17390
  for (const dir of dirs) {
17019
17391
  for (const ext of exts) {
17020
- const candidate = join33(dir, name + ext);
17392
+ const candidate = join35(dir, name + ext);
17021
17393
  if (existsSync19(candidate)) return candidate;
17022
17394
  }
17023
17395
  }
@@ -17188,7 +17560,7 @@ var COMPOSE_MARKERS = [
17188
17560
  ];
17189
17561
  function detectRequirements(repo, io = {}) {
17190
17562
  const exists = io.exists ?? existsSync20;
17191
- const marker = COMPOSE_MARKERS.find((f) => exists(join34(repo, f)));
17563
+ const marker = COMPOSE_MARKERS.find((f) => exists(join36(repo, f)));
17192
17564
  return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
17193
17565
  }
17194
17566
  function resolveRequirements(repo, declared, io = {}) {
@@ -17978,7 +18350,7 @@ function stormBanner(storm) {
17978
18350
  const frozen = storm.dead ? `${storm.dead} \u0432 \u043A\u043E\u043A\u043E\u043D\u0435` : "\u043D\u043E\u0432\u044B\u0445 \u0434\u0440\u043E\u043D\u043E\u0432 \u043D\u0435 \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0435\u043C";
17979
18351
  return {
17980
18352
  ico: "\u26A1",
17981
- title: "\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442",
18353
+ title: "\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442",
17982
18354
  desc: `\u0420\u043E\u0439 \u0437\u0430\u043C\u0435\u0440, \u0434\u0440\u043E\u043D\u044B \u0432 \u043A\u043E\u043A\u043E\u043D\u0430\u0445 \u2014 ${frozen}, \u043E\u0447\u0435\u0440\u0435\u0434\u044C \u043A\u043E\u043F\u0438\u0442\u0441\u044F. \u041F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u0441\u0430\u043C, \u043A\u0430\u043A \u0441\u0432\u044F\u0437\u044C \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F.`
17983
18355
  };
17984
18356
  }
@@ -18061,7 +18433,7 @@ var GK = ['claw','spore','eye','hex'];
18061
18433
  var ST = ${jsonForScript(statusTuples())};
18062
18434
  var ORDER = { running:0, blocked:1, paused:2, storm_dead:3, review:4, stalled:5, queued:6, stopped:7, done:8, failed:9, superseded:10 };
18063
18435
  var TERM = ${jsonForScript(Object.fromEntries(TERMINAL_STATUSES.map((s) => [s, 1])))};
18064
- var EVL = { spawned:'\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D', step:'', blocked:'\u0432\u043E\u043F\u0440\u043E\u0441 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0443', answered:'\u043F\u043E\u043B\u0443\u0447\u0435\u043D \u043E\u0442\u0432\u0435\u0442', pr_opened:'PR \u043E\u0442\u043A\u0440\u044B\u0442', merged:'PR \u0441\u043C\u0435\u0440\u0436\u0451\u043D, \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043A\u0440\u044B\u0442\u0430', done:'\u0433\u043E\u0442\u043E\u0432\u043E', failed:'\u0434\u0440\u043E\u043D \u0443\u043F\u0430\u043B', stalled:'\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441/\u043F\u043E\u0433\u0438\u0431', respawned:'\u0430\u0432\u0442\u043E-\u043E\u0436\u0438\u0432\u043B\u0435\u043D\u0438\u0435', paused:'\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D', resumed:'overmind \u0432\u0435\u0440\u043D\u0443\u043B\u0441\u044F \u2014 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B', rescued:'worktree \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u2014 \u0437\u0430\u0431\u0435\u0440\u0438 \u0440\u0443\u043A\u0430\u043C\u0438', conflict:'\u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442 \u0441 main (merge-main-in)', died:'\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440', storm_start:'\u26A1 \u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442', storm_end:'\u0441\u0432\u044F\u0437\u044C \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u2014 \u0440\u043E\u0439 \u043F\u0440\u043E\u0431\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044F', storm_dead:'\u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435 (\u0448\u0442\u043E\u0440\u043C)', stopped:'\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D', superseded:'\u043F\u0435\u0440\u0435\u0438\u0433\u0440\u0430\u043D', anomaly:'\u26A0\uFE0F \u0430\u043D\u043E\u043C\u0430\u043B\u0438\u044F \u0440\u043E\u044F', dep_cleared:'\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u044C \u0441\u043D\u044F\u0442\u0430 \u2014 \u0431\u043B\u043E\u043A\u0435\u0440 \u043D\u0435 \u0434\u043E\u0435\u0434\u0435\u0442' };
18436
+ var EVL = { spawned:'\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D', step:'', blocked:'\u0432\u043E\u043F\u0440\u043E\u0441 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0443', answered:'\u043F\u043E\u043B\u0443\u0447\u0435\u043D \u043E\u0442\u0432\u0435\u0442', pr_opened:'PR \u043E\u0442\u043A\u0440\u044B\u0442', merged:'PR \u0441\u043C\u0435\u0440\u0436\u0451\u043D, \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043A\u0440\u044B\u0442\u0430', done:'\u0433\u043E\u0442\u043E\u0432\u043E', failed:'\u0434\u0440\u043E\u043D \u0443\u043F\u0430\u043B', stalled:'\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441/\u043F\u043E\u0433\u0438\u0431', respawned:'\u0430\u0432\u0442\u043E-\u043E\u0436\u0438\u0432\u043B\u0435\u043D\u0438\u0435', paused:'\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D', resumed:'overmind \u0432\u0435\u0440\u043D\u0443\u043B\u0441\u044F \u2014 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B', rescued:'worktree \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u2014 \u0437\u0430\u0431\u0435\u0440\u0438 \u0440\u0443\u043A\u0430\u043C\u0438', conflict:'\u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442 \u0441 main (merge-main-in)', died:'\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440', storm_start:'\u26A1 \u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442', storm_end:'\u0441\u0432\u044F\u0437\u044C \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u2014 \u0440\u043E\u0439 \u043F\u0440\u043E\u0431\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044F', storm_dead:'\u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435 (\u0448\u0442\u043E\u0440\u043C)', stopped:'\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D', superseded:'\u043F\u0435\u0440\u0435\u0438\u0433\u0440\u0430\u043D', anomaly:'\u26A0\uFE0F \u0430\u043D\u043E\u043C\u0430\u043B\u0438\u044F \u0440\u043E\u044F', dep_cleared:'\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u044C \u0441\u043D\u044F\u0442\u0430 \u2014 \u0431\u043B\u043E\u043A\u0435\u0440 \u043D\u0435 \u0434\u043E\u0435\u0434\u0435\u0442' };
18065
18437
  var MDOT = { merged:'--success', done:'--success', pr_opened:'--info', spawned:'--muted-foreground', stalled:'--destructive', failed:'--destructive', respawned:'--warning', paused:'--warning', resumed:'--success', rescued:'--destructive', conflict:'--warning', died:'--destructive', storm_start:'--destructive', storm_end:'--success', storm_dead:'--warning', stopped:'--muted-foreground', superseded:'--muted-foreground', anomaly:'--warning', dep_cleared:'--warning' };
18066
18438
 
18067
18439
  function E(s){ return String(s==null?"":s).replace(/[&<>"]/g,function(c){return{'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]}); }
@@ -18087,13 +18459,21 @@ function pill(st){ var s=ST[st]||ST.queued; return '<span class="pill '+s[0]+'">
18087
18459
  function ava(d){ return '<span class="ava" style="color:'+color(d.status)+'"><svg viewBox="0 0 24 24" fill="none">'+GLYPH[GK[d.id%GK.length]]+'</svg></span>'; }
18088
18460
  function taskUrl(d){ return d.taskUrl || (TASK_URL_BASE ? TASK_URL_BASE + '/tasks/' + d.slug : null); }
18089
18461
 
18462
+ function limitWaitDisplay(stopReason){
18463
+ var m=/^limit-wait: ([^ ]+) \u0434\u043E ([^ ]+);(?: |$)/.exec(stopReason||'');
18464
+ if(!m||isNaN(Date.parse(m[2]))) return null;
18465
+ var text=stopReason.slice(stopReason.indexOf(';')+1).trim()||'\u041E\u0436\u0438\u0434\u0430\u043D\u0438\u0435 \u0441\u0431\u0440\u043E\u0441\u0430 \u043B\u0438\u043C\u0438\u0442\u0430';
18466
+ var reset=new Date(m[2]).toLocaleString('ru-RU',{day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'});
18467
+ var suffix='\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442 \u043F\u043E\u0441\u043B\u0435 \u0441\u0431\u0440\u043E\u0441\u0430';
18468
+ return text.slice(-suffix.length)===suffix ? text+' '+reset : text+', \u0441\u0431\u0440\u043E\u0441 '+reset;
18469
+ }
18090
18470
  /* \u043A\u0430\u0440\u0442\u043E\u0447\u043D\u044B\u0439 \xAB\u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u0448\u0430\u0433\xBB \u043F\u043E \u0441\u0442\u0430\u0442\u0443\u0441\u0443 (\u0441\u043F\u0435\u043A\u0430 TS-3) */
18091
18471
  function cardStep(d){
18092
18472
  if(d.status==='blocked') return '\u0432\u043E\u043F\u0440\u043E\u0441 \u0432 \u0438\u043D\u0431\u043E\u043A\u0441\u0435';
18093
18473
  if(d.status==='stalled') return d.reason || '\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441/\u043F\u043E\u0433\u0438\u0431';
18094
18474
  if(d.status==='stopped') return d.stopReason || d.reason || '\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D';
18095
- if(d.status==='storm_dead') return '\u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435 \u2014 \u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442), worktree \u0446\u0435\u043B, \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u043F\u043E\u0441\u043B\u0435 \u043E\u0442\u0431\u043E\u044F';
18096
- if(d.status==='paused') return d.stopReason || '\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D, \u0436\u0434\u0451\u0442 \u043F\u0435\u0440\u0435\u043F\u043E\u0434\u044A\u0451\u043C\u0430'; // TASWM-151: \u0440\u0435\u0441\u0443\u0440\u0441-\u0440\u0430\u0437\u0433\u0440\u0443\u0437\u043A\u0430 \u0437\u0430\u0434\u0430\u0451\u0442 \u0441\u0432\u043E\u0439 stopReason
18475
+ if(d.status==='storm_dead') return '\u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435 \u2014 \u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (\u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442), worktree \u0446\u0435\u043B, \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u043F\u043E\u0441\u043B\u0435 \u043E\u0442\u0431\u043E\u044F';
18476
+ if(d.status==='paused') return limitWaitDisplay(d.stopReason) || d.stopReason || '\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D, \u0436\u0434\u0451\u0442 \u043F\u0435\u0440\u0435\u043F\u043E\u0434\u044A\u0451\u043C\u0430'; // TASWM-151: \u0440\u0435\u0441\u0443\u0440\u0441-\u0440\u0430\u0437\u0433\u0440\u0443\u0437\u043A\u0430 \u0437\u0430\u0434\u0430\u0451\u0442 \u0441\u0432\u043E\u0439 stopReason
18097
18477
  if(d.status==='review') { var n=prNum(d.pr); return 'PR'+(n?(' #'+n):'')+' \u043D\u0430 \u0440\u0435\u0432\u044C\u044E'; }
18098
18478
  if(d.status==='done') return '\u0441\u043C\u0435\u0440\u0436\u0435\u043D';
18099
18479
  if(d.status==='queued') return (d.waiting&&d.waiting.length) ? '\u0436\u0434\u0451\u0442: '+d.waiting.join(', ') : '\u0432 \u043E\u0447\u0435\u0440\u0435\u0434\u0438 \u2014 \u0436\u0434\u0451\u0442 \u0441\u043B\u043E\u0442\u0430';
@@ -18472,7 +18852,7 @@ function openModal(id){ var reopen=(openId===id); openId=id; var d=byId[id]; if(
18472
18852
  return '<li class="step '+kind+'">'+node(kind)+'<div><div class="stext">'+E(stepLabel(e))+(kind==='now'?'<span class="live-lbl">\u0441\u0435\u0439\u0447\u0430\u0441</span>':'')+'</div>'+(e.at?'<div class="stime" title="'+E(localFull(e.at))+'">'+E(localHM(e.at))+' \xB7 '+E(rel(e.at))+'</div>':'')+'</div></li>'; }).join('');
18473
18853
  var url = taskUrl(d);
18474
18854
  var links = (url?'<a href="'+E(url)+'" target="_blank" rel="noopener">'+E(d.slug)+' \u2197</a>':'<span class="mono">'+E(d.slug)+'</span>')+(d.pr?'<a href="'+E(d.pr)+'" target="_blank" rel="noopener">PR \u2197</a>':'');
18475
- var desc = d.desc || (d.stopReason?('\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D: '+d.stopReason):('\u0414\u0440\u043E\u043D '+d.name+' \xB7 \u043F\u0440\u043E\u0433\u043E\u043D #'+d.id));
18855
+ var desc = d.desc || (d.stopReason?('\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D: '+(limitWaitDisplay(d.stopReason)||d.stopReason)):('\u0414\u0440\u043E\u043D '+d.name+' \xB7 \u043F\u0440\u043E\u0433\u043E\u043D #'+d.id));
18476
18856
  var codeBadge = (mDiffId===id && mDiff && mDiff.ok && mDiff.files.length) ? '<span class="mc-badge"><span class="a">+'+mDiff.added+'</span><span class="d">\u2212'+mDiff.removed+'</span></span>' : '';
18477
18857
  var acts='';
18478
18858
  var qid = firstQid(d.id);
@@ -18537,7 +18917,7 @@ function paintStorm(){ var b=document.getElementById('storm-banner'); if(!b) ret
18537
18917
  '<div class="sb-d">\u041F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u0436\u0438\u0432, \u043D\u043E \u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u043D\u0435 \u043D\u0430\u0441: \u043A\u043B\u044E\u0447, \u0430\u043A\u043A\u0430\u0443\u043D\u0442 \u0438\u043B\u0438 \u0440\u0435\u0433\u0438\u043E\u043D'+E(since)+'. \u0421\u0430\u043C\u043E \u043D\u0435 \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u2014 \u043F\u0440\u043E\u0432\u0435\u0440\u044C \u0432\u0445\u043E\u0434 \u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044F (swarm doctor).</div></div>';
18538
18918
  b.hidden=false; return; }
18539
18919
  var frozen = st.dead ? st.dead+' '+plural(st.dead,DRONEW)+' \u0432 \u043A\u043E\u043A\u043E\u043D\u0435' : '\u043D\u043E\u0432\u044B\u0445 \u0434\u0440\u043E\u043D\u043E\u0432 \u043D\u0435 \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0435\u043C';
18540
- b.innerHTML='<span class="sb-ico">\u26A1</span><div class="sb-body"><div class="sb-t">\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442</div>'+
18920
+ b.innerHTML='<span class="sb-ico">\u26A1</span><div class="sb-body"><div class="sb-t">\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442</div>'+
18541
18921
  '<div class="sb-d">\u0420\u043E\u0439 \u0437\u0430\u043C\u0435\u0440, \u0434\u0440\u043E\u043D\u044B \u0432 \u043A\u043E\u043A\u043E\u043D\u0430\u0445 \u2014 '+E(frozen)+', \u043E\u0447\u0435\u0440\u0435\u0434\u044C \u043A\u043E\u043F\u0438\u0442\u0441\u044F'+E(since)+'. \u041F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u0441\u0430\u043C, \u043A\u0430\u043A \u0441\u0432\u044F\u0437\u044C \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F.</div></div>';
18542
18922
  b.hidden=false; }
18543
18923
  /* \u041F\u0430\u043D\u0435\u043B\u044C \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432 \u043C\u0430\u0448\u0438\u043D\u044B-\u0445\u043E\u0441\u0442\u0430 (TASWM-214 \u0424\u0430\u0437\u0430 2): CPU/RAM + \u0441\u0442\u0430\u0442\u0443\u0441 \u0440\u0435\u0441\u0443\u0440\u0441-\u0433\u0435\u0439\u0442\u0430 \u0441\u043B\u043E\u0432\u0430\u043C\u0438. */
@@ -18944,14 +19324,14 @@ function closeWebServer(server) {
18944
19324
 
18945
19325
  // src/hostCommands.ts
18946
19326
  init_src();
18947
- import { readFileSync as readFileSync25, renameSync as renameSync10, writeFileSync as writeFileSync17 } from "fs";
18948
- import { join as join35 } from "path";
19327
+ import { readFileSync as readFileSync26, renameSync as renameSync10, writeFileSync as writeFileSync17 } from "fs";
19328
+ import { join as join37 } from "path";
18949
19329
  function hostCommandStatePath(home) {
18950
- return join35(home, "host-command.json");
19330
+ return join37(home, "host-command.json");
18951
19331
  }
18952
19332
  function readState(path) {
18953
19333
  try {
18954
- return JSON.parse(readFileSync25(path, "utf8"));
19334
+ return JSON.parse(readFileSync26(path, "utf8"));
18955
19335
  } catch {
18956
19336
  return {};
18957
19337
  }
@@ -19122,7 +19502,7 @@ async function doRestart(cmd, opts, note) {
19122
19502
  // src/selfUpdate.ts
19123
19503
  init_git();
19124
19504
  import { existsSync as existsSync21 } from "fs";
19125
- import { join as join36 } from "path";
19505
+ import { join as join38 } from "path";
19126
19506
  import { $ as $5 } from "execa";
19127
19507
 
19128
19508
  // src/cliIo.ts
@@ -19184,7 +19564,7 @@ async function runSelfUpdate(io) {
19184
19564
  };
19185
19565
  }
19186
19566
  await io.onStep("install", "\u0441\u0442\u0430\u0432\u043B\u044E \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438");
19187
- if (!exists(join36(repo, "pnpm-lock.yaml"))) {
19567
+ if (!exists(join38(repo, "pnpm-lock.yaml"))) {
19188
19568
  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" };
19189
19569
  }
19190
19570
  const installed2 = await run2("pnpm", ["install", "--frozen-lockfile"], repo);
@@ -19292,7 +19672,7 @@ function orphanNoteText(run2, q) {
19292
19672
  // src/probe.ts
19293
19673
  init_executors();
19294
19674
  import { spawn as spawn3 } from "child_process";
19295
- var RESET_RE = /resets[^\n]*/i;
19675
+ var RESET_RE2 = /resets[^\n]*/i;
19296
19676
  function executorHealthy(opts = {}) {
19297
19677
  const executor = opts.executor ?? resolveExecutor();
19298
19678
  const bin = opts.bin ?? executor.resolveBin();
@@ -19325,7 +19705,7 @@ function executorHealthy(opts = {}) {
19325
19705
  child.on("close", (code) => {
19326
19706
  if (code === 0) return finish({ ok: true, reason: "ok", resetHint: null });
19327
19707
  if (executor.probe.limitPattern.test(out)) {
19328
- return finish({ ok: false, reason: "limit", resetHint: out.match(RESET_RE)?.[0]?.trim() ?? null });
19708
+ return finish({ ok: false, reason: "limit", resetHint: out.match(RESET_RE2)?.[0]?.trim() ?? null });
19329
19709
  }
19330
19710
  if (executor.probe.authPattern?.test(out)) {
19331
19711
  return finish({ ok: false, reason: "auth", resetHint: null });
@@ -19355,19 +19735,19 @@ async function fetchExternalStorm(url, opts = {}) {
19355
19735
  }
19356
19736
 
19357
19737
  // src/anomalyState.ts
19358
- import { existsSync as existsSync22, readFileSync as readFileSync26, renameSync as renameSync11, writeFileSync as writeFileSync18 } from "fs";
19359
- import { join as join37 } from "path";
19738
+ import { existsSync as existsSync22, readFileSync as readFileSync27, renameSync as renameSync11, writeFileSync as writeFileSync18 } from "fs";
19739
+ import { join as join39 } from "path";
19360
19740
  var KEY_TTL_MS = 7 * 24 * 60 * 6e4;
19361
19741
  var MAX_RESOLVED = 200;
19362
19742
  function emptyState() {
19363
19743
  return { since: {}, lastFiredAt: {}, fires: {}, resolved: [], stopQuiet: null };
19364
19744
  }
19365
19745
  function anomalyStatePath(home) {
19366
- return join37(home, "anomaly-state.json");
19746
+ return join39(home, "anomaly-state.json");
19367
19747
  }
19368
19748
  function loadAnomalyState(home, now = Date.now(), io = {}) {
19369
19749
  const exists = io.exists ?? existsSync22;
19370
- const readFile2 = io.readFile ?? ((p) => readFileSync26(p, "utf8"));
19750
+ const readFile2 = io.readFile ?? ((p) => readFileSync27(p, "utf8"));
19371
19751
  const path = anomalyStatePath(home);
19372
19752
  if (!exists(path)) return emptyState();
19373
19753
  try {
@@ -20848,10 +21228,10 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
20848
21228
  }
20849
21229
  return parts.join("\n");
20850
21230
  }
20851
- var HERO_CHARTER_PATH = join38(dirname6(THIS_FILE), "..", "docs", "HERO.md");
21231
+ var HERO_CHARTER_PATH = join40(dirname6(THIS_FILE), "..", "docs", "HERO.md");
20852
21232
  function buildHeroPrompt(task, run2, taskContext, attachmentsBlock) {
20853
21233
  const name = run2.name || `#${run2.id}`;
20854
- const charter = readFileSync27(HERO_CHARTER_PATH, "utf8");
21234
+ const charter = readFileSync28(HERO_CHARTER_PATH, "utf8");
20855
21235
  const head = task ? `\u042D\u041F\u0418\u041A ${run2.task_slug}: ${task.title}
20856
21236
 
20857
21237
  ${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).`;
@@ -20911,9 +21291,9 @@ function ciTrustLine(prUrl, verifyMode, ciClosed = null) {
20911
21291
  }
20912
21292
  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}`;
20913
21293
  }
20914
- var REVIEW_SKILL_PATH = join38(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
21294
+ var REVIEW_SKILL_PATH = join40(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
20915
21295
  function reviewDefectClasses(skillPath = REVIEW_SKILL_PATH) {
20916
- const text = readFileSync27(skillPath, "utf8");
21296
+ const text = readFileSync28(skillPath, "utf8");
20917
21297
  const m = /^## Классы дефектов\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(text);
20918
21298
  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?`);
20919
21299
  return `\u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 (skill taskless-review):
@@ -21106,6 +21486,47 @@ function narrate(deps, text) {
21106
21486
  } catch {
21107
21487
  }
21108
21488
  }
21489
+ function stormProviderName(deps) {
21490
+ try {
21491
+ return deps.storm?.providerName?.() ?? "\u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C";
21492
+ } catch {
21493
+ return "\u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C";
21494
+ }
21495
+ }
21496
+ function stormAnomalyCandidates(deps, now) {
21497
+ if (!deps.storm || !deps.db.stormActive()) return [];
21498
+ const startedAt = deps.db.currentStormStartedAt();
21499
+ if (!startedAt) return [];
21500
+ const startedAtMs = sqliteMs(startedAt);
21501
+ const cfg = resolveStormConfig(deps.storm.config);
21502
+ const recs = deps.db.stormProbeRecordsSince(startedAt);
21503
+ const failed = [...recs].reverse().find((rec) => rec.probe === false && rec.reason != null && rec.reason !== "ok");
21504
+ const reason = failed?.reason;
21505
+ const providerName = stormProviderName(deps);
21506
+ const hostName = deps.storm.hostName ?? "\u041C\u0430\u0448\u0438\u043D\u0430";
21507
+ return [
21508
+ {
21509
+ key: `storm_long:${startedAt}`,
21510
+ // Порог целиком, не остаток до него. AnomalyTracker копит minDurationMs
21511
+ // с первого появления ключа (тик старта шторма). Вычитание elapsed
21512
+ // сравнивало остаток с уже накопленным временем и слало письмо на
21513
+ // notifyMs/2: к 15-й минуте остаток 15 мин уже не меньше since.
21514
+ minDurationMs: cfg.notifyMs,
21515
+ once: true,
21516
+ build: () => ({
21517
+ level: "decision",
21518
+ title: `${hostName}: \u0440\u043E\u0439 \u0441\u0442\u043E\u0438\u0442 \u0432 \u0434\u043E\u043B\u0433\u043E\u043C \u0448\u0442\u043E\u0440\u043C\u0435`,
21519
+ body: stormLongText({
21520
+ hostName,
21521
+ startedAtMs,
21522
+ now,
21523
+ providerName,
21524
+ reason: reason === "limit" || reason === "auth" || reason === "exec" || reason === "provider" ? reason : "provider"
21525
+ })
21526
+ })
21527
+ }
21528
+ ];
21529
+ }
21109
21530
  async function manageStorm(deps, now, worktreeExists, hasTranscript) {
21110
21531
  const db = deps.db;
21111
21532
  const s = deps.storm;
@@ -21141,8 +21562,8 @@ async function manageStorm(deps, now, worktreeExists, hasTranscript) {
21141
21562
  };
21142
21563
  if (!stormShouldStart(signals, cfg)) return false;
21143
21564
  if (signals.externalDown) {
21144
- db.startStorm(stormStartReason(signals, cfg));
21145
- narrate(deps, "Anthropic \u043B\u0435\u0436\u0438\u0442 \u2014 \u0440\u043E\u0439 \u0443\u0445\u043E\u0434\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C, \u043F\u0430\u0443\u0437\u044E \u0441\u043F\u0430\u0432\u043D\u044B \u0438 \u0441\u043B\u0435\u0436\u0443 \u0437\u0430 \u043E\u0442\u0431\u043E\u0435\u043C.");
21565
+ db.startStorm(stormStartReason(signals, cfg, stormProviderName(deps)));
21566
+ narrate(deps, `${stormProviderName(deps)} \u043B\u0435\u0436\u0438\u0442 \u2014 \u0440\u043E\u0439 \u0443\u0445\u043E\u0434\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C, \u043F\u0430\u0443\u0437\u044E \u0441\u043F\u0430\u0432\u043D\u044B \u0438 \u0441\u043B\u0435\u0436\u0443 \u0437\u0430 \u043E\u0442\u0431\u043E\u0435\u043C.`);
21146
21567
  return true;
21147
21568
  }
21148
21569
  const lastEndMs = db.lastStormEndedAt();
@@ -21169,18 +21590,18 @@ async function manageStorm(deps, now, worktreeExists, hasTranscript) {
21169
21590
  if (!fresh) healthyDeathsAlert(deps, signals, cfg);
21170
21591
  return false;
21171
21592
  }
21172
- db.startStorm(stormStartReason(signals, cfg));
21173
- narrate(deps, "Anthropic \u043B\u0435\u0436\u0438\u0442 (\u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u043E \u043A\u0440\u0430\u0441\u043D\u043E\u0439 health-probe) \u2014 \u0440\u043E\u0439 \u0443\u0445\u043E\u0434\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C, \u043F\u0430\u0443\u0437\u044E \u0441\u043F\u0430\u0432\u043D\u044B \u0438 \u0441\u043B\u0435\u0436\u0443 \u0437\u0430 \u043E\u0442\u0431\u043E\u0435\u043C.");
21593
+ db.startStorm(stormStartReason(signals, cfg, stormProviderName(deps)));
21594
+ narrate(deps, `${stormProviderName(deps)} \u043B\u0435\u0436\u0438\u0442 (\u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u043E \u043A\u0440\u0430\u0441\u043D\u043E\u0439 health-probe) \u2014 \u0440\u043E\u0439 \u0443\u0445\u043E\u0434\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C, \u043F\u0430\u0443\u0437\u044E \u0441\u043F\u0430\u0432\u043D\u044B \u0438 \u0441\u043B\u0435\u0436\u0443 \u0437\u0430 \u043E\u0442\u0431\u043E\u0435\u043C.`);
21174
21595
  return true;
21175
21596
  }
21176
21597
  function healthyDeathsAlert(deps, signals, cfg) {
21177
- const why = stormStartReason(signals, cfg).split(" \u2014 ")[1] ?? "\u044D\u0432\u0440\u0438\u0441\u0442\u0438\u043A\u0430";
21598
+ const why = stormStartReason(signals, cfg, stormProviderName(deps)).split(" \u2014 ")[1] ?? "\u044D\u0432\u0440\u0438\u0441\u0442\u0438\u043A\u0430";
21178
21599
  try {
21179
21600
  deps.db.addEvent(null, "anomaly", `${STORM_HEALTHY_DEATHS_TEXT} (${why})`);
21180
21601
  } catch (e) {
21181
21602
  console.error("[overmind] \u0448\u0442\u043E\u0440\u043C: \u0430\u043B\u0451\u0440\u0442 \xAB\u0434\u0440\u043E\u043D\u044B \u043C\u0440\u0443\u0442 \u043F\u0440\u0438 \u0436\u0438\u0432\u043E\u043C API\xBB \u043D\u0435 \u0437\u0430\u043F\u0438\u0441\u0430\u043B\u0441\u044F:", e);
21182
21603
  }
21183
- narrate(deps, `\u0414\u0440\u043E\u043D\u044B \u043E\u0442\u0432\u0430\u043B\u0438\u0432\u0430\u044E\u0442\u0441\u044F (${why}), \u043D\u043E health-probe \u0437\u0435\u043B\u0451\u043D\u0430\u044F \u2014 \u044D\u0442\u043E \u041D\u0415 Anthropic, \u0432 \u0448\u0442\u043E\u0440\u043C \u043D\u0435 \u0443\u0445\u043E\u0436\u0443.`);
21604
+ narrate(deps, `\u0414\u0440\u043E\u043D\u044B \u043E\u0442\u0432\u0430\u043B\u0438\u0432\u0430\u044E\u0442\u0441\u044F (${why}), \u043D\u043E health-probe \u0437\u0435\u043B\u0451\u043D\u0430\u044F \u2014 \u044D\u0442\u043E \u041D\u0415 \u0441\u0431\u043E\u0439 ${stormProviderName(deps)}, \u0432 \u0448\u0442\u043E\u0440\u043C \u043D\u0435 \u0443\u0445\u043E\u0436\u0443.`);
21184
21605
  }
21185
21606
  async function resurrectStormDead(deps, worktreeExists, hasTranscript, opts) {
21186
21607
  if (!deps.respawn) return 0;
@@ -21497,9 +21918,9 @@ function repoHasCi(deps, run2) {
21497
21918
  function repoHasCiWorkflows(worktreePath, repo) {
21498
21919
  for (const base3 of [worktreePath, repo]) {
21499
21920
  if (!base3) continue;
21500
- const dir = join38(base3, ".github", "workflows");
21921
+ const dir = join40(base3, ".github", "workflows");
21501
21922
  try {
21502
- if (readdirSync16(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
21923
+ if (readdirSync18(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
21503
21924
  } catch {
21504
21925
  }
21505
21926
  }
@@ -21726,6 +22147,9 @@ function worktreeAndTranscriptAlive(deps, run2) {
21726
22147
  const wt = run2.worktree_path;
21727
22148
  return !!wt && exists(wt) && transcript(run2);
21728
22149
  }
22150
+ function limitWaitCandidate(deps, run2) {
22151
+ return deps.exitLimit?.(run2) ?? null;
22152
+ }
21729
22153
  async function projectWantsChecks(deps, run2) {
21730
22154
  if (!deps.autoReviewForRepo) return true;
21731
22155
  return await deps.autoReviewForRepo(effectiveRepo(deps, run2), run2.task_slug).catch((e) => {
@@ -22002,7 +22426,7 @@ async function zoneConflictFor(db, models, activeFiles, run2, repo, repoFallback
22002
22426
  activeFiles.prune(holders.map((r) => r.id));
22003
22427
  const fileExists = (p) => {
22004
22428
  try {
22005
- return statSync15(join38(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
22429
+ return statSync16(join40(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
22006
22430
  } catch {
22007
22431
  return false;
22008
22432
  }
@@ -22643,6 +23067,46 @@ function logCapacity(own, live2, hostOverride, operatorLimit) {
22643
23067
  lastCapacityLine = line;
22644
23068
  console.log(`[overmind] ${line}`);
22645
23069
  }
23070
+ var LIMIT_RESUME_RETRY_MS = 30 * 6e4;
23071
+ var LIMIT_RESUMED_TEXT = "\u041B\u0438\u043C\u0438\u0442 \u0441\u0431\u0440\u043E\u0448\u0435\u043D, \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u044E";
23072
+ function lastLimitResumeMs(deps, runId) {
23073
+ const event = deps.db.events(runId).filter((item) => item.kind === "resumed" && item.text === LIMIT_RESUMED_TEXT).at(-1);
23074
+ return event ? stampMs(event.at) : null;
23075
+ }
23076
+ async function resumeLimitWaits(deps, now, droneCap, stormActive) {
23077
+ if (stormActive || !deps.respawn || countActiveDrones(deps.db) >= droneCap) return;
23078
+ const candidates = deps.db.listRuns("paused").filter((run2) => isLimitWaitDue(run2.stop_reason, now)).filter((run2) => run2.pid == null || !deps.isAlive(run2.pid)).sort((a, b) => a.updated_at.localeCompare(b.updated_at));
23079
+ for (const candidate of candidates) {
23080
+ const capHolder = cycleCapHolder(deps.db, candidate);
23081
+ if (capHolder) {
23082
+ await handOffAtCycleCap(deps, candidate, capHolder, "\u0432\u043E\u0437\u0432\u0440\u0430\u0442 \u043F\u043E\u0441\u043B\u0435 \u043B\u0438\u043C\u0438\u0442\u0430 \u043C\u043E\u0434\u0435\u043B\u0438");
23083
+ continue;
23084
+ }
23085
+ if (!await projectQuotaGateAllows(deps, candidate)) continue;
23086
+ const canContinue = deps.runHasSession ? deps.runHasSession(candidate) : worktreeAndTranscriptAlive(deps, candidate);
23087
+ const mode = canContinue ? "continue" : "fresh";
23088
+ const wt = candidate.worktree_path;
23089
+ if (mode === "continue" && wt && deps.reclaimWorktree) {
23090
+ try {
23091
+ await deps.reclaimWorktree(wt);
23092
+ } catch (e) {
23093
+ console.error(`[overmind] \u0440\u0435\u043A\u043B\u0435\u0439\u043C worktree \u043F\u0435\u0440\u0435\u0434 \u0432\u043E\u0437\u0432\u0440\u0430\u0442\u043E\u043C \u043F\u043E\u0441\u043B\u0435 \u043B\u0438\u043C\u0438\u0442\u0430 ${droneLabel(candidate)} \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F:`, e);
23094
+ }
23095
+ }
23096
+ try {
23097
+ await deps.respawn(candidate, mode);
23098
+ deps.db.updateRun(candidate.id, { stop_reason: null });
23099
+ if (mode === "fresh") deps.db.addEvent(candidate.id, "step", "\u0441\u0435\u0441\u0441\u0438\u044F \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430, \u043D\u0430\u0447\u0430\u043B \u0437\u0430\u043D\u043E\u0432\u043E");
23100
+ deps.db.addEvent(candidate.id, "resumed", LIMIT_RESUMED_TEXT);
23101
+ narrate(deps, `\u041B\u0438\u043C\u0438\u0442 \u0441\u0431\u0440\u043E\u0448\u0435\u043D \u2014 \u0432\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u044E ${droneLabel(candidate)} \u0432 \u0440\u0430\u0431\u043E\u0442\u0443.`);
23102
+ } catch (e) {
23103
+ const reason = `\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C \u043F\u043E\u0441\u043B\u0435 \u043B\u0438\u043C\u0438\u0442\u0430: ${String(e)}`;
23104
+ deps.db.updateRun(candidate.id, { status: "stalled", stop_reason: reason });
23105
+ deps.db.addEvent(candidate.id, "stalled", reason);
23106
+ }
23107
+ return;
23108
+ }
23109
+ }
22646
23110
  async function manageRelief(deps, now, droneCap, stormActive) {
22647
23111
  const state = deps.relief ?? (deps.relief = {});
22648
23112
  const cfg = state.config ? resolveReliefConfig(state.config) : DEFAULT_RELIEF_CONFIG;
@@ -23467,11 +23931,14 @@ async function tickOnce(deps) {
23467
23931
  }
23468
23932
  }
23469
23933
  if (deps.exitOutcome && endedItself(deps.exitOutcome(run2))) continue;
23934
+ if (limitWaitCandidate(deps, run2)) continue;
23470
23935
  deps.db.recordDeath(run2.id, `\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440 (pid ${run2.pid} \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442)`);
23471
23936
  }
23472
23937
  stormActive = await manageStorm(deps, now, worktreeExists, hasTranscript);
23473
23938
  }
23474
23939
  const droneCap = deps.maxDrones ? await deps.maxDrones() : Infinity;
23940
+ deps.stepClock?.mark("0e \u0432\u043E\u0437\u0432\u0440\u0430\u0442 \u043F\u043E\u0441\u043B\u0435 \u043B\u0438\u043C\u0438\u0442\u0430");
23941
+ await resumeLimitWaits(deps, now, droneCap, stormActive);
23475
23942
  deps.stepClock?.mark("1 \u043F\u043E\u0434\u043D\u044F\u0442\u044C \u043E\u0447\u0435\u0440\u0435\u0434\u044C");
23476
23943
  if (stormActive) noteStormStall(deps);
23477
23944
  deps.stepClock?.mark("0b \u0432\u0435\u0441 \u0437\u0430\u0434\u0430\u0447\u0438");
@@ -23804,6 +24271,22 @@ async function tickOnce(deps) {
23804
24271
  continue;
23805
24272
  }
23806
24273
  }
24274
+ const limitHit = !alive && run2.status === "running" ? limitWaitCandidate(deps, run2) : null;
24275
+ if (limitHit) {
24276
+ const report = deps.limitsSnapshot?.() ?? null;
24277
+ let resetsAt = limitResetAt({ executor: limitHit.executor, report, resetHint: limitHit.resetHint, nowMs: now });
24278
+ const lastResumeMs = lastLimitResumeMs(deps, run2.id);
24279
+ if (lastResumeMs !== null && now - lastResumeMs < LIMIT_RESUME_RETRY_MS) {
24280
+ resetsAt = new Date(Math.max(Date.parse(resetsAt), now + LIMIT_RESUME_RETRY_MS)).toISOString();
24281
+ }
24282
+ const text = limitWaitText(limitHit.executor, limitWaitWindow(report, limitHit.executor));
24283
+ const resetClock = new Date(resetsAt).toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit" });
24284
+ const stopReason = limitWaitReason({ executor: limitHit.executor, resetsAt, text });
24285
+ deps.db.updateRun(run2.id, { status: "paused", stop_reason: stopReason });
24286
+ deps.db.addEvent(run2.id, "paused", `${text}, \u0441\u0431\u0440\u043E\u0441 \u0432 ${resetClock}`);
24287
+ narrate(deps, `${droneLabel(run2)} ${text.charAt(0).toLowerCase()}${text.slice(1)}, \u0436\u0434\u0443 \u0441\u0431\u0440\u043E\u0441\u0430 \u0432 ${resetClock}`);
24288
+ continue;
24289
+ }
23807
24290
  if (stormActive && run2.resolves_run_id == null && run2.reviews_run_id == null) {
23808
24291
  if (!alive) {
23809
24292
  const priorFreezes = deps.db.events(run2.id).filter((e) => e.kind === "storm_dead").length;
@@ -23813,7 +24296,7 @@ async function tickOnce(deps) {
23813
24296
  narrate(deps, `${droneLabel(run2)} \u0446\u0438\u043A\u043B\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C\u0435 (${STORM_DEAD_LIMIT} \u043A\u043E\u043A\u043E\u043D\u043E\u0432) \u2014 \u0441\u0434\u0430\u044E\u0441\u044C, \u0434\u0430\u043B\u044C\u0448\u0435 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440.`);
23814
24297
  } else {
23815
24298
  deps.db.updateRun(run2.id, { status: "storm_dead" });
23816
- deps.db.addEvent(run2.id, "storm_dead", STORM_DEAD_TEXT);
24299
+ deps.db.addEvent(run2.id, "storm_dead", stormDeadText(stormProviderName(deps)));
23817
24300
  }
23818
24301
  }
23819
24302
  continue;
@@ -24035,6 +24518,7 @@ async function tickOnce(deps) {
24035
24518
  for (const run2 of deps.db.listRuns("paused")) {
24036
24519
  if (run2.kind === "hero") continue;
24037
24520
  if (run2.stop_reason === AWAITING_CI_REASON || isReliefPause(run2.stop_reason)) continue;
24521
+ if (isLimitWait(run2.stop_reason)) continue;
24038
24522
  if (isAwaitingBudget(run2.status, run2.stop_reason)) continue;
24039
24523
  const last = lastActivityMs(deps.db, run2);
24040
24524
  if (now - last <= STALL_FLOOR_MS) continue;
@@ -24054,6 +24538,7 @@ async function tickOnce(deps) {
24054
24538
  if (run2.kind === "hero") continue;
24055
24539
  if (run2.reviews_run_id != null) continue;
24056
24540
  if (isReliefPause(run2.stop_reason)) continue;
24541
+ if (isLimitWait(run2.stop_reason)) continue;
24057
24542
  if (NO_AUTO_WAKE_REASONS.some((r) => run2.stop_reason?.startsWith(r))) continue;
24058
24543
  if (run2.pid != null && deps.isAlive(run2.pid)) continue;
24059
24544
  const capHolder = cycleCapHolder(deps.db, run2);
@@ -24124,6 +24609,7 @@ async function tickOnce(deps) {
24124
24609
  ...az.startedAt != null ? { daemonStartedAt: az.startedAt } : {}
24125
24610
  }),
24126
24611
  ...buildEscalationCandidates(deps.db),
24612
+ ...stormAnomalyCandidates(deps, now),
24127
24613
  // ЦЕНА РАЗГРУЗКИ (TASWM-316): «машина не тянет» с числами и рекомендацией — та же
24128
24614
  // труба, тот же дедуп «один раз на эпизод». Пустой список при нормальной работе.
24129
24615
  ...await buildReliefCostCandidatesFor(deps, now, droneCap)
@@ -24303,7 +24789,7 @@ async function resolveConflict(deps, reviewRun) {
24303
24789
  model: reviewRun.model,
24304
24790
  review_model: reviewRun.review_model
24305
24791
  });
24306
- const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
24792
+ const wt = join40(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
24307
24793
  try {
24308
24794
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24309
24795
  await deps.git.setWorktreeIdentity(wt, resolver.name);
@@ -24384,7 +24870,7 @@ async function spawnReviewer(deps, reviewRun, files) {
24384
24870
  // (своей у ревьюера нет, TASWM-204), и коммент с вердиктом должен уехать именно туда.
24385
24871
  workspace_id: reviewRun.workspace_id
24386
24872
  });
24387
- const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
24873
+ const wt = join40(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
24388
24874
  try {
24389
24875
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24390
24876
  await deps.git.setWorktreeIdentity(wt, reviewer.name);
@@ -24465,7 +24951,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
24465
24951
  // штамп цикла: фикс-итерацию проверяет свежий верификатор
24466
24952
  workspace_id: verifiedRun.workspace_id
24467
24953
  });
24468
- const wt = join38(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
24954
+ const wt = join40(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
24469
24955
  try {
24470
24956
  await deps.git.prepareDetachedWorktree(repo, branch, wt);
24471
24957
  await deps.git.setWorktreeIdentity(wt, verifier.name);
@@ -24664,7 +25150,7 @@ async function makeStore(repo, worktreesDir, repoFlag, executorFor) {
24664
25150
  console.warn(`[overmind] \u043D\u0435 \u0441\u043C\u043E\u0433 \u0437\u0430\u043F\u043E\u043C\u043D\u0438\u0442\u044C \u043F\u0443\u0442\u044C \u043A \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044E (${e instanceof Error ? e.message : e}) \u2014 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u0437\u0430\u043F\u0443\u0441\u043A \u0441\u043D\u043E\u0432\u0430 \u043F\u043E\u043F\u0440\u043E\u0441\u0438\u0442 --repo`);
24665
25151
  }
24666
25152
  }
24667
- const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW, homedir7(), repoPaths);
25153
+ const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW, homedir8(), repoPaths);
24668
25154
  const repoMap = emptyRepoMapState(scanRootsList);
24669
25155
  if (SWARM_BACKEND !== "client") {
24670
25156
  const { SwarmDb: SwarmDb2 } = await loadSqlite();
@@ -24769,7 +25255,7 @@ async function migrateWorktreesAtStartup() {
24769
25255
  exists: (d) => existsSync23(d),
24770
25256
  isNonEmptyDir: (d) => {
24771
25257
  try {
24772
- return readdirSync16(d).length > 0;
25258
+ return readdirSync18(d).length > 0;
24773
25259
  } catch {
24774
25260
  return false;
24775
25261
  }
@@ -24796,6 +25282,10 @@ async function reportWorkspaceAccess(tl, db) {
24796
25282
  console.warn("[overmind] \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A \u0432\u043E\u0440\u043A\u0441\u043F\u0435\u0439\u0441\u0430\u043C \u043D\u0435 \u0443\u0434\u0430\u043B\u0430\u0441\u044C (\u043D\u0435 \u0431\u043B\u043E\u043A\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0430\u0440\u0442):", e);
24797
25283
  }
24798
25284
  }
25285
+ var modelLimitsPoller = null;
25286
+ function lastModelLimits() {
25287
+ return modelLimitsPoller?.report() ?? null;
25288
+ }
24799
25289
  async function runDaemon(opts) {
24800
25290
  installCrashGuards();
24801
25291
  installLogStamps();
@@ -24946,6 +25436,7 @@ async function runDaemon(opts) {
24946
25436
  };
24947
25437
  const tickIntervalMs = opts.intervalMs ?? 4e3;
24948
25438
  const tickHealth = initialTickHealth(Date.now());
25439
+ modelLimitsPoller = createModelLimitsPoller({ installed: () => cachedInstalledExecutorIds() });
24949
25440
  let heartbeat;
24950
25441
  if (SWARM_BACKEND === "client" && db instanceof SwarmClient && SWARM_PROD_HEARTBEAT_MS > 0) {
24951
25442
  const client = db;
@@ -24953,6 +25444,7 @@ async function runDaemon(opts) {
24953
25444
  push: async () => {
24954
25445
  const stormActive = client.stormActive();
24955
25446
  const stormStartedAt = stormActive ? client.currentStormStartedAt() : null;
25447
+ modelLimitsPoller?.maybePoll();
24956
25448
  const reply = await client.heartbeat(
24957
25449
  daemonVersion?.get() ?? null,
24958
25450
  control.state ?? null,
@@ -24977,7 +25469,8 @@ async function runDaemon(opts) {
24977
25469
  tickPulse(tickHealth, Date.now(), tickIntervalMs),
24978
25470
  // TASWM-592: установленные агенты машины — справочник для парка машин.
24979
25471
  cachedInstalledExecutorIds(),
24980
- availableProviders(cachedInstalledExecutorIds())
25472
+ availableProviders(cachedInstalledExecutorIds()),
25473
+ modelLimitsPoller?.report() ?? null
24981
25474
  );
24982
25475
  if (reply.maxDrones !== void 0) operatorMaxDrones = reply.maxDrones;
24983
25476
  if (reply.commands.length) onHostCommands(reply.commands);
@@ -25431,6 +25924,13 @@ async function runDaemon(opts) {
25431
25924
  exitOutcome: makeExitClassifier(RUN_LOGS_DIR, (runId) => db.runLogKeys(runId), (run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null)),
25432
25925
  // TASWM-487: вид обрыва — из того же result-файла и теми же ключами каталога.
25433
25926
  exitAbort: makeAbortReader(RUN_LOGS_DIR, (runId) => db.runLogKeys(runId), (run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null)),
25927
+ exitLimit: makeLimitReader(
25928
+ RUN_LOGS_DIR,
25929
+ (runId) => db.runLogKeys(runId),
25930
+ (run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null),
25931
+ lastModelLimits
25932
+ ),
25933
+ limitsSnapshot: lastModelLimits,
25434
25934
  // TASWM-487: жива ли работа на origin. Тот же фолбэк repo, что у removeWorktree выше:
25435
25935
  // у прогона в основном репозитории демона run.repo пуст.
25436
25936
  branchOnOrigin: (repo, branch) => remoteBranchExists(repo || opts.repo, branch),
@@ -25635,6 +26135,7 @@ async function runDaemon(opts) {
25635
26135
  startedAt: Date.now(),
25636
26136
  // TASWM-592: run-aware — где лежит сессия, знает харнесс ПРОГОНА.
25637
26137
  hasTranscript: (run2) => !!run2.worktree_path && executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null).session.exists(run2.worktree_path),
26138
+ runHasSession: (run2) => !!run2.worktree_path && existsSync23(run2.worktree_path) && executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null).session.exists(run2.worktree_path),
25638
26139
  // CI-осведомлённость review-PR (TASWM-102): реальный `gh pr checks`/`gh run view --log-failed`
25639
26140
  // (gh.ts) — решение (будить ли дрона) и гейты живут в tickOnce/handleCiRed. failureSummary
25640
26141
  // строится над failing/failingRunIds ИЗ checks — без повторного `gh pr checks`.
@@ -25645,6 +26146,8 @@ async function runDaemon(opts) {
25645
26146
  // Штормовой режим (TASWM-23): health-probe на отбой (реальный claude) + внешний
25646
26147
  // сигнал SWARM_STORM_URL (2-й слой, если задан). Логика/пороги — в manageStorm/storm.ts.
25647
26148
  storm: {
26149
+ providerName: () => executorLimitLabel(executorForRun({ kind: "drone" }, lastSwarmModels).id).short,
26150
+ hostName: host.hostName,
25648
26151
  // TASWM-592: проба бьёт в исполнителя, на котором работают дроны (реестр провайдеров
25649
26152
  // по ссылке модели роя), — иначе рой на другом харнессе штормовал бы по вине claude
25650
26153
  // и наоборот.
@@ -26207,6 +26710,7 @@ export {
26207
26710
  hasPreparingRuns,
26208
26711
  isSubrun,
26209
26712
  lastChangesSummary,
26713
+ lastModelLimits,
26210
26714
  lastVerifySummary,
26211
26715
  listDroneProcesses,
26212
26716
  livePpids,