@integrity-labs/agt-cli 0.28.69 → 0.28.70
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-NAKDDR6O.js → chunk-CVKQDF5V.js} +2 -2
- package/dist/{chunk-F7LALIIP.js → chunk-OM27L4X2.js} +23 -12
- package/dist/{chunk-F7LALIIP.js.map → chunk-OM27L4X2.js.map} +1 -1
- package/dist/{chunk-RTQ42HVY.js → chunk-ZNJJPZMN.js} +3 -3
- package/dist/{claude-pair-runtime-W6D56XZG.js → claude-pair-runtime-GMBGZSGJ.js} +2 -2
- package/dist/lib/manager-worker.js +185 -115
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/{persistent-session-37EAR7QR.js → persistent-session-Y7WG66VC.js} +3 -3
- package/dist/{responsiveness-probe-WI5X7C55.js → responsiveness-probe-UK2AFQRX.js} +3 -3
- package/package.json +1 -1
- /package/dist/{chunk-NAKDDR6O.js.map → chunk-CVKQDF5V.js.map} +0 -0
- /package/dist/{chunk-RTQ42HVY.js.map → chunk-ZNJJPZMN.js.map} +0 -0
- /package/dist/{claude-pair-runtime-W6D56XZG.js.map → claude-pair-runtime-GMBGZSGJ.js.map} +0 -0
- /package/dist/{persistent-session-37EAR7QR.js.map → persistent-session-Y7WG66VC.js.map} +0 -0
- /package/dist/{responsiveness-probe-WI5X7C55.js.map → responsiveness-probe-UK2AFQRX.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
requireHost,
|
|
28
28
|
safeWriteJsonAtomic,
|
|
29
29
|
setConfigHash
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-ZNJJPZMN.js";
|
|
31
31
|
import {
|
|
32
32
|
getProjectDir as getProjectDir2,
|
|
33
33
|
getReadyTasks,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
takeWatchdogGiveUpCount,
|
|
66
66
|
takeZombieDetection,
|
|
67
67
|
transcriptActivityAgeSeconds
|
|
68
|
-
} from "../chunk-
|
|
68
|
+
} from "../chunk-CVKQDF5V.js";
|
|
69
69
|
import {
|
|
70
70
|
FLAGS_SCHEMA_VERSION,
|
|
71
71
|
FLAG_REGISTRY,
|
|
@@ -77,6 +77,7 @@ import {
|
|
|
77
77
|
attributeTranscriptUsageByRun,
|
|
78
78
|
classifyActor,
|
|
79
79
|
classifyOutput,
|
|
80
|
+
coerceOnboardingState,
|
|
80
81
|
extractFrontmatter,
|
|
81
82
|
formatActorId,
|
|
82
83
|
formatMissingVar,
|
|
@@ -96,7 +97,7 @@ import {
|
|
|
96
97
|
resolveDmTarget,
|
|
97
98
|
sumTranscriptUsageInWindow,
|
|
98
99
|
wrapScheduledTaskPrompt
|
|
99
|
-
} from "../chunk-
|
|
100
|
+
} from "../chunk-OM27L4X2.js";
|
|
100
101
|
import {
|
|
101
102
|
parsePsRows,
|
|
102
103
|
reapOrphanChannelMcps
|
|
@@ -104,9 +105,9 @@ import {
|
|
|
104
105
|
|
|
105
106
|
// src/lib/manager-worker.ts
|
|
106
107
|
import { createHash as createHash8 } from "crypto";
|
|
107
|
-
import { readFileSync as
|
|
108
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync9, rmSync as rmSync4, readdirSync as readdirSync5, statSync as statSync4, unlinkSync, copyFileSync } from "fs";
|
|
108
109
|
import { execFileSync as syncExecFile } from "child_process";
|
|
109
|
-
import { join as join16, dirname as
|
|
110
|
+
import { join as join16, dirname as dirname5 } from "path";
|
|
110
111
|
import { homedir as homedir9 } from "os";
|
|
111
112
|
import { fileURLToPath } from "url";
|
|
112
113
|
|
|
@@ -840,8 +841,48 @@ function extractSlackBehaviourSubset(config2) {
|
|
|
840
841
|
};
|
|
841
842
|
}
|
|
842
843
|
|
|
844
|
+
// src/lib/onboarding-drive.ts
|
|
845
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
846
|
+
import { dirname as dirname2 } from "path";
|
|
847
|
+
var ONBOARDING_REINJECT_INTERVAL_MS = 20 * 6e4;
|
|
848
|
+
function decideOnboardingDrive(step, marker, nowMs, reinjectIntervalMs = ONBOARDING_REINJECT_INTERVAL_MS) {
|
|
849
|
+
if (step === "interviewing" || step === "configuring") {
|
|
850
|
+
const sameStep = marker?.step === step;
|
|
851
|
+
const stale = sameStep && nowMs - marker.injectedAtMs >= reinjectIntervalMs;
|
|
852
|
+
if (!sameStep || stale) {
|
|
853
|
+
return { inject: true, clearMarker: false, nextMarker: { step, injectedAtMs: nowMs } };
|
|
854
|
+
}
|
|
855
|
+
return { inject: false, clearMarker: false, nextMarker: marker };
|
|
856
|
+
}
|
|
857
|
+
return { inject: false, clearMarker: marker !== null, nextMarker: null };
|
|
858
|
+
}
|
|
859
|
+
function buildOnboardingDirective(step) {
|
|
860
|
+
const phase = step === "interviewing" ? "Interview your manager over their preferred channel to gather setup context (priorities, tools/SaaS to use, reporting cadence)" : "Configure yourself \u2014 propose your role default scheduled tasks and let your manager pick which to set up (then call onboarding_provision_tasks with their choices), tune the provisioned tasks, connect integrations, and add any role-specific extras";
|
|
861
|
+
return `\u{1F680} Onboarding (${step}): your self-onboarding is active and waiting on you. Call the \`onboarding_get\` tool now to see your current step and full instructions, then proceed. ${phase}. Advance with \`onboarding_advance\` (INTERVIEW_DONE \u2192 configuring, CONFIGURE_DONE \u2192 ready).`;
|
|
862
|
+
}
|
|
863
|
+
function readOnboardingDriveMarker(path) {
|
|
864
|
+
try {
|
|
865
|
+
const raw = JSON.parse(readFileSync2(path, "utf8"));
|
|
866
|
+
if ((raw.step === "interviewing" || raw.step === "configuring") && typeof raw.injectedAtMs === "number" && Number.isFinite(raw.injectedAtMs)) {
|
|
867
|
+
return { step: raw.step, injectedAtMs: raw.injectedAtMs };
|
|
868
|
+
}
|
|
869
|
+
} catch {
|
|
870
|
+
}
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
function writeOnboardingDriveMarker(path, marker) {
|
|
874
|
+
mkdirSync2(dirname2(path), { recursive: true });
|
|
875
|
+
writeFileSync2(path, JSON.stringify(marker) + "\n", "utf8");
|
|
876
|
+
}
|
|
877
|
+
function clearOnboardingDriveMarker(path) {
|
|
878
|
+
try {
|
|
879
|
+
rmSync(path, { force: true });
|
|
880
|
+
} catch {
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
|
|
843
884
|
// src/lib/channel-quarantine.ts
|
|
844
|
-
import { readFileSync as
|
|
885
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
845
886
|
import { join as join2 } from "path";
|
|
846
887
|
var ESSENTIAL_CHANNEL_KEYS = /* @__PURE__ */ new Set(["direct-chat", "augmented"]);
|
|
847
888
|
var OPTIONAL_CHANNEL_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -882,7 +923,7 @@ var ChannelQuarantineStore = class {
|
|
|
882
923
|
load() {
|
|
883
924
|
if (this.cache) return this.cache;
|
|
884
925
|
try {
|
|
885
|
-
const raw =
|
|
926
|
+
const raw = readFileSync3(this.path, "utf-8");
|
|
886
927
|
const parsed = JSON.parse(raw);
|
|
887
928
|
this.cache = isQuarantineFile(parsed) ? parsed : {};
|
|
888
929
|
} catch {
|
|
@@ -1407,8 +1448,8 @@ var DependencyRecoveryLedger = class {
|
|
|
1407
1448
|
};
|
|
1408
1449
|
|
|
1409
1450
|
// src/lib/self-update-coalesce.ts
|
|
1410
|
-
import { readFileSync as
|
|
1411
|
-
import { dirname as
|
|
1451
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
1452
|
+
import { dirname as dirname3 } from "path";
|
|
1412
1453
|
var DEFAULT_SELF_UPDATE_COALESCE_MS = 30 * 60 * 1e3;
|
|
1413
1454
|
function resolveCoalesceWindowMs(env = process.env) {
|
|
1414
1455
|
const raw = env.AGT_SELF_UPDATE_COALESCE_MS;
|
|
@@ -1417,7 +1458,7 @@ function resolveCoalesceWindowMs(env = process.env) {
|
|
|
1417
1458
|
if (!Number.isFinite(parsed) || parsed < 0) return DEFAULT_SELF_UPDATE_COALESCE_MS;
|
|
1418
1459
|
return Math.trunc(parsed);
|
|
1419
1460
|
}
|
|
1420
|
-
function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) =>
|
|
1461
|
+
function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) => readFileSync4(p, "utf-8")) {
|
|
1421
1462
|
let raw;
|
|
1422
1463
|
try {
|
|
1423
1464
|
raw = read(markerPath);
|
|
@@ -1430,8 +1471,8 @@ function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) =>
|
|
|
1430
1471
|
return v;
|
|
1431
1472
|
}
|
|
1432
1473
|
function stampLastSelfUpdateApplied(markerPath, now = Date.now(), write = (p, v) => {
|
|
1433
|
-
|
|
1434
|
-
|
|
1474
|
+
mkdirSync3(dirname3(p), { recursive: true });
|
|
1475
|
+
writeFileSync3(p, v);
|
|
1435
1476
|
}) {
|
|
1436
1477
|
try {
|
|
1437
1478
|
write(markerPath, String(now));
|
|
@@ -1565,11 +1606,11 @@ function decideRestartGate(opts) {
|
|
|
1565
1606
|
}
|
|
1566
1607
|
|
|
1567
1608
|
// src/lib/claude-pid-tracker.ts
|
|
1568
|
-
import { existsSync, readFileSync as
|
|
1609
|
+
import { existsSync, readFileSync as readFileSync5 } from "fs";
|
|
1569
1610
|
function readPidFile(path) {
|
|
1570
1611
|
if (!existsSync(path)) return { version: 1, spawns: [] };
|
|
1571
1612
|
try {
|
|
1572
|
-
const raw = JSON.parse(
|
|
1613
|
+
const raw = JSON.parse(readFileSync5(path, "utf-8"));
|
|
1573
1614
|
if (raw.version !== 1 || !Array.isArray(raw.spawns)) return { version: 1, spawns: [] };
|
|
1574
1615
|
const spawns = raw.spawns.filter(
|
|
1575
1616
|
(s) => !!s && typeof s.pid === "number" && Number.isFinite(s.pid) && s.pid > 0
|
|
@@ -1930,7 +1971,7 @@ async function maybeReportUsageBanner(args) {
|
|
|
1930
1971
|
}
|
|
1931
1972
|
|
|
1932
1973
|
// src/lib/token-usage-monitor.ts
|
|
1933
|
-
import { readdirSync, readFileSync as
|
|
1974
|
+
import { readdirSync, readFileSync as readFileSync6, statSync } from "fs";
|
|
1934
1975
|
import { join as join5 } from "path";
|
|
1935
1976
|
var MIN_CHECK_INTERVAL_MS2 = 6e4;
|
|
1936
1977
|
var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
@@ -1976,7 +2017,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
1976
2017
|
}
|
|
1977
2018
|
let content;
|
|
1978
2019
|
try {
|
|
1979
|
-
content =
|
|
2020
|
+
content = readFileSync6(path, "utf-8");
|
|
1980
2021
|
} catch (err) {
|
|
1981
2022
|
log2(`[token-usage] read failed for '${codeName}/${name}': ${err.message}`);
|
|
1982
2023
|
continue;
|
|
@@ -2057,7 +2098,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
2057
2098
|
}
|
|
2058
2099
|
|
|
2059
2100
|
// src/lib/workflow-run-reconciler.ts
|
|
2060
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
2101
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync7, statSync as statSync2 } from "fs";
|
|
2061
2102
|
import { join as join6 } from "path";
|
|
2062
2103
|
var MIN_CHECK_INTERVAL_MS3 = 5 * 6e4;
|
|
2063
2104
|
var SETTLE_MS = 3e4;
|
|
@@ -2157,7 +2198,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
2157
2198
|
const contents = [];
|
|
2158
2199
|
for (const path of files) {
|
|
2159
2200
|
try {
|
|
2160
|
-
contents.push(
|
|
2201
|
+
contents.push(readFileSync7(path, "utf-8"));
|
|
2161
2202
|
} catch {
|
|
2162
2203
|
}
|
|
2163
2204
|
}
|
|
@@ -2202,7 +2243,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
2202
2243
|
}
|
|
2203
2244
|
|
|
2204
2245
|
// src/lib/conversation-evaluator.ts
|
|
2205
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
2246
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
2206
2247
|
import { join as join7 } from "path";
|
|
2207
2248
|
var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
|
|
2208
2249
|
var TRANSCRIPT_MTIME_WINDOW_MS3 = 3 * 24 * 60 * 60 * 1e3;
|
|
@@ -2450,7 +2491,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
2450
2491
|
if (nowMs - mtimeMs > TRANSCRIPT_MTIME_WINDOW_MS3) continue;
|
|
2451
2492
|
let content;
|
|
2452
2493
|
try {
|
|
2453
|
-
content =
|
|
2494
|
+
content = readFileSync8(full, "utf8");
|
|
2454
2495
|
} catch {
|
|
2455
2496
|
continue;
|
|
2456
2497
|
}
|
|
@@ -2619,7 +2660,7 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
|
|
|
2619
2660
|
}
|
|
2620
2661
|
|
|
2621
2662
|
// src/lib/activity-cache-monitor.ts
|
|
2622
|
-
import { existsSync as existsSync2, readFileSync as
|
|
2663
|
+
import { existsSync as existsSync2, readFileSync as readFileSync9 } from "fs";
|
|
2623
2664
|
import { homedir as homedir3 } from "os";
|
|
2624
2665
|
import { join as join8 } from "path";
|
|
2625
2666
|
var MIN_CHECK_INTERVAL_MS6 = 6e4;
|
|
@@ -2671,7 +2712,7 @@ async function maybeReportActivityCache(args) {
|
|
|
2671
2712
|
}
|
|
2672
2713
|
let raw;
|
|
2673
2714
|
try {
|
|
2674
|
-
raw =
|
|
2715
|
+
raw = readFileSync9(STATS_CACHE_PATH, "utf-8");
|
|
2675
2716
|
} catch (err) {
|
|
2676
2717
|
log2(`[activity-cache] readFileSync failed: ${err.message}`);
|
|
2677
2718
|
return;
|
|
@@ -3238,7 +3279,7 @@ function normalize(value) {
|
|
|
3238
3279
|
}
|
|
3239
3280
|
|
|
3240
3281
|
// src/lib/channel-hash-cache.ts
|
|
3241
|
-
import { existsSync as existsSync3, readFileSync as
|
|
3282
|
+
import { existsSync as existsSync3, readFileSync as readFileSync10, writeFileSync as writeFileSync4 } from "fs";
|
|
3242
3283
|
import { join as join10 } from "path";
|
|
3243
3284
|
var CACHE_FILENAME = "channel-hash-cache.json";
|
|
3244
3285
|
function getChannelHashCacheFile(configDir) {
|
|
@@ -3249,7 +3290,7 @@ function loadChannelHashCache(target, configDir) {
|
|
|
3249
3290
|
if (!existsSync3(path)) return;
|
|
3250
3291
|
let parsed;
|
|
3251
3292
|
try {
|
|
3252
|
-
parsed = JSON.parse(
|
|
3293
|
+
parsed = JSON.parse(readFileSync10(path, "utf-8"));
|
|
3253
3294
|
} catch {
|
|
3254
3295
|
return;
|
|
3255
3296
|
}
|
|
@@ -3263,7 +3304,7 @@ function saveChannelHashCache(source, configDir) {
|
|
|
3263
3304
|
const obj = {};
|
|
3264
3305
|
for (const [key, value] of source) obj[key] = value;
|
|
3265
3306
|
try {
|
|
3266
|
-
|
|
3307
|
+
writeFileSync4(path, JSON.stringify(obj, null, 2));
|
|
3267
3308
|
} catch {
|
|
3268
3309
|
}
|
|
3269
3310
|
}
|
|
@@ -3650,8 +3691,8 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash) {
|
|
|
3650
3691
|
|
|
3651
3692
|
// src/lib/manager/runtime.ts
|
|
3652
3693
|
import { createHash as createHash4 } from "crypto";
|
|
3653
|
-
import { readFileSync as
|
|
3654
|
-
import { join as join11, dirname as
|
|
3694
|
+
import { readFileSync as readFileSync11, appendFileSync, mkdirSync as mkdirSync4, chmodSync, existsSync as existsSync4 } from "fs";
|
|
3695
|
+
import { join as join11, dirname as dirname4 } from "path";
|
|
3655
3696
|
import { homedir as homedir5 } from "os";
|
|
3656
3697
|
function redactForDiskLog(value) {
|
|
3657
3698
|
try {
|
|
@@ -3673,7 +3714,7 @@ function log(msg) {
|
|
|
3673
3714
|
if (!managerLogPath) {
|
|
3674
3715
|
try {
|
|
3675
3716
|
managerLogPath = join11(homedir5(), ".augmented", "manager.log");
|
|
3676
|
-
|
|
3717
|
+
mkdirSync4(dirname4(managerLogPath), { recursive: true });
|
|
3677
3718
|
if (existsSync4(managerLogPath)) {
|
|
3678
3719
|
chmodSync(managerLogPath, 384);
|
|
3679
3720
|
}
|
|
@@ -3702,7 +3743,7 @@ function sha256(content) {
|
|
|
3702
3743
|
}
|
|
3703
3744
|
function hashFile(filePath) {
|
|
3704
3745
|
try {
|
|
3705
|
-
const content =
|
|
3746
|
+
const content = readFileSync11(filePath, "utf-8");
|
|
3706
3747
|
return sha256(content);
|
|
3707
3748
|
} catch {
|
|
3708
3749
|
return null;
|
|
@@ -3801,7 +3842,7 @@ function resolveModelChain(refreshData) {
|
|
|
3801
3842
|
}
|
|
3802
3843
|
|
|
3803
3844
|
// src/lib/manager/claude-auth.ts
|
|
3804
|
-
import { existsSync as existsSync5, rmSync } from "fs";
|
|
3845
|
+
import { existsSync as existsSync5, rmSync as rmSync2 } from "fs";
|
|
3805
3846
|
import { join as join12 } from "path";
|
|
3806
3847
|
import { homedir as homedir6 } from "os";
|
|
3807
3848
|
async function applyClaudeAuthToEnv(childEnv, label) {
|
|
@@ -3820,7 +3861,7 @@ async function applyClaudeAuthToEnv(childEnv, label) {
|
|
|
3820
3861
|
const p = join12(claudeDir, filename);
|
|
3821
3862
|
if (existsSync5(p)) {
|
|
3822
3863
|
try {
|
|
3823
|
-
|
|
3864
|
+
rmSync2(p, { force: true });
|
|
3824
3865
|
log(`[${label}] Removed ${p} (api_key mode \u2014 preventing OAuth fallback)`);
|
|
3825
3866
|
} catch {
|
|
3826
3867
|
}
|
|
@@ -3832,7 +3873,7 @@ async function applyClaudeAuthToEnv(childEnv, label) {
|
|
|
3832
3873
|
}
|
|
3833
3874
|
|
|
3834
3875
|
// src/lib/manager/kanban/parsers.ts
|
|
3835
|
-
import { existsSync as existsSync6, readFileSync as
|
|
3876
|
+
import { existsSync as existsSync6, readFileSync as readFileSync12 } from "fs";
|
|
3836
3877
|
import { join as join13 } from "path";
|
|
3837
3878
|
var STANDUP_TEMPLATES = /* @__PURE__ */ new Set(["daily-standup", "end-of-day-summary"]);
|
|
3838
3879
|
var TASK_UPDATE_TEMPLATES = /* @__PURE__ */ new Set(["hourly-status", "task-update"]);
|
|
@@ -3958,7 +3999,7 @@ function getBuiltInSkillContent(skillId) {
|
|
|
3958
3999
|
];
|
|
3959
4000
|
for (const candidate of candidates) {
|
|
3960
4001
|
if (existsSync6(candidate)) {
|
|
3961
|
-
const content =
|
|
4002
|
+
const content = readFileSync12(candidate, "utf-8");
|
|
3962
4003
|
const files = [{ relativePath: "SKILL.md", content }];
|
|
3963
4004
|
builtInSkillCache.set(skillId, files);
|
|
3964
4005
|
return files;
|
|
@@ -5028,7 +5069,7 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
|
|
|
5028
5069
|
|
|
5029
5070
|
// src/lib/manager/scheduler/execution.ts
|
|
5030
5071
|
import { createHash as createHash7 } from "crypto";
|
|
5031
|
-
import { readFileSync as
|
|
5072
|
+
import { readFileSync as readFileSync13, existsSync as existsSync7 } from "fs";
|
|
5032
5073
|
import { homedir as homedir7 } from "os";
|
|
5033
5074
|
import { join as join14 } from "path";
|
|
5034
5075
|
function claudePidFilePath() {
|
|
@@ -5113,7 +5154,7 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
|
|
|
5113
5154
|
const serverNames = [];
|
|
5114
5155
|
if (existsSync7(mcpConfigPath)) {
|
|
5115
5156
|
try {
|
|
5116
|
-
const d = JSON.parse(
|
|
5157
|
+
const d = JSON.parse(readFileSync13(mcpConfigPath, "utf-8"));
|
|
5117
5158
|
if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
|
|
5118
5159
|
} catch {
|
|
5119
5160
|
}
|
|
@@ -5139,7 +5180,7 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
|
|
|
5139
5180
|
const envIntPath = join14(projectDir, ".env.integrations");
|
|
5140
5181
|
if (existsSync7(envIntPath)) {
|
|
5141
5182
|
try {
|
|
5142
|
-
Object.assign(childEnv, parseEnvIntegrations(
|
|
5183
|
+
Object.assign(childEnv, parseEnvIntegrations(readFileSync13(envIntPath, "utf-8")));
|
|
5143
5184
|
} catch {
|
|
5144
5185
|
}
|
|
5145
5186
|
}
|
|
@@ -5394,7 +5435,7 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
5394
5435
|
}
|
|
5395
5436
|
|
|
5396
5437
|
// src/lib/restart-flags.ts
|
|
5397
|
-
import { existsSync as existsSync8, mkdirSync as
|
|
5438
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync5, readdirSync as readdirSync4, readFileSync as readFileSync14, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
5398
5439
|
import { homedir as homedir8 } from "os";
|
|
5399
5440
|
import { join as join15 } from "path";
|
|
5400
5441
|
import { randomUUID } from "crypto";
|
|
@@ -5411,7 +5452,7 @@ function readRestartFlags() {
|
|
|
5411
5452
|
for (const entry of readdirSync4(dir)) {
|
|
5412
5453
|
if (!entry.endsWith(".flag")) continue;
|
|
5413
5454
|
try {
|
|
5414
|
-
const raw =
|
|
5455
|
+
const raw = readFileSync14(join15(dir, entry), "utf8");
|
|
5415
5456
|
const parsed = JSON.parse(raw);
|
|
5416
5457
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
5417
5458
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -5430,7 +5471,7 @@ function readRestartFlags() {
|
|
|
5430
5471
|
function deleteRestartFlag(codeName) {
|
|
5431
5472
|
const path = flagPath(codeName);
|
|
5432
5473
|
if (existsSync8(path)) {
|
|
5433
|
-
|
|
5474
|
+
rmSync3(path, { force: true });
|
|
5434
5475
|
}
|
|
5435
5476
|
}
|
|
5436
5477
|
|
|
@@ -6480,7 +6521,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
|
|
|
6480
6521
|
var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
6481
6522
|
function projectMcpHash(_codeName, projectDir) {
|
|
6482
6523
|
try {
|
|
6483
|
-
const raw =
|
|
6524
|
+
const raw = readFileSync15(join16(projectDir, ".mcp.json"), "utf-8");
|
|
6484
6525
|
return createHash8("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
|
|
6485
6526
|
} catch {
|
|
6486
6527
|
return null;
|
|
@@ -6488,7 +6529,7 @@ function projectMcpHash(_codeName, projectDir) {
|
|
|
6488
6529
|
}
|
|
6489
6530
|
function projectMcpKeys(_codeName, projectDir) {
|
|
6490
6531
|
try {
|
|
6491
|
-
const raw =
|
|
6532
|
+
const raw = readFileSync15(join16(projectDir, ".mcp.json"), "utf-8");
|
|
6492
6533
|
const parsed = JSON.parse(raw);
|
|
6493
6534
|
const servers = parsed.mcpServers;
|
|
6494
6535
|
if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
|
|
@@ -6646,7 +6687,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
|
|
|
6646
6687
|
function projectChannelSecretHash(projectDir) {
|
|
6647
6688
|
try {
|
|
6648
6689
|
const entries = parseEnvIntegrations(
|
|
6649
|
-
|
|
6690
|
+
readFileSync15(join16(projectDir, ".env.integrations"), "utf-8")
|
|
6650
6691
|
);
|
|
6651
6692
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
6652
6693
|
} catch {
|
|
@@ -6734,7 +6775,7 @@ var cachedMaintenanceWindow = null;
|
|
|
6734
6775
|
var lastVersionCheckAt = 0;
|
|
6735
6776
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6736
6777
|
var lastResponsivenessProbeAt = 0;
|
|
6737
|
-
var agtCliVersion = true ? "0.28.
|
|
6778
|
+
var agtCliVersion = true ? "0.28.70" : "dev";
|
|
6738
6779
|
function resolveBrewPath(execFileSync4) {
|
|
6739
6780
|
try {
|
|
6740
6781
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -6829,7 +6870,7 @@ async function ensureToolkitCli(toolkitSlug) {
|
|
|
6829
6870
|
toolkitCliEnsured.add(toolkitSlug);
|
|
6830
6871
|
return;
|
|
6831
6872
|
}
|
|
6832
|
-
brewBinDir =
|
|
6873
|
+
brewBinDir = dirname5(brewPath);
|
|
6833
6874
|
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
6834
6875
|
log(`[toolkit-install] ${toolkitSlug}: installing via brew (${pkg})\u2026`);
|
|
6835
6876
|
if (isRoot) {
|
|
@@ -6911,7 +6952,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
|
|
|
6911
6952
|
try {
|
|
6912
6953
|
let settings = {};
|
|
6913
6954
|
if (existsSync9(path)) {
|
|
6914
|
-
const raw =
|
|
6955
|
+
const raw = readFileSync15(path, "utf-8").trim();
|
|
6915
6956
|
if (raw) {
|
|
6916
6957
|
let parsed;
|
|
6917
6958
|
try {
|
|
@@ -6927,8 +6968,8 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
|
|
|
6927
6968
|
}
|
|
6928
6969
|
if (settings.channelsEnabled === true) return "ok";
|
|
6929
6970
|
settings.channelsEnabled = true;
|
|
6930
|
-
|
|
6931
|
-
|
|
6971
|
+
mkdirSync6(dirname5(path), { recursive: true });
|
|
6972
|
+
writeFileSync6(path, `${JSON.stringify(settings, null, 2)}
|
|
6932
6973
|
`);
|
|
6933
6974
|
log(`[managed-settings] set channelsEnabled:true in ${path} (ENG-5786 \u2014 unblocks Claude Code channels)`);
|
|
6934
6975
|
return "ok";
|
|
@@ -6969,7 +7010,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
6969
7010
|
log(`Claude Code install failed: ${err.message}`);
|
|
6970
7011
|
return;
|
|
6971
7012
|
}
|
|
6972
|
-
const brewBinDir =
|
|
7013
|
+
const brewBinDir = dirname5(brewPath);
|
|
6973
7014
|
if (!process.env.PATH?.split(":").includes(brewBinDir)) {
|
|
6974
7015
|
process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
|
|
6975
7016
|
}
|
|
@@ -7312,11 +7353,11 @@ function ensureEvalEmptyMcpConfig() {
|
|
|
7312
7353
|
if (evalEmptyMcpConfigPath && existsSync9(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
7313
7354
|
const dir = join16(homedir9(), ".augmented");
|
|
7314
7355
|
try {
|
|
7315
|
-
|
|
7356
|
+
mkdirSync6(dir, { recursive: true });
|
|
7316
7357
|
} catch {
|
|
7317
7358
|
}
|
|
7318
7359
|
const p = join16(dir, ".eval-empty-mcp.json");
|
|
7319
|
-
|
|
7360
|
+
writeFileSync6(p, JSON.stringify({ mcpServers: {} }));
|
|
7320
7361
|
evalEmptyMcpConfigPath = p;
|
|
7321
7362
|
return p;
|
|
7322
7363
|
}
|
|
@@ -7389,14 +7430,14 @@ function resolveConversationEvalBackend() {
|
|
|
7389
7430
|
}
|
|
7390
7431
|
function loadGatewayPorts() {
|
|
7391
7432
|
try {
|
|
7392
|
-
return JSON.parse(
|
|
7433
|
+
return JSON.parse(readFileSync15(GATEWAY_PORTS_FILE, "utf-8"));
|
|
7393
7434
|
} catch {
|
|
7394
7435
|
return {};
|
|
7395
7436
|
}
|
|
7396
7437
|
}
|
|
7397
7438
|
function saveGatewayPorts(ports) {
|
|
7398
|
-
|
|
7399
|
-
|
|
7439
|
+
mkdirSync6(AUGMENTED_DIR, { recursive: true });
|
|
7440
|
+
writeFileSync6(GATEWAY_PORTS_FILE, JSON.stringify(ports, null, 2));
|
|
7400
7441
|
}
|
|
7401
7442
|
function allocatePort(codeName) {
|
|
7402
7443
|
const ports = loadGatewayPorts();
|
|
@@ -7492,7 +7533,7 @@ function parseSkillFrontmatter(content) {
|
|
|
7492
7533
|
return out;
|
|
7493
7534
|
}
|
|
7494
7535
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
7495
|
-
const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync:
|
|
7536
|
+
const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync7 } = await import("fs");
|
|
7496
7537
|
const skillsDir = join16(configDir, codeName, "project", ".claude", "skills");
|
|
7497
7538
|
const claudeMdPath = join16(configDir, codeName, "project", "CLAUDE.md");
|
|
7498
7539
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
@@ -7540,7 +7581,7 @@ ${SKILLS_INDEX_END}`;
|
|
|
7540
7581
|
next = current.trimEnd() + "\n\n" + section + "\n";
|
|
7541
7582
|
}
|
|
7542
7583
|
if (next !== current) {
|
|
7543
|
-
|
|
7584
|
+
writeFileSync7(claudeMdPath, next, "utf-8");
|
|
7544
7585
|
log2(`Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)`);
|
|
7545
7586
|
}
|
|
7546
7587
|
}
|
|
@@ -7549,7 +7590,7 @@ async function migrateToProfiles() {
|
|
|
7549
7590
|
const sharedConfigPath = join16(homeDir, ".openclaw", "openclaw.json");
|
|
7550
7591
|
let sharedConfig;
|
|
7551
7592
|
try {
|
|
7552
|
-
sharedConfig = JSON.parse(
|
|
7593
|
+
sharedConfig = JSON.parse(readFileSync15(sharedConfigPath, "utf-8"));
|
|
7553
7594
|
} catch {
|
|
7554
7595
|
return;
|
|
7555
7596
|
}
|
|
@@ -7572,9 +7613,9 @@ async function migrateToProfiles() {
|
|
|
7572
7613
|
const profileAuthDir = join16(profileDir, "agents", codeName, "agent");
|
|
7573
7614
|
const authFile = join16(sharedAuthDir, "auth-profiles.json");
|
|
7574
7615
|
if (existsSync9(authFile)) {
|
|
7575
|
-
|
|
7576
|
-
const authContent =
|
|
7577
|
-
|
|
7616
|
+
mkdirSync6(profileAuthDir, { recursive: true });
|
|
7617
|
+
const authContent = readFileSync15(authFile, "utf-8");
|
|
7618
|
+
writeFileSync6(join16(profileAuthDir, "auth-profiles.json"), authContent);
|
|
7578
7619
|
}
|
|
7579
7620
|
allocatePort(codeName);
|
|
7580
7621
|
migrated++;
|
|
@@ -7590,7 +7631,7 @@ function readGatewayToken(codeName) {
|
|
|
7590
7631
|
}
|
|
7591
7632
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7592
7633
|
try {
|
|
7593
|
-
const cfg = JSON.parse(
|
|
7634
|
+
const cfg = JSON.parse(readFileSync15(join16(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
|
|
7594
7635
|
return cfg?.gateway?.auth?.token;
|
|
7595
7636
|
} catch {
|
|
7596
7637
|
return void 0;
|
|
@@ -7602,7 +7643,7 @@ function isGatewayHung(codeName) {
|
|
|
7602
7643
|
const jobsPath = join16(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
|
|
7603
7644
|
if (!existsSync9(jobsPath)) return false;
|
|
7604
7645
|
try {
|
|
7605
|
-
const data = JSON.parse(
|
|
7646
|
+
const data = JSON.parse(readFileSync15(jobsPath, "utf-8"));
|
|
7606
7647
|
const jobs = data.jobs ?? data;
|
|
7607
7648
|
if (!Array.isArray(jobs)) return false;
|
|
7608
7649
|
const now = Date.now();
|
|
@@ -7643,11 +7684,11 @@ async function ensureGatewayRunning(codeName, adapter) {
|
|
|
7643
7684
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7644
7685
|
const configPath = join16(homeDir, `.openclaw-${codeName}`, "openclaw.json");
|
|
7645
7686
|
if (existsSync9(configPath)) {
|
|
7646
|
-
const cfg = JSON.parse(
|
|
7687
|
+
const cfg = JSON.parse(readFileSync15(configPath, "utf-8"));
|
|
7647
7688
|
if (cfg.gateway?.port !== status.port) {
|
|
7648
7689
|
if (!cfg.gateway) cfg.gateway = {};
|
|
7649
7690
|
cfg.gateway.port = status.port;
|
|
7650
|
-
|
|
7691
|
+
writeFileSync6(configPath, JSON.stringify(cfg, null, 2));
|
|
7651
7692
|
}
|
|
7652
7693
|
}
|
|
7653
7694
|
} catch {
|
|
@@ -7669,10 +7710,10 @@ async function ensureGatewayRunning(codeName, adapter) {
|
|
|
7669
7710
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7670
7711
|
const configPath = join16(homeDir, `.openclaw-${codeName}`, "openclaw.json");
|
|
7671
7712
|
if (existsSync9(configPath)) {
|
|
7672
|
-
const cfg = JSON.parse(
|
|
7713
|
+
const cfg = JSON.parse(readFileSync15(configPath, "utf-8"));
|
|
7673
7714
|
if (!cfg.gateway) cfg.gateway = {};
|
|
7674
7715
|
cfg.gateway.port = port;
|
|
7675
|
-
|
|
7716
|
+
writeFileSync6(configPath, JSON.stringify(cfg, null, 2));
|
|
7676
7717
|
}
|
|
7677
7718
|
} catch {
|
|
7678
7719
|
}
|
|
@@ -7842,7 +7883,7 @@ async function pollCycle() {
|
|
|
7842
7883
|
}
|
|
7843
7884
|
try {
|
|
7844
7885
|
const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
|
|
7845
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
7886
|
+
const { collectDiagnostics } = await import("../persistent-session-Y7WG66VC.js");
|
|
7846
7887
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
7847
7888
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
|
|
7848
7889
|
let tailscaleHostname;
|
|
@@ -7943,7 +7984,7 @@ async function pollCycle() {
|
|
|
7943
7984
|
const {
|
|
7944
7985
|
collectResponsivenessProbes,
|
|
7945
7986
|
getResponsivenessIntervalMs
|
|
7946
|
-
} = await import("../responsiveness-probe-
|
|
7987
|
+
} = await import("../responsiveness-probe-UK2AFQRX.js");
|
|
7947
7988
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
7948
7989
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
7949
7990
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -7975,7 +8016,7 @@ async function pollCycle() {
|
|
|
7975
8016
|
collectResponsivenessProbes,
|
|
7976
8017
|
livePendingInboundOldestAgeSeconds,
|
|
7977
8018
|
parkPendingInbound
|
|
7978
|
-
} = await import("../responsiveness-probe-
|
|
8019
|
+
} = await import("../responsiveness-probe-UK2AFQRX.js");
|
|
7979
8020
|
const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
|
|
7980
8021
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
7981
8022
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -8693,7 +8734,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8693
8734
|
try {
|
|
8694
8735
|
const artifacts = generateArtifacts(agent, refreshData, frameworkAdapter);
|
|
8695
8736
|
const changedFiles = [];
|
|
8696
|
-
|
|
8737
|
+
mkdirSync6(agentDir, { recursive: true });
|
|
8697
8738
|
for (const artifact of artifacts) {
|
|
8698
8739
|
const filePath = join16(agentDir, artifact.relativePath);
|
|
8699
8740
|
let existingHash;
|
|
@@ -8715,7 +8756,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8715
8756
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
8716
8757
|
try {
|
|
8717
8758
|
const projectClaudeMd = join16(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
8718
|
-
const existing =
|
|
8759
|
+
const existing = readFileSync15(projectClaudeMd, "utf-8");
|
|
8719
8760
|
existingHash = sha256(stripDynamicSections(existing));
|
|
8720
8761
|
} catch {
|
|
8721
8762
|
existingHash = null;
|
|
@@ -8733,7 +8774,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8733
8774
|
const generatorKeys = Object.keys(generatorServers);
|
|
8734
8775
|
let existingRaw = "";
|
|
8735
8776
|
try {
|
|
8736
|
-
existingRaw =
|
|
8777
|
+
existingRaw = readFileSync15(filePath, "utf-8");
|
|
8737
8778
|
} catch {
|
|
8738
8779
|
}
|
|
8739
8780
|
const existingServers = parseMcp(existingRaw);
|
|
@@ -8761,11 +8802,11 @@ async function processAgent(agent, agentStates) {
|
|
|
8761
8802
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
8762
8803
|
for (const file of changedFiles) {
|
|
8763
8804
|
const filePath = join16(agentDir, file.relativePath);
|
|
8764
|
-
|
|
8805
|
+
mkdirSync6(dirname5(filePath), { recursive: true });
|
|
8765
8806
|
if (file.relativePath === ".mcp.json") {
|
|
8766
8807
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
8767
8808
|
} else {
|
|
8768
|
-
|
|
8809
|
+
writeFileSync6(filePath, file.content);
|
|
8769
8810
|
}
|
|
8770
8811
|
}
|
|
8771
8812
|
try {
|
|
@@ -8774,7 +8815,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8774
8815
|
for (const folder of readdirSync5(provSkillsDir)) {
|
|
8775
8816
|
if (folder.startsWith("knowledge-")) {
|
|
8776
8817
|
try {
|
|
8777
|
-
|
|
8818
|
+
rmSync4(join16(provSkillsDir, folder), { recursive: true });
|
|
8778
8819
|
} catch {
|
|
8779
8820
|
}
|
|
8780
8821
|
}
|
|
@@ -8812,7 +8853,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8812
8853
|
if (!file.endsWith(".js")) continue;
|
|
8813
8854
|
if (expected.has(file)) continue;
|
|
8814
8855
|
try {
|
|
8815
|
-
|
|
8856
|
+
rmSync4(join16(provWorkflowsDir, file));
|
|
8816
8857
|
} catch {
|
|
8817
8858
|
}
|
|
8818
8859
|
}
|
|
@@ -9071,7 +9112,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9071
9112
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
9072
9113
|
try {
|
|
9073
9114
|
const agentAugmentedDir = join16(homedir9(), ".augmented", agent.code_name);
|
|
9074
|
-
|
|
9115
|
+
mkdirSync6(agentAugmentedDir, { recursive: true });
|
|
9075
9116
|
const markerJson = JSON.stringify({
|
|
9076
9117
|
version: 1,
|
|
9077
9118
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -9232,13 +9273,13 @@ async function processAgent(agent, agentStates) {
|
|
|
9232
9273
|
try {
|
|
9233
9274
|
const agentProvisionDir = agentDir;
|
|
9234
9275
|
const projectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
|
|
9235
|
-
|
|
9236
|
-
|
|
9276
|
+
mkdirSync6(agentProvisionDir, { recursive: true });
|
|
9277
|
+
mkdirSync6(projectDir, { recursive: true });
|
|
9237
9278
|
const provisionMcpPath = join16(agentProvisionDir, ".mcp.json");
|
|
9238
9279
|
const projectMcpPath = join16(projectDir, ".mcp.json");
|
|
9239
9280
|
let mcpConfig = { mcpServers: {} };
|
|
9240
9281
|
try {
|
|
9241
|
-
mcpConfig = JSON.parse(
|
|
9282
|
+
mcpConfig = JSON.parse(readFileSync15(provisionMcpPath, "utf-8"));
|
|
9242
9283
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
9243
9284
|
} catch {
|
|
9244
9285
|
}
|
|
@@ -9275,7 +9316,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9275
9316
|
const staleChannelsPath = join16(projectDir, ".mcp-channels.json");
|
|
9276
9317
|
if (existsSync9(staleChannelsPath)) {
|
|
9277
9318
|
try {
|
|
9278
|
-
|
|
9319
|
+
rmSync4(staleChannelsPath, { force: true });
|
|
9279
9320
|
} catch {
|
|
9280
9321
|
}
|
|
9281
9322
|
}
|
|
@@ -9359,7 +9400,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9359
9400
|
const envIntPath = join16(projectDir, ".env.integrations");
|
|
9360
9401
|
let preWriteEnv;
|
|
9361
9402
|
try {
|
|
9362
|
-
preWriteEnv =
|
|
9403
|
+
preWriteEnv = readFileSync15(envIntPath, "utf-8");
|
|
9363
9404
|
} catch {
|
|
9364
9405
|
preWriteEnv = void 0;
|
|
9365
9406
|
}
|
|
@@ -9372,8 +9413,8 @@ async function processAgent(agent, agentStates) {
|
|
|
9372
9413
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
9373
9414
|
try {
|
|
9374
9415
|
const projectMcpPath = join16(projectDir, ".mcp.json");
|
|
9375
|
-
const postWriteEnv =
|
|
9376
|
-
const mcpContent =
|
|
9416
|
+
const postWriteEnv = readFileSync15(envIntPath, "utf-8");
|
|
9417
|
+
const mcpContent = readFileSync15(projectMcpPath, "utf-8");
|
|
9377
9418
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
9378
9419
|
const mcpJsonForReap = JSON.parse(mcpContent);
|
|
9379
9420
|
const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
|
|
@@ -9453,8 +9494,8 @@ async function processAgent(agent, agentStates) {
|
|
|
9453
9494
|
const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
|
|
9454
9495
|
if (mcpPath) {
|
|
9455
9496
|
try {
|
|
9456
|
-
const { readFileSync:
|
|
9457
|
-
const mcpConfig = JSON.parse(
|
|
9497
|
+
const { readFileSync: readFileSync16 } = await import("fs");
|
|
9498
|
+
const mcpConfig = JSON.parse(readFileSync16(mcpPath, "utf-8"));
|
|
9458
9499
|
if (mcpConfig.mcpServers) {
|
|
9459
9500
|
const managedPrefixes = [
|
|
9460
9501
|
"composio_",
|
|
@@ -9621,7 +9662,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9621
9662
|
}
|
|
9622
9663
|
}
|
|
9623
9664
|
try {
|
|
9624
|
-
const { readdirSync: readdirSync6, rmSync:
|
|
9665
|
+
const { readdirSync: readdirSync6, rmSync: rmSync5 } = await import("fs");
|
|
9625
9666
|
const { homedir: homedir10 } = await import("os");
|
|
9626
9667
|
const frameworkId2 = frameworkAdapter.id;
|
|
9627
9668
|
const candidateSkillDirs = [
|
|
@@ -9651,7 +9692,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9651
9692
|
for (const dir of existingDirs) {
|
|
9652
9693
|
const p = join16(dir, entry);
|
|
9653
9694
|
if (existsSync9(p)) {
|
|
9654
|
-
|
|
9695
|
+
rmSync5(p, { recursive: true, force: true });
|
|
9655
9696
|
}
|
|
9656
9697
|
}
|
|
9657
9698
|
log(`Removed ${reason} '${entry}' for '${agent.code_name}' (framework=${frameworkId2})`);
|
|
@@ -9677,7 +9718,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9677
9718
|
log(`Installed global skill '${skillId}' for '${agent.code_name}'`);
|
|
9678
9719
|
}
|
|
9679
9720
|
if (plan.removes.length) {
|
|
9680
|
-
const { rmSync:
|
|
9721
|
+
const { rmSync: rmSync5 } = await import("fs");
|
|
9681
9722
|
const { homedir: homedir10 } = await import("os");
|
|
9682
9723
|
const globalSkillDirs = [
|
|
9683
9724
|
join16(homedir10(), ".augmented", agent.code_name, "skills"),
|
|
@@ -9688,7 +9729,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9688
9729
|
for (const id of plan.removes) {
|
|
9689
9730
|
for (const dir of globalSkillDirs) {
|
|
9690
9731
|
const p = join16(dir, id);
|
|
9691
|
-
if (existsSync9(p))
|
|
9732
|
+
if (existsSync9(p)) rmSync5(p, { recursive: true, force: true });
|
|
9692
9733
|
}
|
|
9693
9734
|
agentState.knownSkillHashes.delete(`global-skill:${agent.agent_id}:${id}`);
|
|
9694
9735
|
log(`Removed unpublished global skill '${id}' for '${agent.code_name}'`);
|
|
@@ -9864,7 +9905,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9864
9905
|
let mcpJsonParsed = null;
|
|
9865
9906
|
try {
|
|
9866
9907
|
const mcpPath = join16(getProjectDir(agent.code_name), ".mcp.json");
|
|
9867
|
-
mcpJsonParsed = JSON.parse(
|
|
9908
|
+
mcpJsonParsed = JSON.parse(readFileSync15(mcpPath, "utf-8"));
|
|
9868
9909
|
} catch {
|
|
9869
9910
|
}
|
|
9870
9911
|
reapMissingMcpSessions({
|
|
@@ -10082,7 +10123,7 @@ async function processAgent(agent, agentStates) {
|
|
|
10082
10123
|
const jobsPath = join16(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
|
|
10083
10124
|
if (existsSync9(jobsPath)) {
|
|
10084
10125
|
try {
|
|
10085
|
-
const jobsData = JSON.parse(
|
|
10126
|
+
const jobsData = JSON.parse(readFileSync15(jobsPath, "utf-8"));
|
|
10086
10127
|
const kanbanJob = (jobsData.jobs ?? []).find(
|
|
10087
10128
|
(j) => typeof j.name === "string" && j.name.includes("kanban-work")
|
|
10088
10129
|
);
|
|
@@ -10226,6 +10267,35 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
|
|
|
10226
10267
|
} else {
|
|
10227
10268
|
agentState.writtenHashes.delete(agent.agent_id);
|
|
10228
10269
|
}
|
|
10270
|
+
try {
|
|
10271
|
+
const obFramework = agentFrameworkCache.get(agent.code_name) ?? "openclaw";
|
|
10272
|
+
const obSessionMode = refreshData.agent.session_mode;
|
|
10273
|
+
if (obFramework === "claude-code" && obSessionMode === "persistent") {
|
|
10274
|
+
const obStep = coerceOnboardingState(
|
|
10275
|
+
refreshData.agent.onboarding_state
|
|
10276
|
+
).step;
|
|
10277
|
+
const markerPath = join16(homedir9(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
10278
|
+
const marker = readOnboardingDriveMarker(markerPath);
|
|
10279
|
+
const decision = decideOnboardingDrive(obStep, marker, Date.now());
|
|
10280
|
+
if (decision.clearMarker) {
|
|
10281
|
+
clearOnboardingDriveMarker(markerPath);
|
|
10282
|
+
} else if (decision.inject && (obStep === "interviewing" || obStep === "configuring") && isSessionHealthy(agent.code_name)) {
|
|
10283
|
+
const delivered = await injectMessage(
|
|
10284
|
+
agent.code_name,
|
|
10285
|
+
"system",
|
|
10286
|
+
buildOnboardingDirective(obStep),
|
|
10287
|
+
{ task_name: "onboarding" },
|
|
10288
|
+
log
|
|
10289
|
+
).catch(() => false);
|
|
10290
|
+
if (delivered && decision.nextMarker) {
|
|
10291
|
+
writeOnboardingDriveMarker(markerPath, decision.nextMarker);
|
|
10292
|
+
log(`[onboarding] nudged '${agent.code_name}' into '${obStep}'`);
|
|
10293
|
+
}
|
|
10294
|
+
}
|
|
10295
|
+
}
|
|
10296
|
+
} catch (e) {
|
|
10297
|
+
log(`[onboarding] drive failed for '${agent.code_name}': ${e.message}`);
|
|
10298
|
+
}
|
|
10229
10299
|
agentStates.push({
|
|
10230
10300
|
agentId: agent.agent_id,
|
|
10231
10301
|
codeName: agent.code_name,
|
|
@@ -10265,7 +10335,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10265
10335
|
const indexPath = join16(sessionsDir, "sessions.json");
|
|
10266
10336
|
if (!existsSync9(indexPath)) return;
|
|
10267
10337
|
try {
|
|
10268
|
-
const raw =
|
|
10338
|
+
const raw = readFileSync15(indexPath, "utf-8");
|
|
10269
10339
|
const index = JSON.parse(raw);
|
|
10270
10340
|
const cronRunKeys = Object.keys(index).filter((k) => k.includes(":cron:") && k.includes(":run:")).map((k) => ({
|
|
10271
10341
|
key: k,
|
|
@@ -10310,7 +10380,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10310
10380
|
}
|
|
10311
10381
|
}
|
|
10312
10382
|
}
|
|
10313
|
-
|
|
10383
|
+
writeFileSync6(indexPath, JSON.stringify(index));
|
|
10314
10384
|
if (toDelete.length > 0) {
|
|
10315
10385
|
log(`Cleaned ${toDelete.length} cron session(s) and ${deletedFiles} file(s) from ${sessionsDir}`);
|
|
10316
10386
|
}
|
|
@@ -10321,7 +10391,7 @@ var STALE_RUN_TIMEOUT_MS = 5 * 6e4;
|
|
|
10321
10391
|
function clearStaleCronRunState(jobsPath) {
|
|
10322
10392
|
if (!existsSync9(jobsPath)) return;
|
|
10323
10393
|
try {
|
|
10324
|
-
const raw =
|
|
10394
|
+
const raw = readFileSync15(jobsPath, "utf-8");
|
|
10325
10395
|
const data = JSON.parse(raw);
|
|
10326
10396
|
const jobs = data.jobs ?? data;
|
|
10327
10397
|
if (!Array.isArray(jobs)) return;
|
|
@@ -10346,7 +10416,7 @@ function clearStaleCronRunState(jobsPath) {
|
|
|
10346
10416
|
}
|
|
10347
10417
|
}
|
|
10348
10418
|
if (changed) {
|
|
10349
|
-
|
|
10419
|
+
writeFileSync6(jobsPath, JSON.stringify(data, null, 2));
|
|
10350
10420
|
}
|
|
10351
10421
|
} catch {
|
|
10352
10422
|
}
|
|
@@ -10981,8 +11051,8 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
10981
11051
|
if (hostFlagStore().getBoolean("direct-chat-doorbell")) {
|
|
10982
11052
|
try {
|
|
10983
11053
|
const doorbell = directChatDoorbellPath(agent.agentId, homedir9());
|
|
10984
|
-
|
|
10985
|
-
|
|
11054
|
+
mkdirSync6(dirname5(doorbell), { recursive: true });
|
|
11055
|
+
writeFileSync6(doorbell, String(Date.now()));
|
|
10986
11056
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
10987
11057
|
return;
|
|
10988
11058
|
} catch (err) {
|
|
@@ -11030,7 +11100,7 @@ ${escapeXml(msg.content)}
|
|
|
11030
11100
|
const serverNames = [];
|
|
11031
11101
|
if (existsSync9(mcpConfigPath)) {
|
|
11032
11102
|
try {
|
|
11033
|
-
const d = JSON.parse(
|
|
11103
|
+
const d = JSON.parse(readFileSync15(mcpConfigPath, "utf-8"));
|
|
11034
11104
|
if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
|
|
11035
11105
|
} catch {
|
|
11036
11106
|
}
|
|
@@ -11057,7 +11127,7 @@ ${escapeXml(msg.content)}
|
|
|
11057
11127
|
const childEnv = { ...process.env };
|
|
11058
11128
|
if (existsSync9(envIntPath)) {
|
|
11059
11129
|
try {
|
|
11060
|
-
Object.assign(childEnv, parseEnvIntegrations(
|
|
11130
|
+
Object.assign(childEnv, parseEnvIntegrations(readFileSync15(envIntPath, "utf-8")));
|
|
11061
11131
|
} catch {
|
|
11062
11132
|
}
|
|
11063
11133
|
}
|
|
@@ -11409,7 +11479,7 @@ async function processClaudePairSessions(agents) {
|
|
|
11409
11479
|
killPairSession,
|
|
11410
11480
|
pairTmuxSession,
|
|
11411
11481
|
finalizeClaudePairOnboarding
|
|
11412
|
-
} = await import("../claude-pair-runtime-
|
|
11482
|
+
} = await import("../claude-pair-runtime-GMBGZSGJ.js");
|
|
11413
11483
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
11414
11484
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
11415
11485
|
const killed = await killPairSession(pairTmuxSession(pairId));
|
|
@@ -11672,7 +11742,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
11672
11742
|
for (const file of readdirSync5(memoryDir)) {
|
|
11673
11743
|
if (!file.endsWith(".md")) continue;
|
|
11674
11744
|
try {
|
|
11675
|
-
const raw =
|
|
11745
|
+
const raw = readFileSync15(join16(memoryDir, file), "utf-8");
|
|
11676
11746
|
const fileHash = createHash8("sha256").update(raw).digest("hex").slice(0, 16);
|
|
11677
11747
|
currentHashes.set(file, fileHash);
|
|
11678
11748
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -11697,7 +11767,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
11697
11767
|
} catch (err) {
|
|
11698
11768
|
for (const mem of changedMemories) {
|
|
11699
11769
|
for (const [file] of currentHashes) {
|
|
11700
|
-
const parsed = parseMemoryFile(
|
|
11770
|
+
const parsed = parseMemoryFile(readFileSync15(join16(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
11701
11771
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
11702
11772
|
}
|
|
11703
11773
|
}
|
|
@@ -11725,7 +11795,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
|
|
|
11725
11795
|
lastDownloadHash.set(agent.agent_id, responseHash);
|
|
11726
11796
|
lastLocalFileHash.set(agent.agent_id, localListHash);
|
|
11727
11797
|
if (dbMemories.memories?.length) {
|
|
11728
|
-
|
|
11798
|
+
mkdirSync6(memoryDir, { recursive: true });
|
|
11729
11799
|
let written = 0;
|
|
11730
11800
|
let overwritten = 0;
|
|
11731
11801
|
for (let i = 0; i < dbMemories.memories.length; i++) {
|
|
@@ -11744,14 +11814,14 @@ ${mem.content}
|
|
|
11744
11814
|
if (existsSync9(filePath)) {
|
|
11745
11815
|
let existing = "";
|
|
11746
11816
|
try {
|
|
11747
|
-
existing =
|
|
11817
|
+
existing = readFileSync15(filePath, "utf-8");
|
|
11748
11818
|
} catch {
|
|
11749
11819
|
}
|
|
11750
11820
|
if (existing === desired) continue;
|
|
11751
|
-
|
|
11821
|
+
writeFileSync6(filePath, desired);
|
|
11752
11822
|
overwritten++;
|
|
11753
11823
|
} else {
|
|
11754
|
-
|
|
11824
|
+
writeFileSync6(filePath, desired);
|
|
11755
11825
|
written++;
|
|
11756
11826
|
}
|
|
11757
11827
|
}
|
|
@@ -11770,7 +11840,7 @@ ${mem.content}
|
|
|
11770
11840
|
async function cleanupAgentFiles(codeName, agentDir) {
|
|
11771
11841
|
if (existsSync9(agentDir)) {
|
|
11772
11842
|
try {
|
|
11773
|
-
|
|
11843
|
+
rmSync4(agentDir, { recursive: true, force: true });
|
|
11774
11844
|
log(`Removed provision directory for '${codeName}'`);
|
|
11775
11845
|
} catch (err) {
|
|
11776
11846
|
log(`Failed to remove provision dir for '${codeName}': ${err.message}`);
|
|
@@ -12019,7 +12089,7 @@ function startManager(opts) {
|
|
|
12019
12089
|
try {
|
|
12020
12090
|
const stateFile = getStateFile();
|
|
12021
12091
|
if (existsSync9(stateFile)) {
|
|
12022
|
-
const raw =
|
|
12092
|
+
const raw = readFileSync15(stateFile, "utf-8");
|
|
12023
12093
|
const parsed = JSON.parse(raw);
|
|
12024
12094
|
if (Array.isArray(parsed.agents)) {
|
|
12025
12095
|
state6.agents = parsed.agents;
|
|
@@ -12061,7 +12131,7 @@ async function reapOrphanedClaudePids() {
|
|
|
12061
12131
|
const looksLikeClaude = (pid) => {
|
|
12062
12132
|
if (process.platform !== "linux") return true;
|
|
12063
12133
|
try {
|
|
12064
|
-
const comm =
|
|
12134
|
+
const comm = readFileSync15(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
|
|
12065
12135
|
return comm.includes("claude");
|
|
12066
12136
|
} catch {
|
|
12067
12137
|
return false;
|
|
@@ -12172,8 +12242,8 @@ function restartRunningChannelMcps(basenames) {
|
|
|
12172
12242
|
}
|
|
12173
12243
|
function deployMcpAssets() {
|
|
12174
12244
|
const targetDir = join16(homedir9(), ".augmented", "_mcp");
|
|
12175
|
-
|
|
12176
|
-
const moduleDir =
|
|
12245
|
+
mkdirSync6(targetDir, { recursive: true });
|
|
12246
|
+
const moduleDir = dirname5(fileURLToPath(import.meta.url));
|
|
12177
12247
|
let mcpSourceDir = "";
|
|
12178
12248
|
let dir = moduleDir;
|
|
12179
12249
|
for (let i = 0; i < 6; i++) {
|
|
@@ -12182,7 +12252,7 @@ function deployMcpAssets() {
|
|
|
12182
12252
|
mcpSourceDir = candidate;
|
|
12183
12253
|
break;
|
|
12184
12254
|
}
|
|
12185
|
-
const parent =
|
|
12255
|
+
const parent = dirname5(dir);
|
|
12186
12256
|
if (parent === dir) break;
|
|
12187
12257
|
dir = parent;
|
|
12188
12258
|
}
|
|
@@ -12194,7 +12264,7 @@ function deployMcpAssets() {
|
|
|
12194
12264
|
const fileHash = (p) => {
|
|
12195
12265
|
try {
|
|
12196
12266
|
if (!existsSync9(p)) return null;
|
|
12197
|
-
return createHash8("sha256").update(
|
|
12267
|
+
return createHash8("sha256").update(readFileSync15(p)).digest("hex");
|
|
12198
12268
|
} catch {
|
|
12199
12269
|
return null;
|
|
12200
12270
|
}
|
|
@@ -12249,14 +12319,14 @@ function deployMcpAssets() {
|
|
|
12249
12319
|
for (const subdir of ["provision", "project"]) {
|
|
12250
12320
|
const mcpJsonPath = join16(agentsDir, entry.name, subdir, ".mcp.json");
|
|
12251
12321
|
try {
|
|
12252
|
-
const raw =
|
|
12322
|
+
const raw = readFileSync15(mcpJsonPath, "utf-8");
|
|
12253
12323
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|
|
12254
12324
|
const mcpConfig = JSON.parse(raw);
|
|
12255
12325
|
const augServer = mcpConfig.mcpServers?.["augmented"];
|
|
12256
12326
|
if (!augServer) continue;
|
|
12257
12327
|
augServer.command = "node";
|
|
12258
12328
|
augServer.args = [localMcpPath];
|
|
12259
|
-
|
|
12329
|
+
writeFileSync6(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
12260
12330
|
log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
|
|
12261
12331
|
} catch {
|
|
12262
12332
|
}
|