@taskless-app/swarm 0.6.88 → 0.6.90
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 +209 -52
- package/dist/overmind.js +423 -100
- package/package.json +2 -2
package/dist/overmind.js
CHANGED
|
@@ -1657,8 +1657,8 @@ var init_taskWeight = __esm({
|
|
|
1657
1657
|
function hasZoneModel(m) {
|
|
1658
1658
|
return m.tasks > 0 && m.zones.length > 0;
|
|
1659
1659
|
}
|
|
1660
|
-
function testFileFeature(
|
|
1661
|
-
const head =
|
|
1660
|
+
function testFileFeature(basename8) {
|
|
1661
|
+
const head = basename8.replace(/\.(test|spec)\.[a-z]+$/i, "").split(".")[0].toLowerCase();
|
|
1662
1662
|
return head && !GENERIC_DIRS.has(head) ? head : null;
|
|
1663
1663
|
}
|
|
1664
1664
|
function pathZoneCandidate(path) {
|
|
@@ -3409,8 +3409,8 @@ function liveDefaultModel(providerId) {
|
|
|
3409
3409
|
return live.get(providerId) ?? null;
|
|
3410
3410
|
}
|
|
3411
3411
|
function run(bin, args, timeoutMs) {
|
|
3412
|
-
return new Promise((
|
|
3413
|
-
execFile(bin, args, { timeout: timeoutMs, encoding: "utf8" }, (err, stdout) => err ? reject(err) :
|
|
3412
|
+
return new Promise((resolve6, reject) => {
|
|
3413
|
+
execFile(bin, args, { timeout: timeoutMs, encoding: "utf8" }, (err, stdout) => err ? reject(err) : resolve6(stdout));
|
|
3414
3414
|
});
|
|
3415
3415
|
}
|
|
3416
3416
|
async function refreshLiveModels(env = process.env, exec = run) {
|
|
@@ -4826,6 +4826,19 @@ var init_netTimeout = __esm({
|
|
|
4826
4826
|
}
|
|
4827
4827
|
});
|
|
4828
4828
|
|
|
4829
|
+
// src/dockerCli.ts
|
|
4830
|
+
function dockerCli(args) {
|
|
4831
|
+
return impl(args);
|
|
4832
|
+
}
|
|
4833
|
+
var impl;
|
|
4834
|
+
var init_dockerCli = __esm({
|
|
4835
|
+
"src/dockerCli.ts"() {
|
|
4836
|
+
"use strict";
|
|
4837
|
+
init_quietExec();
|
|
4838
|
+
impl = (args) => execQuiet("docker", args);
|
|
4839
|
+
}
|
|
4840
|
+
});
|
|
4841
|
+
|
|
4829
4842
|
// src/procList.ts
|
|
4830
4843
|
import { readFileSync as readFileSync16 } from "fs";
|
|
4831
4844
|
function parsePsRows(out) {
|
|
@@ -4970,8 +4983,10 @@ var init_procList = __esm({
|
|
|
4970
4983
|
});
|
|
4971
4984
|
|
|
4972
4985
|
// src/procCleanup.ts
|
|
4986
|
+
import { homedir as homedir6 } from "os";
|
|
4987
|
+
import { isAbsolute as isAbsolute2, resolve as resolve3, sep } from "path";
|
|
4973
4988
|
function sleep(ms) {
|
|
4974
|
-
return new Promise((
|
|
4989
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
4975
4990
|
}
|
|
4976
4991
|
function parseLsofCwd(output) {
|
|
4977
4992
|
const rows = [];
|
|
@@ -5099,33 +5114,218 @@ function containerBelongsToPrefix(name, prefix) {
|
|
|
5099
5114
|
function findOrphanContainers(containerNames, runs) {
|
|
5100
5115
|
const orphans = [];
|
|
5101
5116
|
for (const name of containerNames) {
|
|
5102
|
-
let
|
|
5117
|
+
let bestLen = -1;
|
|
5118
|
+
let anyActive = false;
|
|
5103
5119
|
for (const r of runs) {
|
|
5104
5120
|
if (!containerBelongsToPrefix(name, r.prefix)) continue;
|
|
5105
|
-
if (
|
|
5121
|
+
if (r.prefix.length < bestLen) continue;
|
|
5122
|
+
if (r.prefix.length > bestLen) {
|
|
5123
|
+
bestLen = r.prefix.length;
|
|
5124
|
+
anyActive = false;
|
|
5125
|
+
}
|
|
5126
|
+
if (r.active) anyActive = true;
|
|
5106
5127
|
}
|
|
5107
|
-
if (
|
|
5128
|
+
if (bestLen >= 0 && !anyActive) orphans.push(name);
|
|
5108
5129
|
}
|
|
5109
5130
|
return orphans;
|
|
5110
5131
|
}
|
|
5132
|
+
function slugMatchKeys(slug) {
|
|
5133
|
+
const lower = slug.toLowerCase();
|
|
5134
|
+
const compact = lower.replace(/-/g, "");
|
|
5135
|
+
const keys = compact === lower ? [lower] : [lower, compact];
|
|
5136
|
+
return keys.filter((k) => k.length > 0);
|
|
5137
|
+
}
|
|
5138
|
+
function containerTaskSlug(name, knownSlugs) {
|
|
5139
|
+
const lower = name.toLowerCase();
|
|
5140
|
+
let best = null;
|
|
5141
|
+
for (const slug of knownSlugs) {
|
|
5142
|
+
for (const key of slugMatchKeys(slug)) {
|
|
5143
|
+
if (!lower.startsWith(key)) continue;
|
|
5144
|
+
const next = lower[key.length];
|
|
5145
|
+
if (next !== void 0 && next >= "0" && next <= "9") continue;
|
|
5146
|
+
if (!best || key.length > best.len) best = { slug, len: key.length };
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
return best?.slug ?? null;
|
|
5150
|
+
}
|
|
5151
|
+
function parseDockerCreatedAt(raw) {
|
|
5152
|
+
const s = raw.trim();
|
|
5153
|
+
if (!s) return null;
|
|
5154
|
+
if (/^\d{4}-\d{2}-\d{2}T/.test(s)) {
|
|
5155
|
+
const iso = s.replace(/(\.\d{3})\d+/, "$1");
|
|
5156
|
+
const t2 = Date.parse(iso);
|
|
5157
|
+
return Number.isNaN(t2) ? null : t2;
|
|
5158
|
+
}
|
|
5159
|
+
const m = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})(?:\.\d+)?(?:\s+([+-]\d{2})(\d{2}))?/.exec(s);
|
|
5160
|
+
if (!m) return null;
|
|
5161
|
+
const [, d, time, zh, zm] = m;
|
|
5162
|
+
const normalized = zh != null ? `${d}T${time}${zh}:${zm}` : `${d}T${time}Z`;
|
|
5163
|
+
const t = Date.parse(normalized);
|
|
5164
|
+
return Number.isNaN(t) ? null : t;
|
|
5165
|
+
}
|
|
5166
|
+
function blankLabel(raw) {
|
|
5167
|
+
const t = (raw ?? "").trim();
|
|
5168
|
+
if (!t || t === "<no value>" || t === "<nil>") return null;
|
|
5169
|
+
return t;
|
|
5170
|
+
}
|
|
5171
|
+
function directoryWithin(candidate, root) {
|
|
5172
|
+
if (!isAbsolute2(candidate) || !isAbsolute2(root)) return false;
|
|
5173
|
+
const base3 = resolve3(root);
|
|
5174
|
+
const dir = resolve3(candidate);
|
|
5175
|
+
if (dir === base3) return true;
|
|
5176
|
+
const prefix = base3.endsWith(sep) ? base3 : `${base3}${sep}`;
|
|
5177
|
+
return dir.startsWith(prefix);
|
|
5178
|
+
}
|
|
5179
|
+
function isOwnStand(container, homeDir = homedir6()) {
|
|
5180
|
+
const home = blankLabel(container.swarmHome ?? void 0);
|
|
5181
|
+
if (home) return directoryWithin(home, homeDir);
|
|
5182
|
+
const dir = blankLabel(container.workingDir ?? void 0);
|
|
5183
|
+
if (!dir) return false;
|
|
5184
|
+
return directoryWithin(dir, homeDir);
|
|
5185
|
+
}
|
|
5186
|
+
function parseContainerPs(output) {
|
|
5187
|
+
const rows = [];
|
|
5188
|
+
for (const line of output.split("\n")) {
|
|
5189
|
+
if (!line.trim()) continue;
|
|
5190
|
+
const [name, createdAt, ports, project, workingDir, swarmHome] = line.split(" ");
|
|
5191
|
+
if (!name) continue;
|
|
5192
|
+
rows.push({
|
|
5193
|
+
name,
|
|
5194
|
+
createdAt: createdAt ?? "",
|
|
5195
|
+
ports: ports ?? "",
|
|
5196
|
+
project: blankLabel(project),
|
|
5197
|
+
workingDir: blankLabel(workingDir),
|
|
5198
|
+
swarmHome: blankLabel(swarmHome)
|
|
5199
|
+
});
|
|
5200
|
+
}
|
|
5201
|
+
return rows;
|
|
5202
|
+
}
|
|
5203
|
+
function listContainersRich() {
|
|
5204
|
+
try {
|
|
5205
|
+
return parseContainerPs(dockerCli(["ps", "-a", "--format", CONTAINER_PS_FORMAT]));
|
|
5206
|
+
} catch (e) {
|
|
5207
|
+
logTransientSpawnError("docker ps", e);
|
|
5208
|
+
return [];
|
|
5209
|
+
}
|
|
5210
|
+
}
|
|
5211
|
+
function exposedWildcardPort(ports) {
|
|
5212
|
+
const m = /(?:0\.0\.0\.0:|\[::\]:)(\d+)/.exec(ports);
|
|
5213
|
+
return m ? m[1] : null;
|
|
5214
|
+
}
|
|
5215
|
+
function openPortWarning(name, port) {
|
|
5216
|
+
return `\u0441\u0442\u0435\u043D\u0434 ${name} \u043E\u0442\u043A\u0440\u044B\u0442 \u043D\u0430 0.0.0.0:${port}, \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0439 \u0441 -p 127.0.0.1:\u2026`;
|
|
5217
|
+
}
|
|
5218
|
+
function formatAge(ms) {
|
|
5219
|
+
const h = ms / 36e5;
|
|
5220
|
+
const text = h >= 10 ? String(Math.round(h)) : String(Math.round(h * 10) / 10);
|
|
5221
|
+
return `${text} \u0447`;
|
|
5222
|
+
}
|
|
5223
|
+
function selectNamedStandRemovals(containers, tasks, homeDir, nowMs) {
|
|
5224
|
+
const slugs = tasks.map((t) => t.slug);
|
|
5225
|
+
const live2 = new Set(tasks.filter((t) => t.live).map((t) => t.slug));
|
|
5226
|
+
const hits = [];
|
|
5227
|
+
for (const c of containers) {
|
|
5228
|
+
const slug = containerTaskSlug(c.name, slugs);
|
|
5229
|
+
if (!slug) continue;
|
|
5230
|
+
if (live2.has(slug)) continue;
|
|
5231
|
+
if (!isOwnStand(c, homeDir)) continue;
|
|
5232
|
+
const created = parseDockerCreatedAt(c.createdAt);
|
|
5233
|
+
if (created == null) continue;
|
|
5234
|
+
const ageMs2 = nowMs - created;
|
|
5235
|
+
if (ageMs2 <= NAMED_STAND_MIN_AGE_MS) continue;
|
|
5236
|
+
hits.push({ name: c.name, slug, ageMs: ageMs2 });
|
|
5237
|
+
}
|
|
5238
|
+
return hits;
|
|
5239
|
+
}
|
|
5111
5240
|
function dockerContainerNames() {
|
|
5112
5241
|
try {
|
|
5113
|
-
return
|
|
5242
|
+
return dockerCli(["ps", "-a", "--format", "{{.Names}}"]).split("\n").map((s) => s.trim()).filter(Boolean);
|
|
5114
5243
|
} catch (e) {
|
|
5115
5244
|
logTransientSpawnError("docker ps", e);
|
|
5116
5245
|
return [];
|
|
5117
5246
|
}
|
|
5118
5247
|
}
|
|
5119
|
-
function
|
|
5120
|
-
|
|
5248
|
+
function defaultDockerExec(args) {
|
|
5249
|
+
return dockerCli(args);
|
|
5250
|
+
}
|
|
5251
|
+
function dockerLines(out) {
|
|
5252
|
+
return out.split("\n").map((s) => s.trim()).filter(Boolean);
|
|
5253
|
+
}
|
|
5254
|
+
function inspectStand(name, exec) {
|
|
5255
|
+
try {
|
|
5256
|
+
const raw = exec(["inspect", "--format", INSPECT_STAND_FORMAT, name]);
|
|
5257
|
+
const [project, workingDir, swarmHome] = raw.split(" ");
|
|
5258
|
+
return { project: blankLabel(project), workingDir: blankLabel(workingDir), swarmHome: blankLabel(swarmHome) };
|
|
5259
|
+
} catch {
|
|
5260
|
+
return null;
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
function listProjectStands(project, exec) {
|
|
5264
|
+
try {
|
|
5265
|
+
const out = exec(["ps", "-a", "--filter", `label=com.docker.compose.project=${project}`, "--format", PROJECT_PS_FORMAT]);
|
|
5266
|
+
const rows = [];
|
|
5267
|
+
for (const line of out.split("\n")) {
|
|
5268
|
+
if (!line.trim()) continue;
|
|
5269
|
+
const [name, workingDir, swarmHome] = line.split(" ");
|
|
5270
|
+
if (!name?.trim()) continue;
|
|
5271
|
+
rows.push({ workingDir: blankLabel(workingDir), swarmHome: blankLabel(swarmHome) });
|
|
5272
|
+
}
|
|
5273
|
+
return rows;
|
|
5274
|
+
} catch (e) {
|
|
5275
|
+
console.warn(`[procCleanup] \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u044B \u043F\u0440\u043E\u0435\u043A\u0442\u0430 ${project}: ${String(e)}`);
|
|
5276
|
+
return null;
|
|
5277
|
+
}
|
|
5278
|
+
}
|
|
5279
|
+
function removeProjectResources(project, exec) {
|
|
5280
|
+
let left;
|
|
5281
|
+
try {
|
|
5282
|
+
left = exec(["ps", "-a", "-q", "--filter", `label=com.docker.compose.project=${project}`]).trim();
|
|
5283
|
+
} catch (e) {
|
|
5284
|
+
console.warn(`[procCleanup] \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C, \u043F\u0443\u0441\u0442 \u043B\u0438 \u043F\u0440\u043E\u0435\u043A\u0442 ${project}: ${String(e)}`);
|
|
5285
|
+
return;
|
|
5286
|
+
}
|
|
5287
|
+
if (left) return;
|
|
5288
|
+
try {
|
|
5289
|
+
const nets = dockerLines(exec(["network", "ls", "-q", "--filter", `label=com.docker.compose.project=${project}`]));
|
|
5290
|
+
for (const id of nets) exec(["network", "rm", id]);
|
|
5291
|
+
} catch (e) {
|
|
5292
|
+
console.warn(`[procCleanup] \u0441\u0435\u0442\u044C \u043F\u0440\u043E\u0435\u043A\u0442\u0430 ${project} \u043D\u0435 \u0443\u0431\u0440\u0430\u043B\u0430\u0441\u044C: ${String(e)}`);
|
|
5293
|
+
}
|
|
5294
|
+
try {
|
|
5295
|
+
const vols = dockerLines(exec(["volume", "ls", "-q", "--filter", `label=com.docker.compose.project=${project}`]));
|
|
5296
|
+
for (const id of vols) exec(["volume", "rm", id]);
|
|
5297
|
+
} catch (e) {
|
|
5298
|
+
console.warn(`[procCleanup] \u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0430 ${project} \u043D\u0435 \u0443\u0431\u0440\u0430\u043B\u0441\u044F: ${String(e)}`);
|
|
5299
|
+
}
|
|
5300
|
+
}
|
|
5301
|
+
function removeContainers(names, exec = defaultDockerExec, homeDir = homedir6()) {
|
|
5302
|
+
const own = [];
|
|
5121
5303
|
for (const name of names) {
|
|
5304
|
+
const stand = inspectStand(name, exec);
|
|
5305
|
+
if (!stand || !isOwnStand(stand, homeDir)) {
|
|
5306
|
+
if (stand) console.warn(`[procCleanup] ${name} \u043D\u0435 \u043D\u0430\u0448 \u0441\u0442\u0435\u043D\u0434 \u2014 \u043D\u0435 \u0441\u043D\u043E\u0448\u0443`);
|
|
5307
|
+
continue;
|
|
5308
|
+
}
|
|
5309
|
+
own.push({ name, project: stand.project });
|
|
5310
|
+
}
|
|
5311
|
+
const tainted = /* @__PURE__ */ new Set();
|
|
5312
|
+
const projects = new Set(own.map((item) => item.project).filter((project) => !!project));
|
|
5313
|
+
for (const project of projects) {
|
|
5314
|
+
const rows = listProjectStands(project, exec);
|
|
5315
|
+
if (rows == null || rows.some((row) => !isOwnStand(row, homeDir))) tainted.add(project);
|
|
5316
|
+
}
|
|
5317
|
+
const removed = [];
|
|
5318
|
+
const cleanProjects = /* @__PURE__ */ new Set();
|
|
5319
|
+
for (const item of own) {
|
|
5122
5320
|
try {
|
|
5123
|
-
|
|
5124
|
-
removed.push(name);
|
|
5321
|
+
exec(["rm", "-f", "-v", item.name]);
|
|
5322
|
+
removed.push(item.name);
|
|
5323
|
+
if (item.project && !tainted.has(item.project)) cleanProjects.add(item.project);
|
|
5125
5324
|
} catch (e) {
|
|
5126
|
-
console.warn(`[procCleanup] docker rm -f ${name} \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F: ${String(e)}`);
|
|
5325
|
+
console.warn(`[procCleanup] docker rm -f -v ${item.name} \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F: ${String(e)}`);
|
|
5127
5326
|
}
|
|
5128
5327
|
}
|
|
5328
|
+
for (const project of cleanProjects) removeProjectResources(project, exec);
|
|
5129
5329
|
return removed;
|
|
5130
5330
|
}
|
|
5131
5331
|
async function cleanupWorktreeProcesses(worktree, opts = {}) {
|
|
@@ -5145,14 +5345,36 @@ async function cleanupWorktreeProcesses(worktree, opts = {}) {
|
|
|
5145
5345
|
try {
|
|
5146
5346
|
const prefix = composeProjectPrefix(worktree.split("/").filter(Boolean).pop() ?? "");
|
|
5147
5347
|
if (!prefix) return;
|
|
5148
|
-
const
|
|
5348
|
+
const homeDir = opts.docker?.homeDir ?? homedir6();
|
|
5349
|
+
const listed = opts.docker?.list ? opts.docker.list() : opts.docker?.names ? null : listContainersRich();
|
|
5350
|
+
const names = listed ? listed.filter((view) => containerBelongsToPrefix(view.name, prefix) && isOwnStand(view, homeDir)).map((view) => view.name) : [];
|
|
5149
5351
|
if (!names.length) return;
|
|
5150
|
-
const removed = (opts.docker?.remove ?? removeContainers)(names);
|
|
5352
|
+
const removed = (opts.docker?.remove ?? ((picked) => removeContainers(picked, defaultDockerExec, homeDir)))(names);
|
|
5151
5353
|
if (removed.length) console.log(`[procCleanup] worktree ${worktree}: \u0441\u043D\u0435\u0441\u0435\u043D\u043E docker-\u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u043E\u0432 ${removed.length} (${removed.join(", ")})`);
|
|
5152
5354
|
} catch (e) {
|
|
5153
5355
|
console.error(`[procCleanup] \u0441\u043D\u043E\u0441 docker-\u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u043E\u0432 worktree ${worktree} \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F:`, e);
|
|
5154
5356
|
}
|
|
5155
5357
|
}
|
|
5358
|
+
function warnOpenPorts(views, named) {
|
|
5359
|
+
if (!named.onOpenPort) return;
|
|
5360
|
+
const warned = named.warned ?? openPortWarned;
|
|
5361
|
+
const slugs = named.tasks.map((t) => t.slug);
|
|
5362
|
+
const liveIds = new Map(named.tasks.filter((t) => t.live && t.liveRunIds.length).map((t) => [t.slug, t.liveRunIds]));
|
|
5363
|
+
for (const c of views) {
|
|
5364
|
+
if (!isOwnStand(c, named.homeDir)) continue;
|
|
5365
|
+
const port = exposedWildcardPort(c.ports);
|
|
5366
|
+
if (!port) continue;
|
|
5367
|
+
const slug = containerTaskSlug(c.name, slugs);
|
|
5368
|
+
if (!slug) continue;
|
|
5369
|
+
const runIds = liveIds.get(slug);
|
|
5370
|
+
if (!runIds?.length) continue;
|
|
5371
|
+
if (warned.has(c.name)) continue;
|
|
5372
|
+
warned.add(c.name);
|
|
5373
|
+
const text = openPortWarning(c.name, port);
|
|
5374
|
+
console.log(`[procCleanup] ${text}`);
|
|
5375
|
+
named.onOpenPort({ runIds, text, name: c.name });
|
|
5376
|
+
}
|
|
5377
|
+
}
|
|
5156
5378
|
async function sweepOrphans(params) {
|
|
5157
5379
|
let killedPids = [];
|
|
5158
5380
|
try {
|
|
@@ -5168,30 +5390,62 @@ async function sweepOrphans(params) {
|
|
|
5168
5390
|
}
|
|
5169
5391
|
let removedContainers = [];
|
|
5170
5392
|
try {
|
|
5171
|
-
const
|
|
5172
|
-
const
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5393
|
+
const named = params.namedStands;
|
|
5394
|
+
const homeDir = named?.homeDir ?? homedir6();
|
|
5395
|
+
const views = params.docker?.list ? params.docker.list() : named ? listContainersRich() : null;
|
|
5396
|
+
const names = views ? views.map((v) => v.name) : dockerContainerNames();
|
|
5397
|
+
const viewByName = new Map((views ?? []).map((view) => [view.name, view]));
|
|
5398
|
+
const prefixOrphans = findOrphanContainers(names, params.containerRunPrefixes).filter((name) => {
|
|
5399
|
+
const view = viewByName.get(name);
|
|
5400
|
+
return !!view && isOwnStand(view, homeDir);
|
|
5401
|
+
});
|
|
5402
|
+
const removeNamed = named ? named.remove ?? process.env.SWARM_SWEEP_NAMED_STANDS !== "0" : false;
|
|
5403
|
+
if (named && removeNamed && named.listComplete === false) {
|
|
5404
|
+
console.log("[procCleanup] \u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u043D\u0430\u044F \u0443\u0431\u043E\u0440\u043A\u0430 \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u0430: \u0441\u043F\u0438\u0441\u043E\u043A \u043F\u0440\u043E\u0433\u043E\u043D\u043E\u0432 \u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0445\u043E\u0434\u0435 \u043D\u0435\u043F\u043E\u043B\u043D\u044B\u0439");
|
|
5405
|
+
}
|
|
5406
|
+
const namedHits = named && removeNamed && named.listComplete !== false && views ? selectNamedStandRemovals(views, named.tasks, named.homeDir, named.nowMs ?? Date.now()) : [];
|
|
5407
|
+
const toRemove = [];
|
|
5408
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5409
|
+
for (const n of [...prefixOrphans, ...namedHits.map((h) => h.name)]) {
|
|
5410
|
+
if (seen.has(n)) continue;
|
|
5411
|
+
seen.add(n);
|
|
5412
|
+
toRemove.push(n);
|
|
5413
|
+
}
|
|
5414
|
+
if (prefixOrphans.length) {
|
|
5415
|
+
console.log(`[procCleanup] \u0437\u0430\u0449\u0438\u0442\u043D\u044B\u0439 sweep: ${prefixOrphans.length} docker-\u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440(\u043E\u0432)-\u0441\u0438\u0440\u043E\u0442 \u2014 \u0433\u0430\u0448\u0443`, prefixOrphans);
|
|
5176
5416
|
}
|
|
5417
|
+
if (toRemove.length) removedContainers = removeContainers(toRemove, params.docker?.exec, homeDir);
|
|
5418
|
+
const removedSet = new Set(removedContainers);
|
|
5419
|
+
for (const hit of namedHits) {
|
|
5420
|
+
if (!removedSet.has(hit.name)) continue;
|
|
5421
|
+
console.log(`[procCleanup] \u0437\u0430\u0449\u0438\u0442\u043D\u044B\u0439 sweep: \u0441\u0442\u0435\u043D\u0434 ${hit.name} \u0437\u0430\u0434\u0430\u0447\u0438 ${hit.slug}, \u0432\u043E\u0437\u0440\u0430\u0441\u0442 ${formatAge(hit.ageMs)} \u2014 \u0441\u043D\u043E\u0448\u0443`);
|
|
5422
|
+
}
|
|
5423
|
+
if (named && views) warnOpenPorts(views, named);
|
|
5177
5424
|
} catch (e) {
|
|
5178
5425
|
console.error("[procCleanup] \u0437\u0430\u0449\u0438\u0442\u043D\u044B\u0439 sweep \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u043E\u0432 \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F:", e);
|
|
5179
5426
|
}
|
|
5180
5427
|
return { killedPids, removedContainers };
|
|
5181
5428
|
}
|
|
5429
|
+
var NAMED_STAND_MIN_AGE_MS, CONTAINER_PS_FORMAT, openPortWarned, INSPECT_STAND_FORMAT, PROJECT_PS_FORMAT;
|
|
5182
5430
|
var init_procCleanup = __esm({
|
|
5183
5431
|
"src/procCleanup.ts"() {
|
|
5184
5432
|
"use strict";
|
|
5433
|
+
init_dockerCli();
|
|
5185
5434
|
init_quietExec();
|
|
5186
5435
|
init_resources();
|
|
5187
5436
|
init_procList();
|
|
5437
|
+
NAMED_STAND_MIN_AGE_MS = 6 * 60 * 60 * 1e3;
|
|
5438
|
+
CONTAINER_PS_FORMAT = '{{.Names}} {{.CreatedAt}} {{.Ports}} {{.Label "com.docker.compose.project"}} {{.Label "com.docker.compose.project.working_dir"}} {{.Label "taskless.swarm.home"}}';
|
|
5439
|
+
openPortWarned = /* @__PURE__ */ new Set();
|
|
5440
|
+
INSPECT_STAND_FORMAT = '{{index .Config.Labels "com.docker.compose.project"}} {{index .Config.Labels "com.docker.compose.project.working_dir"}} {{index .Config.Labels "taskless.swarm.home"}}';
|
|
5441
|
+
PROJECT_PS_FORMAT = '{{.Names}} {{.Label "com.docker.compose.project.working_dir"}} {{.Label "taskless.swarm.home"}}';
|
|
5188
5442
|
}
|
|
5189
5443
|
});
|
|
5190
5444
|
|
|
5191
5445
|
// src/git.ts
|
|
5192
5446
|
import { existsSync as existsSync14, readdirSync as readdirSync16, realpathSync as realpathSync2, statSync as statSync13 } from "fs";
|
|
5193
5447
|
import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
|
|
5194
|
-
import { isAbsolute as
|
|
5448
|
+
import { isAbsolute as isAbsolute4, join as join25, resolve as resolve4, sep as sep3 } from "path";
|
|
5195
5449
|
import { $ as $2 } from "execa";
|
|
5196
5450
|
function gitNet(repo, args, timeoutMs) {
|
|
5197
5451
|
return withHardTimeout(
|
|
@@ -5231,7 +5485,7 @@ function samePath(a, b) {
|
|
|
5231
5485
|
try {
|
|
5232
5486
|
return realpathSync2(p);
|
|
5233
5487
|
} catch {
|
|
5234
|
-
return
|
|
5488
|
+
return resolve4(p);
|
|
5235
5489
|
}
|
|
5236
5490
|
};
|
|
5237
5491
|
const [x, y] = [norm(a), norm(b)];
|
|
@@ -5413,7 +5667,7 @@ async function gitPath(worktree, flag) {
|
|
|
5413
5667
|
const out = await $2({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
|
|
5414
5668
|
const raw = out.stdout.trim();
|
|
5415
5669
|
if (out.exitCode !== 0 || !raw) return null;
|
|
5416
|
-
return
|
|
5670
|
+
return isAbsolute4(raw) ? raw : join25(worktree, raw);
|
|
5417
5671
|
}
|
|
5418
5672
|
async function ensureWorktreeHygiene(worktree) {
|
|
5419
5673
|
for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
|
|
@@ -5438,7 +5692,7 @@ async function installGuardHooks(worktree) {
|
|
|
5438
5692
|
}
|
|
5439
5693
|
}
|
|
5440
5694
|
function posix(p) {
|
|
5441
|
-
return (
|
|
5695
|
+
return (sep3 === "\\" ? p.replace(/\\/g, "/") : p).replace(/\/+$/, "");
|
|
5442
5696
|
}
|
|
5443
5697
|
async function previousHooksPath(worktree) {
|
|
5444
5698
|
for (const scope of ["--local", "--global", "--system"]) {
|
|
@@ -5856,8 +6110,8 @@ function startDroneChannel(deps, port) {
|
|
|
5856
6110
|
return { port, server };
|
|
5857
6111
|
}
|
|
5858
6112
|
function closeDroneChannel(server) {
|
|
5859
|
-
return new Promise((
|
|
5860
|
-
server.close(() =>
|
|
6113
|
+
return new Promise((resolve6) => {
|
|
6114
|
+
server.close(() => resolve6());
|
|
5861
6115
|
server.closeAllConnections?.();
|
|
5862
6116
|
});
|
|
5863
6117
|
}
|
|
@@ -6300,7 +6554,7 @@ var init_attachments = __esm({
|
|
|
6300
6554
|
|
|
6301
6555
|
// src/shotUpload.ts
|
|
6302
6556
|
import { readFile as fsReadFile } from "fs/promises";
|
|
6303
|
-
import { basename as
|
|
6557
|
+
import { basename as basename5, isAbsolute as isAbsolute5, join as join31 } from "path";
|
|
6304
6558
|
function shotMimetype(path) {
|
|
6305
6559
|
const dot = path.lastIndexOf(".");
|
|
6306
6560
|
if (dot < 0) return null;
|
|
@@ -6326,7 +6580,7 @@ async function readShots(paths, opts) {
|
|
|
6326
6580
|
}
|
|
6327
6581
|
let bytes;
|
|
6328
6582
|
try {
|
|
6329
|
-
bytes = await read(
|
|
6583
|
+
bytes = await read(isAbsolute5(path) ? path : join31(opts.worktree, path));
|
|
6330
6584
|
} catch (e) {
|
|
6331
6585
|
skipped.push({ path, reason: `\u043D\u0435 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D: ${e instanceof Error ? e.message : String(e)}` });
|
|
6332
6586
|
continue;
|
|
@@ -6342,7 +6596,7 @@ async function readShots(paths, opts) {
|
|
|
6342
6596
|
});
|
|
6343
6597
|
continue;
|
|
6344
6598
|
}
|
|
6345
|
-
files.push({ path, fileName:
|
|
6599
|
+
files.push({ path, fileName: basename5(path), mimetype, bytes });
|
|
6346
6600
|
}
|
|
6347
6601
|
return { files, skipped };
|
|
6348
6602
|
}
|
|
@@ -7290,7 +7544,7 @@ __export(db_exports, {
|
|
|
7290
7544
|
import { createRequire as createRequire2 } from "module";
|
|
7291
7545
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
7292
7546
|
import { existsSync as existsSync18 } from "fs";
|
|
7293
|
-
import { resolve as
|
|
7547
|
+
import { resolve as resolve5 } from "path";
|
|
7294
7548
|
function rowToQuestion(row) {
|
|
7295
7549
|
return {
|
|
7296
7550
|
id: row.id,
|
|
@@ -7951,7 +8205,7 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
7951
8205
|
* транзакции: прервётся — маркер не встанет, повтор безопасен.
|
|
7952
8206
|
*/
|
|
7953
8207
|
importDb(sourcePath, repo) {
|
|
7954
|
-
const abs =
|
|
8208
|
+
const abs = resolve5(sourcePath);
|
|
7955
8209
|
const repoN = normalizeRepo(repo);
|
|
7956
8210
|
const already = this.db.prepare("SELECT run_count FROM imports WHERE source = ?").get(abs);
|
|
7957
8211
|
if (already) return { imported: false, runs: already.run_count };
|
|
@@ -8364,9 +8618,9 @@ var init_droneStore = __esm({
|
|
|
8364
8618
|
});
|
|
8365
8619
|
|
|
8366
8620
|
// src/overmind.ts
|
|
8367
|
-
import { homedir as
|
|
8621
|
+
import { homedir as homedir9 } from "os";
|
|
8368
8622
|
import { existsSync as existsSync23, readFileSync as readFileSync28, readdirSync as readdirSync18, renameSync as renameSync12, statSync as statSync16 } from "fs";
|
|
8369
|
-
import { basename as
|
|
8623
|
+
import { basename as basename7, dirname as dirname6, join as join40 } from "path";
|
|
8370
8624
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
8371
8625
|
import { spawn as spawn4 } from "child_process";
|
|
8372
8626
|
|
|
@@ -8773,6 +9027,9 @@ var SwarmClient = class _SwarmClient {
|
|
|
8773
9027
|
liveSweepMs;
|
|
8774
9028
|
liveSweptAt = null;
|
|
8775
9029
|
// TASWM-589: когда живые за окном добраны целиком
|
|
9030
|
+
// TASWM-654: последний проход окна и живых статусов прошёл без ошибок. Пока false,
|
|
9031
|
+
// именованная уборка стендов пропускается: неполный список показывает слаг мёртвым.
|
|
9032
|
+
runsListComplete = false;
|
|
8776
9033
|
// TASWM-169: репо-реестр демона — repoFullName[] на claim/heartbeat + обратная
|
|
8777
9034
|
// карта repoFullName→локальный путь для трансляции run.repo из прода (см. resolveRepo).
|
|
8778
9035
|
repoFullNames;
|
|
@@ -9906,17 +10163,28 @@ var SwarmClient = class _SwarmClient {
|
|
|
9906
10163
|
}
|
|
9907
10164
|
}
|
|
9908
10165
|
// ── гидрация зеркала из прода (старт + реконсайл-рефреш) ──────────────────────
|
|
10166
|
+
/** TASWM-654: все запросы прогонов последнего hydrate прошли. Иначе уборка стендов не знает,
|
|
10167
|
+
* жив ли слаг за окном в 200 прогонов. */
|
|
10168
|
+
runsHydrateComplete() {
|
|
10169
|
+
return this.runsListComplete;
|
|
10170
|
+
}
|
|
9909
10171
|
async hydrate() {
|
|
9910
10172
|
let res;
|
|
9911
10173
|
try {
|
|
9912
10174
|
res = await this.call("swarm_list_runs", { limit: this.listLimit, view: "full" });
|
|
9913
10175
|
} catch {
|
|
10176
|
+
this.runsListComplete = false;
|
|
10177
|
+
return;
|
|
10178
|
+
}
|
|
10179
|
+
if (!res || res.isError) {
|
|
10180
|
+
this.runsListComplete = false;
|
|
9914
10181
|
return;
|
|
9915
10182
|
}
|
|
9916
|
-
if (res?.isError) return;
|
|
9917
10183
|
const runs = res.structuredContent?.runs ?? [];
|
|
9918
10184
|
const seen = new Set(runs.map((pr) => String(pr.id ?? "")));
|
|
9919
|
-
|
|
10185
|
+
const beyond = await this.liveBeyondWindow();
|
|
10186
|
+
this.runsListComplete = beyond.complete;
|
|
10187
|
+
for (const pr of beyond.rows) {
|
|
9920
10188
|
const id = String(pr.id ?? "");
|
|
9921
10189
|
if (seen.has(id)) continue;
|
|
9922
10190
|
seen.add(id);
|
|
@@ -9939,16 +10207,19 @@ var SwarmClient = class _SwarmClient {
|
|
|
9939
10207
|
* в зеркало, когда его заводят или трогают, — то есть через окно. Добор нужен на старте и как
|
|
9940
10208
|
* страховка, поэтому он идёт при первой гидрации и дальше не чаще раза в `liveSweepMs`.
|
|
9941
10209
|
*
|
|
9942
|
-
* Fail-open
|
|
9943
|
-
* чтобы повторить его на следующей гидрации, а не через минуту.
|
|
10210
|
+
* Fail-open для зеркала: прод отказал по какому-то статусу — отдаём, что успели, и не
|
|
10211
|
+
* засчитываем добор, чтобы повторить его на следующей гидрации, а не через минуту.
|
|
10212
|
+
* Для уборки стендов это НЕ полный список: runsHydrateComplete() остаётся false, и
|
|
10213
|
+
* именованный снос в этом проходе пропускается (TASWM-654). Граница машины (isMine) и
|
|
9944
10214
|
* слияние с уже известными прогонами — обычный hydrateRun.
|
|
9945
10215
|
*/
|
|
9946
10216
|
async liveBeyondWindow() {
|
|
9947
10217
|
const now = this.now();
|
|
9948
|
-
if (this.liveSweptAt != null && now - this.liveSweptAt < this.liveSweepMs) return [];
|
|
10218
|
+
if (this.liveSweptAt != null && now - this.liveSweptAt < this.liveSweepMs) return { rows: [], complete: true };
|
|
9949
10219
|
const byStatus = await Promise.all(LIVE_STATUSES.map((status) => this.listAllByStatus(status)));
|
|
9950
|
-
|
|
9951
|
-
|
|
10220
|
+
const complete = byStatus.every((rows) => rows !== null);
|
|
10221
|
+
if (complete) this.liveSweptAt = now;
|
|
10222
|
+
return { rows: byStatus.flatMap((rows) => rows ?? []), complete };
|
|
9952
10223
|
}
|
|
9953
10224
|
/** Все прогоны одного статуса, страницами по 200. null — прод не ответил. */
|
|
9954
10225
|
async listAllByStatus(status) {
|
|
@@ -12253,16 +12524,17 @@ function buildReliefCostCandidates(cost, t, sustainMs, build) {
|
|
|
12253
12524
|
}
|
|
12254
12525
|
|
|
12255
12526
|
// src/launcher.ts
|
|
12527
|
+
init_procCleanup();
|
|
12256
12528
|
import { spawn as spawn2 } from "child_process";
|
|
12257
12529
|
import { closeSync as closeSync4, existsSync as existsSync13, mkdirSync as mkdirSync10, openSync as openSync4, readdirSync as readdirSync11 } from "fs";
|
|
12258
12530
|
import { createRequire } from "module";
|
|
12259
|
-
import { homedir as
|
|
12260
|
-
import { dirname as dirname3, join as join19 } from "path";
|
|
12531
|
+
import { homedir as homedir7 } from "os";
|
|
12532
|
+
import { basename as basename3, dirname as dirname3, join as join19 } from "path";
|
|
12261
12533
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
12262
12534
|
|
|
12263
12535
|
// src/droneHome.ts
|
|
12264
12536
|
import { lstatSync, mkdirSync as mkdirSync9, readdirSync as readdirSync10, rmSync, statSync as statSync10, symlinkSync as symlinkSync4 } from "fs";
|
|
12265
|
-
import { join as join18, relative, sep } from "path";
|
|
12537
|
+
import { join as join18, relative, sep as sep2 } from "path";
|
|
12266
12538
|
var DRONE_HOME_DENY_DEFAULT = [".taskless-swarm", ".bash_history", ".zsh_history"];
|
|
12267
12539
|
function droneHomeDeny(env = process.env) {
|
|
12268
12540
|
const extra = (env.SWARM_DRONE_HOME_DENY || "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -12283,7 +12555,7 @@ function buildDroneHome(opts) {
|
|
|
12283
12555
|
mkdirSync9(droneHome, { recursive: true, mode: 448 });
|
|
12284
12556
|
const wanted = new Set(mirroredEntries(readdirSync10(realHome), deny, platform));
|
|
12285
12557
|
const rel = relative(realHome, droneHome);
|
|
12286
|
-
if (rel && !rel.startsWith("..") && !rel.includes(
|
|
12558
|
+
if (rel && !rel.startsWith("..") && !rel.includes(sep2)) wanted.delete(rel);
|
|
12287
12559
|
for (const existing of readdirSync10(droneHome)) {
|
|
12288
12560
|
if (wanted.has(existing)) continue;
|
|
12289
12561
|
const p = join18(droneHome, existing);
|
|
@@ -12420,6 +12692,10 @@ function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
|
|
|
12420
12692
|
if (isolate && !base3.TURBO_CACHE_DIR) {
|
|
12421
12693
|
env.TURBO_CACHE_DIR = join19(worktree, ".turbo", "cache");
|
|
12422
12694
|
}
|
|
12695
|
+
if (!base3.COMPOSE_PROJECT_NAME) {
|
|
12696
|
+
const prefix = composeProjectPrefix(basename3(worktree));
|
|
12697
|
+
if (prefix) env.COMPOSE_PROJECT_NAME = prefix;
|
|
12698
|
+
}
|
|
12423
12699
|
Object.assign(env, droneTestEnv(droneCap, base3));
|
|
12424
12700
|
for (const key of DAEMON_STATE_ENV) delete env[key];
|
|
12425
12701
|
if (isolation) {
|
|
@@ -12561,7 +12837,7 @@ function makeLauncher(cfg) {
|
|
|
12561
12837
|
} catch (e) {
|
|
12562
12838
|
console.error(`[launcher] \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C \u043C\u043E\u0434\u0435\u043B\u044C \u043F\u0440\u043E\u0433\u043E\u043D\u0430 #${run2.id}: ${String(e)}`);
|
|
12563
12839
|
}
|
|
12564
|
-
const realHome = cfg.droneIsolation?.realHome ??
|
|
12840
|
+
const realHome = cfg.droneIsolation?.realHome ?? homedir7();
|
|
12565
12841
|
const home = cfg.droneIsolation ? buildDroneHome({ realHome, droneHome: cfg.droneIsolation.home }) : void 0;
|
|
12566
12842
|
if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync13(join19(cfg.droneIsolation.swarmHome, "token"))) {
|
|
12567
12843
|
console.error(
|
|
@@ -13037,7 +13313,7 @@ function providerUnavailableReason(providerId, available) {
|
|
|
13037
13313
|
// src/modelLimits.ts
|
|
13038
13314
|
import { createHash } from "crypto";
|
|
13039
13315
|
import { readFileSync as readFileSync19, readdirSync as readdirSync15, statSync as statSync12 } from "fs";
|
|
13040
|
-
import { homedir as
|
|
13316
|
+
import { homedir as homedir8 } from "os";
|
|
13041
13317
|
import { join as join24 } from "path";
|
|
13042
13318
|
var KIMI_USAGES_URL = "https://api.kimi.com/coding/v1/usages";
|
|
13043
13319
|
var DEFAULT_POLL_MS = 3e5;
|
|
@@ -13061,7 +13337,7 @@ function accountKey(userId) {
|
|
|
13061
13337
|
}
|
|
13062
13338
|
function readKimiCredentials(env = process.env) {
|
|
13063
13339
|
try {
|
|
13064
|
-
const root = env.KIMI_CODE_HOME?.trim() || join24(
|
|
13340
|
+
const root = env.KIMI_CODE_HOME?.trim() || join24(homedir8(), ".kimi-code");
|
|
13065
13341
|
const dir = join24(root, "credentials");
|
|
13066
13342
|
const files = readdirSync15(dir).filter((name) => name.endsWith(".json")).map((name) => ({ name, path: join24(dir, name) })).filter((entry) => statSync12(entry.path).isFile());
|
|
13067
13343
|
const preferred = files.filter((entry) => entry.name.startsWith("kimi-code-env-"));
|
|
@@ -14213,7 +14489,7 @@ function parkReasonUnretriable(reason) {
|
|
|
14213
14489
|
// package.json
|
|
14214
14490
|
var package_default = {
|
|
14215
14491
|
name: "@taskless-app/swarm",
|
|
14216
|
-
version: "0.6.
|
|
14492
|
+
version: "0.6.90",
|
|
14217
14493
|
type: "module",
|
|
14218
14494
|
description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
|
|
14219
14495
|
keywords: [
|
|
@@ -14265,7 +14541,7 @@ var package_default = {
|
|
|
14265
14541
|
undici: "^7.30.1",
|
|
14266
14542
|
zod: "3.25.76"
|
|
14267
14543
|
},
|
|
14268
|
-
gitHead: "
|
|
14544
|
+
gitHead: "15adc44473d82d392f25ec8d21c0f445d3d4fb91"
|
|
14269
14545
|
};
|
|
14270
14546
|
|
|
14271
14547
|
// src/version.ts
|
|
@@ -14518,7 +14794,7 @@ init_git();
|
|
|
14518
14794
|
init_src();
|
|
14519
14795
|
init_netTimeout();
|
|
14520
14796
|
import { $ as $3 } from "execa";
|
|
14521
|
-
import { basename as
|
|
14797
|
+
import { basename as basename4 } from "path";
|
|
14522
14798
|
|
|
14523
14799
|
// src/ghBudget.ts
|
|
14524
14800
|
var GH_RATE_LIMIT_FALLBACK_MS = 10 * 60 * 1e3;
|
|
@@ -14642,8 +14918,8 @@ async function readMergedList(deps, cache, repo, now, mergedSinceIso) {
|
|
|
14642
14918
|
};
|
|
14643
14919
|
let fail = () => {
|
|
14644
14920
|
};
|
|
14645
|
-
const flight = new Promise((
|
|
14646
|
-
settle =
|
|
14921
|
+
const flight = new Promise((resolve6, reject) => {
|
|
14922
|
+
settle = resolve6;
|
|
14647
14923
|
fail = reject;
|
|
14648
14924
|
});
|
|
14649
14925
|
flight.catch(() => {
|
|
@@ -14782,7 +15058,7 @@ function ghCallSkipsPause(args) {
|
|
|
14782
15058
|
return endpoint.split("?")[0] === "rate_limit";
|
|
14783
15059
|
}
|
|
14784
15060
|
async function runGh(args, timeoutMs, cwd) {
|
|
14785
|
-
const label2 = callLabel("gh", args) + (cwd ? ` (repo ${
|
|
15061
|
+
const label2 = callLabel("gh", args) + (cwd ? ` (repo ${basename4(cwd)})` : "");
|
|
14786
15062
|
const skipsPause = ghCallSkipsPause(args);
|
|
14787
15063
|
if (!skipsPause && ghCallsPaused(Date.now())) throw new GhPausedError();
|
|
14788
15064
|
const child = cwd ? $3({ cwd, timeout: timeoutMs })`gh ${args}` : $3({ timeout: timeoutMs })`gh ${args}`;
|
|
@@ -18124,9 +18400,9 @@ function parseRequirements(lines) {
|
|
|
18124
18400
|
out.push({ kind: "docker", raw });
|
|
18125
18401
|
continue;
|
|
18126
18402
|
}
|
|
18127
|
-
const
|
|
18128
|
-
const prefix =
|
|
18129
|
-
const rest =
|
|
18403
|
+
const sep4 = raw.indexOf(":");
|
|
18404
|
+
const prefix = sep4 === -1 ? "" : lower.slice(0, sep4);
|
|
18405
|
+
const rest = sep4 === -1 ? "" : raw.slice(sep4 + 1).trim();
|
|
18130
18406
|
if (!rest) {
|
|
18131
18407
|
out.push({ kind: "unknown", raw });
|
|
18132
18408
|
continue;
|
|
@@ -18168,7 +18444,7 @@ function resolveRequirements(repo, declared, io = {}) {
|
|
|
18168
18444
|
if (Array.isArray(declared)) return parseRequirements(declared);
|
|
18169
18445
|
return detectRequirements(repo, io);
|
|
18170
18446
|
}
|
|
18171
|
-
async function
|
|
18447
|
+
async function probeDockerDaemon() {
|
|
18172
18448
|
try {
|
|
18173
18449
|
const res = await execa2("docker", ["version", "--format", "{{.Server.Version}}"], {
|
|
18174
18450
|
timeout: PROBE_TIMEOUT_MS,
|
|
@@ -18179,15 +18455,19 @@ async function dockerAlive() {
|
|
|
18179
18455
|
return false;
|
|
18180
18456
|
}
|
|
18181
18457
|
}
|
|
18458
|
+
var dockerAliveImpl = probeDockerDaemon;
|
|
18459
|
+
async function dockerAlive() {
|
|
18460
|
+
return dockerAliveImpl();
|
|
18461
|
+
}
|
|
18182
18462
|
async function hasCommand(name, env) {
|
|
18183
18463
|
return hasCommandInPath(name, env);
|
|
18184
18464
|
}
|
|
18185
18465
|
async function portOpen(host, port) {
|
|
18186
|
-
return new Promise((
|
|
18466
|
+
return new Promise((resolve6) => {
|
|
18187
18467
|
const socket = createConnection({ host, port });
|
|
18188
18468
|
const finish = (ok) => {
|
|
18189
18469
|
socket.destroy();
|
|
18190
|
-
|
|
18470
|
+
resolve6(ok);
|
|
18191
18471
|
};
|
|
18192
18472
|
socket.setTimeout(PORT_TIMEOUT_MS);
|
|
18193
18473
|
socket.once("connect", () => finish(true));
|
|
@@ -18294,7 +18574,7 @@ function makeEnvGate(opts) {
|
|
|
18294
18574
|
// src/web.ts
|
|
18295
18575
|
init_src();
|
|
18296
18576
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
18297
|
-
import { basename as
|
|
18577
|
+
import { basename as basename6 } from "path";
|
|
18298
18578
|
import { serve as serve2 } from "@hono/node-server";
|
|
18299
18579
|
init_storm();
|
|
18300
18580
|
init_swarmModels();
|
|
@@ -18536,7 +18816,7 @@ function timelineState(db, now = Date.now(), overmindLog = []) {
|
|
|
18536
18816
|
id: r.id,
|
|
18537
18817
|
name: r.name,
|
|
18538
18818
|
slug: r.task_slug,
|
|
18539
|
-
repo:
|
|
18819
|
+
repo: basename6(r.repo || "") || "?",
|
|
18540
18820
|
status: r.status,
|
|
18541
18821
|
area: r.area,
|
|
18542
18822
|
start: sqliteIso(r.created_at),
|
|
@@ -19814,14 +20094,14 @@ function makeHandler(deps) {
|
|
|
19814
20094
|
const ref = url.searchParams.get("pr") ?? "";
|
|
19815
20095
|
if (!ref.trim()) return Response.json({ error: "\u043D\u0443\u0436\u0435\u043D \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 pr=<url|\u043D\u043E\u043C\u0435\u0440>" }, { status: 400 });
|
|
19816
20096
|
const ctxRepo = url.searchParams.get("repo");
|
|
19817
|
-
const
|
|
20097
|
+
const resolve6 = deps.mergeGate ?? makeMergeGateResolver({
|
|
19818
20098
|
listRuns: () => deps.db.listRuns(),
|
|
19819
20099
|
fallbackAutoReview: SWARM_AUTO_REVIEW,
|
|
19820
20100
|
autoVerify: SWARM_AUTO_VERIFY,
|
|
19821
20101
|
// TASWM-344
|
|
19822
20102
|
...defaultRepo ? { repoFallback: defaultRepo } : {}
|
|
19823
20103
|
});
|
|
19824
|
-
return Response.json(await
|
|
20104
|
+
return Response.json(await resolve6(ref, ctxRepo));
|
|
19825
20105
|
}
|
|
19826
20106
|
if (p === "/resources") return Response.json(hostResourceSnapshot());
|
|
19827
20107
|
if (p === "/timeline") return Response.json(timelineState(deps.db, Date.now(), readNarratorLog(deps.narratorLog)));
|
|
@@ -19974,8 +20254,8 @@ function startWeb(deps, port = WEB_PORT) {
|
|
|
19974
20254
|
return { port, server };
|
|
19975
20255
|
}
|
|
19976
20256
|
function closeWebServer(server) {
|
|
19977
|
-
return new Promise((
|
|
19978
|
-
server.close(() =>
|
|
20257
|
+
return new Promise((resolve6) => {
|
|
20258
|
+
server.close(() => resolve6());
|
|
19979
20259
|
server.closeAllConnections?.();
|
|
19980
20260
|
});
|
|
19981
20261
|
}
|
|
@@ -20335,7 +20615,7 @@ function executorHealthy(opts = {}) {
|
|
|
20335
20615
|
const executor = opts.executor ?? resolveExecutor();
|
|
20336
20616
|
const bin = opts.bin ?? executor.resolveBin();
|
|
20337
20617
|
const timeoutMs = opts.timeoutMs ?? 2e4;
|
|
20338
|
-
return new Promise((
|
|
20618
|
+
return new Promise((resolve6) => {
|
|
20339
20619
|
let done = false;
|
|
20340
20620
|
let out = "";
|
|
20341
20621
|
const finish = (r) => {
|
|
@@ -20346,7 +20626,7 @@ function executorHealthy(opts = {}) {
|
|
|
20346
20626
|
child.kill("SIGKILL");
|
|
20347
20627
|
} catch {
|
|
20348
20628
|
}
|
|
20349
|
-
|
|
20629
|
+
resolve6(r);
|
|
20350
20630
|
};
|
|
20351
20631
|
const child = spawn3(bin, [...executor.probe.args], {
|
|
20352
20632
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -21726,9 +22006,18 @@ function buildCiReadyNudge(prUrl, over) {
|
|
|
21726
22006
|
].join("\n");
|
|
21727
22007
|
}
|
|
21728
22008
|
var SUBMISSION_REVIEW_STEP = "2. `/code-review --fix` \u2014 \u043F\u0440\u043E\u0433\u043E\u043D\u0438 \u0440\u0435\u0432\u044C\u044E \u0441\u0432\u043E\u0435\u0433\u043E \u0434\u0438\u0444\u0444\u0430, \u043A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 \u2014 \u0432 skill `swarm-drone:taskless-review`; \u043F\u0440\u0438\u043C\u0435\u043D\u0451\u043D\u043D\u044B\u0435 \u043F\u0440\u0430\u0432\u043A\u0438 \u043F\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u0439 \u0438 \u043F\u0435\u0440\u0435\u0443\u0431\u0435\u0434\u0438\u0441\u044C, \u0447\u0442\u043E \u043D\u0435 \u0441\u043B\u043E\u043C\u0430\u043B \u0444\u0438\u0447\u0443.";
|
|
22009
|
+
function dockerStandRules(prefix, homeDir = homedir9()) {
|
|
22010
|
+
return `\u0421\u0432\u043E\u0438 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u044B \u043D\u0430\u0437\u044B\u0432\u0430\u0439 \u0441 \u043F\u0440\u0435\u0444\u0438\u043A\u0441\u043E\u043C ${prefix}: \`docker compose\` \u0431\u0435\u0437 \`-p\` \u0443\u0436\u0435 \u0435\u0433\u043E \u0431\u0435\u0440\u0451\u0442, \u0438\u043C\u0435\u043D\u0430 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u043E\u0432 \u2014 \`\${COMPOSE_PROJECT_NAME}-<\u0441\u0435\u0440\u0432\u0438\u0441>-1\`, \u043D\u0435 \u0438\u0437 README \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F (\u0432 alex-gpt apps/e2e/README.md \u0437\u0430\u0448\u0438\u0442\u044B alexgpt-postgres-1 \u0438 alexgpt-redis-1). Compose \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0439 \u0442\u043E\u043B\u044C\u043A\u043E \u0438\u0437 \u0441\u0432\u043E\u0435\u0433\u043E worktree, \u043D\u0435 \u0438\u0437 /tmp. \u0414\u043B\u044F \`docker run\` \u2014 \`--name ${prefix}-pg --label taskless.swarm.home=${homeDir}\`. \u041F\u043E\u0440\u0442\u044B \u043F\u0443\u0431\u043B\u0438\u043A\u0443\u0439 \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \`127.0.0.1\` (\`-p 127.0.0.1:<\u043F\u043E\u0440\u0442>:5432\`): Docker \u0438\u0434\u0451\u0442 \u043C\u0438\u043C\u043E \u0444\u0430\u0439\u0440\u0432\u043E\u043B\u0430, \u043E\u0442\u043A\u0440\u044B\u0442\u0443\u044E \u0431\u0430\u0437\u0443 \u0432\u0437\u043B\u0430\u043C\u044B\u0432\u0430\u044E\u0442 \u0437\u0430 \u0434\u043D\u0438.`;
|
|
22011
|
+
}
|
|
22012
|
+
function promptStandRule(worktree, slug) {
|
|
22013
|
+
const raw = worktree && worktree.length > 0 ? worktree : slug;
|
|
22014
|
+
const prefix = composeProjectPrefix(basename7(raw));
|
|
22015
|
+
return prefix ? dockerStandRules(prefix, homedir9()) : "";
|
|
22016
|
+
}
|
|
21729
22017
|
function buildChangesFixPrompt(args) {
|
|
21730
22018
|
const { prUrl, slug, branch, base: base3, worktree, verdict } = args;
|
|
21731
22019
|
const baseRef = base3 ? `origin/${base3}` : "origin/HEAD";
|
|
22020
|
+
const standRule = promptStandRule(worktree, slug);
|
|
21732
22021
|
return [
|
|
21733
22022
|
`\u0422\u044B \u2014 \u0434\u0440\u043E\u043D ${args.name || "\u0440\u043E\u044F"}, headless-\u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C (\u041D\u0415 \u0438\u043D\u0442\u0435\u0440\u0430\u043A\u0442\u0438\u0432\u043D\u044B\u0439 \u0447\u0430\u0442). \u041A\u043E\u043C\u043C\u0438\u0442\u044B \u043F\u043E\u0434\u043F\u0438\u0441\u0430\u043D\u044B \u044D\u0442\u0438\u043C \u0438\u043C\u0435\u043D\u0435\u043C \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438.`,
|
|
21734
22023
|
"",
|
|
@@ -21745,6 +22034,7 @@ function buildChangesFixPrompt(args) {
|
|
|
21745
22034
|
...args.taskUrl ? [`\u041F\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430: ${args.taskUrl}`] : [],
|
|
21746
22035
|
`\u0412\u0435\u0442\u043A\u0430: ${branch} (\u0431\u0430\u0437\u0430 ${baseRef}) \xB7 PR: ${prUrl}`,
|
|
21747
22036
|
`\u041A\u0430\u0442\u0430\u043B\u043E\u0433: ${worktree}`,
|
|
22037
|
+
...standRule ? [standRule] : [],
|
|
21748
22038
|
"",
|
|
21749
22039
|
"## \u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u043F\u0443\u043D\u043A\u0442\u044B",
|
|
21750
22040
|
"\u041A\u0430\u0436\u0434\u044B\u0439 \u043F\u0443\u043D\u043A\u0442 \u0437\u0430\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043A\u043E\u043C\u043C\u0438\u0442\u043E\u043C \u0438 \u0442\u0435\u0441\u0442\u043E\u043C \u043B\u0438\u0431\u043E \u044F\u0432\u043D\u044B\u043C \u043D\u0435\u0441\u043E\u0433\u043B\u0430\u0441\u0438\u0435\u043C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u043C \u0432 PR, \u0441 \u0434\u043E\u0432\u043E\u0434\u043E\u043C.",
|
|
@@ -21816,9 +22106,10 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
|
|
|
21816
22106
|
"\u{1F4B8} \u0421\u0435\u0441\u0441\u0438\u044F \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0430 \u041F\u041E\u0422\u041E\u041B\u041A\u041E\u041C \u0422\u0420\u0410\u0422: \u0443\u043F\u0440\u0451\u0448\u044C\u0441\u044F \u2014 \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u044F\u0442 \u043F\u043E\u0441\u0440\u0435\u0434\u0438 \u0440\u0430\u0431\u043E\u0442\u044B. \u0427\u0438\u0442\u0430\u0439 \u0442\u043E, \u0447\u0442\u043E \u043D\u0443\u0436\u043D\u043E \u0437\u0430\u0434\u0430\u0447\u0435, \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043D\u043E\u0435 \u043D\u0435 \u043F\u0435\u0440\u0435\u0447\u0438\u0442\u044B\u0432\u0430\u0439; \u043F\u0440\u043E\u043C\u0435\u0436\u0443\u0442\u043E\u0447\u043D\u044B\u0439 \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442 \u0441\u043E\u0445\u0440\u0430\u043D\u044F\u0439 \u0444\u0430\u0439\u043B\u0430\u043C\u0438 \u0432 cwd \u043F\u043E \u0445\u043E\u0434\u0443 \u2014 \u0442\u043E\u0433\u0434\u0430 \u043E\u0431\u0440\u044B\u0432 \u043D\u0435 \u043F\u043E\u0442\u0435\u0440\u044F\u0435\u0442 \u0440\u0430\u0431\u043E\u0442\u0443."
|
|
21817
22107
|
].join("\n");
|
|
21818
22108
|
}
|
|
21819
|
-
function buildPrompt(task, run2, verifyMode = SWARM_VERIFY, taskContext, attachmentsBlock, zoneMemoryBlock) {
|
|
22109
|
+
function buildPrompt(task, run2, verifyMode = SWARM_VERIFY, taskContext, attachmentsBlock, zoneMemoryBlock, worktree) {
|
|
21820
22110
|
const name = run2.name || `#${run2.id}`;
|
|
21821
22111
|
if (run2.repoless) return buildRepolessPrompt(task, run2, taskContext, attachmentsBlock);
|
|
22112
|
+
const standRule = promptStandRule(worktree || run2.worktree_path, run2.task_slug);
|
|
21822
22113
|
const head = task ? `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug}: ${task.title}
|
|
21823
22114
|
|
|
21824
22115
|
${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${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).`;
|
|
@@ -21842,6 +22133,7 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
|
|
|
21842
22133
|
// вторую ветку мимо PR. Пишем ту, что реально записана на прогоне; пусто (первый спавн —
|
|
21843
22134
|
// ветку заводит spawnDrone из слага) — прежняя формулировка.
|
|
21844
22135
|
`\u0422\u044B \u2014 \u0434\u0440\u043E\u043D \u0440\u043E\u044F. \u0420\u0430\u0431\u043E\u0442\u0430\u0435\u0448\u044C \u0432 \u044D\u0442\u043E\u043C git-worktree, \u0432\u0435\u0442\u043A\u0430 \`${run2.branch || run2.task_slug}\`${run2.branch && run2.branch !== run2.task_slug ? " (\u043E\u043D\u0430 \u041D\u0415 \u0440\u0430\u0432\u043D\u0430 \u0441\u043B\u0430\u0433\u0443 \u0437\u0430\u0434\u0430\u0447\u0438 \u2014 \u044D\u0442\u043E \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0435\u043D\u0438\u0435 \u0443\u0436\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u043E\u0433\u043E PR, \u043F\u0443\u0448 \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u043D\u0435\u0451)" : " \u0441\u043E\u0437\u0434\u0430\u043D\u0430 \u043F\u043E slug \u0437\u0430\u0434\u0430\u0447\u0438"}.`,
|
|
22136
|
+
...standRule ? [standRule] : [],
|
|
21845
22137
|
"\u0418\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u044B overmind (MCP): report_step(text) \u2014 \u043B\u043E\u0433\u0438\u0440\u0443\u0439 \u0445\u043E\u0434 \u0440\u0430\u0431\u043E\u0442\u044B; read_task() \u2014 \u0441\u0432\u0435\u0436\u0438\u0439 \u0441\u043D\u0430\u043F\u0448\u043E\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 (\u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435+\u043A\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0433\u043E\u0442\u043E\u0432\u043D\u043E\u0441\u0442\u0438+\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u044B+\u0434\u043E\u043A\u0438+\u0438\u0441\u0445\u043E\u0434\u044B \u0441\u043E\u0441\u0435\u0434\u043D\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043F\u043E \u0437\u043E\u043D\u0435 \u043A\u043E\u0434\u0430) \u0431\u0435\u0437 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u043E\u0432, \u0435\u0441\u043B\u0438 \u0442\u0440\u0435\u0431\u043E\u0432\u0430\u043D\u0438\u044F \u043C\u043E\u0433\u043B\u0438 \u0434\u043E\u043F\u0438\u0441\u0430\u0442\u044C \u043F\u043E\u0441\u043B\u0435 \u0441\u0442\u0430\u0440\u0442\u0430; ask(question, options?) \u2014 \u0435\u0441\u043B\u0438 \u0443\u043F\u0451\u0440\u0441\u044F \u0432 \u0420\u0415\u0428\u0415\u041D\u0418\u0415, \u0441\u043F\u0440\u043E\u0441\u0438 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 (\u0434\u0430\u0439 2\u20134 \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u0430 \u0432 options, \u0435\u0441\u043B\u0438 \u0440\u0430\u0437\u0432\u0438\u043B\u043A\u0430 \u0441\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u043D\u0430\u044F) \u0438 \u0434\u043E\u0436\u0434\u0438\u0441\u044C \u043E\u0442\u0432\u0435\u0442\u0430 (\u041D\u0415 \u0443\u0433\u0430\u0434\u044B\u0432\u0430\u0439); report_acceptance_check(id, state, evidence) \u2014 \u0437\u0430\u043A\u0440\u043E\u0439 \u041A\u0410\u0416\u0414\u042B\u0419 \u043F\u0443\u043D\u043A\u0442 \u043A\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u0433\u043E\u0442\u043E\u0432\u043D\u043E\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 (id \u0431\u0435\u0440\u0451\u0442\u0441\u044F \u0438\u0437 \u0431\u043B\u043E\u043A\u0430 \xAB\u041A\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0433\u043E\u0442\u043E\u0432\u043D\u043E\u0441\u0442\u0438\xBB, state = passed|failed|pending \u043F\u043E \u0444\u0430\u043A\u0442\u0443 \u043F\u0440\u043E\u0433\u043E\u043D\u0430, evidence \u2014 \u0432\u044B\u0432\u043E\u0434 \u043A\u043E\u043C\u0430\u043D\u0434\u044B/\u0441\u0441\u044B\u043B\u043A\u0430/\u0447\u0442\u043E \u043D\u0430\u0431\u043B\u044E\u0434\u0430\u043B); \u043F\u0440\u043E\u0439\u0434\u0438\u0441\u044C \u043F\u043E \u043D\u0438\u043C \u041F\u0415\u0420\u0415\u0414 done(), \u0438\u043D\u0430\u0447\u0435 \u0433\u0430\u043B\u043E\u0447\u043A\u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0443\u043A\u0430\u043C\u0438 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440; done(pr_url) \u2014 \u043A\u043E\u0433\u0434\u0430 \u043E\u0442\u043A\u0440\u043E\u0435\u0448\u044C PR; return_task(reason, missing, readings, assumed, questions) \u2014 \u0432\u0435\u0440\u043D\u0443\u0442\u044C \u0421\u042B\u0420\u0423\u042E \u0437\u0430\u0434\u0430\u0447\u0443 \u0430\u0432\u0442\u043E\u0440\u0443 (\u0441\u043C. \u043F\u0440\u0430\u0432\u0438\u043B\u043E \u043D\u0438\u0436\u0435); note(text) \u2014 \u0437\u0430\u043C\u0435\u0442\u043A\u0430 \xAB\u0437\u0430\u043C\u0435\u0447\u0435\u043D\u043E \u043F\u043E \u043F\u0443\u0442\u0438\xBB \u0411\u0415\u0417 \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0438: \u043D\u0430\u0442\u043A\u043D\u0443\u043B\u0441\u044F \u043D\u0430 \u043F\u0440\u043E\u0431\u0435\u043B \u0432 \u0434\u0438\u0437\u0430\u0439\u043D-\u0441\u0438\u0441\u0442\u0435\u043C\u0435, \u043F\u0440\u043E\u0442\u0443\u0445\u0448\u0443\u044E \u0438\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044E, \u0431\u0430\u0433 \u0440\u044F\u0434\u043E\u043C \u0441\u043E \u0441\u0432\u043E\u0438\u043C \u0434\u0438\u0444\u0444\u043E\u043C \u2014 \u0441\u043A\u0430\u0436\u0438 \u0438 \u0440\u0430\u0431\u043E\u0442\u0430\u0439 \u0434\u0430\u043B\u044C\u0448\u0435, \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u0443\u0432\u0438\u0434\u0438\u0442 \u0438 \u0441\u0430\u043C \u0440\u0435\u0448\u0438\u0442, \u0437\u0430\u0432\u043E\u0434\u0438\u0442\u044C \u043B\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 (\u043D\u0435 \u043F\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0439 \u0442\u0430\u043A\u043E\u0435 \u0432 \u0434\u043E\u0440\u043E\u0433\u043E\u0439 \u0431\u043B\u043E\u043A\u0438\u0440\u0443\u044E\u0449\u0438\u0439 ask \u0438 \u043D\u0435 \u0445\u043E\u0440\u043E\u043D\u0438 \u0432 \u043E\u0442\u0447\u0451\u0442\u0435 \u043E \u0441\u0434\u0430\u0447\u0435). report_weight(note) \u2014 \u0441\u043A\u0430\u0436\u0438 \u0434\u0435\u043C\u043E\u043D\u0443, \u0447\u0442\u043E \u0420\u0410\u0411\u041E\u0422\u0410 \u0422\u042F\u0416\u0415\u041B\u0415\u0415 \u041E\u0416\u0418\u0414\u0410\u041D\u0418\u0419, \u043A\u043E\u0433\u0434\u0430 \u0441\u043E\u0436\u0436\u0435\u043D\u043E \u0431\u043E\u043B\u044C\u0448\u0435 \u043F\u043E\u043B\u043E\u0432\u0438\u043D\u044B \u0442\u0432\u043E\u0435\u0433\u043E \u0431\u044E\u0434\u0436\u0435\u0442\u0430, \u0430 \u0434\u043E \u0441\u0434\u0430\u0447\u0438 \u0434\u0430\u043B\u0435\u043A\u043E: \u043E\u043D \u043F\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0442 \u043D\u043E\u0432\u0443\u044E \u0440\u0430\u0431\u043E\u0442\u0443 \u043D\u0430 \u043C\u0430\u0448\u0438\u043D\u0435, \u043D\u0435 \u0441\u043D\u0438\u043C\u0435\u0442 \u0442\u0435\u0431\u044F \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u043A\u043E\u0439 \u0438 \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442 \u043F\u043E\u0442\u043E\u043B\u043E\u043A \u0442\u0440\u0430\u0442 \u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0445 \u043F\u0440\u0435\u0434\u0435\u043B\u0430\u0445. \u041F\u0440\u043E\u0432\u0435\u0440\u044F\u0435\u0442\u0441\u044F \u043F\u043E \u0444\u0430\u043A\u0442\u0443 \u2014 \u0432\u0435\u0441 \u0434\u0430\u044E\u0442 \u0442\u043E\u043C\u0443, \u043A\u0442\u043E \u041F\u0420\u041E\u0414\u0412\u0418\u0413\u0410\u0415\u0422\u0421\u042F (\u043A\u043E\u043C\u043C\u0438\u0442\u044B/PR/\u0437\u0430\u043A\u0440\u044B\u0442\u044B\u0435 \u043A\u0440\u0438\u0442\u0435\u0440\u0438\u0438); \u0442\u0440\u0430\u0442\u0430 \u0431\u0435\u0437 \u0434\u0432\u0438\u0436\u0435\u043D\u0438\u044F \u0431\u044E\u0434\u0436\u0435\u0442\u0430 \u043D\u0435 \u043F\u043E\u043B\u0443\u0447\u0430\u0435\u0442, \u0435\u0451 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440. \u0417\u043E\u0432\u0438 \u041F\u041E \u0425\u041E\u0414\u0423, \u0430 \u043D\u0435 \u0432 \u043E\u0442\u0447\u0451\u0442\u0435: \u043F\u043E\u0441\u0442\u0444\u0430\u043A\u0442\u0443\u043C \u043E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u0442\u044C \u0443\u0436\u0435 \u043D\u0435\u0447\u0435\u0433\u043E.",
|
|
21846
22138
|
// TASWM-412: третий выход из непонятной задачи. Раньше их было два, и оба плохие —
|
|
21847
22139
|
// угадать постановку (сделает не то) или ask (слот занят, а ответить может только автор
|
|
@@ -22096,8 +22388,9 @@ var REVIEW_FINDINGS_BLOCK = [
|
|
|
22096
22388
|
'\u2022 \u041D\u0430\u0445\u043E\u0434\u043E\u043A \u043D\u0435\u0442 \u2014 \u0431\u043B\u043E\u043A \u0432\u0441\u0451 \u0440\u0430\u0432\u043D\u043E \u043F\u0435\u0447\u0430\u0442\u0430\u0439, \u0441 \u043F\u0443\u0441\u0442\u044B\u043C \u043C\u0430\u0441\u0441\u0438\u0432\u043E\u043C: {"mode": "read", "findings": []}.',
|
|
22097
22389
|
"\u2022 \u041F\u0435\u0440\u0432\u0443\u044E \u0441\u0442\u0440\u043E\u043A\u0443 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430 \u0431\u043B\u043E\u043A \u041D\u0415 \u043E\u0442\u043C\u0435\u043D\u044F\u0435\u0442: APPROVE / REQUEST CHANGES \u0437\u0430\u0433\u043B\u0430\u0432\u043D\u044B\u043C\u0438 \u2014 \u043A\u0430\u043A \u0431\u044B\u043B\u043E. \u041D\u0430\u0445\u043E\u0434\u043A\u0438 \u0432 \u0431\u043B\u043E\u043A\u0435 \u0434\u0443\u0431\u043B\u0438\u0440\u0443\u044E\u0442 \u0442\u043E, \u0447\u0442\u043E \u0442\u044B \u0438 \u0442\u0430\u043A \u043D\u0430\u043F\u0438\u0441\u0430\u043B \u0442\u0435\u043A\u0441\u0442\u043E\u043C, \u0430 \u043D\u0435 \u0437\u0430\u043C\u0435\u043D\u044F\u044E\u0442 \u0440\u0430\u0437\u0431\u043E\u0440."
|
|
22098
22390
|
].join("\n");
|
|
22099
|
-
function buildReviewerPrompt(reviewRun, reviewer, checklist, branch, attachmentsBlock, verifyMode = SWARM_VERIFY, pendingRules = [], ciClosed = null) {
|
|
22391
|
+
function buildReviewerPrompt(reviewRun, reviewer, checklist, branch, attachmentsBlock, verifyMode = SWARM_VERIFY, pendingRules = [], ciClosed = null, worktree) {
|
|
22100
22392
|
const name = reviewer.name || `#${reviewer.id}`;
|
|
22393
|
+
const standRule = promptStandRule(worktree, reviewRun.task_slug);
|
|
22101
22394
|
const rulesBlock = renderPendingRulesBlock(pendingRules);
|
|
22102
22395
|
const prUrl = reviewRun.pr_url ?? "(\u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 PR \u2014 \u0441\u043C. \u043B\u043E\u0433 \u043F\u0440\u043E\u0433\u043E\u043D\u0430)";
|
|
22103
22396
|
const closed = verifyMode === "local" ? null : ciClosed;
|
|
@@ -22108,6 +22401,7 @@ function buildReviewerPrompt(reviewRun, reviewer, checklist, branch, attachments
|
|
|
22108
22401
|
HEADLESS_BLOCK,
|
|
22109
22402
|
"",
|
|
22110
22403
|
`\u0417\u0410\u0414\u0410\u0427\u0410: \u043F\u0440\u043E\u0440\u0435\u0432\u044C\u044E\u0438\u0440\u043E\u0432\u0430\u0442\u044C PR ${prUrl} \u043F\u0440\u043E\u0433\u043E\u043D\u0430 ${reviewRun.task_slug} (\u0434\u0440\u043E\u043D ${reviewRun.name}). \u0422\u044B \u0432 git-worktree \u0441 \u0447\u0435\u043A\u0430\u0443\u0442\u043E\u043C \u0432\u0435\u0442\u043A\u0438 \`${branch}\` (detached, \u043A\u043E\u043D\u0447\u0438\u043A origin) \u2014 \u043A\u043E\u0434 \u0443\u0436\u0435 \u043D\u0430 \u0434\u0438\u0441\u043A\u0435.`,
|
|
22404
|
+
...standRule ? [standRule] : [],
|
|
22111
22405
|
// TASWM-285: PR открыт НЕ в ветку по умолчанию — ревьюер обязан смотреть диф от той же
|
|
22112
22406
|
// базы. Сравнив с main, он увидел бы чужие изменения (всю пачку) как изменения этого PR
|
|
22113
22407
|
// и завалил бы вердикт по коду, которого автор не писал.
|
|
@@ -23519,8 +23813,8 @@ async function spawnOrPrepareInBackground(deps, run2) {
|
|
|
23519
23813
|
void attempt.then(release, release);
|
|
23520
23814
|
let timer;
|
|
23521
23815
|
const background = /* @__PURE__ */ Symbol("background");
|
|
23522
|
-
const waited = new Promise((
|
|
23523
|
-
timer = setTimeout(() =>
|
|
23816
|
+
const waited = new Promise((resolve6) => {
|
|
23817
|
+
timer = setTimeout(() => resolve6(background), SPAWN_INLINE_WAIT_MS);
|
|
23524
23818
|
});
|
|
23525
23819
|
try {
|
|
23526
23820
|
const first = await Promise.race([attempt, waited]);
|
|
@@ -24179,7 +24473,7 @@ async function buildReliefCostCandidatesFor(deps, now, droneCap) {
|
|
|
24179
24473
|
if (deps.exclusiveProject && await deps.exclusiveProject(repo)) continue;
|
|
24180
24474
|
} catch {
|
|
24181
24475
|
}
|
|
24182
|
-
exclusiveRepos.push(
|
|
24476
|
+
exclusiveRepos.push(basename7(repo));
|
|
24183
24477
|
}
|
|
24184
24478
|
const otherHosts = [
|
|
24185
24479
|
...new Set(
|
|
@@ -24327,10 +24621,10 @@ function pickedVerdictEventText(how, verdict, body, mark) {
|
|
|
24327
24621
|
return `${prefix} (${how}): ${payload}${tail2}`;
|
|
24328
24622
|
}
|
|
24329
24623
|
function verdictEventPayload(text) {
|
|
24330
|
-
const
|
|
24331
|
-
const at = text.indexOf(
|
|
24624
|
+
const sep4 = text.startsWith(PICKUP_EVENT_PREFIX) ? "): " : ": ";
|
|
24625
|
+
const at = text.indexOf(sep4);
|
|
24332
24626
|
if (at < 0) return "";
|
|
24333
|
-
return text.slice(at +
|
|
24627
|
+
return text.slice(at + sep4.length).trim().replace(/\s+\[[^\]]*\]\s*$/, "").trim();
|
|
24334
24628
|
}
|
|
24335
24629
|
function isHeaderOnlyVerdict(text) {
|
|
24336
24630
|
if (!text.startsWith(PICKUP_EVENT_PREFIX) && !text.startsWith("\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E \u043E\u0442")) return false;
|
|
@@ -24341,10 +24635,10 @@ var VERIFY_HEADER_LABELS = /* @__PURE__ */ new Set(["\u041D\u0410\u0428\u0401\u0
|
|
|
24341
24635
|
function isVerifyHeaderOnly(text) {
|
|
24342
24636
|
const pickup = text.startsWith(VERIFY_PICKUP_EVENT_PREFIX);
|
|
24343
24637
|
if (!pickup && !text.startsWith("\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 \u043E\u0442")) return false;
|
|
24344
|
-
const
|
|
24345
|
-
const at = text.indexOf(
|
|
24638
|
+
const sep4 = pickup ? "): " : ": ";
|
|
24639
|
+
const at = text.indexOf(sep4);
|
|
24346
24640
|
if (at < 0) return true;
|
|
24347
|
-
const rest = text.slice(at +
|
|
24641
|
+
const rest = text.slice(at + sep4.length).trim().replace(/\s+\[[^\]]*\]\s*$/, "").trim();
|
|
24348
24642
|
return rest.length === 0 || VERIFY_HEADER_LABELS.has(rest);
|
|
24349
24643
|
}
|
|
24350
24644
|
function isClippedPickup(text) {
|
|
@@ -25625,7 +25919,7 @@ async function resolveConflict(deps, reviewRun) {
|
|
|
25625
25919
|
model: reviewRun.model,
|
|
25626
25920
|
review_model: reviewRun.review_model
|
|
25627
25921
|
});
|
|
25628
|
-
const wt = join40(deps.worktreesDir,
|
|
25922
|
+
const wt = join40(deps.worktreesDir, basename7(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
|
|
25629
25923
|
try {
|
|
25630
25924
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
25631
25925
|
await deps.git.setWorktreeIdentity(wt, resolver.name);
|
|
@@ -25706,7 +26000,7 @@ async function spawnReviewer(deps, reviewRun, files) {
|
|
|
25706
26000
|
// (своей у ревьюера нет, TASWM-204), и коммент с вердиктом должен уехать именно туда.
|
|
25707
26001
|
workspace_id: reviewRun.workspace_id
|
|
25708
26002
|
});
|
|
25709
|
-
const wt = join40(deps.worktreesDir,
|
|
26003
|
+
const wt = join40(deps.worktreesDir, basename7(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
|
|
25710
26004
|
try {
|
|
25711
26005
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
25712
26006
|
await deps.git.setWorktreeIdentity(wt, reviewer.name);
|
|
@@ -25717,7 +26011,7 @@ async function spawnReviewer(deps, reviewRun, files) {
|
|
|
25717
26011
|
(text) => deps.db.addEvent(reviewer.id, "step", text)
|
|
25718
26012
|
);
|
|
25719
26013
|
const pendingRules = await deps.pendingRepoRules?.(repo, reviewRun.task_slug).catch(() => []) ?? [];
|
|
25720
|
-
const prompt = buildReviewerPrompt(reviewRun, reviewer, checklist, branch, attachments, verifyMode, pendingRules, ciClosed);
|
|
26014
|
+
const prompt = buildReviewerPrompt(reviewRun, reviewer, checklist, branch, attachments, verifyMode, pendingRules, ciClosed, wt);
|
|
25721
26015
|
const pid = deps.launch({ worktree: wt, run: reviewer, prompt });
|
|
25722
26016
|
deps.db.updateRun(reviewer.id, { status: "running", worktree_path: wt, branch, pid, pr_url: reviewRun.pr_url });
|
|
25723
26017
|
deps.db.addEvent(reviewRun.id, "step", `\u0430\u0432\u0442\u043E-\u0440\u0435\u0432\u044C\u044E: \u043F\u043E\u0434\u043D\u044F\u0442 \u0440\u0435\u0432\u044C\u044E\u0435\u0440 ${reviewer.name} (#${reviewer.id})`);
|
|
@@ -25737,8 +26031,9 @@ var VERIFY_SCOPE_BLOCK = [
|
|
|
25737
26031
|
"\u2022 \u041F\u0440\u043E\u0447\u0438\u0442\u0430\u043D\u043D\u043E\u0435 \u043D\u0435 \u043F\u0435\u0440\u0435\u0447\u0438\u0442\u044B\u0432\u0430\u0439, \u043E\u0434\u0438\u043D \u0432\u043E\u043F\u0440\u043E\u0441 \u2014 \u043E\u0434\u0438\u043D \u0437\u0430\u0445\u043E\u0434. \u041D\u0435 \u0441\u043E\u0448\u043B\u043E\u0441\u044C \u0441\u043E \u0432\u0442\u043E\u0440\u043E\u0433\u043E \u0440\u0430\u0437\u0430 \u2014 \u0437\u0430\u043F\u0438\u0441\u044B\u0432\u0430\u0439 \u043A\u0430\u043A \u043D\u0430\u0445\u043E\u0434\u043A\u0443, \u0430 \u043D\u0435 \u043D\u0430\u0447\u0438\u043D\u0430\u0439 \u0442\u0440\u0435\u0442\u0438\u0439 \u043A\u0440\u0443\u0433.",
|
|
25738
26032
|
"\u2022 \u0412\u0435\u0440\u0434\u0438\u043A\u0442 \u043F\u043E \u0442\u043E\u043C\u0443, \u0447\u0442\u043E \u0443\u0441\u043F\u0435\u043B \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C, \u0412\u0421\u0415\u0413\u0414\u0410 \u043B\u0443\u0447\u0448\u0435 \u0438\u0434\u0435\u0430\u043B\u044C\u043D\u043E\u0433\u043E \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0430, \u043A\u043E\u0442\u043E\u0440\u043E\u0433\u043E \u043D\u0435 \u0431\u0443\u0434\u0435\u0442. \u0427\u0435\u0441\u0442\u043D\u043E \u043D\u0430\u0437\u043E\u0432\u0438, \u0447\u0435\u0433\u043E \u043D\u0435 \u0441\u043C\u043E\u0442\u0440\u0435\u043B."
|
|
25739
26033
|
].join("\n");
|
|
25740
|
-
function buildVerifierPrompt(verifiedRun, verifier, branch, files, attachmentsBlock, verifyMode = SWARM_VERIFY) {
|
|
26034
|
+
function buildVerifierPrompt(verifiedRun, verifier, branch, files, attachmentsBlock, verifyMode = SWARM_VERIFY, worktree) {
|
|
25741
26035
|
const name = verifier.name || `#${verifier.id}`;
|
|
26036
|
+
const standRule = promptStandRule(worktree, verifiedRun.task_slug);
|
|
25742
26037
|
const prUrl = verifiedRun.pr_url ?? "(\u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 PR \u2014 \u0441\u043C. \u043B\u043E\u0433 \u043F\u0440\u043E\u0433\u043E\u043D\u0430)";
|
|
25743
26038
|
const taskUrl = verifiedRun.task_url ? ` \u0417\u0430\u0434\u0430\u0447\u0430: ${verifiedRun.task_url}.` : "";
|
|
25744
26039
|
const filesBlock = files.length ? `\u0424\u0430\u0439\u043B\u044B \u0434\u0438\u0444\u0444\u0430 (${files.length}): ${files.slice(0, 40).join(", ")}${files.length > 40 ? " \u2026" : ""}.` : "\u0421\u043F\u0438\u0441\u043E\u043A \u0444\u0430\u0439\u043B\u043E\u0432 \u0434\u0438\u0444\u0444\u0430 gh \u043D\u0435 \u043E\u0442\u0434\u0430\u043B \u2014 \u0432\u043E\u0437\u044C\u043C\u0438 \u0435\u0433\u043E \u0441\u0430\u043C: `gh pr diff --name-only`.";
|
|
@@ -25748,6 +26043,7 @@ function buildVerifierPrompt(verifiedRun, verifier, branch, files, attachmentsBl
|
|
|
25748
26043
|
HEADLESS_BLOCK,
|
|
25749
26044
|
"",
|
|
25750
26045
|
`\u0417\u0410\u0414\u0410\u0427\u0410: \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C, \u041F\u0420\u0410\u0412\u0414\u0410 \u041B\u0418 \u0441\u0434\u0435\u043B\u0430\u043D\u043E \u0442\u043E, \u0447\u0442\u043E \u0437\u0430\u044F\u0432\u043B\u0435\u043D\u043E \u0432 PR ${prUrl} \u043F\u0440\u043E\u0433\u043E\u043D\u0430 ${verifiedRun.task_slug} (\u0434\u0440\u043E\u043D ${verifiedRun.name}).${taskUrl} \u0422\u044B \u0432 git-worktree \u0441 \u0447\u0435\u043A\u0430\u0443\u0442\u043E\u043C \u0432\u0435\u0442\u043A\u0438 \`${branch}\` (detached, \u043A\u043E\u043D\u0447\u0438\u043A origin) \u2014 \u043A\u043E\u0434 \u0443\u0436\u0435 \u043D\u0430 \u0434\u0438\u0441\u043A\u0435.`,
|
|
26046
|
+
...standRule ? [standRule] : [],
|
|
25751
26047
|
...verifiedRun.base_branch ? [`\u26A0\uFE0F PR \u043E\u0442\u043A\u0440\u044B\u0442 \u0432 \u0432\u0435\u0442\u043A\u0443 \`${verifiedRun.base_branch}\`, \u0430 \u043D\u0435 \u0432 \u0432\u0435\u0442\u043A\u0443 \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E: \u0441\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u0439 \u0441 \u043D\u0435\u0439 (\`git diff origin/${verifiedRun.base_branch}...HEAD\`), \u0438\u043D\u0430\u0447\u0435 \u043F\u0440\u0438\u043C\u0435\u0448\u044C \u0447\u0443\u0436\u0438\u0435 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F \u043F\u0430\u0447\u043A\u0438 \u0437\u0430 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F \u044D\u0442\u043E\u0433\u043E \u0434\u0440\u043E\u043D\u0430.`] : [],
|
|
25752
26048
|
filesBlock,
|
|
25753
26049
|
"",
|
|
@@ -25787,7 +26083,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
|
|
|
25787
26083
|
// штамп цикла: фикс-итерацию проверяет свежий верификатор
|
|
25788
26084
|
workspace_id: verifiedRun.workspace_id
|
|
25789
26085
|
});
|
|
25790
|
-
const wt = join40(deps.worktreesDir,
|
|
26086
|
+
const wt = join40(deps.worktreesDir, basename7(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
|
|
25791
26087
|
try {
|
|
25792
26088
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
25793
26089
|
await deps.git.setWorktreeIdentity(wt, verifier.name);
|
|
@@ -25797,7 +26093,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
|
|
|
25797
26093
|
verifiedRun.workspace_id,
|
|
25798
26094
|
(text) => deps.db.addEvent(verifier.id, "step", text)
|
|
25799
26095
|
);
|
|
25800
|
-
const prompt = buildVerifierPrompt(verifiedRun, verifier, branch, files, attachments, verifyMode);
|
|
26096
|
+
const prompt = buildVerifierPrompt(verifiedRun, verifier, branch, files, attachments, verifyMode, wt);
|
|
25801
26097
|
const pid = deps.launch({ worktree: wt, run: verifier, prompt });
|
|
25802
26098
|
deps.db.updateRun(verifier.id, { status: "running", worktree_path: wt, branch, pid, pr_url: verifiedRun.pr_url });
|
|
25803
26099
|
deps.db.addEvent(verifiedRun.id, "step", `\u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u044F: \u043F\u043E\u0434\u043D\u044F\u0442 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440 ${verifier.name} (#${verifier.id}) \u2014 \u043F\u0440\u043E\u0432\u0435\u0440\u044F\u0435\u0442 \u0437\u0430\u044F\u0432\u043B\u0435\u043D\u043D\u043E\u0435 \u043D\u0430 \u043E\u043F\u0440\u043E\u0432\u0435\u0440\u0436\u0435\u043D\u0438\u0435`);
|
|
@@ -25912,7 +26208,7 @@ async function respawnRun(deps, run2, mode, nudge) {
|
|
|
25912
26208
|
taskTitle: task?.title ?? null,
|
|
25913
26209
|
taskUrl: task?.url ?? null,
|
|
25914
26210
|
...verifyMode ? { verifyMode } : {}
|
|
25915
|
-
}) : runToSpawn.kind === "hero" ? buildHeroPrompt(task, runToSpawn, taskContext, attachments) : buildPrompt(task, runToSpawn, verifyMode, taskContext, attachments, renderZoneMemoryBlock(runToSpawn.area, zoneNotes));
|
|
26211
|
+
}) : runToSpawn.kind === "hero" ? buildHeroPrompt(task, runToSpawn, taskContext, attachments) : buildPrompt(task, runToSpawn, verifyMode, taskContext, attachments, renderZoneMemoryBlock(runToSpawn.area, zoneNotes), wt);
|
|
25916
26212
|
const notice = depsPromptNotice(depsReport);
|
|
25917
26213
|
const prompt = [freshPrompt, notice, nudge].filter(Boolean).join("\n\n");
|
|
25918
26214
|
const pid = deps.launch({ worktree: wt, run: runToSpawn, prompt });
|
|
@@ -25986,7 +26282,7 @@ async function makeStore(repo, worktreesDir, repoFlag, executorFor) {
|
|
|
25986
26282
|
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`);
|
|
25987
26283
|
}
|
|
25988
26284
|
}
|
|
25989
|
-
const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW,
|
|
26285
|
+
const scanRootsList = resolveScanRoots(SWARM_SCAN_ROOTS_RAW, homedir9(), repoPaths);
|
|
25990
26286
|
const repoMap = emptyRepoMapState(scanRootsList);
|
|
25991
26287
|
if (SWARM_BACKEND !== "client") {
|
|
25992
26288
|
const { SwarmDb: SwarmDb2 } = await loadSqlite();
|
|
@@ -26122,6 +26418,41 @@ var modelLimitsPoller = null;
|
|
|
26122
26418
|
function lastModelLimits() {
|
|
26123
26419
|
return modelLimitsPoller?.report() ?? null;
|
|
26124
26420
|
}
|
|
26421
|
+
function sweepDaemonStands(opts) {
|
|
26422
|
+
const { db, worktreesDir } = opts;
|
|
26423
|
+
const homeDir = opts.homeDir ?? homedir9();
|
|
26424
|
+
const runs = db.listRuns();
|
|
26425
|
+
const runsWithWorktree = runs.filter((r) => r.worktree_path);
|
|
26426
|
+
const bySlug = /* @__PURE__ */ new Map();
|
|
26427
|
+
for (const r of runs) {
|
|
26428
|
+
const cur = bySlug.get(r.task_slug) ?? { live: false, liveRunIds: [] };
|
|
26429
|
+
if (!isTerminalStatus(r.status)) {
|
|
26430
|
+
cur.live = true;
|
|
26431
|
+
cur.liveRunIds.push(r.id);
|
|
26432
|
+
}
|
|
26433
|
+
bySlug.set(r.task_slug, cur);
|
|
26434
|
+
}
|
|
26435
|
+
return sweepOrphans({
|
|
26436
|
+
worktreesDir,
|
|
26437
|
+
activeWorktreePaths: new Set(runsWithWorktree.filter((r) => !isTerminalStatus(r.status)).map((r) => r.worktree_path)),
|
|
26438
|
+
containerRunPrefixes: runsWithWorktree.map((r) => ({
|
|
26439
|
+
prefix: composeProjectPrefix(basename7(r.worktree_path)),
|
|
26440
|
+
active: !isTerminalStatus(r.status)
|
|
26441
|
+
})),
|
|
26442
|
+
...opts.scan ? { scan: opts.scan } : {},
|
|
26443
|
+
...opts.killOpts ? { killOpts: opts.killOpts } : {},
|
|
26444
|
+
...opts.docker ? { docker: opts.docker } : {},
|
|
26445
|
+
namedStands: {
|
|
26446
|
+
tasks: [...bySlug.entries()].map(([slug, v]) => ({ slug, live: v.live, liveRunIds: v.liveRunIds })),
|
|
26447
|
+
homeDir,
|
|
26448
|
+
...opts.nowMs != null ? { nowMs: opts.nowMs } : {},
|
|
26449
|
+
listComplete: !(db instanceof SwarmClient) || db.runsHydrateComplete(),
|
|
26450
|
+
onOpenPort: ({ runIds, text }) => {
|
|
26451
|
+
for (const id of runIds) db.addEvent(id, "step", text);
|
|
26452
|
+
}
|
|
26453
|
+
}
|
|
26454
|
+
});
|
|
26455
|
+
}
|
|
26125
26456
|
async function runDaemon(opts) {
|
|
26126
26457
|
installCrashGuards();
|
|
26127
26458
|
installLogStamps();
|
|
@@ -26683,7 +27014,7 @@ async function runDaemon(opts) {
|
|
|
26683
27014
|
fetchFile: taskClient?.fetchFile?.bind(taskClient),
|
|
26684
27015
|
onEvent: (text) => db.addEvent(r.id, "step", text)
|
|
26685
27016
|
});
|
|
26686
|
-
return r.kind === "hero" ? buildHeroPrompt(task, r, taskContext, attachments) : buildPrompt(task, r, verifyMode, taskContext, attachments, renderZoneMemoryBlock(r.area, zoneNotes));
|
|
27017
|
+
return r.kind === "hero" ? buildHeroPrompt(task, r, taskContext, attachments) : buildPrompt(task, r, verifyMode, taskContext, attachments, renderZoneMemoryBlock(r.area, zoneNotes), worktree);
|
|
26687
27018
|
}
|
|
26688
27019
|
},
|
|
26689
27020
|
runToSpawn
|
|
@@ -26813,18 +27144,8 @@ async function runDaemon(opts) {
|
|
|
26813
27144
|
// paused/stalled/queued/review/storm_dead тоже держат свой worktree/контейнеры, их
|
|
26814
27145
|
// сносить рано), терминальные (done/failed/stopped/superseded) — кандидаты на снос.
|
|
26815
27146
|
sweep: {
|
|
26816
|
-
run: () => {
|
|
26817
|
-
|
|
26818
|
-
return sweepOrphans({
|
|
26819
|
-
worktreesDir,
|
|
26820
|
-
activeWorktreePaths: new Set(runsWithWorktree.filter((r) => !isTerminalStatus(r.status)).map((r) => r.worktree_path)),
|
|
26821
|
-
containerRunPrefixes: runsWithWorktree.map((r) => ({
|
|
26822
|
-
prefix: composeProjectPrefix(basename6(r.worktree_path)),
|
|
26823
|
-
active: !isTerminalStatus(r.status)
|
|
26824
|
-
}))
|
|
26825
|
-
}).then(() => {
|
|
26826
|
-
});
|
|
26827
|
-
},
|
|
27147
|
+
run: () => sweepDaemonStands({ db, worktreesDir }).then(() => {
|
|
27148
|
+
}),
|
|
26828
27149
|
intervalMs: SWARM_SWEEP_INTERVAL_MS,
|
|
26829
27150
|
lastAt: null
|
|
26830
27151
|
},
|
|
@@ -27568,6 +27889,7 @@ export {
|
|
|
27568
27889
|
clipChars,
|
|
27569
27890
|
configureReviewCycleLimit,
|
|
27570
27891
|
cycleCapHolder,
|
|
27892
|
+
dockerStandRules,
|
|
27571
27893
|
effectiveReviewCycleLimit,
|
|
27572
27894
|
hasLiveDescendant,
|
|
27573
27895
|
hasPreparingRuns,
|
|
@@ -27595,6 +27917,7 @@ export {
|
|
|
27595
27917
|
spawnVerifier,
|
|
27596
27918
|
subrunWaitNudge,
|
|
27597
27919
|
swarmModelsReady,
|
|
27920
|
+
sweepDaemonStands,
|
|
27598
27921
|
syncCrashedOnStartup,
|
|
27599
27922
|
tickOnce,
|
|
27600
27923
|
verdictCommentMark,
|