@taskless-app/swarm 0.6.81 → 0.6.82
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 +364 -169
- package/dist/overmind.js +499 -296
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -735,6 +735,25 @@ var init_modelPolicy = __esm({
|
|
|
735
735
|
roles: { executor: "grok-4.7", review: "grok-4.7-build-fast" },
|
|
736
736
|
models: ["grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5"]
|
|
737
737
|
},
|
|
738
|
+
// Kimi Code CLI (Moonshot). Каталог — все 5 моделей из конфига владельца (09.11.2026),
|
|
739
|
+
// полные алиасы как в дефолтном config.toml любого kimi-code: ссылки вида
|
|
740
|
+
// `kimi/kimi-code/k3.1-pro` — parseModelRef режет по первому слэшу, моделью уходит
|
|
741
|
+
// `kimi-code/k3.1-pro` (второй слэш — часть имени). Тарифа нет: подписка, CLI цену не
|
|
742
|
+
// сообщает — честный ноль (costUsd=0 с предупреждением) живёт в адаптере (TASWM-630).
|
|
743
|
+
{
|
|
744
|
+
id: "kimi",
|
|
745
|
+
label: "Kimi (Moonshot)",
|
|
746
|
+
executorId: "kimi",
|
|
747
|
+
selectable: true,
|
|
748
|
+
roles: { executor: "kimi-code/k3.1-pro", review: "kimi-code/k3" },
|
|
749
|
+
models: [
|
|
750
|
+
"kimi-code/kimi-for-coding",
|
|
751
|
+
"kimi-code/k3",
|
|
752
|
+
"kimi-code/k3-256k",
|
|
753
|
+
"kimi-code/k3.1-pro",
|
|
754
|
+
"kimi-code/k3.1-pro-highspeed"
|
|
755
|
+
]
|
|
756
|
+
},
|
|
738
757
|
// TASWM-565 · шаг 1 из четырёх: провайдер в реестре ЕСТЬ, выбрать его ещё нельзя.
|
|
739
758
|
// Имён моделей здесь нет СОЗНАТЕЛЬНО: у владельца подписка, состав моделей в ней нам
|
|
740
759
|
// неизвестен, а выдуманное имя хуже маркера «решает Codex».
|
|
@@ -2873,6 +2892,179 @@ ${notice}` : spec.prompt;
|
|
|
2873
2892
|
}
|
|
2874
2893
|
});
|
|
2875
2894
|
|
|
2895
|
+
// src/executors/kimi.ts
|
|
2896
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync3, statSync as statSync5, symlinkSync as symlinkSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
2897
|
+
import { join as join7 } from "path";
|
|
2898
|
+
function resolveKimiBin(env = process.env) {
|
|
2899
|
+
return (env.SWARM_KIMI_BIN ?? "").trim() || "kimi";
|
|
2900
|
+
}
|
|
2901
|
+
function kimiHomePath(worktree, swarmHome = SWARM_HOME) {
|
|
2902
|
+
const key = worktree.replace(/[^A-Za-z0-9]+/g, "-").replace(/^-|-$/g, "") || "worktree";
|
|
2903
|
+
return join7(swarmHome, "executor-state", "kimi", key);
|
|
2904
|
+
}
|
|
2905
|
+
function kimiSessionRoot(worktree, swarmHome = SWARM_HOME) {
|
|
2906
|
+
return join7(kimiHomePath(worktree, swarmHome), "sessions");
|
|
2907
|
+
}
|
|
2908
|
+
function newestKimiSessionMtime(dir, depth = 4) {
|
|
2909
|
+
let entries;
|
|
2910
|
+
try {
|
|
2911
|
+
entries = readdirSync6(dir, { withFileTypes: true });
|
|
2912
|
+
} catch {
|
|
2913
|
+
return null;
|
|
2914
|
+
}
|
|
2915
|
+
let latest = null;
|
|
2916
|
+
for (const entry of entries) {
|
|
2917
|
+
const full = join7(dir, entry.name);
|
|
2918
|
+
try {
|
|
2919
|
+
if (entry.isDirectory()) {
|
|
2920
|
+
if (depth <= 0) continue;
|
|
2921
|
+
const nested = newestKimiSessionMtime(full, depth - 1);
|
|
2922
|
+
if (nested != null && (latest == null || nested > latest)) latest = nested;
|
|
2923
|
+
} else if (entry.isFile()) {
|
|
2924
|
+
const mtime2 = statSync5(full).mtimeMs;
|
|
2925
|
+
if (latest == null || mtime2 > latest) latest = mtime2;
|
|
2926
|
+
}
|
|
2927
|
+
} catch {
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
return latest;
|
|
2931
|
+
}
|
|
2932
|
+
function extractModelsBlocks(config) {
|
|
2933
|
+
const lines = config.split(/\r?\n/);
|
|
2934
|
+
const blocks = [];
|
|
2935
|
+
let current = null;
|
|
2936
|
+
for (const line of lines) {
|
|
2937
|
+
if (/^\s*\[/.test(line)) {
|
|
2938
|
+
if (current) blocks.push(current);
|
|
2939
|
+
current = /^\s*\[models\./.test(line) ? [line] : null;
|
|
2940
|
+
continue;
|
|
2941
|
+
}
|
|
2942
|
+
if (current) current.push(line);
|
|
2943
|
+
}
|
|
2944
|
+
if (current) blocks.push(current);
|
|
2945
|
+
return blocks.map((b) => b.join("\n").trimEnd()).filter((b) => b.trim() !== "");
|
|
2946
|
+
}
|
|
2947
|
+
function kimiMcpJson(spec) {
|
|
2948
|
+
return JSON.stringify(
|
|
2949
|
+
{ mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
|
|
2950
|
+
null,
|
|
2951
|
+
2
|
|
2952
|
+
);
|
|
2953
|
+
}
|
|
2954
|
+
function ensureKimiHome(worktree, realHome, env = process.env, swarmHome = SWARM_HOME) {
|
|
2955
|
+
const home = kimiHomePath(worktree, swarmHome);
|
|
2956
|
+
mkdirSync5(home, { recursive: true });
|
|
2957
|
+
const realCreds = join7((env.KIMI_CODE_HOME ?? "").trim() || join7(realHome, ".kimi-code"), "credentials");
|
|
2958
|
+
const link = join7(home, "credentials");
|
|
2959
|
+
if (existsSync5(realCreds) && !existsSync5(link)) {
|
|
2960
|
+
try {
|
|
2961
|
+
symlinkSync3(realCreds, link, "junction");
|
|
2962
|
+
} catch {
|
|
2963
|
+
try {
|
|
2964
|
+
mkdirSync5(link, { recursive: true });
|
|
2965
|
+
for (const f of readdirSync6(realCreds)) copyFileSync4(join7(realCreds, f), join7(link, f));
|
|
2966
|
+
} catch {
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
const realConfig = join7((env.KIMI_CODE_HOME ?? "").trim() || join7(realHome, ".kimi-code"), "config.toml");
|
|
2971
|
+
try {
|
|
2972
|
+
const blocks = extractModelsBlocks(readFileSync3(realConfig, "utf8"));
|
|
2973
|
+
if (blocks.length > 0) writeFileSync4(join7(home, "config.toml"), `${blocks.join("\n\n")}
|
|
2974
|
+
`);
|
|
2975
|
+
} catch {
|
|
2976
|
+
}
|
|
2977
|
+
return home;
|
|
2978
|
+
}
|
|
2979
|
+
function modelArgs2(model) {
|
|
2980
|
+
if (!model || isHarnessDefaultModel(model)) return [];
|
|
2981
|
+
return ["-m", model];
|
|
2982
|
+
}
|
|
2983
|
+
function parseKimiResult(raw) {
|
|
2984
|
+
const trimmed = raw.trim();
|
|
2985
|
+
if (!trimmed) return null;
|
|
2986
|
+
let lastAssistant = null;
|
|
2987
|
+
let sawEvent = false;
|
|
2988
|
+
for (const line of trimmed.split(/\r?\n/)) {
|
|
2989
|
+
const s = line.trim();
|
|
2990
|
+
if (!s) continue;
|
|
2991
|
+
let parsed;
|
|
2992
|
+
try {
|
|
2993
|
+
parsed = JSON.parse(s);
|
|
2994
|
+
} catch {
|
|
2995
|
+
continue;
|
|
2996
|
+
}
|
|
2997
|
+
if (typeof parsed !== "object" || parsed === null) continue;
|
|
2998
|
+
sawEvent = true;
|
|
2999
|
+
const rec = parsed;
|
|
3000
|
+
if (rec.role === "assistant" && typeof rec.content === "string") lastAssistant = rec.content;
|
|
3001
|
+
}
|
|
3002
|
+
if (!sawEvent || lastAssistant === null) return null;
|
|
3003
|
+
return {
|
|
3004
|
+
costUsd: 0,
|
|
3005
|
+
warning: "kimi: CLI \u0441\u0442\u043E\u0438\u043C\u043E\u0441\u0442\u044C \u043D\u0435 \u0441\u043E\u043E\u0431\u0449\u0430\u0435\u0442 (\u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0430) \u2014 \u044D\u0442\u043E \u043D\u0435 \u043D\u043E\u043B\u044C \u0432 \u0441\u043C\u044B\u0441\u043B\u0435 \u0431\u0435\u0441\u043F\u043B\u0430\u0442\u043D\u043E"
|
|
3006
|
+
};
|
|
3007
|
+
}
|
|
3008
|
+
var kimiExecutor;
|
|
3009
|
+
var init_kimi = __esm({
|
|
3010
|
+
"src/executors/kimi.ts"() {
|
|
3011
|
+
"use strict";
|
|
3012
|
+
init_src();
|
|
3013
|
+
init_swarmHome();
|
|
3014
|
+
init_swarmFiles();
|
|
3015
|
+
kimiExecutor = {
|
|
3016
|
+
id: "kimi",
|
|
3017
|
+
title: "Kimi Code CLI (kimi)",
|
|
3018
|
+
binEnv: "SWARM_KIMI_BIN",
|
|
3019
|
+
install: {
|
|
3020
|
+
what: "Kimi Code CLI (Moonshot). \u041E\u0444\u0438\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u0439 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0449\u0438\u043A \u0441 code.kimi.com \u2014 \u041D\u0415 npm-\u043F\u0430\u043A\u0435\u0442 kimi-code (\u044D\u0442\u043E \u0447\u0443\u0436\u043E\u0439 \u043F\u0440\u043E\u043A\u0441\u0438-\u0432\u0440\u0430\u043F\u043F\u0435\u0440).",
|
|
3021
|
+
pkg: "kimi-code",
|
|
3022
|
+
command: "curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash",
|
|
3023
|
+
windowsCommand: "irm https://code.kimi.com/kimi-code/install.ps1 | iex"
|
|
3024
|
+
},
|
|
3025
|
+
resolveBin: (env) => resolveKimiBin(env ?? process.env),
|
|
3026
|
+
plan: (spec) => {
|
|
3027
|
+
const home = ensureKimiHome(spec.worktree, spec.realHome);
|
|
3028
|
+
writeFileSync4(join7(home, "mcp.json"), kimiMcpJson(spec));
|
|
3029
|
+
writeFileSync4(
|
|
3030
|
+
join7(spec.worktree, SWARM_MCP_CONFIG_FILE),
|
|
3031
|
+
JSON.stringify(
|
|
3032
|
+
{ mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
|
|
3033
|
+
null,
|
|
3034
|
+
2
|
|
3035
|
+
)
|
|
3036
|
+
);
|
|
3037
|
+
const args = [
|
|
3038
|
+
// `--add-dir` стоит первым: настоящий флаг kimi, по нему реконсайл узнаёт
|
|
3039
|
+
// worktree живого процесса после рестарта демона (worktreeFromKimiCmd).
|
|
3040
|
+
"--add-dir",
|
|
3041
|
+
spec.worktree,
|
|
3042
|
+
"--output-format",
|
|
3043
|
+
"stream-json",
|
|
3044
|
+
...spec.skillDirs.flatMap((dir) => ["--skills-dir", dir]),
|
|
3045
|
+
...spec.continueSession ? ["--continue"] : [],
|
|
3046
|
+
...modelArgs2(spec.model),
|
|
3047
|
+
"-p",
|
|
3048
|
+
spec.prompt
|
|
3049
|
+
];
|
|
3050
|
+
return { bin: resolveKimiBin(), args, env: { KIMI_CODE_HOME: home } };
|
|
3051
|
+
},
|
|
3052
|
+
parseResult(raw) {
|
|
3053
|
+
return parseKimiResult(raw);
|
|
3054
|
+
},
|
|
3055
|
+
session: {
|
|
3056
|
+
exists: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree)) !== null,
|
|
3057
|
+
mtimeMs: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree))
|
|
3058
|
+
},
|
|
3059
|
+
probe: {
|
|
3060
|
+
args: ["-p", "ok", "--output-format", "stream-json"],
|
|
3061
|
+
limitPattern: /usage limit|quota|rate.limit|too many requests/i,
|
|
3062
|
+
authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
|
|
3063
|
+
}
|
|
3064
|
+
};
|
|
3065
|
+
}
|
|
3066
|
+
});
|
|
3067
|
+
|
|
2876
3068
|
// src/liveModels.ts
|
|
2877
3069
|
import { execFile } from "child_process";
|
|
2878
3070
|
function liveDefaultModel(providerId) {
|
|
@@ -2970,23 +3162,26 @@ var init_executors = __esm({
|
|
|
2970
3162
|
init_claudeCode();
|
|
2971
3163
|
init_codex();
|
|
2972
3164
|
init_grok();
|
|
3165
|
+
init_kimi();
|
|
2973
3166
|
init_swarmModels();
|
|
2974
3167
|
init_types2();
|
|
2975
3168
|
init_claudeCode();
|
|
2976
3169
|
init_codex();
|
|
2977
3170
|
init_grok();
|
|
3171
|
+
init_kimi();
|
|
2978
3172
|
DEFAULT_EXECUTOR_ID = "claude-code";
|
|
2979
3173
|
EXECUTORS = {
|
|
2980
3174
|
[claudeCodeExecutor.id]: claudeCodeExecutor,
|
|
2981
3175
|
[codexExecutor.id]: codexExecutor,
|
|
2982
|
-
[grokExecutor.id]: grokExecutor
|
|
3176
|
+
[grokExecutor.id]: grokExecutor,
|
|
3177
|
+
[kimiExecutor.id]: kimiExecutor
|
|
2983
3178
|
};
|
|
2984
3179
|
}
|
|
2985
3180
|
});
|
|
2986
3181
|
|
|
2987
3182
|
// src/config.ts
|
|
2988
|
-
import { basename, join as
|
|
2989
|
-
import { readFileSync as
|
|
3183
|
+
import { basename, join as join8, resolve } from "path";
|
|
3184
|
+
import { readFileSync as readFileSync4, realpathSync, renameSync, writeFileSync as writeFileSync5 } from "fs";
|
|
2990
3185
|
function normalizeRepo(repo) {
|
|
2991
3186
|
const r = (repo ?? "").trim();
|
|
2992
3187
|
if (!r) return "";
|
|
@@ -3000,10 +3195,10 @@ function effectiveRepoOf(repo, fallback) {
|
|
|
3000
3195
|
return normalizeRepo(repo || fallback || "");
|
|
3001
3196
|
}
|
|
3002
3197
|
function droneWorktreePath(worktreesDir, repo, slug) {
|
|
3003
|
-
return
|
|
3198
|
+
return join8(droneWorktreeRoot(worktreesDir, repo), slug);
|
|
3004
3199
|
}
|
|
3005
3200
|
function droneWorktreeRoot(worktreesDir, repo) {
|
|
3006
|
-
return
|
|
3201
|
+
return join8(worktreesDir, basename(normalizeRepo(repo)));
|
|
3007
3202
|
}
|
|
3008
3203
|
function resolveEffectiveWorktreesDir(deps) {
|
|
3009
3204
|
if (deps.envOverride) return deps.envOverride;
|
|
@@ -3030,7 +3225,7 @@ function mcpEndpoint(api, path = TASKLESS_MCP_PATH) {
|
|
|
3030
3225
|
}
|
|
3031
3226
|
function tokenFromFile() {
|
|
3032
3227
|
try {
|
|
3033
|
-
return
|
|
3228
|
+
return readFileSync4(join8(SWARM_HOME, "token"), "utf8").trim();
|
|
3034
3229
|
} catch {
|
|
3035
3230
|
return "";
|
|
3036
3231
|
}
|
|
@@ -3043,25 +3238,25 @@ var init_config = __esm({
|
|
|
3043
3238
|
init_executors();
|
|
3044
3239
|
init_swarmHome();
|
|
3045
3240
|
init_swarmHome();
|
|
3046
|
-
DB_PATH = process.env.SWARM_DB ||
|
|
3241
|
+
DB_PATH = process.env.SWARM_DB || join8(SWARM_HOME, "swarm.db");
|
|
3047
3242
|
EXECUTOR = resolveExecutor(process.env.SWARM_EXECUTOR);
|
|
3048
|
-
DRONE_HOME = process.env.SWARM_DRONE_HOME ||
|
|
3243
|
+
DRONE_HOME = process.env.SWARM_DRONE_HOME || join8(SWARM_HOME, "drone-home");
|
|
3049
3244
|
DRONE_HOME_ISOLATION = process.env.SWARM_DRONE_ISOLATE_HOME !== "0" && process.platform !== "win32";
|
|
3050
3245
|
DRONE_ISOLATION = DRONE_HOME_ISOLATION ? { home: DRONE_HOME, swarmHome: SWARM_HOME } : void 0;
|
|
3051
|
-
WORKTREES_NOINDEX_DIR =
|
|
3052
|
-
WORKTREES_LEGACY_DIR =
|
|
3246
|
+
WORKTREES_NOINDEX_DIR = join8(SWARM_HOME, "worktrees.noindex");
|
|
3247
|
+
WORKTREES_LEGACY_DIR = join8(SWARM_HOME, "worktrees");
|
|
3053
3248
|
WORKTREES_DIR = process.env.SWARM_WORKTREES || WORKTREES_NOINDEX_DIR;
|
|
3054
|
-
RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS ||
|
|
3055
|
-
DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG ||
|
|
3249
|
+
RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS || join8(SWARM_HOME, "run-logs");
|
|
3250
|
+
DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG || join8(SWARM_HOME, "overmind.log");
|
|
3056
3251
|
DAEMON_LOG_MAX_BYTES = envNum("SWARM_DAEMON_LOG_MAX_BYTES", 16 * 1024 * 1024);
|
|
3057
3252
|
DAEMON_LOG_KEEP = envNum("SWARM_DAEMON_LOG_KEEP", 2);
|
|
3058
3253
|
DAEMON_LOG_CHECK_MS = envNum("SWARM_DAEMON_LOG_CHECK_MS", 6e4);
|
|
3059
3254
|
DIST_BUILD = true;
|
|
3060
3255
|
SWARM_BACKEND = process.env.SWARM_BACKEND === "client" ? "client" : process.env.SWARM_BACKEND === "sqlite" ? "sqlite" : DIST_BUILD ? "client" : "sqlite";
|
|
3061
|
-
SWARM_OUTBOX = process.env.SWARM_OUTBOX ||
|
|
3256
|
+
SWARM_OUTBOX = process.env.SWARM_OUTBOX || join8(SWARM_HOME, "outbox.jsonl");
|
|
3062
3257
|
SWARM_MAX_IN_FLIGHT = Math.trunc(envNum("SWARM_MAX_IN_FLIGHT", 3));
|
|
3063
3258
|
SWARM_CLAIM_INTERVAL_MS = envNum("SWARM_CLAIM_INTERVAL_MS", 6e4);
|
|
3064
|
-
ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR ||
|
|
3259
|
+
ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR || join8(SWARM_HOME, "env-cache");
|
|
3065
3260
|
ENV_CACHE_ENABLED = process.env.SWARM_ENV_CACHE !== "0";
|
|
3066
3261
|
ENV_CACHE_KEEP = Math.trunc(envNum("SWARM_ENV_CACHE_KEEP", 4));
|
|
3067
3262
|
SWARM_MAX_LOAD_FACTOR = envNum("SWARM_MAX_LOAD_FACTOR", 0.9);
|
|
@@ -3091,15 +3286,15 @@ var init_config = __esm({
|
|
|
3091
3286
|
DRONE_CHANNEL_ENABLED = process.env.SWARM_DRONE_CHANNEL !== "0";
|
|
3092
3287
|
DRONE_CHANNEL_PORT = Number(process.env.SWARM_DRONE_CHANNEL_PORT) || 7421;
|
|
3093
3288
|
DRONE_CHANNEL_URL = process.env.SWARM_DRONE_CHANNEL_URL || `http://127.0.0.1:${DRONE_CHANNEL_PORT}`;
|
|
3094
|
-
DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET ||
|
|
3289
|
+
DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET || join8(SWARM_HOME, "drone-channel.key");
|
|
3095
3290
|
DRONE_CHANNEL_GRACE_MS = envNum("SWARM_DRONE_CHANNEL_GRACE_MS", 12e4);
|
|
3096
|
-
HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT ||
|
|
3291
|
+
HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join8(SWARM_HOME, "overmind.heartbeat");
|
|
3097
3292
|
HEARTBEAT_STALE_MS = Number(process.env.SWARM_HEARTBEAT_STALE_MS) || 3e4;
|
|
3098
3293
|
SWARM_REPO = process.env.SWARM_REPO || "";
|
|
3099
3294
|
SWARM_SCAN_DEPTH = Number(process.env.SWARM_SCAN_DEPTH) || 3;
|
|
3100
3295
|
SWARM_REPO_PATHS = (process.env.SWARM_REPOS || SWARM_REPO).split(",").map((s) => s.trim()).filter(Boolean);
|
|
3101
3296
|
SWARM_SCAN_ROOTS_RAW = process.env.SWARM_SCAN_ROOTS || "";
|
|
3102
|
-
REPO_MAP_PATH = process.env.SWARM_REPO_MAP ||
|
|
3297
|
+
REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join8(SWARM_HOME, "repo-map.json");
|
|
3103
3298
|
SWARM_REPO_MAP_MS = envNum("SWARM_REPO_MAP_MS", 15 * 6e4);
|
|
3104
3299
|
SWARM_REPO_SCAN_TTL_MS = envNum("SWARM_REPO_SCAN_TTL_MS", 24 * 60 * 6e4);
|
|
3105
3300
|
TASKLESS_API = process.env.TASKLESS_API || "https://taskless.ru";
|
|
@@ -3114,7 +3309,7 @@ var init_config = __esm({
|
|
|
3114
3309
|
SWARM_AUTO_REVIEW = process.env.SWARM_AUTO_REVIEW !== "0";
|
|
3115
3310
|
SWARM_AUTO_VERIFY = process.env.SWARM_AUTO_VERIFY !== "0";
|
|
3116
3311
|
SWARM_MERGE_QUEUE = process.env.SWARM_MERGE_QUEUE !== "0";
|
|
3117
|
-
REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF ||
|
|
3312
|
+
REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join8(SWARM_HOME, "review-cutoff.json");
|
|
3118
3313
|
SWARM_REVIEW_CAP = Math.trunc(envNum("SWARM_REVIEW_CAP", 1));
|
|
3119
3314
|
SWARM_STORM_URL = process.env.SWARM_STORM_URL || "";
|
|
3120
3315
|
WEB_PORT = Number(process.env.SWARM_WEB_PORT) || 7420;
|
|
@@ -3154,7 +3349,7 @@ var init_quietExec = __esm({
|
|
|
3154
3349
|
|
|
3155
3350
|
// src/resources.ts
|
|
3156
3351
|
import os from "os";
|
|
3157
|
-
import { readFileSync as
|
|
3352
|
+
import { readFileSync as readFileSync5, statfsSync } from "fs";
|
|
3158
3353
|
function isTransientResourceError(e) {
|
|
3159
3354
|
const code = e?.code;
|
|
3160
3355
|
return code === "ENFILE" || code === "EMFILE" || code === "EAGAIN";
|
|
@@ -3206,7 +3401,7 @@ function fileDescriptorLoadRatio() {
|
|
|
3206
3401
|
}
|
|
3207
3402
|
if (process.platform === "linux") {
|
|
3208
3403
|
try {
|
|
3209
|
-
const [allocated, , max] =
|
|
3404
|
+
const [allocated, , max] = readFileSync5("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
|
|
3210
3405
|
if (Number.isFinite(allocated ?? NaN) && Number.isFinite(max ?? NaN) && max) return allocated / max;
|
|
3211
3406
|
} catch {
|
|
3212
3407
|
}
|
|
@@ -3469,18 +3664,18 @@ var init_store = __esm({
|
|
|
3469
3664
|
});
|
|
3470
3665
|
|
|
3471
3666
|
// src/agentToken.ts
|
|
3472
|
-
import { readFileSync as
|
|
3473
|
-
import { join as
|
|
3667
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, unlinkSync } from "fs";
|
|
3668
|
+
import { join as join9 } from "path";
|
|
3474
3669
|
function loadAgentToken() {
|
|
3475
3670
|
try {
|
|
3476
|
-
const s = JSON.parse(
|
|
3671
|
+
const s = JSON.parse(readFileSync6(STORE_PATH, "utf8"));
|
|
3477
3672
|
return s.token ? s : null;
|
|
3478
3673
|
} catch {
|
|
3479
3674
|
return null;
|
|
3480
3675
|
}
|
|
3481
3676
|
}
|
|
3482
3677
|
function saveAgentToken(s) {
|
|
3483
|
-
|
|
3678
|
+
writeFileSync6(STORE_PATH, JSON.stringify(s, null, 2), { mode: 384 });
|
|
3484
3679
|
}
|
|
3485
3680
|
function clearAgentToken() {
|
|
3486
3681
|
try {
|
|
@@ -3551,7 +3746,7 @@ var init_agentToken = __esm({
|
|
|
3551
3746
|
"src/agentToken.ts"() {
|
|
3552
3747
|
"use strict";
|
|
3553
3748
|
init_config();
|
|
3554
|
-
STORE_PATH =
|
|
3749
|
+
STORE_PATH = join9(SWARM_HOME, "agent.json");
|
|
3555
3750
|
base = (api) => api.replace(/\/$/, "");
|
|
3556
3751
|
TOKEN_PROBE_TIMEOUT_MS = 8e3;
|
|
3557
3752
|
}
|
|
@@ -3655,7 +3850,7 @@ var init_toolFailure = __esm({
|
|
|
3655
3850
|
});
|
|
3656
3851
|
|
|
3657
3852
|
// src/procList.ts
|
|
3658
|
-
import { readFileSync as
|
|
3853
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
3659
3854
|
function parsePsRows(out) {
|
|
3660
3855
|
const rows = [];
|
|
3661
3856
|
for (const line of out.split("\n")) {
|
|
@@ -3938,7 +4133,7 @@ var init_package = __esm({
|
|
|
3938
4133
|
"package.json"() {
|
|
3939
4134
|
package_default = {
|
|
3940
4135
|
name: "@taskless-app/swarm",
|
|
3941
|
-
version: "0.6.
|
|
4136
|
+
version: "0.6.82",
|
|
3942
4137
|
type: "module",
|
|
3943
4138
|
description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
|
|
3944
4139
|
keywords: [
|
|
@@ -3990,7 +4185,7 @@ var init_package = __esm({
|
|
|
3990
4185
|
undici: "^7.30.1",
|
|
3991
4186
|
zod: "3.25.76"
|
|
3992
4187
|
},
|
|
3993
|
-
gitHead: "
|
|
4188
|
+
gitHead: "1ca25b5c37db968ab99a966201fd4a1dd35a2ac1"
|
|
3994
4189
|
};
|
|
3995
4190
|
}
|
|
3996
4191
|
});
|
|
@@ -4156,18 +4351,18 @@ var init_netTimeout = __esm({
|
|
|
4156
4351
|
|
|
4157
4352
|
// src/droneChannel.ts
|
|
4158
4353
|
import { createHmac, randomBytes, timingSafeEqual } from "crypto";
|
|
4159
|
-
import { chmodSync as chmodSync2, mkdirSync as
|
|
4354
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync9 } from "fs";
|
|
4160
4355
|
import { dirname as dirname3 } from "path";
|
|
4161
4356
|
import { serve } from "@hono/node-server";
|
|
4162
4357
|
function loadChannelSecret(path) {
|
|
4163
4358
|
try {
|
|
4164
|
-
const s =
|
|
4359
|
+
const s = readFileSync11(path, "utf8").trim();
|
|
4165
4360
|
if (s.length >= 32) return s;
|
|
4166
4361
|
} catch {
|
|
4167
4362
|
}
|
|
4168
4363
|
const secret = randomBytes(32).toString("hex");
|
|
4169
|
-
|
|
4170
|
-
|
|
4364
|
+
mkdirSync9(dirname3(path), { recursive: true });
|
|
4365
|
+
writeFileSync9(path, secret, { mode: 384 });
|
|
4171
4366
|
try {
|
|
4172
4367
|
chmodSync2(path, 384);
|
|
4173
4368
|
} catch {
|
|
@@ -4244,8 +4439,8 @@ var init_authState = __esm({
|
|
|
4244
4439
|
|
|
4245
4440
|
// src/oauth.ts
|
|
4246
4441
|
import { createHash, randomBytes as randomBytes2 } from "crypto";
|
|
4247
|
-
import { readFileSync as
|
|
4248
|
-
import { join as
|
|
4442
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync10, unlinkSync as unlinkSync3 } from "fs";
|
|
4443
|
+
import { join as join14 } from "path";
|
|
4249
4444
|
function makePkce() {
|
|
4250
4445
|
const verifier = randomBytes2(48).toString("base64url");
|
|
4251
4446
|
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
|
@@ -4329,13 +4524,13 @@ function toStore(clientId, t, now) {
|
|
|
4329
4524
|
}
|
|
4330
4525
|
function loadStore() {
|
|
4331
4526
|
try {
|
|
4332
|
-
return JSON.parse(
|
|
4527
|
+
return JSON.parse(readFileSync12(STORE_PATH2, "utf8"));
|
|
4333
4528
|
} catch {
|
|
4334
4529
|
return null;
|
|
4335
4530
|
}
|
|
4336
4531
|
}
|
|
4337
4532
|
function saveStore(s) {
|
|
4338
|
-
|
|
4533
|
+
writeFileSync10(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
|
|
4339
4534
|
}
|
|
4340
4535
|
function clearStore() {
|
|
4341
4536
|
try {
|
|
@@ -4345,7 +4540,7 @@ function clearStore() {
|
|
|
4345
4540
|
}
|
|
4346
4541
|
function loadClientId() {
|
|
4347
4542
|
try {
|
|
4348
|
-
return JSON.parse(
|
|
4543
|
+
return JSON.parse(readFileSync12(CLIENT_PATH, "utf8")).clientId;
|
|
4349
4544
|
} catch {
|
|
4350
4545
|
return null;
|
|
4351
4546
|
}
|
|
@@ -4354,7 +4549,7 @@ async function ensureClientId(api, redirectUri, fetchFn = fetch) {
|
|
|
4354
4549
|
const existing = loadClientId();
|
|
4355
4550
|
if (existing) return existing;
|
|
4356
4551
|
const clientId = await registerClient({ api, redirectUri }, fetchFn);
|
|
4357
|
-
|
|
4552
|
+
writeFileSync10(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
|
|
4358
4553
|
return clientId;
|
|
4359
4554
|
}
|
|
4360
4555
|
async function ensureAccess(store, opts = {}) {
|
|
@@ -4380,16 +4575,16 @@ var init_oauth = __esm({
|
|
|
4380
4575
|
AUTHORIZE = "/api/oauth/authorize";
|
|
4381
4576
|
TOKEN = "/api/oauth/token";
|
|
4382
4577
|
SCOPE = "openid profile email taskless:full";
|
|
4383
|
-
STORE_PATH2 =
|
|
4384
|
-
CLIENT_PATH =
|
|
4578
|
+
STORE_PATH2 = join14(SWARM_HOME, "oauth.json");
|
|
4579
|
+
CLIENT_PATH = join14(SWARM_HOME, "oauth-client.json");
|
|
4385
4580
|
base2 = (api) => api.replace(/\/$/, "");
|
|
4386
4581
|
}
|
|
4387
4582
|
});
|
|
4388
4583
|
|
|
4389
4584
|
// src/git.ts
|
|
4390
|
-
import { existsSync as
|
|
4585
|
+
import { existsSync as existsSync12, readdirSync as readdirSync11, realpathSync as realpathSync2, statSync as statSync11 } from "fs";
|
|
4391
4586
|
import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
|
|
4392
|
-
import { isAbsolute, join as
|
|
4587
|
+
import { isAbsolute, join as join17, resolve as resolve2, sep as sep2 } from "path";
|
|
4393
4588
|
import { $ as $5 } from "execa";
|
|
4394
4589
|
function gitNet(repo, args, timeoutMs) {
|
|
4395
4590
|
return withHardTimeout(
|
|
@@ -4403,14 +4598,14 @@ async function reclaimStaleWorktree(repo, worktree) {
|
|
|
4403
4598
|
await detachWorktree(repo, worktree);
|
|
4404
4599
|
}
|
|
4405
4600
|
async function inspectWorktreePath(path) {
|
|
4406
|
-
if (!
|
|
4601
|
+
if (!existsSync12(path)) return "free";
|
|
4407
4602
|
try {
|
|
4408
|
-
if (
|
|
4603
|
+
if (readdirSync11(path).length === 0) return "free";
|
|
4409
4604
|
} catch {
|
|
4410
4605
|
return "orphan";
|
|
4411
4606
|
}
|
|
4412
4607
|
try {
|
|
4413
|
-
if (
|
|
4608
|
+
if (statSync11(join17(path, ".git")).isDirectory()) return "main-checkout";
|
|
4414
4609
|
} catch {
|
|
4415
4610
|
}
|
|
4416
4611
|
const top = await $5({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
|
|
@@ -4449,7 +4644,7 @@ async function clearWorktreePath(repo, path, branch, opts = {}) {
|
|
|
4449
4644
|
await detachWorktree(repo, path);
|
|
4450
4645
|
opts.onStaleReclaim?.(path);
|
|
4451
4646
|
}
|
|
4452
|
-
if (!
|
|
4647
|
+
if (!existsSync12(path)) return;
|
|
4453
4648
|
await parkOrphanDir(repo, path, branch);
|
|
4454
4649
|
}
|
|
4455
4650
|
async function parkOrphanDir(repo, path, branch) {
|
|
@@ -4470,7 +4665,7 @@ async function parkOrphanDir(repo, path, branch) {
|
|
|
4470
4665
|
}
|
|
4471
4666
|
function isLinkedWorktree(dir) {
|
|
4472
4667
|
try {
|
|
4473
|
-
return
|
|
4668
|
+
return statSync11(join17(dir, ".git")).isFile();
|
|
4474
4669
|
} catch {
|
|
4475
4670
|
return false;
|
|
4476
4671
|
}
|
|
@@ -4482,7 +4677,7 @@ async function detachWorktree(repo, worktree) {
|
|
|
4482
4677
|
}
|
|
4483
4678
|
}
|
|
4484
4679
|
async function ensureWorktreeDirGone(worktree) {
|
|
4485
|
-
if (!
|
|
4680
|
+
if (!existsSync12(worktree)) return false;
|
|
4486
4681
|
if (!isLinkedWorktree(worktree)) {
|
|
4487
4682
|
console.error(
|
|
4488
4683
|
`[git] ${worktree} \u2014 \u043D\u0435 \u043F\u0440\u0438\u0441\u0442\u0451\u0433\u043D\u0443\u0442\u044B\u0439 worktree (.git \u043D\u0435 \u0444\u0430\u0439\u043B): \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u041D\u0415 \u0442\u0440\u043E\u0433\u0430\u044E. \u0415\u0441\u043B\u0438 \u044D\u0442\u043E \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E worktree \u0434\u0440\u043E\u043D\u0430 \u2014 \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u0435\u0433\u043E \u0440\u0443\u043A\u0430\u043C\u0438; \u0435\u0441\u043B\u0438 \u044D\u0442\u043E \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0447\u0435\u043A\u0430\u0443\u0442, \u0437\u043D\u0430\u0447\u0438\u0442 \u0432\u0435\u0442\u043A\u0430 \u0441\u043B\u0430\u0433\u0430 \u0447\u0435\u043A\u043D\u0443\u0442\u0430 \u0432 \u043D\u0451\u043C (git checkout <slug>) \u2014 \u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u0435\u0433\u043E \u043D\u0430 \u0434\u0440\u0443\u0433\u0443\u044E \u0432\u0435\u0442\u043A\u0443.`
|
|
@@ -4497,7 +4692,7 @@ async function ensureWorktreeDirGone(worktree) {
|
|
|
4497
4692
|
);
|
|
4498
4693
|
return true;
|
|
4499
4694
|
}
|
|
4500
|
-
if (
|
|
4695
|
+
if (existsSync12(worktree)) {
|
|
4501
4696
|
console.error(`[git] \u043A\u0430\u0442\u0430\u043B\u043E\u0433 worktree ${worktree} \u043F\u0435\u0440\u0435\u0436\u0438\u043B rm \u2014 \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0443\u043A\u0430\u043C\u0438, \u0438\u043D\u0430\u0447\u0435 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u0441\u043F\u0430\u0432\u043D \u0441\u043B\u0430\u0433\u0430 \u0432\u0441\u0442\u0430\u043D\u0435\u0442.`);
|
|
4502
4697
|
}
|
|
4503
4698
|
return true;
|
|
@@ -4546,7 +4741,7 @@ async function checkoutWorktree(repo, path, branch, opts) {
|
|
|
4546
4741
|
}
|
|
4547
4742
|
const busyAt = await worktreeForBranch(repo, branch);
|
|
4548
4743
|
if (busyAt) {
|
|
4549
|
-
const exists =
|
|
4744
|
+
const exists = existsSync12(busyAt);
|
|
4550
4745
|
const live2 = exists && (opts.isWorktreeHeldLive ? await opts.isWorktreeHeldLive(busyAt) : true);
|
|
4551
4746
|
if (live2) throw new WorktreeBusyError(branch, busyAt);
|
|
4552
4747
|
if (exists && await worktreeDirty(busyAt)) throw new WorktreeBusyError(branch, busyAt);
|
|
@@ -4577,8 +4772,8 @@ async function ensureGitExcluded(worktree, pattern) {
|
|
|
4577
4772
|
try {
|
|
4578
4773
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
4579
4774
|
if (!commonDir) return false;
|
|
4580
|
-
const infoDir =
|
|
4581
|
-
const excludeFile =
|
|
4775
|
+
const infoDir = join17(commonDir, "info");
|
|
4776
|
+
const excludeFile = join17(infoDir, "exclude");
|
|
4582
4777
|
let current = "";
|
|
4583
4778
|
try {
|
|
4584
4779
|
current = await readFile(excludeFile, "utf8");
|
|
@@ -4598,7 +4793,7 @@ async function gitPath(worktree, flag) {
|
|
|
4598
4793
|
const out = await $5({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
|
|
4599
4794
|
const raw = out.stdout.trim();
|
|
4600
4795
|
if (out.exitCode !== 0 || !raw) return null;
|
|
4601
|
-
return isAbsolute(raw) ? raw :
|
|
4796
|
+
return isAbsolute(raw) ? raw : join17(worktree, raw);
|
|
4602
4797
|
}
|
|
4603
4798
|
async function ensureWorktreeHygiene(worktree) {
|
|
4604
4799
|
for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
|
|
@@ -4608,12 +4803,12 @@ async function installGuardHooks(worktree) {
|
|
|
4608
4803
|
try {
|
|
4609
4804
|
const gitDir = await gitPath(worktree, "--git-dir");
|
|
4610
4805
|
if (!gitDir) return false;
|
|
4611
|
-
const hooksDir =
|
|
4806
|
+
const hooksDir = join17(gitDir, "swarm-hooks");
|
|
4612
4807
|
const prev = await previousHooksPath(worktree);
|
|
4613
4808
|
await mkdir(hooksDir, { recursive: true });
|
|
4614
4809
|
for (const hook of GUARD_HOOKS) {
|
|
4615
|
-
await writeFile(
|
|
4616
|
-
await chmod(
|
|
4810
|
+
await writeFile(join17(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
|
|
4811
|
+
await chmod(join17(hooksDir, hook), 493);
|
|
4617
4812
|
}
|
|
4618
4813
|
await $5`git -C ${worktree} config extensions.worktreeConfig true`;
|
|
4619
4814
|
await $5`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
|
|
@@ -4632,7 +4827,7 @@ async function previousHooksPath(worktree) {
|
|
|
4632
4827
|
if (out.exitCode === 0 && value) return value;
|
|
4633
4828
|
}
|
|
4634
4829
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
4635
|
-
return commonDir ?
|
|
4830
|
+
return commonDir ? join17(commonDir, "hooks") : null;
|
|
4636
4831
|
}
|
|
4637
4832
|
async function removeWorktree(repo, path) {
|
|
4638
4833
|
const branch = (await $5({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
|
|
@@ -4695,7 +4890,7 @@ var init_git = __esm({
|
|
|
4695
4890
|
|
|
4696
4891
|
// src/attachments.ts
|
|
4697
4892
|
import { mkdir as mkdir2, rm as rm2, writeFile as writeFile2 } from "fs/promises";
|
|
4698
|
-
import { join as
|
|
4893
|
+
import { join as join18 } from "path";
|
|
4699
4894
|
var ATTACHMENTS_DIR, ATTACH_MAX_TOTAL_BYTES, ATTACH_MAX_FILE_BYTES, IMAGE_EXT, DOC_EXT, TEXT_EXT, KNOWN_EXT;
|
|
4700
4895
|
var init_attachments = __esm({
|
|
4701
4896
|
"src/attachments.ts"() {
|
|
@@ -4714,7 +4909,7 @@ var init_attachments = __esm({
|
|
|
4714
4909
|
|
|
4715
4910
|
// src/shotUpload.ts
|
|
4716
4911
|
import { readFile as fsReadFile } from "fs/promises";
|
|
4717
|
-
import { basename as basename5, isAbsolute as isAbsolute2, join as
|
|
4912
|
+
import { basename as basename5, isAbsolute as isAbsolute2, join as join19 } from "path";
|
|
4718
4913
|
var SHOT_MAX_FILE_BYTES;
|
|
4719
4914
|
var init_shotUpload = __esm({
|
|
4720
4915
|
"src/shotUpload.ts"() {
|
|
@@ -4765,18 +4960,18 @@ var init_prodHttp = __esm({
|
|
|
4765
4960
|
});
|
|
4766
4961
|
|
|
4767
4962
|
// src/workspace.ts
|
|
4768
|
-
import { readFileSync as
|
|
4769
|
-
import { join as
|
|
4963
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync11, unlinkSync as unlinkSync4 } from "fs";
|
|
4964
|
+
import { join as join20 } from "path";
|
|
4770
4965
|
function loadWorkspace() {
|
|
4771
4966
|
try {
|
|
4772
|
-
const w = JSON.parse(
|
|
4967
|
+
const w = JSON.parse(readFileSync13(WORKSPACE_PATH, "utf8"));
|
|
4773
4968
|
return w && typeof w.id === "string" && w.id ? w : null;
|
|
4774
4969
|
} catch {
|
|
4775
4970
|
return null;
|
|
4776
4971
|
}
|
|
4777
4972
|
}
|
|
4778
4973
|
function saveWorkspace(w) {
|
|
4779
|
-
|
|
4974
|
+
writeFileSync11(WORKSPACE_PATH, JSON.stringify(w, null, 2), { mode: 384 });
|
|
4780
4975
|
}
|
|
4781
4976
|
function clearWorkspace() {
|
|
4782
4977
|
try {
|
|
@@ -4792,7 +4987,7 @@ var init_workspace = __esm({
|
|
|
4792
4987
|
"src/workspace.ts"() {
|
|
4793
4988
|
"use strict";
|
|
4794
4989
|
init_config();
|
|
4795
|
-
WORKSPACE_PATH =
|
|
4990
|
+
WORKSPACE_PATH = join20(SWARM_HOME, "workspace.json");
|
|
4796
4991
|
}
|
|
4797
4992
|
});
|
|
4798
4993
|
|
|
@@ -5233,14 +5428,14 @@ var init_daemonLink = __esm({
|
|
|
5233
5428
|
});
|
|
5234
5429
|
|
|
5235
5430
|
// src/pauseState.ts
|
|
5236
|
-
import { existsSync as
|
|
5237
|
-
import { join as
|
|
5431
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14, renameSync as renameSync5, unlinkSync as unlinkSync5, writeFileSync as writeFileSync12 } from "fs";
|
|
5432
|
+
import { join as join21 } from "path";
|
|
5238
5433
|
function pauseStatePath(home) {
|
|
5239
|
-
return
|
|
5434
|
+
return join21(home, "pause.json");
|
|
5240
5435
|
}
|
|
5241
5436
|
function loadPauseState(home, io = {}) {
|
|
5242
|
-
const exists = io.exists ??
|
|
5243
|
-
const readFile2 = io.readFile ?? ((p) =>
|
|
5437
|
+
const exists = io.exists ?? existsSync13;
|
|
5438
|
+
const readFile2 = io.readFile ?? ((p) => readFileSync14(p, "utf8"));
|
|
5244
5439
|
const path = pauseStatePath(home);
|
|
5245
5440
|
if (!exists(path)) return ACTIVE;
|
|
5246
5441
|
try {
|
|
@@ -5259,12 +5454,12 @@ function loadPauseState(home, io = {}) {
|
|
|
5259
5454
|
function savePauseState(home, state, io = {}) {
|
|
5260
5455
|
const path = pauseStatePath(home);
|
|
5261
5456
|
if (!state.paused) {
|
|
5262
|
-
const remove = io.remove ?? ((p) =>
|
|
5457
|
+
const remove = io.remove ?? ((p) => existsSync13(p) && unlinkSync5(p));
|
|
5263
5458
|
remove(path);
|
|
5264
5459
|
return;
|
|
5265
5460
|
}
|
|
5266
5461
|
const writeFile3 = io.writeFile ?? ((p, data) => {
|
|
5267
|
-
|
|
5462
|
+
writeFileSync12(`${p}.tmp`, data);
|
|
5268
5463
|
renameSync5(`${p}.tmp`, p);
|
|
5269
5464
|
});
|
|
5270
5465
|
writeFile3(path, JSON.stringify(state, null, 2));
|
|
@@ -5301,10 +5496,10 @@ var init_pauseState = __esm({
|
|
|
5301
5496
|
});
|
|
5302
5497
|
|
|
5303
5498
|
// src/heartbeat.ts
|
|
5304
|
-
import { readFileSync as
|
|
5499
|
+
import { readFileSync as readFileSync15, renameSync as renameSync6, writeFileSync as writeFileSync13 } from "fs";
|
|
5305
5500
|
function readHeartbeat(path) {
|
|
5306
5501
|
try {
|
|
5307
|
-
const ms = Number(
|
|
5502
|
+
const ms = Number(readFileSync15(path, "utf8").trim());
|
|
5308
5503
|
return Number.isFinite(ms) ? ms : null;
|
|
5309
5504
|
} catch {
|
|
5310
5505
|
return null;
|
|
@@ -5323,7 +5518,7 @@ __export(db_exports, {
|
|
|
5323
5518
|
});
|
|
5324
5519
|
import { createRequire as createRequire2 } from "module";
|
|
5325
5520
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
5326
|
-
import { existsSync as
|
|
5521
|
+
import { existsSync as existsSync14 } from "fs";
|
|
5327
5522
|
import { resolve as resolve3 } from "path";
|
|
5328
5523
|
function rowToQuestion(row) {
|
|
5329
5524
|
return {
|
|
@@ -5987,7 +6182,7 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
5987
6182
|
const repoN = normalizeRepo(repo);
|
|
5988
6183
|
const already = this.db.prepare("SELECT run_count FROM imports WHERE source = ?").get(abs);
|
|
5989
6184
|
if (already) return { imported: false, runs: already.run_count };
|
|
5990
|
-
if (!
|
|
6185
|
+
if (!existsSync14(abs)) throw new Error(`import-db: \u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442: ${abs}`);
|
|
5991
6186
|
const src = new this.databaseCtor(abs);
|
|
5992
6187
|
try {
|
|
5993
6188
|
const runs = src.prepare("SELECT * FROM runs ORDER BY id").all();
|
|
@@ -6315,8 +6510,8 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
6315
6510
|
});
|
|
6316
6511
|
|
|
6317
6512
|
// src/repoScan.ts
|
|
6318
|
-
import { readdirSync as
|
|
6319
|
-
import { join as
|
|
6513
|
+
import { readdirSync as readdirSync12, readFileSync as readFileSync16, statSync as statSync12 } from "fs";
|
|
6514
|
+
import { join as join22 } from "path";
|
|
6320
6515
|
var init_repoScan = __esm({
|
|
6321
6516
|
"src/repoScan.ts"() {
|
|
6322
6517
|
"use strict";
|
|
@@ -6326,8 +6521,8 @@ var init_repoScan = __esm({
|
|
|
6326
6521
|
|
|
6327
6522
|
// src/repoDiscovery.ts
|
|
6328
6523
|
import { homedir as homedir6 } from "os";
|
|
6329
|
-
import { readFileSync as
|
|
6330
|
-
import { isAbsolute as isAbsolute3, join as
|
|
6524
|
+
import { readFileSync as readFileSync17, renameSync as renameSync7, writeFileSync as writeFileSync14 } from "fs";
|
|
6525
|
+
import { isAbsolute as isAbsolute3, join as join23, resolve as resolve4 } from "path";
|
|
6331
6526
|
function repoMapLines(rows) {
|
|
6332
6527
|
if (!rows?.length) return [];
|
|
6333
6528
|
const missing = rows.filter((r) => !r.path).length;
|
|
@@ -6342,7 +6537,7 @@ function repoMapLines(rows) {
|
|
|
6342
6537
|
}
|
|
6343
6538
|
function loadRepoMapCache(path) {
|
|
6344
6539
|
try {
|
|
6345
|
-
const raw = JSON.parse(
|
|
6540
|
+
const raw = JSON.parse(readFileSync17(path, "utf8"));
|
|
6346
6541
|
if (!Array.isArray(raw?.entries)) return { scannedAt: null, entries: [] };
|
|
6347
6542
|
return {
|
|
6348
6543
|
scannedAt: typeof raw.scannedAt === "string" && raw.scannedAt ? raw.scannedAt : null,
|
|
@@ -6718,11 +6913,11 @@ __export(statusCli_exports, {
|
|
|
6718
6913
|
probeLink: () => probeLink,
|
|
6719
6914
|
runStatusCli: () => runStatusCli
|
|
6720
6915
|
});
|
|
6721
|
-
import { existsSync as
|
|
6916
|
+
import { existsSync as existsSync15, readFileSync as readFileSync18 } from "fs";
|
|
6722
6917
|
function outboxPending(path) {
|
|
6723
6918
|
try {
|
|
6724
|
-
if (!
|
|
6725
|
-
return
|
|
6919
|
+
if (!existsSync15(path)) return 0;
|
|
6920
|
+
return readFileSync18(path, "utf8").split("\n").filter((l) => l.trim()).length;
|
|
6726
6921
|
} catch {
|
|
6727
6922
|
return null;
|
|
6728
6923
|
}
|
|
@@ -6929,23 +7124,23 @@ var init_prodMergeGate = __esm({
|
|
|
6929
7124
|
});
|
|
6930
7125
|
|
|
6931
7126
|
// src/platform.ts
|
|
6932
|
-
import { accessSync, constants, existsSync as
|
|
6933
|
-
import { delimiter, join as
|
|
7127
|
+
import { accessSync, constants, existsSync as existsSync16, readFileSync as readFileSync19, realpathSync as realpathSync3 } from "fs";
|
|
7128
|
+
import { delimiter, join as join24, posix as posix2, win32 } from "path";
|
|
6934
7129
|
function safeReadText(path) {
|
|
6935
7130
|
try {
|
|
6936
|
-
return
|
|
7131
|
+
return readFileSync19(path, "utf8");
|
|
6937
7132
|
} catch {
|
|
6938
7133
|
return null;
|
|
6939
7134
|
}
|
|
6940
7135
|
}
|
|
6941
7136
|
function resolveCommandPath(name, env = process.env, platform = process.platform) {
|
|
6942
|
-
if (name.includes("/") || name.includes("\\")) return
|
|
7137
|
+
if (name.includes("/") || name.includes("\\")) return existsSync16(name) ? name : null;
|
|
6943
7138
|
const dirs = (env.PATH ?? env.Path ?? "").split(delimiter).filter(Boolean);
|
|
6944
7139
|
const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
|
|
6945
7140
|
for (const dir of dirs) {
|
|
6946
7141
|
for (const ext of exts) {
|
|
6947
|
-
const candidate =
|
|
6948
|
-
if (
|
|
7142
|
+
const candidate = join24(dir, name + ext);
|
|
7143
|
+
if (existsSync16(candidate)) return candidate;
|
|
6949
7144
|
}
|
|
6950
7145
|
}
|
|
6951
7146
|
return null;
|
|
@@ -7135,13 +7330,13 @@ var init_platform = __esm({
|
|
|
7135
7330
|
});
|
|
7136
7331
|
|
|
7137
7332
|
// src/envGate.ts
|
|
7138
|
-
import { existsSync as
|
|
7139
|
-
import { join as
|
|
7333
|
+
import { existsSync as existsSync17 } from "fs";
|
|
7334
|
+
import { join as join25 } from "path";
|
|
7140
7335
|
import { createConnection } from "net";
|
|
7141
7336
|
import { execa as execa3 } from "execa";
|
|
7142
7337
|
function detectRequirements(repo, io = {}) {
|
|
7143
|
-
const exists = io.exists ??
|
|
7144
|
-
const marker = COMPOSE_MARKERS.find((f) => exists(
|
|
7338
|
+
const exists = io.exists ?? existsSync17;
|
|
7339
|
+
const marker = COMPOSE_MARKERS.find((f) => exists(join25(repo, f)));
|
|
7145
7340
|
return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
|
|
7146
7341
|
}
|
|
7147
7342
|
async function dockerAlive() {
|
|
@@ -7173,7 +7368,7 @@ var init_envGate = __esm({
|
|
|
7173
7368
|
});
|
|
7174
7369
|
|
|
7175
7370
|
// src/doctor.ts
|
|
7176
|
-
import { isAbsolute as isAbsolute4, join as
|
|
7371
|
+
import { isAbsolute as isAbsolute4, join as join26 } from "path";
|
|
7177
7372
|
function ok(id, title, detail) {
|
|
7178
7373
|
return { id, title, status: "ok", detail, remedies: [], critical: false };
|
|
7179
7374
|
}
|
|
@@ -7382,7 +7577,7 @@ function checkRepos(io, snap) {
|
|
|
7382
7577
|
critical: true
|
|
7383
7578
|
};
|
|
7384
7579
|
}
|
|
7385
|
-
if (env && !io.exists(
|
|
7580
|
+
if (env && !io.exists(join26(env, ".git"))) {
|
|
7386
7581
|
return {
|
|
7387
7582
|
id: "repos",
|
|
7388
7583
|
title,
|
|
@@ -7392,7 +7587,7 @@ function checkRepos(io, snap) {
|
|
|
7392
7587
|
critical: true
|
|
7393
7588
|
};
|
|
7394
7589
|
}
|
|
7395
|
-
const broken = snap.paths.filter((p) => !io.exists(
|
|
7590
|
+
const broken = snap.paths.filter((p) => !io.exists(join26(p, ".git")));
|
|
7396
7591
|
if (broken.length) {
|
|
7397
7592
|
return {
|
|
7398
7593
|
id: "repos",
|
|
@@ -7582,12 +7777,12 @@ var init_doctor = __esm({
|
|
|
7582
7777
|
});
|
|
7583
7778
|
|
|
7584
7779
|
// src/repoMemory.ts
|
|
7585
|
-
import { readFileSync as
|
|
7586
|
-
import { join as
|
|
7780
|
+
import { readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "fs";
|
|
7781
|
+
import { join as join27 } from "path";
|
|
7587
7782
|
function loadRememberedRepos(home) {
|
|
7588
7783
|
let raw;
|
|
7589
7784
|
try {
|
|
7590
|
-
raw =
|
|
7785
|
+
raw = readFileSync20(join27(home, FILE), "utf8");
|
|
7591
7786
|
} catch {
|
|
7592
7787
|
return [];
|
|
7593
7788
|
}
|
|
@@ -7623,7 +7818,7 @@ __export(installCli_exports, {
|
|
|
7623
7818
|
runInstallHookCli: () => runInstallHookCli,
|
|
7624
7819
|
shortenError: () => shortenError
|
|
7625
7820
|
});
|
|
7626
|
-
import { existsSync as
|
|
7821
|
+
import { existsSync as existsSync18 } from "fs";
|
|
7627
7822
|
function classifyChromiumError(message) {
|
|
7628
7823
|
if (/playwright-core не установлен|Cannot find (module|package)/i.test(message)) return "no-module";
|
|
7629
7824
|
if (/error while loading shared libraries|cannot open shared object file|missing dependencies|\blib[\w.+-]*\.so[.\d]*\b/i.test(message)) return "no-libs";
|
|
@@ -7678,7 +7873,7 @@ function defaultDoctorIO(packageVersion) {
|
|
|
7678
7873
|
packageVersion,
|
|
7679
7874
|
entry,
|
|
7680
7875
|
hasCommand: (name) => hasCommandInPath(name),
|
|
7681
|
-
exists:
|
|
7876
|
+
exists: existsSync18,
|
|
7682
7877
|
run: (command) => runQuiet(command),
|
|
7683
7878
|
latestVersion: () => latestMemo ??= fetchLatestVersion(),
|
|
7684
7879
|
probeChromium: () => probeChromium(),
|
|
@@ -7918,8 +8113,8 @@ var init_updateCli = __esm({
|
|
|
7918
8113
|
|
|
7919
8114
|
// src/cli.ts
|
|
7920
8115
|
init_cliIo();
|
|
7921
|
-
import { basename as basename6, dirname as dirname5, join as
|
|
7922
|
-
import { existsSync as
|
|
8116
|
+
import { basename as basename6, dirname as dirname5, join as join28 } from "path";
|
|
8117
|
+
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";
|
|
7923
8118
|
import { setTimeout as sleep2 } from "timers/promises";
|
|
7924
8119
|
|
|
7925
8120
|
// src/swarmClient.ts
|
|
@@ -7927,7 +8122,7 @@ init_config();
|
|
|
7927
8122
|
init_resources();
|
|
7928
8123
|
init_names2();
|
|
7929
8124
|
init_storm();
|
|
7930
|
-
import { appendFileSync, existsSync as
|
|
8125
|
+
import { appendFileSync, existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "fs";
|
|
7931
8126
|
import { dirname as dirname2 } from "path";
|
|
7932
8127
|
import { randomUUID } from "crypto";
|
|
7933
8128
|
|
|
@@ -7961,24 +8156,24 @@ init_store();
|
|
|
7961
8156
|
init_toolFailure();
|
|
7962
8157
|
|
|
7963
8158
|
// src/logTail.ts
|
|
7964
|
-
import { closeSync, existsSync as
|
|
7965
|
-
import { join as
|
|
8159
|
+
import { closeSync, existsSync as existsSync7, openSync, readSync, readdirSync as readdirSync8, statSync as statSync7 } from "fs";
|
|
8160
|
+
import { join as join11 } from "path";
|
|
7966
8161
|
|
|
7967
8162
|
// src/runLogDir.ts
|
|
7968
|
-
import { existsSync as
|
|
7969
|
-
import { join as
|
|
8163
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync7, readdirSync as readdirSync7, renameSync as renameSync2, statSync as statSync6 } from "fs";
|
|
8164
|
+
import { join as join10 } from "path";
|
|
7970
8165
|
function runLogDirName(runLogKey) {
|
|
7971
8166
|
const safe = runLogKey.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^[-_]+|[-_]+$/g, "");
|
|
7972
8167
|
if (!safe) throw new Error(`\u043A\u043B\u044E\u0447 \u043F\u0440\u043E\u0433\u043E\u043D\u0430 \u043D\u0435 \u0433\u043E\u0434\u0438\u0442\u0441\u044F \u0432 \u0438\u043C\u044F \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 run-log'\u043E\u0432: ${JSON.stringify(runLogKey)}`);
|
|
7973
8168
|
return /^\d+$/.test(safe) ? `k-${safe}` : safe;
|
|
7974
8169
|
}
|
|
7975
8170
|
function runLogDirPath(runLogsDir, runLogKey) {
|
|
7976
|
-
return
|
|
8171
|
+
return join10(runLogsDir, runLogDirName(runLogKey));
|
|
7977
8172
|
}
|
|
7978
8173
|
function findRunLogDir(runLogsDir, keys) {
|
|
7979
8174
|
for (const key of keys) {
|
|
7980
8175
|
const dir = runLogDirPath(runLogsDir, key);
|
|
7981
|
-
if (
|
|
8176
|
+
if (existsSync6(dir)) return dir;
|
|
7982
8177
|
}
|
|
7983
8178
|
return null;
|
|
7984
8179
|
}
|
|
@@ -8195,26 +8390,26 @@ var SwarmClient = class _SwarmClient {
|
|
|
8195
8390
|
this.repoFullNames = registry.map((e) => e.repoFullName);
|
|
8196
8391
|
this.repoPathByFullName = new Map(registry.map((e) => [e.repoFullName, normalizeRepo(e.path)]));
|
|
8197
8392
|
this.host = opts.host ?? null;
|
|
8198
|
-
this.repoExists = opts.repoExists ??
|
|
8393
|
+
this.repoExists = opts.repoExists ?? existsSync8;
|
|
8199
8394
|
this.questionSyncMs = opts.questionSyncMs ?? 3e3;
|
|
8200
8395
|
this.executorId = opts.executorId ?? EXECUTOR.id;
|
|
8201
8396
|
this.outboxPath = opts.outboxPath;
|
|
8202
8397
|
this.mapPath = `${opts.outboxPath}.prodmap.json`;
|
|
8203
8398
|
this.stormPath = `${opts.outboxPath}.storm.jsonl`;
|
|
8204
|
-
|
|
8399
|
+
mkdirSync8(dirname2(this.outboxPath), { recursive: true });
|
|
8205
8400
|
this.recover();
|
|
8206
8401
|
}
|
|
8207
8402
|
// ── рестарт: поднять outbox (незаписанные операции) и карту runKey→prodId ─────
|
|
8208
8403
|
recover() {
|
|
8209
|
-
if (
|
|
8404
|
+
if (existsSync8(this.mapPath)) {
|
|
8210
8405
|
try {
|
|
8211
|
-
const obj = JSON.parse(
|
|
8406
|
+
const obj = JSON.parse(readFileSync7(this.mapPath, "utf8"));
|
|
8212
8407
|
for (const [k, v] of Object.entries(obj)) this.prodIdByKey.set(k, v);
|
|
8213
8408
|
} catch {
|
|
8214
8409
|
}
|
|
8215
8410
|
}
|
|
8216
|
-
if (
|
|
8217
|
-
const txt =
|
|
8411
|
+
if (existsSync8(this.outboxPath)) {
|
|
8412
|
+
const txt = readFileSync7(this.outboxPath, "utf8");
|
|
8218
8413
|
for (const line of txt.split("\n")) {
|
|
8219
8414
|
const s = line.trim();
|
|
8220
8415
|
if (!s) continue;
|
|
@@ -8234,10 +8429,10 @@ var SwarmClient = class _SwarmClient {
|
|
|
8234
8429
|
// eventsLog ПЕРВЫМИ (до hydrate), в порядке файла (= хронологический); id
|
|
8235
8430
|
// переприсваиваем локально (id событий — только порядок, не корреляция с продом).
|
|
8236
8431
|
replayGlobalEvents() {
|
|
8237
|
-
if (!
|
|
8432
|
+
if (!existsSync8(this.stormPath)) return;
|
|
8238
8433
|
let txt;
|
|
8239
8434
|
try {
|
|
8240
|
-
txt =
|
|
8435
|
+
txt = readFileSync7(this.stormPath, "utf8");
|
|
8241
8436
|
} catch {
|
|
8242
8437
|
return;
|
|
8243
8438
|
}
|
|
@@ -9234,7 +9429,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
9234
9429
|
* транзиентным сбоем ОС, который этот PR должен переживать, а не превращать в мор.
|
|
9235
9430
|
*/
|
|
9236
9431
|
reconcileRuntime(opts) {
|
|
9237
|
-
const wtExists = opts.worktreeExists ??
|
|
9432
|
+
const wtExists = opts.worktreeExists ?? existsSync8;
|
|
9238
9433
|
const pidByWorktree = /* @__PURE__ */ new Map();
|
|
9239
9434
|
try {
|
|
9240
9435
|
for (const p of opts.listProcesses()) if (p.worktree) pidByWorktree.set(p.worktree, p.pid);
|
|
@@ -10502,13 +10697,13 @@ var SwarmClient = class _SwarmClient {
|
|
|
10502
10697
|
}
|
|
10503
10698
|
persistPending() {
|
|
10504
10699
|
try {
|
|
10505
|
-
|
|
10700
|
+
writeFileSync7(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
|
|
10506
10701
|
} catch {
|
|
10507
10702
|
}
|
|
10508
10703
|
}
|
|
10509
10704
|
persistMap() {
|
|
10510
10705
|
try {
|
|
10511
|
-
|
|
10706
|
+
writeFileSync7(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
|
|
10512
10707
|
} catch {
|
|
10513
10708
|
}
|
|
10514
10709
|
}
|
|
@@ -10641,7 +10836,7 @@ init_config();
|
|
|
10641
10836
|
import { $ as $6 } from "execa";
|
|
10642
10837
|
|
|
10643
10838
|
// src/daemonLaunch.ts
|
|
10644
|
-
import { openSync as openSync2, closeSync as closeSync2, readFileSync as
|
|
10839
|
+
import { openSync as openSync2, closeSync as closeSync2, readFileSync as readFileSync8 } from "fs";
|
|
10645
10840
|
import { spawn } from "child_process";
|
|
10646
10841
|
var FOREGROUND_FLAGS = /* @__PURE__ */ new Set(["--foreground", "-f", "--attach"]);
|
|
10647
10842
|
function parseStartMode(argv) {
|
|
@@ -10701,27 +10896,27 @@ function launchDetached(opts) {
|
|
|
10701
10896
|
}
|
|
10702
10897
|
function tailFile(path, lines) {
|
|
10703
10898
|
try {
|
|
10704
|
-
return tailText(
|
|
10899
|
+
return tailText(readFileSync8(path, "utf8"), lines);
|
|
10705
10900
|
} catch {
|
|
10706
10901
|
return "";
|
|
10707
10902
|
}
|
|
10708
10903
|
}
|
|
10709
10904
|
|
|
10710
10905
|
// src/logRotate.ts
|
|
10711
|
-
import { copyFileSync as
|
|
10906
|
+
import { copyFileSync as copyFileSync5, renameSync as renameSync3, statSync as statSync8, fstatSync, truncateSync, unlinkSync as unlinkSync2, existsSync as existsSync9, openSync as openSync3, writeSync, closeSync as closeSync3 } from "fs";
|
|
10712
10907
|
var realIo = {
|
|
10713
10908
|
size: (path) => {
|
|
10714
10909
|
try {
|
|
10715
|
-
return
|
|
10910
|
+
return statSync8(path).size;
|
|
10716
10911
|
} catch {
|
|
10717
10912
|
return null;
|
|
10718
10913
|
}
|
|
10719
10914
|
},
|
|
10720
|
-
copy:
|
|
10915
|
+
copy: copyFileSync5,
|
|
10721
10916
|
rename: renameSync3,
|
|
10722
10917
|
truncate: (path) => truncateSync(path, 0),
|
|
10723
10918
|
unlink: unlinkSync2,
|
|
10724
|
-
exists:
|
|
10919
|
+
exists: existsSync9
|
|
10725
10920
|
};
|
|
10726
10921
|
var realOwnerIo = {
|
|
10727
10922
|
statFd: (fd) => {
|
|
@@ -10734,7 +10929,7 @@ var realOwnerIo = {
|
|
|
10734
10929
|
},
|
|
10735
10930
|
statPath: (path) => {
|
|
10736
10931
|
try {
|
|
10737
|
-
const s =
|
|
10932
|
+
const s = statSync8(path);
|
|
10738
10933
|
return { dev: s.dev, ino: s.ino };
|
|
10739
10934
|
} catch {
|
|
10740
10935
|
return null;
|
|
@@ -10801,17 +10996,17 @@ init_repoRegistry();
|
|
|
10801
10996
|
|
|
10802
10997
|
// src/hostIdentity.ts
|
|
10803
10998
|
import { hostname } from "os";
|
|
10804
|
-
import { existsSync as
|
|
10805
|
-
import { join as
|
|
10999
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10, renameSync as renameSync4, writeFileSync as writeFileSync8 } from "fs";
|
|
11000
|
+
import { join as join12 } from "path";
|
|
10806
11001
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
10807
11002
|
function hostIdentityPath(home) {
|
|
10808
|
-
return
|
|
11003
|
+
return join12(home, "host.json");
|
|
10809
11004
|
}
|
|
10810
11005
|
function loadHostIdentity(deps) {
|
|
10811
|
-
const exists = deps.exists ??
|
|
10812
|
-
const readFile2 = deps.readFile ?? ((p) =>
|
|
11006
|
+
const exists = deps.exists ?? existsSync10;
|
|
11007
|
+
const readFile2 = deps.readFile ?? ((p) => readFileSync10(p, "utf8"));
|
|
10813
11008
|
const writeFile3 = deps.writeFile ?? ((p, data) => {
|
|
10814
|
-
|
|
11009
|
+
writeFileSync8(`${p}.tmp`, data);
|
|
10815
11010
|
renameSync4(`${p}.tmp`, p);
|
|
10816
11011
|
});
|
|
10817
11012
|
const host = deps.hostname ?? hostname;
|
|
@@ -10926,8 +11121,8 @@ import { basename as basename4 } from "path";
|
|
|
10926
11121
|
import { serve as serve2 } from "@hono/node-server";
|
|
10927
11122
|
|
|
10928
11123
|
// src/diff.ts
|
|
10929
|
-
import { statSync as
|
|
10930
|
-
import { join as
|
|
11124
|
+
import { statSync as statSync9 } from "fs";
|
|
11125
|
+
import { join as join13 } from "path";
|
|
10931
11126
|
import { $ as $3 } from "execa";
|
|
10932
11127
|
var MAX_FILES = 200;
|
|
10933
11128
|
var MAX_LINES_PER_FILE = 1500;
|
|
@@ -11070,7 +11265,7 @@ async function resolveBase(wt, baseBranch) {
|
|
|
11070
11265
|
}
|
|
11071
11266
|
function mtime(path) {
|
|
11072
11267
|
try {
|
|
11073
|
-
return
|
|
11268
|
+
return statSync9(path).mtimeMs;
|
|
11074
11269
|
} catch {
|
|
11075
11270
|
return 0;
|
|
11076
11271
|
}
|
|
@@ -11095,7 +11290,7 @@ async function collectRunDiff(worktree, opts = {}) {
|
|
|
11095
11290
|
files.push(pf);
|
|
11096
11291
|
}
|
|
11097
11292
|
}
|
|
11098
|
-
files.sort((a, b) => mtime(
|
|
11293
|
+
files.sort((a, b) => mtime(join13(worktree, b.path)) - mtime(join13(worktree, a.path)));
|
|
11099
11294
|
const truncatedFiles = files.length > MAX_FILES;
|
|
11100
11295
|
if (truncatedFiles) files = files.slice(0, MAX_FILES);
|
|
11101
11296
|
const added = files.reduce((s, f) => s + f.added, 0);
|
|
@@ -13257,15 +13452,15 @@ import { cancelRun, respawnRun, runDaemon, wakeRun, OVERMIND_ENTRY, listDronePro
|
|
|
13257
13452
|
|
|
13258
13453
|
// src/launcher.ts
|
|
13259
13454
|
import { spawn as spawn2 } from "child_process";
|
|
13260
|
-
import { closeSync as closeSync4, existsSync as
|
|
13455
|
+
import { closeSync as closeSync4, existsSync as existsSync11, mkdirSync as mkdirSync11, openSync as openSync4, readdirSync as readdirSync10 } from "fs";
|
|
13261
13456
|
import { createRequire } from "module";
|
|
13262
13457
|
import { homedir as homedir5 } from "os";
|
|
13263
|
-
import { dirname as dirname4, join as
|
|
13458
|
+
import { dirname as dirname4, join as join16 } from "path";
|
|
13264
13459
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
13265
13460
|
|
|
13266
13461
|
// src/droneHome.ts
|
|
13267
|
-
import { lstatSync, mkdirSync as
|
|
13268
|
-
import { join as
|
|
13462
|
+
import { lstatSync, mkdirSync as mkdirSync10, readdirSync as readdirSync9, rmSync, statSync as statSync10, symlinkSync as symlinkSync4 } from "fs";
|
|
13463
|
+
import { join as join15, relative, sep } from "path";
|
|
13269
13464
|
var DRONE_HOME_DENY_DEFAULT = [".taskless-swarm", ".bash_history", ".zsh_history"];
|
|
13270
13465
|
function droneHomeDeny(env = process.env) {
|
|
13271
13466
|
const extra = (env.SWARM_DRONE_HOME_DENY || "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -13283,34 +13478,34 @@ function buildDroneHome(opts) {
|
|
|
13283
13478
|
const { realHome, droneHome } = opts;
|
|
13284
13479
|
const deny = opts.deny ?? droneHomeDeny();
|
|
13285
13480
|
const platform = opts.platform ?? process.platform;
|
|
13286
|
-
|
|
13287
|
-
const wanted = new Set(mirroredEntries(
|
|
13481
|
+
mkdirSync10(droneHome, { recursive: true, mode: 448 });
|
|
13482
|
+
const wanted = new Set(mirroredEntries(readdirSync9(realHome), deny, platform));
|
|
13288
13483
|
const rel = relative(realHome, droneHome);
|
|
13289
13484
|
if (rel && !rel.startsWith("..") && !rel.includes(sep)) wanted.delete(rel);
|
|
13290
|
-
for (const existing of
|
|
13485
|
+
for (const existing of readdirSync9(droneHome)) {
|
|
13291
13486
|
if (wanted.has(existing)) continue;
|
|
13292
|
-
const p =
|
|
13487
|
+
const p = join15(droneHome, existing);
|
|
13293
13488
|
try {
|
|
13294
13489
|
if (lstatSync(p).isSymbolicLink()) rmSync(p);
|
|
13295
13490
|
} catch {
|
|
13296
13491
|
}
|
|
13297
13492
|
}
|
|
13298
13493
|
for (const name of wanted) {
|
|
13299
|
-
const link =
|
|
13494
|
+
const link = join15(droneHome, name);
|
|
13300
13495
|
try {
|
|
13301
13496
|
lstatSync(link);
|
|
13302
13497
|
continue;
|
|
13303
13498
|
} catch {
|
|
13304
13499
|
}
|
|
13305
|
-
const target =
|
|
13500
|
+
const target = join15(realHome, name);
|
|
13306
13501
|
let isDir;
|
|
13307
13502
|
try {
|
|
13308
|
-
isDir =
|
|
13503
|
+
isDir = statSync10(target).isDirectory();
|
|
13309
13504
|
} catch {
|
|
13310
13505
|
continue;
|
|
13311
13506
|
}
|
|
13312
13507
|
try {
|
|
13313
|
-
|
|
13508
|
+
symlinkSync4(target, link, isDir ? "junction" : "file");
|
|
13314
13509
|
} catch (e) {
|
|
13315
13510
|
if (e.code !== "EEXIST") throw e;
|
|
13316
13511
|
}
|
|
@@ -13323,7 +13518,7 @@ var REAL_PATH_ENV_PINS = [
|
|
|
13323
13518
|
{ env: "YARN_GLOBAL_FOLDER", segments: [".yarn", "berry"] }
|
|
13324
13519
|
];
|
|
13325
13520
|
function realPathEnvPins(realHome) {
|
|
13326
|
-
return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env,
|
|
13521
|
+
return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join15(realHome, ...segments)]));
|
|
13327
13522
|
}
|
|
13328
13523
|
function dronePrivatePaths(realHome, swarmHome) {
|
|
13329
13524
|
return [
|
|
@@ -13407,7 +13602,7 @@ function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
|
|
|
13407
13602
|
const env = { ...base3 };
|
|
13408
13603
|
const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
|
|
13409
13604
|
if (isolate && !base3.TURBO_CACHE_DIR) {
|
|
13410
|
-
env.TURBO_CACHE_DIR =
|
|
13605
|
+
env.TURBO_CACHE_DIR = join16(worktree, ".turbo", "cache");
|
|
13411
13606
|
}
|
|
13412
13607
|
Object.assign(env, droneTestEnv(droneCap, base3));
|
|
13413
13608
|
for (const key of DAEMON_STATE_ENV) delete env[key];
|
|
@@ -13438,21 +13633,21 @@ var DAEMON_STATE_ENV = [
|
|
|
13438
13633
|
...PROVIDER_TOKEN_ENV
|
|
13439
13634
|
];
|
|
13440
13635
|
function bundledRoleDir(kind) {
|
|
13441
|
-
return
|
|
13636
|
+
return join16(dirname4(fileURLToPath2(import.meta.url)), "..", "roles", kind);
|
|
13442
13637
|
}
|
|
13443
13638
|
function roleDir(worktree, kind) {
|
|
13444
|
-
return
|
|
13639
|
+
return join16(worktree, ".claude", "roles", kind);
|
|
13445
13640
|
}
|
|
13446
13641
|
function roleDirs(worktree, kind) {
|
|
13447
|
-
return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) =>
|
|
13642
|
+
return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync11(dir));
|
|
13448
13643
|
}
|
|
13449
13644
|
function nextRunLogPath(runLogsDir, runLogKeys) {
|
|
13450
13645
|
const dir = runLogDirForWrite(runLogsDir, runLogKeys);
|
|
13451
13646
|
if (!dir) throw new Error("\u043D\u0435\u0447\u0435\u043C \u0430\u0434\u0440\u0435\u0441\u043E\u0432\u0430\u0442\u044C \u043A\u0430\u0442\u0430\u043B\u043E\u0433 run-log'\u043E\u0432: \u0443 \u043F\u0440\u043E\u0433\u043E\u043D\u0430 \u043D\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043B\u044C\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 (SwarmStore.runLogKeys)");
|
|
13452
|
-
|
|
13647
|
+
mkdirSync11(dir, { recursive: true });
|
|
13453
13648
|
let files = [];
|
|
13454
13649
|
try {
|
|
13455
|
-
files =
|
|
13650
|
+
files = readdirSync10(dir);
|
|
13456
13651
|
} catch {
|
|
13457
13652
|
}
|
|
13458
13653
|
let next = 0;
|
|
@@ -13460,7 +13655,7 @@ function nextRunLogPath(runLogsDir, runLogKeys) {
|
|
|
13460
13655
|
const m = /^(\d+)\.json/.exec(f);
|
|
13461
13656
|
if (m) next = Math.max(next, Number(m[1]) + 1);
|
|
13462
13657
|
}
|
|
13463
|
-
return
|
|
13658
|
+
return join16(dir, `${next}.json`);
|
|
13464
13659
|
}
|
|
13465
13660
|
function openNextRunLog(runLogsDir, runLogKeys) {
|
|
13466
13661
|
for (let attempt = 0; attempt < 50; attempt++) {
|
|
@@ -13552,9 +13747,9 @@ function makeLauncher(cfg) {
|
|
|
13552
13747
|
}
|
|
13553
13748
|
const realHome = cfg.droneIsolation?.realHome ?? homedir5();
|
|
13554
13749
|
const home = cfg.droneIsolation ? buildDroneHome({ realHome, droneHome: cfg.droneIsolation.home }) : void 0;
|
|
13555
|
-
if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !
|
|
13750
|
+
if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync11(join16(cfg.droneIsolation.swarmHome, "token"))) {
|
|
13556
13751
|
console.error(
|
|
13557
|
-
`[launcher] TASKLESS_TOKEN \u0437\u0430\u0434\u0430\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 env \u0434\u0435\u043C\u043E\u043D\u0430 \u2014 \u0434\u0440\u043E\u043D\u0443 \u043E\u043D \u043D\u0435 \u043D\u0430\u0441\u043B\u0435\u0434\u0443\u0435\u0442\u0441\u044F (TASWM-289), \u0430 \u0444\u0430\u0439\u043B\u0430 ${
|
|
13752
|
+
`[launcher] TASKLESS_TOKEN \u0437\u0430\u0434\u0430\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 env \u0434\u0435\u043C\u043E\u043D\u0430 \u2014 \u0434\u0440\u043E\u043D\u0443 \u043E\u043D \u043D\u0435 \u043D\u0430\u0441\u043B\u0435\u0434\u0443\u0435\u0442\u0441\u044F (TASWM-289), \u0430 \u0444\u0430\u0439\u043B\u0430 ${join16(cfg.droneIsolation.swarmHome, "token")} \u043D\u0435\u0442. read_task \u0434\u0440\u043E\u043D\u0430 \u0431\u0443\u0434\u0435\u0442 slug-only. \u041F\u043E\u0447\u0438\u043D\u0438: \`swarm login\` (oauth.json) \u0438\u043B\u0438 \u043F\u043E\u043B\u043E\u0436\u0438 \u0442\u043E\u043A\u0435\u043D \u0432 \u044D\u0442\u043E\u0442 \u0444\u0430\u0439\u043B.`
|
|
13558
13753
|
);
|
|
13559
13754
|
}
|
|
13560
13755
|
const executor = cfg.executor ?? executorForRun(run, cfg.swarmModels?.() ?? null);
|
|
@@ -14485,7 +14680,7 @@ async function runDaemonLogs(argv) {
|
|
|
14485
14680
|
console.error(`\u043B\u043E\u0433 \u041F\u0420\u041E\u0413\u041E\u041D\u0410 \u2014 \u044D\u0442\u043E \xABswarm log ${stray}\xBB (\u0431\u0435\u0437 s). \xABswarm logs\xBB \u043F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0435\u0442 \u043B\u043E\u0433 \u0434\u0435\u043C\u043E\u043D\u0430; \u0447\u0438\u0441\u043B\u043E \u0441\u0442\u0440\u043E\u043A \u2014 \xABswarm logs -n 200\xBB.`);
|
|
14486
14681
|
return 1;
|
|
14487
14682
|
}
|
|
14488
|
-
if (!
|
|
14683
|
+
if (!existsSync19(DAEMON_LOG_PATH)) {
|
|
14489
14684
|
console.error(`\u043B\u043E\u0433\u0430 \u0434\u0435\u043C\u043E\u043D\u0430 \u043D\u0435\u0442: ${DAEMON_LOG_PATH}`);
|
|
14490
14685
|
console.error("\u043E\u043D \u043F\u0438\u0448\u0435\u0442\u0441\u044F \u043F\u0440\u0438 \u0444\u043E\u043D\u043E\u0432\u043E\u043C \u0437\u0430\u043F\u0443\u0441\u043A\u0435 (swarm start). \u0414\u0435\u043C\u043E\u043D \u043F\u043E\u0434\u043D\u044F\u0442 \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435 (--foreground) \u2014 \u0432\u044B\u0432\u043E\u0434 \u0438\u0434\u0451\u0442 \u0442\u0443\u0434\u0430.");
|
|
14491
14686
|
return 1;
|
|
@@ -14493,12 +14688,12 @@ async function runDaemonLogs(argv) {
|
|
|
14493
14688
|
const head = tailFile(DAEMON_LOG_PATH, lines);
|
|
14494
14689
|
if (head) console.log(head);
|
|
14495
14690
|
if (!follow) return 0;
|
|
14496
|
-
let pos =
|
|
14691
|
+
let pos = statSync13(DAEMON_LOG_PATH).size;
|
|
14497
14692
|
for (; ; ) {
|
|
14498
14693
|
await sleep2(500);
|
|
14499
14694
|
let size;
|
|
14500
14695
|
try {
|
|
14501
|
-
size =
|
|
14696
|
+
size = statSync13(DAEMON_LOG_PATH).size;
|
|
14502
14697
|
} catch {
|
|
14503
14698
|
continue;
|
|
14504
14699
|
}
|
|
@@ -14767,10 +14962,10 @@ function effectiveWorktreesDir() {
|
|
|
14767
14962
|
legacyDir: WORKTREES_LEGACY_DIR,
|
|
14768
14963
|
targetDir: WORKTREES_DIR,
|
|
14769
14964
|
envOverride: process.env.SWARM_WORKTREES || "",
|
|
14770
|
-
exists: (d) =>
|
|
14965
|
+
exists: (d) => existsSync19(d),
|
|
14771
14966
|
isNonEmptyDir: (d) => {
|
|
14772
14967
|
try {
|
|
14773
|
-
return
|
|
14968
|
+
return readdirSync13(d).length > 0;
|
|
14774
14969
|
} catch {
|
|
14775
14970
|
return false;
|
|
14776
14971
|
}
|
|
@@ -14826,15 +15021,15 @@ async function scoutRepo(repo) {
|
|
|
14826
15021
|
await $6({ reject: false })`git -C ${worktree} reset --hard ${baseRef}`;
|
|
14827
15022
|
}
|
|
14828
15023
|
await setWorktreeIdentity(worktree, name);
|
|
14829
|
-
const abs = (rel) =>
|
|
15024
|
+
const abs = (rel) => join28(worktree, rel);
|
|
14830
15025
|
const code = await runRepoScout({
|
|
14831
15026
|
repoFullName,
|
|
14832
15027
|
repoPath: worktree,
|
|
14833
15028
|
name,
|
|
14834
|
-
readFile: (rel) =>
|
|
15029
|
+
readFile: (rel) => existsSync19(abs(rel)) ? readFileSync21(abs(rel), "utf8") : null,
|
|
14835
15030
|
writeFile: (rel, text) => {
|
|
14836
|
-
|
|
14837
|
-
|
|
15031
|
+
mkdirSync12(dirname5(abs(rel)), { recursive: true });
|
|
15032
|
+
writeFileSync16(abs(rel), text);
|
|
14838
15033
|
},
|
|
14839
15034
|
runScout: (prompt) => new Promise((resolve5) => {
|
|
14840
15035
|
const child = spawn3(bin, [...ISOLATION_FLAGS, "--dangerously-skip-permissions", "-p", prompt], {
|