@taskless-app/swarm 0.6.89 → 0.6.91
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/cli.js
CHANGED
|
@@ -1410,8 +1410,8 @@ var init_taskWeight = __esm({
|
|
|
1410
1410
|
function hasZoneModel(m) {
|
|
1411
1411
|
return m.tasks > 0 && m.zones.length > 0;
|
|
1412
1412
|
}
|
|
1413
|
-
function testFileFeature(
|
|
1414
|
-
const head =
|
|
1413
|
+
function testFileFeature(basename8) {
|
|
1414
|
+
const head = basename8.replace(/\.(test|spec)\.[a-z]+$/i, "").split(".")[0].toLowerCase();
|
|
1415
1415
|
return head && !GENERIC_DIRS.has(head) ? head : null;
|
|
1416
1416
|
}
|
|
1417
1417
|
function pathZoneCandidate(path) {
|
|
@@ -4061,6 +4061,19 @@ var init_toolFailure = __esm({
|
|
|
4061
4061
|
}
|
|
4062
4062
|
});
|
|
4063
4063
|
|
|
4064
|
+
// src/dockerCli.ts
|
|
4065
|
+
function dockerCli(args) {
|
|
4066
|
+
return impl(args);
|
|
4067
|
+
}
|
|
4068
|
+
var impl;
|
|
4069
|
+
var init_dockerCli = __esm({
|
|
4070
|
+
"src/dockerCli.ts"() {
|
|
4071
|
+
"use strict";
|
|
4072
|
+
init_quietExec();
|
|
4073
|
+
impl = (args) => execQuiet("docker", args);
|
|
4074
|
+
}
|
|
4075
|
+
});
|
|
4076
|
+
|
|
4064
4077
|
// src/procList.ts
|
|
4065
4078
|
import { readFileSync as readFileSync9 } from "fs";
|
|
4066
4079
|
function parsePsRows(out) {
|
|
@@ -4145,8 +4158,10 @@ var init_procList = __esm({
|
|
|
4145
4158
|
});
|
|
4146
4159
|
|
|
4147
4160
|
// src/procCleanup.ts
|
|
4161
|
+
import { homedir as homedir5 } from "os";
|
|
4162
|
+
import { isAbsolute, resolve as resolve2, sep } from "path";
|
|
4148
4163
|
function sleep(ms) {
|
|
4149
|
-
return new Promise((
|
|
4164
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
4150
4165
|
}
|
|
4151
4166
|
function parseLsofCwd(output) {
|
|
4152
4167
|
const rows = [];
|
|
@@ -4255,24 +4270,132 @@ function composeProjectPrefix(worktreeDirName) {
|
|
|
4255
4270
|
function containerBelongsToPrefix(name, prefix) {
|
|
4256
4271
|
return name === prefix || name.startsWith(`${prefix}-`);
|
|
4257
4272
|
}
|
|
4258
|
-
function
|
|
4273
|
+
function blankLabel(raw) {
|
|
4274
|
+
const t = (raw ?? "").trim();
|
|
4275
|
+
if (!t || t === "<no value>" || t === "<nil>") return null;
|
|
4276
|
+
return t;
|
|
4277
|
+
}
|
|
4278
|
+
function directoryWithin(candidate, root) {
|
|
4279
|
+
if (!isAbsolute(candidate) || !isAbsolute(root)) return false;
|
|
4280
|
+
const base3 = resolve2(root);
|
|
4281
|
+
const dir = resolve2(candidate);
|
|
4282
|
+
if (dir === base3) return true;
|
|
4283
|
+
const prefix = base3.endsWith(sep) ? base3 : `${base3}${sep}`;
|
|
4284
|
+
return dir.startsWith(prefix);
|
|
4285
|
+
}
|
|
4286
|
+
function isOwnStand(container, homeDir = homedir5()) {
|
|
4287
|
+
const home = blankLabel(container.swarmHome ?? void 0);
|
|
4288
|
+
if (home) return directoryWithin(home, homeDir);
|
|
4289
|
+
const dir = blankLabel(container.workingDir ?? void 0);
|
|
4290
|
+
if (!dir) return false;
|
|
4291
|
+
return directoryWithin(dir, homeDir);
|
|
4292
|
+
}
|
|
4293
|
+
function parseContainerPs(output) {
|
|
4294
|
+
const rows = [];
|
|
4295
|
+
for (const line of output.split("\n")) {
|
|
4296
|
+
if (!line.trim()) continue;
|
|
4297
|
+
const [name, createdAt, ports, project, workingDir, swarmHome] = line.split(" ");
|
|
4298
|
+
if (!name) continue;
|
|
4299
|
+
rows.push({
|
|
4300
|
+
name,
|
|
4301
|
+
createdAt: createdAt ?? "",
|
|
4302
|
+
ports: ports ?? "",
|
|
4303
|
+
project: blankLabel(project),
|
|
4304
|
+
workingDir: blankLabel(workingDir),
|
|
4305
|
+
swarmHome: blankLabel(swarmHome)
|
|
4306
|
+
});
|
|
4307
|
+
}
|
|
4308
|
+
return rows;
|
|
4309
|
+
}
|
|
4310
|
+
function listContainersRich() {
|
|
4259
4311
|
try {
|
|
4260
|
-
return
|
|
4312
|
+
return parseContainerPs(dockerCli(["ps", "-a", "--format", CONTAINER_PS_FORMAT]));
|
|
4261
4313
|
} catch (e) {
|
|
4262
4314
|
logTransientSpawnError("docker ps", e);
|
|
4263
4315
|
return [];
|
|
4264
4316
|
}
|
|
4265
4317
|
}
|
|
4266
|
-
function
|
|
4267
|
-
|
|
4318
|
+
function defaultDockerExec(args) {
|
|
4319
|
+
return dockerCli(args);
|
|
4320
|
+
}
|
|
4321
|
+
function dockerLines(out) {
|
|
4322
|
+
return out.split("\n").map((s) => s.trim()).filter(Boolean);
|
|
4323
|
+
}
|
|
4324
|
+
function inspectStand(name, exec) {
|
|
4325
|
+
try {
|
|
4326
|
+
const raw = exec(["inspect", "--format", INSPECT_STAND_FORMAT, name]);
|
|
4327
|
+
const [project, workingDir, swarmHome] = raw.split(" ");
|
|
4328
|
+
return { project: blankLabel(project), workingDir: blankLabel(workingDir), swarmHome: blankLabel(swarmHome) };
|
|
4329
|
+
} catch {
|
|
4330
|
+
return null;
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
function listProjectStands(project, exec) {
|
|
4334
|
+
try {
|
|
4335
|
+
const out = exec(["ps", "-a", "--filter", `label=com.docker.compose.project=${project}`, "--format", PROJECT_PS_FORMAT]);
|
|
4336
|
+
const rows = [];
|
|
4337
|
+
for (const line of out.split("\n")) {
|
|
4338
|
+
if (!line.trim()) continue;
|
|
4339
|
+
const [name, workingDir, swarmHome] = line.split(" ");
|
|
4340
|
+
if (!name?.trim()) continue;
|
|
4341
|
+
rows.push({ workingDir: blankLabel(workingDir), swarmHome: blankLabel(swarmHome) });
|
|
4342
|
+
}
|
|
4343
|
+
return rows;
|
|
4344
|
+
} catch (e) {
|
|
4345
|
+
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)}`);
|
|
4346
|
+
return null;
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
function removeProjectResources(project, exec) {
|
|
4350
|
+
let left;
|
|
4351
|
+
try {
|
|
4352
|
+
left = exec(["ps", "-a", "-q", "--filter", `label=com.docker.compose.project=${project}`]).trim();
|
|
4353
|
+
} catch (e) {
|
|
4354
|
+
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)}`);
|
|
4355
|
+
return;
|
|
4356
|
+
}
|
|
4357
|
+
if (left) return;
|
|
4358
|
+
try {
|
|
4359
|
+
const nets = dockerLines(exec(["network", "ls", "-q", "--filter", `label=com.docker.compose.project=${project}`]));
|
|
4360
|
+
for (const id of nets) exec(["network", "rm", id]);
|
|
4361
|
+
} catch (e) {
|
|
4362
|
+
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)}`);
|
|
4363
|
+
}
|
|
4364
|
+
try {
|
|
4365
|
+
const vols = dockerLines(exec(["volume", "ls", "-q", "--filter", `label=com.docker.compose.project=${project}`]));
|
|
4366
|
+
for (const id of vols) exec(["volume", "rm", id]);
|
|
4367
|
+
} catch (e) {
|
|
4368
|
+
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)}`);
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
function removeContainers(names, exec = defaultDockerExec, homeDir = homedir5()) {
|
|
4372
|
+
const own = [];
|
|
4268
4373
|
for (const name of names) {
|
|
4374
|
+
const stand = inspectStand(name, exec);
|
|
4375
|
+
if (!stand || !isOwnStand(stand, homeDir)) {
|
|
4376
|
+
if (stand) console.warn(`[procCleanup] ${name} \u043D\u0435 \u043D\u0430\u0448 \u0441\u0442\u0435\u043D\u0434 \u2014 \u043D\u0435 \u0441\u043D\u043E\u0448\u0443`);
|
|
4377
|
+
continue;
|
|
4378
|
+
}
|
|
4379
|
+
own.push({ name, project: stand.project });
|
|
4380
|
+
}
|
|
4381
|
+
const tainted = /* @__PURE__ */ new Set();
|
|
4382
|
+
const projects = new Set(own.map((item) => item.project).filter((project) => !!project));
|
|
4383
|
+
for (const project of projects) {
|
|
4384
|
+
const rows = listProjectStands(project, exec);
|
|
4385
|
+
if (rows == null || rows.some((row) => !isOwnStand(row, homeDir))) tainted.add(project);
|
|
4386
|
+
}
|
|
4387
|
+
const removed = [];
|
|
4388
|
+
const cleanProjects = /* @__PURE__ */ new Set();
|
|
4389
|
+
for (const item of own) {
|
|
4269
4390
|
try {
|
|
4270
|
-
|
|
4271
|
-
removed.push(name);
|
|
4391
|
+
exec(["rm", "-f", "-v", item.name]);
|
|
4392
|
+
removed.push(item.name);
|
|
4393
|
+
if (item.project && !tainted.has(item.project)) cleanProjects.add(item.project);
|
|
4272
4394
|
} catch (e) {
|
|
4273
|
-
console.warn(`[procCleanup] docker rm -f ${name} \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F: ${String(e)}`);
|
|
4395
|
+
console.warn(`[procCleanup] docker rm -f -v ${item.name} \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F: ${String(e)}`);
|
|
4274
4396
|
}
|
|
4275
4397
|
}
|
|
4398
|
+
for (const project of cleanProjects) removeProjectResources(project, exec);
|
|
4276
4399
|
return removed;
|
|
4277
4400
|
}
|
|
4278
4401
|
async function cleanupWorktreeProcesses(worktree, opts = {}) {
|
|
@@ -4292,20 +4415,28 @@ async function cleanupWorktreeProcesses(worktree, opts = {}) {
|
|
|
4292
4415
|
try {
|
|
4293
4416
|
const prefix = composeProjectPrefix(worktree.split("/").filter(Boolean).pop() ?? "");
|
|
4294
4417
|
if (!prefix) return;
|
|
4295
|
-
const
|
|
4418
|
+
const homeDir = opts.docker?.homeDir ?? homedir5();
|
|
4419
|
+
const listed = opts.docker?.list ? opts.docker.list() : opts.docker?.names ? null : listContainersRich();
|
|
4420
|
+
const names = listed ? listed.filter((view) => containerBelongsToPrefix(view.name, prefix) && isOwnStand(view, homeDir)).map((view) => view.name) : [];
|
|
4296
4421
|
if (!names.length) return;
|
|
4297
|
-
const removed = (opts.docker?.remove ?? removeContainers)(names);
|
|
4422
|
+
const removed = (opts.docker?.remove ?? ((picked) => removeContainers(picked, defaultDockerExec, homeDir)))(names);
|
|
4298
4423
|
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(", ")})`);
|
|
4299
4424
|
} catch (e) {
|
|
4300
4425
|
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);
|
|
4301
4426
|
}
|
|
4302
4427
|
}
|
|
4428
|
+
var NAMED_STAND_MIN_AGE_MS, CONTAINER_PS_FORMAT, INSPECT_STAND_FORMAT, PROJECT_PS_FORMAT;
|
|
4303
4429
|
var init_procCleanup = __esm({
|
|
4304
4430
|
"src/procCleanup.ts"() {
|
|
4305
4431
|
"use strict";
|
|
4432
|
+
init_dockerCli();
|
|
4306
4433
|
init_quietExec();
|
|
4307
4434
|
init_resources();
|
|
4308
4435
|
init_procList();
|
|
4436
|
+
NAMED_STAND_MIN_AGE_MS = 6 * 60 * 60 * 1e3;
|
|
4437
|
+
CONTAINER_PS_FORMAT = '{{.Names}} {{.CreatedAt}} {{.Ports}} {{.Label "com.docker.compose.project"}} {{.Label "com.docker.compose.project.working_dir"}} {{.Label "taskless.swarm.home"}}';
|
|
4438
|
+
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"}}';
|
|
4439
|
+
PROJECT_PS_FORMAT = '{{.Names}} {{.Label "com.docker.compose.project.working_dir"}} {{.Label "taskless.swarm.home"}}';
|
|
4309
4440
|
}
|
|
4310
4441
|
});
|
|
4311
4442
|
|
|
@@ -4345,7 +4476,7 @@ var init_package = __esm({
|
|
|
4345
4476
|
"package.json"() {
|
|
4346
4477
|
package_default = {
|
|
4347
4478
|
name: "@taskless-app/swarm",
|
|
4348
|
-
version: "0.6.
|
|
4479
|
+
version: "0.6.91",
|
|
4349
4480
|
type: "module",
|
|
4350
4481
|
description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
|
|
4351
4482
|
keywords: [
|
|
@@ -4397,7 +4528,7 @@ var init_package = __esm({
|
|
|
4397
4528
|
undici: "^7.30.1",
|
|
4398
4529
|
zod: "3.25.76"
|
|
4399
4530
|
},
|
|
4400
|
-
gitHead: "
|
|
4531
|
+
gitHead: "74ce3ffa5ec959f7078e663a22ef094b7f0f3c55"
|
|
4401
4532
|
};
|
|
4402
4533
|
}
|
|
4403
4534
|
});
|
|
@@ -4796,7 +4927,7 @@ var init_oauth = __esm({
|
|
|
4796
4927
|
// src/git.ts
|
|
4797
4928
|
import { existsSync as existsSync12, readdirSync as readdirSync11, realpathSync as realpathSync2, statSync as statSync11 } from "fs";
|
|
4798
4929
|
import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
|
|
4799
|
-
import { isAbsolute, join as join17, resolve as
|
|
4930
|
+
import { isAbsolute as isAbsolute2, join as join17, resolve as resolve3, sep as sep3 } from "path";
|
|
4800
4931
|
import { $ as $5 } from "execa";
|
|
4801
4932
|
function gitNet(repo, args, timeoutMs) {
|
|
4802
4933
|
return withHardTimeout(
|
|
@@ -4828,7 +4959,7 @@ function samePath(a, b) {
|
|
|
4828
4959
|
try {
|
|
4829
4960
|
return realpathSync2(p);
|
|
4830
4961
|
} catch {
|
|
4831
|
-
return
|
|
4962
|
+
return resolve3(p);
|
|
4832
4963
|
}
|
|
4833
4964
|
};
|
|
4834
4965
|
const [x, y] = [norm(a), norm(b)];
|
|
@@ -5005,7 +5136,7 @@ async function gitPath(worktree, flag) {
|
|
|
5005
5136
|
const out = await $5({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
|
|
5006
5137
|
const raw = out.stdout.trim();
|
|
5007
5138
|
if (out.exitCode !== 0 || !raw) return null;
|
|
5008
|
-
return
|
|
5139
|
+
return isAbsolute2(raw) ? raw : join17(worktree, raw);
|
|
5009
5140
|
}
|
|
5010
5141
|
async function ensureWorktreeHygiene(worktree) {
|
|
5011
5142
|
for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
|
|
@@ -5030,7 +5161,7 @@ async function installGuardHooks(worktree) {
|
|
|
5030
5161
|
}
|
|
5031
5162
|
}
|
|
5032
5163
|
function posix(p) {
|
|
5033
|
-
return (
|
|
5164
|
+
return (sep3 === "\\" ? p.replace(/\\/g, "/") : p).replace(/\/+$/, "");
|
|
5034
5165
|
}
|
|
5035
5166
|
async function previousHooksPath(worktree) {
|
|
5036
5167
|
for (const scope of ["--local", "--global", "--system"]) {
|
|
@@ -5121,7 +5252,7 @@ var init_attachments = __esm({
|
|
|
5121
5252
|
|
|
5122
5253
|
// src/shotUpload.ts
|
|
5123
5254
|
import { readFile as fsReadFile } from "fs/promises";
|
|
5124
|
-
import { basename as
|
|
5255
|
+
import { basename as basename6, isAbsolute as isAbsolute3, join as join19 } from "path";
|
|
5125
5256
|
var SHOT_MAX_FILE_BYTES;
|
|
5126
5257
|
var init_shotUpload = __esm({
|
|
5127
5258
|
"src/shotUpload.ts"() {
|
|
@@ -5447,14 +5578,14 @@ function createNetworkSettleTracker(target) {
|
|
|
5447
5578
|
});
|
|
5448
5579
|
target.on("requestfinished", onDone);
|
|
5449
5580
|
target.on("requestfailed", onDone);
|
|
5450
|
-
const settleOnce = (quietMs, budgetMs) => new Promise((
|
|
5581
|
+
const settleOnce = (quietMs, budgetMs) => new Promise((resolve6) => {
|
|
5451
5582
|
let quietTimer;
|
|
5452
5583
|
const hardTimer = setTimeout(finish, Math.max(0, budgetMs));
|
|
5453
5584
|
function finish() {
|
|
5454
5585
|
clearTimeout(quietTimer);
|
|
5455
5586
|
clearTimeout(hardTimer);
|
|
5456
5587
|
onChange.delete(check);
|
|
5457
|
-
|
|
5588
|
+
resolve6();
|
|
5458
5589
|
}
|
|
5459
5590
|
function check() {
|
|
5460
5591
|
clearTimeout(quietTimer);
|
|
@@ -5731,7 +5862,7 @@ __export(db_exports, {
|
|
|
5731
5862
|
import { createRequire as createRequire2 } from "module";
|
|
5732
5863
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
5733
5864
|
import { existsSync as existsSync14 } from "fs";
|
|
5734
|
-
import { resolve as
|
|
5865
|
+
import { resolve as resolve4 } from "path";
|
|
5735
5866
|
function rowToQuestion(row) {
|
|
5736
5867
|
return {
|
|
5737
5868
|
id: row.id,
|
|
@@ -6392,7 +6523,7 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
6392
6523
|
* транзакции: прервётся — маркер не встанет, повтор безопасен.
|
|
6393
6524
|
*/
|
|
6394
6525
|
importDb(sourcePath, repo) {
|
|
6395
|
-
const abs =
|
|
6526
|
+
const abs = resolve4(sourcePath);
|
|
6396
6527
|
const repoN = normalizeRepo(repo);
|
|
6397
6528
|
const already = this.db.prepare("SELECT run_count FROM imports WHERE source = ?").get(abs);
|
|
6398
6529
|
if (already) return { imported: false, runs: already.run_count };
|
|
@@ -6774,9 +6905,9 @@ var init_repoScan = __esm({
|
|
|
6774
6905
|
});
|
|
6775
6906
|
|
|
6776
6907
|
// src/repoDiscovery.ts
|
|
6777
|
-
import { homedir as
|
|
6908
|
+
import { homedir as homedir7 } from "os";
|
|
6778
6909
|
import { readFileSync as readFileSync17, renameSync as renameSync7, writeFileSync as writeFileSync14 } from "fs";
|
|
6779
|
-
import { isAbsolute as
|
|
6910
|
+
import { isAbsolute as isAbsolute4, join as join23, resolve as resolve5 } from "path";
|
|
6780
6911
|
function repoMapLines(rows) {
|
|
6781
6912
|
if (!rows?.length) return [];
|
|
6782
6913
|
const missing = rows.filter((r) => !r.path).length;
|
|
@@ -7613,7 +7744,7 @@ function detectRequirements(repo, io = {}) {
|
|
|
7613
7744
|
const marker = COMPOSE_MARKERS.find((f) => exists(join25(repo, f)));
|
|
7614
7745
|
return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
|
|
7615
7746
|
}
|
|
7616
|
-
async function
|
|
7747
|
+
async function probeDockerDaemon() {
|
|
7617
7748
|
try {
|
|
7618
7749
|
const res = await execa3("docker", ["version", "--format", "{{.Server.Version}}"], {
|
|
7619
7750
|
timeout: PROBE_TIMEOUT_MS2,
|
|
@@ -7624,7 +7755,10 @@ async function dockerAlive() {
|
|
|
7624
7755
|
return false;
|
|
7625
7756
|
}
|
|
7626
7757
|
}
|
|
7627
|
-
|
|
7758
|
+
async function dockerAlive() {
|
|
7759
|
+
return dockerAliveImpl();
|
|
7760
|
+
}
|
|
7761
|
+
var PROBE_TIMEOUT_MS2, COMPOSE_MARKERS, dockerAliveImpl;
|
|
7628
7762
|
var init_envGate = __esm({
|
|
7629
7763
|
"src/envGate.ts"() {
|
|
7630
7764
|
"use strict";
|
|
@@ -7638,11 +7772,12 @@ var init_envGate = __esm({
|
|
|
7638
7772
|
"compose.yml",
|
|
7639
7773
|
"compose.yaml"
|
|
7640
7774
|
];
|
|
7775
|
+
dockerAliveImpl = probeDockerDaemon;
|
|
7641
7776
|
}
|
|
7642
7777
|
});
|
|
7643
7778
|
|
|
7644
7779
|
// src/doctor.ts
|
|
7645
|
-
import { isAbsolute as
|
|
7780
|
+
import { isAbsolute as isAbsolute5, join as join26 } from "path";
|
|
7646
7781
|
function ok(id, title, detail) {
|
|
7647
7782
|
return { id, title, status: "ok", detail, remedies: [], critical: false };
|
|
7648
7783
|
}
|
|
@@ -7841,7 +7976,7 @@ async function checkDocker(io, repoPaths) {
|
|
|
7841
7976
|
function checkRepos(io, snap) {
|
|
7842
7977
|
const title = "\u0420\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u0438 SWARM_REPO";
|
|
7843
7978
|
const env = snap.envRepo.trim();
|
|
7844
|
-
if (env && !
|
|
7979
|
+
if (env && !isAbsolute5(env)) {
|
|
7845
7980
|
return {
|
|
7846
7981
|
id: "repos",
|
|
7847
7982
|
title,
|
|
@@ -8387,7 +8522,7 @@ var init_updateCli = __esm({
|
|
|
8387
8522
|
|
|
8388
8523
|
// src/cli.ts
|
|
8389
8524
|
init_cliIo();
|
|
8390
|
-
import { basename as
|
|
8525
|
+
import { basename as basename7, dirname as dirname5, join as join28 } from "path";
|
|
8391
8526
|
import { existsSync as existsSync19, readFileSync as readFileSync21, writeFileSync as writeFileSync16, mkdirSync as mkdirSync12, readdirSync as readdirSync13, statSync as statSync13, openSync as openSync5, readSync as readSync2, closeSync as closeSync5 } from "fs";
|
|
8392
8527
|
import { setTimeout as sleep2 } from "timers/promises";
|
|
8393
8528
|
|
|
@@ -8540,6 +8675,9 @@ var SwarmClient = class _SwarmClient {
|
|
|
8540
8675
|
liveSweepMs;
|
|
8541
8676
|
liveSweptAt = null;
|
|
8542
8677
|
// TASWM-589: когда живые за окном добраны целиком
|
|
8678
|
+
// TASWM-654: последний проход окна и живых статусов прошёл без ошибок. Пока false,
|
|
8679
|
+
// именованная уборка стендов пропускается: неполный список показывает слаг мёртвым.
|
|
8680
|
+
runsListComplete = false;
|
|
8543
8681
|
// TASWM-169: репо-реестр демона — repoFullName[] на claim/heartbeat + обратная
|
|
8544
8682
|
// карта repoFullName→локальный путь для трансляции run.repo из прода (см. resolveRepo).
|
|
8545
8683
|
repoFullNames;
|
|
@@ -9673,17 +9811,28 @@ var SwarmClient = class _SwarmClient {
|
|
|
9673
9811
|
}
|
|
9674
9812
|
}
|
|
9675
9813
|
// ── гидрация зеркала из прода (старт + реконсайл-рефреш) ──────────────────────
|
|
9814
|
+
/** TASWM-654: все запросы прогонов последнего hydrate прошли. Иначе уборка стендов не знает,
|
|
9815
|
+
* жив ли слаг за окном в 200 прогонов. */
|
|
9816
|
+
runsHydrateComplete() {
|
|
9817
|
+
return this.runsListComplete;
|
|
9818
|
+
}
|
|
9676
9819
|
async hydrate() {
|
|
9677
9820
|
let res;
|
|
9678
9821
|
try {
|
|
9679
9822
|
res = await this.call("swarm_list_runs", { limit: this.listLimit, view: "full" });
|
|
9680
9823
|
} catch {
|
|
9824
|
+
this.runsListComplete = false;
|
|
9825
|
+
return;
|
|
9826
|
+
}
|
|
9827
|
+
if (!res || res.isError) {
|
|
9828
|
+
this.runsListComplete = false;
|
|
9681
9829
|
return;
|
|
9682
9830
|
}
|
|
9683
|
-
if (res?.isError) return;
|
|
9684
9831
|
const runs = res.structuredContent?.runs ?? [];
|
|
9685
9832
|
const seen = new Set(runs.map((pr) => String(pr.id ?? "")));
|
|
9686
|
-
|
|
9833
|
+
const beyond = await this.liveBeyondWindow();
|
|
9834
|
+
this.runsListComplete = beyond.complete;
|
|
9835
|
+
for (const pr of beyond.rows) {
|
|
9687
9836
|
const id = String(pr.id ?? "");
|
|
9688
9837
|
if (seen.has(id)) continue;
|
|
9689
9838
|
seen.add(id);
|
|
@@ -9706,16 +9855,19 @@ var SwarmClient = class _SwarmClient {
|
|
|
9706
9855
|
* в зеркало, когда его заводят или трогают, — то есть через окно. Добор нужен на старте и как
|
|
9707
9856
|
* страховка, поэтому он идёт при первой гидрации и дальше не чаще раза в `liveSweepMs`.
|
|
9708
9857
|
*
|
|
9709
|
-
* Fail-open
|
|
9710
|
-
* чтобы повторить его на следующей гидрации, а не через минуту.
|
|
9858
|
+
* Fail-open для зеркала: прод отказал по какому-то статусу — отдаём, что успели, и не
|
|
9859
|
+
* засчитываем добор, чтобы повторить его на следующей гидрации, а не через минуту.
|
|
9860
|
+
* Для уборки стендов это НЕ полный список: runsHydrateComplete() остаётся false, и
|
|
9861
|
+
* именованный снос в этом проходе пропускается (TASWM-654). Граница машины (isMine) и
|
|
9711
9862
|
* слияние с уже известными прогонами — обычный hydrateRun.
|
|
9712
9863
|
*/
|
|
9713
9864
|
async liveBeyondWindow() {
|
|
9714
9865
|
const now = this.now();
|
|
9715
|
-
if (this.liveSweptAt != null && now - this.liveSweptAt < this.liveSweepMs) return [];
|
|
9866
|
+
if (this.liveSweptAt != null && now - this.liveSweptAt < this.liveSweepMs) return { rows: [], complete: true };
|
|
9716
9867
|
const byStatus = await Promise.all(LIVE_STATUSES.map((status) => this.listAllByStatus(status)));
|
|
9717
|
-
|
|
9718
|
-
|
|
9868
|
+
const complete = byStatus.every((rows) => rows !== null);
|
|
9869
|
+
if (complete) this.liveSweptAt = now;
|
|
9870
|
+
return { rows: byStatus.flatMap((rows) => rows ?? []), complete };
|
|
9719
9871
|
}
|
|
9720
9872
|
/** Все прогоны одного статуса, страницами по 200. null — прод не ответил. */
|
|
9721
9873
|
async listAllByStatus(status) {
|
|
@@ -13819,14 +13971,14 @@ function makeHandler(deps) {
|
|
|
13819
13971
|
const ref = url.searchParams.get("pr") ?? "";
|
|
13820
13972
|
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 });
|
|
13821
13973
|
const ctxRepo = url.searchParams.get("repo");
|
|
13822
|
-
const
|
|
13974
|
+
const resolve6 = deps.mergeGate ?? makeMergeGateResolver({
|
|
13823
13975
|
listRuns: () => deps.db.listRuns(),
|
|
13824
13976
|
fallbackAutoReview: SWARM_AUTO_REVIEW,
|
|
13825
13977
|
autoVerify: SWARM_AUTO_VERIFY,
|
|
13826
13978
|
// TASWM-344
|
|
13827
13979
|
...defaultRepo ? { repoFallback: defaultRepo } : {}
|
|
13828
13980
|
});
|
|
13829
|
-
return Response.json(await
|
|
13981
|
+
return Response.json(await resolve6(ref, ctxRepo));
|
|
13830
13982
|
}
|
|
13831
13983
|
if (p === "/resources") return Response.json(hostResourceSnapshot());
|
|
13832
13984
|
if (p === "/timeline") return Response.json(timelineState(deps.db, Date.now(), readNarratorLog(deps.narratorLog)));
|
|
@@ -13983,16 +14135,17 @@ function startWeb(deps, port = WEB_PORT) {
|
|
|
13983
14135
|
import { cancelRun, respawnRun, runDaemon, wakeRun, OVERMIND_ENTRY, listDroneProcesses } from "./overmind.js";
|
|
13984
14136
|
|
|
13985
14137
|
// src/launcher.ts
|
|
14138
|
+
init_procCleanup();
|
|
13986
14139
|
import { spawn as spawn2 } from "child_process";
|
|
13987
14140
|
import { closeSync as closeSync4, existsSync as existsSync11, mkdirSync as mkdirSync11, openSync as openSync4, readdirSync as readdirSync10 } from "fs";
|
|
13988
14141
|
import { createRequire } from "module";
|
|
13989
|
-
import { homedir as
|
|
13990
|
-
import { dirname as dirname4, join as join16 } from "path";
|
|
14142
|
+
import { homedir as homedir6 } from "os";
|
|
14143
|
+
import { basename as basename5, dirname as dirname4, join as join16 } from "path";
|
|
13991
14144
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
13992
14145
|
|
|
13993
14146
|
// src/droneHome.ts
|
|
13994
14147
|
import { lstatSync, mkdirSync as mkdirSync10, readdirSync as readdirSync9, rmSync, statSync as statSync10, symlinkSync as symlinkSync4 } from "fs";
|
|
13995
|
-
import { join as join15, relative, sep } from "path";
|
|
14148
|
+
import { join as join15, relative, sep as sep2 } from "path";
|
|
13996
14149
|
var DRONE_HOME_DENY_DEFAULT = [".taskless-swarm", ".bash_history", ".zsh_history"];
|
|
13997
14150
|
function droneHomeDeny(env = process.env) {
|
|
13998
14151
|
const extra = (env.SWARM_DRONE_HOME_DENY || "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -14013,7 +14166,7 @@ function buildDroneHome(opts) {
|
|
|
14013
14166
|
mkdirSync10(droneHome, { recursive: true, mode: 448 });
|
|
14014
14167
|
const wanted = new Set(mirroredEntries(readdirSync9(realHome), deny, platform));
|
|
14015
14168
|
const rel = relative(realHome, droneHome);
|
|
14016
|
-
if (rel && !rel.startsWith("..") && !rel.includes(
|
|
14169
|
+
if (rel && !rel.startsWith("..") && !rel.includes(sep2)) wanted.delete(rel);
|
|
14017
14170
|
for (const existing of readdirSync9(droneHome)) {
|
|
14018
14171
|
if (wanted.has(existing)) continue;
|
|
14019
14172
|
const p = join15(droneHome, existing);
|
|
@@ -14150,6 +14303,10 @@ function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
|
|
|
14150
14303
|
if (isolate && !base3.TURBO_CACHE_DIR) {
|
|
14151
14304
|
env.TURBO_CACHE_DIR = join16(worktree, ".turbo", "cache");
|
|
14152
14305
|
}
|
|
14306
|
+
if (!base3.COMPOSE_PROJECT_NAME) {
|
|
14307
|
+
const prefix = composeProjectPrefix(basename5(worktree));
|
|
14308
|
+
if (prefix) env.COMPOSE_PROJECT_NAME = prefix;
|
|
14309
|
+
}
|
|
14153
14310
|
Object.assign(env, droneTestEnv(droneCap, base3));
|
|
14154
14311
|
for (const key of DAEMON_STATE_ENV) delete env[key];
|
|
14155
14312
|
if (isolation) {
|
|
@@ -14291,7 +14448,7 @@ function makeLauncher(cfg) {
|
|
|
14291
14448
|
} catch (e) {
|
|
14292
14449
|
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 #${run.id}: ${String(e)}`);
|
|
14293
14450
|
}
|
|
14294
|
-
const realHome = cfg.droneIsolation?.realHome ??
|
|
14451
|
+
const realHome = cfg.droneIsolation?.realHome ?? homedir6();
|
|
14295
14452
|
const home = cfg.droneIsolation ? buildDroneHome({ realHome, droneHome: cfg.droneIsolation.home }) : void 0;
|
|
14296
14453
|
if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync11(join16(cfg.droneIsolation.swarmHome, "token"))) {
|
|
14297
14454
|
console.error(
|
|
@@ -14744,10 +14901,10 @@ async function restoreDaemon(d, loginOk) {
|
|
|
14744
14901
|
d.err("\u0434\u0435\u043C\u043E\u043D \u043E\u0431\u0440\u0430\u0442\u043D\u043E \u041D\u0415 \u043F\u043E\u0434\u043D\u044F\u043B\u0441\u044F (\u043F\u0440\u0438\u0447\u0438\u043D\u0430 \u0432\u044B\u0448\u0435) \u2014 \u0440\u043E\u0439 \u0441\u0442\u043E\u0438\u0442. \u041F\u043E\u0434\u043D\u0438\u043C\u0438 \u0432\u0440\u0443\u0447\u043D\u0443\u044E: swarm start");
|
|
14745
14902
|
}
|
|
14746
14903
|
function isPortFree(port, host = "127.0.0.1") {
|
|
14747
|
-
return new Promise((
|
|
14904
|
+
return new Promise((resolve6) => {
|
|
14748
14905
|
const probe = createServer();
|
|
14749
|
-
probe.once("error", () =>
|
|
14750
|
-
probe.listen(port, host, () => probe.close(() =>
|
|
14906
|
+
probe.once("error", () => resolve6(false));
|
|
14907
|
+
probe.listen(port, host, () => probe.close(() => resolve6(true)));
|
|
14751
14908
|
});
|
|
14752
14909
|
}
|
|
14753
14910
|
async function chooseWorkspace(d) {
|
|
@@ -15365,7 +15522,7 @@ var thisHost = loadHostIdentity({ home: SWARM_HOME, envHostId: process.env.SWARM
|
|
|
15365
15522
|
function fmtRun(r, opts = {}) {
|
|
15366
15523
|
const mark = STATUS_MARK[r.status] ?? "?";
|
|
15367
15524
|
const area = r.area ? ` [${r.area}]` : "";
|
|
15368
|
-
const repo = r.repo ? ` (${
|
|
15525
|
+
const repo = r.repo ? ` (${basename7(r.repo)})` : "";
|
|
15369
15526
|
const q = r.status === "blocked" ? " \u2190 \u0436\u0434\u0451\u0442 \u043E\u0442\u0432\u0435\u0442\u0430" : "";
|
|
15370
15527
|
const why = r.status === "stopped" && r.stop_reason ? ` \u2014 ${r.stop_reason}` : "";
|
|
15371
15528
|
const priority = r.priority ? ` \u2691${r.priority > 0 ? "+" : ""}${r.priority}` : "";
|
|
@@ -15577,7 +15734,7 @@ async function scoutRepo(repo) {
|
|
|
15577
15734
|
mkdirSync12(dirname5(abs(rel)), { recursive: true });
|
|
15578
15735
|
writeFileSync16(abs(rel), text);
|
|
15579
15736
|
},
|
|
15580
|
-
runScout: (prompt) => new Promise((
|
|
15737
|
+
runScout: (prompt) => new Promise((resolve6) => {
|
|
15581
15738
|
const child = spawn3(bin, [...ISOLATION_FLAGS, "--dangerously-skip-permissions", "-p", prompt], {
|
|
15582
15739
|
cwd: worktree,
|
|
15583
15740
|
stdio: ["ignore", "inherit", "inherit"]
|
|
@@ -15585,9 +15742,9 @@ async function scoutRepo(repo) {
|
|
|
15585
15742
|
});
|
|
15586
15743
|
child.on("error", (e) => {
|
|
15587
15744
|
console.error(`\u043D\u0435 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u043B\u0441\u044F \u0438\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C (${bin}): ${e.message}`);
|
|
15588
|
-
|
|
15745
|
+
resolve6(1);
|
|
15589
15746
|
});
|
|
15590
|
-
child.on("exit", (c) =>
|
|
15747
|
+
child.on("exit", (c) => resolve6(c ?? 1));
|
|
15591
15748
|
}),
|
|
15592
15749
|
publish: (files) => publishScoutPr({ worktree, repo, files, name, baseBranch, openPr: openPr.url, fresh: openPr.known && !openPr.url }),
|
|
15593
15750
|
log: (line) => console.log(line)
|
|
@@ -16168,7 +16325,7 @@ switch (cmd) {
|
|
|
16168
16325
|
process.exit(1);
|
|
16169
16326
|
}
|
|
16170
16327
|
const run = db.getRun(runId);
|
|
16171
|
-
if (run) console.log(`#${run.id} ${run.name} ${run.task_slug}${run.repo ? ` (${
|
|
16328
|
+
if (run) console.log(`#${run.id} ${run.name} ${run.task_slug}${run.repo ? ` (${basename7(run.repo)})` : ""}`);
|
|
16172
16329
|
const events = db.events(runId);
|
|
16173
16330
|
if (events.length === 0) console.log("\u0441\u043E\u0431\u044B\u0442\u0438\u0439 \u043D\u0435\u0442");
|
|
16174
16331
|
else events.forEach((e) => console.log(`${e.at} ${e.kind}${e.text ? " " + e.text : ""}`));
|