@integrity-labs/agt-cli 0.28.431 → 0.28.433
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-EREBH2LV.js → chunk-NUKNLJNJ.js} +212 -274
- package/dist/chunk-NUKNLJNJ.js.map +1 -0
- package/dist/{chunk-SV67CNIX.js → chunk-RUVNJO63.js} +3 -3
- package/dist/{claude-pair-runtime-44RPFRIE.js → claude-pair-runtime-YAHBPFYL.js} +2 -2
- package/dist/lib/manager-worker.js +238 -197
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +101 -26
- package/dist/mcp/slack-channel.js +236 -128
- package/dist/mcp/telegram-channel.js +187 -91
- package/dist/{persistent-session-A4VUV3UI.js → persistent-session-ISBR3BBX.js} +2 -2
- package/dist/{responsiveness-probe-QRVMR22C.js → responsiveness-probe-OT6JVP43.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-EREBH2LV.js.map +0 -1
- /package/dist/{chunk-SV67CNIX.js.map → chunk-RUVNJO63.js.map} +0 -0
- /package/dist/{claude-pair-runtime-44RPFRIE.js.map → claude-pair-runtime-YAHBPFYL.js.map} +0 -0
- /package/dist/{persistent-session-A4VUV3UI.js.map → persistent-session-ISBR3BBX.js.map} +0 -0
- /package/dist/{responsiveness-probe-QRVMR22C.js.map → responsiveness-probe-OT6JVP43.js.map} +0 -0
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
resolveEffectivePinRaw,
|
|
43
43
|
safeWriteJsonAtomic,
|
|
44
44
|
setConfigHash
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-RUVNJO63.js";
|
|
46
46
|
import {
|
|
47
47
|
getProjectDir as getProjectDir2,
|
|
48
48
|
getReadyTasks,
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
syncTasksToScheduler
|
|
52
52
|
} from "../chunk-3HLECXMI.js";
|
|
53
53
|
import {
|
|
54
|
+
ACCOUNT_ENFORCEMENT_MARKER_FILENAME,
|
|
54
55
|
AnchorSessionClient,
|
|
55
56
|
CLAUDE_MD_MAX_CHARS,
|
|
56
57
|
CONVERSATION_FAILURE_CATEGORIES,
|
|
@@ -137,6 +138,7 @@ import {
|
|
|
137
138
|
resolveDmTarget,
|
|
138
139
|
restartEgressSidecar,
|
|
139
140
|
rotateSessionForWedge,
|
|
141
|
+
serializeAccountEnforcementMarker,
|
|
140
142
|
serializeUsageLimitMarker,
|
|
141
143
|
sessionTranscriptDir,
|
|
142
144
|
sha256,
|
|
@@ -153,17 +155,17 @@ import {
|
|
|
153
155
|
toOpencodeModel,
|
|
154
156
|
transcriptActivityAgeSeconds,
|
|
155
157
|
writeEgressAllowlist
|
|
156
|
-
} from "../chunk-
|
|
158
|
+
} from "../chunk-NUKNLJNJ.js";
|
|
157
159
|
import {
|
|
158
160
|
reapOrphanChannelMcps
|
|
159
161
|
} from "../chunk-XWVM4KPK.js";
|
|
160
162
|
|
|
161
163
|
// src/lib/manager-worker.ts
|
|
162
164
|
import { createHash as createHash15 } from "crypto";
|
|
163
|
-
import { readFileSync as readFileSync20, writeFileSync as
|
|
165
|
+
import { readFileSync as readFileSync20, writeFileSync as writeFileSync13, mkdirSync as mkdirSync11, existsSync as existsSync11, rmSync as rmSync6, readdirSync as readdirSync6, statSync as statSync5, copyFileSync } from "fs";
|
|
164
166
|
import { execFileSync as syncExecFile } from "child_process";
|
|
165
|
-
import { join as
|
|
166
|
-
import { homedir as
|
|
167
|
+
import { join as join24, dirname as dirname7, delimiter as pathDelimiter } from "path";
|
|
168
|
+
import { homedir as homedir11 } from "os";
|
|
167
169
|
import { fileURLToPath } from "url";
|
|
168
170
|
|
|
169
171
|
// src/lib/claude-code-upgrade-throttle.ts
|
|
@@ -2149,9 +2151,47 @@ async function maybeReportUsageBanner(args) {
|
|
|
2149
2151
|
}
|
|
2150
2152
|
}
|
|
2151
2153
|
|
|
2154
|
+
// src/lib/account-enforcement-marker.ts
|
|
2155
|
+
import { mkdirSync as mkdirSync5, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
2156
|
+
import { homedir as homedir4 } from "os";
|
|
2157
|
+
import { join as join7 } from "path";
|
|
2158
|
+
function accountEnforcementMarkerPath(codeName) {
|
|
2159
|
+
return join7(homedir4(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
2160
|
+
}
|
|
2161
|
+
function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.stderr.write(`${m}
|
|
2162
|
+
`)) {
|
|
2163
|
+
if (level !== "warn" && level !== "mute") {
|
|
2164
|
+
clearAccountEnforcementMarker(codeName, log2);
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
const dir = join7(homedir4(), ".augmented", codeName);
|
|
2168
|
+
const path = join7(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
2169
|
+
const tempPath = `${path}.${process.pid}.tmp`;
|
|
2170
|
+
try {
|
|
2171
|
+
mkdirSync5(dir, { recursive: true });
|
|
2172
|
+
writeFileSync5(tempPath, serializeAccountEnforcementMarker(level), "utf-8");
|
|
2173
|
+
renameSync(tempPath, path);
|
|
2174
|
+
} catch (err) {
|
|
2175
|
+
try {
|
|
2176
|
+
rmSync3(tempPath, { force: true });
|
|
2177
|
+
} catch {
|
|
2178
|
+
}
|
|
2179
|
+
log2(`[account-enforcement] marker sync failed for '${codeName}': ${err.message}`);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
function clearAccountEnforcementMarker(codeName, log2 = (m) => process.stderr.write(`${m}
|
|
2183
|
+
`)) {
|
|
2184
|
+
const path = accountEnforcementMarkerPath(codeName);
|
|
2185
|
+
try {
|
|
2186
|
+
rmSync3(path, { force: true });
|
|
2187
|
+
} catch (err) {
|
|
2188
|
+
log2(`[account-enforcement] marker clear failed for '${codeName}': ${err.message}`);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2152
2192
|
// src/lib/token-usage-monitor.ts
|
|
2153
2193
|
import { readdirSync, readFileSync as readFileSync7, statSync } from "fs";
|
|
2154
|
-
import { join as
|
|
2194
|
+
import { join as join8 } from "path";
|
|
2155
2195
|
var MIN_CHECK_INTERVAL_MS2 = 6e4;
|
|
2156
2196
|
var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
2157
2197
|
var MAX_ENTRIES_PER_POST = 200;
|
|
@@ -2180,7 +2220,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
2180
2220
|
if (!name.endsWith(".jsonl")) continue;
|
|
2181
2221
|
const sessionId = name.slice(0, -".jsonl".length);
|
|
2182
2222
|
if (!sessionId) continue;
|
|
2183
|
-
const path =
|
|
2223
|
+
const path = join8(dir, name);
|
|
2184
2224
|
let st;
|
|
2185
2225
|
try {
|
|
2186
2226
|
st = statSync(path);
|
|
@@ -2278,7 +2318,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
2278
2318
|
|
|
2279
2319
|
// src/lib/workflow-run-reconciler.ts
|
|
2280
2320
|
import { readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync2 } from "fs";
|
|
2281
|
-
import { join as
|
|
2321
|
+
import { join as join9 } from "path";
|
|
2282
2322
|
var MIN_CHECK_INTERVAL_MS3 = 5 * 6e4;
|
|
2283
2323
|
var SETTLE_MS = 3e4;
|
|
2284
2324
|
var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
|
|
@@ -2297,7 +2337,7 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
|
|
|
2297
2337
|
return;
|
|
2298
2338
|
}
|
|
2299
2339
|
for (const name of entries) {
|
|
2300
|
-
const p =
|
|
2340
|
+
const p = join9(dir, name);
|
|
2301
2341
|
let st;
|
|
2302
2342
|
try {
|
|
2303
2343
|
st = statSync2(p);
|
|
@@ -2320,7 +2360,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
2320
2360
|
return out;
|
|
2321
2361
|
}
|
|
2322
2362
|
for (const name of entries) {
|
|
2323
|
-
const path =
|
|
2363
|
+
const path = join9(transcriptDir, name);
|
|
2324
2364
|
let st;
|
|
2325
2365
|
try {
|
|
2326
2366
|
st = statSync2(path);
|
|
@@ -2332,7 +2372,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
2332
2372
|
continue;
|
|
2333
2373
|
}
|
|
2334
2374
|
if (st.isDirectory()) {
|
|
2335
|
-
collectJsonlRecursive(
|
|
2375
|
+
collectJsonlRecursive(join9(path, "subagents"), minMtimeMs, out, 0);
|
|
2336
2376
|
}
|
|
2337
2377
|
}
|
|
2338
2378
|
return out;
|
|
@@ -2423,7 +2463,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
2423
2463
|
|
|
2424
2464
|
// src/lib/conversation-evaluator.ts
|
|
2425
2465
|
import { readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
|
|
2426
|
-
import { join as
|
|
2466
|
+
import { join as join10 } from "path";
|
|
2427
2467
|
var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
|
|
2428
2468
|
var TRANSCRIPT_MTIME_WINDOW_MS3 = 7 * 24 * 60 * 60 * 1e3;
|
|
2429
2469
|
var WINDOW_PAD_MS = 5 * 6e4;
|
|
@@ -2859,7 +2899,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
2859
2899
|
return;
|
|
2860
2900
|
}
|
|
2861
2901
|
for (const ent of entries) {
|
|
2862
|
-
const full =
|
|
2902
|
+
const full = join10(d, ent.name);
|
|
2863
2903
|
if (ent.isDirectory()) {
|
|
2864
2904
|
visit(full);
|
|
2865
2905
|
continue;
|
|
@@ -3165,10 +3205,10 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
|
|
|
3165
3205
|
|
|
3166
3206
|
// src/lib/activity-cache-monitor.ts
|
|
3167
3207
|
import { existsSync as existsSync2, readFileSync as readFileSync10 } from "fs";
|
|
3168
|
-
import { homedir as
|
|
3169
|
-
import { join as
|
|
3208
|
+
import { homedir as homedir5 } from "os";
|
|
3209
|
+
import { join as join11 } from "path";
|
|
3170
3210
|
var MIN_CHECK_INTERVAL_MS6 = 6e4;
|
|
3171
|
-
var STATS_CACHE_PATH =
|
|
3211
|
+
var STATS_CACHE_PATH = join11(homedir5(), ".claude", "stats-cache.json");
|
|
3172
3212
|
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
3173
3213
|
var state5 = { lastObservedDate: null, lastCheckedAt: 0 };
|
|
3174
3214
|
function selectNewDailyRows(raw, lastObservedDate) {
|
|
@@ -3402,8 +3442,8 @@ function bundleFingerprint(files) {
|
|
|
3402
3442
|
|
|
3403
3443
|
// src/lib/claude-auth-detect.ts
|
|
3404
3444
|
import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
|
|
3405
|
-
import { homedir as
|
|
3406
|
-
import { join as
|
|
3445
|
+
import { homedir as homedir6, platform } from "os";
|
|
3446
|
+
import { join as join12 } from "path";
|
|
3407
3447
|
import { execFile } from "child_process";
|
|
3408
3448
|
import { promisify } from "util";
|
|
3409
3449
|
var execFileAsync = promisify(execFile);
|
|
@@ -3418,8 +3458,8 @@ async function detectClaudeAuth() {
|
|
|
3418
3458
|
}
|
|
3419
3459
|
async function findClaudeCredentialsPaths() {
|
|
3420
3460
|
const candidates = [
|
|
3421
|
-
|
|
3422
|
-
|
|
3461
|
+
join12(homedir6(), ".claude", ".credentials.json"),
|
|
3462
|
+
join12(homedir6(), ".claude", "credentials.json")
|
|
3423
3463
|
];
|
|
3424
3464
|
const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
3425
3465
|
if (isLinuxRoot) {
|
|
@@ -3427,8 +3467,8 @@ async function findClaudeCredentialsPaths() {
|
|
|
3427
3467
|
const entries = await readdir2("/home", { withFileTypes: true });
|
|
3428
3468
|
for (const entry of entries) {
|
|
3429
3469
|
if (!entry.isDirectory()) continue;
|
|
3430
|
-
candidates.push(
|
|
3431
|
-
candidates.push(
|
|
3470
|
+
candidates.push(join12("/home", entry.name, ".claude", ".credentials.json"));
|
|
3471
|
+
candidates.push(join12("/home", entry.name, ".claude", "credentials.json"));
|
|
3432
3472
|
}
|
|
3433
3473
|
} catch {
|
|
3434
3474
|
}
|
|
@@ -3524,11 +3564,11 @@ function computeChannelConfigHash(input) {
|
|
|
3524
3564
|
}
|
|
3525
3565
|
|
|
3526
3566
|
// src/lib/channel-hash-cache.ts
|
|
3527
|
-
import { existsSync as existsSync3, readFileSync as readFileSync11, writeFileSync as
|
|
3528
|
-
import { join as
|
|
3567
|
+
import { existsSync as existsSync3, readFileSync as readFileSync11, writeFileSync as writeFileSync6 } from "fs";
|
|
3568
|
+
import { join as join13 } from "path";
|
|
3529
3569
|
var CACHE_FILENAME = "channel-hash-cache.json";
|
|
3530
3570
|
function getChannelHashCacheFile(configDir) {
|
|
3531
|
-
return
|
|
3571
|
+
return join13(configDir, CACHE_FILENAME);
|
|
3532
3572
|
}
|
|
3533
3573
|
function loadChannelHashCache(target, configDir) {
|
|
3534
3574
|
const path = getChannelHashCacheFile(configDir);
|
|
@@ -3549,14 +3589,14 @@ function saveChannelHashCache(source, configDir) {
|
|
|
3549
3589
|
const obj = {};
|
|
3550
3590
|
for (const [key, value] of source) obj[key] = value;
|
|
3551
3591
|
try {
|
|
3552
|
-
|
|
3592
|
+
writeFileSync6(path, JSON.stringify(obj, null, 2));
|
|
3553
3593
|
} catch {
|
|
3554
3594
|
}
|
|
3555
3595
|
}
|
|
3556
3596
|
|
|
3557
3597
|
// src/lib/sender-policy-baseline.ts
|
|
3558
3598
|
import { existsSync as existsSync4, readFileSync as readFileSync12 } from "fs";
|
|
3559
|
-
import { join as
|
|
3599
|
+
import { join as join14 } from "path";
|
|
3560
3600
|
var BASELINE_FILENAME = "sender-policy-baseline.json";
|
|
3561
3601
|
var SENDER_POLICY_BASELINE_VERSION = 1;
|
|
3562
3602
|
var BASELINE_CONCERNS = ["senderPolicy", "slackBehaviour", "msteamsBehaviour"];
|
|
@@ -3568,7 +3608,7 @@ function createDeliveryBaselineMaps() {
|
|
|
3568
3608
|
};
|
|
3569
3609
|
}
|
|
3570
3610
|
function getSenderPolicyBaselineFile(configDir) {
|
|
3571
|
-
return
|
|
3611
|
+
return join14(configDir, BASELINE_FILENAME);
|
|
3572
3612
|
}
|
|
3573
3613
|
function loadSenderPolicyBaseline(target, configDir, log2) {
|
|
3574
3614
|
const path = getSenderPolicyBaselineFile(configDir);
|
|
@@ -4098,11 +4138,11 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
|
|
|
4098
4138
|
}
|
|
4099
4139
|
|
|
4100
4140
|
// src/lib/manager/managed-skill-manifest.ts
|
|
4101
|
-
import { existsSync as existsSync5, mkdirSync as
|
|
4102
|
-
import { dirname as dirname4, join as
|
|
4141
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync6, readFileSync as readFileSync13, writeFileSync as writeFileSync7 } from "fs";
|
|
4142
|
+
import { dirname as dirname4, join as join15 } from "path";
|
|
4103
4143
|
var MANIFEST_VERSION = 1;
|
|
4104
4144
|
function managedSkillManifestPath(agentRootDir) {
|
|
4105
|
-
return
|
|
4145
|
+
return join15(agentRootDir, "managed-skills.json");
|
|
4106
4146
|
}
|
|
4107
4147
|
function readManagedSkillManifest(path) {
|
|
4108
4148
|
try {
|
|
@@ -4116,12 +4156,12 @@ function readManagedSkillManifest(path) {
|
|
|
4116
4156
|
}
|
|
4117
4157
|
function writeManagedSkillManifest(path, ids) {
|
|
4118
4158
|
try {
|
|
4119
|
-
|
|
4159
|
+
mkdirSync6(dirname4(path), { recursive: true });
|
|
4120
4160
|
const body = {
|
|
4121
4161
|
version: MANIFEST_VERSION,
|
|
4122
4162
|
globalSkillIds: [...ids].sort()
|
|
4123
4163
|
};
|
|
4124
|
-
|
|
4164
|
+
writeFileSync7(path, JSON.stringify(body, null, 2));
|
|
4125
4165
|
} catch {
|
|
4126
4166
|
}
|
|
4127
4167
|
}
|
|
@@ -4219,9 +4259,9 @@ function resolveModelChain(refreshData) {
|
|
|
4219
4259
|
}
|
|
4220
4260
|
|
|
4221
4261
|
// src/lib/manager/claude-auth.ts
|
|
4222
|
-
import { existsSync as existsSync6, rmSync as
|
|
4223
|
-
import { join as
|
|
4224
|
-
import { homedir as
|
|
4262
|
+
import { existsSync as existsSync6, rmSync as rmSync4 } from "fs";
|
|
4263
|
+
import { join as join16 } from "path";
|
|
4264
|
+
import { homedir as homedir7 } from "os";
|
|
4225
4265
|
async function applyClaudeAuthToEnv(childEnv, label) {
|
|
4226
4266
|
const apiKey = getApiKey();
|
|
4227
4267
|
if (!apiKey) {
|
|
@@ -4233,12 +4273,12 @@ async function applyClaudeAuthToEnv(childEnv, label) {
|
|
|
4233
4273
|
throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
|
|
4234
4274
|
}
|
|
4235
4275
|
childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
|
|
4236
|
-
const claudeDir =
|
|
4276
|
+
const claudeDir = join16(homedir7(), ".claude");
|
|
4237
4277
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
4238
|
-
const p =
|
|
4278
|
+
const p = join16(claudeDir, filename);
|
|
4239
4279
|
if (existsSync6(p)) {
|
|
4240
4280
|
try {
|
|
4241
|
-
|
|
4281
|
+
rmSync4(p, { force: true });
|
|
4242
4282
|
log(`[${label}] Removed ${p} (api_key mode \u2014 preventing OAuth fallback)`);
|
|
4243
4283
|
} catch {
|
|
4244
4284
|
}
|
|
@@ -4251,7 +4291,7 @@ async function applyClaudeAuthToEnv(childEnv, label) {
|
|
|
4251
4291
|
|
|
4252
4292
|
// src/lib/manager/kanban/parsers.ts
|
|
4253
4293
|
import { existsSync as existsSync7, readFileSync as readFileSync14 } from "fs";
|
|
4254
|
-
import { join as
|
|
4294
|
+
import { join as join17 } from "path";
|
|
4255
4295
|
var STANDUP_TEMPLATES = /* @__PURE__ */ new Set(["daily-standup", "end-of-day-summary"]);
|
|
4256
4296
|
var TASK_UPDATE_TEMPLATES = /* @__PURE__ */ new Set(["hourly-status", "task-update"]);
|
|
4257
4297
|
var PLAN_TEMPLATES = /* @__PURE__ */ new Set(["morning-plan"]);
|
|
@@ -4390,8 +4430,8 @@ function getBuiltInSkillContent(skillId) {
|
|
|
4390
4430
|
if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
|
|
4391
4431
|
try {
|
|
4392
4432
|
const candidates = [
|
|
4393
|
-
|
|
4394
|
-
|
|
4433
|
+
join17(process.cwd(), "skills", skillId, "SKILL.md"),
|
|
4434
|
+
join17(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
|
|
4395
4435
|
];
|
|
4396
4436
|
for (const candidate of candidates) {
|
|
4397
4437
|
if (existsSync7(candidate)) {
|
|
@@ -4536,12 +4576,12 @@ function formatBoardForPrompt(items, template) {
|
|
|
4536
4576
|
}
|
|
4537
4577
|
|
|
4538
4578
|
// src/lib/manager/kanban/nudge-state-cache.ts
|
|
4539
|
-
import { existsSync as existsSync8, readFileSync as readFileSync15, writeFileSync as
|
|
4540
|
-
import { join as
|
|
4579
|
+
import { existsSync as existsSync8, readFileSync as readFileSync15, writeFileSync as writeFileSync8 } from "fs";
|
|
4580
|
+
import { join as join18 } from "path";
|
|
4541
4581
|
var CACHE_FILENAME2 = "kanban-nudge-state.json";
|
|
4542
4582
|
var KANBAN_NUDGE_STATE_VERSION = 1;
|
|
4543
4583
|
function getKanbanNudgeStateFile(configDir) {
|
|
4544
|
-
return
|
|
4584
|
+
return join18(configDir, CACHE_FILENAME2);
|
|
4545
4585
|
}
|
|
4546
4586
|
function loadKanbanNudgeState(target, configDir) {
|
|
4547
4587
|
const path = getKanbanNudgeStateFile(configDir);
|
|
@@ -4573,7 +4613,7 @@ function saveKanbanNudgeState(source, configDir) {
|
|
|
4573
4613
|
const agents = {};
|
|
4574
4614
|
for (const [codeName, state7] of source) agents[codeName] = state7;
|
|
4575
4615
|
try {
|
|
4576
|
-
|
|
4616
|
+
writeFileSync8(path, JSON.stringify({ version: KANBAN_NUDGE_STATE_VERSION, agents }, null, 2));
|
|
4577
4617
|
} catch {
|
|
4578
4618
|
}
|
|
4579
4619
|
}
|
|
@@ -5114,9 +5154,9 @@ function closeScheduledRunsForCode(codeName, outcome, reason) {
|
|
|
5114
5154
|
|
|
5115
5155
|
// src/lib/manager/scheduler/kanban-route.ts
|
|
5116
5156
|
import { createHash as createHash10 } from "crypto";
|
|
5117
|
-
import { writeFileSync as
|
|
5118
|
-
import { homedir as
|
|
5119
|
-
import { join as
|
|
5157
|
+
import { writeFileSync as writeFileSync9, renameSync as renameSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync16, unlinkSync } from "fs";
|
|
5158
|
+
import { homedir as homedir8 } from "os";
|
|
5159
|
+
import { join as join19, dirname as dirname5 } from "path";
|
|
5120
5160
|
|
|
5121
5161
|
// src/lib/manager/scheduler/notify.ts
|
|
5122
5162
|
import { createHash as createHash9 } from "crypto";
|
|
@@ -5456,17 +5496,17 @@ function resolveScheduledSlackTarget(task) {
|
|
|
5456
5496
|
}
|
|
5457
5497
|
function stampScheduledTurnMarker(codeName, taskId, target) {
|
|
5458
5498
|
try {
|
|
5459
|
-
const file =
|
|
5499
|
+
const file = join19(homedir8(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
5460
5500
|
const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
|
|
5461
5501
|
const tmp = `${file}.tmp`;
|
|
5462
|
-
|
|
5463
|
-
|
|
5502
|
+
writeFileSync9(tmp, JSON.stringify(marker), "utf8");
|
|
5503
|
+
renameSync2(tmp, file);
|
|
5464
5504
|
} catch (err) {
|
|
5465
5505
|
log(`[scheduled-kanban] scheduled-turn marker write failed for '${codeName}': ${err.message}`);
|
|
5466
5506
|
}
|
|
5467
5507
|
}
|
|
5468
5508
|
function clearScheduledTurnMarkerForTask(codeName, taskId) {
|
|
5469
|
-
const file =
|
|
5509
|
+
const file = join19(homedir8(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
5470
5510
|
try {
|
|
5471
5511
|
const raw = JSON.parse(readFileSync16(file, "utf8"));
|
|
5472
5512
|
if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
|
|
@@ -5522,9 +5562,9 @@ async function routeScheduledTaskViaKanban(codeName, agentId, task, prompt, dura
|
|
|
5522
5562
|
return false;
|
|
5523
5563
|
}
|
|
5524
5564
|
try {
|
|
5525
|
-
const doorbell = directChatDoorbellPath(agentId,
|
|
5526
|
-
|
|
5527
|
-
|
|
5565
|
+
const doorbell = directChatDoorbellPath(agentId, homedir8());
|
|
5566
|
+
mkdirSync7(dirname5(doorbell), { recursive: true });
|
|
5567
|
+
writeFileSync9(doorbell, String(Date.now()));
|
|
5528
5568
|
} catch (err) {
|
|
5529
5569
|
log(`[scheduled-kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
|
|
5530
5570
|
}
|
|
@@ -5674,10 +5714,10 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
|
|
|
5674
5714
|
|
|
5675
5715
|
// src/lib/manager/scheduler/execution.ts
|
|
5676
5716
|
import { createHash as createHash11 } from "crypto";
|
|
5677
|
-
import { homedir as
|
|
5678
|
-
import { join as
|
|
5717
|
+
import { homedir as homedir9 } from "os";
|
|
5718
|
+
import { join as join20 } from "path";
|
|
5679
5719
|
function claudePidFilePath() {
|
|
5680
|
-
return
|
|
5720
|
+
return join20(homedir9(), ".augmented", "manager-claude-pids.json");
|
|
5681
5721
|
}
|
|
5682
5722
|
var inFlightClaudePids = /* @__PURE__ */ new Map();
|
|
5683
5723
|
function registerClaudeSpawn(record) {
|
|
@@ -6901,9 +6941,9 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
6901
6941
|
|
|
6902
6942
|
// src/lib/opencode-telegram-ingest.ts
|
|
6903
6943
|
import { createHash as createHash14 } from "crypto";
|
|
6904
|
-
import { existsSync as existsSync9, mkdirSync as
|
|
6944
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync17, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync10 } from "fs";
|
|
6905
6945
|
import { randomUUID } from "crypto";
|
|
6906
|
-
import { join as
|
|
6946
|
+
import { join as join21 } from "path";
|
|
6907
6947
|
|
|
6908
6948
|
// src/lib/telegram-ingest.ts
|
|
6909
6949
|
import https2 from "https";
|
|
@@ -7451,7 +7491,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
7451
7491
|
let filePath;
|
|
7452
7492
|
try {
|
|
7453
7493
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
7454
|
-
filePath =
|
|
7494
|
+
filePath = join21(dir, "telegram-getupdates-offset-opencode.json");
|
|
7455
7495
|
} catch {
|
|
7456
7496
|
dir = null;
|
|
7457
7497
|
filePath = null;
|
|
@@ -7478,8 +7518,8 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
7478
7518
|
if (!filePath || !dir) return;
|
|
7479
7519
|
const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
7480
7520
|
try {
|
|
7481
|
-
|
|
7482
|
-
|
|
7521
|
+
mkdirSync8(dir, { recursive: true, mode: 448 });
|
|
7522
|
+
writeFileSync10(
|
|
7483
7523
|
tmpPath,
|
|
7484
7524
|
JSON.stringify({
|
|
7485
7525
|
offset,
|
|
@@ -7489,7 +7529,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
7489
7529
|
}),
|
|
7490
7530
|
{ mode: 384 }
|
|
7491
7531
|
);
|
|
7492
|
-
|
|
7532
|
+
renameSync3(tmpPath, filePath);
|
|
7493
7533
|
} catch (err) {
|
|
7494
7534
|
log2(`[telegram-ingest:${codeName}] offset persist failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
7495
7535
|
try {
|
|
@@ -7710,15 +7750,15 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
7710
7750
|
}
|
|
7711
7751
|
|
|
7712
7752
|
// src/lib/restart-flags.ts
|
|
7713
|
-
import { existsSync as existsSync10, mkdirSync as
|
|
7714
|
-
import { homedir as
|
|
7715
|
-
import { join as
|
|
7753
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync9, readdirSync as readdirSync4, readFileSync as readFileSync18, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "fs";
|
|
7754
|
+
import { homedir as homedir10 } from "os";
|
|
7755
|
+
import { join as join22 } from "path";
|
|
7716
7756
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
7717
7757
|
function restartFlagsDir() {
|
|
7718
|
-
return
|
|
7758
|
+
return join22(homedir10(), ".augmented", "restart-flags");
|
|
7719
7759
|
}
|
|
7720
7760
|
function flagPath(codeName) {
|
|
7721
|
-
return
|
|
7761
|
+
return join22(restartFlagsDir(), `${codeName}.flag`);
|
|
7722
7762
|
}
|
|
7723
7763
|
function readRestartFlags() {
|
|
7724
7764
|
const dir = restartFlagsDir();
|
|
@@ -7727,7 +7767,7 @@ function readRestartFlags() {
|
|
|
7727
7767
|
for (const entry of readdirSync4(dir)) {
|
|
7728
7768
|
if (!entry.endsWith(".flag")) continue;
|
|
7729
7769
|
try {
|
|
7730
|
-
const raw = readFileSync18(
|
|
7770
|
+
const raw = readFileSync18(join22(dir, entry), "utf8");
|
|
7731
7771
|
const parsed = JSON.parse(raw);
|
|
7732
7772
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
7733
7773
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -7746,7 +7786,7 @@ function readRestartFlags() {
|
|
|
7746
7786
|
function deleteRestartFlag(codeName) {
|
|
7747
7787
|
const path = flagPath(codeName);
|
|
7748
7788
|
if (existsSync10(path)) {
|
|
7749
|
-
|
|
7789
|
+
rmSync5(path, { force: true });
|
|
7750
7790
|
}
|
|
7751
7791
|
}
|
|
7752
7792
|
|
|
@@ -7845,8 +7885,8 @@ async function sendError(flag, opts, text) {
|
|
|
7845
7885
|
}
|
|
7846
7886
|
|
|
7847
7887
|
// src/lib/restart-context.ts
|
|
7848
|
-
import { readdirSync as readdirSync5, readFileSync as readFileSync19, writeFileSync as
|
|
7849
|
-
import { dirname as dirname6, join as
|
|
7888
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync19, writeFileSync as writeFileSync12, mkdirSync as mkdirSync10, unlinkSync as unlinkSync3 } from "fs";
|
|
7889
|
+
import { dirname as dirname6, join as join23 } from "path";
|
|
7850
7890
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
7851
7891
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
7852
7892
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -7858,10 +7898,10 @@ function augmentedAgentDir(codeName) {
|
|
|
7858
7898
|
return dirname6(getProjectDir(codeName));
|
|
7859
7899
|
}
|
|
7860
7900
|
function slackPendingInboundDir(codeName) {
|
|
7861
|
-
return
|
|
7901
|
+
return join23(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
7862
7902
|
}
|
|
7863
7903
|
function slackRestartContextDir(codeName) {
|
|
7864
|
-
return
|
|
7904
|
+
return join23(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
7865
7905
|
}
|
|
7866
7906
|
function sanitizeTopic(raw) {
|
|
7867
7907
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -7912,8 +7952,8 @@ function readStrandedMarker(path) {
|
|
|
7912
7952
|
return null;
|
|
7913
7953
|
}
|
|
7914
7954
|
function writeHintFile(path, dir, hint) {
|
|
7915
|
-
|
|
7916
|
-
|
|
7955
|
+
mkdirSync10(dir, { recursive: true, mode: 448 });
|
|
7956
|
+
writeFileSync12(path, JSON.stringify(hint), { mode: 384 });
|
|
7917
7957
|
}
|
|
7918
7958
|
function pruneHintsExcept(codeName, freshFilenames) {
|
|
7919
7959
|
const ctxDir = slackRestartContextDir(codeName);
|
|
@@ -7921,7 +7961,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
7921
7961
|
if (!filename.endsWith(".json")) continue;
|
|
7922
7962
|
if (freshFilenames.has(filename)) continue;
|
|
7923
7963
|
try {
|
|
7924
|
-
unlinkSync3(
|
|
7964
|
+
unlinkSync3(join23(ctxDir, filename));
|
|
7925
7965
|
} catch {
|
|
7926
7966
|
}
|
|
7927
7967
|
}
|
|
@@ -7942,7 +7982,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
7942
7982
|
}
|
|
7943
7983
|
const markers = [];
|
|
7944
7984
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
7945
|
-
const parsed = readStrandedMarker(
|
|
7985
|
+
const parsed = readStrandedMarker(join23(markerDir, filename));
|
|
7946
7986
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
7947
7987
|
}
|
|
7948
7988
|
if (markers.length === 0) {
|
|
@@ -7956,7 +7996,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
7956
7996
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
7957
7997
|
for (const { filename, hint } of hints) {
|
|
7958
7998
|
try {
|
|
7959
|
-
writeHintFile(
|
|
7999
|
+
writeHintFile(join23(ctxDir, filename), ctxDir, hint);
|
|
7960
8000
|
freshFilenames.add(filename);
|
|
7961
8001
|
} catch (err) {
|
|
7962
8002
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -9187,7 +9227,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
|
9187
9227
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
9188
9228
|
function projectMcpHash(_codeName, projectDir) {
|
|
9189
9229
|
try {
|
|
9190
|
-
const raw = readFileSync20(
|
|
9230
|
+
const raw = readFileSync20(join24(projectDir, ".mcp.json"), "utf-8");
|
|
9191
9231
|
return createHash15("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
|
|
9192
9232
|
} catch {
|
|
9193
9233
|
return null;
|
|
@@ -9195,7 +9235,7 @@ function projectMcpHash(_codeName, projectDir) {
|
|
|
9195
9235
|
}
|
|
9196
9236
|
function projectMcpKeys(_codeName, projectDir) {
|
|
9197
9237
|
try {
|
|
9198
|
-
const raw = readFileSync20(
|
|
9238
|
+
const raw = readFileSync20(join24(projectDir, ".mcp.json"), "utf-8");
|
|
9199
9239
|
const parsed = JSON.parse(raw);
|
|
9200
9240
|
const servers = parsed.mcpServers;
|
|
9201
9241
|
if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
|
|
@@ -9213,7 +9253,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
|
|
|
9213
9253
|
else runningMcpServerKeys.delete(codeName);
|
|
9214
9254
|
let launchStructure = null;
|
|
9215
9255
|
try {
|
|
9216
|
-
const raw = readFileSync20(
|
|
9256
|
+
const raw = readFileSync20(join24(projectDir, ".mcp.json"), "utf-8");
|
|
9217
9257
|
launchStructure = managedMcpStructureHashFromFile(
|
|
9218
9258
|
JSON.parse(raw),
|
|
9219
9259
|
isManagedMcpServerKey
|
|
@@ -9317,7 +9357,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
9317
9357
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
9318
9358
|
let mcpJsonForRebind = null;
|
|
9319
9359
|
try {
|
|
9320
|
-
mcpJsonForRebind = JSON.parse(readFileSync20(
|
|
9360
|
+
mcpJsonForRebind = JSON.parse(readFileSync20(join24(projectDir, ".mcp.json"), "utf-8"));
|
|
9321
9361
|
} catch {
|
|
9322
9362
|
mcpJsonForRebind = null;
|
|
9323
9363
|
}
|
|
@@ -9468,7 +9508,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
|
|
|
9468
9508
|
function projectChannelSecretHash(projectDir) {
|
|
9469
9509
|
try {
|
|
9470
9510
|
const entries = parseEnvIntegrations(
|
|
9471
|
-
readFileSync20(
|
|
9511
|
+
readFileSync20(join24(projectDir, ".env.integrations"), "utf-8")
|
|
9472
9512
|
);
|
|
9473
9513
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
9474
9514
|
} catch {
|
|
@@ -9564,7 +9604,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
9564
9604
|
var lastVersionCheckAt = 0;
|
|
9565
9605
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
9566
9606
|
var lastResponsivenessProbeAt = 0;
|
|
9567
|
-
var agtCliVersion = true ? "0.28.
|
|
9607
|
+
var agtCliVersion = true ? "0.28.433" : "dev";
|
|
9568
9608
|
function resolveBrewPath(execFileSync2) {
|
|
9569
9609
|
try {
|
|
9570
9610
|
const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -9869,8 +9909,8 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
|
|
|
9869
9909
|
}
|
|
9870
9910
|
if (settings.channelsEnabled === true) return "ok";
|
|
9871
9911
|
settings.channelsEnabled = true;
|
|
9872
|
-
|
|
9873
|
-
|
|
9912
|
+
mkdirSync11(dirname7(path), { recursive: true });
|
|
9913
|
+
writeFileSync13(path, `${JSON.stringify(settings, null, 2)}
|
|
9874
9914
|
`);
|
|
9875
9915
|
log(`[managed-settings] set channelsEnabled:true in ${path} (ENG-5786 \u2014 unblocks Claude Code channels)`);
|
|
9876
9916
|
return "ok";
|
|
@@ -9908,7 +9948,7 @@ async function ensureOpencodeBinary() {
|
|
|
9908
9948
|
try {
|
|
9909
9949
|
const prefix = execFileSync2("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
9910
9950
|
if (prefix) {
|
|
9911
|
-
const npmBin =
|
|
9951
|
+
const npmBin = join24(prefix, "bin");
|
|
9912
9952
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
9913
9953
|
if (!current.includes(npmBin)) {
|
|
9914
9954
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -10025,7 +10065,7 @@ ${r.stderr}`;
|
|
|
10025
10065
|
}
|
|
10026
10066
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
10027
10067
|
function selfUpdateAppliedMarkerPath() {
|
|
10028
|
-
return
|
|
10068
|
+
return join24(homedir11(), ".augmented", ".last-self-update-applied");
|
|
10029
10069
|
}
|
|
10030
10070
|
var selfUpdateUpToDateLogged = false;
|
|
10031
10071
|
var selfUpdatePinnedLogged = false;
|
|
@@ -10053,7 +10093,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
10053
10093
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
10054
10094
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
10055
10095
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
10056
|
-
const markerPath =
|
|
10096
|
+
const markerPath = join24(homedir11(), ".augmented", ".last-update-check");
|
|
10057
10097
|
if (!force) {
|
|
10058
10098
|
try {
|
|
10059
10099
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -10413,13 +10453,13 @@ async function checkClaudeAuth() {
|
|
|
10413
10453
|
var evalEmptyMcpConfigPath = null;
|
|
10414
10454
|
function ensureEvalEmptyMcpConfig() {
|
|
10415
10455
|
if (evalEmptyMcpConfigPath && existsSync11(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
10416
|
-
const dir =
|
|
10456
|
+
const dir = join24(homedir11(), ".augmented");
|
|
10417
10457
|
try {
|
|
10418
|
-
|
|
10458
|
+
mkdirSync11(dir, { recursive: true });
|
|
10419
10459
|
} catch {
|
|
10420
10460
|
}
|
|
10421
|
-
const p =
|
|
10422
|
-
|
|
10461
|
+
const p = join24(dir, ".eval-empty-mcp.json");
|
|
10462
|
+
writeFileSync13(p, JSON.stringify({ mcpServers: {} }));
|
|
10423
10463
|
evalEmptyMcpConfigPath = p;
|
|
10424
10464
|
return p;
|
|
10425
10465
|
}
|
|
@@ -10444,7 +10484,7 @@ async function runEvalClaude(prompt, model) {
|
|
|
10444
10484
|
""
|
|
10445
10485
|
];
|
|
10446
10486
|
const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
10447
|
-
cwd:
|
|
10487
|
+
cwd: homedir11(),
|
|
10448
10488
|
timeout: 12e4,
|
|
10449
10489
|
stdin: "ignore",
|
|
10450
10490
|
env: childEnv,
|
|
@@ -10510,10 +10550,10 @@ function resolveConversationEvalBackend() {
|
|
|
10510
10550
|
return conversationEvalBackend;
|
|
10511
10551
|
}
|
|
10512
10552
|
function getStateFile() {
|
|
10513
|
-
return
|
|
10553
|
+
return join24(config?.configDir ?? join24(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
10514
10554
|
}
|
|
10515
10555
|
function channelHashCacheDir() {
|
|
10516
|
-
return config?.configDir ??
|
|
10556
|
+
return config?.configDir ?? join24(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
10517
10557
|
}
|
|
10518
10558
|
function loadChannelHashCache2() {
|
|
10519
10559
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -10565,7 +10605,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
10565
10605
|
var _channelQuarantineStore = null;
|
|
10566
10606
|
function channelQuarantineStore() {
|
|
10567
10607
|
if (!_channelQuarantineStore) {
|
|
10568
|
-
const dir = config?.configDir ??
|
|
10608
|
+
const dir = config?.configDir ?? join24(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
10569
10609
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
10570
10610
|
}
|
|
10571
10611
|
return _channelQuarantineStore;
|
|
@@ -10582,7 +10622,7 @@ function claudeMdSizeFor(codeName) {
|
|
|
10582
10622
|
var _hostFlagStore = null;
|
|
10583
10623
|
function hostFlagStore() {
|
|
10584
10624
|
if (!_hostFlagStore) {
|
|
10585
|
-
const dir = config?.configDir ??
|
|
10625
|
+
const dir = config?.configDir ?? join24(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
10586
10626
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
10587
10627
|
}
|
|
10588
10628
|
return _hostFlagStore;
|
|
@@ -10649,13 +10689,13 @@ function parseSkillFrontmatter(content) {
|
|
|
10649
10689
|
return out;
|
|
10650
10690
|
}
|
|
10651
10691
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
10652
|
-
const { readdirSync: readdirSync7, readFileSync: rfs, existsSync: ex, writeFileSync:
|
|
10653
|
-
const skillsDir =
|
|
10654
|
-
const claudeMdPath =
|
|
10692
|
+
const { readdirSync: readdirSync7, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync14 } = await import("fs");
|
|
10693
|
+
const skillsDir = join24(configDir, codeName, "project", ".claude", "skills");
|
|
10694
|
+
const claudeMdPath = join24(configDir, codeName, "project", "CLAUDE.md");
|
|
10655
10695
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
10656
10696
|
const entries = [];
|
|
10657
10697
|
for (const dir of readdirSync7(skillsDir).sort()) {
|
|
10658
|
-
const skillFile =
|
|
10698
|
+
const skillFile = join24(skillsDir, dir, "SKILL.md");
|
|
10659
10699
|
if (!ex(skillFile)) continue;
|
|
10660
10700
|
try {
|
|
10661
10701
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -10699,7 +10739,7 @@ ${SKILLS_INDEX_END}`;
|
|
|
10699
10739
|
next = current.trimEnd() + "\n\n" + section + "\n";
|
|
10700
10740
|
}
|
|
10701
10741
|
if (next !== current) {
|
|
10702
|
-
|
|
10742
|
+
writeFileSync14(claudeMdPath, next, "utf-8");
|
|
10703
10743
|
log2(
|
|
10704
10744
|
injectSkillList ? `Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)` : `Refreshed CLAUDE.md managed block for '${codeName}' (skill list suppressed by claude-md-skills-index=false; ${entries.length} skills on disk)`
|
|
10705
10745
|
);
|
|
@@ -10722,7 +10762,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
|
|
|
10722
10762
|
if (codeNames.length === 0) return;
|
|
10723
10763
|
void (async () => {
|
|
10724
10764
|
try {
|
|
10725
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
10765
|
+
const { collectDiagnostics } = await import("../persistent-session-ISBR3BBX.js");
|
|
10726
10766
|
await api.post("/host/heartbeat", {
|
|
10727
10767
|
host_id: hostId,
|
|
10728
10768
|
agent_diagnostics: collectDiagnostics(codeNames, quarantineEntriesFor, claudeMdSizeFor)
|
|
@@ -10829,7 +10869,7 @@ async function pollCycle() {
|
|
|
10829
10869
|
}
|
|
10830
10870
|
try {
|
|
10831
10871
|
const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
|
|
10832
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
10872
|
+
const { collectDiagnostics } = await import("../persistent-session-ISBR3BBX.js");
|
|
10833
10873
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
10834
10874
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames, quarantineEntriesFor, claudeMdSizeFor) : void 0;
|
|
10835
10875
|
let tailscaleHostname;
|
|
@@ -10943,7 +10983,7 @@ async function pollCycle() {
|
|
|
10943
10983
|
collectResponsivenessProbes,
|
|
10944
10984
|
collectPanelessActivityProbes,
|
|
10945
10985
|
getResponsivenessIntervalMs
|
|
10946
|
-
} = await import("../responsiveness-probe-
|
|
10986
|
+
} = await import("../responsiveness-probe-OT6JVP43.js");
|
|
10947
10987
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
10948
10988
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
10949
10989
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -11007,7 +11047,7 @@ async function pollCycle() {
|
|
|
11007
11047
|
collectResponsivenessProbes,
|
|
11008
11048
|
livePendingInboundOldestAgeSeconds,
|
|
11009
11049
|
parkPendingInbound
|
|
11010
|
-
} = await import("../responsiveness-probe-
|
|
11050
|
+
} = await import("../responsiveness-probe-OT6JVP43.js");
|
|
11011
11051
|
const { getProjectDir: wedgeProjectDir } = await import("../scheduler-engine-NDP36U7O.js");
|
|
11012
11052
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
11013
11053
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -11099,10 +11139,10 @@ async function pollCycle() {
|
|
|
11099
11139
|
const paneTail = readFileSync20(paneLogPath(codeName), "utf8").slice(-65536);
|
|
11100
11140
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
11101
11141
|
if (transient) {
|
|
11102
|
-
const wedgeHome =
|
|
11142
|
+
const wedgeHome = join24(homedir11(), ".augmented", codeName);
|
|
11103
11143
|
if (existsSync11(wedgeHome)) {
|
|
11104
11144
|
atomicWriteFileSync(
|
|
11105
|
-
|
|
11145
|
+
join24(wedgeHome, "watchdog-give-up.json"),
|
|
11106
11146
|
JSON.stringify({
|
|
11107
11147
|
gave_up_at: wedgeNow.toISOString(),
|
|
11108
11148
|
reason: "transient_overload"
|
|
@@ -11373,7 +11413,7 @@ async function pollCycle() {
|
|
|
11373
11413
|
const adapter = resolveAgentFramework(prev.codeName);
|
|
11374
11414
|
stopAgentRuntime2(prev.codeName, "removed-from-host");
|
|
11375
11415
|
killAgentChannelProcesses(prev.codeName, { log });
|
|
11376
|
-
const agentDir =
|
|
11416
|
+
const agentDir = join24(adapter.getAgentDir(prev.codeName), "provision");
|
|
11377
11417
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
11378
11418
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
11379
11419
|
}
|
|
@@ -11460,10 +11500,10 @@ async function pollCycle() {
|
|
|
11460
11500
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
11461
11501
|
// the watchdog, never fails the poll cycle.
|
|
11462
11502
|
signalGiveUp: (codeName) => {
|
|
11463
|
-
const dir =
|
|
11503
|
+
const dir = join24(homedir11(), ".augmented", codeName);
|
|
11464
11504
|
if (!existsSync11(dir)) return;
|
|
11465
11505
|
atomicWriteFileSync(
|
|
11466
|
-
|
|
11506
|
+
join24(dir, "watchdog-give-up.json"),
|
|
11467
11507
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
11468
11508
|
);
|
|
11469
11509
|
}
|
|
@@ -11547,6 +11587,7 @@ async function getOrCacheRegisteredAgents(adapter, profile) {
|
|
|
11547
11587
|
}
|
|
11548
11588
|
async function processAgent(agent, agentStates) {
|
|
11549
11589
|
if (!config) return;
|
|
11590
|
+
syncAccountEnforcementMarker(agent.code_name, agent.enforcement ?? null, log);
|
|
11550
11591
|
const previousKnownStatus = agentState.knownStatuses.get(agent.agent_id);
|
|
11551
11592
|
agentState.agentDisplayNames.set(agent.code_name, agent.display_name);
|
|
11552
11593
|
agentState.codeNameToAgentId.set(agent.code_name, agent.agent_id);
|
|
@@ -11602,7 +11643,7 @@ async function processAgent(agent, agentStates) {
|
|
|
11602
11643
|
}
|
|
11603
11644
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
11604
11645
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
11605
|
-
let agentDir =
|
|
11646
|
+
let agentDir = join24(adapter.getAgentDir(agent.code_name), "provision");
|
|
11606
11647
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
11607
11648
|
if (previousKnownStatus !== agent.status) {
|
|
11608
11649
|
log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
|
|
@@ -11775,7 +11816,7 @@ async function processAgent(agent, agentStates) {
|
|
|
11775
11816
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
11776
11817
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
11777
11818
|
const frameworkAdapter = getFramework(frameworkId);
|
|
11778
|
-
agentDir =
|
|
11819
|
+
agentDir = join24(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
11779
11820
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
11780
11821
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
11781
11822
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -11822,9 +11863,9 @@ async function processAgent(agent, agentStates) {
|
|
|
11822
11863
|
try {
|
|
11823
11864
|
const artifacts = generateArtifacts(agent, refreshData, frameworkAdapter);
|
|
11824
11865
|
const changedFiles = [];
|
|
11825
|
-
|
|
11866
|
+
mkdirSync11(agentDir, { recursive: true });
|
|
11826
11867
|
for (const artifact of artifacts) {
|
|
11827
|
-
const filePath =
|
|
11868
|
+
const filePath = join24(agentDir, artifact.relativePath);
|
|
11828
11869
|
let existingHash;
|
|
11829
11870
|
let newHash;
|
|
11830
11871
|
let writeContent = artifact.content;
|
|
@@ -11843,7 +11884,7 @@ async function processAgent(agent, agentStates) {
|
|
|
11843
11884
|
};
|
|
11844
11885
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
11845
11886
|
try {
|
|
11846
|
-
const projectClaudeMd =
|
|
11887
|
+
const projectClaudeMd = join24(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
11847
11888
|
const existing = readFileSync20(projectClaudeMd, "utf-8");
|
|
11848
11889
|
existingHash = sha256(stripDynamicSections(existing));
|
|
11849
11890
|
} catch {
|
|
@@ -11894,26 +11935,26 @@ async function processAgent(agent, agentStates) {
|
|
|
11894
11935
|
}
|
|
11895
11936
|
}
|
|
11896
11937
|
if (changedFiles.length > 0) {
|
|
11897
|
-
const isFirst = !existsSync11(
|
|
11938
|
+
const isFirst = !existsSync11(join24(agentDir, "CHARTER.md"));
|
|
11898
11939
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
11899
11940
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
11900
11941
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
11901
11942
|
for (const file of changedFiles) {
|
|
11902
|
-
const filePath =
|
|
11903
|
-
|
|
11943
|
+
const filePath = join24(agentDir, file.relativePath);
|
|
11944
|
+
mkdirSync11(dirname7(filePath), { recursive: true });
|
|
11904
11945
|
if (file.relativePath === ".mcp.json") {
|
|
11905
11946
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
11906
11947
|
} else {
|
|
11907
|
-
|
|
11948
|
+
writeFileSync13(filePath, file.content);
|
|
11908
11949
|
}
|
|
11909
11950
|
}
|
|
11910
11951
|
try {
|
|
11911
|
-
const provSkillsDir =
|
|
11952
|
+
const provSkillsDir = join24(agentDir, ".claude", "skills");
|
|
11912
11953
|
if (existsSync11(provSkillsDir)) {
|
|
11913
11954
|
for (const folder of readdirSync6(provSkillsDir)) {
|
|
11914
11955
|
if (folder.startsWith("knowledge-")) {
|
|
11915
11956
|
try {
|
|
11916
|
-
|
|
11957
|
+
rmSync6(join24(provSkillsDir, folder), { recursive: true });
|
|
11917
11958
|
} catch {
|
|
11918
11959
|
}
|
|
11919
11960
|
}
|
|
@@ -11926,7 +11967,7 @@ async function processAgent(agent, agentStates) {
|
|
|
11926
11967
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
11927
11968
|
const hashes = /* @__PURE__ */ new Map();
|
|
11928
11969
|
for (const file of trackedFiles2) {
|
|
11929
|
-
const h = hashFile(
|
|
11970
|
+
const h = hashFile(join24(agentDir, file));
|
|
11930
11971
|
if (h) hashes.set(file, h);
|
|
11931
11972
|
}
|
|
11932
11973
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -11944,14 +11985,14 @@ async function processAgent(agent, agentStates) {
|
|
|
11944
11985
|
}
|
|
11945
11986
|
if (Array.isArray(refreshData.workflows)) {
|
|
11946
11987
|
try {
|
|
11947
|
-
const provWorkflowsDir =
|
|
11988
|
+
const provWorkflowsDir = join24(agentDir, ".claude", "workflows");
|
|
11948
11989
|
if (existsSync11(provWorkflowsDir)) {
|
|
11949
11990
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
11950
11991
|
for (const file of readdirSync6(provWorkflowsDir)) {
|
|
11951
11992
|
if (!file.endsWith(".js")) continue;
|
|
11952
11993
|
if (expected.has(file)) continue;
|
|
11953
11994
|
try {
|
|
11954
|
-
|
|
11995
|
+
rmSync6(join24(provWorkflowsDir, file));
|
|
11955
11996
|
} catch {
|
|
11956
11997
|
}
|
|
11957
11998
|
}
|
|
@@ -12033,7 +12074,7 @@ async function processAgent(agent, agentStates) {
|
|
|
12033
12074
|
if (written && existsSync11(agentDir)) {
|
|
12034
12075
|
const driftedFiles = [];
|
|
12035
12076
|
for (const [file, expectedHash] of written) {
|
|
12036
|
-
const localHash = hashFile(
|
|
12077
|
+
const localHash = hashFile(join24(agentDir, file));
|
|
12037
12078
|
if (localHash && localHash !== expectedHash) {
|
|
12038
12079
|
driftedFiles.push(file);
|
|
12039
12080
|
}
|
|
@@ -12044,7 +12085,7 @@ async function processAgent(agent, agentStates) {
|
|
|
12044
12085
|
try {
|
|
12045
12086
|
const localHashes = {};
|
|
12046
12087
|
for (const file of driftedFiles) {
|
|
12047
|
-
localHashes[file] = hashFile(
|
|
12088
|
+
localHashes[file] = hashFile(join24(agentDir, file));
|
|
12048
12089
|
}
|
|
12049
12090
|
await api.post("/host/drift", {
|
|
12050
12091
|
agent_id: agent.agent_id,
|
|
@@ -12231,15 +12272,15 @@ async function processAgent(agent, agentStates) {
|
|
|
12231
12272
|
const addedChannels = [...restartDecision.added];
|
|
12232
12273
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
12233
12274
|
try {
|
|
12234
|
-
const agentAugmentedDir =
|
|
12235
|
-
|
|
12275
|
+
const agentAugmentedDir = join24(homedir11(), ".augmented", agent.code_name);
|
|
12276
|
+
mkdirSync11(agentAugmentedDir, { recursive: true });
|
|
12236
12277
|
const markerJson = JSON.stringify({
|
|
12237
12278
|
version: 1,
|
|
12238
12279
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12239
12280
|
added: addedChannels
|
|
12240
12281
|
});
|
|
12241
12282
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
12242
|
-
atomicWriteFileSync(
|
|
12283
|
+
atomicWriteFileSync(join24(agentAugmentedDir, file), markerJson);
|
|
12243
12284
|
}
|
|
12244
12285
|
} catch (err) {
|
|
12245
12286
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -12428,18 +12469,18 @@ async function processAgent(agent, agentStates) {
|
|
|
12428
12469
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
12429
12470
|
try {
|
|
12430
12471
|
const agentProvisionDir = agentDir;
|
|
12431
|
-
const projectDir =
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
const provisionMcpPath =
|
|
12435
|
-
const projectMcpPath =
|
|
12472
|
+
const projectDir = join24(homedir11(), ".augmented", agent.code_name, "project");
|
|
12473
|
+
mkdirSync11(agentProvisionDir, { recursive: true });
|
|
12474
|
+
mkdirSync11(projectDir, { recursive: true });
|
|
12475
|
+
const provisionMcpPath = join24(agentProvisionDir, ".mcp.json");
|
|
12476
|
+
const projectMcpPath = join24(projectDir, ".mcp.json");
|
|
12436
12477
|
let mcpConfig = { mcpServers: {} };
|
|
12437
12478
|
try {
|
|
12438
12479
|
mcpConfig = JSON.parse(readFileSync20(provisionMcpPath, "utf-8"));
|
|
12439
12480
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
12440
12481
|
} catch {
|
|
12441
12482
|
}
|
|
12442
|
-
const localDirectChatChannel =
|
|
12483
|
+
const localDirectChatChannel = join24(homedir11(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
12443
12484
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
12444
12485
|
const directChatTz = (() => {
|
|
12445
12486
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -12465,7 +12506,7 @@ async function processAgent(agent, agentStates) {
|
|
|
12465
12506
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
12466
12507
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
12467
12508
|
// so it byte-matches the broker readers' path.
|
|
12468
|
-
AGT_TURN_INITIATOR_FILE:
|
|
12509
|
+
AGT_TURN_INITIATOR_FILE: join24(
|
|
12469
12510
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
12470
12511
|
".current-turn-initiator.json"
|
|
12471
12512
|
)
|
|
@@ -12485,10 +12526,10 @@ async function processAgent(agent, agentStates) {
|
|
|
12485
12526
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
12486
12527
|
}
|
|
12487
12528
|
}
|
|
12488
|
-
const staleChannelsPath =
|
|
12529
|
+
const staleChannelsPath = join24(projectDir, ".mcp-channels.json");
|
|
12489
12530
|
if (existsSync11(staleChannelsPath)) {
|
|
12490
12531
|
try {
|
|
12491
|
-
|
|
12532
|
+
rmSync6(staleChannelsPath, { force: true });
|
|
12492
12533
|
} catch {
|
|
12493
12534
|
}
|
|
12494
12535
|
}
|
|
@@ -12575,7 +12616,7 @@ async function processAgent(agent, agentStates) {
|
|
|
12575
12616
|
}
|
|
12576
12617
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
12577
12618
|
try {
|
|
12578
|
-
const probeProjectDir =
|
|
12619
|
+
const probeProjectDir = join24(homedir11(), ".augmented", agent.code_name, "project");
|
|
12579
12620
|
let probeSet = integrations;
|
|
12580
12621
|
try {
|
|
12581
12622
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -12621,7 +12662,7 @@ async function processAgent(agent, agentStates) {
|
|
|
12621
12662
|
const forceDue = attemptsLeft > 0;
|
|
12622
12663
|
let probeRan = false;
|
|
12623
12664
|
try {
|
|
12624
|
-
const probeProjectDir =
|
|
12665
|
+
const probeProjectDir = join24(homedir11(), ".augmented", agent.code_name, "project");
|
|
12625
12666
|
probeRan = await runAgentSessionToolBindProbes(agent, integrations, probeProjectDir, { forceDue });
|
|
12626
12667
|
} catch (err) {
|
|
12627
12668
|
log(`Session-tool-bind probe failed for '${agent.code_name}': ${err.message}`);
|
|
@@ -12696,8 +12737,8 @@ async function processAgent(agent, agentStates) {
|
|
|
12696
12737
|
const intHash = computeIntegrationsHash(integrations);
|
|
12697
12738
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
12698
12739
|
if (intHash !== prevIntHash) {
|
|
12699
|
-
const projectDir =
|
|
12700
|
-
const envIntPath =
|
|
12740
|
+
const projectDir = join24(homedir11(), ".augmented", agent.code_name, "project");
|
|
12741
|
+
const envIntPath = join24(projectDir, ".env.integrations");
|
|
12701
12742
|
let preWriteEnv;
|
|
12702
12743
|
try {
|
|
12703
12744
|
preWriteEnv = readFileSync20(envIntPath, "utf-8");
|
|
@@ -12717,7 +12758,7 @@ async function processAgent(agent, agentStates) {
|
|
|
12717
12758
|
}
|
|
12718
12759
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
12719
12760
|
try {
|
|
12720
|
-
const projectMcpPath =
|
|
12761
|
+
const projectMcpPath = join24(projectDir, ".mcp.json");
|
|
12721
12762
|
const postWriteEnv = readFileSync20(envIntPath, "utf-8");
|
|
12722
12763
|
const mcpContent = readFileSync20(projectMcpPath, "utf-8");
|
|
12723
12764
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
@@ -12965,17 +13006,17 @@ async function processAgent(agent, agentStates) {
|
|
|
12965
13006
|
}
|
|
12966
13007
|
}
|
|
12967
13008
|
try {
|
|
12968
|
-
const { readdirSync: readdirSync7, rmSync:
|
|
12969
|
-
const { homedir:
|
|
13009
|
+
const { readdirSync: readdirSync7, rmSync: rmSync7 } = await import("fs");
|
|
13010
|
+
const { homedir: homedir12 } = await import("os");
|
|
12970
13011
|
const frameworkId2 = frameworkAdapter.id;
|
|
12971
13012
|
const candidateSkillDirs = [
|
|
12972
13013
|
// Claude Code — framework runtime tree
|
|
12973
|
-
|
|
13014
|
+
join24(homedir12(), ".augmented", agent.code_name, "skills"),
|
|
12974
13015
|
// Claude Code — project tree
|
|
12975
|
-
|
|
13016
|
+
join24(homedir12(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
12976
13017
|
// Defensive: legacy provision-side path, not currently an
|
|
12977
13018
|
// install target but cheap to sweep.
|
|
12978
|
-
|
|
13019
|
+
join24(agentDir, ".claude", "skills")
|
|
12979
13020
|
];
|
|
12980
13021
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync11(d));
|
|
12981
13022
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
@@ -12991,9 +13032,9 @@ async function processAgent(agent, agentStates) {
|
|
|
12991
13032
|
}
|
|
12992
13033
|
const removeSkillFolder = (entry, reason) => {
|
|
12993
13034
|
for (const dir of existingDirs) {
|
|
12994
|
-
const p =
|
|
13035
|
+
const p = join24(dir, entry);
|
|
12995
13036
|
if (existsSync11(p)) {
|
|
12996
|
-
|
|
13037
|
+
rmSync7(p, { recursive: true, force: true });
|
|
12997
13038
|
}
|
|
12998
13039
|
}
|
|
12999
13040
|
log(`Removed ${reason} '${entry}' for '${agent.code_name}' (framework=${frameworkId2})`);
|
|
@@ -13011,7 +13052,7 @@ async function processAgent(agent, agentStates) {
|
|
|
13011
13052
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
13012
13053
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
13013
13054
|
const manifestPath = managedSkillManifestPath(
|
|
13014
|
-
|
|
13055
|
+
join24(homedir11(), ".augmented", agent.code_name)
|
|
13015
13056
|
);
|
|
13016
13057
|
const prevIds = /* @__PURE__ */ new Set([
|
|
13017
13058
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -13031,16 +13072,16 @@ async function processAgent(agent, agentStates) {
|
|
|
13031
13072
|
}
|
|
13032
13073
|
if (plan.removes.length) {
|
|
13033
13074
|
const globalSkillDirs = [
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13075
|
+
join24(homedir11(), ".augmented", agent.code_name, "skills"),
|
|
13076
|
+
join24(homedir11(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
13077
|
+
join24(agentDir, ".claude", "skills")
|
|
13037
13078
|
];
|
|
13038
13079
|
for (const id of plan.removes) {
|
|
13039
13080
|
let prunedAny = false;
|
|
13040
13081
|
for (const dir of globalSkillDirs) {
|
|
13041
|
-
const p =
|
|
13042
|
-
if (existsSync11(p) && existsSync11(
|
|
13043
|
-
|
|
13082
|
+
const p = join24(dir, id);
|
|
13083
|
+
if (existsSync11(p) && existsSync11(join24(p, "SKILL.md"))) {
|
|
13084
|
+
rmSync6(p, { recursive: true, force: true });
|
|
13044
13085
|
prunedAny = true;
|
|
13045
13086
|
}
|
|
13046
13087
|
}
|
|
@@ -13258,7 +13299,7 @@ async function processAgent(agent, agentStates) {
|
|
|
13258
13299
|
const sess = getSessionState(agent.code_name);
|
|
13259
13300
|
let mcpJsonParsed = null;
|
|
13260
13301
|
try {
|
|
13261
|
-
const mcpPath =
|
|
13302
|
+
const mcpPath = join24(getProjectDir(agent.code_name), ".mcp.json");
|
|
13262
13303
|
mcpJsonParsed = JSON.parse(readFileSync20(mcpPath, "utf-8"));
|
|
13263
13304
|
} catch {
|
|
13264
13305
|
}
|
|
@@ -13624,7 +13665,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
13624
13665
|
if (trackedFiles.length > 0 && existsSync11(agentDir)) {
|
|
13625
13666
|
const hashes = /* @__PURE__ */ new Map();
|
|
13626
13667
|
for (const file of trackedFiles) {
|
|
13627
|
-
const h = hashFile(
|
|
13668
|
+
const h = hashFile(join24(agentDir, file));
|
|
13628
13669
|
if (h) hashes.set(file, h);
|
|
13629
13670
|
}
|
|
13630
13671
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -13639,7 +13680,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
13639
13680
|
refreshData.agent.onboarding_state
|
|
13640
13681
|
);
|
|
13641
13682
|
const obStep = obState.step;
|
|
13642
|
-
const markerPath =
|
|
13683
|
+
const markerPath = join24(homedir11(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
13643
13684
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
13644
13685
|
const decision = decideOnboardingDrive(obStep, marker, Date.now(), obState.generation ?? 0);
|
|
13645
13686
|
if (decision.clearMarker) {
|
|
@@ -13727,7 +13768,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
13727
13768
|
}
|
|
13728
13769
|
stopOpencodeSlackIngest(codeName, log);
|
|
13729
13770
|
stopOpencodeTelegramIngest(codeName, log);
|
|
13730
|
-
const opencodeProjectDir =
|
|
13771
|
+
const opencodeProjectDir = join24(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
13731
13772
|
const serveEnv = {
|
|
13732
13773
|
AGT_HOST: requireHost(),
|
|
13733
13774
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -13770,8 +13811,8 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
13770
13811
|
async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
|
|
13771
13812
|
const codeName = agent.code_name;
|
|
13772
13813
|
const projectDir = getProjectDir(codeName);
|
|
13773
|
-
const mcpConfigPath =
|
|
13774
|
-
const claudeMdPath =
|
|
13814
|
+
const mcpConfigPath = join24(projectDir, ".mcp.json");
|
|
13815
|
+
const claudeMdPath = join24(projectDir, "CLAUDE.md");
|
|
13775
13816
|
if (restartBreaker.isTripped(codeName)) {
|
|
13776
13817
|
const trip = restartBreaker.getTrip(codeName);
|
|
13777
13818
|
return {
|
|
@@ -14323,7 +14364,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
14323
14364
|
void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
|
|
14324
14365
|
void (async () => {
|
|
14325
14366
|
try {
|
|
14326
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
14367
|
+
const { collectDiagnostics } = await import("../persistent-session-ISBR3BBX.js");
|
|
14327
14368
|
await api.post("/host/heartbeat", {
|
|
14328
14369
|
host_id: hostId,
|
|
14329
14370
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor)
|
|
@@ -14373,7 +14414,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
|
|
|
14373
14414
|
}
|
|
14374
14415
|
try {
|
|
14375
14416
|
const hostId = await getHostId();
|
|
14376
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
14417
|
+
const { collectDiagnostics } = await import("../persistent-session-ISBR3BBX.js");
|
|
14377
14418
|
await api.post("/host/heartbeat", {
|
|
14378
14419
|
host_id: hostId,
|
|
14379
14420
|
agent_diagnostics: collectDiagnostics([codeName], quarantineEntriesFor, claudeMdSizeFor)
|
|
@@ -14658,9 +14699,9 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
14658
14699
|
const useDoorbell = hostFlagStore().getBoolean("direct-chat-doorbell") || isolationMode(agent.codeName) === "docker";
|
|
14659
14700
|
if (useDoorbell) {
|
|
14660
14701
|
try {
|
|
14661
|
-
const doorbell = directChatDoorbellPath(agent.agentId,
|
|
14662
|
-
|
|
14663
|
-
|
|
14702
|
+
const doorbell = directChatDoorbellPath(agent.agentId, homedir11());
|
|
14703
|
+
mkdirSync11(dirname7(doorbell), { recursive: true });
|
|
14704
|
+
writeFileSync13(doorbell, String(Date.now()));
|
|
14664
14705
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
14665
14706
|
return;
|
|
14666
14707
|
} catch (err) {
|
|
@@ -14768,9 +14809,9 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
|
|
|
14768
14809
|
}
|
|
14769
14810
|
if (run_id) openInjectedRunByCode.set(codeName, run_id);
|
|
14770
14811
|
try {
|
|
14771
|
-
const doorbell = directChatDoorbellPath(agentId,
|
|
14772
|
-
|
|
14773
|
-
|
|
14812
|
+
const doorbell = directChatDoorbellPath(agentId, homedir11());
|
|
14813
|
+
mkdirSync11(dirname7(doorbell), { recursive: true });
|
|
14814
|
+
writeFileSync13(doorbell, String(Date.now()));
|
|
14774
14815
|
} catch (err) {
|
|
14775
14816
|
log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
|
|
14776
14817
|
}
|
|
@@ -14826,7 +14867,7 @@ async function processClaudePairSessions(agents) {
|
|
|
14826
14867
|
killPairSession,
|
|
14827
14868
|
pairTmuxSession,
|
|
14828
14869
|
finalizeClaudePairOnboarding
|
|
14829
|
-
} = await import("../claude-pair-runtime-
|
|
14870
|
+
} = await import("../claude-pair-runtime-YAHBPFYL.js");
|
|
14830
14871
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
14831
14872
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
14832
14873
|
const killed = await killPairSession(pairTmuxSession(pairId));
|
|
@@ -15076,8 +15117,8 @@ function parseMemoryFile(raw, fallbackName) {
|
|
|
15076
15117
|
};
|
|
15077
15118
|
}
|
|
15078
15119
|
async function syncMemories(agent, configDir, log2) {
|
|
15079
|
-
const projectDir =
|
|
15080
|
-
const memoryDir =
|
|
15120
|
+
const projectDir = join24(configDir, agent.code_name, "project");
|
|
15121
|
+
const memoryDir = join24(projectDir, "memory");
|
|
15081
15122
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
15082
15123
|
if (isFreshSync) {
|
|
15083
15124
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -15095,7 +15136,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
15095
15136
|
for (const file of readdirSync6(memoryDir)) {
|
|
15096
15137
|
if (!file.endsWith(".md")) continue;
|
|
15097
15138
|
try {
|
|
15098
|
-
const raw = readFileSync20(
|
|
15139
|
+
const raw = readFileSync20(join24(memoryDir, file), "utf-8");
|
|
15099
15140
|
const fileHash = createHash15("sha256").update(raw).digest("hex").slice(0, 16);
|
|
15100
15141
|
currentHashes.set(file, fileHash);
|
|
15101
15142
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -15120,7 +15161,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
15120
15161
|
} catch (err) {
|
|
15121
15162
|
for (const mem of changedMemories) {
|
|
15122
15163
|
for (const [file] of currentHashes) {
|
|
15123
|
-
const parsed = parseMemoryFile(readFileSync20(
|
|
15164
|
+
const parsed = parseMemoryFile(readFileSync20(join24(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
15124
15165
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
15125
15166
|
}
|
|
15126
15167
|
}
|
|
@@ -15148,14 +15189,14 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
|
|
|
15148
15189
|
lastDownloadHash.set(agent.agent_id, responseHash);
|
|
15149
15190
|
lastLocalFileHash.set(agent.agent_id, localListHash);
|
|
15150
15191
|
if (dbMemories.memories?.length) {
|
|
15151
|
-
|
|
15192
|
+
mkdirSync11(memoryDir, { recursive: true });
|
|
15152
15193
|
let written = 0;
|
|
15153
15194
|
let overwritten = 0;
|
|
15154
15195
|
for (let i = 0; i < dbMemories.memories.length; i++) {
|
|
15155
15196
|
const mem = dbMemories.memories[i];
|
|
15156
15197
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
15157
15198
|
const slug = rawSlug || `memory-${i}`;
|
|
15158
|
-
const filePath =
|
|
15199
|
+
const filePath = join24(memoryDir, `${slug}.md`);
|
|
15159
15200
|
const desired = `---
|
|
15160
15201
|
name: ${JSON.stringify(mem.name)}
|
|
15161
15202
|
type: ${mem.type}
|
|
@@ -15171,10 +15212,10 @@ ${mem.content}
|
|
|
15171
15212
|
} catch {
|
|
15172
15213
|
}
|
|
15173
15214
|
if (existing === desired) continue;
|
|
15174
|
-
|
|
15215
|
+
writeFileSync13(filePath, desired);
|
|
15175
15216
|
overwritten++;
|
|
15176
15217
|
} else {
|
|
15177
|
-
|
|
15218
|
+
writeFileSync13(filePath, desired);
|
|
15178
15219
|
written++;
|
|
15179
15220
|
}
|
|
15180
15221
|
}
|
|
@@ -15193,7 +15234,7 @@ ${mem.content}
|
|
|
15193
15234
|
async function cleanupAgentFiles(codeName, agentDir) {
|
|
15194
15235
|
if (existsSync11(agentDir)) {
|
|
15195
15236
|
try {
|
|
15196
|
-
|
|
15237
|
+
rmSync6(agentDir, { recursive: true, force: true });
|
|
15197
15238
|
log(`Removed provision directory for '${codeName}'`);
|
|
15198
15239
|
} catch (err) {
|
|
15199
15240
|
log(`Failed to remove provision dir for '${codeName}': ${err.message}`);
|
|
@@ -15458,7 +15499,7 @@ function startManager(opts) {
|
|
|
15458
15499
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
15459
15500
|
}
|
|
15460
15501
|
log(
|
|
15461
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
15502
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join24(homedir11(), ".augmented", "manager.log")}`
|
|
15462
15503
|
);
|
|
15463
15504
|
deployMcpAssets();
|
|
15464
15505
|
reapOrphanChannelMcps({ log });
|
|
@@ -15584,14 +15625,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
15584
15625
|
}
|
|
15585
15626
|
}
|
|
15586
15627
|
function deployMcpAssets() {
|
|
15587
|
-
const targetDir =
|
|
15588
|
-
|
|
15628
|
+
const targetDir = join24(homedir11(), ".augmented", "_mcp");
|
|
15629
|
+
mkdirSync11(targetDir, { recursive: true });
|
|
15589
15630
|
const moduleDir = dirname7(fileURLToPath(import.meta.url));
|
|
15590
15631
|
let mcpSourceDir = "";
|
|
15591
15632
|
let dir = moduleDir;
|
|
15592
15633
|
for (let i = 0; i < 6; i++) {
|
|
15593
|
-
const candidate =
|
|
15594
|
-
if (existsSync11(
|
|
15634
|
+
const candidate = join24(dir, "dist", "mcp");
|
|
15635
|
+
if (existsSync11(join24(candidate, "index.js"))) {
|
|
15595
15636
|
mcpSourceDir = candidate;
|
|
15596
15637
|
break;
|
|
15597
15638
|
}
|
|
@@ -15671,8 +15712,8 @@ function deployMcpAssets() {
|
|
|
15671
15712
|
// needs restarting to pick up a token rotation.
|
|
15672
15713
|
"xero.js"
|
|
15673
15714
|
]) {
|
|
15674
|
-
const src =
|
|
15675
|
-
const dst =
|
|
15715
|
+
const src = join24(mcpSourceDir, file);
|
|
15716
|
+
const dst = join24(targetDir, file);
|
|
15676
15717
|
if (!existsSync11(src)) continue;
|
|
15677
15718
|
const before = fileHash(dst);
|
|
15678
15719
|
try {
|
|
@@ -15690,14 +15731,14 @@ function deployMcpAssets() {
|
|
|
15690
15731
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
15691
15732
|
restartRunningChannelMcps(changedBasenames);
|
|
15692
15733
|
}
|
|
15693
|
-
const localMcpPath =
|
|
15734
|
+
const localMcpPath = join24(targetDir, "index.js");
|
|
15694
15735
|
try {
|
|
15695
|
-
const agentsDir =
|
|
15736
|
+
const agentsDir = join24(homedir11(), ".augmented", "agents");
|
|
15696
15737
|
if (existsSync11(agentsDir)) {
|
|
15697
15738
|
for (const entry of readdirSync6(agentsDir, { withFileTypes: true })) {
|
|
15698
15739
|
if (!entry.isDirectory()) continue;
|
|
15699
15740
|
for (const subdir of ["provision", "project"]) {
|
|
15700
|
-
const mcpJsonPath =
|
|
15741
|
+
const mcpJsonPath = join24(agentsDir, entry.name, subdir, ".mcp.json");
|
|
15701
15742
|
try {
|
|
15702
15743
|
const raw = readFileSync20(mcpJsonPath, "utf-8");
|
|
15703
15744
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|
|
@@ -15706,7 +15747,7 @@ function deployMcpAssets() {
|
|
|
15706
15747
|
if (!augServer) continue;
|
|
15707
15748
|
augServer.command = "node";
|
|
15708
15749
|
augServer.args = [localMcpPath];
|
|
15709
|
-
|
|
15750
|
+
writeFileSync13(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
15710
15751
|
log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
|
|
15711
15752
|
} catch {
|
|
15712
15753
|
}
|