@taskless-app/swarm 0.6.82 → 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.
- package/dist/cli.js +73 -29
- package/dist/overmind.js +715 -184
- 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();
|
|
@@ -3147,7 +3186,7 @@ function extractModelsBlocks(config) {
|
|
|
3147
3186
|
for (const line of lines) {
|
|
3148
3187
|
if (/^\s*\[/.test(line)) {
|
|
3149
3188
|
if (current) blocks.push(current);
|
|
3150
|
-
current = /^\s*\[models\./.test(line) ? [line] : null;
|
|
3189
|
+
current = /^\s*\[(?:models|providers)\./.test(line) ? [line] : null;
|
|
3151
3190
|
continue;
|
|
3152
3191
|
}
|
|
3153
3192
|
if (current) current.push(line);
|
|
@@ -3180,13 +3219,27 @@ function ensureKimiHome(worktree, realHome, env = process.env, swarmHome = SWARM
|
|
|
3180
3219
|
}
|
|
3181
3220
|
const realConfig = join8((env.KIMI_CODE_HOME ?? "").trim() || join8(realHome, ".kimi-code"), "config.toml");
|
|
3182
3221
|
try {
|
|
3183
|
-
const
|
|
3184
|
-
|
|
3222
|
+
const raw = readFileSync4(realConfig, "utf8");
|
|
3223
|
+
const blocks = extractModelsBlocks(raw);
|
|
3224
|
+
const defaultModel = resolveShadowDefaultModel(raw, blocks);
|
|
3225
|
+
if (blocks.length > 0) {
|
|
3226
|
+
const head = defaultModel ? `default_model = "${defaultModel}"
|
|
3227
|
+
|
|
3228
|
+
` : "";
|
|
3229
|
+
writeFileSync5(join8(home, "config.toml"), `${head}${blocks.join("\n\n")}
|
|
3185
3230
|
`);
|
|
3231
|
+
}
|
|
3186
3232
|
} catch {
|
|
3187
3233
|
}
|
|
3188
3234
|
return home;
|
|
3189
3235
|
}
|
|
3236
|
+
function resolveShadowDefaultModel(config, blocks) {
|
|
3237
|
+
const declared = /^default_model\s*=\s*"([^"]+)"/m.exec(config)?.[1];
|
|
3238
|
+
if (declared?.trim()) return declared.trim();
|
|
3239
|
+
const firstModel = blocks.find((b) => /^\s*\[models\./.test(b));
|
|
3240
|
+
const alias = /^\s*\[models\."([^"]+)"\]/.exec(firstModel ?? "")?.[1];
|
|
3241
|
+
return alias?.trim() || null;
|
|
3242
|
+
}
|
|
3190
3243
|
function modelArgs2(model) {
|
|
3191
3244
|
if (!model || isHarnessDefaultModel(model)) return [];
|
|
3192
3245
|
return ["-m", model];
|
|
@@ -3236,15 +3289,9 @@ var init_kimi = __esm({
|
|
|
3236
3289
|
resolveBin: (env) => resolveKimiBin(env ?? process.env),
|
|
3237
3290
|
plan: (spec) => {
|
|
3238
3291
|
const home = ensureKimiHome(spec.worktree, spec.realHome);
|
|
3239
|
-
|
|
3240
|
-
writeFileSync5(
|
|
3241
|
-
|
|
3242
|
-
JSON.stringify(
|
|
3243
|
-
{ mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
|
|
3244
|
-
null,
|
|
3245
|
-
2
|
|
3246
|
-
)
|
|
3247
|
-
);
|
|
3292
|
+
const mcpJson = kimiMcpJson(spec);
|
|
3293
|
+
writeFileSync5(join8(home, "mcp.json"), mcpJson);
|
|
3294
|
+
writeFileSync5(join8(spec.worktree, SWARM_MCP_CONFIG_FILE), mcpJson);
|
|
3248
3295
|
const args = [
|
|
3249
3296
|
// `--add-dir` стоит первым: настоящий флаг kimi, по нему реконсайл узнаёт
|
|
3250
3297
|
// worktree живого процесса после рестарта демона (worktreeFromKimiCmd).
|
|
@@ -3269,7 +3316,7 @@ var init_kimi = __esm({
|
|
|
3269
3316
|
},
|
|
3270
3317
|
probe: {
|
|
3271
3318
|
args: ["-p", "ok", "--output-format", "stream-json"],
|
|
3272
|
-
limitPattern: /usage limit|quota
|
|
3319
|
+
limitPattern: /usage limit|insufficient[_ ]quota/i,
|
|
3273
3320
|
authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
|
|
3274
3321
|
}
|
|
3275
3322
|
};
|
|
@@ -4094,14 +4141,25 @@ function plural(n, forms) {
|
|
|
4094
4141
|
const d = n % 10;
|
|
4095
4142
|
return forms[m >= 11 && m <= 14 ? 2 : d === 1 ? 0 : d >= 2 && d <= 4 ? 1 : 2];
|
|
4096
4143
|
}
|
|
4097
|
-
function
|
|
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) {
|
|
4098
4151
|
const why = [];
|
|
4099
4152
|
if (s.deaths >= cfg.deathThreshold)
|
|
4100
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`);
|
|
4101
4154
|
if (s.spawnFails >= cfg.spawnFailThreshold)
|
|
4102
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`);
|
|
4103
|
-
if (s.externalDown) why.push(
|
|
4104
|
-
return `${
|
|
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.`;
|
|
4105
4163
|
}
|
|
4106
4164
|
function trailingProbeSuccesses(recs) {
|
|
4107
4165
|
let n = 0;
|
|
@@ -4120,7 +4178,7 @@ function lastExternalDown(recs) {
|
|
|
4120
4178
|
function stormShouldEnd(s, cfg) {
|
|
4121
4179
|
return s.consecutiveProbeOk >= cfg.probeSuccessesToClear && !s.externalDown;
|
|
4122
4180
|
}
|
|
4123
|
-
var numEnv, DEFAULT_STORM_CONFIG,
|
|
4181
|
+
var numEnv, DEFAULT_STORM_CONFIG, STORM_END_TEXT, STORM_HEALTHY_DEATHS_TEXT, STORM_RESUME_CONTINUE_TEXT, STORM_RESUME_FRESH_TEXT;
|
|
4124
4182
|
var init_storm = __esm({
|
|
4125
4183
|
"src/storm.ts"() {
|
|
4126
4184
|
"use strict";
|
|
@@ -4136,12 +4194,11 @@ var init_storm = __esm({
|
|
|
4136
4194
|
probeIntervalMs: numEnv("SWARM_STORM_PROBE_INTERVAL_MS", 60 * 1e3),
|
|
4137
4195
|
probeSuccessesToClear: numEnv("SWARM_STORM_PROBE_CLEAR", 2),
|
|
4138
4196
|
probeTimeoutMs: numEnv("SWARM_STORM_PROBE_TIMEOUT_MS", 20 * 1e3),
|
|
4139
|
-
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)
|
|
4140
4199
|
};
|
|
4141
|
-
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)";
|
|
4142
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";
|
|
4143
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";
|
|
4144
|
-
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";
|
|
4145
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)";
|
|
4146
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)";
|
|
4147
4204
|
}
|
|
@@ -4947,9 +5004,9 @@ var init_procCleanup = __esm({
|
|
|
4947
5004
|
});
|
|
4948
5005
|
|
|
4949
5006
|
// src/git.ts
|
|
4950
|
-
import { existsSync as existsSync14, readdirSync as
|
|
5007
|
+
import { existsSync as existsSync14, readdirSync as readdirSync16, realpathSync as realpathSync2, statSync as statSync13 } from "fs";
|
|
4951
5008
|
import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
|
|
4952
|
-
import { isAbsolute as isAbsolute3, join as
|
|
5009
|
+
import { isAbsolute as isAbsolute3, join as join25, resolve as resolve3, sep as sep2 } from "path";
|
|
4953
5010
|
import { $ as $2 } from "execa";
|
|
4954
5011
|
function gitNet(repo, args, timeoutMs) {
|
|
4955
5012
|
return withHardTimeout(
|
|
@@ -4973,12 +5030,12 @@ async function reclaimStaleWorktree(repo, worktree) {
|
|
|
4973
5030
|
async function inspectWorktreePath(path) {
|
|
4974
5031
|
if (!existsSync14(path)) return "free";
|
|
4975
5032
|
try {
|
|
4976
|
-
if (
|
|
5033
|
+
if (readdirSync16(path).length === 0) return "free";
|
|
4977
5034
|
} catch {
|
|
4978
5035
|
return "orphan";
|
|
4979
5036
|
}
|
|
4980
5037
|
try {
|
|
4981
|
-
if (
|
|
5038
|
+
if (statSync13(join25(path, ".git")).isDirectory()) return "main-checkout";
|
|
4982
5039
|
} catch {
|
|
4983
5040
|
}
|
|
4984
5041
|
const top = await $2({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
|
|
@@ -5038,7 +5095,7 @@ async function parkOrphanDir(repo, path, branch) {
|
|
|
5038
5095
|
}
|
|
5039
5096
|
function isLinkedWorktree(dir) {
|
|
5040
5097
|
try {
|
|
5041
|
-
return
|
|
5098
|
+
return statSync13(join25(dir, ".git")).isFile();
|
|
5042
5099
|
} catch {
|
|
5043
5100
|
return false;
|
|
5044
5101
|
}
|
|
@@ -5150,8 +5207,8 @@ async function ensureGitExcluded(worktree, pattern) {
|
|
|
5150
5207
|
try {
|
|
5151
5208
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
5152
5209
|
if (!commonDir) return false;
|
|
5153
|
-
const infoDir =
|
|
5154
|
-
const excludeFile =
|
|
5210
|
+
const infoDir = join25(commonDir, "info");
|
|
5211
|
+
const excludeFile = join25(infoDir, "exclude");
|
|
5155
5212
|
let current = "";
|
|
5156
5213
|
try {
|
|
5157
5214
|
current = await readFile(excludeFile, "utf8");
|
|
@@ -5171,7 +5228,7 @@ async function gitPath(worktree, flag) {
|
|
|
5171
5228
|
const out = await $2({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
|
|
5172
5229
|
const raw = out.stdout.trim();
|
|
5173
5230
|
if (out.exitCode !== 0 || !raw) return null;
|
|
5174
|
-
return isAbsolute3(raw) ? raw :
|
|
5231
|
+
return isAbsolute3(raw) ? raw : join25(worktree, raw);
|
|
5175
5232
|
}
|
|
5176
5233
|
async function ensureWorktreeHygiene(worktree) {
|
|
5177
5234
|
for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
|
|
@@ -5181,12 +5238,12 @@ async function installGuardHooks(worktree) {
|
|
|
5181
5238
|
try {
|
|
5182
5239
|
const gitDir = await gitPath(worktree, "--git-dir");
|
|
5183
5240
|
if (!gitDir) return false;
|
|
5184
|
-
const hooksDir =
|
|
5241
|
+
const hooksDir = join25(gitDir, "swarm-hooks");
|
|
5185
5242
|
const prev = await previousHooksPath(worktree);
|
|
5186
5243
|
await mkdir(hooksDir, { recursive: true });
|
|
5187
5244
|
for (const hook of GUARD_HOOKS) {
|
|
5188
|
-
await writeFile(
|
|
5189
|
-
await chmod(
|
|
5245
|
+
await writeFile(join25(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
|
|
5246
|
+
await chmod(join25(hooksDir, hook), 493);
|
|
5190
5247
|
}
|
|
5191
5248
|
await $2`git -C ${worktree} config extensions.worktreeConfig true`;
|
|
5192
5249
|
await $2`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
|
|
@@ -5205,7 +5262,7 @@ async function previousHooksPath(worktree) {
|
|
|
5205
5262
|
if (out.exitCode === 0 && value) return value;
|
|
5206
5263
|
}
|
|
5207
5264
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
5208
|
-
return commonDir ?
|
|
5265
|
+
return commonDir ? join25(commonDir, "hooks") : null;
|
|
5209
5266
|
}
|
|
5210
5267
|
async function removeWorktree(repo, path) {
|
|
5211
5268
|
const branch = (await $2({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
|
|
@@ -5230,7 +5287,7 @@ async function worktreeDirty(path) {
|
|
|
5230
5287
|
async function repairMovedWorktrees(targetDir) {
|
|
5231
5288
|
const subdirs = (dir) => {
|
|
5232
5289
|
try {
|
|
5233
|
-
return
|
|
5290
|
+
return readdirSync16(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join25(dir, d.name));
|
|
5234
5291
|
} catch {
|
|
5235
5292
|
return [];
|
|
5236
5293
|
}
|
|
@@ -5367,12 +5424,12 @@ __export(droneChannel_exports, {
|
|
|
5367
5424
|
verifyLocalCliToken: () => verifyLocalCliToken
|
|
5368
5425
|
});
|
|
5369
5426
|
import { createHmac, randomBytes, timingSafeEqual } from "crypto";
|
|
5370
|
-
import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as
|
|
5427
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "fs";
|
|
5371
5428
|
import { dirname as dirname5 } from "path";
|
|
5372
5429
|
import { serve } from "@hono/node-server";
|
|
5373
5430
|
function loadChannelSecret(path) {
|
|
5374
5431
|
try {
|
|
5375
|
-
const s =
|
|
5432
|
+
const s = readFileSync22(path, "utf8").trim();
|
|
5376
5433
|
if (s.length >= 32) return s;
|
|
5377
5434
|
} catch {
|
|
5378
5435
|
}
|
|
@@ -5768,7 +5825,7 @@ var init_droneChannel = __esm({
|
|
|
5768
5825
|
|
|
5769
5826
|
// src/attachments.ts
|
|
5770
5827
|
import { mkdir as mkdir3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
5771
|
-
import { join as
|
|
5828
|
+
import { join as join30 } from "path";
|
|
5772
5829
|
function attachmentsFromDoc(doc, origin) {
|
|
5773
5830
|
const out = [];
|
|
5774
5831
|
const walk2 = (node) => {
|
|
@@ -5859,7 +5916,7 @@ async function materializeAttachments(opts) {
|
|
|
5859
5916
|
};
|
|
5860
5917
|
const result = { files: [], skipped: [] };
|
|
5861
5918
|
if (opts.refs.length === 0) return result;
|
|
5862
|
-
const dir =
|
|
5919
|
+
const dir = join30(opts.worktree, ATTACHMENTS_DIR);
|
|
5863
5920
|
await io.removeDir(dir);
|
|
5864
5921
|
let dirReady = false;
|
|
5865
5922
|
let total = 0;
|
|
@@ -5905,7 +5962,7 @@ async function materializeAttachments(opts) {
|
|
|
5905
5962
|
await io.mkdir(dir);
|
|
5906
5963
|
dirReady = true;
|
|
5907
5964
|
}
|
|
5908
|
-
await io.writeFile(
|
|
5965
|
+
await io.writeFile(join30(dir, name), file.bytes);
|
|
5909
5966
|
} catch (e) {
|
|
5910
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)})`);
|
|
5911
5968
|
continue;
|
|
@@ -6058,7 +6115,7 @@ var init_attachments = __esm({
|
|
|
6058
6115
|
|
|
6059
6116
|
// src/shotUpload.ts
|
|
6060
6117
|
import { readFile as fsReadFile } from "fs/promises";
|
|
6061
|
-
import { basename as basename4, isAbsolute as isAbsolute4, join as
|
|
6118
|
+
import { basename as basename4, isAbsolute as isAbsolute4, join as join31 } from "path";
|
|
6062
6119
|
function shotMimetype(path) {
|
|
6063
6120
|
const dot = path.lastIndexOf(".");
|
|
6064
6121
|
if (dot < 0) return null;
|
|
@@ -6084,7 +6141,7 @@ async function readShots(paths, opts) {
|
|
|
6084
6141
|
}
|
|
6085
6142
|
let bytes;
|
|
6086
6143
|
try {
|
|
6087
|
-
bytes = await read(isAbsolute4(path) ? path :
|
|
6144
|
+
bytes = await read(isAbsolute4(path) ? path : join31(opts.worktree, path));
|
|
6088
6145
|
} catch (e) {
|
|
6089
6146
|
skipped.push({ path, reason: `\u043D\u0435 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D: ${e instanceof Error ? e.message : String(e)}` });
|
|
6090
6147
|
continue;
|
|
@@ -6164,12 +6221,12 @@ var init_shotUpload = __esm({
|
|
|
6164
6221
|
});
|
|
6165
6222
|
|
|
6166
6223
|
// src/oauth.ts
|
|
6167
|
-
import { createHash as
|
|
6168
|
-
import { readFileSync as
|
|
6169
|
-
import { join as
|
|
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";
|
|
6170
6227
|
function makePkce() {
|
|
6171
6228
|
const verifier = randomBytes2(48).toString("base64url");
|
|
6172
|
-
const challenge =
|
|
6229
|
+
const challenge = createHash4("sha256").update(verifier).digest("base64url");
|
|
6173
6230
|
return { verifier, challenge };
|
|
6174
6231
|
}
|
|
6175
6232
|
async function registerClient(args, fetchFn = fetch) {
|
|
@@ -6250,7 +6307,7 @@ function toStore(clientId, t, now) {
|
|
|
6250
6307
|
}
|
|
6251
6308
|
function loadStore() {
|
|
6252
6309
|
try {
|
|
6253
|
-
return JSON.parse(
|
|
6310
|
+
return JSON.parse(readFileSync23(STORE_PATH2, "utf8"));
|
|
6254
6311
|
} catch {
|
|
6255
6312
|
return null;
|
|
6256
6313
|
}
|
|
@@ -6266,7 +6323,7 @@ function clearStore() {
|
|
|
6266
6323
|
}
|
|
6267
6324
|
function loadClientId() {
|
|
6268
6325
|
try {
|
|
6269
|
-
return JSON.parse(
|
|
6326
|
+
return JSON.parse(readFileSync23(CLIENT_PATH, "utf8")).clientId;
|
|
6270
6327
|
} catch {
|
|
6271
6328
|
return null;
|
|
6272
6329
|
}
|
|
@@ -6301,8 +6358,8 @@ var init_oauth = __esm({
|
|
|
6301
6358
|
AUTHORIZE = "/api/oauth/authorize";
|
|
6302
6359
|
TOKEN = "/api/oauth/token";
|
|
6303
6360
|
SCOPE = "openid profile email taskless:full";
|
|
6304
|
-
STORE_PATH2 =
|
|
6305
|
-
CLIENT_PATH =
|
|
6361
|
+
STORE_PATH2 = join32(SWARM_HOME, "oauth.json");
|
|
6362
|
+
CLIENT_PATH = join32(SWARM_HOME, "oauth-client.json");
|
|
6306
6363
|
base2 = (api) => api.replace(/\/$/, "");
|
|
6307
6364
|
}
|
|
6308
6365
|
});
|
|
@@ -6389,11 +6446,11 @@ var init_authState = __esm({
|
|
|
6389
6446
|
});
|
|
6390
6447
|
|
|
6391
6448
|
// src/workspace.ts
|
|
6392
|
-
import { readFileSync as
|
|
6393
|
-
import { join as
|
|
6449
|
+
import { readFileSync as readFileSync24, writeFileSync as writeFileSync16, unlinkSync as unlinkSync5 } from "fs";
|
|
6450
|
+
import { join as join33 } from "path";
|
|
6394
6451
|
function loadWorkspace() {
|
|
6395
6452
|
try {
|
|
6396
|
-
const w = JSON.parse(
|
|
6453
|
+
const w = JSON.parse(readFileSync24(WORKSPACE_PATH, "utf8"));
|
|
6397
6454
|
return w && typeof w.id === "string" && w.id ? w : null;
|
|
6398
6455
|
} catch {
|
|
6399
6456
|
return null;
|
|
@@ -6407,7 +6464,7 @@ var init_workspace = __esm({
|
|
|
6407
6464
|
"src/workspace.ts"() {
|
|
6408
6465
|
"use strict";
|
|
6409
6466
|
init_config();
|
|
6410
|
-
WORKSPACE_PATH =
|
|
6467
|
+
WORKSPACE_PATH = join33(SWARM_HOME, "workspace.json");
|
|
6411
6468
|
}
|
|
6412
6469
|
});
|
|
6413
6470
|
|
|
@@ -8080,9 +8137,9 @@ var init_droneStore = __esm({
|
|
|
8080
8137
|
});
|
|
8081
8138
|
|
|
8082
8139
|
// src/overmind.ts
|
|
8083
|
-
import { homedir as
|
|
8084
|
-
import { existsSync as existsSync23, readFileSync as
|
|
8085
|
-
import { basename as basename6, dirname as dirname6, join as
|
|
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";
|
|
8086
8143
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
8087
8144
|
import { spawn as spawn4 } from "child_process";
|
|
8088
8145
|
|
|
@@ -8497,8 +8554,8 @@ var SwarmClient = class _SwarmClient {
|
|
|
8497
8554
|
// предикат «репо есть локально» для решения, брать ли свободный прогон.
|
|
8498
8555
|
host;
|
|
8499
8556
|
repoExists;
|
|
8500
|
-
// TASWM-398: ЧЕМ эта машина исполняет прогоны — id адаптера (claude-code|codex).
|
|
8501
8557
|
executorId;
|
|
8558
|
+
executorFor;
|
|
8502
8559
|
// Зеркало.
|
|
8503
8560
|
runs = /* @__PURE__ */ new Map();
|
|
8504
8561
|
runtime = /* @__PURE__ */ new Map();
|
|
@@ -8560,6 +8617,8 @@ var SwarmClient = class _SwarmClient {
|
|
|
8560
8617
|
// TAS-956: момент отказа taskSlug по тулу. Окно и детектор — slugRetry.
|
|
8561
8618
|
// Свой экземпляр: отказ этого клиента не общий с makeTasklessClient.
|
|
8562
8619
|
slugRetry;
|
|
8620
|
+
// TASWM-643: старый прод может не знать modelLimits; окно повторной пробы отдельное от taskSlug.
|
|
8621
|
+
modelLimitsRetry;
|
|
8563
8622
|
// Корреляция с продом.
|
|
8564
8623
|
keyByLocal = /* @__PURE__ */ new Map();
|
|
8565
8624
|
// local run id → runKey
|
|
@@ -8604,6 +8663,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
8604
8663
|
constructor(opts) {
|
|
8605
8664
|
this.now = opts.now ?? Date.now;
|
|
8606
8665
|
this.slugRetry = new SlugUnsupportedAt(this.now);
|
|
8666
|
+
this.modelLimitsRetry = new SlugUnsupportedAt(this.now);
|
|
8607
8667
|
this.call = opts.call;
|
|
8608
8668
|
this.defaultRepo = normalizeRepo(opts.defaultRepo ?? "");
|
|
8609
8669
|
this.autoFlush = opts.autoFlush ?? true;
|
|
@@ -8616,6 +8676,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
8616
8676
|
this.repoExists = opts.repoExists ?? existsSync9;
|
|
8617
8677
|
this.questionSyncMs = opts.questionSyncMs ?? 3e3;
|
|
8618
8678
|
this.executorId = opts.executorId ?? EXECUTOR.id;
|
|
8679
|
+
this.executorFor = opts.executorFor;
|
|
8619
8680
|
this.outboxPath = opts.outboxPath;
|
|
8620
8681
|
this.mapPath = `${opts.outboxPath}.prodmap.json`;
|
|
8621
8682
|
this.stormPath = `${opts.outboxPath}.storm.jsonl`;
|
|
@@ -8726,10 +8787,16 @@ var SwarmClient = class _SwarmClient {
|
|
|
8726
8787
|
// в прод НЕ уходят. kind → role (плоский enum). Self-ref
|
|
8727
8788
|
// прогонов hero_run_id/resolves_run_id/superseded_by → heroId/resolvesRunId/
|
|
8728
8789
|
// supersededById как ОТЛОЖЕННЫЕ ссылки (RunRef) — cuid резолвится на флаше.
|
|
8729
|
-
runFields(patch) {
|
|
8790
|
+
runFields(patch, run2) {
|
|
8730
8791
|
const out = {};
|
|
8731
8792
|
if ("status" in patch && patch.status !== void 0) out.status = patch.status;
|
|
8732
|
-
if (patch.status === "running")
|
|
8793
|
+
if (patch.status === "running") {
|
|
8794
|
+
try {
|
|
8795
|
+
out.executor = run2 && this.executorFor ? this.executorFor(run2) : this.executorId;
|
|
8796
|
+
} catch {
|
|
8797
|
+
out.executor = this.executorId;
|
|
8798
|
+
}
|
|
8799
|
+
}
|
|
8733
8800
|
if ("area" in patch) out.area = normalizeZoneLabel(patch.area) || null;
|
|
8734
8801
|
if ("model" in patch) out.model = patch.model ?? null;
|
|
8735
8802
|
if ("review_model" in patch) out.reviewModel = patch.review_model ?? null;
|
|
@@ -8981,7 +9048,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
8981
9048
|
d[k] = v;
|
|
8982
9049
|
}
|
|
8983
9050
|
d.updated_at = stamp();
|
|
8984
|
-
this.enqueueRun(d, this.runFields(patch));
|
|
9051
|
+
this.enqueueRun(d, this.runFields(patch, this.mat(d)));
|
|
8985
9052
|
return this.mat(d);
|
|
8986
9053
|
}
|
|
8987
9054
|
incRespawn(id) {
|
|
@@ -10292,7 +10359,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
10292
10359
|
*
|
|
10293
10360
|
* Прод недоступен / ответ без поручений → пустые списки (демон работает дальше).
|
|
10294
10361
|
*/
|
|
10295
|
-
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) {
|
|
10296
10363
|
try {
|
|
10297
10364
|
const args = this.repoFullNames.length ? { repoFullNames: this.repoFullNames } : {};
|
|
10298
10365
|
if (daemonVersion) args.daemonVersion = daemonVersion;
|
|
@@ -10324,7 +10391,14 @@ var SwarmClient = class _SwarmClient {
|
|
|
10324
10391
|
}
|
|
10325
10392
|
if (executors) args.executorsAvailable = executors;
|
|
10326
10393
|
if (providers) args.providersAvailable = providers;
|
|
10327
|
-
|
|
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
|
+
}
|
|
10328
10402
|
if (res?.isError) return EMPTY_HEARTBEAT_REPLY;
|
|
10329
10403
|
this.heartbeatOkAt = this.now();
|
|
10330
10404
|
const data = res?.structuredContent ?? {};
|
|
@@ -12043,7 +12117,7 @@ function envCapUsd(env) {
|
|
|
12043
12117
|
return Number.isFinite(n) && n >= 0 ? n : DEFAULT_RUN_LIMITS.maxCostUsd;
|
|
12044
12118
|
}
|
|
12045
12119
|
function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
|
|
12046
|
-
const env = { ...base3 };
|
|
12120
|
+
const env = { ...base3, TASKLESS_SWARM_DRONE: "1" };
|
|
12047
12121
|
const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
|
|
12048
12122
|
if (isolate && !base3.TURBO_CACHE_DIR) {
|
|
12049
12123
|
env.TURBO_CACHE_DIR = join19(worktree, ".turbo", "cache");
|
|
@@ -12445,6 +12519,154 @@ function makeAbortReader(runLogsDir, runLogKeys, executorFor = () => resolveExec
|
|
|
12445
12519
|
return (run2) => abortOfExit(runLogsDir, runLogKeys(run2.id), executorFor(run2));
|
|
12446
12520
|
}
|
|
12447
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
|
+
|
|
12448
12670
|
// src/overmind.ts
|
|
12449
12671
|
init_executors();
|
|
12450
12672
|
init_claudeCode();
|
|
@@ -12456,7 +12678,7 @@ init_src();
|
|
|
12456
12678
|
init_swarmModels();
|
|
12457
12679
|
init_executors();
|
|
12458
12680
|
import { accessSync, constants } from "fs";
|
|
12459
|
-
import { delimiter, join as
|
|
12681
|
+
import { delimiter, join as join23 } from "path";
|
|
12460
12682
|
function binRunnable(bin, env) {
|
|
12461
12683
|
if (!bin) return false;
|
|
12462
12684
|
if (bin.includes("/") || bin.includes("\\")) {
|
|
@@ -12472,7 +12694,7 @@ function binRunnable(bin, env) {
|
|
|
12472
12694
|
if (!dir) continue;
|
|
12473
12695
|
for (const ext of exts) {
|
|
12474
12696
|
try {
|
|
12475
|
-
accessSync(
|
|
12697
|
+
accessSync(join23(dir, bin + ext), constants.X_OK);
|
|
12476
12698
|
return true;
|
|
12477
12699
|
} catch {
|
|
12478
12700
|
}
|
|
@@ -12514,33 +12736,198 @@ function providerUnavailableReason(providerId, available) {
|
|
|
12514
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`;
|
|
12515
12737
|
}
|
|
12516
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
|
+
|
|
12517
12904
|
// src/orchestrator.ts
|
|
12518
12905
|
init_src();
|
|
12519
12906
|
init_git();
|
|
12520
12907
|
|
|
12521
12908
|
// src/deps.ts
|
|
12522
|
-
import { existsSync as existsSync16, readdirSync as
|
|
12523
|
-
import { join as
|
|
12909
|
+
import { existsSync as existsSync16, readdirSync as readdirSync17, readFileSync as readFileSync21 } from "fs";
|
|
12910
|
+
import { join as join28 } from "path";
|
|
12524
12911
|
import { execa } from "execa";
|
|
12525
12912
|
|
|
12526
12913
|
// src/prepareLock.ts
|
|
12527
|
-
import { createHash } from "crypto";
|
|
12528
|
-
import { closeSync as
|
|
12529
|
-
import { join as
|
|
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";
|
|
12530
12917
|
import { tmpdir } from "os";
|
|
12531
12918
|
var WAIT_TIMEOUT_MS = 5 * 6e4;
|
|
12532
12919
|
var POLL_MS = 300;
|
|
12533
12920
|
var STALE_MS = 20 * 6e4;
|
|
12534
12921
|
function machineLockPath(key, dir = tmpdir()) {
|
|
12535
|
-
return
|
|
12922
|
+
return join26(dir, `swarm-prepare-${createHash2("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
|
|
12536
12923
|
}
|
|
12537
12924
|
function defaultTryCreate(path, content) {
|
|
12538
12925
|
try {
|
|
12539
|
-
const fd =
|
|
12926
|
+
const fd = openSync6(path, "wx");
|
|
12540
12927
|
try {
|
|
12541
12928
|
writeSync2(fd, content);
|
|
12542
12929
|
} finally {
|
|
12543
|
-
|
|
12930
|
+
closeSync6(fd);
|
|
12544
12931
|
}
|
|
12545
12932
|
return true;
|
|
12546
12933
|
} catch {
|
|
@@ -12549,7 +12936,7 @@ function defaultTryCreate(path, content) {
|
|
|
12549
12936
|
}
|
|
12550
12937
|
function defaultAgeMs(path) {
|
|
12551
12938
|
try {
|
|
12552
|
-
return Date.now() -
|
|
12939
|
+
return Date.now() - statSync14(path).mtimeMs;
|
|
12553
12940
|
} catch {
|
|
12554
12941
|
return null;
|
|
12555
12942
|
}
|
|
@@ -12591,12 +12978,12 @@ init_config();
|
|
|
12591
12978
|
|
|
12592
12979
|
// src/envCache.ts
|
|
12593
12980
|
init_config();
|
|
12594
|
-
import { createHash as
|
|
12981
|
+
import { createHash as createHash3 } from "crypto";
|
|
12595
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";
|
|
12596
|
-
import { existsSync as existsSync15, readFileSync as
|
|
12597
|
-
import { join as
|
|
12983
|
+
import { existsSync as existsSync15, readFileSync as readFileSync20 } from "fs";
|
|
12984
|
+
import { join as join27 } from "path";
|
|
12598
12985
|
function fingerprint(parts) {
|
|
12599
|
-
const h =
|
|
12986
|
+
const h = createHash3("sha256");
|
|
12600
12987
|
for (const p of parts) {
|
|
12601
12988
|
h.update(p);
|
|
12602
12989
|
h.update("\0");
|
|
@@ -12608,8 +12995,8 @@ async function cloneTree(src, dst) {
|
|
|
12608
12995
|
const entries = await readdir(src, { withFileTypes: true });
|
|
12609
12996
|
await Promise.all(
|
|
12610
12997
|
entries.map(async (e) => {
|
|
12611
|
-
const from =
|
|
12612
|
-
const to =
|
|
12998
|
+
const from = join27(src, e.name);
|
|
12999
|
+
const to = join27(dst, e.name);
|
|
12613
13000
|
if (e.isDirectory()) return cloneTree(from, to);
|
|
12614
13001
|
if (e.isSymbolicLink()) {
|
|
12615
13002
|
return symlink(await readlink(from), to).catch(() => cp(from, to, { recursive: true, verbatimSymlinks: true }));
|
|
@@ -12622,11 +13009,11 @@ function cacheRoot(io) {
|
|
|
12622
13009
|
return io.root ?? ENV_CACHE_DIR;
|
|
12623
13010
|
}
|
|
12624
13011
|
function snapshotDir(io, key) {
|
|
12625
|
-
return
|
|
13012
|
+
return join27(cacheRoot(io), key);
|
|
12626
13013
|
}
|
|
12627
13014
|
function readManifest(dir) {
|
|
12628
13015
|
try {
|
|
12629
|
-
const parsed = JSON.parse(
|
|
13016
|
+
const parsed = JSON.parse(readFileSync20(join27(dir, "manifest.json"), "utf8"));
|
|
12630
13017
|
if (!parsed || typeof parsed !== "object") return null;
|
|
12631
13018
|
const m = parsed;
|
|
12632
13019
|
if (typeof m.key !== "string" || !Array.isArray(m.dirs)) return null;
|
|
@@ -12639,7 +13026,7 @@ function readManifest(dir) {
|
|
|
12639
13026
|
}
|
|
12640
13027
|
function hasEnvSnapshot(key, io = {}) {
|
|
12641
13028
|
const exists = io.exists ?? existsSync15;
|
|
12642
|
-
return exists(
|
|
13029
|
+
return exists(join27(snapshotDir(io, key), "manifest.json"));
|
|
12643
13030
|
}
|
|
12644
13031
|
async function restoreEnvSnapshot(worktree, key, io = {}) {
|
|
12645
13032
|
const exists = io.exists ?? existsSync15;
|
|
@@ -12651,13 +13038,13 @@ async function restoreEnvSnapshot(worktree, key, io = {}) {
|
|
|
12651
13038
|
try {
|
|
12652
13039
|
for (let i = 0; i < manifest.dirs.length; i++) {
|
|
12653
13040
|
const rel = manifest.dirs[i] ?? "";
|
|
12654
|
-
const target =
|
|
13041
|
+
const target = join27(worktree, rel);
|
|
12655
13042
|
if (exists(target)) continue;
|
|
12656
|
-
await clone(
|
|
13043
|
+
await clone(join27(dir, "trees", String(i)), target);
|
|
12657
13044
|
made.push(rel);
|
|
12658
13045
|
}
|
|
12659
13046
|
} catch {
|
|
12660
|
-
for (const rel of made) await rm2(
|
|
13047
|
+
for (const rel of made) await rm2(join27(worktree, rel), { recursive: true, force: true }).catch(() => {
|
|
12661
13048
|
});
|
|
12662
13049
|
return null;
|
|
12663
13050
|
}
|
|
@@ -12673,16 +13060,16 @@ async function saveEnvSnapshot(worktree, key, dirs, io = {}) {
|
|
|
12673
13060
|
const exists = io.exists ?? existsSync15;
|
|
12674
13061
|
const clone = io.clone ?? cloneTree;
|
|
12675
13062
|
if (hasEnvSnapshot(key, io)) return true;
|
|
12676
|
-
const present = dirs.filter((rel) => exists(
|
|
13063
|
+
const present = dirs.filter((rel) => exists(join27(worktree, rel)));
|
|
12677
13064
|
if (!present.length) return false;
|
|
12678
13065
|
const root = cacheRoot(io);
|
|
12679
|
-
const tmp =
|
|
13066
|
+
const tmp = join27(root, `.tmp-${key}-${process.pid}`);
|
|
12680
13067
|
try {
|
|
12681
13068
|
await rm2(tmp, { recursive: true, force: true });
|
|
12682
|
-
await mkdir2(
|
|
12683
|
-
for (let i = 0; i < present.length; i++) await clone(
|
|
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)));
|
|
12684
13071
|
const manifest = { key, dirs: present, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
12685
|
-
await writeFile2(
|
|
13072
|
+
await writeFile2(join27(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
12686
13073
|
await rename2(tmp, snapshotDir(io, key));
|
|
12687
13074
|
return true;
|
|
12688
13075
|
} catch {
|
|
@@ -12702,13 +13089,13 @@ async function pruneEnvSnapshots(io = {}) {
|
|
|
12702
13089
|
}
|
|
12703
13090
|
const withTime = [];
|
|
12704
13091
|
for (const name of names) {
|
|
12705
|
-
const s = await stat(
|
|
13092
|
+
const s = await stat(join27(root, name)).catch(() => null);
|
|
12706
13093
|
if (s) withTime.push({ name, mtime: s.mtimeMs });
|
|
12707
13094
|
}
|
|
12708
13095
|
withTime.sort((a, b) => b.mtime - a.mtime);
|
|
12709
13096
|
let removed = 0;
|
|
12710
13097
|
for (const { name } of withTime.slice(Math.max(0, keep))) {
|
|
12711
|
-
await rm2(
|
|
13098
|
+
await rm2(join27(root, name), { recursive: true, force: true }).catch(() => {
|
|
12712
13099
|
});
|
|
12713
13100
|
removed++;
|
|
12714
13101
|
}
|
|
@@ -12724,9 +13111,9 @@ async function sweepEnvCacheTemp(io = {}) {
|
|
|
12724
13111
|
}
|
|
12725
13112
|
let removed = 0;
|
|
12726
13113
|
for (const name of names) {
|
|
12727
|
-
const s = await lstat(
|
|
13114
|
+
const s = await lstat(join27(root, name)).catch(() => null);
|
|
12728
13115
|
if (!s || Date.now() - s.mtimeMs < 60 * 6e4) continue;
|
|
12729
|
-
await rm2(
|
|
13116
|
+
await rm2(join27(root, name), { recursive: true, force: true }).catch(() => {
|
|
12730
13117
|
});
|
|
12731
13118
|
removed++;
|
|
12732
13119
|
}
|
|
@@ -12753,21 +13140,21 @@ async function runCommand(cmd, worktree) {
|
|
|
12753
13140
|
}
|
|
12754
13141
|
function safeReadText(p) {
|
|
12755
13142
|
try {
|
|
12756
|
-
return
|
|
13143
|
+
return readFileSync21(p, "utf8");
|
|
12757
13144
|
} catch {
|
|
12758
13145
|
return null;
|
|
12759
13146
|
}
|
|
12760
13147
|
}
|
|
12761
13148
|
function safeListDirs(p) {
|
|
12762
13149
|
try {
|
|
12763
|
-
return
|
|
13150
|
+
return readdirSync17(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
12764
13151
|
} catch {
|
|
12765
13152
|
return [];
|
|
12766
13153
|
}
|
|
12767
13154
|
}
|
|
12768
13155
|
function safeListFiles(p) {
|
|
12769
13156
|
try {
|
|
12770
|
-
return
|
|
13157
|
+
return readdirSync17(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
|
|
12771
13158
|
} catch {
|
|
12772
13159
|
return [];
|
|
12773
13160
|
}
|
|
@@ -12795,19 +13182,19 @@ function overridePlan(override) {
|
|
|
12795
13182
|
function detectPackageManager(worktree, io = {}) {
|
|
12796
13183
|
const exists = io.exists ?? existsSync16;
|
|
12797
13184
|
const readText = io.readText ?? safeReadText;
|
|
12798
|
-
const hasPkgJson = exists(
|
|
13185
|
+
const hasPkgJson = exists(join28(worktree, "package.json"));
|
|
12799
13186
|
if (!hasPkgJson) {
|
|
12800
|
-
if (exists(
|
|
13187
|
+
if (exists(join28(worktree, "deno.json")) || exists(join28(worktree, "deno.jsonc")) || exists(join28(worktree, "deno.lock"))) return "deno";
|
|
12801
13188
|
return null;
|
|
12802
13189
|
}
|
|
12803
|
-
const pkg = readJson(readText,
|
|
13190
|
+
const pkg = readJson(readText, join28(worktree, "package.json"));
|
|
12804
13191
|
const declared = typeof pkg?.packageManager === "string" ? pkg.packageManager.split("@")[0] : void 0;
|
|
12805
13192
|
if (declared === "pnpm" || declared === "bun" || declared === "npm" || declared === "yarn") return declared;
|
|
12806
|
-
if (exists(
|
|
12807
|
-
if (exists(
|
|
12808
|
-
if (exists(
|
|
12809
|
-
if (exists(
|
|
12810
|
-
if (exists(
|
|
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";
|
|
12811
13198
|
return "npm";
|
|
12812
13199
|
}
|
|
12813
13200
|
function jsInstallCommand(pm) {
|
|
@@ -12871,7 +13258,7 @@ function detectPlan(worktree, io) {
|
|
|
12871
13258
|
// node_modules на месте — установку пропускаем (быстрый путь переиспользованного worktree).
|
|
12872
13259
|
// У deno каталога может не быть вовсе (кэш в DENO_DIR) — тогда `deno install` отработает
|
|
12873
13260
|
// заново, но он дешёвый: тянет из того же общего кэша.
|
|
12874
|
-
{ label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists:
|
|
13261
|
+
{ label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join28(worktree, "node_modules"), source: "detect" }
|
|
12875
13262
|
];
|
|
12876
13263
|
for (const target of workspaceBuildTargets(worktree, io)) {
|
|
12877
13264
|
commands.push({ label: `\u0441\u0431\u043E\u0440\u043A\u0430 ${target.name}`, run: jsRunScript(pm, "build"), cwd: target.dir, source: "detect" });
|
|
@@ -12880,12 +13267,12 @@ function detectPlan(worktree, io) {
|
|
|
12880
13267
|
return { source: "detect", ecosystem: `node/${pm}`, commands };
|
|
12881
13268
|
}
|
|
12882
13269
|
for (const marker of ECOSYSTEM_MARKERS) {
|
|
12883
|
-
const hit = marker.files.some((f) => exists(
|
|
13270
|
+
const hit = marker.files.some((f) => exists(join28(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
|
|
12884
13271
|
if (!hit) continue;
|
|
12885
13272
|
let ecosystem = marker.ecosystem;
|
|
12886
13273
|
let command = marker.command;
|
|
12887
13274
|
for (const refine of marker.refine ?? []) {
|
|
12888
|
-
if (!exists(
|
|
13275
|
+
if (!exists(join28(worktree, refine.file))) continue;
|
|
12889
13276
|
ecosystem = refine.ecosystem;
|
|
12890
13277
|
command = refine.command;
|
|
12891
13278
|
break;
|
|
@@ -12942,12 +13329,12 @@ var CI_INSTALL_PATTERNS = [
|
|
|
12942
13329
|
function ciWorkflowPlan(worktree, io) {
|
|
12943
13330
|
const readText = io.readText ?? safeReadText;
|
|
12944
13331
|
const listFiles = io.listFiles ?? safeListFiles;
|
|
12945
|
-
const dir =
|
|
13332
|
+
const dir = join28(worktree, ".github", "workflows");
|
|
12946
13333
|
const files = listFiles(dir).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml"));
|
|
12947
13334
|
const seen = /* @__PURE__ */ new Set();
|
|
12948
13335
|
const commands = [];
|
|
12949
13336
|
for (const name of files.sort()) {
|
|
12950
|
-
const yaml = readText(
|
|
13337
|
+
const yaml = readText(join28(dir, name));
|
|
12951
13338
|
if (yaml === null) continue;
|
|
12952
13339
|
for (const raw of workflowRunLines(yaml)) {
|
|
12953
13340
|
const line = raw.replace(/\s+/g, " ").trim();
|
|
@@ -12962,7 +13349,7 @@ function ciWorkflowPlan(worktree, io) {
|
|
|
12962
13349
|
return commands.length ? { source: "ci-workflow", ecosystem: "ci-\u043A\u043E\u043D\u0444\u0438\u0433", commands } : null;
|
|
12963
13350
|
}
|
|
12964
13351
|
function workspaceGlobs(worktree, readText) {
|
|
12965
|
-
const yaml = readText(
|
|
13352
|
+
const yaml = readText(join28(worktree, "pnpm-workspace.yaml"));
|
|
12966
13353
|
if (yaml !== null) {
|
|
12967
13354
|
const globs = [];
|
|
12968
13355
|
let inPackages = false;
|
|
@@ -12982,7 +13369,7 @@ function workspaceGlobs(worktree, readText) {
|
|
|
12982
13369
|
}
|
|
12983
13370
|
if (globs.length) return globs;
|
|
12984
13371
|
}
|
|
12985
|
-
const pkg = readJson(readText,
|
|
13372
|
+
const pkg = readJson(readText, join28(worktree, "package.json"));
|
|
12986
13373
|
const ws = pkg?.workspaces;
|
|
12987
13374
|
const list = Array.isArray(ws) ? ws : Array.isArray(ws?.packages) ? ws.packages : [];
|
|
12988
13375
|
return list.filter((g) => typeof g === "string");
|
|
@@ -12993,14 +13380,14 @@ function workspaceDirs(worktree, globs, io) {
|
|
|
12993
13380
|
if (glob.startsWith("!")) continue;
|
|
12994
13381
|
const star = glob.indexOf("*");
|
|
12995
13382
|
if (star === -1) {
|
|
12996
|
-
const dir =
|
|
12997
|
-
if (io.exists(
|
|
13383
|
+
const dir = join28(worktree, glob);
|
|
13384
|
+
if (io.exists(join28(dir, "package.json"))) dirs.add(dir);
|
|
12998
13385
|
continue;
|
|
12999
13386
|
}
|
|
13000
|
-
const base3 =
|
|
13387
|
+
const base3 = join28(worktree, glob.slice(0, star).replace(/\/$/, ""));
|
|
13001
13388
|
for (const name of io.listDirs(base3)) {
|
|
13002
|
-
const dir =
|
|
13003
|
-
if (io.exists(
|
|
13389
|
+
const dir = join28(base3, name);
|
|
13390
|
+
if (io.exists(join28(dir, "package.json"))) dirs.add(dir);
|
|
13004
13391
|
}
|
|
13005
13392
|
}
|
|
13006
13393
|
return [...dirs];
|
|
@@ -13028,11 +13415,11 @@ function workspaceBuildTargets(worktree, io = {}) {
|
|
|
13028
13415
|
if (!globs.length) return [];
|
|
13029
13416
|
const pkgs = [];
|
|
13030
13417
|
for (const dir of workspaceDirs(worktree, globs, { exists, listDirs })) {
|
|
13031
|
-
const pkg = readJson(readText,
|
|
13418
|
+
const pkg = readJson(readText, join28(dir, "package.json"));
|
|
13032
13419
|
if (!pkg || typeof pkg.name !== "string") continue;
|
|
13033
13420
|
const scripts = pkg.scripts ?? {};
|
|
13034
13421
|
const entries = entryPaths(pkg);
|
|
13035
|
-
const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(
|
|
13422
|
+
const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join28(dir, e)));
|
|
13036
13423
|
const deps = Object.keys({ ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} });
|
|
13037
13424
|
pkgs.push({ name: pkg.name, dir, deps, needsBuild });
|
|
13038
13425
|
}
|
|
@@ -13060,7 +13447,7 @@ function devDatabaseUrl(worktree, io = {}) {
|
|
|
13060
13447
|
const fromEnv = (io.env ?? process.env).DATABASE_URL;
|
|
13061
13448
|
if (fromEnv && fromEnv.trim()) return fromEnv.trim();
|
|
13062
13449
|
for (const file of [".env", ".env.example"]) {
|
|
13063
|
-
const raw = readText(
|
|
13450
|
+
const raw = readText(join28(worktree, file));
|
|
13064
13451
|
if (raw === null) continue;
|
|
13065
13452
|
const m = /^\s*(?:export\s+)?DATABASE_URL\s*=\s*(.*)$/m.exec(raw);
|
|
13066
13453
|
const value = (m?.[1] ?? "").trim().replace(/^['"]|['"]$/g, "");
|
|
@@ -13080,7 +13467,7 @@ function prismaPackages(worktree, io) {
|
|
|
13080
13467
|
const readText = io.readText ?? safeReadText;
|
|
13081
13468
|
const listDirs = io.listDirs ?? safeListDirs;
|
|
13082
13469
|
const dirs = [worktree, ...workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs })];
|
|
13083
|
-
return dirs.filter((dir) => exists(
|
|
13470
|
+
return dirs.filter((dir) => exists(join28(dir, "prisma", "schema.prisma")) && listDirs(join28(dir, "prisma", "migrations")).length > 0);
|
|
13084
13471
|
}
|
|
13085
13472
|
function jsExecBin(pm, command) {
|
|
13086
13473
|
switch (pm) {
|
|
@@ -13117,18 +13504,18 @@ function envCachePlan(worktree, io = {}) {
|
|
|
13117
13504
|
if (!pm) return null;
|
|
13118
13505
|
const parts = [`pm:${pm}`];
|
|
13119
13506
|
for (const name of ENV_DEFINING_FILES) {
|
|
13120
|
-
const raw = readText(
|
|
13507
|
+
const raw = readText(join28(worktree, name));
|
|
13121
13508
|
if (raw !== null) parts.push(`${name}
|
|
13122
13509
|
${raw}`);
|
|
13123
13510
|
}
|
|
13124
13511
|
const pkgDirs = workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs });
|
|
13125
13512
|
const rels = pkgDirs.map((dir) => dir.slice(worktree.length + 1)).sort();
|
|
13126
13513
|
for (const rel of ["", ...rels]) {
|
|
13127
|
-
const raw = readText(
|
|
13514
|
+
const raw = readText(join28(worktree, rel, "package.json"));
|
|
13128
13515
|
if (raw !== null) parts.push(`${rel}/package.json
|
|
13129
13516
|
${raw}`);
|
|
13130
13517
|
}
|
|
13131
|
-
return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) =>
|
|
13518
|
+
return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join28(rel, "node_modules"))] };
|
|
13132
13519
|
}
|
|
13133
13520
|
function planPrepare(worktree, io = {}) {
|
|
13134
13521
|
const plan = overridePlan(io.override) ?? detectPlan(worktree, io) ?? ciWorkflowPlan(worktree, io);
|
|
@@ -13153,7 +13540,7 @@ async function ensureWorktreeDeps(worktree, io = {}) {
|
|
|
13153
13540
|
restored: [],
|
|
13154
13541
|
cached: false
|
|
13155
13542
|
};
|
|
13156
|
-
if (cachePlan && !exists(
|
|
13543
|
+
if (cachePlan && !exists(join28(worktree, "node_modules"))) {
|
|
13157
13544
|
report.restored = await restoreEnvSnapshot(worktree, cachePlan.key, cacheIO) ?? [];
|
|
13158
13545
|
}
|
|
13159
13546
|
const plan = planPrepare(worktree, io);
|
|
@@ -13241,7 +13628,7 @@ function depsPromptNotice(report) {
|
|
|
13241
13628
|
// src/orchestrator.ts
|
|
13242
13629
|
init_config();
|
|
13243
13630
|
import { existsSync as existsSync17, mkdirSync as mkdirSync11, rmSync as rmSync3 } from "fs";
|
|
13244
|
-
import { join as
|
|
13631
|
+
import { join as join29, dirname as dirname4 } from "path";
|
|
13245
13632
|
function droneLaunchedText(workdir, pid) {
|
|
13246
13633
|
return `\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0432 ${workdir} (pid ${pid})`;
|
|
13247
13634
|
}
|
|
@@ -13250,7 +13637,7 @@ function droneLaunchedPid(text) {
|
|
|
13250
13637
|
return m ? Number(m[1]) : null;
|
|
13251
13638
|
}
|
|
13252
13639
|
function repolessRunDir(worktreesDir, taskSlug) {
|
|
13253
|
-
return
|
|
13640
|
+
return join29(dirname4(worktreesDir), "runs", taskSlug);
|
|
13254
13641
|
}
|
|
13255
13642
|
var WORKTREE_HELD_STATUSES = /* @__PURE__ */ new Set(["running", "blocked", "review", "paused", "storm_dead"]);
|
|
13256
13643
|
function worktreePathHeldLive(db, path, exceptRunId) {
|
|
@@ -13528,7 +13915,7 @@ function parkReasonUnretriable(reason) {
|
|
|
13528
13915
|
// package.json
|
|
13529
13916
|
var package_default = {
|
|
13530
13917
|
name: "@taskless-app/swarm",
|
|
13531
|
-
version: "0.6.
|
|
13918
|
+
version: "0.6.84",
|
|
13532
13919
|
type: "module",
|
|
13533
13920
|
description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
|
|
13534
13921
|
keywords: [
|
|
@@ -13580,7 +13967,7 @@ var package_default = {
|
|
|
13580
13967
|
undici: "^7.30.1",
|
|
13581
13968
|
zod: "3.25.76"
|
|
13582
13969
|
},
|
|
13583
|
-
gitHead: "
|
|
13970
|
+
gitHead: "ca2ec899dc2136ad1d23130849fed378b2819ee7"
|
|
13584
13971
|
};
|
|
13585
13972
|
|
|
13586
13973
|
// src/version.ts
|
|
@@ -14400,8 +14787,8 @@ import { z } from "zod";
|
|
|
14400
14787
|
init_git();
|
|
14401
14788
|
|
|
14402
14789
|
// src/diff.ts
|
|
14403
|
-
import { statSync as
|
|
14404
|
-
import { join as
|
|
14790
|
+
import { statSync as statSync15 } from "fs";
|
|
14791
|
+
import { join as join34 } from "path";
|
|
14405
14792
|
import { $ as $4 } from "execa";
|
|
14406
14793
|
var MAX_FILES = 200;
|
|
14407
14794
|
var MAX_LINES_PER_FILE = 1500;
|
|
@@ -14544,7 +14931,7 @@ async function resolveBase(wt, baseBranch) {
|
|
|
14544
14931
|
}
|
|
14545
14932
|
function mtime(path) {
|
|
14546
14933
|
try {
|
|
14547
|
-
return
|
|
14934
|
+
return statSync15(path).mtimeMs;
|
|
14548
14935
|
} catch {
|
|
14549
14936
|
return 0;
|
|
14550
14937
|
}
|
|
@@ -14569,7 +14956,7 @@ async function collectRunDiff(worktree, opts = {}) {
|
|
|
14569
14956
|
files.push(pf);
|
|
14570
14957
|
}
|
|
14571
14958
|
}
|
|
14572
|
-
files.sort((a, b) => mtime(
|
|
14959
|
+
files.sort((a, b) => mtime(join34(worktree, b.path)) - mtime(join34(worktree, a.path)));
|
|
14573
14960
|
const truncatedFiles = files.length > MAX_FILES;
|
|
14574
14961
|
if (truncatedFiles) files = files.slice(0, MAX_FILES);
|
|
14575
14962
|
const added = files.reduce((s, f) => s + f.added, 0);
|
|
@@ -15660,7 +16047,7 @@ async function runDroneServer(runId) {
|
|
|
15660
16047
|
|
|
15661
16048
|
// src/droneBridge.ts
|
|
15662
16049
|
init_src();
|
|
15663
|
-
import { createHash as
|
|
16050
|
+
import { createHash as createHash5 } from "crypto";
|
|
15664
16051
|
|
|
15665
16052
|
// src/anomalies.ts
|
|
15666
16053
|
init_src();
|
|
@@ -15792,7 +16179,7 @@ var AnomalyTracker = class {
|
|
|
15792
16179
|
if (now - startedAt < c.minDurationMs) continue;
|
|
15793
16180
|
const lastFired = this.lastFiredAt.get(c.key);
|
|
15794
16181
|
if (lastFired != null && now - lastFired < this.renotifyCooldownMs) continue;
|
|
15795
|
-
if ((this.fires.get(c.key) ?? 0) >= this.maxRepeats) continue;
|
|
16182
|
+
if ((this.fires.get(c.key) ?? 0) >= (c.once ? 1 : this.maxRepeats)) continue;
|
|
15796
16183
|
result.push(c);
|
|
15797
16184
|
}
|
|
15798
16185
|
let pruned = false;
|
|
@@ -16194,7 +16581,7 @@ function questionKey(runId, text) {
|
|
|
16194
16581
|
return `${runId} ${text.trim().replace(/\s+/g, " ")}`;
|
|
16195
16582
|
}
|
|
16196
16583
|
function noteKey(runId, text) {
|
|
16197
|
-
return `note:${runId}:${
|
|
16584
|
+
return `note:${runId}:${createHash5("sha1").update(questionKey(runId, text)).digest("hex").slice(0, 16)}`;
|
|
16198
16585
|
}
|
|
16199
16586
|
async function syncDroneChannel(opts) {
|
|
16200
16587
|
const result = { imported: [], answered: [], notes: [] };
|
|
@@ -16988,21 +17375,21 @@ async function prodClearMergeIntent(runId, deps = {}) {
|
|
|
16988
17375
|
|
|
16989
17376
|
// src/envGate.ts
|
|
16990
17377
|
import { existsSync as existsSync20 } from "fs";
|
|
16991
|
-
import { join as
|
|
17378
|
+
import { join as join36 } from "path";
|
|
16992
17379
|
import { createConnection } from "net";
|
|
16993
17380
|
import { execa as execa2 } from "execa";
|
|
16994
17381
|
|
|
16995
17382
|
// src/platform.ts
|
|
16996
17383
|
init_src();
|
|
16997
|
-
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync19, readFileSync as
|
|
16998
|
-
import { delimiter as delimiter2, join as
|
|
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";
|
|
16999
17386
|
function resolveCommandPath(name, env = process.env, platform = process.platform) {
|
|
17000
17387
|
if (name.includes("/") || name.includes("\\")) return existsSync19(name) ? name : null;
|
|
17001
17388
|
const dirs = (env.PATH ?? env.Path ?? "").split(delimiter2).filter(Boolean);
|
|
17002
17389
|
const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
|
|
17003
17390
|
for (const dir of dirs) {
|
|
17004
17391
|
for (const ext of exts) {
|
|
17005
|
-
const candidate =
|
|
17392
|
+
const candidate = join35(dir, name + ext);
|
|
17006
17393
|
if (existsSync19(candidate)) return candidate;
|
|
17007
17394
|
}
|
|
17008
17395
|
}
|
|
@@ -17173,7 +17560,7 @@ var COMPOSE_MARKERS = [
|
|
|
17173
17560
|
];
|
|
17174
17561
|
function detectRequirements(repo, io = {}) {
|
|
17175
17562
|
const exists = io.exists ?? existsSync20;
|
|
17176
|
-
const marker = COMPOSE_MARKERS.find((f) => exists(
|
|
17563
|
+
const marker = COMPOSE_MARKERS.find((f) => exists(join36(repo, f)));
|
|
17177
17564
|
return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
|
|
17178
17565
|
}
|
|
17179
17566
|
function resolveRequirements(repo, declared, io = {}) {
|
|
@@ -17963,7 +18350,7 @@ function stormBanner(storm) {
|
|
|
17963
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";
|
|
17964
18351
|
return {
|
|
17965
18352
|
ico: "\u26A1",
|
|
17966
|
-
title: "\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014
|
|
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",
|
|
17967
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.`
|
|
17968
18355
|
};
|
|
17969
18356
|
}
|
|
@@ -18046,7 +18433,7 @@ var GK = ['claw','spore','eye','hex'];
|
|
|
18046
18433
|
var ST = ${jsonForScript(statusTuples())};
|
|
18047
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 };
|
|
18048
18435
|
var TERM = ${jsonForScript(Object.fromEntries(TERMINAL_STATUSES.map((s) => [s, 1])))};
|
|
18049
|
-
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
|
|
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' };
|
|
18050
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' };
|
|
18051
18438
|
|
|
18052
18439
|
function E(s){ return String(s==null?"":s).replace(/[&<>"]/g,function(c){return{'&':'&','<':'<','>':'>','"':'"'}[c]}); }
|
|
@@ -18072,13 +18459,21 @@ function pill(st){ var s=ST[st]||ST.queued; return '<span class="pill '+s[0]+'">
|
|
|
18072
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>'; }
|
|
18073
18460
|
function taskUrl(d){ return d.taskUrl || (TASK_URL_BASE ? TASK_URL_BASE + '/tasks/' + d.slug : null); }
|
|
18074
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
|
+
}
|
|
18075
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) */
|
|
18076
18471
|
function cardStep(d){
|
|
18077
18472
|
if(d.status==='blocked') return '\u0432\u043E\u043F\u0440\u043E\u0441 \u0432 \u0438\u043D\u0431\u043E\u043A\u0441\u0435';
|
|
18078
18473
|
if(d.status==='stalled') return d.reason || '\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441/\u043F\u043E\u0433\u0438\u0431';
|
|
18079
18474
|
if(d.status==='stopped') return d.stopReason || d.reason || '\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D';
|
|
18080
|
-
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 (
|
|
18081
|
-
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
|
|
18082
18477
|
if(d.status==='review') { var n=prNum(d.pr); return 'PR'+(n?(' #'+n):'')+' \u043D\u0430 \u0440\u0435\u0432\u044C\u044E'; }
|
|
18083
18478
|
if(d.status==='done') return '\u0441\u043C\u0435\u0440\u0436\u0435\u043D';
|
|
18084
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';
|
|
@@ -18457,7 +18852,7 @@ function openModal(id){ var reopen=(openId===id); openId=id; var d=byId[id]; if(
|
|
|
18457
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('');
|
|
18458
18853
|
var url = taskUrl(d);
|
|
18459
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>':'');
|
|
18460
|
-
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));
|
|
18461
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>' : '';
|
|
18462
18857
|
var acts='';
|
|
18463
18858
|
var qid = firstQid(d.id);
|
|
@@ -18522,7 +18917,7 @@ function paintStorm(){ var b=document.getElementById('storm-banner'); if(!b) ret
|
|
|
18522
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>';
|
|
18523
18918
|
b.hidden=false; return; }
|
|
18524
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';
|
|
18525
|
-
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
|
|
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>'+
|
|
18526
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>';
|
|
18527
18922
|
b.hidden=false; }
|
|
18528
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. */
|
|
@@ -18929,14 +19324,14 @@ function closeWebServer(server) {
|
|
|
18929
19324
|
|
|
18930
19325
|
// src/hostCommands.ts
|
|
18931
19326
|
init_src();
|
|
18932
|
-
import { readFileSync as
|
|
18933
|
-
import { join as
|
|
19327
|
+
import { readFileSync as readFileSync26, renameSync as renameSync10, writeFileSync as writeFileSync17 } from "fs";
|
|
19328
|
+
import { join as join37 } from "path";
|
|
18934
19329
|
function hostCommandStatePath(home) {
|
|
18935
|
-
return
|
|
19330
|
+
return join37(home, "host-command.json");
|
|
18936
19331
|
}
|
|
18937
19332
|
function readState(path) {
|
|
18938
19333
|
try {
|
|
18939
|
-
return JSON.parse(
|
|
19334
|
+
return JSON.parse(readFileSync26(path, "utf8"));
|
|
18940
19335
|
} catch {
|
|
18941
19336
|
return {};
|
|
18942
19337
|
}
|
|
@@ -19107,7 +19502,7 @@ async function doRestart(cmd, opts, note) {
|
|
|
19107
19502
|
// src/selfUpdate.ts
|
|
19108
19503
|
init_git();
|
|
19109
19504
|
import { existsSync as existsSync21 } from "fs";
|
|
19110
|
-
import { join as
|
|
19505
|
+
import { join as join38 } from "path";
|
|
19111
19506
|
import { $ as $5 } from "execa";
|
|
19112
19507
|
|
|
19113
19508
|
// src/cliIo.ts
|
|
@@ -19169,7 +19564,7 @@ async function runSelfUpdate(io) {
|
|
|
19169
19564
|
};
|
|
19170
19565
|
}
|
|
19171
19566
|
await io.onStep("install", "\u0441\u0442\u0430\u0432\u043B\u044E \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438");
|
|
19172
|
-
if (!exists(
|
|
19567
|
+
if (!exists(join38(repo, "pnpm-lock.yaml"))) {
|
|
19173
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" };
|
|
19174
19569
|
}
|
|
19175
19570
|
const installed2 = await run2("pnpm", ["install", "--frozen-lockfile"], repo);
|
|
@@ -19277,7 +19672,7 @@ function orphanNoteText(run2, q) {
|
|
|
19277
19672
|
// src/probe.ts
|
|
19278
19673
|
init_executors();
|
|
19279
19674
|
import { spawn as spawn3 } from "child_process";
|
|
19280
|
-
var
|
|
19675
|
+
var RESET_RE2 = /resets[^\n]*/i;
|
|
19281
19676
|
function executorHealthy(opts = {}) {
|
|
19282
19677
|
const executor = opts.executor ?? resolveExecutor();
|
|
19283
19678
|
const bin = opts.bin ?? executor.resolveBin();
|
|
@@ -19310,7 +19705,7 @@ function executorHealthy(opts = {}) {
|
|
|
19310
19705
|
child.on("close", (code) => {
|
|
19311
19706
|
if (code === 0) return finish({ ok: true, reason: "ok", resetHint: null });
|
|
19312
19707
|
if (executor.probe.limitPattern.test(out)) {
|
|
19313
|
-
return finish({ ok: false, reason: "limit", resetHint: out.match(
|
|
19708
|
+
return finish({ ok: false, reason: "limit", resetHint: out.match(RESET_RE2)?.[0]?.trim() ?? null });
|
|
19314
19709
|
}
|
|
19315
19710
|
if (executor.probe.authPattern?.test(out)) {
|
|
19316
19711
|
return finish({ ok: false, reason: "auth", resetHint: null });
|
|
@@ -19340,19 +19735,19 @@ async function fetchExternalStorm(url, opts = {}) {
|
|
|
19340
19735
|
}
|
|
19341
19736
|
|
|
19342
19737
|
// src/anomalyState.ts
|
|
19343
|
-
import { existsSync as existsSync22, readFileSync as
|
|
19344
|
-
import { join as
|
|
19738
|
+
import { existsSync as existsSync22, readFileSync as readFileSync27, renameSync as renameSync11, writeFileSync as writeFileSync18 } from "fs";
|
|
19739
|
+
import { join as join39 } from "path";
|
|
19345
19740
|
var KEY_TTL_MS = 7 * 24 * 60 * 6e4;
|
|
19346
19741
|
var MAX_RESOLVED = 200;
|
|
19347
19742
|
function emptyState() {
|
|
19348
19743
|
return { since: {}, lastFiredAt: {}, fires: {}, resolved: [], stopQuiet: null };
|
|
19349
19744
|
}
|
|
19350
19745
|
function anomalyStatePath(home) {
|
|
19351
|
-
return
|
|
19746
|
+
return join39(home, "anomaly-state.json");
|
|
19352
19747
|
}
|
|
19353
19748
|
function loadAnomalyState(home, now = Date.now(), io = {}) {
|
|
19354
19749
|
const exists = io.exists ?? existsSync22;
|
|
19355
|
-
const readFile2 = io.readFile ?? ((p) =>
|
|
19750
|
+
const readFile2 = io.readFile ?? ((p) => readFileSync27(p, "utf8"));
|
|
19356
19751
|
const path = anomalyStatePath(home);
|
|
19357
19752
|
if (!exists(path)) return emptyState();
|
|
19358
19753
|
try {
|
|
@@ -20833,10 +21228,10 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
|
|
|
20833
21228
|
}
|
|
20834
21229
|
return parts.join("\n");
|
|
20835
21230
|
}
|
|
20836
|
-
var HERO_CHARTER_PATH =
|
|
21231
|
+
var HERO_CHARTER_PATH = join40(dirname6(THIS_FILE), "..", "docs", "HERO.md");
|
|
20837
21232
|
function buildHeroPrompt(task, run2, taskContext, attachmentsBlock) {
|
|
20838
21233
|
const name = run2.name || `#${run2.id}`;
|
|
20839
|
-
const charter =
|
|
21234
|
+
const charter = readFileSync28(HERO_CHARTER_PATH, "utf8");
|
|
20840
21235
|
const head = task ? `\u042D\u041F\u0418\u041A ${run2.task_slug}: ${task.title}
|
|
20841
21236
|
|
|
20842
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).`;
|
|
@@ -20896,9 +21291,9 @@ function ciTrustLine(prUrl, verifyMode, ciClosed = null) {
|
|
|
20896
21291
|
}
|
|
20897
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}`;
|
|
20898
21293
|
}
|
|
20899
|
-
var REVIEW_SKILL_PATH =
|
|
21294
|
+
var REVIEW_SKILL_PATH = join40(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
|
|
20900
21295
|
function reviewDefectClasses(skillPath = REVIEW_SKILL_PATH) {
|
|
20901
|
-
const text =
|
|
21296
|
+
const text = readFileSync28(skillPath, "utf8");
|
|
20902
21297
|
const m = /^## Классы дефектов\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(text);
|
|
20903
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?`);
|
|
20904
21299
|
return `\u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 (skill taskless-review):
|
|
@@ -21091,6 +21486,47 @@ function narrate(deps, text) {
|
|
|
21091
21486
|
} catch {
|
|
21092
21487
|
}
|
|
21093
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
|
+
}
|
|
21094
21530
|
async function manageStorm(deps, now, worktreeExists, hasTranscript) {
|
|
21095
21531
|
const db = deps.db;
|
|
21096
21532
|
const s = deps.storm;
|
|
@@ -21126,8 +21562,8 @@ async function manageStorm(deps, now, worktreeExists, hasTranscript) {
|
|
|
21126
21562
|
};
|
|
21127
21563
|
if (!stormShouldStart(signals, cfg)) return false;
|
|
21128
21564
|
if (signals.externalDown) {
|
|
21129
|
-
db.startStorm(stormStartReason(signals, cfg));
|
|
21130
|
-
narrate(deps,
|
|
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.`);
|
|
21131
21567
|
return true;
|
|
21132
21568
|
}
|
|
21133
21569
|
const lastEndMs = db.lastStormEndedAt();
|
|
@@ -21154,18 +21590,18 @@ async function manageStorm(deps, now, worktreeExists, hasTranscript) {
|
|
|
21154
21590
|
if (!fresh) healthyDeathsAlert(deps, signals, cfg);
|
|
21155
21591
|
return false;
|
|
21156
21592
|
}
|
|
21157
|
-
db.startStorm(stormStartReason(signals, cfg));
|
|
21158
|
-
narrate(deps,
|
|
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.`);
|
|
21159
21595
|
return true;
|
|
21160
21596
|
}
|
|
21161
21597
|
function healthyDeathsAlert(deps, signals, cfg) {
|
|
21162
|
-
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";
|
|
21163
21599
|
try {
|
|
21164
21600
|
deps.db.addEvent(null, "anomaly", `${STORM_HEALTHY_DEATHS_TEXT} (${why})`);
|
|
21165
21601
|
} catch (e) {
|
|
21166
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);
|
|
21167
21603
|
}
|
|
21168
|
-
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
|
|
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.`);
|
|
21169
21605
|
}
|
|
21170
21606
|
async function resurrectStormDead(deps, worktreeExists, hasTranscript, opts) {
|
|
21171
21607
|
if (!deps.respawn) return 0;
|
|
@@ -21482,9 +21918,9 @@ function repoHasCi(deps, run2) {
|
|
|
21482
21918
|
function repoHasCiWorkflows(worktreePath, repo) {
|
|
21483
21919
|
for (const base3 of [worktreePath, repo]) {
|
|
21484
21920
|
if (!base3) continue;
|
|
21485
|
-
const dir =
|
|
21921
|
+
const dir = join40(base3, ".github", "workflows");
|
|
21486
21922
|
try {
|
|
21487
|
-
if (
|
|
21923
|
+
if (readdirSync18(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
|
|
21488
21924
|
} catch {
|
|
21489
21925
|
}
|
|
21490
21926
|
}
|
|
@@ -21711,6 +22147,9 @@ function worktreeAndTranscriptAlive(deps, run2) {
|
|
|
21711
22147
|
const wt = run2.worktree_path;
|
|
21712
22148
|
return !!wt && exists(wt) && transcript(run2);
|
|
21713
22149
|
}
|
|
22150
|
+
function limitWaitCandidate(deps, run2) {
|
|
22151
|
+
return deps.exitLimit?.(run2) ?? null;
|
|
22152
|
+
}
|
|
21714
22153
|
async function projectWantsChecks(deps, run2) {
|
|
21715
22154
|
if (!deps.autoReviewForRepo) return true;
|
|
21716
22155
|
return await deps.autoReviewForRepo(effectiveRepo(deps, run2), run2.task_slug).catch((e) => {
|
|
@@ -21987,7 +22426,7 @@ async function zoneConflictFor(db, models, activeFiles, run2, repo, repoFallback
|
|
|
21987
22426
|
activeFiles.prune(holders.map((r) => r.id));
|
|
21988
22427
|
const fileExists = (p) => {
|
|
21989
22428
|
try {
|
|
21990
|
-
return
|
|
22429
|
+
return statSync16(join40(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
|
|
21991
22430
|
} catch {
|
|
21992
22431
|
return false;
|
|
21993
22432
|
}
|
|
@@ -22628,6 +23067,46 @@ function logCapacity(own, live2, hostOverride, operatorLimit) {
|
|
|
22628
23067
|
lastCapacityLine = line;
|
|
22629
23068
|
console.log(`[overmind] ${line}`);
|
|
22630
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
|
+
}
|
|
22631
23110
|
async function manageRelief(deps, now, droneCap, stormActive) {
|
|
22632
23111
|
const state = deps.relief ?? (deps.relief = {});
|
|
22633
23112
|
const cfg = state.config ? resolveReliefConfig(state.config) : DEFAULT_RELIEF_CONFIG;
|
|
@@ -23452,11 +23931,14 @@ async function tickOnce(deps) {
|
|
|
23452
23931
|
}
|
|
23453
23932
|
}
|
|
23454
23933
|
if (deps.exitOutcome && endedItself(deps.exitOutcome(run2))) continue;
|
|
23934
|
+
if (limitWaitCandidate(deps, run2)) continue;
|
|
23455
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)`);
|
|
23456
23936
|
}
|
|
23457
23937
|
stormActive = await manageStorm(deps, now, worktreeExists, hasTranscript);
|
|
23458
23938
|
}
|
|
23459
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);
|
|
23460
23942
|
deps.stepClock?.mark("1 \u043F\u043E\u0434\u043D\u044F\u0442\u044C \u043E\u0447\u0435\u0440\u0435\u0434\u044C");
|
|
23461
23943
|
if (stormActive) noteStormStall(deps);
|
|
23462
23944
|
deps.stepClock?.mark("0b \u0432\u0435\u0441 \u0437\u0430\u0434\u0430\u0447\u0438");
|
|
@@ -23789,6 +24271,22 @@ async function tickOnce(deps) {
|
|
|
23789
24271
|
continue;
|
|
23790
24272
|
}
|
|
23791
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
|
+
}
|
|
23792
24290
|
if (stormActive && run2.resolves_run_id == null && run2.reviews_run_id == null) {
|
|
23793
24291
|
if (!alive) {
|
|
23794
24292
|
const priorFreezes = deps.db.events(run2.id).filter((e) => e.kind === "storm_dead").length;
|
|
@@ -23798,7 +24296,7 @@ async function tickOnce(deps) {
|
|
|
23798
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.`);
|
|
23799
24297
|
} else {
|
|
23800
24298
|
deps.db.updateRun(run2.id, { status: "storm_dead" });
|
|
23801
|
-
deps.db.addEvent(run2.id, "storm_dead",
|
|
24299
|
+
deps.db.addEvent(run2.id, "storm_dead", stormDeadText(stormProviderName(deps)));
|
|
23802
24300
|
}
|
|
23803
24301
|
}
|
|
23804
24302
|
continue;
|
|
@@ -24020,6 +24518,7 @@ async function tickOnce(deps) {
|
|
|
24020
24518
|
for (const run2 of deps.db.listRuns("paused")) {
|
|
24021
24519
|
if (run2.kind === "hero") continue;
|
|
24022
24520
|
if (run2.stop_reason === AWAITING_CI_REASON || isReliefPause(run2.stop_reason)) continue;
|
|
24521
|
+
if (isLimitWait(run2.stop_reason)) continue;
|
|
24023
24522
|
if (isAwaitingBudget(run2.status, run2.stop_reason)) continue;
|
|
24024
24523
|
const last = lastActivityMs(deps.db, run2);
|
|
24025
24524
|
if (now - last <= STALL_FLOOR_MS) continue;
|
|
@@ -24039,6 +24538,7 @@ async function tickOnce(deps) {
|
|
|
24039
24538
|
if (run2.kind === "hero") continue;
|
|
24040
24539
|
if (run2.reviews_run_id != null) continue;
|
|
24041
24540
|
if (isReliefPause(run2.stop_reason)) continue;
|
|
24541
|
+
if (isLimitWait(run2.stop_reason)) continue;
|
|
24042
24542
|
if (NO_AUTO_WAKE_REASONS.some((r) => run2.stop_reason?.startsWith(r))) continue;
|
|
24043
24543
|
if (run2.pid != null && deps.isAlive(run2.pid)) continue;
|
|
24044
24544
|
const capHolder = cycleCapHolder(deps.db, run2);
|
|
@@ -24109,6 +24609,7 @@ async function tickOnce(deps) {
|
|
|
24109
24609
|
...az.startedAt != null ? { daemonStartedAt: az.startedAt } : {}
|
|
24110
24610
|
}),
|
|
24111
24611
|
...buildEscalationCandidates(deps.db),
|
|
24612
|
+
...stormAnomalyCandidates(deps, now),
|
|
24112
24613
|
// ЦЕНА РАЗГРУЗКИ (TASWM-316): «машина не тянет» с числами и рекомендацией — та же
|
|
24113
24614
|
// труба, тот же дедуп «один раз на эпизод». Пустой список при нормальной работе.
|
|
24114
24615
|
...await buildReliefCostCandidatesFor(deps, now, droneCap)
|
|
@@ -24288,7 +24789,7 @@ async function resolveConflict(deps, reviewRun) {
|
|
|
24288
24789
|
model: reviewRun.model,
|
|
24289
24790
|
review_model: reviewRun.review_model
|
|
24290
24791
|
});
|
|
24291
|
-
const wt =
|
|
24792
|
+
const wt = join40(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
|
|
24292
24793
|
try {
|
|
24293
24794
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
24294
24795
|
await deps.git.setWorktreeIdentity(wt, resolver.name);
|
|
@@ -24369,7 +24870,7 @@ async function spawnReviewer(deps, reviewRun, files) {
|
|
|
24369
24870
|
// (своей у ревьюера нет, TASWM-204), и коммент с вердиктом должен уехать именно туда.
|
|
24370
24871
|
workspace_id: reviewRun.workspace_id
|
|
24371
24872
|
});
|
|
24372
|
-
const wt =
|
|
24873
|
+
const wt = join40(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
|
|
24373
24874
|
try {
|
|
24374
24875
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
24375
24876
|
await deps.git.setWorktreeIdentity(wt, reviewer.name);
|
|
@@ -24450,7 +24951,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
|
|
|
24450
24951
|
// штамп цикла: фикс-итерацию проверяет свежий верификатор
|
|
24451
24952
|
workspace_id: verifiedRun.workspace_id
|
|
24452
24953
|
});
|
|
24453
|
-
const wt =
|
|
24954
|
+
const wt = join40(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
|
|
24454
24955
|
try {
|
|
24455
24956
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
24456
24957
|
await deps.git.setWorktreeIdentity(wt, verifier.name);
|
|
@@ -24626,7 +25127,7 @@ async function loadSqlite() {
|
|
|
24626
25127
|
);
|
|
24627
25128
|
}
|
|
24628
25129
|
}
|
|
24629
|
-
async function makeStore(repo, worktreesDir, repoFlag) {
|
|
25130
|
+
async function makeStore(repo, worktreesDir, repoFlag, executorFor) {
|
|
24630
25131
|
const host = loadHostIdentity({
|
|
24631
25132
|
home: SWARM_HOME,
|
|
24632
25133
|
envHostId: process.env.SWARM_HOST_ID,
|
|
@@ -24649,7 +25150,7 @@ async function makeStore(repo, worktreesDir, repoFlag) {
|
|
|
24649
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`);
|
|
24650
25151
|
}
|
|
24651
25152
|
}
|
|
24652
|
-
const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW,
|
|
25153
|
+
const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW, homedir8(), repoPaths);
|
|
24653
25154
|
const repoMap = emptyRepoMapState(scanRootsList);
|
|
24654
25155
|
if (SWARM_BACKEND !== "client") {
|
|
24655
25156
|
const { SwarmDb: SwarmDb2 } = await loadSqlite();
|
|
@@ -24692,7 +25193,14 @@ async function makeStore(repo, worktreesDir, repoFlag) {
|
|
|
24692
25193
|
(repoMap.unknown ? "\u041F\u0440\u043E\u0434 \u043D\u0435 \u0441\u043A\u0430\u0437\u0430\u043B, \u043A\u0430\u043A\u0438\u0435 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u0443 \u0440\u043E\u044F, \u2014 \u043F\u0440\u043E\u0432\u0435\u0440\u044C `swarm login` \u0438 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u0441\u0442\u044C \u0441\u0435\u0440\u0432\u0435\u0440\u0430. " : repoMap.missing.length ? `\u041D\u0438 \u043E\u0434\u043D\u043E\u0433\u043E \u0438\u0437 ${repoMap.missing.length} \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0435\u0432 \u0440\u043E\u044F \u0442\u0443\u0442 \u043D\u0435\u0442. ` : "\u0423 \u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0430 \u043D\u0435\u0442 \u043F\u0440\u043E\u0435\u043A\u0442\u043E\u0432 \u0441 \u0432\u043A\u043B\u044E\u0447\u0451\u043D\u043D\u044B\u043C \u0440\u043E\u0435\u043C. ") + "\u0415\u0441\u043B\u0438 \u043A\u043B\u043E\u043D\u044B \u043B\u0435\u0436\u0430\u0442 \u0432 \u0434\u0440\u0443\u0433\u043E\u043C \u043C\u0435\u0441\u0442\u0435 \u2014 \u0443\u043A\u0430\u0436\u0438: swarm start --repo <\u043F\u0443\u0442\u044C \u043A \u0440\u0435\u043F\u043E> (\u0437\u0430\u043F\u043E\u043C\u043D\u0438\u0442\u0441\u044F)."
|
|
24693
25194
|
);
|
|
24694
25195
|
}
|
|
24695
|
-
const client = new SwarmClient({
|
|
25196
|
+
const client = new SwarmClient({
|
|
25197
|
+
call,
|
|
25198
|
+
outboxPath: SWARM_OUTBOX,
|
|
25199
|
+
defaultRepo: repo,
|
|
25200
|
+
repoRegistry,
|
|
25201
|
+
host,
|
|
25202
|
+
...executorFor ? { executorFor } : {}
|
|
25203
|
+
});
|
|
24696
25204
|
await client.hydrate();
|
|
24697
25205
|
const rec = client.reconcileRuntime({ worktreesDir, listProcesses: listDroneProcesses });
|
|
24698
25206
|
const adopted = await client.takeRunningLocally();
|
|
@@ -24747,7 +25255,7 @@ async function migrateWorktreesAtStartup() {
|
|
|
24747
25255
|
exists: (d) => existsSync23(d),
|
|
24748
25256
|
isNonEmptyDir: (d) => {
|
|
24749
25257
|
try {
|
|
24750
|
-
return
|
|
25258
|
+
return readdirSync18(d).length > 0;
|
|
24751
25259
|
} catch {
|
|
24752
25260
|
return false;
|
|
24753
25261
|
}
|
|
@@ -24774,6 +25282,10 @@ async function reportWorkspaceAccess(tl, db) {
|
|
|
24774
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);
|
|
24775
25283
|
}
|
|
24776
25284
|
}
|
|
25285
|
+
var modelLimitsPoller = null;
|
|
25286
|
+
function lastModelLimits() {
|
|
25287
|
+
return modelLimitsPoller?.report() ?? null;
|
|
25288
|
+
}
|
|
24777
25289
|
async function runDaemon(opts) {
|
|
24778
25290
|
installCrashGuards();
|
|
24779
25291
|
installLogStamps();
|
|
@@ -24793,6 +25305,8 @@ async function runDaemon(opts) {
|
|
|
24793
25305
|
const remembered = effectiveRepoPaths("", loadRememberedRepos(SWARM_HOME))[0];
|
|
24794
25306
|
if (remembered) opts.repo = remembered;
|
|
24795
25307
|
}
|
|
25308
|
+
let lastSwarmModels = null;
|
|
25309
|
+
const runModelRefPin = /* @__PURE__ */ new Map();
|
|
24796
25310
|
const {
|
|
24797
25311
|
store: db,
|
|
24798
25312
|
reconciled,
|
|
@@ -24802,7 +25316,12 @@ async function runDaemon(opts) {
|
|
|
24802
25316
|
prodMcp,
|
|
24803
25317
|
reposServed,
|
|
24804
25318
|
repoFullNameOf
|
|
24805
|
-
} = await makeStore(
|
|
25319
|
+
} = await makeStore(
|
|
25320
|
+
opts.repo,
|
|
25321
|
+
worktreesDir,
|
|
25322
|
+
opts.repoFlag,
|
|
25323
|
+
(run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null).id
|
|
25324
|
+
);
|
|
24806
25325
|
await preflightAuth();
|
|
24807
25326
|
const outdated = outdatedLine(PACKAGE_VERSION, await latestRelease);
|
|
24808
25327
|
if (outdated) console.warn(`[overmind] ${outdated}`);
|
|
@@ -24836,8 +25355,6 @@ async function runDaemon(opts) {
|
|
|
24836
25355
|
}
|
|
24837
25356
|
} : void 0;
|
|
24838
25357
|
let lastDroneCap = null;
|
|
24839
|
-
let lastSwarmModels = null;
|
|
24840
|
-
const runModelRefPin = /* @__PURE__ */ new Map();
|
|
24841
25358
|
let lastSwarmEfforts = null;
|
|
24842
25359
|
let lastMaxCostUsd = null;
|
|
24843
25360
|
let lastOwnCapacity = null;
|
|
@@ -24919,6 +25436,7 @@ async function runDaemon(opts) {
|
|
|
24919
25436
|
};
|
|
24920
25437
|
const tickIntervalMs = opts.intervalMs ?? 4e3;
|
|
24921
25438
|
const tickHealth = initialTickHealth(Date.now());
|
|
25439
|
+
modelLimitsPoller = createModelLimitsPoller({ installed: () => cachedInstalledExecutorIds() });
|
|
24922
25440
|
let heartbeat;
|
|
24923
25441
|
if (SWARM_BACKEND === "client" && db instanceof SwarmClient && SWARM_PROD_HEARTBEAT_MS > 0) {
|
|
24924
25442
|
const client = db;
|
|
@@ -24926,6 +25444,7 @@ async function runDaemon(opts) {
|
|
|
24926
25444
|
push: async () => {
|
|
24927
25445
|
const stormActive = client.stormActive();
|
|
24928
25446
|
const stormStartedAt = stormActive ? client.currentStormStartedAt() : null;
|
|
25447
|
+
modelLimitsPoller?.maybePoll();
|
|
24929
25448
|
const reply = await client.heartbeat(
|
|
24930
25449
|
daemonVersion?.get() ?? null,
|
|
24931
25450
|
control.state ?? null,
|
|
@@ -24950,7 +25469,8 @@ async function runDaemon(opts) {
|
|
|
24950
25469
|
tickPulse(tickHealth, Date.now(), tickIntervalMs),
|
|
24951
25470
|
// TASWM-592: установленные агенты машины — справочник для парка машин.
|
|
24952
25471
|
cachedInstalledExecutorIds(),
|
|
24953
|
-
availableProviders(cachedInstalledExecutorIds())
|
|
25472
|
+
availableProviders(cachedInstalledExecutorIds()),
|
|
25473
|
+
modelLimitsPoller?.report() ?? null
|
|
24954
25474
|
);
|
|
24955
25475
|
if (reply.maxDrones !== void 0) operatorMaxDrones = reply.maxDrones;
|
|
24956
25476
|
if (reply.commands.length) onHostCommands(reply.commands);
|
|
@@ -25404,6 +25924,13 @@ async function runDaemon(opts) {
|
|
|
25404
25924
|
exitOutcome: makeExitClassifier(RUN_LOGS_DIR, (runId) => db.runLogKeys(runId), (run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null)),
|
|
25405
25925
|
// TASWM-487: вид обрыва — из того же result-файла и теми же ключами каталога.
|
|
25406
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,
|
|
25407
25934
|
// TASWM-487: жива ли работа на origin. Тот же фолбэк repo, что у removeWorktree выше:
|
|
25408
25935
|
// у прогона в основном репозитории демона run.repo пуст.
|
|
25409
25936
|
branchOnOrigin: (repo, branch) => remoteBranchExists(repo || opts.repo, branch),
|
|
@@ -25608,6 +26135,7 @@ async function runDaemon(opts) {
|
|
|
25608
26135
|
startedAt: Date.now(),
|
|
25609
26136
|
// TASWM-592: run-aware — где лежит сессия, знает харнесс ПРОГОНА.
|
|
25610
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),
|
|
25611
26139
|
// CI-осведомлённость review-PR (TASWM-102): реальный `gh pr checks`/`gh run view --log-failed`
|
|
25612
26140
|
// (gh.ts) — решение (будить ли дрона) и гейты живут в tickOnce/handleCiRed. failureSummary
|
|
25613
26141
|
// строится над failing/failingRunIds ИЗ checks — без повторного `gh pr checks`.
|
|
@@ -25618,6 +26146,8 @@ async function runDaemon(opts) {
|
|
|
25618
26146
|
// Штормовой режим (TASWM-23): health-probe на отбой (реальный claude) + внешний
|
|
25619
26147
|
// сигнал SWARM_STORM_URL (2-й слой, если задан). Логика/пороги — в manageStorm/storm.ts.
|
|
25620
26148
|
storm: {
|
|
26149
|
+
providerName: () => executorLimitLabel(executorForRun({ kind: "drone" }, lastSwarmModels).id).short,
|
|
26150
|
+
hostName: host.hostName,
|
|
25621
26151
|
// TASWM-592: проба бьёт в исполнителя, на котором работают дроны (реестр провайдеров
|
|
25622
26152
|
// по ссылке модели роя), — иначе рой на другом харнессе штормовал бы по вине claude
|
|
25623
26153
|
// и наоборот.
|
|
@@ -26180,6 +26710,7 @@ export {
|
|
|
26180
26710
|
hasPreparingRuns,
|
|
26181
26711
|
isSubrun,
|
|
26182
26712
|
lastChangesSummary,
|
|
26713
|
+
lastModelLimits,
|
|
26183
26714
|
lastVerifySummary,
|
|
26184
26715
|
listDroneProcesses,
|
|
26185
26716
|
livePpids,
|