@integrity-labs/agt-cli 0.28.448 → 0.28.449
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 +3 -3
- package/dist/{chunk-JUUAHLX5.js → chunk-MDD7H7EP.js} +2 -2
- package/dist/lib/manager-worker.js +4 -4
- package/dist/mcp/slack-channel.js +153 -120
- package/dist/{responsiveness-probe-FJ7TRQE2.js → responsiveness-probe-AIA7ZEBW.js} +58 -1
- package/dist/responsiveness-probe-AIA7ZEBW.js.map +1 -0
- package/package.json +1 -1
- package/dist/responsiveness-probe-FJ7TRQE2.js.map +0 -1
- /package/dist/{chunk-JUUAHLX5.js.map → chunk-MDD7H7EP.js.map} +0 -0
|
@@ -18870,7 +18870,7 @@ var require_filters = __commonJS({
|
|
|
18870
18870
|
return r.copySafeness(str, res);
|
|
18871
18871
|
}
|
|
18872
18872
|
_exports.indent = indent;
|
|
18873
|
-
function
|
|
18873
|
+
function join20(arr, del, attr) {
|
|
18874
18874
|
del = del || "";
|
|
18875
18875
|
if (attr) {
|
|
18876
18876
|
arr = lib.map(arr, function(v) {
|
|
@@ -18879,7 +18879,7 @@ var require_filters = __commonJS({
|
|
|
18879
18879
|
}
|
|
18880
18880
|
return arr.join(del);
|
|
18881
18881
|
}
|
|
18882
|
-
_exports.join =
|
|
18882
|
+
_exports.join = join20;
|
|
18883
18883
|
function last(arr) {
|
|
18884
18884
|
return arr[arr.length - 1];
|
|
18885
18885
|
}
|
|
@@ -36882,8 +36882,36 @@ function applyHotThreadGuard(input) {
|
|
|
36882
36882
|
return { threadTs: void 0, guard: "root_no_hot_thread" };
|
|
36883
36883
|
}
|
|
36884
36884
|
|
|
36885
|
+
// src/slack-hot-thread-telemetry.ts
|
|
36886
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
|
|
36887
|
+
import { join as join10 } from "path";
|
|
36888
|
+
var HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX = "-hot-thread-classifications.json";
|
|
36889
|
+
function hotThreadKey(mode, outcome, proactive) {
|
|
36890
|
+
return `${mode}|${outcome}|${proactive ? "true" : "false"}`;
|
|
36891
|
+
}
|
|
36892
|
+
function recordHotThreadClassification(agentDir, channel, classification) {
|
|
36893
|
+
if (!agentDir || !channel) return;
|
|
36894
|
+
const path = join10(agentDir, `${channel}${HOT_THREAD_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
36895
|
+
let counts = {};
|
|
36896
|
+
try {
|
|
36897
|
+
const parsed = JSON.parse(readFileSync6(path, "utf-8"));
|
|
36898
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
36899
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
36900
|
+
if (typeof v === "number" && Number.isInteger(v) && v >= 0) counts[k] = v;
|
|
36901
|
+
}
|
|
36902
|
+
}
|
|
36903
|
+
} catch {
|
|
36904
|
+
}
|
|
36905
|
+
const key2 = hotThreadKey(classification.mode, classification.outcome, classification.proactive);
|
|
36906
|
+
counts[key2] = (counts[key2] ?? 0) + 1;
|
|
36907
|
+
try {
|
|
36908
|
+
writeFileSync3(path, JSON.stringify(counts), { mode: 384 });
|
|
36909
|
+
} catch {
|
|
36910
|
+
}
|
|
36911
|
+
}
|
|
36912
|
+
|
|
36885
36913
|
// src/restart-confirm.ts
|
|
36886
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as
|
|
36914
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync7, renameSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
36887
36915
|
import { dirname } from "path";
|
|
36888
36916
|
import { randomUUID } from "crypto";
|
|
36889
36917
|
var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
@@ -36903,13 +36931,13 @@ function writeRestartConfirmMarker(filePath, marker) {
|
|
|
36903
36931
|
const dir = dirname(filePath);
|
|
36904
36932
|
if (!existsSync6(dir)) mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
36905
36933
|
const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
36906
|
-
|
|
36934
|
+
writeFileSync4(tmpPath, JSON.stringify(marker) + "\n", { encoding: "utf8", mode: 384 });
|
|
36907
36935
|
renameSync(tmpPath, filePath);
|
|
36908
36936
|
}
|
|
36909
36937
|
function readRestartConfirmMarker(filePath) {
|
|
36910
36938
|
try {
|
|
36911
36939
|
if (!existsSync6(filePath)) return null;
|
|
36912
|
-
const parsed = JSON.parse(
|
|
36940
|
+
const parsed = JSON.parse(readFileSync7(filePath, "utf8"));
|
|
36913
36941
|
if (!parsed || typeof parsed !== "object") return null;
|
|
36914
36942
|
return parsed;
|
|
36915
36943
|
} catch {
|
|
@@ -37054,21 +37082,21 @@ import {
|
|
|
37054
37082
|
ftruncateSync,
|
|
37055
37083
|
mkdirSync as mkdirSync9,
|
|
37056
37084
|
openSync,
|
|
37057
|
-
readFileSync as
|
|
37085
|
+
readFileSync as readFileSync19,
|
|
37058
37086
|
readdirSync as readdirSync5,
|
|
37059
37087
|
renameSync as renameSync5,
|
|
37060
37088
|
statSync as statSync3,
|
|
37061
37089
|
unlinkSync as unlinkSync7,
|
|
37062
37090
|
watch,
|
|
37063
|
-
writeFileSync as
|
|
37091
|
+
writeFileSync as writeFileSync14,
|
|
37064
37092
|
writeSync
|
|
37065
37093
|
} from "fs";
|
|
37066
|
-
import { basename, join as
|
|
37094
|
+
import { basename, join as join19, resolve as resolve2 } from "path";
|
|
37067
37095
|
import { homedir as homedir6 } from "os";
|
|
37068
37096
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
|
|
37069
37097
|
|
|
37070
37098
|
// src/slack-thread-store.ts
|
|
37071
|
-
import { mkdirSync as mkdirSync3, readFileSync as
|
|
37099
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "fs";
|
|
37072
37100
|
import { dirname as dirname2 } from "path";
|
|
37073
37101
|
function isParticipatingThread(entry) {
|
|
37074
37102
|
if (!entry) return false;
|
|
@@ -37083,7 +37111,7 @@ function loadThreadStore(filePath, opts = {}) {
|
|
|
37083
37111
|
const ttlMs = ttlDays * 24 * 60 * 60 * 1e3;
|
|
37084
37112
|
let raw;
|
|
37085
37113
|
try {
|
|
37086
|
-
raw =
|
|
37114
|
+
raw = readFileSync8(filePath, "utf-8");
|
|
37087
37115
|
} catch {
|
|
37088
37116
|
return { threads: /* @__PURE__ */ new Map(), pruned: 0 };
|
|
37089
37117
|
}
|
|
@@ -37132,7 +37160,7 @@ function createThreadPersister(opts) {
|
|
|
37132
37160
|
const writeNow = (snap) => {
|
|
37133
37161
|
try {
|
|
37134
37162
|
mkdirSync3(dirname2(opts.filePath), { recursive: true });
|
|
37135
|
-
|
|
37163
|
+
writeFileSync5(opts.filePath, serializeThreadStore(snap), "utf-8");
|
|
37136
37164
|
lastWriteAt = Date.now();
|
|
37137
37165
|
} catch (err) {
|
|
37138
37166
|
opts.onError?.(
|
|
@@ -37184,7 +37212,7 @@ function isThreadEntry(value) {
|
|
|
37184
37212
|
}
|
|
37185
37213
|
|
|
37186
37214
|
// src/dm-restart-notice.ts
|
|
37187
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
37215
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
37188
37216
|
import { dirname as dirname3 } from "path";
|
|
37189
37217
|
var RECENT_DM_VERSION = 1;
|
|
37190
37218
|
var DEFAULT_RECENT_DM_TTL_MS = 30 * 60 * 1e3;
|
|
@@ -37208,7 +37236,7 @@ function loadRecentDms(filePath, opts = {}) {
|
|
|
37208
37236
|
const ttlMs = opts.ttlMs ?? DEFAULT_RECENT_DM_TTL_MS;
|
|
37209
37237
|
let raw;
|
|
37210
37238
|
try {
|
|
37211
|
-
raw =
|
|
37239
|
+
raw = readFileSync9(filePath, "utf-8");
|
|
37212
37240
|
} catch (err) {
|
|
37213
37241
|
const code = err.code;
|
|
37214
37242
|
if (code !== "ENOENT") {
|
|
@@ -37248,7 +37276,7 @@ function createRecentDmPersister(opts) {
|
|
|
37248
37276
|
const writeNow = (snap) => {
|
|
37249
37277
|
try {
|
|
37250
37278
|
mkdirSync4(dirname3(opts.filePath), { recursive: true });
|
|
37251
|
-
|
|
37279
|
+
writeFileSync6(opts.filePath, serializeRecentDms(snap), "utf-8");
|
|
37252
37280
|
lastWriteAt = Date.now();
|
|
37253
37281
|
} catch (err) {
|
|
37254
37282
|
opts.onError?.(`dm-restart-notice: failed to persist recent-DMs: ${err.message}`);
|
|
@@ -37293,7 +37321,7 @@ var CHANNEL_ADD_RESTART_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
|
37293
37321
|
function readChannelAddRestartMarker(filePath) {
|
|
37294
37322
|
let raw;
|
|
37295
37323
|
try {
|
|
37296
|
-
raw =
|
|
37324
|
+
raw = readFileSync9(filePath, "utf-8");
|
|
37297
37325
|
} catch {
|
|
37298
37326
|
return null;
|
|
37299
37327
|
}
|
|
@@ -37351,13 +37379,13 @@ async function runOrRetry(fn, opts) {
|
|
|
37351
37379
|
}
|
|
37352
37380
|
|
|
37353
37381
|
// src/turn-initiator-marker.ts
|
|
37354
|
-
import { writeFileSync as
|
|
37355
|
-
import { dirname as dirname4, join as
|
|
37382
|
+
import { writeFileSync as writeFileSync7, readFileSync as readFileSync10, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
|
|
37383
|
+
import { dirname as dirname4, join as join11 } from "path";
|
|
37356
37384
|
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
37357
37385
|
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
37358
37386
|
var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
|
|
37359
37387
|
function turnInitiatorLedgerPath(singleSlotFile) {
|
|
37360
|
-
return
|
|
37388
|
+
return join11(dirname4(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
|
|
37361
37389
|
}
|
|
37362
37390
|
function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
|
|
37363
37391
|
const now = marker.ts;
|
|
@@ -37382,13 +37410,13 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
|
|
|
37382
37410
|
const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
|
|
37383
37411
|
let existing = null;
|
|
37384
37412
|
try {
|
|
37385
|
-
const parsed = JSON.parse(
|
|
37413
|
+
const parsed = JSON.parse(readFileSync10(ledgerFile, "utf8"));
|
|
37386
37414
|
if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
|
|
37387
37415
|
} catch {
|
|
37388
37416
|
}
|
|
37389
37417
|
const next = foldTurnInitiatorLedger(existing, marker);
|
|
37390
37418
|
const tmp = `${ledgerFile}.tmp`;
|
|
37391
|
-
|
|
37419
|
+
writeFileSync7(tmp, JSON.stringify(next), "utf8");
|
|
37392
37420
|
renameSync2(tmp, ledgerFile);
|
|
37393
37421
|
}
|
|
37394
37422
|
function writeTurnInitiatorMarker(input) {
|
|
@@ -37398,7 +37426,7 @@ function writeTurnInitiatorMarker(input) {
|
|
|
37398
37426
|
mkdirSync5(dirname4(file), { recursive: true });
|
|
37399
37427
|
const marker = { ...input, ts: Date.now() };
|
|
37400
37428
|
const tmp = `${file}.tmp`;
|
|
37401
|
-
|
|
37429
|
+
writeFileSync7(tmp, JSON.stringify(marker), "utf8");
|
|
37402
37430
|
renameSync2(tmp, file);
|
|
37403
37431
|
try {
|
|
37404
37432
|
updateTurnInitiatorLedger(file, marker);
|
|
@@ -37409,7 +37437,7 @@ function writeTurnInitiatorMarker(input) {
|
|
|
37409
37437
|
}
|
|
37410
37438
|
|
|
37411
37439
|
// src/slack-bot-photo.ts
|
|
37412
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as
|
|
37440
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "fs";
|
|
37413
37441
|
import { dirname as dirname5 } from "path";
|
|
37414
37442
|
async function applyBotPhoto(opts) {
|
|
37415
37443
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
@@ -37419,7 +37447,7 @@ async function applyBotPhoto(opts) {
|
|
|
37419
37447
|
const { token, avatarUrl, markerPath } = opts;
|
|
37420
37448
|
if (markerPath && existsSync7(markerPath)) {
|
|
37421
37449
|
try {
|
|
37422
|
-
if (
|
|
37450
|
+
if (readFileSync11(markerPath, "utf-8").trim() === avatarUrl) {
|
|
37423
37451
|
return { status: "skipped-unchanged" };
|
|
37424
37452
|
}
|
|
37425
37453
|
} catch {
|
|
@@ -37461,7 +37489,7 @@ async function applyBotPhoto(opts) {
|
|
|
37461
37489
|
if (markerPath) {
|
|
37462
37490
|
try {
|
|
37463
37491
|
mkdirSync6(dirname5(markerPath), { recursive: true, mode: 448 });
|
|
37464
|
-
|
|
37492
|
+
writeFileSync8(markerPath, avatarUrl, { mode: 384 });
|
|
37465
37493
|
} catch {
|
|
37466
37494
|
}
|
|
37467
37495
|
}
|
|
@@ -37544,8 +37572,8 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
37544
37572
|
}
|
|
37545
37573
|
|
|
37546
37574
|
// src/inbound-lane-telemetry.ts
|
|
37547
|
-
import { readFileSync as
|
|
37548
|
-
import { join as
|
|
37575
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "fs";
|
|
37576
|
+
import { join as join12 } from "path";
|
|
37549
37577
|
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
37550
37578
|
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
37551
37579
|
var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
|
|
@@ -37562,10 +37590,10 @@ function isSuspectedMisclassification(lane, source) {
|
|
|
37562
37590
|
}
|
|
37563
37591
|
function recordLaneClassification(agentDir, channel, classification) {
|
|
37564
37592
|
if (!agentDir) return;
|
|
37565
|
-
const path =
|
|
37593
|
+
const path = join12(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
37566
37594
|
let counts = {};
|
|
37567
37595
|
try {
|
|
37568
|
-
const parsed = JSON.parse(
|
|
37596
|
+
const parsed = JSON.parse(readFileSync12(path, "utf-8"));
|
|
37569
37597
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
37570
37598
|
} catch {
|
|
37571
37599
|
}
|
|
@@ -37575,14 +37603,14 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
37575
37603
|
counts[SUSPECTED_MISCLASSIFICATION_KEY] = (counts[SUSPECTED_MISCLASSIFICATION_KEY] ?? 0) + 1;
|
|
37576
37604
|
}
|
|
37577
37605
|
try {
|
|
37578
|
-
|
|
37606
|
+
writeFileSync9(path, JSON.stringify(counts), { mode: 384 });
|
|
37579
37607
|
} catch {
|
|
37580
37608
|
}
|
|
37581
37609
|
}
|
|
37582
37610
|
|
|
37583
37611
|
// src/slack-inbound-registry.ts
|
|
37584
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
37585
|
-
import { join as
|
|
37612
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync13 } from "fs";
|
|
37613
|
+
import { join as join13 } from "path";
|
|
37586
37614
|
var DEFAULT_MAX_ENTRIES = 500;
|
|
37587
37615
|
var DEFAULT_CLEARED_TTL_MS = 6 * 60 * 60 * 1e3;
|
|
37588
37616
|
function entryKey(channel, messageTs) {
|
|
@@ -37703,7 +37731,7 @@ function createInboundRegistry(opts = {}) {
|
|
|
37703
37731
|
if (name.includes(".retry-") || name.includes(".poison")) continue;
|
|
37704
37732
|
let marker;
|
|
37705
37733
|
try {
|
|
37706
|
-
marker = JSON.parse(
|
|
37734
|
+
marker = JSON.parse(readFileSync13(join13(dir, name), "utf-8"));
|
|
37707
37735
|
} catch {
|
|
37708
37736
|
continue;
|
|
37709
37737
|
}
|
|
@@ -37748,17 +37776,17 @@ function slackInboundId(channel, threadTs, messageTs) {
|
|
|
37748
37776
|
}
|
|
37749
37777
|
|
|
37750
37778
|
// src/inbound-delivery-ledger.ts
|
|
37751
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as
|
|
37752
|
-
import { join as
|
|
37779
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as readFileSync14, renameSync as renameSync3, writeFileSync as writeFileSync10 } from "fs";
|
|
37780
|
+
import { join as join14 } from "path";
|
|
37753
37781
|
function safeInboundId(inboundId) {
|
|
37754
37782
|
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
37755
37783
|
}
|
|
37756
37784
|
var defaultDeps = {
|
|
37757
37785
|
mkdir: (dir) => mkdirSync7(dir, { recursive: true }),
|
|
37758
|
-
writeFile: (path, data) =>
|
|
37786
|
+
writeFile: (path, data) => writeFileSync10(path, data, "utf8"),
|
|
37759
37787
|
rename: (from, to) => renameSync3(from, to),
|
|
37760
37788
|
readdir: (dir) => readdirSync4(dir),
|
|
37761
|
-
readFile: (path) =>
|
|
37789
|
+
readFile: (path) => readFileSync14(path, "utf8"),
|
|
37762
37790
|
exists: (path) => existsSync8(path)
|
|
37763
37791
|
};
|
|
37764
37792
|
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
@@ -37767,7 +37795,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
|
37767
37795
|
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
|
|
37768
37796
|
try {
|
|
37769
37797
|
deps.mkdir(dir);
|
|
37770
|
-
const final =
|
|
37798
|
+
const final = join14(dir, `${safe}.json`);
|
|
37771
37799
|
const tmp = `${final}.tmp`;
|
|
37772
37800
|
deps.writeFile(tmp, JSON.stringify(record2));
|
|
37773
37801
|
deps.rename(tmp, final);
|
|
@@ -37923,8 +37951,8 @@ function describeChannelRedirect(input) {
|
|
|
37923
37951
|
}
|
|
37924
37952
|
|
|
37925
37953
|
// src/slack-reply-binding-telemetry.ts
|
|
37926
|
-
import { readFileSync as
|
|
37927
|
-
import { join as
|
|
37954
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync11 } from "fs";
|
|
37955
|
+
import { join as join15 } from "path";
|
|
37928
37956
|
var REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX = "-reply-binding-classifications.json";
|
|
37929
37957
|
var UNKNOWN_INBOUND_ID_KEY = "unknown_inbound_id";
|
|
37930
37958
|
var CHANNEL_MISTARGET_CORRECTED_KEY = "channel_mistarget_corrected";
|
|
@@ -37939,10 +37967,10 @@ function slackReplyBindingMode() {
|
|
|
37939
37967
|
}
|
|
37940
37968
|
function recordReplyBindingClassification(agentDir, channel, input) {
|
|
37941
37969
|
if (!agentDir) return;
|
|
37942
|
-
const path =
|
|
37970
|
+
const path = join15(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
37943
37971
|
let counts = {};
|
|
37944
37972
|
try {
|
|
37945
|
-
const parsed = JSON.parse(
|
|
37973
|
+
const parsed = JSON.parse(readFileSync15(path, "utf-8"));
|
|
37946
37974
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
37947
37975
|
} catch {
|
|
37948
37976
|
}
|
|
@@ -37951,32 +37979,32 @@ function recordReplyBindingClassification(agentDir, channel, input) {
|
|
|
37951
37979
|
counts[UNKNOWN_INBOUND_ID_KEY] = (counts[UNKNOWN_INBOUND_ID_KEY] ?? 0) + 1;
|
|
37952
37980
|
}
|
|
37953
37981
|
try {
|
|
37954
|
-
|
|
37982
|
+
writeFileSync11(path, JSON.stringify(counts), { mode: 384 });
|
|
37955
37983
|
} catch {
|
|
37956
37984
|
}
|
|
37957
37985
|
}
|
|
37958
37986
|
function recordScheduledChannelOverride(agentDir, channel, input) {
|
|
37959
37987
|
if (!agentDir) return;
|
|
37960
|
-
const path =
|
|
37988
|
+
const path = join15(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
37961
37989
|
let counts = {};
|
|
37962
37990
|
try {
|
|
37963
|
-
const parsed = JSON.parse(
|
|
37991
|
+
const parsed = JSON.parse(readFileSync15(path, "utf-8"));
|
|
37964
37992
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
37965
37993
|
} catch {
|
|
37966
37994
|
}
|
|
37967
37995
|
const key2 = input.enforced ? SCHEDULED_CHANNEL_OVERRIDE_BLOCKED_KEY : SCHEDULED_CHANNEL_OVERRIDE_SHADOW_KEY;
|
|
37968
37996
|
counts[key2] = (counts[key2] ?? 0) + 1;
|
|
37969
37997
|
try {
|
|
37970
|
-
|
|
37998
|
+
writeFileSync11(path, JSON.stringify(counts), { mode: 384 });
|
|
37971
37999
|
} catch {
|
|
37972
38000
|
}
|
|
37973
38001
|
}
|
|
37974
38002
|
function recordChannelMistarget(agentDir, channel, input) {
|
|
37975
38003
|
if (!agentDir) return;
|
|
37976
|
-
const path =
|
|
38004
|
+
const path = join15(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
37977
38005
|
let counts = {};
|
|
37978
38006
|
try {
|
|
37979
|
-
const parsed = JSON.parse(
|
|
38007
|
+
const parsed = JSON.parse(readFileSync15(path, "utf-8"));
|
|
37980
38008
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
37981
38009
|
} catch {
|
|
37982
38010
|
}
|
|
@@ -37985,14 +38013,14 @@ function recordChannelMistarget(agentDir, channel, input) {
|
|
|
37985
38013
|
counts[DM_CHANNEL_MISTARGET_KEY] = (counts[DM_CHANNEL_MISTARGET_KEY] ?? 0) + 1;
|
|
37986
38014
|
}
|
|
37987
38015
|
try {
|
|
37988
|
-
|
|
38016
|
+
writeFileSync11(path, JSON.stringify(counts), { mode: 384 });
|
|
37989
38017
|
} catch {
|
|
37990
38018
|
}
|
|
37991
38019
|
}
|
|
37992
38020
|
|
|
37993
38021
|
// src/slack-reply-target-telemetry.ts
|
|
37994
|
-
import { readFileSync as
|
|
37995
|
-
import { join as
|
|
38022
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync12 } from "fs";
|
|
38023
|
+
import { join as join16 } from "path";
|
|
37996
38024
|
var REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX = "-reply-target-classifications.json";
|
|
37997
38025
|
function pendingThreadsBucket(n) {
|
|
37998
38026
|
if (n <= 0) return "0";
|
|
@@ -38025,10 +38053,10 @@ function classifyReplyTarget(input) {
|
|
|
38025
38053
|
}
|
|
38026
38054
|
function recordReplyTargetClassification(agentDir, channel, classification) {
|
|
38027
38055
|
if (!agentDir) return;
|
|
38028
|
-
const path =
|
|
38056
|
+
const path = join16(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
38029
38057
|
let counts = {};
|
|
38030
38058
|
try {
|
|
38031
|
-
const parsed = JSON.parse(
|
|
38059
|
+
const parsed = JSON.parse(readFileSync16(path, "utf-8"));
|
|
38032
38060
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
38033
38061
|
} catch {
|
|
38034
38062
|
}
|
|
@@ -38038,14 +38066,14 @@ function recordReplyTargetClassification(agentDir, channel, classification) {
|
|
|
38038
38066
|
);
|
|
38039
38067
|
counts[key2] = (counts[key2] ?? 0) + 1;
|
|
38040
38068
|
try {
|
|
38041
|
-
|
|
38069
|
+
writeFileSync12(path, JSON.stringify(counts), { mode: 384 });
|
|
38042
38070
|
} catch {
|
|
38043
38071
|
}
|
|
38044
38072
|
}
|
|
38045
38073
|
|
|
38046
38074
|
// src/scheduled-turn-marker.ts
|
|
38047
|
-
import { readFileSync as
|
|
38048
|
-
import { join as
|
|
38075
|
+
import { readFileSync as readFileSync17, unlinkSync as unlinkSync5 } from "fs";
|
|
38076
|
+
import { join as join17 } from "path";
|
|
38049
38077
|
var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
|
|
38050
38078
|
var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
38051
38079
|
function validateScheduledTurnMarker(raw, now, maxAgeMs = SCHEDULED_TURN_MAX_AGE_MS) {
|
|
@@ -38083,7 +38111,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
|
|
|
38083
38111
|
if (!agentDir) return null;
|
|
38084
38112
|
try {
|
|
38085
38113
|
const raw = JSON.parse(
|
|
38086
|
-
|
|
38114
|
+
readFileSync17(join17(agentDir, SCHEDULED_TURN_MARKER_FILENAME2), "utf8")
|
|
38087
38115
|
);
|
|
38088
38116
|
return validateScheduledTurnMarker(raw, now);
|
|
38089
38117
|
} catch {
|
|
@@ -38093,7 +38121,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
|
|
|
38093
38121
|
function clearScheduledTurnMarker(agentDir) {
|
|
38094
38122
|
if (!agentDir) return;
|
|
38095
38123
|
try {
|
|
38096
|
-
unlinkSync5(
|
|
38124
|
+
unlinkSync5(join17(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
|
|
38097
38125
|
} catch {
|
|
38098
38126
|
}
|
|
38099
38127
|
}
|
|
@@ -38891,14 +38919,14 @@ async function actuateHostRestart(opts) {
|
|
|
38891
38919
|
import {
|
|
38892
38920
|
existsSync as existsSync9,
|
|
38893
38921
|
mkdirSync as mkdirSync8,
|
|
38894
|
-
readFileSync as
|
|
38922
|
+
readFileSync as readFileSync18,
|
|
38895
38923
|
renameSync as renameSync4,
|
|
38896
38924
|
statSync as statSync2,
|
|
38897
38925
|
unlinkSync as unlinkSync6,
|
|
38898
38926
|
utimesSync,
|
|
38899
|
-
writeFileSync as
|
|
38927
|
+
writeFileSync as writeFileSync13
|
|
38900
38928
|
} from "fs";
|
|
38901
|
-
import { join as
|
|
38929
|
+
import { join as join18 } from "path";
|
|
38902
38930
|
var STALE_LOCK_MS = 9e4;
|
|
38903
38931
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
38904
38932
|
function defaultIsPidAlive(pid) {
|
|
@@ -38921,7 +38949,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
38921
38949
|
const nowMs = options.nowMs ?? (() => Date.now());
|
|
38922
38950
|
const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
|
|
38923
38951
|
const staleMs = options.staleMs ?? STALE_LOCK_MS;
|
|
38924
|
-
const path =
|
|
38952
|
+
const path = join18(agentDir, basename2);
|
|
38925
38953
|
const existing = readLockHolder(path);
|
|
38926
38954
|
if (existing) {
|
|
38927
38955
|
if (existing.pid === selfPid) {
|
|
@@ -38938,7 +38966,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
38938
38966
|
mkdirSync8(agentDir, { recursive: true, mode: 448 });
|
|
38939
38967
|
const tmpPath = `${path}.${selfPid}.tmp`;
|
|
38940
38968
|
const payload = { pid: selfPid, started_at: now() };
|
|
38941
|
-
|
|
38969
|
+
writeFileSync13(tmpPath, JSON.stringify(payload), { mode: 384 });
|
|
38942
38970
|
renameSync4(tmpPath, path);
|
|
38943
38971
|
return { kind: "acquired", path };
|
|
38944
38972
|
}
|
|
@@ -38988,7 +39016,7 @@ function defaultLockMtimeMs(path) {
|
|
|
38988
39016
|
function readLockHolder(path) {
|
|
38989
39017
|
if (!existsSync9(path)) return null;
|
|
38990
39018
|
try {
|
|
38991
|
-
const raw =
|
|
39019
|
+
const raw = readFileSync18(path, "utf8");
|
|
38992
39020
|
const parsed = JSON.parse(raw);
|
|
38993
39021
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
38994
39022
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -39394,8 +39422,8 @@ var SLACK_TEAM_PEER_USER_IDS = parseTeamPeerUserIdsEnv(
|
|
|
39394
39422
|
process.env.SLACK_TEAM_PEER_USER_IDS
|
|
39395
39423
|
);
|
|
39396
39424
|
var PEER_HINT_SEEN = /* @__PURE__ */ new Set();
|
|
39397
|
-
var SLACK_AGENT_DIR = AGENT_CODE_NAME ?
|
|
39398
|
-
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ?
|
|
39425
|
+
var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join19(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
|
|
39426
|
+
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
|
|
39399
39427
|
var liveAllowedUsersCache = null;
|
|
39400
39428
|
function readLiveAllowedUsers() {
|
|
39401
39429
|
if (!SLACK_MCP_CONFIG_PATH) return null;
|
|
@@ -39405,7 +39433,7 @@ function readLiveAllowedUsers() {
|
|
|
39405
39433
|
return liveAllowedUsersCache.value;
|
|
39406
39434
|
}
|
|
39407
39435
|
const value = extractAllowedUsersFromMcpJson(
|
|
39408
|
-
|
|
39436
|
+
readFileSync19(SLACK_MCP_CONFIG_PATH, "utf-8")
|
|
39409
39437
|
);
|
|
39410
39438
|
if (value === null) return null;
|
|
39411
39439
|
liveAllowedUsersCache = { mtimeMs, value };
|
|
@@ -39426,7 +39454,7 @@ function readLivePingAllowedUsers() {
|
|
|
39426
39454
|
return livePingAllowedUsersCache.value;
|
|
39427
39455
|
}
|
|
39428
39456
|
const value = extractPingAllowedUsersFromMcpJson(
|
|
39429
|
-
|
|
39457
|
+
readFileSync19(SLACK_MCP_CONFIG_PATH, "utf-8")
|
|
39430
39458
|
);
|
|
39431
39459
|
if (value === null) return null;
|
|
39432
39460
|
livePingAllowedUsersCache = { mtimeMs, value };
|
|
@@ -39438,17 +39466,17 @@ function readLivePingAllowedUsers() {
|
|
|
39438
39466
|
function getEffectivePingAllowedUsers() {
|
|
39439
39467
|
return readLivePingAllowedUsers() ?? PING_ALLOWED_USERS;
|
|
39440
39468
|
}
|
|
39441
|
-
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ?
|
|
39442
|
-
var SLACK_RESTART_CONTEXT_DIR = SLACK_AGENT_DIR ?
|
|
39443
|
-
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
39444
|
-
var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ?
|
|
39445
|
-
var SLACK_DELIVERY_LEDGER_DIR = SLACK_AGENT_DIR ?
|
|
39469
|
+
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
|
|
39470
|
+
var SLACK_RESTART_CONTEXT_DIR = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-restart-context") : null;
|
|
39471
|
+
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
|
|
39472
|
+
var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, ".agt-slack-recovery-ledger") : null;
|
|
39473
|
+
var SLACK_DELIVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
|
|
39446
39474
|
var slackInboundRegistry = createInboundRegistry();
|
|
39447
|
-
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ?
|
|
39448
|
-
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ?
|
|
39449
|
-
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ?
|
|
39475
|
+
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
|
|
39476
|
+
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-recent-dms.json") : null;
|
|
39477
|
+
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-channel-add-restart.json") : null;
|
|
39450
39478
|
var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
|
|
39451
|
-
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ?
|
|
39479
|
+
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
|
|
39452
39480
|
function redactSlackId(id) {
|
|
39453
39481
|
if (!id) return "<none>";
|
|
39454
39482
|
return createHash2("sha256").update(id).digest("hex").slice(0, 8);
|
|
@@ -39459,7 +39487,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
|
|
|
39459
39487
|
}
|
|
39460
39488
|
function slackPendingInboundPath(channel, threadTs, messageTs) {
|
|
39461
39489
|
if (!SLACK_PENDING_INBOUND_DIR) return null;
|
|
39462
|
-
return
|
|
39490
|
+
return join19(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
|
|
39463
39491
|
}
|
|
39464
39492
|
function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false, discretionary = false, payload) {
|
|
39465
39493
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
@@ -39482,7 +39510,7 @@ function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undelivera
|
|
|
39482
39510
|
};
|
|
39483
39511
|
try {
|
|
39484
39512
|
mkdirSync9(SLACK_PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
|
|
39485
|
-
|
|
39513
|
+
writeFileSync14(path, JSON.stringify(marker), { mode: 384 });
|
|
39486
39514
|
} catch (err) {
|
|
39487
39515
|
process.stderr.write(
|
|
39488
39516
|
`slack-channel(${AGENT_CODE_NAME}): pending-inbound marker write failed: ${err.message}
|
|
@@ -39510,7 +39538,7 @@ function rewriteSlackMarkerInPlace(path, marker) {
|
|
|
39510
39538
|
function markSlackMarkerSeenInPlace(fullPath) {
|
|
39511
39539
|
let marker;
|
|
39512
39540
|
try {
|
|
39513
|
-
marker = JSON.parse(
|
|
39541
|
+
marker = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
39514
39542
|
} catch {
|
|
39515
39543
|
return;
|
|
39516
39544
|
}
|
|
@@ -39524,7 +39552,7 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
|
|
|
39524
39552
|
if (!path) return;
|
|
39525
39553
|
let marker;
|
|
39526
39554
|
try {
|
|
39527
|
-
marker = JSON.parse(
|
|
39555
|
+
marker = JSON.parse(readFileSync19(path, "utf-8"));
|
|
39528
39556
|
} catch {
|
|
39529
39557
|
return;
|
|
39530
39558
|
}
|
|
@@ -39535,7 +39563,7 @@ function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
|
|
|
39535
39563
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
39536
39564
|
if (!path || !existsSync10(path)) return null;
|
|
39537
39565
|
try {
|
|
39538
|
-
return JSON.parse(
|
|
39566
|
+
return JSON.parse(readFileSync19(path, "utf-8"));
|
|
39539
39567
|
} catch {
|
|
39540
39568
|
return null;
|
|
39541
39569
|
}
|
|
@@ -39651,7 +39679,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply, arrivedWhi
|
|
|
39651
39679
|
let paneLogFreshAgeMs = null;
|
|
39652
39680
|
if (SLACK_AGENT_DIR) {
|
|
39653
39681
|
try {
|
|
39654
|
-
const paneMtimeMs = statSync3(
|
|
39682
|
+
const paneMtimeMs = statSync3(join19(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
39655
39683
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
39656
39684
|
} catch {
|
|
39657
39685
|
}
|
|
@@ -39684,7 +39712,7 @@ function __resetSlackBusyAckNoticeThrottle() {
|
|
|
39684
39712
|
function clearSlackMarkerFileWithHeal(fullPath) {
|
|
39685
39713
|
let marker = null;
|
|
39686
39714
|
try {
|
|
39687
|
-
marker = JSON.parse(
|
|
39715
|
+
marker = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
39688
39716
|
} catch {
|
|
39689
39717
|
}
|
|
39690
39718
|
if (marker && decideRecoveryHeal({
|
|
@@ -39702,7 +39730,7 @@ function clearSlackMarkerFileWithHeal(fullPath) {
|
|
|
39702
39730
|
function markSlackMarkerSeenWithHeal(fullPath) {
|
|
39703
39731
|
let marker = null;
|
|
39704
39732
|
try {
|
|
39705
|
-
marker = JSON.parse(
|
|
39733
|
+
marker = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
39706
39734
|
} catch {
|
|
39707
39735
|
return;
|
|
39708
39736
|
}
|
|
@@ -39771,10 +39799,10 @@ function slackNextRetryName(filename) {
|
|
|
39771
39799
|
async function processSlackRecoveryOutboxFile(filename) {
|
|
39772
39800
|
if (!SLACK_RECOVERY_OUTBOX_DIR) return;
|
|
39773
39801
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
39774
|
-
const fullPath =
|
|
39802
|
+
const fullPath = join19(SLACK_RECOVERY_OUTBOX_DIR, filename);
|
|
39775
39803
|
let payload;
|
|
39776
39804
|
try {
|
|
39777
|
-
payload = JSON.parse(
|
|
39805
|
+
payload = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
39778
39806
|
} catch (err) {
|
|
39779
39807
|
process.stderr.write(
|
|
39780
39808
|
`slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
|
|
@@ -39878,7 +39906,7 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
39878
39906
|
const next = slackNextRetryName(filename);
|
|
39879
39907
|
if (next) {
|
|
39880
39908
|
try {
|
|
39881
|
-
renameSync5(fullPath,
|
|
39909
|
+
renameSync5(fullPath, join19(SLACK_RECOVERY_OUTBOX_DIR, next.next));
|
|
39882
39910
|
if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
|
|
39883
39911
|
process.stderr.write(
|
|
39884
39912
|
`slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -39918,7 +39946,7 @@ function scanSlackRecoveryRetries() {
|
|
|
39918
39946
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
39919
39947
|
let mtimeMs;
|
|
39920
39948
|
try {
|
|
39921
|
-
mtimeMs = statSync3(
|
|
39949
|
+
mtimeMs = statSync3(join19(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
39922
39950
|
} catch {
|
|
39923
39951
|
continue;
|
|
39924
39952
|
}
|
|
@@ -39948,7 +39976,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
39948
39976
|
const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
39949
39977
|
if (event !== "rename" || !filename) return;
|
|
39950
39978
|
if (!isFirstAttemptSlackOutboxFile(filename)) return;
|
|
39951
|
-
if (existsSync10(
|
|
39979
|
+
if (existsSync10(join19(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
|
|
39952
39980
|
void processSlackRecoveryOutboxFile(filename);
|
|
39953
39981
|
}
|
|
39954
39982
|
});
|
|
@@ -39963,7 +39991,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
39963
39991
|
retryTimer.unref?.();
|
|
39964
39992
|
}
|
|
39965
39993
|
startSlackRecoveryOutboxWatcher();
|
|
39966
|
-
var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
39994
|
+
var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "slack-notice-outbox") : null;
|
|
39967
39995
|
var SLACK_NOTICE_MAX_AGE_MS = 9e4;
|
|
39968
39996
|
var SLACK_NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
|
|
39969
39997
|
async function processSlackNoticeOutboxFile(filename) {
|
|
@@ -39971,7 +39999,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
39971
39999
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
39972
40000
|
if (SLACK_NOTICE_INFLIGHT.has(filename)) return;
|
|
39973
40001
|
SLACK_NOTICE_INFLIGHT.add(filename);
|
|
39974
|
-
const fullPath =
|
|
40002
|
+
const fullPath = join19(SLACK_NOTICE_OUTBOX_DIR, filename);
|
|
39975
40003
|
try {
|
|
39976
40004
|
let mtimeMs;
|
|
39977
40005
|
try {
|
|
@@ -39988,7 +40016,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
39988
40016
|
}
|
|
39989
40017
|
let payload;
|
|
39990
40018
|
try {
|
|
39991
|
-
const parsed = JSON.parse(
|
|
40019
|
+
const parsed = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
39992
40020
|
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
39993
40021
|
payload = parsed;
|
|
39994
40022
|
} catch {
|
|
@@ -40077,7 +40105,7 @@ function startSlackNoticeOutboxWatcher() {
|
|
|
40077
40105
|
try {
|
|
40078
40106
|
const watcher = watch(SLACK_NOTICE_OUTBOX_DIR, (event, filename) => {
|
|
40079
40107
|
if (event !== "rename" || !filename) return;
|
|
40080
|
-
if (existsSync10(
|
|
40108
|
+
if (existsSync10(join19(SLACK_NOTICE_OUTBOX_DIR, filename))) {
|
|
40081
40109
|
void processSlackNoticeOutboxFile(filename);
|
|
40082
40110
|
}
|
|
40083
40111
|
});
|
|
@@ -40114,10 +40142,10 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
40114
40142
|
for (const filename of filenames) {
|
|
40115
40143
|
if (!filename.endsWith(".json")) continue;
|
|
40116
40144
|
if (filename.endsWith(".tmp")) continue;
|
|
40117
|
-
const fullPath =
|
|
40145
|
+
const fullPath = join19(SLACK_PENDING_INBOUND_DIR, filename);
|
|
40118
40146
|
let marker;
|
|
40119
40147
|
try {
|
|
40120
|
-
marker = JSON.parse(
|
|
40148
|
+
marker = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
40121
40149
|
} catch (err) {
|
|
40122
40150
|
process.stderr.write(
|
|
40123
40151
|
`slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
|
|
@@ -40175,13 +40203,13 @@ var slackOrphanSweepTimer = setInterval(() => {
|
|
|
40175
40203
|
checkSlackWatchdogGiveUpNotice();
|
|
40176
40204
|
}, orphanSweepIntervalMs());
|
|
40177
40205
|
slackOrphanSweepTimer.unref?.();
|
|
40178
|
-
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ?
|
|
40206
|
+
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join19(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
40179
40207
|
var slackTrackedProgress = null;
|
|
40180
40208
|
var slackProgressTickRunning = false;
|
|
40181
40209
|
function readSlackProgressHeartbeat() {
|
|
40182
40210
|
if (!SLACK_PROGRESS_HEARTBEAT_PATH || !existsSync10(SLACK_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
40183
40211
|
try {
|
|
40184
|
-
return parseProgressHeartbeat(
|
|
40212
|
+
return parseProgressHeartbeat(readFileSync19(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
40185
40213
|
} catch {
|
|
40186
40214
|
return null;
|
|
40187
40215
|
}
|
|
@@ -40190,7 +40218,7 @@ function seedSlackProgressHeartbeat() {
|
|
|
40190
40218
|
if (!SLACK_PROGRESS_HEARTBEAT_PATH) return;
|
|
40191
40219
|
const tmp = `${SLACK_PROGRESS_HEARTBEAT_PATH}.${process.pid}.tmp`;
|
|
40192
40220
|
try {
|
|
40193
|
-
|
|
40221
|
+
writeFileSync14(tmp, serializeProgressHeartbeat(SEED_PROGRESS_STEP, Date.now()), { mode: 384 });
|
|
40194
40222
|
renameSync5(tmp, SLACK_PROGRESS_HEARTBEAT_PATH);
|
|
40195
40223
|
} catch {
|
|
40196
40224
|
try {
|
|
@@ -40208,7 +40236,7 @@ function findSlackProgressTarget() {
|
|
|
40208
40236
|
if (!name.endsWith(".json")) continue;
|
|
40209
40237
|
let m;
|
|
40210
40238
|
try {
|
|
40211
|
-
m = JSON.parse(
|
|
40239
|
+
m = JSON.parse(readFileSync19(join19(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
|
|
40212
40240
|
} catch {
|
|
40213
40241
|
continue;
|
|
40214
40242
|
}
|
|
@@ -40359,7 +40387,7 @@ function listPendingSlackConversations() {
|
|
|
40359
40387
|
if (!name.endsWith(".json")) continue;
|
|
40360
40388
|
try {
|
|
40361
40389
|
const marker = JSON.parse(
|
|
40362
|
-
|
|
40390
|
+
readFileSync19(join19(SLACK_PENDING_INBOUND_DIR, name), "utf8")
|
|
40363
40391
|
);
|
|
40364
40392
|
if (typeof marker.channel !== "string" || !marker.channel) continue;
|
|
40365
40393
|
if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
|
|
@@ -40411,7 +40439,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply, reason)
|
|
|
40411
40439
|
}
|
|
40412
40440
|
function checkSlackWatchdogGiveUpNotice() {
|
|
40413
40441
|
if (!SLACK_AGENT_DIR) return;
|
|
40414
|
-
const signal = readGiveUpSignal(
|
|
40442
|
+
const signal = readGiveUpSignal(join19(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
40415
40443
|
const signalAtMs = signal?.atMs ?? null;
|
|
40416
40444
|
const act = decideGiveUpNotice({
|
|
40417
40445
|
signalAtMs,
|
|
@@ -40443,7 +40471,7 @@ function readRestartTopicForMarker(filename, channel, threadTs) {
|
|
|
40443
40471
|
if (!SLACK_RESTART_CONTEXT_DIR) return null;
|
|
40444
40472
|
let raw;
|
|
40445
40473
|
try {
|
|
40446
|
-
raw =
|
|
40474
|
+
raw = readFileSync19(join19(SLACK_RESTART_CONTEXT_DIR, filename), "utf-8");
|
|
40447
40475
|
} catch {
|
|
40448
40476
|
return null;
|
|
40449
40477
|
}
|
|
@@ -40452,7 +40480,7 @@ function readRestartTopicForMarker(filename, channel, threadTs) {
|
|
|
40452
40480
|
function removeRestartContextHint(filename) {
|
|
40453
40481
|
if (!SLACK_RESTART_CONTEXT_DIR) return;
|
|
40454
40482
|
try {
|
|
40455
|
-
unlinkSync7(
|
|
40483
|
+
unlinkSync7(join19(SLACK_RESTART_CONTEXT_DIR, filename));
|
|
40456
40484
|
} catch {
|
|
40457
40485
|
}
|
|
40458
40486
|
}
|
|
@@ -40467,7 +40495,7 @@ function clearAllRestartContextHints() {
|
|
|
40467
40495
|
for (const name of names) {
|
|
40468
40496
|
if (!name.endsWith(".json")) continue;
|
|
40469
40497
|
try {
|
|
40470
|
-
unlinkSync7(
|
|
40498
|
+
unlinkSync7(join19(SLACK_RESTART_CONTEXT_DIR, name));
|
|
40471
40499
|
} catch {
|
|
40472
40500
|
}
|
|
40473
40501
|
}
|
|
@@ -40494,10 +40522,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
40494
40522
|
let notified = 0;
|
|
40495
40523
|
for (const filename of filenames) {
|
|
40496
40524
|
if (!filename.endsWith(".json")) continue;
|
|
40497
|
-
const fullPath =
|
|
40525
|
+
const fullPath = join19(SLACK_PENDING_INBOUND_DIR, filename);
|
|
40498
40526
|
let marker;
|
|
40499
40527
|
try {
|
|
40500
|
-
marker = JSON.parse(
|
|
40528
|
+
marker = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
40501
40529
|
} catch {
|
|
40502
40530
|
continue;
|
|
40503
40531
|
}
|
|
@@ -40671,7 +40699,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
|
|
|
40671
40699
|
markSeenAllSlackPendingMarkersForThread2(channel, messageTs);
|
|
40672
40700
|
markSeenSlackPendingMarkerByMessageTs2(channel, messageTs);
|
|
40673
40701
|
}
|
|
40674
|
-
var RESTART_FLAGS_DIR =
|
|
40702
|
+
var RESTART_FLAGS_DIR = join19(homedir6(), ".augmented", "restart-flags");
|
|
40675
40703
|
function actuateHostRestartSlack() {
|
|
40676
40704
|
return actuateHostRestart({
|
|
40677
40705
|
agtHost: AGT_HOST,
|
|
@@ -41276,7 +41304,7 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
41276
41304
|
if (!existsSync10(RESTART_FLAGS_DIR)) {
|
|
41277
41305
|
mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
|
|
41278
41306
|
}
|
|
41279
|
-
const flagPath =
|
|
41307
|
+
const flagPath = join19(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
41280
41308
|
const flag = {
|
|
41281
41309
|
codeName,
|
|
41282
41310
|
source: "slack",
|
|
@@ -41284,7 +41312,7 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
41284
41312
|
reply: confirmReply
|
|
41285
41313
|
};
|
|
41286
41314
|
const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
|
|
41287
|
-
|
|
41315
|
+
writeFileSync14(tmpPath, JSON.stringify(flag) + "\n", "utf8");
|
|
41288
41316
|
renameSync5(tmpPath, flagPath);
|
|
41289
41317
|
}
|
|
41290
41318
|
process.stderr.write(
|
|
@@ -41419,7 +41447,7 @@ async function handleRestartCommand(opts) {
|
|
|
41419
41447
|
if (!existsSync10(RESTART_FLAGS_DIR)) {
|
|
41420
41448
|
mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
|
|
41421
41449
|
}
|
|
41422
|
-
const flagPath =
|
|
41450
|
+
const flagPath = join19(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
41423
41451
|
const flag = {
|
|
41424
41452
|
codeName,
|
|
41425
41453
|
source: "slack",
|
|
@@ -41427,7 +41455,7 @@ async function handleRestartCommand(opts) {
|
|
|
41427
41455
|
reply: { ...confirmReply, message_ts: opts.ts }
|
|
41428
41456
|
};
|
|
41429
41457
|
const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
|
|
41430
|
-
|
|
41458
|
+
writeFileSync14(tmpPath, JSON.stringify(flag) + "\n", "utf8");
|
|
41431
41459
|
renameSync5(tmpPath, flagPath);
|
|
41432
41460
|
}
|
|
41433
41461
|
process.stderr.write(
|
|
@@ -41541,7 +41569,7 @@ var SLACK_HOT_THREAD_WINDOW_MS = parseHotThreadWindowMs(
|
|
|
41541
41569
|
);
|
|
41542
41570
|
function resolveThreadStorePath() {
|
|
41543
41571
|
if (!AGENT_CODE_NAME) return null;
|
|
41544
|
-
return
|
|
41572
|
+
return join19(homedir6(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
|
|
41545
41573
|
}
|
|
41546
41574
|
function parseTtlDays(raw) {
|
|
41547
41575
|
if (!raw) return void 0;
|
|
@@ -41580,9 +41608,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
|
|
|
41580
41608
|
var slackStderrLogStream = null;
|
|
41581
41609
|
if (AGENT_CODE_NAME) {
|
|
41582
41610
|
try {
|
|
41583
|
-
const logDir =
|
|
41611
|
+
const logDir = join19(homedir6(), ".augmented", AGENT_CODE_NAME);
|
|
41584
41612
|
mkdirSync9(logDir, { recursive: true });
|
|
41585
|
-
slackStderrLogStream = createWriteStream(
|
|
41613
|
+
slackStderrLogStream = createWriteStream(join19(logDir, "slack-channel-stderr.log"), {
|
|
41586
41614
|
flags: "a",
|
|
41587
41615
|
mode: 384
|
|
41588
41616
|
});
|
|
@@ -42118,6 +42146,11 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
42118
42146
|
windowMs: SLACK_HOT_THREAD_WINDOW_MS
|
|
42119
42147
|
});
|
|
42120
42148
|
hotGuard = applyHotThreadGuard({ baseThreadTs, forcedRoot, hotThread });
|
|
42149
|
+
recordHotThreadClassification(SLACK_AGENT_DIR, channel, {
|
|
42150
|
+
mode: hotThreadMode,
|
|
42151
|
+
outcome: hotGuard.guard,
|
|
42152
|
+
proactive: proactive === true
|
|
42153
|
+
});
|
|
42121
42154
|
if (hotGuard.guard === "redirected_to_hot_thread") {
|
|
42122
42155
|
process.stderr.write(
|
|
42123
42156
|
`slack-channel(${AGENT_CODE_NAME}): hot_thread_guard mode=${hotThreadMode} applied=${hotThreadMode === "enforce"} channel=${redactSlackId(channel)} hot_thread=${redactSlackId(hotGuard.threadTs)} proactive=${proactive === true} age_ms=${hotThread?.ageMs ?? ""}
|
|
@@ -42475,7 +42508,7 @@ ${result.formatted}` : "No messages in range, or the bot is not a member of this
|
|
|
42475
42508
|
};
|
|
42476
42509
|
}
|
|
42477
42510
|
size = stat2.size;
|
|
42478
|
-
bytes =
|
|
42511
|
+
bytes = readFileSync19(resolvedPath);
|
|
42479
42512
|
} catch (err) {
|
|
42480
42513
|
return {
|
|
42481
42514
|
content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
|
|
@@ -43189,7 +43222,7 @@ async function downloadSlackFile(fileId, codeName) {
|
|
|
43189
43222
|
throw new Error(`refusing to write ${savedPath} outside ${dir}`);
|
|
43190
43223
|
}
|
|
43191
43224
|
mkdirSync9(dir, { recursive: true });
|
|
43192
|
-
|
|
43225
|
+
writeFileSync14(savedPath, bytes, { mode: 384 });
|
|
43193
43226
|
try {
|
|
43194
43227
|
chmodSync(savedPath, 384);
|
|
43195
43228
|
} catch {
|
|
@@ -43258,7 +43291,7 @@ async function replayPendingSlackMarkers() {
|
|
|
43258
43291
|
let paneFreshAgeMs = null;
|
|
43259
43292
|
if (SLACK_AGENT_DIR) {
|
|
43260
43293
|
try {
|
|
43261
|
-
paneFreshAgeMs = Math.max(0, now - statSync3(
|
|
43294
|
+
paneFreshAgeMs = Math.max(0, now - statSync3(join19(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
|
|
43262
43295
|
} catch {
|
|
43263
43296
|
}
|
|
43264
43297
|
}
|
|
@@ -43266,10 +43299,10 @@ async function replayPendingSlackMarkers() {
|
|
|
43266
43299
|
const entries = [];
|
|
43267
43300
|
for (const name of filenames) {
|
|
43268
43301
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
43269
|
-
const fullPath =
|
|
43302
|
+
const fullPath = join19(SLACK_PENDING_INBOUND_DIR, name);
|
|
43270
43303
|
let marker;
|
|
43271
43304
|
try {
|
|
43272
|
-
marker = JSON.parse(
|
|
43305
|
+
marker = JSON.parse(readFileSync19(fullPath, "utf-8"));
|
|
43273
43306
|
} catch {
|
|
43274
43307
|
continue;
|
|
43275
43308
|
}
|
|
@@ -43866,7 +43899,7 @@ async function connectSocketMode() {
|
|
|
43866
43899
|
let paneLogFreshAgeMs = null;
|
|
43867
43900
|
if (SLACK_AGENT_DIR) {
|
|
43868
43901
|
try {
|
|
43869
|
-
const paneMtimeMs = statSync3(
|
|
43902
|
+
const paneMtimeMs = statSync3(join19(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
43870
43903
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
43871
43904
|
} catch {
|
|
43872
43905
|
}
|