@taskless-app/swarm 0.6.83 → 0.6.85
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 +95 -14
- package/dist/overmind.js +723 -164
- 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();
|
|
@@ -3035,6 +3074,57 @@ function parseGrokResult(raw) {
|
|
|
3035
3074
|
if (aborted) result.aborted = aborted;
|
|
3036
3075
|
return result;
|
|
3037
3076
|
}
|
|
3077
|
+
function grokProbeOkFromOutput(out) {
|
|
3078
|
+
const rec = readGrokProbeRecord(out);
|
|
3079
|
+
if (!rec) return false;
|
|
3080
|
+
return typeof rec.text === "string" && rec.text.trim().length > 0 && (rec.stopReason === "max_turn_requests" || rec.stopReason === "end_turn");
|
|
3081
|
+
}
|
|
3082
|
+
function readGrokProbeRecord(out) {
|
|
3083
|
+
const line = out.split(/\r?\n/).find((item) => item.trimStart().startsWith("{"));
|
|
3084
|
+
if (line) {
|
|
3085
|
+
const parsed = parseJsonObject(line.trim());
|
|
3086
|
+
if (parsed) return parsed;
|
|
3087
|
+
}
|
|
3088
|
+
const whole = parseJsonObject(out.trim());
|
|
3089
|
+
if (whole) return whole;
|
|
3090
|
+
const sliced = extractJsonObject(out);
|
|
3091
|
+
return sliced ? parseJsonObject(sliced) : null;
|
|
3092
|
+
}
|
|
3093
|
+
function parseJsonObject(raw) {
|
|
3094
|
+
try {
|
|
3095
|
+
const parsed = JSON.parse(raw);
|
|
3096
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
3097
|
+
return parsed;
|
|
3098
|
+
} catch {
|
|
3099
|
+
return null;
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
function extractJsonObject(raw) {
|
|
3103
|
+
const start = raw.indexOf("{");
|
|
3104
|
+
if (start < 0) return null;
|
|
3105
|
+
let depth = 0;
|
|
3106
|
+
let inString = false;
|
|
3107
|
+
let escape = false;
|
|
3108
|
+
for (let i = start; i < raw.length; i++) {
|
|
3109
|
+
const ch = raw[i];
|
|
3110
|
+
if (inString) {
|
|
3111
|
+
if (escape) escape = false;
|
|
3112
|
+
else if (ch === "\\") escape = true;
|
|
3113
|
+
else if (ch === '"') inString = false;
|
|
3114
|
+
continue;
|
|
3115
|
+
}
|
|
3116
|
+
if (ch === '"') {
|
|
3117
|
+
inString = true;
|
|
3118
|
+
continue;
|
|
3119
|
+
}
|
|
3120
|
+
if (ch === "{") depth++;
|
|
3121
|
+
else if (ch === "}") {
|
|
3122
|
+
depth--;
|
|
3123
|
+
if (depth === 0) return raw.slice(start, i + 1);
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
return null;
|
|
3127
|
+
}
|
|
3038
3128
|
var grokExecutor;
|
|
3039
3129
|
var init_grok = __esm({
|
|
3040
3130
|
"src/executors/grok.ts"() {
|
|
@@ -3097,7 +3187,8 @@ ${notice}` : spec.prompt;
|
|
|
3097
3187
|
probe: {
|
|
3098
3188
|
args: ["-p", "ok", "--output-format", "json", "--yolo", "--max-turns", "1", "--no-auto-update"],
|
|
3099
3189
|
limitPattern: /usage limit/i,
|
|
3100
|
-
authPattern: /not logged in|unauthorized|\b401\b|authentication required|auth required/i
|
|
3190
|
+
authPattern: /not logged in|unauthorized|\b401\b|authentication required|auth required/i,
|
|
3191
|
+
okFromOutput: grokProbeOkFromOutput
|
|
3101
3192
|
}
|
|
3102
3193
|
};
|
|
3103
3194
|
}
|
|
@@ -3277,7 +3368,7 @@ var init_kimi = __esm({
|
|
|
3277
3368
|
},
|
|
3278
3369
|
probe: {
|
|
3279
3370
|
args: ["-p", "ok", "--output-format", "stream-json"],
|
|
3280
|
-
limitPattern: /usage limit|quota
|
|
3371
|
+
limitPattern: /usage limit|insufficient[_ ]quota/i,
|
|
3281
3372
|
authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
|
|
3282
3373
|
}
|
|
3283
3374
|
};
|
|
@@ -4102,14 +4193,25 @@ function plural(n, forms) {
|
|
|
4102
4193
|
const d = n % 10;
|
|
4103
4194
|
return forms[m >= 11 && m <= 14 ? 2 : d === 1 ? 0 : d >= 2 && d <= 4 ? 1 : 2];
|
|
4104
4195
|
}
|
|
4105
|
-
function
|
|
4196
|
+
function stormStartText(providerName) {
|
|
4197
|
+
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)`;
|
|
4198
|
+
}
|
|
4199
|
+
function stormDeadText(providerName) {
|
|
4200
|
+
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`;
|
|
4201
|
+
}
|
|
4202
|
+
function stormStartReason(s, cfg, providerName) {
|
|
4106
4203
|
const why = [];
|
|
4107
4204
|
if (s.deaths >= cfg.deathThreshold)
|
|
4108
4205
|
why.push(`${s.deaths} ${plural(s.deaths, ["\u0441\u043C\u0435\u0440\u0442\u044C", "\u0441\u043C\u0435\u0440\u0442\u0438", "\u0441\u043C\u0435\u0440\u0442\u0435\u0439"])} \u0434\u0440\u043E\u043D\u043E\u0432 \u0437\u0430 ${Math.round(cfg.windowMs / 6e4)} \u043C\u0438\u043D`);
|
|
4109
4206
|
if (s.spawnFails >= cfg.spawnFailThreshold)
|
|
4110
4207
|
why.push(`${s.spawnFails} ${plural(s.spawnFails, ["\u0441\u043F\u0430\u0432\u043D-\u0444\u0435\u0439\u043B", "\u0441\u043F\u0430\u0432\u043D-\u0444\u0435\u0439\u043B\u0430", "\u0441\u043F\u0430\u0432\u043D-\u0444\u0435\u0439\u043B\u043E\u0432"])} \u043F\u043E\u0434\u0440\u044F\u0434`);
|
|
4111
|
-
if (s.externalDown) why.push(
|
|
4112
|
-
return `${
|
|
4208
|
+
if (s.externalDown) why.push(`\u0432\u043D\u0435\u0448\u043D\u0438\u0439 \u0441\u0438\u0433\u043D\u0430\u043B: ${providerName} down`);
|
|
4209
|
+
return `${stormStartText(providerName)} \u2014 ${why.join("; ") || "\u044D\u0432\u0440\u0438\u0441\u0442\u0438\u043A\u0430"}`;
|
|
4210
|
+
}
|
|
4211
|
+
function stormLongText(input) {
|
|
4212
|
+
const minutes = Math.max(1, Math.round((input.now - input.startedAtMs) / 6e4));
|
|
4213
|
+
const since = new Date(input.startedAtMs).toISOString().slice(0, 16).replace("T", " ");
|
|
4214
|
+
return `${input.hostName} \u0441\u0442\u043E\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C\u0435 ${minutes} ${plural(minutes, ["\u043C\u0438\u043D\u0443\u0442\u0443", "\u043C\u0438\u043D\u0443\u0442\u044B", "\u043C\u0438\u043D\u0443\u0442"])} (\u0441 ${since} UTC): \u043F\u0440\u043E\u0431\u0430 ${input.providerName} \u043D\u0435 \u043F\u0440\u043E\u0445\u043E\u0434\u0438\u0442 (${input.reason}). \u041F\u0440\u043E\u0432\u0435\u0440\u044C \u043C\u043E\u0434\u0435\u043B\u044C \u0434\u0440\u043E\u043D\u043E\u0432 \u0432 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u0445 \u0440\u043E\u044F.`;
|
|
4113
4215
|
}
|
|
4114
4216
|
function trailingProbeSuccesses(recs) {
|
|
4115
4217
|
let n = 0;
|
|
@@ -4128,7 +4230,7 @@ function lastExternalDown(recs) {
|
|
|
4128
4230
|
function stormShouldEnd(s, cfg) {
|
|
4129
4231
|
return s.consecutiveProbeOk >= cfg.probeSuccessesToClear && !s.externalDown;
|
|
4130
4232
|
}
|
|
4131
|
-
var numEnv, DEFAULT_STORM_CONFIG,
|
|
4233
|
+
var numEnv, DEFAULT_STORM_CONFIG, STORM_END_TEXT, STORM_HEALTHY_DEATHS_TEXT, STORM_RESUME_CONTINUE_TEXT, STORM_RESUME_FRESH_TEXT;
|
|
4132
4234
|
var init_storm = __esm({
|
|
4133
4235
|
"src/storm.ts"() {
|
|
4134
4236
|
"use strict";
|
|
@@ -4144,12 +4246,11 @@ var init_storm = __esm({
|
|
|
4144
4246
|
probeIntervalMs: numEnv("SWARM_STORM_PROBE_INTERVAL_MS", 60 * 1e3),
|
|
4145
4247
|
probeSuccessesToClear: numEnv("SWARM_STORM_PROBE_CLEAR", 2),
|
|
4146
4248
|
probeTimeoutMs: numEnv("SWARM_STORM_PROBE_TIMEOUT_MS", 20 * 1e3),
|
|
4147
|
-
restartCooldownMs: numEnv("SWARM_STORM_RESTART_COOLDOWN_MS", 3 * 60 * 1e3)
|
|
4249
|
+
restartCooldownMs: numEnv("SWARM_STORM_RESTART_COOLDOWN_MS", 3 * 60 * 1e3),
|
|
4250
|
+
notifyMs: numEnv("SWARM_STORM_NOTIFY_MS", 30 * 60 * 1e3)
|
|
4148
4251
|
};
|
|
4149
|
-
STORM_START_TEXT = "\u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442)";
|
|
4150
4252
|
STORM_END_TEXT = "\u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u2014 \u0420\u043E\u0439 \u043F\u0440\u043E\u0431\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044F";
|
|
4151
4253
|
STORM_HEALTHY_DEATHS_TEXT = "\u0434\u0440\u043E\u043D\u044B \u043C\u0440\u0443\u0442 \u043F\u0440\u0438 \u0436\u0438\u0432\u043E\u043C API (health-probe \u0437\u0435\u043B\u0451\u043D\u0430\u044F) \u2014 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u0430\u044F \u043F\u0440\u043E\u0431\u043B\u0435\u043C\u0430, \u0441\u043C\u043E\u0442\u0440\u0438 \u043B\u043E\u0433\u0438 \u0440\u043E\u044F; \u0432 \u0448\u0442\u043E\u0440\u043C \u043D\u0435 \u0443\u0445\u043E\u0436\u0443";
|
|
4152
|
-
STORM_DEAD_TEXT = "\u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (Anthropic \u0448\u0442\u043E\u0440\u043C\u0438\u0442) \u2014 \u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435, worktree \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D, \u043F\u043E\u0434\u044A\u0451\u043C \u043F\u043E\u0441\u043B\u0435 \u043E\u0442\u0431\u043E\u044F";
|
|
4153
4254
|
STORM_RESUME_CONTINUE_TEXT = "\u0434\u0440\u043E\u043D \u0432\u044B\u0448\u0435\u043B \u0438\u0437 \u043A\u043E\u043A\u043E\u043D\u0430 \u2014 \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0435\u0442 \u0441 \u043C\u0435\u0441\u0442\u0430 \u043E\u0431\u0440\u044B\u0432\u0430 (--continue)";
|
|
4154
4255
|
STORM_RESUME_FRESH_TEXT = "\u0434\u0440\u043E\u043D \u0432\u044B\u0448\u0435\u043B \u0438\u0437 \u043A\u043E\u043A\u043E\u043D\u0430 \u2014 \u0441\u0442\u0430\u0440\u0442 \u0437\u0430\u043D\u043E\u0432\u043E (\u0441\u0435\u0441\u0441\u0438\u044F/worktree \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B, \u0440\u0430\u0431\u043E\u0442\u0430 \u0432 origin)";
|
|
4155
4256
|
}
|
|
@@ -4955,9 +5056,9 @@ var init_procCleanup = __esm({
|
|
|
4955
5056
|
});
|
|
4956
5057
|
|
|
4957
5058
|
// src/git.ts
|
|
4958
|
-
import { existsSync as existsSync14, readdirSync as
|
|
5059
|
+
import { existsSync as existsSync14, readdirSync as readdirSync16, realpathSync as realpathSync2, statSync as statSync13 } from "fs";
|
|
4959
5060
|
import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
|
|
4960
|
-
import { isAbsolute as isAbsolute3, join as
|
|
5061
|
+
import { isAbsolute as isAbsolute3, join as join25, resolve as resolve3, sep as sep2 } from "path";
|
|
4961
5062
|
import { $ as $2 } from "execa";
|
|
4962
5063
|
function gitNet(repo, args, timeoutMs) {
|
|
4963
5064
|
return withHardTimeout(
|
|
@@ -4981,12 +5082,12 @@ async function reclaimStaleWorktree(repo, worktree) {
|
|
|
4981
5082
|
async function inspectWorktreePath(path) {
|
|
4982
5083
|
if (!existsSync14(path)) return "free";
|
|
4983
5084
|
try {
|
|
4984
|
-
if (
|
|
5085
|
+
if (readdirSync16(path).length === 0) return "free";
|
|
4985
5086
|
} catch {
|
|
4986
5087
|
return "orphan";
|
|
4987
5088
|
}
|
|
4988
5089
|
try {
|
|
4989
|
-
if (
|
|
5090
|
+
if (statSync13(join25(path, ".git")).isDirectory()) return "main-checkout";
|
|
4990
5091
|
} catch {
|
|
4991
5092
|
}
|
|
4992
5093
|
const top = await $2({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
|
|
@@ -5046,7 +5147,7 @@ async function parkOrphanDir(repo, path, branch) {
|
|
|
5046
5147
|
}
|
|
5047
5148
|
function isLinkedWorktree(dir) {
|
|
5048
5149
|
try {
|
|
5049
|
-
return
|
|
5150
|
+
return statSync13(join25(dir, ".git")).isFile();
|
|
5050
5151
|
} catch {
|
|
5051
5152
|
return false;
|
|
5052
5153
|
}
|
|
@@ -5158,8 +5259,8 @@ async function ensureGitExcluded(worktree, pattern) {
|
|
|
5158
5259
|
try {
|
|
5159
5260
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
5160
5261
|
if (!commonDir) return false;
|
|
5161
|
-
const infoDir =
|
|
5162
|
-
const excludeFile =
|
|
5262
|
+
const infoDir = join25(commonDir, "info");
|
|
5263
|
+
const excludeFile = join25(infoDir, "exclude");
|
|
5163
5264
|
let current = "";
|
|
5164
5265
|
try {
|
|
5165
5266
|
current = await readFile(excludeFile, "utf8");
|
|
@@ -5179,7 +5280,7 @@ async function gitPath(worktree, flag) {
|
|
|
5179
5280
|
const out = await $2({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
|
|
5180
5281
|
const raw = out.stdout.trim();
|
|
5181
5282
|
if (out.exitCode !== 0 || !raw) return null;
|
|
5182
|
-
return isAbsolute3(raw) ? raw :
|
|
5283
|
+
return isAbsolute3(raw) ? raw : join25(worktree, raw);
|
|
5183
5284
|
}
|
|
5184
5285
|
async function ensureWorktreeHygiene(worktree) {
|
|
5185
5286
|
for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
|
|
@@ -5189,12 +5290,12 @@ async function installGuardHooks(worktree) {
|
|
|
5189
5290
|
try {
|
|
5190
5291
|
const gitDir = await gitPath(worktree, "--git-dir");
|
|
5191
5292
|
if (!gitDir) return false;
|
|
5192
|
-
const hooksDir =
|
|
5293
|
+
const hooksDir = join25(gitDir, "swarm-hooks");
|
|
5193
5294
|
const prev = await previousHooksPath(worktree);
|
|
5194
5295
|
await mkdir(hooksDir, { recursive: true });
|
|
5195
5296
|
for (const hook of GUARD_HOOKS) {
|
|
5196
|
-
await writeFile(
|
|
5197
|
-
await chmod(
|
|
5297
|
+
await writeFile(join25(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
|
|
5298
|
+
await chmod(join25(hooksDir, hook), 493);
|
|
5198
5299
|
}
|
|
5199
5300
|
await $2`git -C ${worktree} config extensions.worktreeConfig true`;
|
|
5200
5301
|
await $2`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
|
|
@@ -5213,7 +5314,7 @@ async function previousHooksPath(worktree) {
|
|
|
5213
5314
|
if (out.exitCode === 0 && value) return value;
|
|
5214
5315
|
}
|
|
5215
5316
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
5216
|
-
return commonDir ?
|
|
5317
|
+
return commonDir ? join25(commonDir, "hooks") : null;
|
|
5217
5318
|
}
|
|
5218
5319
|
async function removeWorktree(repo, path) {
|
|
5219
5320
|
const branch = (await $2({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
|
|
@@ -5238,7 +5339,7 @@ async function worktreeDirty(path) {
|
|
|
5238
5339
|
async function repairMovedWorktrees(targetDir) {
|
|
5239
5340
|
const subdirs = (dir) => {
|
|
5240
5341
|
try {
|
|
5241
|
-
return
|
|
5342
|
+
return readdirSync16(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join25(dir, d.name));
|
|
5242
5343
|
} catch {
|
|
5243
5344
|
return [];
|
|
5244
5345
|
}
|
|
@@ -5375,12 +5476,12 @@ __export(droneChannel_exports, {
|
|
|
5375
5476
|
verifyLocalCliToken: () => verifyLocalCliToken
|
|
5376
5477
|
});
|
|
5377
5478
|
import { createHmac, randomBytes, timingSafeEqual } from "crypto";
|
|
5378
|
-
import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as
|
|
5479
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "fs";
|
|
5379
5480
|
import { dirname as dirname5 } from "path";
|
|
5380
5481
|
import { serve } from "@hono/node-server";
|
|
5381
5482
|
function loadChannelSecret(path) {
|
|
5382
5483
|
try {
|
|
5383
|
-
const s =
|
|
5484
|
+
const s = readFileSync22(path, "utf8").trim();
|
|
5384
5485
|
if (s.length >= 32) return s;
|
|
5385
5486
|
} catch {
|
|
5386
5487
|
}
|
|
@@ -5776,7 +5877,7 @@ var init_droneChannel = __esm({
|
|
|
5776
5877
|
|
|
5777
5878
|
// src/attachments.ts
|
|
5778
5879
|
import { mkdir as mkdir3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
5779
|
-
import { join as
|
|
5880
|
+
import { join as join30 } from "path";
|
|
5780
5881
|
function attachmentsFromDoc(doc, origin) {
|
|
5781
5882
|
const out = [];
|
|
5782
5883
|
const walk2 = (node) => {
|
|
@@ -5867,7 +5968,7 @@ async function materializeAttachments(opts) {
|
|
|
5867
5968
|
};
|
|
5868
5969
|
const result = { files: [], skipped: [] };
|
|
5869
5970
|
if (opts.refs.length === 0) return result;
|
|
5870
|
-
const dir =
|
|
5971
|
+
const dir = join30(opts.worktree, ATTACHMENTS_DIR);
|
|
5871
5972
|
await io.removeDir(dir);
|
|
5872
5973
|
let dirReady = false;
|
|
5873
5974
|
let total = 0;
|
|
@@ -5913,7 +6014,7 @@ async function materializeAttachments(opts) {
|
|
|
5913
6014
|
await io.mkdir(dir);
|
|
5914
6015
|
dirReady = true;
|
|
5915
6016
|
}
|
|
5916
|
-
await io.writeFile(
|
|
6017
|
+
await io.writeFile(join30(dir, name), file.bytes);
|
|
5917
6018
|
} catch (e) {
|
|
5918
6019
|
result.skipped.push(`${label2} \u2014 \u043D\u0435 \u0437\u0430\u043F\u0438\u0441\u0430\u043B\u043E\u0441\u044C \u043D\u0430 \u0434\u0438\u0441\u043A (${errText2(e)})`);
|
|
5919
6020
|
continue;
|
|
@@ -6066,7 +6167,7 @@ var init_attachments = __esm({
|
|
|
6066
6167
|
|
|
6067
6168
|
// src/shotUpload.ts
|
|
6068
6169
|
import { readFile as fsReadFile } from "fs/promises";
|
|
6069
|
-
import { basename as basename4, isAbsolute as isAbsolute4, join as
|
|
6170
|
+
import { basename as basename4, isAbsolute as isAbsolute4, join as join31 } from "path";
|
|
6070
6171
|
function shotMimetype(path) {
|
|
6071
6172
|
const dot = path.lastIndexOf(".");
|
|
6072
6173
|
if (dot < 0) return null;
|
|
@@ -6092,7 +6193,7 @@ async function readShots(paths, opts) {
|
|
|
6092
6193
|
}
|
|
6093
6194
|
let bytes;
|
|
6094
6195
|
try {
|
|
6095
|
-
bytes = await read(isAbsolute4(path) ? path :
|
|
6196
|
+
bytes = await read(isAbsolute4(path) ? path : join31(opts.worktree, path));
|
|
6096
6197
|
} catch (e) {
|
|
6097
6198
|
skipped.push({ path, reason: `\u043D\u0435 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D: ${e instanceof Error ? e.message : String(e)}` });
|
|
6098
6199
|
continue;
|
|
@@ -6172,12 +6273,12 @@ var init_shotUpload = __esm({
|
|
|
6172
6273
|
});
|
|
6173
6274
|
|
|
6174
6275
|
// src/oauth.ts
|
|
6175
|
-
import { createHash as
|
|
6176
|
-
import { readFileSync as
|
|
6177
|
-
import { join as
|
|
6276
|
+
import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
|
|
6277
|
+
import { readFileSync as readFileSync23, writeFileSync as writeFileSync15, unlinkSync as unlinkSync4 } from "fs";
|
|
6278
|
+
import { join as join32 } from "path";
|
|
6178
6279
|
function makePkce() {
|
|
6179
6280
|
const verifier = randomBytes2(48).toString("base64url");
|
|
6180
|
-
const challenge =
|
|
6281
|
+
const challenge = createHash4("sha256").update(verifier).digest("base64url");
|
|
6181
6282
|
return { verifier, challenge };
|
|
6182
6283
|
}
|
|
6183
6284
|
async function registerClient(args, fetchFn = fetch) {
|
|
@@ -6258,7 +6359,7 @@ function toStore(clientId, t, now) {
|
|
|
6258
6359
|
}
|
|
6259
6360
|
function loadStore() {
|
|
6260
6361
|
try {
|
|
6261
|
-
return JSON.parse(
|
|
6362
|
+
return JSON.parse(readFileSync23(STORE_PATH2, "utf8"));
|
|
6262
6363
|
} catch {
|
|
6263
6364
|
return null;
|
|
6264
6365
|
}
|
|
@@ -6274,7 +6375,7 @@ function clearStore() {
|
|
|
6274
6375
|
}
|
|
6275
6376
|
function loadClientId() {
|
|
6276
6377
|
try {
|
|
6277
|
-
return JSON.parse(
|
|
6378
|
+
return JSON.parse(readFileSync23(CLIENT_PATH, "utf8")).clientId;
|
|
6278
6379
|
} catch {
|
|
6279
6380
|
return null;
|
|
6280
6381
|
}
|
|
@@ -6309,8 +6410,8 @@ var init_oauth = __esm({
|
|
|
6309
6410
|
AUTHORIZE = "/api/oauth/authorize";
|
|
6310
6411
|
TOKEN = "/api/oauth/token";
|
|
6311
6412
|
SCOPE = "openid profile email taskless:full";
|
|
6312
|
-
STORE_PATH2 =
|
|
6313
|
-
CLIENT_PATH =
|
|
6413
|
+
STORE_PATH2 = join32(SWARM_HOME, "oauth.json");
|
|
6414
|
+
CLIENT_PATH = join32(SWARM_HOME, "oauth-client.json");
|
|
6314
6415
|
base2 = (api) => api.replace(/\/$/, "");
|
|
6315
6416
|
}
|
|
6316
6417
|
});
|
|
@@ -6397,11 +6498,11 @@ var init_authState = __esm({
|
|
|
6397
6498
|
});
|
|
6398
6499
|
|
|
6399
6500
|
// src/workspace.ts
|
|
6400
|
-
import { readFileSync as
|
|
6401
|
-
import { join as
|
|
6501
|
+
import { readFileSync as readFileSync24, writeFileSync as writeFileSync16, unlinkSync as unlinkSync5 } from "fs";
|
|
6502
|
+
import { join as join33 } from "path";
|
|
6402
6503
|
function loadWorkspace() {
|
|
6403
6504
|
try {
|
|
6404
|
-
const w = JSON.parse(
|
|
6505
|
+
const w = JSON.parse(readFileSync24(WORKSPACE_PATH, "utf8"));
|
|
6405
6506
|
return w && typeof w.id === "string" && w.id ? w : null;
|
|
6406
6507
|
} catch {
|
|
6407
6508
|
return null;
|
|
@@ -6415,7 +6516,7 @@ var init_workspace = __esm({
|
|
|
6415
6516
|
"src/workspace.ts"() {
|
|
6416
6517
|
"use strict";
|
|
6417
6518
|
init_config();
|
|
6418
|
-
WORKSPACE_PATH =
|
|
6519
|
+
WORKSPACE_PATH = join33(SWARM_HOME, "workspace.json");
|
|
6419
6520
|
}
|
|
6420
6521
|
});
|
|
6421
6522
|
|
|
@@ -8088,9 +8189,9 @@ var init_droneStore = __esm({
|
|
|
8088
8189
|
});
|
|
8089
8190
|
|
|
8090
8191
|
// src/overmind.ts
|
|
8091
|
-
import { homedir as
|
|
8092
|
-
import { existsSync as existsSync23, readFileSync as
|
|
8093
|
-
import { basename as basename6, dirname as dirname6, join as
|
|
8192
|
+
import { homedir as homedir8 } from "os";
|
|
8193
|
+
import { existsSync as existsSync23, readFileSync as readFileSync28, readdirSync as readdirSync18, renameSync as renameSync12, statSync as statSync16 } from "fs";
|
|
8194
|
+
import { basename as basename6, dirname as dirname6, join as join40 } from "path";
|
|
8094
8195
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
8095
8196
|
import { spawn as spawn4 } from "child_process";
|
|
8096
8197
|
|
|
@@ -8568,6 +8669,8 @@ var SwarmClient = class _SwarmClient {
|
|
|
8568
8669
|
// TAS-956: момент отказа taskSlug по тулу. Окно и детектор — slugRetry.
|
|
8569
8670
|
// Свой экземпляр: отказ этого клиента не общий с makeTasklessClient.
|
|
8570
8671
|
slugRetry;
|
|
8672
|
+
// TASWM-643: старый прод может не знать modelLimits; окно повторной пробы отдельное от taskSlug.
|
|
8673
|
+
modelLimitsRetry;
|
|
8571
8674
|
// Корреляция с продом.
|
|
8572
8675
|
keyByLocal = /* @__PURE__ */ new Map();
|
|
8573
8676
|
// local run id → runKey
|
|
@@ -8612,6 +8715,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
8612
8715
|
constructor(opts) {
|
|
8613
8716
|
this.now = opts.now ?? Date.now;
|
|
8614
8717
|
this.slugRetry = new SlugUnsupportedAt(this.now);
|
|
8718
|
+
this.modelLimitsRetry = new SlugUnsupportedAt(this.now);
|
|
8615
8719
|
this.call = opts.call;
|
|
8616
8720
|
this.defaultRepo = normalizeRepo(opts.defaultRepo ?? "");
|
|
8617
8721
|
this.autoFlush = opts.autoFlush ?? true;
|
|
@@ -10307,7 +10411,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
10307
10411
|
*
|
|
10308
10412
|
* Прод недоступен / ответ без поручений → пустые списки (демон работает дальше).
|
|
10309
10413
|
*/
|
|
10310
|
-
async heartbeat(daemonVersion, pause, capacity, resources, storm, worktreesDir, signIn, tick, executors, providers) {
|
|
10414
|
+
async heartbeat(daemonVersion, pause, capacity, resources, storm, worktreesDir, signIn, tick, executors, providers, modelLimits) {
|
|
10311
10415
|
try {
|
|
10312
10416
|
const args = this.repoFullNames.length ? { repoFullNames: this.repoFullNames } : {};
|
|
10313
10417
|
if (daemonVersion) args.daemonVersion = daemonVersion;
|
|
@@ -10339,7 +10443,14 @@ var SwarmClient = class _SwarmClient {
|
|
|
10339
10443
|
}
|
|
10340
10444
|
if (executors) args.executorsAvailable = executors;
|
|
10341
10445
|
if (providers) args.providersAvailable = providers;
|
|
10342
|
-
|
|
10446
|
+
if (modelLimits && !this.modelLimitsRetry.within("modelLimits")) args.modelLimits = modelLimits;
|
|
10447
|
+
let res = await this.call("swarm_heartbeat", args);
|
|
10448
|
+
if (res?.isError && args.modelLimits !== void 0 && unknownArg(toolErrorText(res), "modelLimits")) {
|
|
10449
|
+
this.modelLimitsRetry.note("modelLimits");
|
|
10450
|
+
const retryArgs = { ...args };
|
|
10451
|
+
delete retryArgs.modelLimits;
|
|
10452
|
+
res = await this.call("swarm_heartbeat", retryArgs);
|
|
10453
|
+
}
|
|
10343
10454
|
if (res?.isError) return EMPTY_HEARTBEAT_REPLY;
|
|
10344
10455
|
this.heartbeatOkAt = this.now();
|
|
10345
10456
|
const data = res?.structuredContent ?? {};
|
|
@@ -12058,7 +12169,7 @@ function envCapUsd(env) {
|
|
|
12058
12169
|
return Number.isFinite(n) && n >= 0 ? n : DEFAULT_RUN_LIMITS.maxCostUsd;
|
|
12059
12170
|
}
|
|
12060
12171
|
function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
|
|
12061
|
-
const env = { ...base3 };
|
|
12172
|
+
const env = { ...base3, TASKLESS_SWARM_DRONE: "1" };
|
|
12062
12173
|
const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
|
|
12063
12174
|
if (isolate && !base3.TURBO_CACHE_DIR) {
|
|
12064
12175
|
env.TURBO_CACHE_DIR = join19(worktree, ".turbo", "cache");
|
|
@@ -12460,6 +12571,154 @@ function makeAbortReader(runLogsDir, runLogKeys, executorFor = () => resolveExec
|
|
|
12460
12571
|
return (run2) => abortOfExit(runLogsDir, runLogKeys(run2.id), executorFor(run2));
|
|
12461
12572
|
}
|
|
12462
12573
|
|
|
12574
|
+
// src/limitWait.ts
|
|
12575
|
+
init_src();
|
|
12576
|
+
import { closeSync as closeSync5, fstatSync as fstatSync2, openSync as openSync5, readdirSync as readdirSync14, readSync as readSync2 } from "fs";
|
|
12577
|
+
import { join as join22 } from "path";
|
|
12578
|
+
var TAIL_BYTES = 8 * 1024;
|
|
12579
|
+
var SNAPSHOT_FRESH_MS = 15 * 6e4;
|
|
12580
|
+
var RESULT_FILE_RE2 = /^(\d+)\.json(\.done)?$/;
|
|
12581
|
+
var STDERR_FILE_RE = /^(\d+)\.err\.log$/;
|
|
12582
|
+
var RESET_RE = /resets[^\n]*/i;
|
|
12583
|
+
function readTail2(path, dropPartialFirstLine = false) {
|
|
12584
|
+
let fd;
|
|
12585
|
+
try {
|
|
12586
|
+
fd = openSync5(path, "r");
|
|
12587
|
+
} catch {
|
|
12588
|
+
return null;
|
|
12589
|
+
}
|
|
12590
|
+
try {
|
|
12591
|
+
const size = fstatSync2(fd).size;
|
|
12592
|
+
const length = Math.min(size, TAIL_BYTES);
|
|
12593
|
+
const buffer = Buffer.alloc(length);
|
|
12594
|
+
readSync2(fd, buffer, 0, length, Math.max(0, size - length));
|
|
12595
|
+
const text = buffer.toString("utf8");
|
|
12596
|
+
return dropPartialFirstLine && size > TAIL_BYTES ? text.replace(/^[^\n]*(?:\n|$)/, "") : text;
|
|
12597
|
+
} catch {
|
|
12598
|
+
return null;
|
|
12599
|
+
} finally {
|
|
12600
|
+
closeSync5(fd);
|
|
12601
|
+
}
|
|
12602
|
+
}
|
|
12603
|
+
function latestLaunch(logsDir, keys) {
|
|
12604
|
+
const dir = findRunLogDir(logsDir, keys);
|
|
12605
|
+
if (!dir) return null;
|
|
12606
|
+
let latest = null;
|
|
12607
|
+
let files;
|
|
12608
|
+
try {
|
|
12609
|
+
files = readdirSync14(dir);
|
|
12610
|
+
} catch {
|
|
12611
|
+
return null;
|
|
12612
|
+
}
|
|
12613
|
+
for (const name of files) {
|
|
12614
|
+
const result = RESULT_FILE_RE2.exec(name);
|
|
12615
|
+
const stderr = STDERR_FILE_RE.exec(name);
|
|
12616
|
+
if (!result && !stderr) continue;
|
|
12617
|
+
const index = Number((result ?? stderr)[1]);
|
|
12618
|
+
if (!latest || index > latest.index) latest = { index, stdoutName: result ? name : null };
|
|
12619
|
+
else if (index === latest.index && result) latest.stdoutName = name;
|
|
12620
|
+
}
|
|
12621
|
+
return latest ? { dir, ...latest } : null;
|
|
12622
|
+
}
|
|
12623
|
+
function matchesLimit(pattern, text) {
|
|
12624
|
+
pattern.lastIndex = 0;
|
|
12625
|
+
return pattern.test(text);
|
|
12626
|
+
}
|
|
12627
|
+
function nonJsonLines(raw) {
|
|
12628
|
+
const lines = raw.split(/\r?\n/);
|
|
12629
|
+
if (!/\r?\n$/.test(raw)) lines.pop();
|
|
12630
|
+
return lines.filter((line) => {
|
|
12631
|
+
const trimmed = line.trim();
|
|
12632
|
+
if (!trimmed) return false;
|
|
12633
|
+
try {
|
|
12634
|
+
const parsed = JSON.parse(trimmed);
|
|
12635
|
+
return parsed === null || typeof parsed !== "object" || Array.isArray(parsed);
|
|
12636
|
+
} catch {
|
|
12637
|
+
return true;
|
|
12638
|
+
}
|
|
12639
|
+
}).join("\n");
|
|
12640
|
+
}
|
|
12641
|
+
function exhaustedWindows(report, executor) {
|
|
12642
|
+
const model = report?.models.find((item) => item.executor === executor);
|
|
12643
|
+
return model?.windows.filter((window) => limitWindowState(window) === "out") ?? [];
|
|
12644
|
+
}
|
|
12645
|
+
function latestExhaustedWindow(report, executor) {
|
|
12646
|
+
const windows = exhaustedWindows(report, executor);
|
|
12647
|
+
let latest = null;
|
|
12648
|
+
for (const window of windows) {
|
|
12649
|
+
const resetMs = window.resetsAt ? Date.parse(window.resetsAt) : Number.NaN;
|
|
12650
|
+
if (!Number.isFinite(resetMs)) continue;
|
|
12651
|
+
if (!latest || resetMs > latest.resetMs) latest = { window, resetMs };
|
|
12652
|
+
}
|
|
12653
|
+
return latest?.window ?? windows[0] ?? null;
|
|
12654
|
+
}
|
|
12655
|
+
function resetFromHint(resetHint, nowMs) {
|
|
12656
|
+
const relative2 = /resets\s+in\s+(?:(\d+)\s*h)?\s*(?:(\d+)\s*m)?/i.exec(resetHint);
|
|
12657
|
+
if (relative2 && (relative2[1] || relative2[2])) {
|
|
12658
|
+
return nowMs + (Number(relative2[1] ?? 0) * 60 + Number(relative2[2] ?? 0)) * 6e4;
|
|
12659
|
+
}
|
|
12660
|
+
const clock = /resets(?:\s+at)?\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/i.exec(resetHint);
|
|
12661
|
+
if (!clock) return null;
|
|
12662
|
+
let hour = Number(clock[1]);
|
|
12663
|
+
const minute = Number(clock[2] ?? 0);
|
|
12664
|
+
const meridiem = clock[3]?.toLowerCase();
|
|
12665
|
+
if (minute >= 60 || (meridiem ? hour < 1 || hour > 12 : hour >= 24)) return null;
|
|
12666
|
+
if (meridiem === "pm" && hour !== 12) hour += 12;
|
|
12667
|
+
if (meridiem === "am" && hour === 12) hour = 0;
|
|
12668
|
+
const reset = new Date(nowMs);
|
|
12669
|
+
reset.setHours(hour, minute, 0, 0);
|
|
12670
|
+
if (reset.getTime() <= nowMs) reset.setDate(reset.getDate() + 1);
|
|
12671
|
+
return reset.getTime();
|
|
12672
|
+
}
|
|
12673
|
+
function makeLimitReader(logsDir, logKeys, executorOf, snapshot = () => null) {
|
|
12674
|
+
return (run2) => {
|
|
12675
|
+
const executor = executorOf(run2);
|
|
12676
|
+
const launch = latestLaunch(logsDir, logKeys(run2.id));
|
|
12677
|
+
if (!launch) return null;
|
|
12678
|
+
const stderr = readTail2(join22(launch.dir, `${launch.index}.err.log`)) ?? "";
|
|
12679
|
+
const stdout = launch.stdoutName ? readTail2(join22(launch.dir, launch.stdoutName), true) ?? "" : "";
|
|
12680
|
+
const stdoutText = nonJsonLines(stdout);
|
|
12681
|
+
const limitText = matchesLimit(executor.probe.limitPattern, stderr) ? stderr : matchesLimit(executor.probe.limitPattern, stdoutText) ? stdoutText : null;
|
|
12682
|
+
if (limitText !== null) {
|
|
12683
|
+
return { executor: executor.id, resetHint: limitText.match(RESET_RE)?.[0]?.trim() ?? null };
|
|
12684
|
+
}
|
|
12685
|
+
if (executor.id === "kimi") {
|
|
12686
|
+
const report = snapshot();
|
|
12687
|
+
const model = report?.models.find((item) => item.executor === "kimi");
|
|
12688
|
+
const fetchedMs = model?.fetchedAt ? Date.parse(model.fetchedAt) : Number.NaN;
|
|
12689
|
+
if (Number.isFinite(fetchedMs) && Date.now() - fetchedMs <= SNAPSHOT_FRESH_MS && exhaustedWindows(report, "kimi").length > 0) {
|
|
12690
|
+
return { executor: "kimi", resetHint: null };
|
|
12691
|
+
}
|
|
12692
|
+
if (stderr.trim()) {
|
|
12693
|
+
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, " ")}`);
|
|
12694
|
+
}
|
|
12695
|
+
}
|
|
12696
|
+
return null;
|
|
12697
|
+
};
|
|
12698
|
+
}
|
|
12699
|
+
function limitResetAt(input) {
|
|
12700
|
+
const model = input.report?.models.find((item) => item.executor === input.executor);
|
|
12701
|
+
const fetchedMs = model?.fetchedAt ? Date.parse(model.fetchedAt) : Number.NaN;
|
|
12702
|
+
const fresh = Number.isFinite(fetchedMs) && input.nowMs - fetchedMs <= SNAPSHOT_FRESH_MS;
|
|
12703
|
+
const latest = fresh ? latestExhaustedWindow(input.report, input.executor) : null;
|
|
12704
|
+
const reportResetMs = latest?.resetsAt ? Date.parse(latest.resetsAt) : Number.NaN;
|
|
12705
|
+
if (Number.isFinite(reportResetMs) && reportResetMs > input.nowMs) return new Date(reportResetMs).toISOString();
|
|
12706
|
+
const hintResetMs = input.resetHint ? resetFromHint(input.resetHint, input.nowMs) : null;
|
|
12707
|
+
return new Date(hintResetMs !== null && hintResetMs > input.nowMs ? hintResetMs : input.nowMs + 30 * 6e4).toISOString();
|
|
12708
|
+
}
|
|
12709
|
+
function limitWaitWindow(report, executor) {
|
|
12710
|
+
return latestExhaustedWindow(report, executor)?.window ?? null;
|
|
12711
|
+
}
|
|
12712
|
+
function limitWaitText(executor, window) {
|
|
12713
|
+
const label2 = executorLimitLabel(executor).short;
|
|
12714
|
+
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" : "";
|
|
12715
|
+
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`;
|
|
12716
|
+
}
|
|
12717
|
+
function isLimitWaitDue(stopReason, nowMs) {
|
|
12718
|
+
const wait = parseLimitWait(stopReason);
|
|
12719
|
+
return wait !== null && Date.parse(wait.resetsAt) <= nowMs;
|
|
12720
|
+
}
|
|
12721
|
+
|
|
12463
12722
|
// src/overmind.ts
|
|
12464
12723
|
init_executors();
|
|
12465
12724
|
init_claudeCode();
|
|
@@ -12471,7 +12730,7 @@ init_src();
|
|
|
12471
12730
|
init_swarmModels();
|
|
12472
12731
|
init_executors();
|
|
12473
12732
|
import { accessSync, constants } from "fs";
|
|
12474
|
-
import { delimiter, join as
|
|
12733
|
+
import { delimiter, join as join23 } from "path";
|
|
12475
12734
|
function binRunnable(bin, env) {
|
|
12476
12735
|
if (!bin) return false;
|
|
12477
12736
|
if (bin.includes("/") || bin.includes("\\")) {
|
|
@@ -12487,7 +12746,7 @@ function binRunnable(bin, env) {
|
|
|
12487
12746
|
if (!dir) continue;
|
|
12488
12747
|
for (const ext of exts) {
|
|
12489
12748
|
try {
|
|
12490
|
-
accessSync(
|
|
12749
|
+
accessSync(join23(dir, bin + ext), constants.X_OK);
|
|
12491
12750
|
return true;
|
|
12492
12751
|
} catch {
|
|
12493
12752
|
}
|
|
@@ -12529,33 +12788,198 @@ function providerUnavailableReason(providerId, available) {
|
|
|
12529
12788
|
return `provider_unavailable: \u043C\u043E\u0434\u0435\u043B\u044C \u043F\u0440\u043E\u0433\u043E\u043D\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \xAB${providerId}\xBB, \u0430 \u043D\u0430 \u044D\u0442\u043E\u0439 \u043C\u0430\u0448\u0438\u043D\u0435 \u0442\u043E\u043B\u044C\u043A\u043E ${available.join(", ")} \u2014 \u043F\u0440\u043E\u0433\u043E\u043D \u043D\u0435 \u0431\u0435\u0440\u0443, \u0435\u0433\u043E \u0432\u043E\u0437\u044C\u043C\u0451\u0442 \u0434\u0440\u0443\u0433\u0430\u044F \u043C\u0430\u0448\u0438\u043D\u0430`;
|
|
12530
12789
|
}
|
|
12531
12790
|
|
|
12791
|
+
// src/modelLimits.ts
|
|
12792
|
+
import { createHash } from "crypto";
|
|
12793
|
+
import { readFileSync as readFileSync19, readdirSync as readdirSync15, statSync as statSync12 } from "fs";
|
|
12794
|
+
import { homedir as homedir7 } from "os";
|
|
12795
|
+
import { join as join24 } from "path";
|
|
12796
|
+
var KIMI_USAGES_URL = "https://api.kimi.com/coding/v1/usages";
|
|
12797
|
+
var DEFAULT_POLL_MS = 3e5;
|
|
12798
|
+
var FETCH_TIMEOUT_MS = 1e4;
|
|
12799
|
+
function record(value) {
|
|
12800
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
12801
|
+
}
|
|
12802
|
+
function jwtUserId(token) {
|
|
12803
|
+
try {
|
|
12804
|
+
const payload = token.split(".")[1];
|
|
12805
|
+
if (!payload) return null;
|
|
12806
|
+
const parsed = record(JSON.parse(Buffer.from(payload, "base64url").toString("utf8")));
|
|
12807
|
+
const id = [parsed?.user_id, parsed?.sub].find((v) => typeof v === "string" && v);
|
|
12808
|
+
return typeof id === "string" && id ? id : null;
|
|
12809
|
+
} catch {
|
|
12810
|
+
return null;
|
|
12811
|
+
}
|
|
12812
|
+
}
|
|
12813
|
+
function accountKey(userId) {
|
|
12814
|
+
return userId ? createHash("sha256").update(userId).digest("hex").slice(0, 16) : null;
|
|
12815
|
+
}
|
|
12816
|
+
function readKimiCredentials(env = process.env) {
|
|
12817
|
+
try {
|
|
12818
|
+
const root = env.KIMI_CODE_HOME?.trim() || join24(homedir7(), ".kimi-code");
|
|
12819
|
+
const dir = join24(root, "credentials");
|
|
12820
|
+
const files = readdirSync15(dir).filter((name) => name.endsWith(".json")).map((name) => ({ name, path: join24(dir, name) })).filter((entry) => statSync12(entry.path).isFile());
|
|
12821
|
+
const preferred = files.filter((entry) => entry.name.startsWith("kimi-code-env-"));
|
|
12822
|
+
const candidates = preferred.length ? preferred : files;
|
|
12823
|
+
candidates.sort((a, b) => statSync12(b.path).mtimeMs - statSync12(a.path).mtimeMs || a.name.localeCompare(b.name));
|
|
12824
|
+
const newest2 = candidates[0];
|
|
12825
|
+
if (!newest2) return null;
|
|
12826
|
+
const body = record(JSON.parse(readFileSync19(newest2.path, "utf8")));
|
|
12827
|
+
if (typeof body?.access_token !== "string" || !body.access_token) return null;
|
|
12828
|
+
const userId = jwtUserId(body.access_token);
|
|
12829
|
+
return { accessToken: body.access_token, accountKey: accountKey(userId) };
|
|
12830
|
+
} catch {
|
|
12831
|
+
return null;
|
|
12832
|
+
}
|
|
12833
|
+
}
|
|
12834
|
+
function finiteNumber(value) {
|
|
12835
|
+
if (typeof value !== "number" && typeof value !== "string") return null;
|
|
12836
|
+
if (typeof value === "string" && !value.trim()) return null;
|
|
12837
|
+
const parsed = Number(value);
|
|
12838
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
12839
|
+
}
|
|
12840
|
+
function isoOrNull2(value) {
|
|
12841
|
+
if (typeof value !== "string") return null;
|
|
12842
|
+
const normalized = value.replace(/\.(\d{3})\d+(?=(?:Z|[+-]\d{2}:?\d{2})$)/, ".$1");
|
|
12843
|
+
const date = new Date(normalized);
|
|
12844
|
+
return Number.isNaN(date.getTime()) ? null : date.toISOString();
|
|
12845
|
+
}
|
|
12846
|
+
function ratioWindow(kind, raw) {
|
|
12847
|
+
const value = record(raw);
|
|
12848
|
+
const ratio = finiteNumber(value?.used_ratio);
|
|
12849
|
+
if (ratio === null) return null;
|
|
12850
|
+
const usedPct = Math.floor(Math.round(Math.min(1, Math.max(0, ratio)) * 1e6) / 1e4);
|
|
12851
|
+
return { window: kind, usedPct, resetsAt: isoOrNull2(value?.reset_time) };
|
|
12852
|
+
}
|
|
12853
|
+
function fiveHourDetail(body) {
|
|
12854
|
+
if (!Array.isArray(body.limits)) return null;
|
|
12855
|
+
for (const raw of body.limits) {
|
|
12856
|
+
const item = record(raw);
|
|
12857
|
+
const window = record(item?.window);
|
|
12858
|
+
const detail = record(item?.detail);
|
|
12859
|
+
if (window?.duration !== 300 || window.timeUnit !== "TIME_UNIT_MINUTE" && window.timeUnit !== "MINUTE") continue;
|
|
12860
|
+
const limit = finiteNumber(detail?.limit);
|
|
12861
|
+
const used = finiteNumber(detail?.used);
|
|
12862
|
+
if (limit === null || used === null || limit <= 0) continue;
|
|
12863
|
+
const usedPct = Math.min(100, Math.max(0, Math.floor(used * 100 / limit)));
|
|
12864
|
+
return { window: "5h", usedPct, resetsAt: isoOrNull2(detail?.resetTime) };
|
|
12865
|
+
}
|
|
12866
|
+
return null;
|
|
12867
|
+
}
|
|
12868
|
+
function parseKimiUsages(body, nowIso) {
|
|
12869
|
+
const root = record(body);
|
|
12870
|
+
const usages = record(root?.usages);
|
|
12871
|
+
const fiveHours = root ? fiveHourDetail(root) ?? ratioWindow("5h", usages?.limit_5h) : null;
|
|
12872
|
+
const month = ratioWindow("month", usages?.limit_month_code) ?? ratioWindow("month", usages?.limit_month_total);
|
|
12873
|
+
const windows = [fiveHours, month].filter((window) => window !== null);
|
|
12874
|
+
if (!windows.length) throw new Error("Kimi usages: no known windows");
|
|
12875
|
+
return {
|
|
12876
|
+
executor: "kimi",
|
|
12877
|
+
state: "ok",
|
|
12878
|
+
accountKey: null,
|
|
12879
|
+
accountLabel: null,
|
|
12880
|
+
windows,
|
|
12881
|
+
fetchedAt: nowIso
|
|
12882
|
+
};
|
|
12883
|
+
}
|
|
12884
|
+
function noneModel(executor) {
|
|
12885
|
+
return { executor, state: "none", accountKey: null, accountLabel: null, windows: [], fetchedAt: null };
|
|
12886
|
+
}
|
|
12887
|
+
function accountLabel(env) {
|
|
12888
|
+
const label2 = env.SWARM_KIMI_ACCOUNT_LABEL?.trim() ?? "";
|
|
12889
|
+
return label2 ? Array.from(label2).slice(0, 40).join("") : null;
|
|
12890
|
+
}
|
|
12891
|
+
function pollPeriod(env) {
|
|
12892
|
+
const configured = Number(env.SWARM_LIMITS_POLL_MS);
|
|
12893
|
+
return Number.isFinite(configured) && configured > 0 ? Math.max(DEFAULT_POLL_MS, configured) : DEFAULT_POLL_MS;
|
|
12894
|
+
}
|
|
12895
|
+
function createModelLimitsPoller(options) {
|
|
12896
|
+
const env = options.env ?? process.env;
|
|
12897
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
12898
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
12899
|
+
const periodMs = options.periodMs ?? pollPeriod(env);
|
|
12900
|
+
let lastAttemptMs = Number.NEGATIVE_INFINITY;
|
|
12901
|
+
let inFlight = null;
|
|
12902
|
+
let lastKimi = null;
|
|
12903
|
+
async function poll() {
|
|
12904
|
+
try {
|
|
12905
|
+
const credentials = readKimiCredentials(env);
|
|
12906
|
+
if (!credentials) {
|
|
12907
|
+
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");
|
|
12908
|
+
return;
|
|
12909
|
+
}
|
|
12910
|
+
const controller = new AbortController();
|
|
12911
|
+
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
12912
|
+
timeout.unref();
|
|
12913
|
+
try {
|
|
12914
|
+
const response = await fetchImpl(KIMI_USAGES_URL, {
|
|
12915
|
+
headers: { Authorization: `Bearer ${credentials.accessToken}` },
|
|
12916
|
+
signal: controller.signal
|
|
12917
|
+
});
|
|
12918
|
+
if (!response.ok) throw new Error(`http_${response.status}`);
|
|
12919
|
+
const parsed = parseKimiUsages(await response.json(), now().toISOString());
|
|
12920
|
+
lastKimi = { ...parsed, accountKey: credentials.accountKey, accountLabel: accountLabel(env) };
|
|
12921
|
+
} finally {
|
|
12922
|
+
clearTimeout(timeout);
|
|
12923
|
+
}
|
|
12924
|
+
} catch (error) {
|
|
12925
|
+
const name = record(error)?.name;
|
|
12926
|
+
const message = record(error)?.message;
|
|
12927
|
+
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";
|
|
12928
|
+
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`);
|
|
12929
|
+
}
|
|
12930
|
+
}
|
|
12931
|
+
return {
|
|
12932
|
+
maybePoll() {
|
|
12933
|
+
if (!options.installed().includes("kimi")) return null;
|
|
12934
|
+
const nowMs = now().getTime();
|
|
12935
|
+
if (inFlight || nowMs - lastAttemptMs <= periodMs) return inFlight;
|
|
12936
|
+
lastAttemptMs = nowMs;
|
|
12937
|
+
inFlight = poll().finally(() => {
|
|
12938
|
+
inFlight = null;
|
|
12939
|
+
});
|
|
12940
|
+
return inFlight;
|
|
12941
|
+
},
|
|
12942
|
+
report() {
|
|
12943
|
+
const installed2 = options.installed();
|
|
12944
|
+
if (!installed2.length) return null;
|
|
12945
|
+
return {
|
|
12946
|
+
sentAt: now().toISOString(),
|
|
12947
|
+
models: installed2.map((executor) => executor === "kimi" && lastKimi ? lastKimi : noneModel(executor))
|
|
12948
|
+
};
|
|
12949
|
+
}
|
|
12950
|
+
};
|
|
12951
|
+
}
|
|
12952
|
+
|
|
12953
|
+
// src/overmind.ts
|
|
12954
|
+
init_src();
|
|
12955
|
+
|
|
12532
12956
|
// src/orchestrator.ts
|
|
12533
12957
|
init_src();
|
|
12534
12958
|
init_git();
|
|
12535
12959
|
|
|
12536
12960
|
// src/deps.ts
|
|
12537
|
-
import { existsSync as existsSync16, readdirSync as
|
|
12538
|
-
import { join as
|
|
12961
|
+
import { existsSync as existsSync16, readdirSync as readdirSync17, readFileSync as readFileSync21 } from "fs";
|
|
12962
|
+
import { join as join28 } from "path";
|
|
12539
12963
|
import { execa } from "execa";
|
|
12540
12964
|
|
|
12541
12965
|
// src/prepareLock.ts
|
|
12542
|
-
import { createHash } from "crypto";
|
|
12543
|
-
import { closeSync as
|
|
12544
|
-
import { join as
|
|
12966
|
+
import { createHash as createHash2 } from "crypto";
|
|
12967
|
+
import { closeSync as closeSync6, openSync as openSync6, rmSync as rmSync2, statSync as statSync14, writeSync as writeSync2 } from "fs";
|
|
12968
|
+
import { join as join26 } from "path";
|
|
12545
12969
|
import { tmpdir } from "os";
|
|
12546
12970
|
var WAIT_TIMEOUT_MS = 5 * 6e4;
|
|
12547
12971
|
var POLL_MS = 300;
|
|
12548
12972
|
var STALE_MS = 20 * 6e4;
|
|
12549
12973
|
function machineLockPath(key, dir = tmpdir()) {
|
|
12550
|
-
return
|
|
12974
|
+
return join26(dir, `swarm-prepare-${createHash2("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
|
|
12551
12975
|
}
|
|
12552
12976
|
function defaultTryCreate(path, content) {
|
|
12553
12977
|
try {
|
|
12554
|
-
const fd =
|
|
12978
|
+
const fd = openSync6(path, "wx");
|
|
12555
12979
|
try {
|
|
12556
12980
|
writeSync2(fd, content);
|
|
12557
12981
|
} finally {
|
|
12558
|
-
|
|
12982
|
+
closeSync6(fd);
|
|
12559
12983
|
}
|
|
12560
12984
|
return true;
|
|
12561
12985
|
} catch {
|
|
@@ -12564,7 +12988,7 @@ function defaultTryCreate(path, content) {
|
|
|
12564
12988
|
}
|
|
12565
12989
|
function defaultAgeMs(path) {
|
|
12566
12990
|
try {
|
|
12567
|
-
return Date.now() -
|
|
12991
|
+
return Date.now() - statSync14(path).mtimeMs;
|
|
12568
12992
|
} catch {
|
|
12569
12993
|
return null;
|
|
12570
12994
|
}
|
|
@@ -12606,12 +13030,12 @@ init_config();
|
|
|
12606
13030
|
|
|
12607
13031
|
// src/envCache.ts
|
|
12608
13032
|
init_config();
|
|
12609
|
-
import { createHash as
|
|
13033
|
+
import { createHash as createHash3 } from "crypto";
|
|
12610
13034
|
import { cp, link, lstat, mkdir as mkdir2, readdir, readlink, rename as rename2, rm as rm2, stat, symlink, utimes, writeFile as writeFile2 } from "fs/promises";
|
|
12611
|
-
import { existsSync as existsSync15, readFileSync as
|
|
12612
|
-
import { join as
|
|
13035
|
+
import { existsSync as existsSync15, readFileSync as readFileSync20 } from "fs";
|
|
13036
|
+
import { join as join27 } from "path";
|
|
12613
13037
|
function fingerprint(parts) {
|
|
12614
|
-
const h =
|
|
13038
|
+
const h = createHash3("sha256");
|
|
12615
13039
|
for (const p of parts) {
|
|
12616
13040
|
h.update(p);
|
|
12617
13041
|
h.update("\0");
|
|
@@ -12623,8 +13047,8 @@ async function cloneTree(src, dst) {
|
|
|
12623
13047
|
const entries = await readdir(src, { withFileTypes: true });
|
|
12624
13048
|
await Promise.all(
|
|
12625
13049
|
entries.map(async (e) => {
|
|
12626
|
-
const from =
|
|
12627
|
-
const to =
|
|
13050
|
+
const from = join27(src, e.name);
|
|
13051
|
+
const to = join27(dst, e.name);
|
|
12628
13052
|
if (e.isDirectory()) return cloneTree(from, to);
|
|
12629
13053
|
if (e.isSymbolicLink()) {
|
|
12630
13054
|
return symlink(await readlink(from), to).catch(() => cp(from, to, { recursive: true, verbatimSymlinks: true }));
|
|
@@ -12637,11 +13061,11 @@ function cacheRoot(io) {
|
|
|
12637
13061
|
return io.root ?? ENV_CACHE_DIR;
|
|
12638
13062
|
}
|
|
12639
13063
|
function snapshotDir(io, key) {
|
|
12640
|
-
return
|
|
13064
|
+
return join27(cacheRoot(io), key);
|
|
12641
13065
|
}
|
|
12642
13066
|
function readManifest(dir) {
|
|
12643
13067
|
try {
|
|
12644
|
-
const parsed = JSON.parse(
|
|
13068
|
+
const parsed = JSON.parse(readFileSync20(join27(dir, "manifest.json"), "utf8"));
|
|
12645
13069
|
if (!parsed || typeof parsed !== "object") return null;
|
|
12646
13070
|
const m = parsed;
|
|
12647
13071
|
if (typeof m.key !== "string" || !Array.isArray(m.dirs)) return null;
|
|
@@ -12654,7 +13078,7 @@ function readManifest(dir) {
|
|
|
12654
13078
|
}
|
|
12655
13079
|
function hasEnvSnapshot(key, io = {}) {
|
|
12656
13080
|
const exists = io.exists ?? existsSync15;
|
|
12657
|
-
return exists(
|
|
13081
|
+
return exists(join27(snapshotDir(io, key), "manifest.json"));
|
|
12658
13082
|
}
|
|
12659
13083
|
async function restoreEnvSnapshot(worktree, key, io = {}) {
|
|
12660
13084
|
const exists = io.exists ?? existsSync15;
|
|
@@ -12666,13 +13090,13 @@ async function restoreEnvSnapshot(worktree, key, io = {}) {
|
|
|
12666
13090
|
try {
|
|
12667
13091
|
for (let i = 0; i < manifest.dirs.length; i++) {
|
|
12668
13092
|
const rel = manifest.dirs[i] ?? "";
|
|
12669
|
-
const target =
|
|
13093
|
+
const target = join27(worktree, rel);
|
|
12670
13094
|
if (exists(target)) continue;
|
|
12671
|
-
await clone(
|
|
13095
|
+
await clone(join27(dir, "trees", String(i)), target);
|
|
12672
13096
|
made.push(rel);
|
|
12673
13097
|
}
|
|
12674
13098
|
} catch {
|
|
12675
|
-
for (const rel of made) await rm2(
|
|
13099
|
+
for (const rel of made) await rm2(join27(worktree, rel), { recursive: true, force: true }).catch(() => {
|
|
12676
13100
|
});
|
|
12677
13101
|
return null;
|
|
12678
13102
|
}
|
|
@@ -12688,16 +13112,16 @@ async function saveEnvSnapshot(worktree, key, dirs, io = {}) {
|
|
|
12688
13112
|
const exists = io.exists ?? existsSync15;
|
|
12689
13113
|
const clone = io.clone ?? cloneTree;
|
|
12690
13114
|
if (hasEnvSnapshot(key, io)) return true;
|
|
12691
|
-
const present = dirs.filter((rel) => exists(
|
|
13115
|
+
const present = dirs.filter((rel) => exists(join27(worktree, rel)));
|
|
12692
13116
|
if (!present.length) return false;
|
|
12693
13117
|
const root = cacheRoot(io);
|
|
12694
|
-
const tmp =
|
|
13118
|
+
const tmp = join27(root, `.tmp-${key}-${process.pid}`);
|
|
12695
13119
|
try {
|
|
12696
13120
|
await rm2(tmp, { recursive: true, force: true });
|
|
12697
|
-
await mkdir2(
|
|
12698
|
-
for (let i = 0; i < present.length; i++) await clone(
|
|
13121
|
+
await mkdir2(join27(tmp, "trees"), { recursive: true });
|
|
13122
|
+
for (let i = 0; i < present.length; i++) await clone(join27(worktree, present[i] ?? ""), join27(tmp, "trees", String(i)));
|
|
12699
13123
|
const manifest = { key, dirs: present, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
12700
|
-
await writeFile2(
|
|
13124
|
+
await writeFile2(join27(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
12701
13125
|
await rename2(tmp, snapshotDir(io, key));
|
|
12702
13126
|
return true;
|
|
12703
13127
|
} catch {
|
|
@@ -12717,13 +13141,13 @@ async function pruneEnvSnapshots(io = {}) {
|
|
|
12717
13141
|
}
|
|
12718
13142
|
const withTime = [];
|
|
12719
13143
|
for (const name of names) {
|
|
12720
|
-
const s = await stat(
|
|
13144
|
+
const s = await stat(join27(root, name)).catch(() => null);
|
|
12721
13145
|
if (s) withTime.push({ name, mtime: s.mtimeMs });
|
|
12722
13146
|
}
|
|
12723
13147
|
withTime.sort((a, b) => b.mtime - a.mtime);
|
|
12724
13148
|
let removed = 0;
|
|
12725
13149
|
for (const { name } of withTime.slice(Math.max(0, keep))) {
|
|
12726
|
-
await rm2(
|
|
13150
|
+
await rm2(join27(root, name), { recursive: true, force: true }).catch(() => {
|
|
12727
13151
|
});
|
|
12728
13152
|
removed++;
|
|
12729
13153
|
}
|
|
@@ -12739,9 +13163,9 @@ async function sweepEnvCacheTemp(io = {}) {
|
|
|
12739
13163
|
}
|
|
12740
13164
|
let removed = 0;
|
|
12741
13165
|
for (const name of names) {
|
|
12742
|
-
const s = await lstat(
|
|
13166
|
+
const s = await lstat(join27(root, name)).catch(() => null);
|
|
12743
13167
|
if (!s || Date.now() - s.mtimeMs < 60 * 6e4) continue;
|
|
12744
|
-
await rm2(
|
|
13168
|
+
await rm2(join27(root, name), { recursive: true, force: true }).catch(() => {
|
|
12745
13169
|
});
|
|
12746
13170
|
removed++;
|
|
12747
13171
|
}
|
|
@@ -12768,21 +13192,21 @@ async function runCommand(cmd, worktree) {
|
|
|
12768
13192
|
}
|
|
12769
13193
|
function safeReadText(p) {
|
|
12770
13194
|
try {
|
|
12771
|
-
return
|
|
13195
|
+
return readFileSync21(p, "utf8");
|
|
12772
13196
|
} catch {
|
|
12773
13197
|
return null;
|
|
12774
13198
|
}
|
|
12775
13199
|
}
|
|
12776
13200
|
function safeListDirs(p) {
|
|
12777
13201
|
try {
|
|
12778
|
-
return
|
|
13202
|
+
return readdirSync17(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
12779
13203
|
} catch {
|
|
12780
13204
|
return [];
|
|
12781
13205
|
}
|
|
12782
13206
|
}
|
|
12783
13207
|
function safeListFiles(p) {
|
|
12784
13208
|
try {
|
|
12785
|
-
return
|
|
13209
|
+
return readdirSync17(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
|
|
12786
13210
|
} catch {
|
|
12787
13211
|
return [];
|
|
12788
13212
|
}
|
|
@@ -12810,19 +13234,19 @@ function overridePlan(override) {
|
|
|
12810
13234
|
function detectPackageManager(worktree, io = {}) {
|
|
12811
13235
|
const exists = io.exists ?? existsSync16;
|
|
12812
13236
|
const readText = io.readText ?? safeReadText;
|
|
12813
|
-
const hasPkgJson = exists(
|
|
13237
|
+
const hasPkgJson = exists(join28(worktree, "package.json"));
|
|
12814
13238
|
if (!hasPkgJson) {
|
|
12815
|
-
if (exists(
|
|
13239
|
+
if (exists(join28(worktree, "deno.json")) || exists(join28(worktree, "deno.jsonc")) || exists(join28(worktree, "deno.lock"))) return "deno";
|
|
12816
13240
|
return null;
|
|
12817
13241
|
}
|
|
12818
|
-
const pkg = readJson(readText,
|
|
13242
|
+
const pkg = readJson(readText, join28(worktree, "package.json"));
|
|
12819
13243
|
const declared = typeof pkg?.packageManager === "string" ? pkg.packageManager.split("@")[0] : void 0;
|
|
12820
13244
|
if (declared === "pnpm" || declared === "bun" || declared === "npm" || declared === "yarn") return declared;
|
|
12821
|
-
if (exists(
|
|
12822
|
-
if (exists(
|
|
12823
|
-
if (exists(
|
|
12824
|
-
if (exists(
|
|
12825
|
-
if (exists(
|
|
13245
|
+
if (exists(join28(worktree, "bun.lock")) || exists(join28(worktree, "bun.lockb"))) return "bun";
|
|
13246
|
+
if (exists(join28(worktree, "pnpm-lock.yaml"))) return "pnpm";
|
|
13247
|
+
if (exists(join28(worktree, "yarn.lock"))) return "yarn";
|
|
13248
|
+
if (exists(join28(worktree, "package-lock.json"))) return "npm";
|
|
13249
|
+
if (exists(join28(worktree, "deno.lock"))) return "deno";
|
|
12826
13250
|
return "npm";
|
|
12827
13251
|
}
|
|
12828
13252
|
function jsInstallCommand(pm) {
|
|
@@ -12886,7 +13310,7 @@ function detectPlan(worktree, io) {
|
|
|
12886
13310
|
// node_modules на месте — установку пропускаем (быстрый путь переиспользованного worktree).
|
|
12887
13311
|
// У deno каталога может не быть вовсе (кэш в DENO_DIR) — тогда `deno install` отработает
|
|
12888
13312
|
// заново, но он дешёвый: тянет из того же общего кэша.
|
|
12889
|
-
{ label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists:
|
|
13313
|
+
{ label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join28(worktree, "node_modules"), source: "detect" }
|
|
12890
13314
|
];
|
|
12891
13315
|
for (const target of workspaceBuildTargets(worktree, io)) {
|
|
12892
13316
|
commands.push({ label: `\u0441\u0431\u043E\u0440\u043A\u0430 ${target.name}`, run: jsRunScript(pm, "build"), cwd: target.dir, source: "detect" });
|
|
@@ -12895,12 +13319,12 @@ function detectPlan(worktree, io) {
|
|
|
12895
13319
|
return { source: "detect", ecosystem: `node/${pm}`, commands };
|
|
12896
13320
|
}
|
|
12897
13321
|
for (const marker of ECOSYSTEM_MARKERS) {
|
|
12898
|
-
const hit = marker.files.some((f) => exists(
|
|
13322
|
+
const hit = marker.files.some((f) => exists(join28(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
|
|
12899
13323
|
if (!hit) continue;
|
|
12900
13324
|
let ecosystem = marker.ecosystem;
|
|
12901
13325
|
let command = marker.command;
|
|
12902
13326
|
for (const refine of marker.refine ?? []) {
|
|
12903
|
-
if (!exists(
|
|
13327
|
+
if (!exists(join28(worktree, refine.file))) continue;
|
|
12904
13328
|
ecosystem = refine.ecosystem;
|
|
12905
13329
|
command = refine.command;
|
|
12906
13330
|
break;
|
|
@@ -12957,12 +13381,12 @@ var CI_INSTALL_PATTERNS = [
|
|
|
12957
13381
|
function ciWorkflowPlan(worktree, io) {
|
|
12958
13382
|
const readText = io.readText ?? safeReadText;
|
|
12959
13383
|
const listFiles = io.listFiles ?? safeListFiles;
|
|
12960
|
-
const dir =
|
|
13384
|
+
const dir = join28(worktree, ".github", "workflows");
|
|
12961
13385
|
const files = listFiles(dir).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml"));
|
|
12962
13386
|
const seen = /* @__PURE__ */ new Set();
|
|
12963
13387
|
const commands = [];
|
|
12964
13388
|
for (const name of files.sort()) {
|
|
12965
|
-
const yaml = readText(
|
|
13389
|
+
const yaml = readText(join28(dir, name));
|
|
12966
13390
|
if (yaml === null) continue;
|
|
12967
13391
|
for (const raw of workflowRunLines(yaml)) {
|
|
12968
13392
|
const line = raw.replace(/\s+/g, " ").trim();
|
|
@@ -12977,7 +13401,7 @@ function ciWorkflowPlan(worktree, io) {
|
|
|
12977
13401
|
return commands.length ? { source: "ci-workflow", ecosystem: "ci-\u043A\u043E\u043D\u0444\u0438\u0433", commands } : null;
|
|
12978
13402
|
}
|
|
12979
13403
|
function workspaceGlobs(worktree, readText) {
|
|
12980
|
-
const yaml = readText(
|
|
13404
|
+
const yaml = readText(join28(worktree, "pnpm-workspace.yaml"));
|
|
12981
13405
|
if (yaml !== null) {
|
|
12982
13406
|
const globs = [];
|
|
12983
13407
|
let inPackages = false;
|
|
@@ -12997,7 +13421,7 @@ function workspaceGlobs(worktree, readText) {
|
|
|
12997
13421
|
}
|
|
12998
13422
|
if (globs.length) return globs;
|
|
12999
13423
|
}
|
|
13000
|
-
const pkg = readJson(readText,
|
|
13424
|
+
const pkg = readJson(readText, join28(worktree, "package.json"));
|
|
13001
13425
|
const ws = pkg?.workspaces;
|
|
13002
13426
|
const list = Array.isArray(ws) ? ws : Array.isArray(ws?.packages) ? ws.packages : [];
|
|
13003
13427
|
return list.filter((g) => typeof g === "string");
|
|
@@ -13008,14 +13432,14 @@ function workspaceDirs(worktree, globs, io) {
|
|
|
13008
13432
|
if (glob.startsWith("!")) continue;
|
|
13009
13433
|
const star = glob.indexOf("*");
|
|
13010
13434
|
if (star === -1) {
|
|
13011
|
-
const dir =
|
|
13012
|
-
if (io.exists(
|
|
13435
|
+
const dir = join28(worktree, glob);
|
|
13436
|
+
if (io.exists(join28(dir, "package.json"))) dirs.add(dir);
|
|
13013
13437
|
continue;
|
|
13014
13438
|
}
|
|
13015
|
-
const base3 =
|
|
13439
|
+
const base3 = join28(worktree, glob.slice(0, star).replace(/\/$/, ""));
|
|
13016
13440
|
for (const name of io.listDirs(base3)) {
|
|
13017
|
-
const dir =
|
|
13018
|
-
if (io.exists(
|
|
13441
|
+
const dir = join28(base3, name);
|
|
13442
|
+
if (io.exists(join28(dir, "package.json"))) dirs.add(dir);
|
|
13019
13443
|
}
|
|
13020
13444
|
}
|
|
13021
13445
|
return [...dirs];
|
|
@@ -13043,11 +13467,11 @@ function workspaceBuildTargets(worktree, io = {}) {
|
|
|
13043
13467
|
if (!globs.length) return [];
|
|
13044
13468
|
const pkgs = [];
|
|
13045
13469
|
for (const dir of workspaceDirs(worktree, globs, { exists, listDirs })) {
|
|
13046
|
-
const pkg = readJson(readText,
|
|
13470
|
+
const pkg = readJson(readText, join28(dir, "package.json"));
|
|
13047
13471
|
if (!pkg || typeof pkg.name !== "string") continue;
|
|
13048
13472
|
const scripts = pkg.scripts ?? {};
|
|
13049
13473
|
const entries = entryPaths(pkg);
|
|
13050
|
-
const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(
|
|
13474
|
+
const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join28(dir, e)));
|
|
13051
13475
|
const deps = Object.keys({ ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} });
|
|
13052
13476
|
pkgs.push({ name: pkg.name, dir, deps, needsBuild });
|
|
13053
13477
|
}
|
|
@@ -13075,7 +13499,7 @@ function devDatabaseUrl(worktree, io = {}) {
|
|
|
13075
13499
|
const fromEnv = (io.env ?? process.env).DATABASE_URL;
|
|
13076
13500
|
if (fromEnv && fromEnv.trim()) return fromEnv.trim();
|
|
13077
13501
|
for (const file of [".env", ".env.example"]) {
|
|
13078
|
-
const raw = readText(
|
|
13502
|
+
const raw = readText(join28(worktree, file));
|
|
13079
13503
|
if (raw === null) continue;
|
|
13080
13504
|
const m = /^\s*(?:export\s+)?DATABASE_URL\s*=\s*(.*)$/m.exec(raw);
|
|
13081
13505
|
const value = (m?.[1] ?? "").trim().replace(/^['"]|['"]$/g, "");
|
|
@@ -13095,7 +13519,7 @@ function prismaPackages(worktree, io) {
|
|
|
13095
13519
|
const readText = io.readText ?? safeReadText;
|
|
13096
13520
|
const listDirs = io.listDirs ?? safeListDirs;
|
|
13097
13521
|
const dirs = [worktree, ...workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs })];
|
|
13098
|
-
return dirs.filter((dir) => exists(
|
|
13522
|
+
return dirs.filter((dir) => exists(join28(dir, "prisma", "schema.prisma")) && listDirs(join28(dir, "prisma", "migrations")).length > 0);
|
|
13099
13523
|
}
|
|
13100
13524
|
function jsExecBin(pm, command) {
|
|
13101
13525
|
switch (pm) {
|
|
@@ -13132,18 +13556,18 @@ function envCachePlan(worktree, io = {}) {
|
|
|
13132
13556
|
if (!pm) return null;
|
|
13133
13557
|
const parts = [`pm:${pm}`];
|
|
13134
13558
|
for (const name of ENV_DEFINING_FILES) {
|
|
13135
|
-
const raw = readText(
|
|
13559
|
+
const raw = readText(join28(worktree, name));
|
|
13136
13560
|
if (raw !== null) parts.push(`${name}
|
|
13137
13561
|
${raw}`);
|
|
13138
13562
|
}
|
|
13139
13563
|
const pkgDirs = workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs });
|
|
13140
13564
|
const rels = pkgDirs.map((dir) => dir.slice(worktree.length + 1)).sort();
|
|
13141
13565
|
for (const rel of ["", ...rels]) {
|
|
13142
|
-
const raw = readText(
|
|
13566
|
+
const raw = readText(join28(worktree, rel, "package.json"));
|
|
13143
13567
|
if (raw !== null) parts.push(`${rel}/package.json
|
|
13144
13568
|
${raw}`);
|
|
13145
13569
|
}
|
|
13146
|
-
return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) =>
|
|
13570
|
+
return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join28(rel, "node_modules"))] };
|
|
13147
13571
|
}
|
|
13148
13572
|
function planPrepare(worktree, io = {}) {
|
|
13149
13573
|
const plan = overridePlan(io.override) ?? detectPlan(worktree, io) ?? ciWorkflowPlan(worktree, io);
|
|
@@ -13168,7 +13592,7 @@ async function ensureWorktreeDeps(worktree, io = {}) {
|
|
|
13168
13592
|
restored: [],
|
|
13169
13593
|
cached: false
|
|
13170
13594
|
};
|
|
13171
|
-
if (cachePlan && !exists(
|
|
13595
|
+
if (cachePlan && !exists(join28(worktree, "node_modules"))) {
|
|
13172
13596
|
report.restored = await restoreEnvSnapshot(worktree, cachePlan.key, cacheIO) ?? [];
|
|
13173
13597
|
}
|
|
13174
13598
|
const plan = planPrepare(worktree, io);
|
|
@@ -13256,7 +13680,7 @@ function depsPromptNotice(report) {
|
|
|
13256
13680
|
// src/orchestrator.ts
|
|
13257
13681
|
init_config();
|
|
13258
13682
|
import { existsSync as existsSync17, mkdirSync as mkdirSync11, rmSync as rmSync3 } from "fs";
|
|
13259
|
-
import { join as
|
|
13683
|
+
import { join as join29, dirname as dirname4 } from "path";
|
|
13260
13684
|
function droneLaunchedText(workdir, pid) {
|
|
13261
13685
|
return `\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0432 ${workdir} (pid ${pid})`;
|
|
13262
13686
|
}
|
|
@@ -13265,7 +13689,7 @@ function droneLaunchedPid(text) {
|
|
|
13265
13689
|
return m ? Number(m[1]) : null;
|
|
13266
13690
|
}
|
|
13267
13691
|
function repolessRunDir(worktreesDir, taskSlug) {
|
|
13268
|
-
return
|
|
13692
|
+
return join29(dirname4(worktreesDir), "runs", taskSlug);
|
|
13269
13693
|
}
|
|
13270
13694
|
var WORKTREE_HELD_STATUSES = /* @__PURE__ */ new Set(["running", "blocked", "review", "paused", "storm_dead"]);
|
|
13271
13695
|
function worktreePathHeldLive(db, path, exceptRunId) {
|
|
@@ -13543,7 +13967,7 @@ function parkReasonUnretriable(reason) {
|
|
|
13543
13967
|
// package.json
|
|
13544
13968
|
var package_default = {
|
|
13545
13969
|
name: "@taskless-app/swarm",
|
|
13546
|
-
version: "0.6.
|
|
13970
|
+
version: "0.6.85",
|
|
13547
13971
|
type: "module",
|
|
13548
13972
|
description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
|
|
13549
13973
|
keywords: [
|
|
@@ -13595,7 +14019,7 @@ var package_default = {
|
|
|
13595
14019
|
undici: "^7.30.1",
|
|
13596
14020
|
zod: "3.25.76"
|
|
13597
14021
|
},
|
|
13598
|
-
gitHead: "
|
|
14022
|
+
gitHead: "71965d722ad5cdcb80cd4053710c1097c65e7352"
|
|
13599
14023
|
};
|
|
13600
14024
|
|
|
13601
14025
|
// src/version.ts
|
|
@@ -14415,8 +14839,8 @@ import { z } from "zod";
|
|
|
14415
14839
|
init_git();
|
|
14416
14840
|
|
|
14417
14841
|
// src/diff.ts
|
|
14418
|
-
import { statSync as
|
|
14419
|
-
import { join as
|
|
14842
|
+
import { statSync as statSync15 } from "fs";
|
|
14843
|
+
import { join as join34 } from "path";
|
|
14420
14844
|
import { $ as $4 } from "execa";
|
|
14421
14845
|
var MAX_FILES = 200;
|
|
14422
14846
|
var MAX_LINES_PER_FILE = 1500;
|
|
@@ -14559,7 +14983,7 @@ async function resolveBase(wt, baseBranch) {
|
|
|
14559
14983
|
}
|
|
14560
14984
|
function mtime(path) {
|
|
14561
14985
|
try {
|
|
14562
|
-
return
|
|
14986
|
+
return statSync15(path).mtimeMs;
|
|
14563
14987
|
} catch {
|
|
14564
14988
|
return 0;
|
|
14565
14989
|
}
|
|
@@ -14584,7 +15008,7 @@ async function collectRunDiff(worktree, opts = {}) {
|
|
|
14584
15008
|
files.push(pf);
|
|
14585
15009
|
}
|
|
14586
15010
|
}
|
|
14587
|
-
files.sort((a, b) => mtime(
|
|
15011
|
+
files.sort((a, b) => mtime(join34(worktree, b.path)) - mtime(join34(worktree, a.path)));
|
|
14588
15012
|
const truncatedFiles = files.length > MAX_FILES;
|
|
14589
15013
|
if (truncatedFiles) files = files.slice(0, MAX_FILES);
|
|
14590
15014
|
const added = files.reduce((s, f) => s + f.added, 0);
|
|
@@ -15675,7 +16099,7 @@ async function runDroneServer(runId) {
|
|
|
15675
16099
|
|
|
15676
16100
|
// src/droneBridge.ts
|
|
15677
16101
|
init_src();
|
|
15678
|
-
import { createHash as
|
|
16102
|
+
import { createHash as createHash5 } from "crypto";
|
|
15679
16103
|
|
|
15680
16104
|
// src/anomalies.ts
|
|
15681
16105
|
init_src();
|
|
@@ -15807,7 +16231,7 @@ var AnomalyTracker = class {
|
|
|
15807
16231
|
if (now - startedAt < c.minDurationMs) continue;
|
|
15808
16232
|
const lastFired = this.lastFiredAt.get(c.key);
|
|
15809
16233
|
if (lastFired != null && now - lastFired < this.renotifyCooldownMs) continue;
|
|
15810
|
-
if ((this.fires.get(c.key) ?? 0) >= this.maxRepeats) continue;
|
|
16234
|
+
if ((this.fires.get(c.key) ?? 0) >= (c.once ? 1 : this.maxRepeats)) continue;
|
|
15811
16235
|
result.push(c);
|
|
15812
16236
|
}
|
|
15813
16237
|
let pruned = false;
|
|
@@ -16209,7 +16633,7 @@ function questionKey(runId, text) {
|
|
|
16209
16633
|
return `${runId} ${text.trim().replace(/\s+/g, " ")}`;
|
|
16210
16634
|
}
|
|
16211
16635
|
function noteKey(runId, text) {
|
|
16212
|
-
return `note:${runId}:${
|
|
16636
|
+
return `note:${runId}:${createHash5("sha1").update(questionKey(runId, text)).digest("hex").slice(0, 16)}`;
|
|
16213
16637
|
}
|
|
16214
16638
|
async function syncDroneChannel(opts) {
|
|
16215
16639
|
const result = { imported: [], answered: [], notes: [] };
|
|
@@ -17003,21 +17427,21 @@ async function prodClearMergeIntent(runId, deps = {}) {
|
|
|
17003
17427
|
|
|
17004
17428
|
// src/envGate.ts
|
|
17005
17429
|
import { existsSync as existsSync20 } from "fs";
|
|
17006
|
-
import { join as
|
|
17430
|
+
import { join as join36 } from "path";
|
|
17007
17431
|
import { createConnection } from "net";
|
|
17008
17432
|
import { execa as execa2 } from "execa";
|
|
17009
17433
|
|
|
17010
17434
|
// src/platform.ts
|
|
17011
17435
|
init_src();
|
|
17012
|
-
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync19, readFileSync as
|
|
17013
|
-
import { delimiter as delimiter2, join as
|
|
17436
|
+
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync19, readFileSync as readFileSync25, realpathSync as realpathSync3 } from "fs";
|
|
17437
|
+
import { delimiter as delimiter2, join as join35, posix as posix2, win32 } from "path";
|
|
17014
17438
|
function resolveCommandPath(name, env = process.env, platform = process.platform) {
|
|
17015
17439
|
if (name.includes("/") || name.includes("\\")) return existsSync19(name) ? name : null;
|
|
17016
17440
|
const dirs = (env.PATH ?? env.Path ?? "").split(delimiter2).filter(Boolean);
|
|
17017
17441
|
const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
|
|
17018
17442
|
for (const dir of dirs) {
|
|
17019
17443
|
for (const ext of exts) {
|
|
17020
|
-
const candidate =
|
|
17444
|
+
const candidate = join35(dir, name + ext);
|
|
17021
17445
|
if (existsSync19(candidate)) return candidate;
|
|
17022
17446
|
}
|
|
17023
17447
|
}
|
|
@@ -17188,7 +17612,7 @@ var COMPOSE_MARKERS = [
|
|
|
17188
17612
|
];
|
|
17189
17613
|
function detectRequirements(repo, io = {}) {
|
|
17190
17614
|
const exists = io.exists ?? existsSync20;
|
|
17191
|
-
const marker = COMPOSE_MARKERS.find((f) => exists(
|
|
17615
|
+
const marker = COMPOSE_MARKERS.find((f) => exists(join36(repo, f)));
|
|
17192
17616
|
return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
|
|
17193
17617
|
}
|
|
17194
17618
|
function resolveRequirements(repo, declared, io = {}) {
|
|
@@ -17978,7 +18402,7 @@ function stormBanner(storm) {
|
|
|
17978
18402
|
const frozen = storm.dead ? `${storm.dead} \u0432 \u043A\u043E\u043A\u043E\u043D\u0435` : "\u043D\u043E\u0432\u044B\u0445 \u0434\u0440\u043E\u043D\u043E\u0432 \u043D\u0435 \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0435\u043C";
|
|
17979
18403
|
return {
|
|
17980
18404
|
ico: "\u26A1",
|
|
17981
|
-
title: "\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014
|
|
18405
|
+
title: "\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442",
|
|
17982
18406
|
desc: `\u0420\u043E\u0439 \u0437\u0430\u043C\u0435\u0440, \u0434\u0440\u043E\u043D\u044B \u0432 \u043A\u043E\u043A\u043E\u043D\u0430\u0445 \u2014 ${frozen}, \u043E\u0447\u0435\u0440\u0435\u0434\u044C \u043A\u043E\u043F\u0438\u0442\u0441\u044F. \u041F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u0441\u0430\u043C, \u043A\u0430\u043A \u0441\u0432\u044F\u0437\u044C \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F.`
|
|
17983
18407
|
};
|
|
17984
18408
|
}
|
|
@@ -18061,7 +18485,7 @@ var GK = ['claw','spore','eye','hex'];
|
|
|
18061
18485
|
var ST = ${jsonForScript(statusTuples())};
|
|
18062
18486
|
var ORDER = { running:0, blocked:1, paused:2, storm_dead:3, review:4, stalled:5, queued:6, stopped:7, done:8, failed:9, superseded:10 };
|
|
18063
18487
|
var TERM = ${jsonForScript(Object.fromEntries(TERMINAL_STATUSES.map((s) => [s, 1])))};
|
|
18064
|
-
var EVL = { spawned:'\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D', step:'', blocked:'\u0432\u043E\u043F\u0440\u043E\u0441 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0443', answered:'\u043F\u043E\u043B\u0443\u0447\u0435\u043D \u043E\u0442\u0432\u0435\u0442', pr_opened:'PR \u043E\u0442\u043A\u0440\u044B\u0442', merged:'PR \u0441\u043C\u0435\u0440\u0436\u0451\u043D, \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043A\u0440\u044B\u0442\u0430', done:'\u0433\u043E\u0442\u043E\u0432\u043E', failed:'\u0434\u0440\u043E\u043D \u0443\u043F\u0430\u043B', stalled:'\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441/\u043F\u043E\u0433\u0438\u0431', respawned:'\u0430\u0432\u0442\u043E-\u043E\u0436\u0438\u0432\u043B\u0435\u043D\u0438\u0435', paused:'\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D', resumed:'overmind \u0432\u0435\u0440\u043D\u0443\u043B\u0441\u044F \u2014 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B', rescued:'worktree \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u2014 \u0437\u0430\u0431\u0435\u0440\u0438 \u0440\u0443\u043A\u0430\u043C\u0438', conflict:'\u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442 \u0441 main (merge-main-in)', died:'\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440', storm_start:'\u26A1 \u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014
|
|
18488
|
+
var EVL = { spawned:'\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D', step:'', blocked:'\u0432\u043E\u043F\u0440\u043E\u0441 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0443', answered:'\u043F\u043E\u043B\u0443\u0447\u0435\u043D \u043E\u0442\u0432\u0435\u0442', pr_opened:'PR \u043E\u0442\u043A\u0440\u044B\u0442', merged:'PR \u0441\u043C\u0435\u0440\u0436\u0451\u043D, \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043A\u0440\u044B\u0442\u0430', done:'\u0433\u043E\u0442\u043E\u0432\u043E', failed:'\u0434\u0440\u043E\u043D \u0443\u043F\u0430\u043B', stalled:'\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441/\u043F\u043E\u0433\u0438\u0431', respawned:'\u0430\u0432\u0442\u043E-\u043E\u0436\u0438\u0432\u043B\u0435\u043D\u0438\u0435', paused:'\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D', resumed:'overmind \u0432\u0435\u0440\u043D\u0443\u043B\u0441\u044F \u2014 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B', rescued:'worktree \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u2014 \u0437\u0430\u0431\u0435\u0440\u0438 \u0440\u0443\u043A\u0430\u043C\u0438', conflict:'\u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442 \u0441 main (merge-main-in)', died:'\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440', storm_start:'\u26A1 \u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442', storm_end:'\u0441\u0432\u044F\u0437\u044C \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u2014 \u0440\u043E\u0439 \u043F\u0440\u043E\u0431\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044F', storm_dead:'\u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435 (\u0448\u0442\u043E\u0440\u043C)', stopped:'\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D', superseded:'\u043F\u0435\u0440\u0435\u0438\u0433\u0440\u0430\u043D', anomaly:'\u26A0\uFE0F \u0430\u043D\u043E\u043C\u0430\u043B\u0438\u044F \u0440\u043E\u044F', dep_cleared:'\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u044C \u0441\u043D\u044F\u0442\u0430 \u2014 \u0431\u043B\u043E\u043A\u0435\u0440 \u043D\u0435 \u0434\u043E\u0435\u0434\u0435\u0442' };
|
|
18065
18489
|
var MDOT = { merged:'--success', done:'--success', pr_opened:'--info', spawned:'--muted-foreground', stalled:'--destructive', failed:'--destructive', respawned:'--warning', paused:'--warning', resumed:'--success', rescued:'--destructive', conflict:'--warning', died:'--destructive', storm_start:'--destructive', storm_end:'--success', storm_dead:'--warning', stopped:'--muted-foreground', superseded:'--muted-foreground', anomaly:'--warning', dep_cleared:'--warning' };
|
|
18066
18490
|
|
|
18067
18491
|
function E(s){ return String(s==null?"":s).replace(/[&<>"]/g,function(c){return{'&':'&','<':'<','>':'>','"':'"'}[c]}); }
|
|
@@ -18087,13 +18511,21 @@ function pill(st){ var s=ST[st]||ST.queued; return '<span class="pill '+s[0]+'">
|
|
|
18087
18511
|
function ava(d){ return '<span class="ava" style="color:'+color(d.status)+'"><svg viewBox="0 0 24 24" fill="none">'+GLYPH[GK[d.id%GK.length]]+'</svg></span>'; }
|
|
18088
18512
|
function taskUrl(d){ return d.taskUrl || (TASK_URL_BASE ? TASK_URL_BASE + '/tasks/' + d.slug : null); }
|
|
18089
18513
|
|
|
18514
|
+
function limitWaitDisplay(stopReason){
|
|
18515
|
+
var m=/^limit-wait: ([^ ]+) \u0434\u043E ([^ ]+);(?: |$)/.exec(stopReason||'');
|
|
18516
|
+
if(!m||isNaN(Date.parse(m[2]))) return null;
|
|
18517
|
+
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';
|
|
18518
|
+
var reset=new Date(m[2]).toLocaleString('ru-RU',{day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit'});
|
|
18519
|
+
var suffix='\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442 \u043F\u043E\u0441\u043B\u0435 \u0441\u0431\u0440\u043E\u0441\u0430';
|
|
18520
|
+
return text.slice(-suffix.length)===suffix ? text+' '+reset : text+', \u0441\u0431\u0440\u043E\u0441 '+reset;
|
|
18521
|
+
}
|
|
18090
18522
|
/* \u043A\u0430\u0440\u0442\u043E\u0447\u043D\u044B\u0439 \xAB\u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u0448\u0430\u0433\xBB \u043F\u043E \u0441\u0442\u0430\u0442\u0443\u0441\u0443 (\u0441\u043F\u0435\u043A\u0430 TS-3) */
|
|
18091
18523
|
function cardStep(d){
|
|
18092
18524
|
if(d.status==='blocked') return '\u0432\u043E\u043F\u0440\u043E\u0441 \u0432 \u0438\u043D\u0431\u043E\u043A\u0441\u0435';
|
|
18093
18525
|
if(d.status==='stalled') return d.reason || '\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441/\u043F\u043E\u0433\u0438\u0431';
|
|
18094
18526
|
if(d.status==='stopped') return d.stopReason || d.reason || '\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D';
|
|
18095
|
-
if(d.status==='storm_dead') return '\u0434\u0440\u043E\u043D \u0432 \u043A\u043E\u043A\u043E\u043D\u0435 \u2014 \u043F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 (
|
|
18096
|
-
if(d.status==='paused') return d.stopReason || '\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D, \u0436\u0434\u0451\u0442 \u043F\u0435\u0440\u0435\u043F\u043E\u0434\u044A\u0451\u043C\u0430'; // TASWM-151: \u0440\u0435\u0441\u0443\u0440\u0441-\u0440\u0430\u0437\u0433\u0440\u0443\u0437\u043A\u0430 \u0437\u0430\u0434\u0430\u0451\u0442 \u0441\u0432\u043E\u0439 stopReason
|
|
18527
|
+
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';
|
|
18528
|
+
if(d.status==='paused') return limitWaitDisplay(d.stopReason) || d.stopReason || '\u0437\u0430\u043C\u0435\u0440 \u2014 overmind \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D, \u0436\u0434\u0451\u0442 \u043F\u0435\u0440\u0435\u043F\u043E\u0434\u044A\u0451\u043C\u0430'; // TASWM-151: \u0440\u0435\u0441\u0443\u0440\u0441-\u0440\u0430\u0437\u0433\u0440\u0443\u0437\u043A\u0430 \u0437\u0430\u0434\u0430\u0451\u0442 \u0441\u0432\u043E\u0439 stopReason
|
|
18097
18529
|
if(d.status==='review') { var n=prNum(d.pr); return 'PR'+(n?(' #'+n):'')+' \u043D\u0430 \u0440\u0435\u0432\u044C\u044E'; }
|
|
18098
18530
|
if(d.status==='done') return '\u0441\u043C\u0435\u0440\u0436\u0435\u043D';
|
|
18099
18531
|
if(d.status==='queued') return (d.waiting&&d.waiting.length) ? '\u0436\u0434\u0451\u0442: '+d.waiting.join(', ') : '\u0432 \u043E\u0447\u0435\u0440\u0435\u0434\u0438 \u2014 \u0436\u0434\u0451\u0442 \u0441\u043B\u043E\u0442\u0430';
|
|
@@ -18472,7 +18904,7 @@ function openModal(id){ var reopen=(openId===id); openId=id; var d=byId[id]; if(
|
|
|
18472
18904
|
return '<li class="step '+kind+'">'+node(kind)+'<div><div class="stext">'+E(stepLabel(e))+(kind==='now'?'<span class="live-lbl">\u0441\u0435\u0439\u0447\u0430\u0441</span>':'')+'</div>'+(e.at?'<div class="stime" title="'+E(localFull(e.at))+'">'+E(localHM(e.at))+' \xB7 '+E(rel(e.at))+'</div>':'')+'</div></li>'; }).join('');
|
|
18473
18905
|
var url = taskUrl(d);
|
|
18474
18906
|
var links = (url?'<a href="'+E(url)+'" target="_blank" rel="noopener">'+E(d.slug)+' \u2197</a>':'<span class="mono">'+E(d.slug)+'</span>')+(d.pr?'<a href="'+E(d.pr)+'" target="_blank" rel="noopener">PR \u2197</a>':'');
|
|
18475
|
-
var desc = d.desc || (d.stopReason?('\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D: '+d.stopReason):('\u0414\u0440\u043E\u043D '+d.name+' \xB7 \u043F\u0440\u043E\u0433\u043E\u043D #'+d.id));
|
|
18907
|
+
var desc = d.desc || (d.stopReason?('\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D: '+(limitWaitDisplay(d.stopReason)||d.stopReason)):('\u0414\u0440\u043E\u043D '+d.name+' \xB7 \u043F\u0440\u043E\u0433\u043E\u043D #'+d.id));
|
|
18476
18908
|
var codeBadge = (mDiffId===id && mDiff && mDiff.ok && mDiff.files.length) ? '<span class="mc-badge"><span class="a">+'+mDiff.added+'</span><span class="d">\u2212'+mDiff.removed+'</span></span>' : '';
|
|
18477
18909
|
var acts='';
|
|
18478
18910
|
var qid = firstQid(d.id);
|
|
@@ -18537,7 +18969,7 @@ function paintStorm(){ var b=document.getElementById('storm-banner'); if(!b) ret
|
|
|
18537
18969
|
'<div class="sb-d">\u041F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u0436\u0438\u0432, \u043D\u043E \u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u043D\u0435 \u043D\u0430\u0441: \u043A\u043B\u044E\u0447, \u0430\u043A\u043A\u0430\u0443\u043D\u0442 \u0438\u043B\u0438 \u0440\u0435\u0433\u0438\u043E\u043D'+E(since)+'. \u0421\u0430\u043C\u043E \u043D\u0435 \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u2014 \u043F\u0440\u043E\u0432\u0435\u0440\u044C \u0432\u0445\u043E\u0434 \u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044F (swarm doctor).</div></div>';
|
|
18538
18970
|
b.hidden=false; return; }
|
|
18539
18971
|
var frozen = st.dead ? st.dead+' '+plural(st.dead,DRONEW)+' \u0432 \u043A\u043E\u043A\u043E\u043D\u0435' : '\u043D\u043E\u0432\u044B\u0445 \u0434\u0440\u043E\u043D\u043E\u0432 \u043D\u0435 \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0435\u043C';
|
|
18540
|
-
b.innerHTML='<span class="sb-ico">\u26A1</span><div class="sb-body"><div class="sb-t">\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014
|
|
18972
|
+
b.innerHTML='<span class="sb-ico">\u26A1</span><div class="sb-body"><div class="sb-t">\u041F\u0441\u0438\u043E\u043D\u043D\u0430\u044F \u0441\u0432\u044F\u0437\u044C \u043F\u043E\u0442\u0435\u0440\u044F\u043D\u0430 \u2014 \u043F\u0440\u043E\u0432\u0430\u0439\u0434\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442</div>'+
|
|
18541
18973
|
'<div class="sb-d">\u0420\u043E\u0439 \u0437\u0430\u043C\u0435\u0440, \u0434\u0440\u043E\u043D\u044B \u0432 \u043A\u043E\u043A\u043E\u043D\u0430\u0445 \u2014 '+E(frozen)+', \u043E\u0447\u0435\u0440\u0435\u0434\u044C \u043A\u043E\u043F\u0438\u0442\u0441\u044F'+E(since)+'. \u041F\u043E\u0434\u043D\u0438\u043C\u0435\u0442\u0441\u044F \u0441\u0430\u043C, \u043A\u0430\u043A \u0441\u0432\u044F\u0437\u044C \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F.</div></div>';
|
|
18542
18974
|
b.hidden=false; }
|
|
18543
18975
|
/* \u041F\u0430\u043D\u0435\u043B\u044C \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432 \u043C\u0430\u0448\u0438\u043D\u044B-\u0445\u043E\u0441\u0442\u0430 (TASWM-214 \u0424\u0430\u0437\u0430 2): CPU/RAM + \u0441\u0442\u0430\u0442\u0443\u0441 \u0440\u0435\u0441\u0443\u0440\u0441-\u0433\u0435\u0439\u0442\u0430 \u0441\u043B\u043E\u0432\u0430\u043C\u0438. */
|
|
@@ -18944,14 +19376,14 @@ function closeWebServer(server) {
|
|
|
18944
19376
|
|
|
18945
19377
|
// src/hostCommands.ts
|
|
18946
19378
|
init_src();
|
|
18947
|
-
import { readFileSync as
|
|
18948
|
-
import { join as
|
|
19379
|
+
import { readFileSync as readFileSync26, renameSync as renameSync10, writeFileSync as writeFileSync17 } from "fs";
|
|
19380
|
+
import { join as join37 } from "path";
|
|
18949
19381
|
function hostCommandStatePath(home) {
|
|
18950
|
-
return
|
|
19382
|
+
return join37(home, "host-command.json");
|
|
18951
19383
|
}
|
|
18952
19384
|
function readState(path) {
|
|
18953
19385
|
try {
|
|
18954
|
-
return JSON.parse(
|
|
19386
|
+
return JSON.parse(readFileSync26(path, "utf8"));
|
|
18955
19387
|
} catch {
|
|
18956
19388
|
return {};
|
|
18957
19389
|
}
|
|
@@ -19122,7 +19554,7 @@ async function doRestart(cmd, opts, note) {
|
|
|
19122
19554
|
// src/selfUpdate.ts
|
|
19123
19555
|
init_git();
|
|
19124
19556
|
import { existsSync as existsSync21 } from "fs";
|
|
19125
|
-
import { join as
|
|
19557
|
+
import { join as join38 } from "path";
|
|
19126
19558
|
import { $ as $5 } from "execa";
|
|
19127
19559
|
|
|
19128
19560
|
// src/cliIo.ts
|
|
@@ -19184,7 +19616,7 @@ async function runSelfUpdate(io) {
|
|
|
19184
19616
|
};
|
|
19185
19617
|
}
|
|
19186
19618
|
await io.onStep("install", "\u0441\u0442\u0430\u0432\u043B\u044E \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438");
|
|
19187
|
-
if (!exists(
|
|
19619
|
+
if (!exists(join38(repo, "pnpm-lock.yaml"))) {
|
|
19188
19620
|
return { ok: false, step: "install", message: "\u0432 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u0434\u0435\u043C\u043E\u043D\u0430 \u043D\u0435\u0442 pnpm-lock.yaml \u2014 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0442\u044C \u0435\u0433\u043E \u044D\u0442\u0438\u043C \u043F\u0443\u0442\u0451\u043C \u043D\u0435 \u0431\u0435\u0440\u0443\u0441\u044C" };
|
|
19189
19621
|
}
|
|
19190
19622
|
const installed2 = await run2("pnpm", ["install", "--frozen-lockfile"], repo);
|
|
@@ -19292,7 +19724,7 @@ function orphanNoteText(run2, q) {
|
|
|
19292
19724
|
// src/probe.ts
|
|
19293
19725
|
init_executors();
|
|
19294
19726
|
import { spawn as spawn3 } from "child_process";
|
|
19295
|
-
var
|
|
19727
|
+
var RESET_RE2 = /resets[^\n]*/i;
|
|
19296
19728
|
function executorHealthy(opts = {}) {
|
|
19297
19729
|
const executor = opts.executor ?? resolveExecutor();
|
|
19298
19730
|
const bin = opts.bin ?? executor.resolveBin();
|
|
@@ -19325,11 +19757,14 @@ function executorHealthy(opts = {}) {
|
|
|
19325
19757
|
child.on("close", (code) => {
|
|
19326
19758
|
if (code === 0) return finish({ ok: true, reason: "ok", resetHint: null });
|
|
19327
19759
|
if (executor.probe.limitPattern.test(out)) {
|
|
19328
|
-
return finish({ ok: false, reason: "limit", resetHint: out.match(
|
|
19760
|
+
return finish({ ok: false, reason: "limit", resetHint: out.match(RESET_RE2)?.[0]?.trim() ?? null });
|
|
19329
19761
|
}
|
|
19330
19762
|
if (executor.probe.authPattern?.test(out)) {
|
|
19331
19763
|
return finish({ ok: false, reason: "auth", resetHint: null });
|
|
19332
19764
|
}
|
|
19765
|
+
if (executor.probe.okFromOutput?.(out, code) === true) {
|
|
19766
|
+
return finish({ ok: true, reason: "ok", resetHint: null });
|
|
19767
|
+
}
|
|
19333
19768
|
finish({ ok: false, reason: "provider", resetHint: null });
|
|
19334
19769
|
});
|
|
19335
19770
|
});
|
|
@@ -19355,19 +19790,19 @@ async function fetchExternalStorm(url, opts = {}) {
|
|
|
19355
19790
|
}
|
|
19356
19791
|
|
|
19357
19792
|
// src/anomalyState.ts
|
|
19358
|
-
import { existsSync as existsSync22, readFileSync as
|
|
19359
|
-
import { join as
|
|
19793
|
+
import { existsSync as existsSync22, readFileSync as readFileSync27, renameSync as renameSync11, writeFileSync as writeFileSync18 } from "fs";
|
|
19794
|
+
import { join as join39 } from "path";
|
|
19360
19795
|
var KEY_TTL_MS = 7 * 24 * 60 * 6e4;
|
|
19361
19796
|
var MAX_RESOLVED = 200;
|
|
19362
19797
|
function emptyState() {
|
|
19363
19798
|
return { since: {}, lastFiredAt: {}, fires: {}, resolved: [], stopQuiet: null };
|
|
19364
19799
|
}
|
|
19365
19800
|
function anomalyStatePath(home) {
|
|
19366
|
-
return
|
|
19801
|
+
return join39(home, "anomaly-state.json");
|
|
19367
19802
|
}
|
|
19368
19803
|
function loadAnomalyState(home, now = Date.now(), io = {}) {
|
|
19369
19804
|
const exists = io.exists ?? existsSync22;
|
|
19370
|
-
const readFile2 = io.readFile ?? ((p) =>
|
|
19805
|
+
const readFile2 = io.readFile ?? ((p) => readFileSync27(p, "utf8"));
|
|
19371
19806
|
const path = anomalyStatePath(home);
|
|
19372
19807
|
if (!exists(path)) return emptyState();
|
|
19373
19808
|
try {
|
|
@@ -20848,10 +21283,10 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
|
|
|
20848
21283
|
}
|
|
20849
21284
|
return parts.join("\n");
|
|
20850
21285
|
}
|
|
20851
|
-
var HERO_CHARTER_PATH =
|
|
21286
|
+
var HERO_CHARTER_PATH = join40(dirname6(THIS_FILE), "..", "docs", "HERO.md");
|
|
20852
21287
|
function buildHeroPrompt(task, run2, taskContext, attachmentsBlock) {
|
|
20853
21288
|
const name = run2.name || `#${run2.id}`;
|
|
20854
|
-
const charter =
|
|
21289
|
+
const charter = readFileSync28(HERO_CHARTER_PATH, "utf8");
|
|
20855
21290
|
const head = task ? `\u042D\u041F\u0418\u041A ${run2.task_slug}: ${task.title}
|
|
20856
21291
|
|
|
20857
21292
|
${task.description}` : `\u042D\u041F\u0418\u041A ${run2.task_slug} (\u0442\u0435\u043B\u043E \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u2014 \u0440\u0430\u0431\u043E\u0442\u0430\u0439 \u043F\u043E slug \u0438 \u0437\u0434\u0440\u0430\u0432\u043E\u043C\u0443 \u0441\u043C\u044B\u0441\u043B\u0443).`;
|
|
@@ -20911,9 +21346,9 @@ function ciTrustLine(prUrl, verifyMode, ciClosed = null) {
|
|
|
20911
21346
|
}
|
|
20912
21347
|
return `\u041D\u0435 \u043F\u0435\u0440\u0435\u0433\u043E\u043D\u044F\u0439 \u0442\u0435\u0441\u0442-\u0441\u044C\u044E\u0442/typecheck \u0437\u0430\u043D\u043E\u0432\u043E \u2014 \u044D\u0442\u043E \u0443\u0436\u0435 \u0441\u0434\u0435\u043B\u0430\u043B CI \u043D\u0430 \u044D\u0442\u043E\u043C \u0436\u0435 \u043A\u043E\u043C\u043C\u0438\u0442\u0435 (\u0434\u0432\u043E\u0439\u043D\u043E\u0439 \u043F\u0440\u043E\u0433\u043E\u043D \u043D\u0430 \u043C\u0430\u0448\u0438\u043D\u0435 \u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0430 \u043E\u0442\u043C\u0435\u043D\u0451\u043D, TASWM-249). \u041F\u0440\u043E\u0447\u0438\u0442\u0430\u0439 \u0435\u0433\u043E \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442 \u0441\u0430\u043C: ${readChecks}. \u0414\u0430\u043B\u044C\u0448\u0435 \u0442\u0440\u0438 \u0440\u0430\u0437\u043D\u044B\u0445 \u0441\u043B\u0443\u0447\u0430\u044F: \u2460 \u0445\u043E\u0442\u044C \u043E\u0434\u0438\u043D \u0447\u0435\u043A \u0435\u0449\u0451 PENDING \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u043E\u043E\u0431\u0449\u0435 \u043D\u0435 \u0432\u044B\u043D\u043E\u0441\u0438: \u043D\u0435 \u043F\u043E\u0441\u0442\u0438 REQUEST CHANGES, \u043D\u0435 \u0437\u043E\u0432\u0438 done(), \u043F\u0440\u043E\u0441\u0442\u043E \u0437\u0430\u0432\u0435\u0440\u0448\u0438 \u0441\u0435\u0441\u0441\u0438\u044E \u043A\u0430\u043A \u0435\u0441\u0442\u044C \u2014 \u0440\u043E\u0439 \u0441\u0430\u043C \u0437\u0430\u043C\u0435\u0442\u0438\u0442, \u0447\u0442\u043E \u0442\u044B \u0436\u0434\u0451\u0448\u044C CI, \u0438 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u0442 \u0434\u043E\u0434\u0435\u043B\u0430\u0442\u044C \u0440\u0435\u0432\u044C\u044E, \u043A\u043E\u0433\u0434\u0430 \u0432\u0441\u0435 \u0447\u0435\u043A\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u0441\u044F (\u044D\u0442\u043E \u0448\u0442\u0430\u0442\u043D\u044B\u0439 \u043F\u0443\u0442\u044C, \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 \u0437\u0432\u0430\u0442\u044C \u043D\u0435 \u043D\u0443\u0436\u043D\u043E). \u2461 \u0432\u0441\u0435 \u0447\u0435\u043A\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0438\u0441\u044C \u0438 \u0435\u0441\u0442\u044C FAIL \u2014 REQUEST CHANGES, \u043D\u0430\u0437\u043E\u0432\u0438 \u043F\u043E\u0438\u043C\u0451\u043D\u043D\u043E, \u0447\u0442\u043E \u0443\u043F\u0430\u043B\u043E. \u2462 \u043D\u0430 \u044D\u0442\u043E\u043C \u043A\u043E\u043C\u043C\u0438\u0442\u0435 \u0447\u0435\u043A\u043E\u0432 \u043D\u0435\u0442 \u0432\u043E\u0432\u0441\u0435 \u2014 \u0442\u043E \u0436\u0435, \u0447\u0442\u043E \u2460: \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u043D\u0435 \u0432\u044B\u043D\u043E\u0441\u0438, \u043D\u0435 \u043F\u0438\u0448\u0438 REQUEST CHANGES, \u043D\u0435 \u0437\u043E\u0432\u0438 done(), \u043F\u0440\u043E\u0441\u0442\u043E \u0437\u0430\u0432\u0435\u0440\u0448\u0438 \u0441\u0435\u0441\u0441\u0438\u044E. \u0427\u0435\u043A\u043E\u0432 \u043C\u043E\u0436\u0435\u0442 \u043D\u0435 \u0431\u044B\u0442\u044C, \u043F\u043E\u0442\u043E\u043C\u0443 \u0447\u0442\u043E \u0441\u0442\u0430\u0440\u044B\u0439 \u043F\u0440\u043E\u0433\u043E\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0442\u043E \u043E\u0442\u043C\u0435\u043D\u0451\u043D \u043D\u043E\u0432\u044B\u043C \u043F\u0443\u0448\u0435\u043C \u0438\u043B\u0438 \u0440\u0430\u043D\u043D\u0435\u0440\u044B \u0437\u0430\u043D\u044F\u0442\u044B. \u0420\u043E\u0439 \u0441\u0430\u043C \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u0442, \u043A\u043E\u0433\u0434\u0430 \u0447\u0435\u043A\u0438 \u043F\u043E\u044F\u0432\u044F\u0442\u0441\u044F \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u0441\u044F, \u0438\u043B\u0438 \u0441\u043A\u0430\u0436\u0435\u0442, \u0447\u0442\u043E \u0438\u0445 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442. ${dontTrustAuthor}`;
|
|
20913
21348
|
}
|
|
20914
|
-
var REVIEW_SKILL_PATH =
|
|
21349
|
+
var REVIEW_SKILL_PATH = join40(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
|
|
20915
21350
|
function reviewDefectClasses(skillPath = REVIEW_SKILL_PATH) {
|
|
20916
|
-
const text =
|
|
21351
|
+
const text = readFileSync28(skillPath, "utf8");
|
|
20917
21352
|
const m = /^## Классы дефектов\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(text);
|
|
20918
21353
|
if (!m) throw new Error(`${skillPath}: \u043D\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043B\u0430 \xAB## \u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432\xBB \u2014 \u0444\u043E\u0440\u043C\u0430\u0442 skill taskless-review \u043F\u043E\u043C\u0435\u043D\u044F\u043B\u0441\u044F?`);
|
|
20919
21354
|
return `\u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 (skill taskless-review):
|
|
@@ -21106,6 +21541,47 @@ function narrate(deps, text) {
|
|
|
21106
21541
|
} catch {
|
|
21107
21542
|
}
|
|
21108
21543
|
}
|
|
21544
|
+
function stormProviderName(deps) {
|
|
21545
|
+
try {
|
|
21546
|
+
return deps.storm?.providerName?.() ?? "\u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C";
|
|
21547
|
+
} catch {
|
|
21548
|
+
return "\u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C";
|
|
21549
|
+
}
|
|
21550
|
+
}
|
|
21551
|
+
function stormAnomalyCandidates(deps, now) {
|
|
21552
|
+
if (!deps.storm || !deps.db.stormActive()) return [];
|
|
21553
|
+
const startedAt = deps.db.currentStormStartedAt();
|
|
21554
|
+
if (!startedAt) return [];
|
|
21555
|
+
const startedAtMs = sqliteMs(startedAt);
|
|
21556
|
+
const cfg = resolveStormConfig(deps.storm.config);
|
|
21557
|
+
const recs = deps.db.stormProbeRecordsSince(startedAt);
|
|
21558
|
+
const failed = [...recs].reverse().find((rec) => rec.probe === false && rec.reason != null && rec.reason !== "ok");
|
|
21559
|
+
const reason = failed?.reason;
|
|
21560
|
+
const providerName = stormProviderName(deps);
|
|
21561
|
+
const hostName = deps.storm.hostName ?? "\u041C\u0430\u0448\u0438\u043D\u0430";
|
|
21562
|
+
return [
|
|
21563
|
+
{
|
|
21564
|
+
key: `storm_long:${startedAt}`,
|
|
21565
|
+
// Порог целиком, не остаток до него. AnomalyTracker копит minDurationMs
|
|
21566
|
+
// с первого появления ключа (тик старта шторма). Вычитание elapsed
|
|
21567
|
+
// сравнивало остаток с уже накопленным временем и слало письмо на
|
|
21568
|
+
// notifyMs/2: к 15-й минуте остаток 15 мин уже не меньше since.
|
|
21569
|
+
minDurationMs: cfg.notifyMs,
|
|
21570
|
+
once: true,
|
|
21571
|
+
build: () => ({
|
|
21572
|
+
level: "decision",
|
|
21573
|
+
title: `${hostName}: \u0440\u043E\u0439 \u0441\u0442\u043E\u0438\u0442 \u0432 \u0434\u043E\u043B\u0433\u043E\u043C \u0448\u0442\u043E\u0440\u043C\u0435`,
|
|
21574
|
+
body: stormLongText({
|
|
21575
|
+
hostName,
|
|
21576
|
+
startedAtMs,
|
|
21577
|
+
now,
|
|
21578
|
+
providerName,
|
|
21579
|
+
reason: reason === "limit" || reason === "auth" || reason === "exec" || reason === "provider" ? reason : "provider"
|
|
21580
|
+
})
|
|
21581
|
+
})
|
|
21582
|
+
}
|
|
21583
|
+
];
|
|
21584
|
+
}
|
|
21109
21585
|
async function manageStorm(deps, now, worktreeExists, hasTranscript) {
|
|
21110
21586
|
const db = deps.db;
|
|
21111
21587
|
const s = deps.storm;
|
|
@@ -21141,8 +21617,8 @@ async function manageStorm(deps, now, worktreeExists, hasTranscript) {
|
|
|
21141
21617
|
};
|
|
21142
21618
|
if (!stormShouldStart(signals, cfg)) return false;
|
|
21143
21619
|
if (signals.externalDown) {
|
|
21144
|
-
db.startStorm(stormStartReason(signals, cfg));
|
|
21145
|
-
narrate(deps,
|
|
21620
|
+
db.startStorm(stormStartReason(signals, cfg, stormProviderName(deps)));
|
|
21621
|
+
narrate(deps, `${stormProviderName(deps)} \u043B\u0435\u0436\u0438\u0442 \u2014 \u0440\u043E\u0439 \u0443\u0445\u043E\u0434\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C, \u043F\u0430\u0443\u0437\u044E \u0441\u043F\u0430\u0432\u043D\u044B \u0438 \u0441\u043B\u0435\u0436\u0443 \u0437\u0430 \u043E\u0442\u0431\u043E\u0435\u043C.`);
|
|
21146
21622
|
return true;
|
|
21147
21623
|
}
|
|
21148
21624
|
const lastEndMs = db.lastStormEndedAt();
|
|
@@ -21169,18 +21645,18 @@ async function manageStorm(deps, now, worktreeExists, hasTranscript) {
|
|
|
21169
21645
|
if (!fresh) healthyDeathsAlert(deps, signals, cfg);
|
|
21170
21646
|
return false;
|
|
21171
21647
|
}
|
|
21172
|
-
db.startStorm(stormStartReason(signals, cfg));
|
|
21173
|
-
narrate(deps,
|
|
21648
|
+
db.startStorm(stormStartReason(signals, cfg, stormProviderName(deps)));
|
|
21649
|
+
narrate(deps, `${stormProviderName(deps)} \u043B\u0435\u0436\u0438\u0442 (\u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u043E \u043A\u0440\u0430\u0441\u043D\u043E\u0439 health-probe) \u2014 \u0440\u043E\u0439 \u0443\u0445\u043E\u0434\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C, \u043F\u0430\u0443\u0437\u044E \u0441\u043F\u0430\u0432\u043D\u044B \u0438 \u0441\u043B\u0435\u0436\u0443 \u0437\u0430 \u043E\u0442\u0431\u043E\u0435\u043C.`);
|
|
21174
21650
|
return true;
|
|
21175
21651
|
}
|
|
21176
21652
|
function healthyDeathsAlert(deps, signals, cfg) {
|
|
21177
|
-
const why = stormStartReason(signals, cfg).split(" \u2014 ")[1] ?? "\u044D\u0432\u0440\u0438\u0441\u0442\u0438\u043A\u0430";
|
|
21653
|
+
const why = stormStartReason(signals, cfg, stormProviderName(deps)).split(" \u2014 ")[1] ?? "\u044D\u0432\u0440\u0438\u0441\u0442\u0438\u043A\u0430";
|
|
21178
21654
|
try {
|
|
21179
21655
|
deps.db.addEvent(null, "anomaly", `${STORM_HEALTHY_DEATHS_TEXT} (${why})`);
|
|
21180
21656
|
} catch (e) {
|
|
21181
21657
|
console.error("[overmind] \u0448\u0442\u043E\u0440\u043C: \u0430\u043B\u0451\u0440\u0442 \xAB\u0434\u0440\u043E\u043D\u044B \u043C\u0440\u0443\u0442 \u043F\u0440\u0438 \u0436\u0438\u0432\u043E\u043C API\xBB \u043D\u0435 \u0437\u0430\u043F\u0438\u0441\u0430\u043B\u0441\u044F:", e);
|
|
21182
21658
|
}
|
|
21183
|
-
narrate(deps, `\u0414\u0440\u043E\u043D\u044B \u043E\u0442\u0432\u0430\u043B\u0438\u0432\u0430\u044E\u0442\u0441\u044F (${why}), \u043D\u043E health-probe \u0437\u0435\u043B\u0451\u043D\u0430\u044F \u2014 \u044D\u0442\u043E \u041D\u0415
|
|
21659
|
+
narrate(deps, `\u0414\u0440\u043E\u043D\u044B \u043E\u0442\u0432\u0430\u043B\u0438\u0432\u0430\u044E\u0442\u0441\u044F (${why}), \u043D\u043E health-probe \u0437\u0435\u043B\u0451\u043D\u0430\u044F \u2014 \u044D\u0442\u043E \u041D\u0415 \u0441\u0431\u043E\u0439 ${stormProviderName(deps)}, \u0432 \u0448\u0442\u043E\u0440\u043C \u043D\u0435 \u0443\u0445\u043E\u0436\u0443.`);
|
|
21184
21660
|
}
|
|
21185
21661
|
async function resurrectStormDead(deps, worktreeExists, hasTranscript, opts) {
|
|
21186
21662
|
if (!deps.respawn) return 0;
|
|
@@ -21497,9 +21973,9 @@ function repoHasCi(deps, run2) {
|
|
|
21497
21973
|
function repoHasCiWorkflows(worktreePath, repo) {
|
|
21498
21974
|
for (const base3 of [worktreePath, repo]) {
|
|
21499
21975
|
if (!base3) continue;
|
|
21500
|
-
const dir =
|
|
21976
|
+
const dir = join40(base3, ".github", "workflows");
|
|
21501
21977
|
try {
|
|
21502
|
-
if (
|
|
21978
|
+
if (readdirSync18(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
|
|
21503
21979
|
} catch {
|
|
21504
21980
|
}
|
|
21505
21981
|
}
|
|
@@ -21726,6 +22202,9 @@ function worktreeAndTranscriptAlive(deps, run2) {
|
|
|
21726
22202
|
const wt = run2.worktree_path;
|
|
21727
22203
|
return !!wt && exists(wt) && transcript(run2);
|
|
21728
22204
|
}
|
|
22205
|
+
function limitWaitCandidate(deps, run2) {
|
|
22206
|
+
return deps.exitLimit?.(run2) ?? null;
|
|
22207
|
+
}
|
|
21729
22208
|
async function projectWantsChecks(deps, run2) {
|
|
21730
22209
|
if (!deps.autoReviewForRepo) return true;
|
|
21731
22210
|
return await deps.autoReviewForRepo(effectiveRepo(deps, run2), run2.task_slug).catch((e) => {
|
|
@@ -22002,7 +22481,7 @@ async function zoneConflictFor(db, models, activeFiles, run2, repo, repoFallback
|
|
|
22002
22481
|
activeFiles.prune(holders.map((r) => r.id));
|
|
22003
22482
|
const fileExists = (p) => {
|
|
22004
22483
|
try {
|
|
22005
|
-
return
|
|
22484
|
+
return statSync16(join40(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
|
|
22006
22485
|
} catch {
|
|
22007
22486
|
return false;
|
|
22008
22487
|
}
|
|
@@ -22643,6 +23122,46 @@ function logCapacity(own, live2, hostOverride, operatorLimit) {
|
|
|
22643
23122
|
lastCapacityLine = line;
|
|
22644
23123
|
console.log(`[overmind] ${line}`);
|
|
22645
23124
|
}
|
|
23125
|
+
var LIMIT_RESUME_RETRY_MS = 30 * 6e4;
|
|
23126
|
+
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";
|
|
23127
|
+
function lastLimitResumeMs(deps, runId) {
|
|
23128
|
+
const event = deps.db.events(runId).filter((item) => item.kind === "resumed" && item.text === LIMIT_RESUMED_TEXT).at(-1);
|
|
23129
|
+
return event ? stampMs(event.at) : null;
|
|
23130
|
+
}
|
|
23131
|
+
async function resumeLimitWaits(deps, now, droneCap, stormActive) {
|
|
23132
|
+
if (stormActive || !deps.respawn || countActiveDrones(deps.db) >= droneCap) return;
|
|
23133
|
+
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));
|
|
23134
|
+
for (const candidate of candidates) {
|
|
23135
|
+
const capHolder = cycleCapHolder(deps.db, candidate);
|
|
23136
|
+
if (capHolder) {
|
|
23137
|
+
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");
|
|
23138
|
+
continue;
|
|
23139
|
+
}
|
|
23140
|
+
if (!await projectQuotaGateAllows(deps, candidate)) continue;
|
|
23141
|
+
const canContinue = deps.runHasSession ? deps.runHasSession(candidate) : worktreeAndTranscriptAlive(deps, candidate);
|
|
23142
|
+
const mode = canContinue ? "continue" : "fresh";
|
|
23143
|
+
const wt = candidate.worktree_path;
|
|
23144
|
+
if (mode === "continue" && wt && deps.reclaimWorktree) {
|
|
23145
|
+
try {
|
|
23146
|
+
await deps.reclaimWorktree(wt);
|
|
23147
|
+
} catch (e) {
|
|
23148
|
+
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);
|
|
23149
|
+
}
|
|
23150
|
+
}
|
|
23151
|
+
try {
|
|
23152
|
+
await deps.respawn(candidate, mode);
|
|
23153
|
+
deps.db.updateRun(candidate.id, { stop_reason: null });
|
|
23154
|
+
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");
|
|
23155
|
+
deps.db.addEvent(candidate.id, "resumed", LIMIT_RESUMED_TEXT);
|
|
23156
|
+
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.`);
|
|
23157
|
+
} catch (e) {
|
|
23158
|
+
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)}`;
|
|
23159
|
+
deps.db.updateRun(candidate.id, { status: "stalled", stop_reason: reason });
|
|
23160
|
+
deps.db.addEvent(candidate.id, "stalled", reason);
|
|
23161
|
+
}
|
|
23162
|
+
return;
|
|
23163
|
+
}
|
|
23164
|
+
}
|
|
22646
23165
|
async function manageRelief(deps, now, droneCap, stormActive) {
|
|
22647
23166
|
const state = deps.relief ?? (deps.relief = {});
|
|
22648
23167
|
const cfg = state.config ? resolveReliefConfig(state.config) : DEFAULT_RELIEF_CONFIG;
|
|
@@ -23467,11 +23986,14 @@ async function tickOnce(deps) {
|
|
|
23467
23986
|
}
|
|
23468
23987
|
}
|
|
23469
23988
|
if (deps.exitOutcome && endedItself(deps.exitOutcome(run2))) continue;
|
|
23989
|
+
if (limitWaitCandidate(deps, run2)) continue;
|
|
23470
23990
|
deps.db.recordDeath(run2.id, `\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440 (pid ${run2.pid} \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442)`);
|
|
23471
23991
|
}
|
|
23472
23992
|
stormActive = await manageStorm(deps, now, worktreeExists, hasTranscript);
|
|
23473
23993
|
}
|
|
23474
23994
|
const droneCap = deps.maxDrones ? await deps.maxDrones() : Infinity;
|
|
23995
|
+
deps.stepClock?.mark("0e \u0432\u043E\u0437\u0432\u0440\u0430\u0442 \u043F\u043E\u0441\u043B\u0435 \u043B\u0438\u043C\u0438\u0442\u0430");
|
|
23996
|
+
await resumeLimitWaits(deps, now, droneCap, stormActive);
|
|
23475
23997
|
deps.stepClock?.mark("1 \u043F\u043E\u0434\u043D\u044F\u0442\u044C \u043E\u0447\u0435\u0440\u0435\u0434\u044C");
|
|
23476
23998
|
if (stormActive) noteStormStall(deps);
|
|
23477
23999
|
deps.stepClock?.mark("0b \u0432\u0435\u0441 \u0437\u0430\u0434\u0430\u0447\u0438");
|
|
@@ -23804,6 +24326,22 @@ async function tickOnce(deps) {
|
|
|
23804
24326
|
continue;
|
|
23805
24327
|
}
|
|
23806
24328
|
}
|
|
24329
|
+
const limitHit = !alive && run2.status === "running" ? limitWaitCandidate(deps, run2) : null;
|
|
24330
|
+
if (limitHit) {
|
|
24331
|
+
const report = deps.limitsSnapshot?.() ?? null;
|
|
24332
|
+
let resetsAt = limitResetAt({ executor: limitHit.executor, report, resetHint: limitHit.resetHint, nowMs: now });
|
|
24333
|
+
const lastResumeMs = lastLimitResumeMs(deps, run2.id);
|
|
24334
|
+
if (lastResumeMs !== null && now - lastResumeMs < LIMIT_RESUME_RETRY_MS) {
|
|
24335
|
+
resetsAt = new Date(Math.max(Date.parse(resetsAt), now + LIMIT_RESUME_RETRY_MS)).toISOString();
|
|
24336
|
+
}
|
|
24337
|
+
const text = limitWaitText(limitHit.executor, limitWaitWindow(report, limitHit.executor));
|
|
24338
|
+
const resetClock = new Date(resetsAt).toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit" });
|
|
24339
|
+
const stopReason = limitWaitReason({ executor: limitHit.executor, resetsAt, text });
|
|
24340
|
+
deps.db.updateRun(run2.id, { status: "paused", stop_reason: stopReason });
|
|
24341
|
+
deps.db.addEvent(run2.id, "paused", `${text}, \u0441\u0431\u0440\u043E\u0441 \u0432 ${resetClock}`);
|
|
24342
|
+
narrate(deps, `${droneLabel(run2)} ${text.charAt(0).toLowerCase()}${text.slice(1)}, \u0436\u0434\u0443 \u0441\u0431\u0440\u043E\u0441\u0430 \u0432 ${resetClock}`);
|
|
24343
|
+
continue;
|
|
24344
|
+
}
|
|
23807
24345
|
if (stormActive && run2.resolves_run_id == null && run2.reviews_run_id == null) {
|
|
23808
24346
|
if (!alive) {
|
|
23809
24347
|
const priorFreezes = deps.db.events(run2.id).filter((e) => e.kind === "storm_dead").length;
|
|
@@ -23813,7 +24351,7 @@ async function tickOnce(deps) {
|
|
|
23813
24351
|
narrate(deps, `${droneLabel(run2)} \u0446\u0438\u043A\u043B\u0438\u0442 \u0432 \u0448\u0442\u043E\u0440\u043C\u0435 (${STORM_DEAD_LIMIT} \u043A\u043E\u043A\u043E\u043D\u043E\u0432) \u2014 \u0441\u0434\u0430\u044E\u0441\u044C, \u0434\u0430\u043B\u044C\u0448\u0435 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440.`);
|
|
23814
24352
|
} else {
|
|
23815
24353
|
deps.db.updateRun(run2.id, { status: "storm_dead" });
|
|
23816
|
-
deps.db.addEvent(run2.id, "storm_dead",
|
|
24354
|
+
deps.db.addEvent(run2.id, "storm_dead", stormDeadText(stormProviderName(deps)));
|
|
23817
24355
|
}
|
|
23818
24356
|
}
|
|
23819
24357
|
continue;
|
|
@@ -24035,6 +24573,7 @@ async function tickOnce(deps) {
|
|
|
24035
24573
|
for (const run2 of deps.db.listRuns("paused")) {
|
|
24036
24574
|
if (run2.kind === "hero") continue;
|
|
24037
24575
|
if (run2.stop_reason === AWAITING_CI_REASON || isReliefPause(run2.stop_reason)) continue;
|
|
24576
|
+
if (isLimitWait(run2.stop_reason)) continue;
|
|
24038
24577
|
if (isAwaitingBudget(run2.status, run2.stop_reason)) continue;
|
|
24039
24578
|
const last = lastActivityMs(deps.db, run2);
|
|
24040
24579
|
if (now - last <= STALL_FLOOR_MS) continue;
|
|
@@ -24054,6 +24593,7 @@ async function tickOnce(deps) {
|
|
|
24054
24593
|
if (run2.kind === "hero") continue;
|
|
24055
24594
|
if (run2.reviews_run_id != null) continue;
|
|
24056
24595
|
if (isReliefPause(run2.stop_reason)) continue;
|
|
24596
|
+
if (isLimitWait(run2.stop_reason)) continue;
|
|
24057
24597
|
if (NO_AUTO_WAKE_REASONS.some((r) => run2.stop_reason?.startsWith(r))) continue;
|
|
24058
24598
|
if (run2.pid != null && deps.isAlive(run2.pid)) continue;
|
|
24059
24599
|
const capHolder = cycleCapHolder(deps.db, run2);
|
|
@@ -24124,6 +24664,7 @@ async function tickOnce(deps) {
|
|
|
24124
24664
|
...az.startedAt != null ? { daemonStartedAt: az.startedAt } : {}
|
|
24125
24665
|
}),
|
|
24126
24666
|
...buildEscalationCandidates(deps.db),
|
|
24667
|
+
...stormAnomalyCandidates(deps, now),
|
|
24127
24668
|
// ЦЕНА РАЗГРУЗКИ (TASWM-316): «машина не тянет» с числами и рекомендацией — та же
|
|
24128
24669
|
// труба, тот же дедуп «один раз на эпизод». Пустой список при нормальной работе.
|
|
24129
24670
|
...await buildReliefCostCandidatesFor(deps, now, droneCap)
|
|
@@ -24303,7 +24844,7 @@ async function resolveConflict(deps, reviewRun) {
|
|
|
24303
24844
|
model: reviewRun.model,
|
|
24304
24845
|
review_model: reviewRun.review_model
|
|
24305
24846
|
});
|
|
24306
|
-
const wt =
|
|
24847
|
+
const wt = join40(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
|
|
24307
24848
|
try {
|
|
24308
24849
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
24309
24850
|
await deps.git.setWorktreeIdentity(wt, resolver.name);
|
|
@@ -24384,7 +24925,7 @@ async function spawnReviewer(deps, reviewRun, files) {
|
|
|
24384
24925
|
// (своей у ревьюера нет, TASWM-204), и коммент с вердиктом должен уехать именно туда.
|
|
24385
24926
|
workspace_id: reviewRun.workspace_id
|
|
24386
24927
|
});
|
|
24387
|
-
const wt =
|
|
24928
|
+
const wt = join40(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
|
|
24388
24929
|
try {
|
|
24389
24930
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
24390
24931
|
await deps.git.setWorktreeIdentity(wt, reviewer.name);
|
|
@@ -24465,7 +25006,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
|
|
|
24465
25006
|
// штамп цикла: фикс-итерацию проверяет свежий верификатор
|
|
24466
25007
|
workspace_id: verifiedRun.workspace_id
|
|
24467
25008
|
});
|
|
24468
|
-
const wt =
|
|
25009
|
+
const wt = join40(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
|
|
24469
25010
|
try {
|
|
24470
25011
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
24471
25012
|
await deps.git.setWorktreeIdentity(wt, verifier.name);
|
|
@@ -24664,7 +25205,7 @@ async function makeStore(repo, worktreesDir, repoFlag, executorFor) {
|
|
|
24664
25205
|
console.warn(`[overmind] \u043D\u0435 \u0441\u043C\u043E\u0433 \u0437\u0430\u043F\u043E\u043C\u043D\u0438\u0442\u044C \u043F\u0443\u0442\u044C \u043A \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044E (${e instanceof Error ? e.message : e}) \u2014 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u0437\u0430\u043F\u0443\u0441\u043A \u0441\u043D\u043E\u0432\u0430 \u043F\u043E\u043F\u0440\u043E\u0441\u0438\u0442 --repo`);
|
|
24665
25206
|
}
|
|
24666
25207
|
}
|
|
24667
|
-
const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW,
|
|
25208
|
+
const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW, homedir8(), repoPaths);
|
|
24668
25209
|
const repoMap = emptyRepoMapState(scanRootsList);
|
|
24669
25210
|
if (SWARM_BACKEND !== "client") {
|
|
24670
25211
|
const { SwarmDb: SwarmDb2 } = await loadSqlite();
|
|
@@ -24769,7 +25310,7 @@ async function migrateWorktreesAtStartup() {
|
|
|
24769
25310
|
exists: (d) => existsSync23(d),
|
|
24770
25311
|
isNonEmptyDir: (d) => {
|
|
24771
25312
|
try {
|
|
24772
|
-
return
|
|
25313
|
+
return readdirSync18(d).length > 0;
|
|
24773
25314
|
} catch {
|
|
24774
25315
|
return false;
|
|
24775
25316
|
}
|
|
@@ -24796,6 +25337,10 @@ async function reportWorkspaceAccess(tl, db) {
|
|
|
24796
25337
|
console.warn("[overmind] \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u0434\u043E\u0441\u0442\u0443\u043F\u0430 \u043A \u0432\u043E\u0440\u043A\u0441\u043F\u0435\u0439\u0441\u0430\u043C \u043D\u0435 \u0443\u0434\u0430\u043B\u0430\u0441\u044C (\u043D\u0435 \u0431\u043B\u043E\u043A\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0430\u0440\u0442):", e);
|
|
24797
25338
|
}
|
|
24798
25339
|
}
|
|
25340
|
+
var modelLimitsPoller = null;
|
|
25341
|
+
function lastModelLimits() {
|
|
25342
|
+
return modelLimitsPoller?.report() ?? null;
|
|
25343
|
+
}
|
|
24799
25344
|
async function runDaemon(opts) {
|
|
24800
25345
|
installCrashGuards();
|
|
24801
25346
|
installLogStamps();
|
|
@@ -24946,6 +25491,7 @@ async function runDaemon(opts) {
|
|
|
24946
25491
|
};
|
|
24947
25492
|
const tickIntervalMs = opts.intervalMs ?? 4e3;
|
|
24948
25493
|
const tickHealth = initialTickHealth(Date.now());
|
|
25494
|
+
modelLimitsPoller = createModelLimitsPoller({ installed: () => cachedInstalledExecutorIds() });
|
|
24949
25495
|
let heartbeat;
|
|
24950
25496
|
if (SWARM_BACKEND === "client" && db instanceof SwarmClient && SWARM_PROD_HEARTBEAT_MS > 0) {
|
|
24951
25497
|
const client = db;
|
|
@@ -24953,6 +25499,7 @@ async function runDaemon(opts) {
|
|
|
24953
25499
|
push: async () => {
|
|
24954
25500
|
const stormActive = client.stormActive();
|
|
24955
25501
|
const stormStartedAt = stormActive ? client.currentStormStartedAt() : null;
|
|
25502
|
+
modelLimitsPoller?.maybePoll();
|
|
24956
25503
|
const reply = await client.heartbeat(
|
|
24957
25504
|
daemonVersion?.get() ?? null,
|
|
24958
25505
|
control.state ?? null,
|
|
@@ -24977,7 +25524,8 @@ async function runDaemon(opts) {
|
|
|
24977
25524
|
tickPulse(tickHealth, Date.now(), tickIntervalMs),
|
|
24978
25525
|
// TASWM-592: установленные агенты машины — справочник для парка машин.
|
|
24979
25526
|
cachedInstalledExecutorIds(),
|
|
24980
|
-
availableProviders(cachedInstalledExecutorIds())
|
|
25527
|
+
availableProviders(cachedInstalledExecutorIds()),
|
|
25528
|
+
modelLimitsPoller?.report() ?? null
|
|
24981
25529
|
);
|
|
24982
25530
|
if (reply.maxDrones !== void 0) operatorMaxDrones = reply.maxDrones;
|
|
24983
25531
|
if (reply.commands.length) onHostCommands(reply.commands);
|
|
@@ -25431,6 +25979,13 @@ async function runDaemon(opts) {
|
|
|
25431
25979
|
exitOutcome: makeExitClassifier(RUN_LOGS_DIR, (runId) => db.runLogKeys(runId), (run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null)),
|
|
25432
25980
|
// TASWM-487: вид обрыва — из того же result-файла и теми же ключами каталога.
|
|
25433
25981
|
exitAbort: makeAbortReader(RUN_LOGS_DIR, (runId) => db.runLogKeys(runId), (run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null)),
|
|
25982
|
+
exitLimit: makeLimitReader(
|
|
25983
|
+
RUN_LOGS_DIR,
|
|
25984
|
+
(runId) => db.runLogKeys(runId),
|
|
25985
|
+
(run2) => executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null),
|
|
25986
|
+
lastModelLimits
|
|
25987
|
+
),
|
|
25988
|
+
limitsSnapshot: lastModelLimits,
|
|
25434
25989
|
// TASWM-487: жива ли работа на origin. Тот же фолбэк repo, что у removeWorktree выше:
|
|
25435
25990
|
// у прогона в основном репозитории демона run.repo пуст.
|
|
25436
25991
|
branchOnOrigin: (repo, branch) => remoteBranchExists(repo || opts.repo, branch),
|
|
@@ -25635,6 +26190,7 @@ async function runDaemon(opts) {
|
|
|
25635
26190
|
startedAt: Date.now(),
|
|
25636
26191
|
// TASWM-592: run-aware — где лежит сессия, знает харнесс ПРОГОНА.
|
|
25637
26192
|
hasTranscript: (run2) => !!run2.worktree_path && executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null).session.exists(run2.worktree_path),
|
|
26193
|
+
runHasSession: (run2) => !!run2.worktree_path && existsSync23(run2.worktree_path) && executorForRun(run2, lastSwarmModels, process.env, runModelRefPin.get(run2.id) ?? null).session.exists(run2.worktree_path),
|
|
25638
26194
|
// CI-осведомлённость review-PR (TASWM-102): реальный `gh pr checks`/`gh run view --log-failed`
|
|
25639
26195
|
// (gh.ts) — решение (будить ли дрона) и гейты живут в tickOnce/handleCiRed. failureSummary
|
|
25640
26196
|
// строится над failing/failingRunIds ИЗ checks — без повторного `gh pr checks`.
|
|
@@ -25645,6 +26201,8 @@ async function runDaemon(opts) {
|
|
|
25645
26201
|
// Штормовой режим (TASWM-23): health-probe на отбой (реальный claude) + внешний
|
|
25646
26202
|
// сигнал SWARM_STORM_URL (2-й слой, если задан). Логика/пороги — в manageStorm/storm.ts.
|
|
25647
26203
|
storm: {
|
|
26204
|
+
providerName: () => executorLimitLabel(executorForRun({ kind: "drone" }, lastSwarmModels).id).short,
|
|
26205
|
+
hostName: host.hostName,
|
|
25648
26206
|
// TASWM-592: проба бьёт в исполнителя, на котором работают дроны (реестр провайдеров
|
|
25649
26207
|
// по ссылке модели роя), — иначе рой на другом харнессе штормовал бы по вине claude
|
|
25650
26208
|
// и наоборот.
|
|
@@ -26207,6 +26765,7 @@ export {
|
|
|
26207
26765
|
hasPreparingRuns,
|
|
26208
26766
|
isSubrun,
|
|
26209
26767
|
lastChangesSummary,
|
|
26768
|
+
lastModelLimits,
|
|
26210
26769
|
lastVerifySummary,
|
|
26211
26770
|
listDroneProcesses,
|
|
26212
26771
|
livePpids,
|