@integrity-labs/agt-cli 0.28.149 → 0.28.150
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/bin/agt.js +4 -4
- package/dist/{chunk-SVF454L3.js → chunk-HYW5ZAGY.js} +2 -3
- package/dist/{chunk-A4S52T2C.js → chunk-LCKA5XPX.js} +3 -3
- package/dist/{chunk-5AIF4FOP.js → chunk-SKANUWSB.js} +247 -5
- package/dist/chunk-SKANUWSB.js.map +1 -0
- package/dist/{claude-pair-runtime-OU4ROYH4.js → claude-pair-runtime-ZSBUAMO3.js} +2 -2
- package/dist/lib/manager-worker.js +95 -280
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/{persistent-session-IMMJEVRD.js → persistent-session-S2674LBO.js} +3 -3
- package/dist/{responsiveness-probe-Z2GD24QE.js → responsiveness-probe-NHQYDMHJ.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-5AIF4FOP.js.map +0 -1
- /package/dist/{chunk-SVF454L3.js.map → chunk-HYW5ZAGY.js.map} +0 -0
- /package/dist/{chunk-A4S52T2C.js.map → chunk-LCKA5XPX.js.map} +0 -0
- /package/dist/{claude-pair-runtime-OU4ROYH4.js.map → claude-pair-runtime-ZSBUAMO3.js.map} +0 -0
- /package/dist/{persistent-session-IMMJEVRD.js.map → persistent-session-S2674LBO.js.map} +0 -0
- /package/dist/{responsiveness-probe-Z2GD24QE.js.map → responsiveness-probe-NHQYDMHJ.js.map} +0 -0
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
requireHost,
|
|
29
29
|
safeWriteJsonAtomic,
|
|
30
30
|
setConfigHash
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-LCKA5XPX.js";
|
|
32
32
|
import {
|
|
33
33
|
getProjectDir as getProjectDir2,
|
|
34
34
|
getReadyTasks,
|
|
@@ -61,7 +61,6 @@ import {
|
|
|
61
61
|
resolveClaudeBinary,
|
|
62
62
|
restartEgressSidecar,
|
|
63
63
|
rotateSessionForWedge,
|
|
64
|
-
sanitizeMcpJson,
|
|
65
64
|
sendToAgent,
|
|
66
65
|
sessionTranscriptDir,
|
|
67
66
|
startPersistentSession,
|
|
@@ -72,7 +71,7 @@ import {
|
|
|
72
71
|
takeZombieDetection,
|
|
73
72
|
transcriptActivityAgeSeconds,
|
|
74
73
|
writeEgressAllowlist
|
|
75
|
-
} from "../chunk-
|
|
74
|
+
} from "../chunk-HYW5ZAGY.js";
|
|
76
75
|
import {
|
|
77
76
|
FLAGS_SCHEMA_VERSION,
|
|
78
77
|
FLAG_REGISTRY,
|
|
@@ -110,9 +109,8 @@ import {
|
|
|
110
109
|
resolveAvatarEnvUrl,
|
|
111
110
|
resolveChannels,
|
|
112
111
|
resolveDmTarget,
|
|
113
|
-
sumTranscriptUsageInWindow
|
|
114
|
-
|
|
115
|
-
} from "../chunk-5AIF4FOP.js";
|
|
112
|
+
sumTranscriptUsageInWindow
|
|
113
|
+
} from "../chunk-SKANUWSB.js";
|
|
116
114
|
import {
|
|
117
115
|
parsePsRows,
|
|
118
116
|
reapOrphanChannelMcps
|
|
@@ -120,7 +118,7 @@ import {
|
|
|
120
118
|
|
|
121
119
|
// src/lib/manager-worker.ts
|
|
122
120
|
import { createHash as createHash10 } from "crypto";
|
|
123
|
-
import { readFileSync as
|
|
121
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync8, rmSync as rmSync4, readdirSync as readdirSync5, statSync as statSync4, unlinkSync, copyFileSync } from "fs";
|
|
124
122
|
import { execFileSync as syncExecFile } from "child_process";
|
|
125
123
|
import { join as join16, dirname as dirname5 } from "path";
|
|
126
124
|
import { homedir as homedir9 } from "os";
|
|
@@ -4779,10 +4777,6 @@ function deriveScheduledTaskNotify(task) {
|
|
|
4779
4777
|
if (!conversationId) return {};
|
|
4780
4778
|
return { notify_channel: "msteams", notify_to: conversationId };
|
|
4781
4779
|
}
|
|
4782
|
-
function isScheduledViaKanbanEnabled() {
|
|
4783
|
-
const v = process.env["AGT_SCHEDULED_VIA_KANBAN"];
|
|
4784
|
-
return !(v === "0" || v?.toLowerCase() === "false");
|
|
4785
|
-
}
|
|
4786
4780
|
|
|
4787
4781
|
// src/lib/manager/scheduler/runs.ts
|
|
4788
4782
|
import { createHash as createHash7 } from "crypto";
|
|
@@ -5388,7 +5382,6 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
|
|
|
5388
5382
|
|
|
5389
5383
|
// src/lib/manager/scheduler/execution.ts
|
|
5390
5384
|
import { createHash as createHash9 } from "crypto";
|
|
5391
|
-
import { readFileSync as readFileSync13, existsSync as existsSync7 } from "fs";
|
|
5392
5385
|
import { homedir as homedir7 } from "os";
|
|
5393
5386
|
import { join as join14 } from "path";
|
|
5394
5387
|
function claudePidFilePath() {
|
|
@@ -5446,177 +5439,9 @@ async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData
|
|
|
5446
5439
|
}
|
|
5447
5440
|
inFlightClaudeTasks.add(task.taskId);
|
|
5448
5441
|
claudeTaskConcurrency.set(codeName, (claudeTaskConcurrency.get(codeName) ?? 0) + 1);
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
claudeTaskConcurrency.set(codeName, Math.max(0, (claudeTaskConcurrency.get(codeName) ?? 1) - 1));
|
|
5453
|
-
continue;
|
|
5454
|
-
}
|
|
5455
|
-
log(`[claude-scheduler] Firing '${task.name}' for '${codeName}'`);
|
|
5456
|
-
executeAndProcessClaudeTask(codeName, agent.agent_id, task, prompt).finally(() => {
|
|
5457
|
-
inFlightClaudeTasks.delete(task.taskId);
|
|
5458
|
-
claudeTaskConcurrency.set(codeName, Math.max(0, (claudeTaskConcurrency.get(codeName) ?? 1) - 1));
|
|
5459
|
-
});
|
|
5460
|
-
}
|
|
5461
|
-
}
|
|
5462
|
-
async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
|
|
5463
|
-
const projectDir = getProjectDir2(codeName);
|
|
5464
|
-
const mcpConfigPath = join14(projectDir, ".mcp.json");
|
|
5465
|
-
let runId = null;
|
|
5466
|
-
let kanbanItemId = null;
|
|
5467
|
-
let taskResult;
|
|
5468
|
-
sanitizeMcpJson(mcpConfigPath, requireHost());
|
|
5469
|
-
const priorRuns = await fetchPriorScheduledRuns(agentId, task.taskId);
|
|
5470
|
-
prompt = wrapScheduledTaskPrompt(prompt, { priorRuns, timezone: task.timezone, deliveryPolicy: task.deliveryPolicy });
|
|
5471
|
-
try {
|
|
5472
|
-
const claudeMdPath = join14(projectDir, "CLAUDE.md");
|
|
5473
|
-
const serverNames = [];
|
|
5474
|
-
if (existsSync7(mcpConfigPath)) {
|
|
5475
|
-
try {
|
|
5476
|
-
const d = JSON.parse(readFileSync13(mcpConfigPath, "utf-8"));
|
|
5477
|
-
if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
|
|
5478
|
-
} catch {
|
|
5479
|
-
}
|
|
5480
|
-
}
|
|
5481
|
-
const allowedTools = buildAllowedTools(serverNames);
|
|
5482
|
-
const claudeArgs = [
|
|
5483
|
-
"-p",
|
|
5484
|
-
prompt,
|
|
5485
|
-
"--output-format",
|
|
5486
|
-
"text",
|
|
5487
|
-
"--mcp-config",
|
|
5488
|
-
mcpConfigPath,
|
|
5489
|
-
"--strict-mcp-config",
|
|
5490
|
-
"--permission-mode",
|
|
5491
|
-
"auto",
|
|
5492
|
-
"--allowedTools",
|
|
5493
|
-
allowedTools
|
|
5494
|
-
];
|
|
5495
|
-
if (existsSync7(claudeMdPath)) {
|
|
5496
|
-
claudeArgs.push("--system-prompt-file", claudeMdPath);
|
|
5497
|
-
}
|
|
5498
|
-
const childEnv = { ...process.env };
|
|
5499
|
-
const envIntPath = join14(projectDir, ".env.integrations");
|
|
5500
|
-
if (existsSync7(envIntPath)) {
|
|
5501
|
-
try {
|
|
5502
|
-
Object.assign(childEnv, parseEnvIntegrations(readFileSync13(envIntPath, "utf-8")));
|
|
5503
|
-
} catch {
|
|
5504
|
-
}
|
|
5505
|
-
}
|
|
5506
|
-
try {
|
|
5507
|
-
await applyClaudeAuthToEnv(childEnv, "claude-scheduler");
|
|
5508
|
-
} catch (err) {
|
|
5509
|
-
log(`[claude-scheduler] Skipping task '${task.name}' for '${codeName}' \u2014 auth resolve failed: ${err.message}`);
|
|
5510
|
-
return;
|
|
5511
|
-
}
|
|
5512
|
-
const startResult = await startRun({
|
|
5513
|
-
agent_id: agentId,
|
|
5514
|
-
source_type: "scheduled_task",
|
|
5515
|
-
source_ref: task.taskId,
|
|
5516
|
-
metadata: { template_id: task.templateId, name: task.name },
|
|
5517
|
-
materialize_kanban: { title: task.name, priority: 2, ...deriveScheduledTaskNotify(task) }
|
|
5518
|
-
});
|
|
5519
|
-
runId = startResult.run_id;
|
|
5520
|
-
kanbanItemId = startResult.kanban_item_id;
|
|
5521
|
-
if (runId) childEnv["AGT_RUN_ID"] = runId;
|
|
5522
|
-
for (const f of probeMcpEnvSubstitution({
|
|
5523
|
-
mcpConfigPath,
|
|
5524
|
-
envIntegrationsPath: envIntPath,
|
|
5525
|
-
baseEnv: childEnv
|
|
5526
|
-
})) {
|
|
5527
|
-
log(`[claude-scheduler] ${formatMissingVar(f)} agent=${codeName}`);
|
|
5528
|
-
}
|
|
5529
|
-
const claudeKind = task.templateId === "kanban-work" ? "kanban-work" : "scheduled-task";
|
|
5530
|
-
const { stdout, stderr } = await execFilePromiseLong(resolveClaudeBinary(), claudeArgs, {
|
|
5531
|
-
cwd: projectDir,
|
|
5532
|
-
timeout: 3e5,
|
|
5533
|
-
stdin: "ignore",
|
|
5534
|
-
env: childEnv,
|
|
5535
|
-
onSpawn: (pid) => registerClaudeSpawn({
|
|
5536
|
-
pid,
|
|
5537
|
-
started_at: Date.now(),
|
|
5538
|
-
kind: claudeKind,
|
|
5539
|
-
agent_id: agentId,
|
|
5540
|
-
agent_code_name: codeName,
|
|
5541
|
-
kanban_card_id: kanbanItemId ?? void 0
|
|
5542
|
-
}),
|
|
5543
|
-
onExit: (pid) => unregisterClaudeSpawn(pid)
|
|
5544
|
-
});
|
|
5545
|
-
if (stderr) {
|
|
5546
|
-
log(`[claude-scheduler] Task '${task.name}' stderr for '${codeName}': ${stderr.slice(0, 500)}`);
|
|
5547
|
-
}
|
|
5548
|
-
const output = stdout.trim();
|
|
5549
|
-
taskResult = output.slice(0, 4e3) || void 0;
|
|
5550
|
-
log(`[claude-scheduler] Task '${task.name}' completed for '${codeName}' (${output.length} chars): ${output.slice(0, 300)}`);
|
|
5551
|
-
const outcome = await processClaudeTaskResult(codeName, agentId, task.templateId, output, {
|
|
5552
|
-
mode: task.deliveryMode,
|
|
5553
|
-
channel: task.deliveryChannel,
|
|
5554
|
-
to: task.deliveryTo,
|
|
5555
|
-
taskId: task.taskId,
|
|
5556
|
-
// ENG-6803: hand the oneshot result processor the policy so it can enforce
|
|
5557
|
-
// conditional (suppressed-by-default, deliver only on a concrete
|
|
5558
|
-
// `<deliver: reason>` marker) / never. The in-session kanban caller
|
|
5559
|
-
// deliberately omits this — it gates upstream via suppress_delivery.
|
|
5560
|
-
deliveryPolicy: task.deliveryPolicy
|
|
5561
|
-
});
|
|
5562
|
-
if (!outcome.ok) {
|
|
5563
|
-
log(`[claude-scheduler] Task '${task.name}' result post failed for '${codeName}': ${outcome.error}`);
|
|
5564
|
-
if (runId) {
|
|
5565
|
-
try {
|
|
5566
|
-
await finishRun(runId, "failed", {
|
|
5567
|
-
outcomeMessage: outcome.error,
|
|
5568
|
-
completeKanbanItemId: kanbanItemId,
|
|
5569
|
-
result: taskResult
|
|
5570
|
-
});
|
|
5571
|
-
} catch {
|
|
5572
|
-
}
|
|
5573
|
-
}
|
|
5574
|
-
const failedUpdate = markTaskFired(codeName, task.taskId, "error");
|
|
5575
|
-
claudeSchedulerStates.set(codeName, failedUpdate);
|
|
5576
|
-
return;
|
|
5577
|
-
}
|
|
5578
|
-
if (runId) {
|
|
5579
|
-
await finishRun(runId, "completed", {
|
|
5580
|
-
metadata: { output_length: output.length },
|
|
5581
|
-
completeKanbanItemId: kanbanItemId,
|
|
5582
|
-
result: taskResult
|
|
5583
|
-
});
|
|
5584
|
-
}
|
|
5585
|
-
const updated = markTaskFired(codeName, task.taskId, "ok");
|
|
5586
|
-
claudeSchedulerStates.set(codeName, updated);
|
|
5587
|
-
if (task.scheduleKind === "at") {
|
|
5588
|
-
try {
|
|
5589
|
-
await api.post("/host/schedules/disable", { agent_id: agentId, task_id: task.taskId });
|
|
5590
|
-
log(`[claude-scheduler] One-off task '${task.name}' fired and disabled for '${codeName}'`);
|
|
5591
|
-
} catch (err) {
|
|
5592
|
-
log(`[claude-scheduler] Failed to disable one-off task '${task.name}': ${err.message}`);
|
|
5593
|
-
}
|
|
5594
|
-
}
|
|
5595
|
-
} catch (err) {
|
|
5596
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
5597
|
-
log(`[claude-scheduler] Task '${task.name}' failed for '${codeName}': ${errMsg}`);
|
|
5598
|
-
if (err instanceof ChildProcessError) {
|
|
5599
|
-
const errStdout = err.stdout.trim();
|
|
5600
|
-
if (errStdout) {
|
|
5601
|
-
taskResult = errStdout.slice(0, 4e3) || taskResult;
|
|
5602
|
-
log(`[claude-scheduler] Task '${task.name}' stdout for '${codeName}': ${errStdout.slice(0, 1e3)}`);
|
|
5603
|
-
}
|
|
5604
|
-
if (err.stderr.trim()) {
|
|
5605
|
-
log(`[claude-scheduler] Task '${task.name}' stderr for '${codeName}': ${err.stderr.trim().slice(0, 1e3)}`);
|
|
5606
|
-
}
|
|
5607
|
-
}
|
|
5608
|
-
if (runId) {
|
|
5609
|
-
try {
|
|
5610
|
-
await finishRun(runId, "failed", {
|
|
5611
|
-
outcomeMessage: errMsg,
|
|
5612
|
-
completeKanbanItemId: kanbanItemId,
|
|
5613
|
-
result: taskResult
|
|
5614
|
-
});
|
|
5615
|
-
} catch {
|
|
5616
|
-
}
|
|
5617
|
-
}
|
|
5618
|
-
const updated = markTaskFired(codeName, task.taskId, "error");
|
|
5619
|
-
claudeSchedulerStates.set(codeName, updated);
|
|
5442
|
+
await fireScheduledTaskViaKanban(codeName, agent.agent_id, task, prompt);
|
|
5443
|
+
inFlightClaudeTasks.delete(task.taskId);
|
|
5444
|
+
claudeTaskConcurrency.set(codeName, Math.max(0, (claudeTaskConcurrency.get(codeName) ?? 1) - 1));
|
|
5620
5445
|
}
|
|
5621
5446
|
}
|
|
5622
5447
|
|
|
@@ -5759,7 +5584,7 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
5759
5584
|
}
|
|
5760
5585
|
|
|
5761
5586
|
// src/lib/restart-flags.ts
|
|
5762
|
-
import { existsSync as
|
|
5587
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, readdirSync as readdirSync4, readFileSync as readFileSync13, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
5763
5588
|
import { homedir as homedir8 } from "os";
|
|
5764
5589
|
import { join as join15 } from "path";
|
|
5765
5590
|
import { randomUUID } from "crypto";
|
|
@@ -5771,12 +5596,12 @@ function flagPath(codeName) {
|
|
|
5771
5596
|
}
|
|
5772
5597
|
function readRestartFlags() {
|
|
5773
5598
|
const dir = restartFlagsDir();
|
|
5774
|
-
if (!
|
|
5599
|
+
if (!existsSync7(dir)) return [];
|
|
5775
5600
|
const out = [];
|
|
5776
5601
|
for (const entry of readdirSync4(dir)) {
|
|
5777
5602
|
if (!entry.endsWith(".flag")) continue;
|
|
5778
5603
|
try {
|
|
5779
|
-
const raw =
|
|
5604
|
+
const raw = readFileSync13(join15(dir, entry), "utf8");
|
|
5780
5605
|
const parsed = JSON.parse(raw);
|
|
5781
5606
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
5782
5607
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -5794,7 +5619,7 @@ function readRestartFlags() {
|
|
|
5794
5619
|
}
|
|
5795
5620
|
function deleteRestartFlag(codeName) {
|
|
5796
5621
|
const path = flagPath(codeName);
|
|
5797
|
-
if (
|
|
5622
|
+
if (existsSync7(path)) {
|
|
5798
5623
|
rmSync3(path, { force: true });
|
|
5799
5624
|
}
|
|
5800
5625
|
}
|
|
@@ -6869,7 +6694,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
|
|
|
6869
6694
|
var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
6870
6695
|
function projectMcpHash(_codeName, projectDir) {
|
|
6871
6696
|
try {
|
|
6872
|
-
const raw =
|
|
6697
|
+
const raw = readFileSync14(join16(projectDir, ".mcp.json"), "utf-8");
|
|
6873
6698
|
return createHash10("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
|
|
6874
6699
|
} catch {
|
|
6875
6700
|
return null;
|
|
@@ -6877,7 +6702,7 @@ function projectMcpHash(_codeName, projectDir) {
|
|
|
6877
6702
|
}
|
|
6878
6703
|
function projectMcpKeys(_codeName, projectDir) {
|
|
6879
6704
|
try {
|
|
6880
|
-
const raw =
|
|
6705
|
+
const raw = readFileSync14(join16(projectDir, ".mcp.json"), "utf-8");
|
|
6881
6706
|
const parsed = JSON.parse(raw);
|
|
6882
6707
|
const servers = parsed.mcpServers;
|
|
6883
6708
|
if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
|
|
@@ -7035,7 +6860,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
|
|
|
7035
6860
|
function projectChannelSecretHash(projectDir) {
|
|
7036
6861
|
try {
|
|
7037
6862
|
const entries = parseEnvIntegrations(
|
|
7038
|
-
|
|
6863
|
+
readFileSync14(join16(projectDir, ".env.integrations"), "utf-8")
|
|
7039
6864
|
);
|
|
7040
6865
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
7041
6866
|
} catch {
|
|
@@ -7124,7 +6949,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
7124
6949
|
var lastVersionCheckAt = 0;
|
|
7125
6950
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
7126
6951
|
var lastResponsivenessProbeAt = 0;
|
|
7127
|
-
var agtCliVersion = true ? "0.28.
|
|
6952
|
+
var agtCliVersion = true ? "0.28.150" : "dev";
|
|
7128
6953
|
function resolveBrewPath(execFileSync4) {
|
|
7129
6954
|
try {
|
|
7130
6955
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -7137,7 +6962,7 @@ function resolveBrewPath(execFileSync4) {
|
|
|
7137
6962
|
"/usr/local/bin/brew"
|
|
7138
6963
|
];
|
|
7139
6964
|
for (const path of fallbacks) {
|
|
7140
|
-
if (
|
|
6965
|
+
if (existsSync8(path)) return path;
|
|
7141
6966
|
}
|
|
7142
6967
|
return null;
|
|
7143
6968
|
}
|
|
@@ -7147,7 +6972,7 @@ function claudeBinaryInstalled(execFileSync4) {
|
|
|
7147
6972
|
"/opt/homebrew/bin/claude",
|
|
7148
6973
|
"/usr/local/bin/claude"
|
|
7149
6974
|
];
|
|
7150
|
-
if (canonical.some((path) =>
|
|
6975
|
+
if (canonical.some((path) => existsSync8(path))) return true;
|
|
7151
6976
|
try {
|
|
7152
6977
|
execFileSync4("which", ["claude"], { timeout: 5e3 });
|
|
7153
6978
|
return true;
|
|
@@ -7300,8 +7125,8 @@ function claudeManagedSettingsPath() {
|
|
|
7300
7125
|
function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
|
|
7301
7126
|
try {
|
|
7302
7127
|
let settings = {};
|
|
7303
|
-
if (
|
|
7304
|
-
const raw =
|
|
7128
|
+
if (existsSync8(path)) {
|
|
7129
|
+
const raw = readFileSync14(path, "utf-8").trim();
|
|
7305
7130
|
if (raw) {
|
|
7306
7131
|
let parsed;
|
|
7307
7132
|
try {
|
|
@@ -7363,7 +7188,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
7363
7188
|
if (!process.env.PATH?.split(":").includes(brewBinDir)) {
|
|
7364
7189
|
process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
|
|
7365
7190
|
}
|
|
7366
|
-
if (
|
|
7191
|
+
if (existsSync8("/home/linuxbrew/.linuxbrew/bin/claude")) {
|
|
7367
7192
|
log("Claude Code installed successfully");
|
|
7368
7193
|
} else {
|
|
7369
7194
|
log("Claude Code install completed but binary not found at expected path \u2014 check brew logs");
|
|
@@ -7721,7 +7546,7 @@ async function checkClaudeAuth() {
|
|
|
7721
7546
|
}
|
|
7722
7547
|
var evalEmptyMcpConfigPath = null;
|
|
7723
7548
|
function ensureEvalEmptyMcpConfig() {
|
|
7724
|
-
if (evalEmptyMcpConfigPath &&
|
|
7549
|
+
if (evalEmptyMcpConfigPath && existsSync8(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
7725
7550
|
const dir = join16(homedir9(), ".augmented");
|
|
7726
7551
|
try {
|
|
7727
7552
|
mkdirSync6(dir, { recursive: true });
|
|
@@ -7804,7 +7629,7 @@ function resolveConversationEvalBackend() {
|
|
|
7804
7629
|
}
|
|
7805
7630
|
function loadGatewayPorts() {
|
|
7806
7631
|
try {
|
|
7807
|
-
return JSON.parse(
|
|
7632
|
+
return JSON.parse(readFileSync14(GATEWAY_PORTS_FILE, "utf-8"));
|
|
7808
7633
|
} catch {
|
|
7809
7634
|
return {};
|
|
7810
7635
|
}
|
|
@@ -7964,7 +7789,7 @@ async function migrateToProfiles() {
|
|
|
7964
7789
|
const sharedConfigPath = join16(homeDir, ".openclaw", "openclaw.json");
|
|
7965
7790
|
let sharedConfig;
|
|
7966
7791
|
try {
|
|
7967
|
-
sharedConfig = JSON.parse(
|
|
7792
|
+
sharedConfig = JSON.parse(readFileSync14(sharedConfigPath, "utf-8"));
|
|
7968
7793
|
} catch {
|
|
7969
7794
|
return;
|
|
7970
7795
|
}
|
|
@@ -7978,7 +7803,7 @@ async function migrateToProfiles() {
|
|
|
7978
7803
|
if (!codeName) continue;
|
|
7979
7804
|
if (codeName === "main") continue;
|
|
7980
7805
|
const profileDir = join16(homeDir, `.openclaw-${codeName}`);
|
|
7981
|
-
if (
|
|
7806
|
+
if (existsSync8(join16(profileDir, "openclaw.json"))) continue;
|
|
7982
7807
|
log(`Migrating agent '${codeName}' to per-agent profile`);
|
|
7983
7808
|
if (adapter.seedProfileConfig) {
|
|
7984
7809
|
adapter.seedProfileConfig(codeName);
|
|
@@ -7986,9 +7811,9 @@ async function migrateToProfiles() {
|
|
|
7986
7811
|
const sharedAuthDir = join16(homeDir, ".openclaw", "agents", codeName, "agent");
|
|
7987
7812
|
const profileAuthDir = join16(profileDir, "agents", codeName, "agent");
|
|
7988
7813
|
const authFile = join16(sharedAuthDir, "auth-profiles.json");
|
|
7989
|
-
if (
|
|
7814
|
+
if (existsSync8(authFile)) {
|
|
7990
7815
|
mkdirSync6(profileAuthDir, { recursive: true });
|
|
7991
|
-
const authContent =
|
|
7816
|
+
const authContent = readFileSync14(authFile, "utf-8");
|
|
7992
7817
|
writeFileSync6(join16(profileAuthDir, "auth-profiles.json"), authContent);
|
|
7993
7818
|
}
|
|
7994
7819
|
allocatePort(codeName);
|
|
@@ -8005,7 +7830,7 @@ function readGatewayToken(codeName) {
|
|
|
8005
7830
|
}
|
|
8006
7831
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
8007
7832
|
try {
|
|
8008
|
-
const cfg = JSON.parse(
|
|
7833
|
+
const cfg = JSON.parse(readFileSync14(join16(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
|
|
8009
7834
|
return cfg?.gateway?.auth?.token;
|
|
8010
7835
|
} catch {
|
|
8011
7836
|
return void 0;
|
|
@@ -8015,9 +7840,9 @@ var GATEWAY_HUNG_TIMEOUT_MS = 5 * 6e4;
|
|
|
8015
7840
|
function isGatewayHung(codeName) {
|
|
8016
7841
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
8017
7842
|
const jobsPath = join16(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
|
|
8018
|
-
if (!
|
|
7843
|
+
if (!existsSync8(jobsPath)) return false;
|
|
8019
7844
|
try {
|
|
8020
|
-
const data = JSON.parse(
|
|
7845
|
+
const data = JSON.parse(readFileSync14(jobsPath, "utf-8"));
|
|
8021
7846
|
const jobs = data.jobs ?? data;
|
|
8022
7847
|
if (!Array.isArray(jobs)) return false;
|
|
8023
7848
|
const now = Date.now();
|
|
@@ -8057,8 +7882,8 @@ async function ensureGatewayRunning(codeName, adapter) {
|
|
|
8057
7882
|
try {
|
|
8058
7883
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
8059
7884
|
const configPath = join16(homeDir, `.openclaw-${codeName}`, "openclaw.json");
|
|
8060
|
-
if (
|
|
8061
|
-
const cfg = JSON.parse(
|
|
7885
|
+
if (existsSync8(configPath)) {
|
|
7886
|
+
const cfg = JSON.parse(readFileSync14(configPath, "utf-8"));
|
|
8062
7887
|
if (cfg.gateway?.port !== status.port) {
|
|
8063
7888
|
if (!cfg.gateway) cfg.gateway = {};
|
|
8064
7889
|
cfg.gateway.port = status.port;
|
|
@@ -8083,8 +7908,8 @@ async function ensureGatewayRunning(codeName, adapter) {
|
|
|
8083
7908
|
try {
|
|
8084
7909
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
8085
7910
|
const configPath = join16(homeDir, `.openclaw-${codeName}`, "openclaw.json");
|
|
8086
|
-
if (
|
|
8087
|
-
const cfg = JSON.parse(
|
|
7911
|
+
if (existsSync8(configPath)) {
|
|
7912
|
+
const cfg = JSON.parse(readFileSync14(configPath, "utf-8"));
|
|
8088
7913
|
if (!cfg.gateway) cfg.gateway = {};
|
|
8089
7914
|
cfg.gateway.port = port;
|
|
8090
7915
|
writeFileSync6(configPath, JSON.stringify(cfg, null, 2));
|
|
@@ -8257,7 +8082,7 @@ async function pollCycle() {
|
|
|
8257
8082
|
}
|
|
8258
8083
|
try {
|
|
8259
8084
|
const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
|
|
8260
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
8085
|
+
const { collectDiagnostics } = await import("../persistent-session-S2674LBO.js");
|
|
8261
8086
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
8262
8087
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
|
|
8263
8088
|
let tailscaleHostname;
|
|
@@ -8405,7 +8230,7 @@ async function pollCycle() {
|
|
|
8405
8230
|
const {
|
|
8406
8231
|
collectResponsivenessProbes,
|
|
8407
8232
|
getResponsivenessIntervalMs
|
|
8408
|
-
} = await import("../responsiveness-probe-
|
|
8233
|
+
} = await import("../responsiveness-probe-NHQYDMHJ.js");
|
|
8409
8234
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
8410
8235
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
8411
8236
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -8437,7 +8262,7 @@ async function pollCycle() {
|
|
|
8437
8262
|
collectResponsivenessProbes,
|
|
8438
8263
|
livePendingInboundOldestAgeSeconds,
|
|
8439
8264
|
parkPendingInbound
|
|
8440
|
-
} = await import("../responsiveness-probe-
|
|
8265
|
+
} = await import("../responsiveness-probe-NHQYDMHJ.js");
|
|
8441
8266
|
const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
|
|
8442
8267
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
8443
8268
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -8783,7 +8608,7 @@ async function pollCycle() {
|
|
|
8783
8608
|
// the watchdog, never fails the poll cycle.
|
|
8784
8609
|
signalGiveUp: (codeName) => {
|
|
8785
8610
|
const dir = join16(homedir9(), ".augmented", codeName);
|
|
8786
|
-
if (!
|
|
8611
|
+
if (!existsSync8(dir)) return;
|
|
8787
8612
|
atomicWriteFileSync(
|
|
8788
8613
|
join16(dir, "watchdog-give-up.json"),
|
|
8789
8614
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
@@ -8964,7 +8789,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8964
8789
|
const residuals = {
|
|
8965
8790
|
gatewayRunning: gatewayLiveness.running,
|
|
8966
8791
|
portAllocated: Object.prototype.hasOwnProperty.call(ports, agent.code_name),
|
|
8967
|
-
provisionDirExists:
|
|
8792
|
+
provisionDirExists: existsSync8(agentDir)
|
|
8968
8793
|
};
|
|
8969
8794
|
if (!hasRevokedResiduals(residuals)) {
|
|
8970
8795
|
agentStates.push({
|
|
@@ -9183,7 +9008,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9183
9008
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
9184
9009
|
try {
|
|
9185
9010
|
const projectClaudeMd = join16(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
9186
|
-
const existing =
|
|
9011
|
+
const existing = readFileSync14(projectClaudeMd, "utf-8");
|
|
9187
9012
|
existingHash = sha256(stripDynamicSections(existing));
|
|
9188
9013
|
} catch {
|
|
9189
9014
|
existingHash = null;
|
|
@@ -9201,7 +9026,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9201
9026
|
const generatorKeys = Object.keys(generatorServers);
|
|
9202
9027
|
let existingRaw = "";
|
|
9203
9028
|
try {
|
|
9204
|
-
existingRaw =
|
|
9029
|
+
existingRaw = readFileSync14(filePath, "utf-8");
|
|
9205
9030
|
} catch {
|
|
9206
9031
|
}
|
|
9207
9032
|
const existingServers = parseMcp(existingRaw);
|
|
@@ -9223,7 +9048,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9223
9048
|
}
|
|
9224
9049
|
}
|
|
9225
9050
|
if (changedFiles.length > 0) {
|
|
9226
|
-
const isFirst = !
|
|
9051
|
+
const isFirst = !existsSync8(join16(agentDir, "CHARTER.md"));
|
|
9227
9052
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
9228
9053
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
9229
9054
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
@@ -9238,7 +9063,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9238
9063
|
}
|
|
9239
9064
|
try {
|
|
9240
9065
|
const provSkillsDir = join16(agentDir, ".claude", "skills");
|
|
9241
|
-
if (
|
|
9066
|
+
if (existsSync8(provSkillsDir)) {
|
|
9242
9067
|
for (const folder of readdirSync5(provSkillsDir)) {
|
|
9243
9068
|
if (folder.startsWith("knowledge-")) {
|
|
9244
9069
|
try {
|
|
@@ -9274,7 +9099,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9274
9099
|
if (Array.isArray(refreshData.workflows)) {
|
|
9275
9100
|
try {
|
|
9276
9101
|
const provWorkflowsDir = join16(agentDir, ".claude", "workflows");
|
|
9277
|
-
if (
|
|
9102
|
+
if (existsSync8(provWorkflowsDir)) {
|
|
9278
9103
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
9279
9104
|
for (const file of readdirSync5(provWorkflowsDir)) {
|
|
9280
9105
|
if (!file.endsWith(".js")) continue;
|
|
@@ -9337,7 +9162,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9337
9162
|
}
|
|
9338
9163
|
let lastDriftCheckAt = now;
|
|
9339
9164
|
const written = agentState.writtenHashes.get(agent.agent_id);
|
|
9340
|
-
if (written &&
|
|
9165
|
+
if (written && existsSync8(agentDir)) {
|
|
9341
9166
|
const driftedFiles = [];
|
|
9342
9167
|
for (const [file, expectedHash] of written) {
|
|
9343
9168
|
const localHash = hashFile(join16(agentDir, file));
|
|
@@ -9703,7 +9528,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9703
9528
|
const projectMcpPath = join16(projectDir, ".mcp.json");
|
|
9704
9529
|
let mcpConfig = { mcpServers: {} };
|
|
9705
9530
|
try {
|
|
9706
|
-
mcpConfig = JSON.parse(
|
|
9531
|
+
mcpConfig = JSON.parse(readFileSync14(provisionMcpPath, "utf-8"));
|
|
9707
9532
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
9708
9533
|
} catch {
|
|
9709
9534
|
}
|
|
@@ -9713,7 +9538,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9713
9538
|
const tz = directChatTeamSettings?.["timezone"];
|
|
9714
9539
|
return typeof tz === "string" && tz.trim() !== "" ? tz.trim() : void 0;
|
|
9715
9540
|
})();
|
|
9716
|
-
if (
|
|
9541
|
+
if (existsSync8(localDirectChatChannel)) {
|
|
9717
9542
|
const directChatEnv = {
|
|
9718
9543
|
AGT_HOST: requireHost(),
|
|
9719
9544
|
// ENG-5901 Track D: templated — the manager exports the real
|
|
@@ -9748,7 +9573,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9748
9573
|
}
|
|
9749
9574
|
}
|
|
9750
9575
|
const staleChannelsPath = join16(projectDir, ".mcp-channels.json");
|
|
9751
|
-
if (
|
|
9576
|
+
if (existsSync8(staleChannelsPath)) {
|
|
9752
9577
|
try {
|
|
9753
9578
|
rmSync4(staleChannelsPath, { force: true });
|
|
9754
9579
|
} catch {
|
|
@@ -9834,7 +9659,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9834
9659
|
const envIntPath = join16(projectDir, ".env.integrations");
|
|
9835
9660
|
let preWriteEnv;
|
|
9836
9661
|
try {
|
|
9837
|
-
preWriteEnv =
|
|
9662
|
+
preWriteEnv = readFileSync14(envIntPath, "utf-8");
|
|
9838
9663
|
} catch {
|
|
9839
9664
|
preWriteEnv = void 0;
|
|
9840
9665
|
}
|
|
@@ -9847,8 +9672,8 @@ async function processAgent(agent, agentStates) {
|
|
|
9847
9672
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
9848
9673
|
try {
|
|
9849
9674
|
const projectMcpPath = join16(projectDir, ".mcp.json");
|
|
9850
|
-
const postWriteEnv =
|
|
9851
|
-
const mcpContent =
|
|
9675
|
+
const postWriteEnv = readFileSync14(envIntPath, "utf-8");
|
|
9676
|
+
const mcpContent = readFileSync14(projectMcpPath, "utf-8");
|
|
9852
9677
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
9853
9678
|
const mcpJsonForReap = JSON.parse(mcpContent);
|
|
9854
9679
|
const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
|
|
@@ -9932,8 +9757,8 @@ async function processAgent(agent, agentStates) {
|
|
|
9932
9757
|
const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
|
|
9933
9758
|
if (mcpPath) {
|
|
9934
9759
|
try {
|
|
9935
|
-
const { readFileSync:
|
|
9936
|
-
const mcpConfig = JSON.parse(
|
|
9760
|
+
const { readFileSync: readFileSync15 } = await import("fs");
|
|
9761
|
+
const mcpConfig = JSON.parse(readFileSync15(mcpPath, "utf-8"));
|
|
9937
9762
|
if (mcpConfig.mcpServers) {
|
|
9938
9763
|
const managedPrefixes = [
|
|
9939
9764
|
"composio_",
|
|
@@ -10035,7 +9860,7 @@ async function processAgent(agent, agentStates) {
|
|
|
10035
9860
|
if (frameworkAdapter.installPlugin) {
|
|
10036
9861
|
try {
|
|
10037
9862
|
const pluginPath = join16(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
|
|
10038
|
-
if (
|
|
9863
|
+
if (existsSync8(pluginPath)) {
|
|
10039
9864
|
frameworkAdapter.installPlugin(agent.code_name, "augmented", pluginPath, {
|
|
10040
9865
|
agtHost: requireHost(),
|
|
10041
9866
|
agtApiKey: getApiKey() ?? void 0,
|
|
@@ -10114,7 +9939,7 @@ async function processAgent(agent, agentStates) {
|
|
|
10114
9939
|
// install target but cheap to sweep.
|
|
10115
9940
|
join16(agentDir, ".claude", "skills")
|
|
10116
9941
|
];
|
|
10117
|
-
const existingDirs = candidateSkillDirs.filter((d) =>
|
|
9942
|
+
const existingDirs = candidateSkillDirs.filter((d) => existsSync8(d));
|
|
10118
9943
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
10119
9944
|
for (const dir of existingDirs) {
|
|
10120
9945
|
try {
|
|
@@ -10129,7 +9954,7 @@ async function processAgent(agent, agentStates) {
|
|
|
10129
9954
|
const removeSkillFolder = (entry, reason) => {
|
|
10130
9955
|
for (const dir of existingDirs) {
|
|
10131
9956
|
const p = join16(dir, entry);
|
|
10132
|
-
if (
|
|
9957
|
+
if (existsSync8(p)) {
|
|
10133
9958
|
rmSync5(p, { recursive: true, force: true });
|
|
10134
9959
|
}
|
|
10135
9960
|
}
|
|
@@ -10167,7 +9992,7 @@ async function processAgent(agent, agentStates) {
|
|
|
10167
9992
|
for (const id of plan.removes) {
|
|
10168
9993
|
for (const dir of globalSkillDirs) {
|
|
10169
9994
|
const p = join16(dir, id);
|
|
10170
|
-
if (
|
|
9995
|
+
if (existsSync8(p)) rmSync5(p, { recursive: true, force: true });
|
|
10171
9996
|
}
|
|
10172
9997
|
agentState.knownSkillHashes.delete(`global-skill:${agent.agent_id}:${id}`);
|
|
10173
9998
|
log(`Removed unpublished global skill '${id}' for '${agent.code_name}'`);
|
|
@@ -10258,8 +10083,7 @@ async function processAgent(agent, agentStates) {
|
|
|
10258
10083
|
const agentFw = agentFrameworkCache.get(agent.code_name) ?? "openclaw";
|
|
10259
10084
|
const sessionMode = refreshData.agent.session_mode ?? "oneshot";
|
|
10260
10085
|
const wantsHybridInject = isKanbanHybridEnabled();
|
|
10261
|
-
|
|
10262
|
-
if ((wantsHybridInject || wantsScheduledReconcile) && agentFw === "claude-code" && sessionMode === "persistent") {
|
|
10086
|
+
if (agentFw === "claude-code" && sessionMode === "persistent") {
|
|
10263
10087
|
let hybridBoard = hasBoardTemplates ? boardItems : void 0;
|
|
10264
10088
|
if (!hybridBoard) {
|
|
10265
10089
|
try {
|
|
@@ -10343,7 +10167,7 @@ async function processAgent(agent, agentStates) {
|
|
|
10343
10167
|
let mcpJsonParsed = null;
|
|
10344
10168
|
try {
|
|
10345
10169
|
const mcpPath = join16(getProjectDir(agent.code_name), ".mcp.json");
|
|
10346
|
-
mcpJsonParsed = JSON.parse(
|
|
10170
|
+
mcpJsonParsed = JSON.parse(readFileSync14(mcpPath, "utf-8"));
|
|
10347
10171
|
} catch {
|
|
10348
10172
|
}
|
|
10349
10173
|
reapMissingMcpSessions({
|
|
@@ -10563,9 +10387,9 @@ async function processAgent(agent, agentStates) {
|
|
|
10563
10387
|
if (agentFw === "openclaw" && gatewayRunning && gatewayPort) {
|
|
10564
10388
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
10565
10389
|
const jobsPath = join16(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
|
|
10566
|
-
if (
|
|
10390
|
+
if (existsSync8(jobsPath)) {
|
|
10567
10391
|
try {
|
|
10568
|
-
const jobsData = JSON.parse(
|
|
10392
|
+
const jobsData = JSON.parse(readFileSync14(jobsPath, "utf-8"));
|
|
10569
10393
|
const kanbanJob = (jobsData.jobs ?? []).find(
|
|
10570
10394
|
(j) => typeof j.name === "string" && j.name.includes("kanban-work")
|
|
10571
10395
|
);
|
|
@@ -10699,7 +10523,7 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
|
|
|
10699
10523
|
}
|
|
10700
10524
|
}
|
|
10701
10525
|
const trackedFiles = frameworkAdapter.driftTrackedFiles();
|
|
10702
|
-
if (trackedFiles.length > 0 &&
|
|
10526
|
+
if (trackedFiles.length > 0 && existsSync8(agentDir)) {
|
|
10703
10527
|
const hashes = /* @__PURE__ */ new Map();
|
|
10704
10528
|
for (const file of trackedFiles) {
|
|
10705
10529
|
const h = hashFile(join16(agentDir, file));
|
|
@@ -10789,9 +10613,9 @@ function cleanupStaleSessions(codeName) {
|
|
|
10789
10613
|
}
|
|
10790
10614
|
function cleanupCronSessions(sessionsDir, keepCount) {
|
|
10791
10615
|
const indexPath = join16(sessionsDir, "sessions.json");
|
|
10792
|
-
if (!
|
|
10616
|
+
if (!existsSync8(indexPath)) return;
|
|
10793
10617
|
try {
|
|
10794
|
-
const raw =
|
|
10618
|
+
const raw = readFileSync14(indexPath, "utf-8");
|
|
10795
10619
|
const index = JSON.parse(raw);
|
|
10796
10620
|
const cronRunKeys = Object.keys(index).filter((k) => k.includes(":cron:") && k.includes(":run:")).map((k) => ({
|
|
10797
10621
|
key: k,
|
|
@@ -10806,7 +10630,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10806
10630
|
if (entry.sessionId) {
|
|
10807
10631
|
const sessionFile = join16(sessionsDir, `${entry.sessionId}.jsonl`);
|
|
10808
10632
|
try {
|
|
10809
|
-
if (
|
|
10633
|
+
if (existsSync8(sessionFile)) {
|
|
10810
10634
|
unlinkSync(sessionFile);
|
|
10811
10635
|
deletedFiles++;
|
|
10812
10636
|
}
|
|
@@ -10827,7 +10651,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10827
10651
|
if (parentSessionId) {
|
|
10828
10652
|
try {
|
|
10829
10653
|
const f = join16(sessionsDir, `${parentSessionId}.jsonl`);
|
|
10830
|
-
if (
|
|
10654
|
+
if (existsSync8(f)) {
|
|
10831
10655
|
unlinkSync(f);
|
|
10832
10656
|
deletedFiles++;
|
|
10833
10657
|
}
|
|
@@ -10845,9 +10669,9 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10845
10669
|
}
|
|
10846
10670
|
var STALE_RUN_TIMEOUT_MS = 5 * 6e4;
|
|
10847
10671
|
function clearStaleCronRunState(jobsPath) {
|
|
10848
|
-
if (!
|
|
10672
|
+
if (!existsSync8(jobsPath)) return;
|
|
10849
10673
|
try {
|
|
10850
|
-
const raw =
|
|
10674
|
+
const raw = readFileSync14(jobsPath, "utf-8");
|
|
10851
10675
|
const data = JSON.parse(raw);
|
|
10852
10676
|
const jobs = data.jobs ?? data;
|
|
10853
10677
|
if (!Array.isArray(jobs)) return;
|
|
@@ -10878,7 +10702,7 @@ function clearStaleCronRunState(jobsPath) {
|
|
|
10878
10702
|
}
|
|
10879
10703
|
}
|
|
10880
10704
|
function cleanupOldFiles(dir, maxAgeDays, ext) {
|
|
10881
|
-
if (!
|
|
10705
|
+
if (!existsSync8(dir)) return;
|
|
10882
10706
|
const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1e3;
|
|
10883
10707
|
let removed = 0;
|
|
10884
10708
|
try {
|
|
@@ -11205,18 +11029,9 @@ ${truncateForLog(ctx.tail)}` : `; pane_tail_hash=sha256:${createHash10("sha256")
|
|
|
11205
11029
|
}
|
|
11206
11030
|
inFlightClaudeTasks.add(task.taskId);
|
|
11207
11031
|
claudeTaskConcurrency.set(codeName, (claudeTaskConcurrency.get(codeName) ?? 0) + 1);
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
claudeTaskConcurrency.set(codeName, Math.max(0, (claudeTaskConcurrency.get(codeName) ?? 1) - 1));
|
|
11212
|
-
break;
|
|
11213
|
-
}
|
|
11214
|
-
log(`[persistent-session] Firing task '${task.name}' for '${codeName}' via claude -p`);
|
|
11215
|
-
executeAndProcessClaudeTask(codeName, agent.agent_id, task, prompt).catch(() => {
|
|
11216
|
-
}).finally(() => {
|
|
11217
|
-
inFlightClaudeTasks.delete(task.taskId);
|
|
11218
|
-
claudeTaskConcurrency.set(codeName, Math.max(0, (claudeTaskConcurrency.get(codeName) ?? 1) - 1));
|
|
11219
|
-
});
|
|
11032
|
+
await fireScheduledTaskViaKanban(codeName, agent.agent_id, task, prompt);
|
|
11033
|
+
inFlightClaudeTasks.delete(task.taskId);
|
|
11034
|
+
claudeTaskConcurrency.set(codeName, Math.max(0, (claudeTaskConcurrency.get(codeName) ?? 1) - 1));
|
|
11220
11035
|
break;
|
|
11221
11036
|
}
|
|
11222
11037
|
}
|
|
@@ -11432,7 +11247,7 @@ function ensureRealtimeKanbanStarted(agentStates) {
|
|
|
11432
11247
|
log(
|
|
11433
11248
|
`[realtime] Kanban completion forwarded for '${codeName}': item=${event.item_id} status=${event.status} actor=${event.last_actor_id ?? "unknown"}`
|
|
11434
11249
|
);
|
|
11435
|
-
if (event.status === "done" &&
|
|
11250
|
+
if (event.status === "done" && classifyActor(event.last_actor_id, event.agent_id) === "user" && isScheduledCardTracked(event.item_id)) {
|
|
11436
11251
|
void deliverScheduledCardResult(codeName, event.agent_id, event.item_id, "user");
|
|
11437
11252
|
}
|
|
11438
11253
|
},
|
|
@@ -11610,9 +11425,9 @@ ${escapeXml(msg.content)}
|
|
|
11610
11425
|
const projDir = ccProjectDir(agent.codeName);
|
|
11611
11426
|
const mcpConfigPath = join16(projDir, ".mcp.json");
|
|
11612
11427
|
const serverNames = [];
|
|
11613
|
-
if (
|
|
11428
|
+
if (existsSync8(mcpConfigPath)) {
|
|
11614
11429
|
try {
|
|
11615
|
-
const d = JSON.parse(
|
|
11430
|
+
const d = JSON.parse(readFileSync14(mcpConfigPath, "utf-8"));
|
|
11616
11431
|
if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
|
|
11617
11432
|
} catch {
|
|
11618
11433
|
}
|
|
@@ -11632,14 +11447,14 @@ ${escapeXml(msg.content)}
|
|
|
11632
11447
|
allowedTools
|
|
11633
11448
|
];
|
|
11634
11449
|
const chatClaudeMd = join16(projDir, "CLAUDE.md");
|
|
11635
|
-
if (
|
|
11450
|
+
if (existsSync8(chatClaudeMd)) {
|
|
11636
11451
|
chatArgs.push("--system-prompt-file", chatClaudeMd);
|
|
11637
11452
|
}
|
|
11638
11453
|
const envIntPath = join16(projDir, ".env.integrations");
|
|
11639
11454
|
const childEnv = { ...process.env };
|
|
11640
|
-
if (
|
|
11455
|
+
if (existsSync8(envIntPath)) {
|
|
11641
11456
|
try {
|
|
11642
|
-
Object.assign(childEnv, parseEnvIntegrations(
|
|
11457
|
+
Object.assign(childEnv, parseEnvIntegrations(readFileSync14(envIntPath, "utf-8")));
|
|
11643
11458
|
} catch {
|
|
11644
11459
|
}
|
|
11645
11460
|
}
|
|
@@ -12030,7 +11845,7 @@ async function processClaudePairSessions(agents) {
|
|
|
12030
11845
|
killPairSession,
|
|
12031
11846
|
pairTmuxSession,
|
|
12032
11847
|
finalizeClaudePairOnboarding
|
|
12033
|
-
} = await import("../claude-pair-runtime-
|
|
11848
|
+
} = await import("../claude-pair-runtime-ZSBUAMO3.js");
|
|
12034
11849
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
12035
11850
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
12036
11851
|
const killed = await killPairSession(pairTmuxSession(pairId));
|
|
@@ -12286,14 +12101,14 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
12286
12101
|
}
|
|
12287
12102
|
pendingFreshMemorySync.delete(agent.agent_id);
|
|
12288
12103
|
}
|
|
12289
|
-
if (
|
|
12104
|
+
if (existsSync8(memoryDir)) {
|
|
12290
12105
|
const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
|
|
12291
12106
|
const currentHashes = /* @__PURE__ */ new Map();
|
|
12292
12107
|
const changedMemories = [];
|
|
12293
12108
|
for (const file of readdirSync5(memoryDir)) {
|
|
12294
12109
|
if (!file.endsWith(".md")) continue;
|
|
12295
12110
|
try {
|
|
12296
|
-
const raw =
|
|
12111
|
+
const raw = readFileSync14(join16(memoryDir, file), "utf-8");
|
|
12297
12112
|
const fileHash = createHash10("sha256").update(raw).digest("hex").slice(0, 16);
|
|
12298
12113
|
currentHashes.set(file, fileHash);
|
|
12299
12114
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -12318,7 +12133,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
12318
12133
|
} catch (err) {
|
|
12319
12134
|
for (const mem of changedMemories) {
|
|
12320
12135
|
for (const [file] of currentHashes) {
|
|
12321
|
-
const parsed = parseMemoryFile(
|
|
12136
|
+
const parsed = parseMemoryFile(readFileSync14(join16(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
12322
12137
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
12323
12138
|
}
|
|
12324
12139
|
}
|
|
@@ -12331,7 +12146,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
12331
12146
|
}
|
|
12332
12147
|
}
|
|
12333
12148
|
async function downloadMemories(agent, memoryDir, log2, { force }) {
|
|
12334
|
-
const localFiles =
|
|
12149
|
+
const localFiles = existsSync8(memoryDir) ? readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
|
|
12335
12150
|
const localListHash = createHash10("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
|
|
12336
12151
|
const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
|
|
12337
12152
|
const prevDownload = lastDownloadHash.get(agent.agent_id);
|
|
@@ -12362,10 +12177,10 @@ description: ${JSON.stringify(mem.content.slice(0, 200))}
|
|
|
12362
12177
|
|
|
12363
12178
|
${mem.content}
|
|
12364
12179
|
`;
|
|
12365
|
-
if (
|
|
12180
|
+
if (existsSync8(filePath)) {
|
|
12366
12181
|
let existing = "";
|
|
12367
12182
|
try {
|
|
12368
|
-
existing =
|
|
12183
|
+
existing = readFileSync14(filePath, "utf-8");
|
|
12369
12184
|
} catch {
|
|
12370
12185
|
}
|
|
12371
12186
|
if (existing === desired) continue;
|
|
@@ -12389,7 +12204,7 @@ ${mem.content}
|
|
|
12389
12204
|
}
|
|
12390
12205
|
}
|
|
12391
12206
|
async function cleanupAgentFiles(codeName, agentDir) {
|
|
12392
|
-
if (
|
|
12207
|
+
if (existsSync8(agentDir)) {
|
|
12393
12208
|
try {
|
|
12394
12209
|
rmSync4(agentDir, { recursive: true, force: true });
|
|
12395
12210
|
log(`Removed provision directory for '${codeName}'`);
|
|
@@ -12639,8 +12454,8 @@ function startManager(opts) {
|
|
|
12639
12454
|
config = opts;
|
|
12640
12455
|
try {
|
|
12641
12456
|
const stateFile = getStateFile();
|
|
12642
|
-
if (
|
|
12643
|
-
const raw =
|
|
12457
|
+
if (existsSync8(stateFile)) {
|
|
12458
|
+
const raw = readFileSync14(stateFile, "utf-8");
|
|
12644
12459
|
const parsed = JSON.parse(raw);
|
|
12645
12460
|
if (Array.isArray(parsed.agents)) {
|
|
12646
12461
|
state6.agents = parsed.agents;
|
|
@@ -12688,7 +12503,7 @@ async function reapOrphanedClaudePids() {
|
|
|
12688
12503
|
const looksLikeClaude = (pid) => {
|
|
12689
12504
|
if (process.platform !== "linux") return true;
|
|
12690
12505
|
try {
|
|
12691
|
-
const comm =
|
|
12506
|
+
const comm = readFileSync14(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
|
|
12692
12507
|
return comm.includes("claude");
|
|
12693
12508
|
} catch {
|
|
12694
12509
|
return false;
|
|
@@ -12805,7 +12620,7 @@ function deployMcpAssets() {
|
|
|
12805
12620
|
let dir = moduleDir;
|
|
12806
12621
|
for (let i = 0; i < 6; i++) {
|
|
12807
12622
|
const candidate = join16(dir, "dist", "mcp");
|
|
12808
|
-
if (
|
|
12623
|
+
if (existsSync8(join16(candidate, "index.js"))) {
|
|
12809
12624
|
mcpSourceDir = candidate;
|
|
12810
12625
|
break;
|
|
12811
12626
|
}
|
|
@@ -12820,8 +12635,8 @@ function deployMcpAssets() {
|
|
|
12820
12635
|
const changedBasenames = [];
|
|
12821
12636
|
const fileHash = (p) => {
|
|
12822
12637
|
try {
|
|
12823
|
-
if (!
|
|
12824
|
-
return createHash10("sha256").update(
|
|
12638
|
+
if (!existsSync8(p)) return null;
|
|
12639
|
+
return createHash10("sha256").update(readFileSync14(p)).digest("hex");
|
|
12825
12640
|
} catch {
|
|
12826
12641
|
return null;
|
|
12827
12642
|
}
|
|
@@ -12858,7 +12673,7 @@ function deployMcpAssets() {
|
|
|
12858
12673
|
]) {
|
|
12859
12674
|
const src = join16(mcpSourceDir, file);
|
|
12860
12675
|
const dst = join16(targetDir, file);
|
|
12861
|
-
if (!
|
|
12676
|
+
if (!existsSync8(src)) continue;
|
|
12862
12677
|
const before = fileHash(dst);
|
|
12863
12678
|
try {
|
|
12864
12679
|
copyFileSync(src, dst);
|
|
@@ -12878,13 +12693,13 @@ function deployMcpAssets() {
|
|
|
12878
12693
|
const localMcpPath = join16(targetDir, "index.js");
|
|
12879
12694
|
try {
|
|
12880
12695
|
const agentsDir = join16(homedir9(), ".augmented", "agents");
|
|
12881
|
-
if (
|
|
12696
|
+
if (existsSync8(agentsDir)) {
|
|
12882
12697
|
for (const entry of readdirSync5(agentsDir, { withFileTypes: true })) {
|
|
12883
12698
|
if (!entry.isDirectory()) continue;
|
|
12884
12699
|
for (const subdir of ["provision", "project"]) {
|
|
12885
12700
|
const mcpJsonPath = join16(agentsDir, entry.name, subdir, ".mcp.json");
|
|
12886
12701
|
try {
|
|
12887
|
-
const raw =
|
|
12702
|
+
const raw = readFileSync14(mcpJsonPath, "utf-8");
|
|
12888
12703
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|
|
12889
12704
|
const mcpConfig = JSON.parse(raw);
|
|
12890
12705
|
const augServer = mcpConfig.mcpServers?.["augmented"];
|