@integrity-labs/agt-cli 0.28.329 → 0.28.331
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-AOSBSVNB.js → chunk-4Y3UPOR2.js} +83 -17
- package/dist/chunk-4Y3UPOR2.js.map +1 -0
- package/dist/lib/manager-worker.js +2 -2
- package/dist/mcp/slack-channel.js +115 -86
- package/dist/mcp/teams-channel.js +62 -41
- package/dist/mcp/telegram-channel.js +90 -61
- package/dist/mcp/xero.js +61 -18
- package/package.json +1 -1
- package/dist/chunk-AOSBSVNB.js.map +0 -1
|
@@ -16199,6 +16199,29 @@ function clearOldestSlackPendingMarkerInChannel(dir, channel, clear = defaultCle
|
|
|
16199
16199
|
}
|
|
16200
16200
|
}
|
|
16201
16201
|
|
|
16202
|
+
// src/recovery-ledger.ts
|
|
16203
|
+
import { existsSync as existsSync5, unlinkSync as unlinkSync2 } from "fs";
|
|
16204
|
+
import { join as join7 } from "path";
|
|
16205
|
+
function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p) => existsSync5(p)) {
|
|
16206
|
+
if (!ledgerDir || !markerName) return false;
|
|
16207
|
+
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
|
|
16208
|
+
try {
|
|
16209
|
+
return exists(join7(ledgerDir, markerName));
|
|
16210
|
+
} catch {
|
|
16211
|
+
return false;
|
|
16212
|
+
}
|
|
16213
|
+
}
|
|
16214
|
+
function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p) => {
|
|
16215
|
+
if (existsSync5(p)) unlinkSync2(p);
|
|
16216
|
+
}) {
|
|
16217
|
+
if (!ledgerDir || !markerName) return;
|
|
16218
|
+
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
|
|
16219
|
+
try {
|
|
16220
|
+
unlink(join7(ledgerDir, markerName));
|
|
16221
|
+
} catch {
|
|
16222
|
+
}
|
|
16223
|
+
}
|
|
16224
|
+
|
|
16202
16225
|
// src/channel-progress.ts
|
|
16203
16226
|
function channelLiveProgressEnabled() {
|
|
16204
16227
|
return resolveHostBooleanFlag({
|
|
@@ -16390,7 +16413,7 @@ function resolveReplyThreadTs(input) {
|
|
|
16390
16413
|
}
|
|
16391
16414
|
|
|
16392
16415
|
// src/restart-confirm.ts
|
|
16393
|
-
import { existsSync as
|
|
16416
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
16394
16417
|
import { dirname } from "path";
|
|
16395
16418
|
import { randomUUID } from "crypto";
|
|
16396
16419
|
var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
@@ -16408,14 +16431,14 @@ function buildBackOnlineText(name) {
|
|
|
16408
16431
|
}
|
|
16409
16432
|
function writeRestartConfirmMarker(filePath, marker) {
|
|
16410
16433
|
const dir = dirname(filePath);
|
|
16411
|
-
if (!
|
|
16434
|
+
if (!existsSync6(dir)) mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
16412
16435
|
const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
16413
16436
|
writeFileSync3(tmpPath, JSON.stringify(marker) + "\n", { encoding: "utf8", mode: 384 });
|
|
16414
16437
|
renameSync(tmpPath, filePath);
|
|
16415
16438
|
}
|
|
16416
16439
|
function readRestartConfirmMarker(filePath) {
|
|
16417
16440
|
try {
|
|
16418
|
-
if (!
|
|
16441
|
+
if (!existsSync6(filePath)) return null;
|
|
16419
16442
|
const parsed = JSON.parse(readFileSync4(filePath, "utf8"));
|
|
16420
16443
|
if (!parsed || typeof parsed !== "object") return null;
|
|
16421
16444
|
return parsed;
|
|
@@ -16425,7 +16448,7 @@ function readRestartConfirmMarker(filePath) {
|
|
|
16425
16448
|
}
|
|
16426
16449
|
function clearRestartConfirmMarker(filePath) {
|
|
16427
16450
|
try {
|
|
16428
|
-
if (
|
|
16451
|
+
if (existsSync6(filePath)) unlinkSync3(filePath);
|
|
16429
16452
|
} catch {
|
|
16430
16453
|
}
|
|
16431
16454
|
}
|
|
@@ -16527,7 +16550,7 @@ import {
|
|
|
16527
16550
|
chmodSync,
|
|
16528
16551
|
closeSync,
|
|
16529
16552
|
createWriteStream,
|
|
16530
|
-
existsSync as
|
|
16553
|
+
existsSync as existsSync9,
|
|
16531
16554
|
ftruncateSync,
|
|
16532
16555
|
mkdirSync as mkdirSync8,
|
|
16533
16556
|
openSync,
|
|
@@ -16535,12 +16558,12 @@ import {
|
|
|
16535
16558
|
readdirSync as readdirSync4,
|
|
16536
16559
|
renameSync as renameSync4,
|
|
16537
16560
|
statSync as statSync2,
|
|
16538
|
-
unlinkSync as
|
|
16561
|
+
unlinkSync as unlinkSync7,
|
|
16539
16562
|
watch,
|
|
16540
16563
|
writeFileSync as writeFileSync12,
|
|
16541
16564
|
writeSync
|
|
16542
16565
|
} from "fs";
|
|
16543
|
-
import { basename, join as
|
|
16566
|
+
import { basename, join as join15, resolve as resolve2 } from "path";
|
|
16544
16567
|
import { homedir as homedir4 } from "os";
|
|
16545
16568
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
|
|
16546
16569
|
|
|
@@ -16661,7 +16684,7 @@ function isThreadEntry(value) {
|
|
|
16661
16684
|
}
|
|
16662
16685
|
|
|
16663
16686
|
// src/dm-restart-notice.ts
|
|
16664
|
-
import { mkdirSync as mkdirSync4, readFileSync as readFileSync6, unlinkSync as
|
|
16687
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync6, unlinkSync as unlinkSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
16665
16688
|
import { dirname as dirname3 } from "path";
|
|
16666
16689
|
var RECENT_DM_VERSION = 1;
|
|
16667
16690
|
var DEFAULT_RECENT_DM_TTL_MS = 30 * 60 * 1e3;
|
|
@@ -16795,7 +16818,7 @@ function shouldPostChannelAddNotice(marker, bootMs, maxAgeMs = CHANNEL_ADD_RESTA
|
|
|
16795
16818
|
}
|
|
16796
16819
|
function clearChannelAddRestartMarker(filePath) {
|
|
16797
16820
|
try {
|
|
16798
|
-
|
|
16821
|
+
unlinkSync4(filePath);
|
|
16799
16822
|
} catch {
|
|
16800
16823
|
}
|
|
16801
16824
|
}
|
|
@@ -16829,12 +16852,12 @@ async function runOrRetry(fn, opts) {
|
|
|
16829
16852
|
|
|
16830
16853
|
// src/turn-initiator-marker.ts
|
|
16831
16854
|
import { writeFileSync as writeFileSync6, readFileSync as readFileSync7, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
|
|
16832
|
-
import { dirname as dirname4, join as
|
|
16855
|
+
import { dirname as dirname4, join as join8 } from "path";
|
|
16833
16856
|
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
16834
16857
|
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
16835
16858
|
var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
|
|
16836
16859
|
function turnInitiatorLedgerPath(singleSlotFile) {
|
|
16837
|
-
return
|
|
16860
|
+
return join8(dirname4(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
|
|
16838
16861
|
}
|
|
16839
16862
|
function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
|
|
16840
16863
|
const now = marker.ts;
|
|
@@ -16886,7 +16909,7 @@ function writeTurnInitiatorMarker(input) {
|
|
|
16886
16909
|
}
|
|
16887
16910
|
|
|
16888
16911
|
// src/slack-bot-photo.ts
|
|
16889
|
-
import { existsSync as
|
|
16912
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
16890
16913
|
import { dirname as dirname5 } from "path";
|
|
16891
16914
|
async function applyBotPhoto(opts) {
|
|
16892
16915
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
@@ -16894,7 +16917,7 @@ async function applyBotPhoto(opts) {
|
|
|
16894
16917
|
process.stderr.write(m);
|
|
16895
16918
|
});
|
|
16896
16919
|
const { token, avatarUrl, markerPath } = opts;
|
|
16897
|
-
if (markerPath &&
|
|
16920
|
+
if (markerPath && existsSync7(markerPath)) {
|
|
16898
16921
|
try {
|
|
16899
16922
|
if (readFileSync8(markerPath, "utf-8").trim() === avatarUrl) {
|
|
16900
16923
|
return { status: "skipped-unchanged" };
|
|
@@ -17022,7 +17045,7 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
17022
17045
|
|
|
17023
17046
|
// src/inbound-lane-telemetry.ts
|
|
17024
17047
|
import { readFileSync as readFileSync9, writeFileSync as writeFileSync8 } from "fs";
|
|
17025
|
-
import { join as
|
|
17048
|
+
import { join as join9 } from "path";
|
|
17026
17049
|
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
17027
17050
|
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
17028
17051
|
var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
|
|
@@ -17039,7 +17062,7 @@ function isSuspectedMisclassification(lane, source) {
|
|
|
17039
17062
|
}
|
|
17040
17063
|
function recordLaneClassification(agentDir, channel, classification) {
|
|
17041
17064
|
if (!agentDir) return;
|
|
17042
|
-
const path =
|
|
17065
|
+
const path = join9(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
17043
17066
|
let counts = {};
|
|
17044
17067
|
try {
|
|
17045
17068
|
const parsed = JSON.parse(readFileSync9(path, "utf-8"));
|
|
@@ -17059,7 +17082,7 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
17059
17082
|
|
|
17060
17083
|
// src/slack-inbound-registry.ts
|
|
17061
17084
|
import { readdirSync as readdirSync3, readFileSync as readFileSync10 } from "fs";
|
|
17062
|
-
import { join as
|
|
17085
|
+
import { join as join10 } from "path";
|
|
17063
17086
|
var DEFAULT_MAX_ENTRIES = 500;
|
|
17064
17087
|
var DEFAULT_CLEARED_TTL_MS = 6 * 60 * 60 * 1e3;
|
|
17065
17088
|
function entryKey(channel, messageTs) {
|
|
@@ -17180,7 +17203,7 @@ function createInboundRegistry(opts = {}) {
|
|
|
17180
17203
|
if (name.includes(".retry-") || name.includes(".poison")) continue;
|
|
17181
17204
|
let marker;
|
|
17182
17205
|
try {
|
|
17183
|
-
marker = JSON.parse(readFileSync10(
|
|
17206
|
+
marker = JSON.parse(readFileSync10(join10(dir, name), "utf-8"));
|
|
17184
17207
|
} catch {
|
|
17185
17208
|
continue;
|
|
17186
17209
|
}
|
|
@@ -17361,7 +17384,7 @@ function buildSlackMcpInstructions(opts) {
|
|
|
17361
17384
|
|
|
17362
17385
|
// src/slack-reply-binding-telemetry.ts
|
|
17363
17386
|
import { readFileSync as readFileSync11, writeFileSync as writeFileSync9 } from "fs";
|
|
17364
|
-
import { join as
|
|
17387
|
+
import { join as join11 } from "path";
|
|
17365
17388
|
var REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX = "-reply-binding-classifications.json";
|
|
17366
17389
|
var UNKNOWN_INBOUND_ID_KEY = "unknown_inbound_id";
|
|
17367
17390
|
var CHANNEL_MISTARGET_CORRECTED_KEY = "channel_mistarget_corrected";
|
|
@@ -17374,7 +17397,7 @@ function slackReplyBindingMode() {
|
|
|
17374
17397
|
}
|
|
17375
17398
|
function recordReplyBindingClassification(agentDir, channel, input) {
|
|
17376
17399
|
if (!agentDir) return;
|
|
17377
|
-
const path =
|
|
17400
|
+
const path = join11(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
17378
17401
|
let counts = {};
|
|
17379
17402
|
try {
|
|
17380
17403
|
const parsed = JSON.parse(readFileSync11(path, "utf-8"));
|
|
@@ -17392,7 +17415,7 @@ function recordReplyBindingClassification(agentDir, channel, input) {
|
|
|
17392
17415
|
}
|
|
17393
17416
|
function recordChannelMistarget(agentDir, channel, input) {
|
|
17394
17417
|
if (!agentDir) return;
|
|
17395
|
-
const path =
|
|
17418
|
+
const path = join11(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
17396
17419
|
let counts = {};
|
|
17397
17420
|
try {
|
|
17398
17421
|
const parsed = JSON.parse(readFileSync11(path, "utf-8"));
|
|
@@ -17411,7 +17434,7 @@ function recordChannelMistarget(agentDir, channel, input) {
|
|
|
17411
17434
|
|
|
17412
17435
|
// src/slack-reply-target-telemetry.ts
|
|
17413
17436
|
import { readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
|
|
17414
|
-
import { join as
|
|
17437
|
+
import { join as join12 } from "path";
|
|
17415
17438
|
var REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX = "-reply-target-classifications.json";
|
|
17416
17439
|
function pendingThreadsBucket(n) {
|
|
17417
17440
|
if (n <= 0) return "0";
|
|
@@ -17444,7 +17467,7 @@ function classifyReplyTarget(input) {
|
|
|
17444
17467
|
}
|
|
17445
17468
|
function recordReplyTargetClassification(agentDir, channel, classification) {
|
|
17446
17469
|
if (!agentDir) return;
|
|
17447
|
-
const path =
|
|
17470
|
+
const path = join12(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
17448
17471
|
let counts = {};
|
|
17449
17472
|
try {
|
|
17450
17473
|
const parsed = JSON.parse(readFileSync12(path, "utf-8"));
|
|
@@ -17463,8 +17486,8 @@ function recordReplyTargetClassification(agentDir, channel, classification) {
|
|
|
17463
17486
|
}
|
|
17464
17487
|
|
|
17465
17488
|
// src/scheduled-turn-marker.ts
|
|
17466
|
-
import { readFileSync as readFileSync13, unlinkSync as
|
|
17467
|
-
import { join as
|
|
17489
|
+
import { readFileSync as readFileSync13, unlinkSync as unlinkSync5 } from "fs";
|
|
17490
|
+
import { join as join13 } from "path";
|
|
17468
17491
|
var SCHEDULED_TURN_MARKER_FILENAME = ".current-scheduled-turn.json";
|
|
17469
17492
|
var SCHEDULED_TURN_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
17470
17493
|
function validateScheduledTurnMarker(raw, now, maxAgeMs = SCHEDULED_TURN_MAX_AGE_MS) {
|
|
@@ -17502,7 +17525,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
|
|
|
17502
17525
|
if (!agentDir) return null;
|
|
17503
17526
|
try {
|
|
17504
17527
|
const raw = JSON.parse(
|
|
17505
|
-
readFileSync13(
|
|
17528
|
+
readFileSync13(join13(agentDir, SCHEDULED_TURN_MARKER_FILENAME), "utf8")
|
|
17506
17529
|
);
|
|
17507
17530
|
return validateScheduledTurnMarker(raw, now);
|
|
17508
17531
|
} catch {
|
|
@@ -17512,7 +17535,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
|
|
|
17512
17535
|
function clearScheduledTurnMarker(agentDir) {
|
|
17513
17536
|
if (!agentDir) return;
|
|
17514
17537
|
try {
|
|
17515
|
-
|
|
17538
|
+
unlinkSync5(join13(agentDir, SCHEDULED_TURN_MARKER_FILENAME));
|
|
17516
17539
|
} catch {
|
|
17517
17540
|
}
|
|
17518
17541
|
}
|
|
@@ -18292,14 +18315,14 @@ async function actuateHostRestart(opts) {
|
|
|
18292
18315
|
|
|
18293
18316
|
// src/mcp-spawn-lock.ts
|
|
18294
18317
|
import {
|
|
18295
|
-
existsSync as
|
|
18318
|
+
existsSync as existsSync8,
|
|
18296
18319
|
mkdirSync as mkdirSync7,
|
|
18297
18320
|
readFileSync as readFileSync14,
|
|
18298
18321
|
renameSync as renameSync3,
|
|
18299
|
-
unlinkSync as
|
|
18322
|
+
unlinkSync as unlinkSync6,
|
|
18300
18323
|
writeFileSync as writeFileSync11
|
|
18301
18324
|
} from "fs";
|
|
18302
|
-
import { join as
|
|
18325
|
+
import { join as join14 } from "path";
|
|
18303
18326
|
function defaultIsPidAlive(pid) {
|
|
18304
18327
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
18305
18328
|
try {
|
|
@@ -18317,7 +18340,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
18317
18340
|
const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
|
|
18318
18341
|
const selfPid = options.selfPid ?? process.pid;
|
|
18319
18342
|
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
18320
|
-
const path =
|
|
18343
|
+
const path = join14(agentDir, basename2);
|
|
18321
18344
|
const existing = readLockHolder(path);
|
|
18322
18345
|
if (existing) {
|
|
18323
18346
|
if (existing.pid === selfPid) {
|
|
@@ -18341,12 +18364,12 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
|
18341
18364
|
if (!existing) return;
|
|
18342
18365
|
if (existing.pid !== selfPid) return;
|
|
18343
18366
|
try {
|
|
18344
|
-
|
|
18367
|
+
unlinkSync6(lockPath);
|
|
18345
18368
|
} catch {
|
|
18346
18369
|
}
|
|
18347
18370
|
}
|
|
18348
18371
|
function readLockHolder(path) {
|
|
18349
|
-
if (!
|
|
18372
|
+
if (!existsSync8(path)) return null;
|
|
18350
18373
|
try {
|
|
18351
18374
|
const raw = readFileSync14(path, "utf8");
|
|
18352
18375
|
const parsed = JSON.parse(raw);
|
|
@@ -18603,8 +18626,8 @@ var SLACK_TEAM_PEER_USER_IDS = parseTeamPeerUserIdsEnv(
|
|
|
18603
18626
|
process.env.SLACK_TEAM_PEER_USER_IDS
|
|
18604
18627
|
);
|
|
18605
18628
|
var PEER_HINT_SEEN = /* @__PURE__ */ new Set();
|
|
18606
|
-
var SLACK_AGENT_DIR = AGENT_CODE_NAME ?
|
|
18607
|
-
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ?
|
|
18629
|
+
var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join15(homedir4(), ".augmented", AGENT_CODE_NAME) : null;
|
|
18630
|
+
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
|
|
18608
18631
|
var liveAllowedUsersCache = null;
|
|
18609
18632
|
function readLiveAllowedUsers() {
|
|
18610
18633
|
if (!SLACK_MCP_CONFIG_PATH) return null;
|
|
@@ -18647,14 +18670,15 @@ function readLivePingAllowedUsers() {
|
|
|
18647
18670
|
function getEffectivePingAllowedUsers() {
|
|
18648
18671
|
return readLivePingAllowedUsers() ?? PING_ALLOWED_USERS;
|
|
18649
18672
|
}
|
|
18650
|
-
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ?
|
|
18651
|
-
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
18673
|
+
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
|
|
18674
|
+
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
|
|
18675
|
+
var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, ".agt-slack-recovery-ledger") : null;
|
|
18652
18676
|
var slackInboundRegistry = createInboundRegistry();
|
|
18653
|
-
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ?
|
|
18654
|
-
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ?
|
|
18655
|
-
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ?
|
|
18677
|
+
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
|
|
18678
|
+
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "slack-recent-dms.json") : null;
|
|
18679
|
+
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "slack-channel-add-restart.json") : null;
|
|
18656
18680
|
var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
|
|
18657
|
-
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ?
|
|
18681
|
+
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
|
|
18658
18682
|
function redactSlackId(id) {
|
|
18659
18683
|
if (!id) return "<none>";
|
|
18660
18684
|
return createHash2("sha256").update(id).digest("hex").slice(0, 8);
|
|
@@ -18665,7 +18689,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
|
|
|
18665
18689
|
}
|
|
18666
18690
|
function slackPendingInboundPath(channel, threadTs, messageTs) {
|
|
18667
18691
|
if (!SLACK_PENDING_INBOUND_DIR) return null;
|
|
18668
|
-
return
|
|
18692
|
+
return join15(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
|
|
18669
18693
|
}
|
|
18670
18694
|
function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false, discretionary = false, payload) {
|
|
18671
18695
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
@@ -18739,7 +18763,7 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
|
|
|
18739
18763
|
}
|
|
18740
18764
|
function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
|
|
18741
18765
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
18742
|
-
if (!path || !
|
|
18766
|
+
if (!path || !existsSync9(path)) return null;
|
|
18743
18767
|
try {
|
|
18744
18768
|
return JSON.parse(readFileSync15(path, "utf-8"));
|
|
18745
18769
|
} catch {
|
|
@@ -18857,7 +18881,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply, arrivedWhi
|
|
|
18857
18881
|
let paneLogFreshAgeMs = null;
|
|
18858
18882
|
if (SLACK_AGENT_DIR) {
|
|
18859
18883
|
try {
|
|
18860
|
-
const paneMtimeMs = statSync2(
|
|
18884
|
+
const paneMtimeMs = statSync2(join15(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
18861
18885
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
18862
18886
|
} catch {
|
|
18863
18887
|
}
|
|
@@ -18901,7 +18925,7 @@ function clearSlackMarkerFileWithHeal(fullPath) {
|
|
|
18901
18925
|
deleteSlackUndeliverableNotice(undeliverableNoticeConversationKeyFromMarker(marker));
|
|
18902
18926
|
}
|
|
18903
18927
|
try {
|
|
18904
|
-
if (
|
|
18928
|
+
if (existsSync9(fullPath)) unlinkSync7(fullPath);
|
|
18905
18929
|
} catch {
|
|
18906
18930
|
}
|
|
18907
18931
|
}
|
|
@@ -18977,7 +19001,7 @@ function slackNextRetryName(filename) {
|
|
|
18977
19001
|
async function processSlackRecoveryOutboxFile(filename) {
|
|
18978
19002
|
if (!SLACK_RECOVERY_OUTBOX_DIR) return;
|
|
18979
19003
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
18980
|
-
const fullPath =
|
|
19004
|
+
const fullPath = join15(SLACK_RECOVERY_OUTBOX_DIR, filename);
|
|
18981
19005
|
let payload;
|
|
18982
19006
|
try {
|
|
18983
19007
|
payload = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
@@ -18997,6 +19021,7 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
18997
19021
|
`slack-channel(${AGENT_CODE_NAME}): recovery outbox malformed (${filename}): missing channel or text
|
|
18998
19022
|
`
|
|
18999
19023
|
);
|
|
19024
|
+
removeRecoveryLedgerEntry(SLACK_RECOVERY_LEDGER_DIR, payload.marker_name);
|
|
19000
19025
|
try {
|
|
19001
19026
|
renameSync4(fullPath, `${fullPath}.malformed.poison`);
|
|
19002
19027
|
} catch {
|
|
@@ -19024,8 +19049,9 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
19024
19049
|
);
|
|
19025
19050
|
if (decision.action === "suppress") {
|
|
19026
19051
|
if (payload.thread_ts) clearPendingMessage(payload.channel, payload.thread_ts);
|
|
19052
|
+
removeRecoveryLedgerEntry(SLACK_RECOVERY_LEDGER_DIR, payload.marker_name);
|
|
19027
19053
|
try {
|
|
19028
|
-
|
|
19054
|
+
unlinkSync7(fullPath);
|
|
19029
19055
|
} catch {
|
|
19030
19056
|
}
|
|
19031
19057
|
return;
|
|
@@ -19072,8 +19098,9 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
19072
19098
|
clearTimeout(timeoutId);
|
|
19073
19099
|
}
|
|
19074
19100
|
if (sendSucceeded) {
|
|
19101
|
+
removeRecoveryLedgerEntry(SLACK_RECOVERY_LEDGER_DIR, payload.marker_name);
|
|
19075
19102
|
try {
|
|
19076
|
-
|
|
19103
|
+
unlinkSync7(fullPath);
|
|
19077
19104
|
} catch {
|
|
19078
19105
|
}
|
|
19079
19106
|
return;
|
|
@@ -19081,12 +19108,13 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
19081
19108
|
const next = slackNextRetryName(filename);
|
|
19082
19109
|
if (next) {
|
|
19083
19110
|
try {
|
|
19084
|
-
renameSync4(fullPath,
|
|
19111
|
+
renameSync4(fullPath, join15(SLACK_RECOVERY_OUTBOX_DIR, next.next));
|
|
19085
19112
|
if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
|
|
19086
19113
|
process.stderr.write(
|
|
19087
19114
|
`slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
19088
19115
|
`
|
|
19089
19116
|
);
|
|
19117
|
+
removeRecoveryLedgerEntry(SLACK_RECOVERY_LEDGER_DIR, payload.marker_name);
|
|
19090
19118
|
}
|
|
19091
19119
|
} catch {
|
|
19092
19120
|
}
|
|
@@ -19120,7 +19148,7 @@ function scanSlackRecoveryRetries() {
|
|
|
19120
19148
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
19121
19149
|
let mtimeMs;
|
|
19122
19150
|
try {
|
|
19123
|
-
mtimeMs = statSync2(
|
|
19151
|
+
mtimeMs = statSync2(join15(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
19124
19152
|
} catch {
|
|
19125
19153
|
continue;
|
|
19126
19154
|
}
|
|
@@ -19150,7 +19178,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
19150
19178
|
const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
19151
19179
|
if (event !== "rename" || !filename) return;
|
|
19152
19180
|
if (!isFirstAttemptSlackOutboxFile(filename)) return;
|
|
19153
|
-
if (
|
|
19181
|
+
if (existsSync9(join15(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
|
|
19154
19182
|
void processSlackRecoveryOutboxFile(filename);
|
|
19155
19183
|
}
|
|
19156
19184
|
});
|
|
@@ -19165,7 +19193,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
19165
19193
|
retryTimer.unref?.();
|
|
19166
19194
|
}
|
|
19167
19195
|
startSlackRecoveryOutboxWatcher();
|
|
19168
|
-
var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
19196
|
+
var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "slack-notice-outbox") : null;
|
|
19169
19197
|
var SLACK_NOTICE_MAX_AGE_MS = 9e4;
|
|
19170
19198
|
var SLACK_NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
|
|
19171
19199
|
async function processSlackNoticeOutboxFile(filename) {
|
|
@@ -19173,7 +19201,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19173
19201
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
19174
19202
|
if (SLACK_NOTICE_INFLIGHT.has(filename)) return;
|
|
19175
19203
|
SLACK_NOTICE_INFLIGHT.add(filename);
|
|
19176
|
-
const fullPath =
|
|
19204
|
+
const fullPath = join15(SLACK_NOTICE_OUTBOX_DIR, filename);
|
|
19177
19205
|
try {
|
|
19178
19206
|
let mtimeMs;
|
|
19179
19207
|
try {
|
|
@@ -19183,7 +19211,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19183
19211
|
}
|
|
19184
19212
|
if (Date.now() - mtimeMs > SLACK_NOTICE_MAX_AGE_MS) {
|
|
19185
19213
|
try {
|
|
19186
|
-
|
|
19214
|
+
unlinkSync7(fullPath);
|
|
19187
19215
|
} catch {
|
|
19188
19216
|
}
|
|
19189
19217
|
return;
|
|
@@ -19195,14 +19223,14 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19195
19223
|
payload = parsed;
|
|
19196
19224
|
} catch {
|
|
19197
19225
|
try {
|
|
19198
|
-
|
|
19226
|
+
unlinkSync7(fullPath);
|
|
19199
19227
|
} catch {
|
|
19200
19228
|
}
|
|
19201
19229
|
return;
|
|
19202
19230
|
}
|
|
19203
19231
|
if (!payload.channel || !payload.text) {
|
|
19204
19232
|
try {
|
|
19205
|
-
|
|
19233
|
+
unlinkSync7(fullPath);
|
|
19206
19234
|
} catch {
|
|
19207
19235
|
}
|
|
19208
19236
|
return;
|
|
@@ -19213,7 +19241,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19213
19241
|
defaultValue: false
|
|
19214
19242
|
})) {
|
|
19215
19243
|
try {
|
|
19216
|
-
|
|
19244
|
+
unlinkSync7(fullPath);
|
|
19217
19245
|
} catch {
|
|
19218
19246
|
}
|
|
19219
19247
|
return;
|
|
@@ -19254,7 +19282,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19254
19282
|
clearTimeout(timeoutId);
|
|
19255
19283
|
}
|
|
19256
19284
|
try {
|
|
19257
|
-
|
|
19285
|
+
unlinkSync7(fullPath);
|
|
19258
19286
|
} catch {
|
|
19259
19287
|
}
|
|
19260
19288
|
} finally {
|
|
@@ -19279,7 +19307,7 @@ function startSlackNoticeOutboxWatcher() {
|
|
|
19279
19307
|
try {
|
|
19280
19308
|
const watcher = watch(SLACK_NOTICE_OUTBOX_DIR, (event, filename) => {
|
|
19281
19309
|
if (event !== "rename" || !filename) return;
|
|
19282
|
-
if (
|
|
19310
|
+
if (existsSync9(join15(SLACK_NOTICE_OUTBOX_DIR, filename))) {
|
|
19283
19311
|
void processSlackNoticeOutboxFile(filename);
|
|
19284
19312
|
}
|
|
19285
19313
|
});
|
|
@@ -19299,7 +19327,7 @@ function trackPendingMessage(channel, threadTs, messageTs, undeliverable = false
|
|
|
19299
19327
|
}
|
|
19300
19328
|
function sweepSlackStaleMarkers(thresholdMs) {
|
|
19301
19329
|
if (!SLACK_PENDING_INBOUND_DIR) return;
|
|
19302
|
-
if (!
|
|
19330
|
+
if (!existsSync9(SLACK_PENDING_INBOUND_DIR)) return;
|
|
19303
19331
|
let filenames;
|
|
19304
19332
|
try {
|
|
19305
19333
|
filenames = readdirSync4(SLACK_PENDING_INBOUND_DIR);
|
|
@@ -19315,7 +19343,7 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
19315
19343
|
for (const filename of filenames) {
|
|
19316
19344
|
if (!filename.endsWith(".json")) continue;
|
|
19317
19345
|
if (filename.endsWith(".tmp")) continue;
|
|
19318
|
-
const fullPath =
|
|
19346
|
+
const fullPath = join15(SLACK_PENDING_INBOUND_DIR, filename);
|
|
19319
19347
|
let marker;
|
|
19320
19348
|
try {
|
|
19321
19349
|
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
@@ -19325,7 +19353,7 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
19325
19353
|
`
|
|
19326
19354
|
);
|
|
19327
19355
|
try {
|
|
19328
|
-
|
|
19356
|
+
unlinkSync7(fullPath);
|
|
19329
19357
|
} catch {
|
|
19330
19358
|
}
|
|
19331
19359
|
cleared++;
|
|
@@ -19344,7 +19372,7 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
19344
19372
|
);
|
|
19345
19373
|
}
|
|
19346
19374
|
try {
|
|
19347
|
-
|
|
19375
|
+
unlinkSync7(fullPath);
|
|
19348
19376
|
} catch {
|
|
19349
19377
|
}
|
|
19350
19378
|
cleared++;
|
|
@@ -19368,11 +19396,11 @@ var slackOrphanSweepTimer = setInterval(() => {
|
|
|
19368
19396
|
checkSlackWatchdogGiveUpNotice();
|
|
19369
19397
|
}, orphanSweepIntervalMs());
|
|
19370
19398
|
slackOrphanSweepTimer.unref?.();
|
|
19371
|
-
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ?
|
|
19399
|
+
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join15(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
19372
19400
|
var slackTrackedProgress = null;
|
|
19373
19401
|
var slackProgressTickRunning = false;
|
|
19374
19402
|
function readSlackProgressHeartbeat() {
|
|
19375
|
-
if (!SLACK_PROGRESS_HEARTBEAT_PATH || !
|
|
19403
|
+
if (!SLACK_PROGRESS_HEARTBEAT_PATH || !existsSync9(SLACK_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
19376
19404
|
try {
|
|
19377
19405
|
return parseProgressHeartbeat(readFileSync15(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
19378
19406
|
} catch {
|
|
@@ -19387,13 +19415,13 @@ function seedSlackProgressHeartbeat() {
|
|
|
19387
19415
|
renameSync4(tmp, SLACK_PROGRESS_HEARTBEAT_PATH);
|
|
19388
19416
|
} catch {
|
|
19389
19417
|
try {
|
|
19390
|
-
|
|
19418
|
+
unlinkSync7(tmp);
|
|
19391
19419
|
} catch {
|
|
19392
19420
|
}
|
|
19393
19421
|
}
|
|
19394
19422
|
}
|
|
19395
19423
|
function findSlackProgressTarget() {
|
|
19396
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
19424
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync9(SLACK_PENDING_INBOUND_DIR)) return null;
|
|
19397
19425
|
let best = null;
|
|
19398
19426
|
let bestMs = Infinity;
|
|
19399
19427
|
try {
|
|
@@ -19401,7 +19429,7 @@ function findSlackProgressTarget() {
|
|
|
19401
19429
|
if (!name.endsWith(".json")) continue;
|
|
19402
19430
|
let m;
|
|
19403
19431
|
try {
|
|
19404
|
-
m = JSON.parse(readFileSync15(
|
|
19432
|
+
m = JSON.parse(readFileSync15(join15(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
|
|
19405
19433
|
} catch {
|
|
19406
19434
|
continue;
|
|
19407
19435
|
}
|
|
@@ -19545,14 +19573,14 @@ if (BOT_TOKEN && SLACK_PENDING_INBOUND_DIR) {
|
|
|
19545
19573
|
}
|
|
19546
19574
|
var lastSlackGiveUpHandledAtMs = null;
|
|
19547
19575
|
function listPendingSlackConversations() {
|
|
19548
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
19576
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync9(SLACK_PENDING_INBOUND_DIR)) return [];
|
|
19549
19577
|
const byKey = /* @__PURE__ */ new Map();
|
|
19550
19578
|
try {
|
|
19551
19579
|
for (const name of readdirSync4(SLACK_PENDING_INBOUND_DIR)) {
|
|
19552
19580
|
if (!name.endsWith(".json")) continue;
|
|
19553
19581
|
try {
|
|
19554
19582
|
const marker = JSON.parse(
|
|
19555
|
-
readFileSync15(
|
|
19583
|
+
readFileSync15(join15(SLACK_PENDING_INBOUND_DIR, name), "utf8")
|
|
19556
19584
|
);
|
|
19557
19585
|
if (typeof marker.channel !== "string" || !marker.channel) continue;
|
|
19558
19586
|
if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
|
|
@@ -19604,7 +19632,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply, reason)
|
|
|
19604
19632
|
}
|
|
19605
19633
|
function checkSlackWatchdogGiveUpNotice() {
|
|
19606
19634
|
if (!SLACK_AGENT_DIR) return;
|
|
19607
|
-
const signal = readGiveUpSignal(
|
|
19635
|
+
const signal = readGiveUpSignal(join15(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
19608
19636
|
const signalAtMs = signal?.atMs ?? null;
|
|
19609
19637
|
const act = decideGiveUpNotice({
|
|
19610
19638
|
signalAtMs,
|
|
@@ -19638,7 +19666,7 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
19638
19666
|
strandedInboundNoticeInFlight = true;
|
|
19639
19667
|
let hadFailure = false;
|
|
19640
19668
|
try {
|
|
19641
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
19669
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync9(SLACK_PENDING_INBOUND_DIR)) return;
|
|
19642
19670
|
let filenames;
|
|
19643
19671
|
try {
|
|
19644
19672
|
filenames = readdirSync4(SLACK_PENDING_INBOUND_DIR);
|
|
@@ -19651,7 +19679,7 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
19651
19679
|
let notified = 0;
|
|
19652
19680
|
for (const filename of filenames) {
|
|
19653
19681
|
if (!filename.endsWith(".json")) continue;
|
|
19654
|
-
const fullPath =
|
|
19682
|
+
const fullPath = join15(SLACK_PENDING_INBOUND_DIR, filename);
|
|
19655
19683
|
let marker;
|
|
19656
19684
|
try {
|
|
19657
19685
|
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
@@ -19667,7 +19695,7 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
19667
19695
|
const key2 = `${channel}__${thread_ts}`;
|
|
19668
19696
|
if (seen.has(key2)) {
|
|
19669
19697
|
try {
|
|
19670
|
-
|
|
19698
|
+
unlinkSync7(fullPath);
|
|
19671
19699
|
} catch {
|
|
19672
19700
|
}
|
|
19673
19701
|
continue;
|
|
@@ -19681,7 +19709,7 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
19681
19709
|
if (res.ok) {
|
|
19682
19710
|
notified += 1;
|
|
19683
19711
|
try {
|
|
19684
|
-
|
|
19712
|
+
unlinkSync7(fullPath);
|
|
19685
19713
|
} catch {
|
|
19686
19714
|
}
|
|
19687
19715
|
} else {
|
|
@@ -19825,7 +19853,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
|
|
|
19825
19853
|
markSeenAllSlackPendingMarkersForThread2(channel, messageTs);
|
|
19826
19854
|
markSeenSlackPendingMarkerByMessageTs2(channel, messageTs);
|
|
19827
19855
|
}
|
|
19828
|
-
var RESTART_FLAGS_DIR =
|
|
19856
|
+
var RESTART_FLAGS_DIR = join15(homedir4(), ".augmented", "restart-flags");
|
|
19829
19857
|
function actuateHostRestartSlack() {
|
|
19830
19858
|
return actuateHostRestart({
|
|
19831
19859
|
agtHost: AGT_HOST,
|
|
@@ -20427,10 +20455,10 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
20427
20455
|
writeSlackRestartConfirm(confirmReply, payload.user_name);
|
|
20428
20456
|
} else {
|
|
20429
20457
|
writeSlackRestartConfirm(confirmReply, payload.user_name);
|
|
20430
|
-
if (!
|
|
20458
|
+
if (!existsSync9(RESTART_FLAGS_DIR)) {
|
|
20431
20459
|
mkdirSync8(RESTART_FLAGS_DIR, { recursive: true });
|
|
20432
20460
|
}
|
|
20433
|
-
const flagPath =
|
|
20461
|
+
const flagPath = join15(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
20434
20462
|
const flag = {
|
|
20435
20463
|
codeName,
|
|
20436
20464
|
source: "slack",
|
|
@@ -20570,10 +20598,10 @@ async function handleRestartCommand(opts) {
|
|
|
20570
20598
|
writeSlackRestartConfirm(confirmReply, opts.requesterName);
|
|
20571
20599
|
} else {
|
|
20572
20600
|
writeSlackRestartConfirm(confirmReply, opts.requesterName);
|
|
20573
|
-
if (!
|
|
20601
|
+
if (!existsSync9(RESTART_FLAGS_DIR)) {
|
|
20574
20602
|
mkdirSync8(RESTART_FLAGS_DIR, { recursive: true });
|
|
20575
20603
|
}
|
|
20576
|
-
const flagPath =
|
|
20604
|
+
const flagPath = join15(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
20577
20605
|
const flag = {
|
|
20578
20606
|
codeName,
|
|
20579
20607
|
source: "slack",
|
|
@@ -20686,7 +20714,7 @@ var THREAD_STORE_TTL_DAYS = parseTtlDays(process.env.SLACK_THREAD_FOLLOW_TTL_DAY
|
|
|
20686
20714
|
var threadPersister = null;
|
|
20687
20715
|
function resolveThreadStorePath() {
|
|
20688
20716
|
if (!AGENT_CODE_NAME) return null;
|
|
20689
|
-
return
|
|
20717
|
+
return join15(homedir4(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
|
|
20690
20718
|
}
|
|
20691
20719
|
function parseTtlDays(raw) {
|
|
20692
20720
|
if (!raw) return void 0;
|
|
@@ -20725,9 +20753,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
|
|
|
20725
20753
|
var slackStderrLogStream = null;
|
|
20726
20754
|
if (AGENT_CODE_NAME) {
|
|
20727
20755
|
try {
|
|
20728
|
-
const logDir =
|
|
20756
|
+
const logDir = join15(homedir4(), ".augmented", AGENT_CODE_NAME);
|
|
20729
20757
|
mkdirSync8(logDir, { recursive: true });
|
|
20730
|
-
slackStderrLogStream = createWriteStream(
|
|
20758
|
+
slackStderrLogStream = createWriteStream(join15(logDir, "slack-channel-stderr.log"), {
|
|
20731
20759
|
flags: "a",
|
|
20732
20760
|
mode: 384
|
|
20733
20761
|
});
|
|
@@ -22299,7 +22327,7 @@ await mcp.connect(new StdioServerTransport());
|
|
|
22299
22327
|
var SLACK_REPLAY_SCAN_INTERVAL_MS = 6e4;
|
|
22300
22328
|
async function replayPendingSlackMarkers() {
|
|
22301
22329
|
if (!channelReplayEnabled()) return;
|
|
22302
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
22330
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync9(SLACK_PENDING_INBOUND_DIR)) return;
|
|
22303
22331
|
const probe = process.env.TMUX && AGENT_CODE_NAME ? probeAgentSessionCached(AGENT_CODE_NAME) : { tmux: "unknown", claude: "unknown" };
|
|
22304
22332
|
const sessionAlive = probe.tmux === "alive" && probe.claude === "alive";
|
|
22305
22333
|
if (!sessionAlive) return;
|
|
@@ -22313,7 +22341,7 @@ async function replayPendingSlackMarkers() {
|
|
|
22313
22341
|
let paneFreshAgeMs = null;
|
|
22314
22342
|
if (SLACK_AGENT_DIR) {
|
|
22315
22343
|
try {
|
|
22316
|
-
paneFreshAgeMs = Math.max(0, now - statSync2(
|
|
22344
|
+
paneFreshAgeMs = Math.max(0, now - statSync2(join15(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
|
|
22317
22345
|
} catch {
|
|
22318
22346
|
}
|
|
22319
22347
|
}
|
|
@@ -22321,7 +22349,7 @@ async function replayPendingSlackMarkers() {
|
|
|
22321
22349
|
const entries = [];
|
|
22322
22350
|
for (const name of filenames) {
|
|
22323
22351
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
22324
|
-
const fullPath =
|
|
22352
|
+
const fullPath = join15(SLACK_PENDING_INBOUND_DIR, name);
|
|
22325
22353
|
let marker;
|
|
22326
22354
|
try {
|
|
22327
22355
|
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
@@ -22334,6 +22362,7 @@ async function replayPendingSlackMarkers() {
|
|
|
22334
22362
|
}
|
|
22335
22363
|
entries.sort((a, b) => b.ageMs - a.ageMs);
|
|
22336
22364
|
for (const { path, marker, ageMs } of entries) {
|
|
22365
|
+
if (recoveryLedgerEntryExists(SLACK_RECOVERY_LEDGER_DIR, basename(path))) continue;
|
|
22337
22366
|
if (!shouldReplayMarker({
|
|
22338
22367
|
enabled: true,
|
|
22339
22368
|
hasPayload: Boolean(marker.payload),
|
|
@@ -22881,7 +22910,7 @@ async function connectSocketMode() {
|
|
|
22881
22910
|
let paneLogFreshAgeMs = null;
|
|
22882
22911
|
if (SLACK_AGENT_DIR) {
|
|
22883
22912
|
try {
|
|
22884
|
-
const paneMtimeMs = statSync2(
|
|
22913
|
+
const paneMtimeMs = statSync2(join15(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
22885
22914
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
22886
22915
|
} catch {
|
|
22887
22916
|
}
|