@integrity-labs/agt-cli 0.28.331 → 0.28.332
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-4Y3UPOR2.js → chunk-YNHMQ4CW.js} +119 -26
- package/dist/chunk-YNHMQ4CW.js.map +1 -0
- package/dist/lib/manager-worker.js +4 -4
- package/dist/mcp/direct-chat-channel.js +92 -51
- package/dist/mcp/slack-channel.js +155 -118
- package/dist/mcp/teams-channel.js +100 -51
- package/dist/mcp/telegram-channel.js +146 -98
- package/dist/{responsiveness-probe-OJJESVVX.js → responsiveness-probe-46XFHCPY.js} +12 -2
- package/dist/responsiveness-probe-46XFHCPY.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-4Y3UPOR2.js.map +0 -1
- package/dist/responsiveness-probe-OJJESVVX.js.map +0 -1
|
@@ -16550,20 +16550,20 @@ import {
|
|
|
16550
16550
|
chmodSync,
|
|
16551
16551
|
closeSync,
|
|
16552
16552
|
createWriteStream,
|
|
16553
|
-
existsSync as
|
|
16553
|
+
existsSync as existsSync10,
|
|
16554
16554
|
ftruncateSync,
|
|
16555
|
-
mkdirSync as
|
|
16555
|
+
mkdirSync as mkdirSync9,
|
|
16556
16556
|
openSync,
|
|
16557
|
-
readFileSync as
|
|
16558
|
-
readdirSync as
|
|
16559
|
-
renameSync as
|
|
16557
|
+
readFileSync as readFileSync16,
|
|
16558
|
+
readdirSync as readdirSync5,
|
|
16559
|
+
renameSync as renameSync5,
|
|
16560
16560
|
statSync as statSync2,
|
|
16561
16561
|
unlinkSync as unlinkSync7,
|
|
16562
16562
|
watch,
|
|
16563
|
-
writeFileSync as
|
|
16563
|
+
writeFileSync as writeFileSync13,
|
|
16564
16564
|
writeSync
|
|
16565
16565
|
} from "fs";
|
|
16566
|
-
import { basename, join as
|
|
16566
|
+
import { basename, join as join16, resolve as resolve2 } from "path";
|
|
16567
16567
|
import { homedir as homedir4 } from "os";
|
|
16568
16568
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
|
|
16569
16569
|
|
|
@@ -17247,6 +17247,34 @@ function slackInboundId(channel, threadTs, messageTs) {
|
|
|
17247
17247
|
return `ib_${digest}`;
|
|
17248
17248
|
}
|
|
17249
17249
|
|
|
17250
|
+
// src/inbound-delivery-ledger.ts
|
|
17251
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as readFileSync11, renameSync as renameSync3, writeFileSync as writeFileSync9 } from "fs";
|
|
17252
|
+
import { join as join11 } from "path";
|
|
17253
|
+
function safeInboundId(inboundId) {
|
|
17254
|
+
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
17255
|
+
}
|
|
17256
|
+
var defaultDeps = {
|
|
17257
|
+
mkdir: (dir) => mkdirSync7(dir, { recursive: true }),
|
|
17258
|
+
writeFile: (path, data) => writeFileSync9(path, data, "utf8"),
|
|
17259
|
+
rename: (from, to) => renameSync3(from, to),
|
|
17260
|
+
readdir: (dir) => readdirSync4(dir),
|
|
17261
|
+
readFile: (path) => readFileSync11(path, "utf8"),
|
|
17262
|
+
exists: (path) => existsSync8(path)
|
|
17263
|
+
};
|
|
17264
|
+
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
17265
|
+
if (!dir || !record2.inbound_id || !record2.conv_key) return;
|
|
17266
|
+
const safe = safeInboundId(record2.inbound_id);
|
|
17267
|
+
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
|
|
17268
|
+
try {
|
|
17269
|
+
deps.mkdir(dir);
|
|
17270
|
+
const final = join11(dir, `${safe}.json`);
|
|
17271
|
+
const tmp = `${final}.tmp`;
|
|
17272
|
+
deps.writeFile(tmp, JSON.stringify(record2));
|
|
17273
|
+
deps.rename(tmp, final);
|
|
17274
|
+
} catch {
|
|
17275
|
+
}
|
|
17276
|
+
}
|
|
17277
|
+
|
|
17250
17278
|
// src/slack-reply-binding.ts
|
|
17251
17279
|
function matchByCoords(registry2, channel, messageTs, threadTs) {
|
|
17252
17280
|
if (!channel) return null;
|
|
@@ -17383,8 +17411,8 @@ function buildSlackMcpInstructions(opts) {
|
|
|
17383
17411
|
}
|
|
17384
17412
|
|
|
17385
17413
|
// src/slack-reply-binding-telemetry.ts
|
|
17386
|
-
import { readFileSync as
|
|
17387
|
-
import { join as
|
|
17414
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
|
|
17415
|
+
import { join as join12 } from "path";
|
|
17388
17416
|
var REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX = "-reply-binding-classifications.json";
|
|
17389
17417
|
var UNKNOWN_INBOUND_ID_KEY = "unknown_inbound_id";
|
|
17390
17418
|
var CHANNEL_MISTARGET_CORRECTED_KEY = "channel_mistarget_corrected";
|
|
@@ -17397,10 +17425,10 @@ function slackReplyBindingMode() {
|
|
|
17397
17425
|
}
|
|
17398
17426
|
function recordReplyBindingClassification(agentDir, channel, input) {
|
|
17399
17427
|
if (!agentDir) return;
|
|
17400
|
-
const path =
|
|
17428
|
+
const path = join12(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
17401
17429
|
let counts = {};
|
|
17402
17430
|
try {
|
|
17403
|
-
const parsed = JSON.parse(
|
|
17431
|
+
const parsed = JSON.parse(readFileSync12(path, "utf-8"));
|
|
17404
17432
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
17405
17433
|
} catch {
|
|
17406
17434
|
}
|
|
@@ -17409,16 +17437,16 @@ function recordReplyBindingClassification(agentDir, channel, input) {
|
|
|
17409
17437
|
counts[UNKNOWN_INBOUND_ID_KEY] = (counts[UNKNOWN_INBOUND_ID_KEY] ?? 0) + 1;
|
|
17410
17438
|
}
|
|
17411
17439
|
try {
|
|
17412
|
-
|
|
17440
|
+
writeFileSync10(path, JSON.stringify(counts), { mode: 384 });
|
|
17413
17441
|
} catch {
|
|
17414
17442
|
}
|
|
17415
17443
|
}
|
|
17416
17444
|
function recordChannelMistarget(agentDir, channel, input) {
|
|
17417
17445
|
if (!agentDir) return;
|
|
17418
|
-
const path =
|
|
17446
|
+
const path = join12(agentDir, `${channel}${REPLY_BINDING_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
17419
17447
|
let counts = {};
|
|
17420
17448
|
try {
|
|
17421
|
-
const parsed = JSON.parse(
|
|
17449
|
+
const parsed = JSON.parse(readFileSync12(path, "utf-8"));
|
|
17422
17450
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
17423
17451
|
} catch {
|
|
17424
17452
|
}
|
|
@@ -17427,14 +17455,14 @@ function recordChannelMistarget(agentDir, channel, input) {
|
|
|
17427
17455
|
counts[DM_CHANNEL_MISTARGET_KEY] = (counts[DM_CHANNEL_MISTARGET_KEY] ?? 0) + 1;
|
|
17428
17456
|
}
|
|
17429
17457
|
try {
|
|
17430
|
-
|
|
17458
|
+
writeFileSync10(path, JSON.stringify(counts), { mode: 384 });
|
|
17431
17459
|
} catch {
|
|
17432
17460
|
}
|
|
17433
17461
|
}
|
|
17434
17462
|
|
|
17435
17463
|
// src/slack-reply-target-telemetry.ts
|
|
17436
|
-
import { readFileSync as
|
|
17437
|
-
import { join as
|
|
17464
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync11 } from "fs";
|
|
17465
|
+
import { join as join13 } from "path";
|
|
17438
17466
|
var REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX = "-reply-target-classifications.json";
|
|
17439
17467
|
function pendingThreadsBucket(n) {
|
|
17440
17468
|
if (n <= 0) return "0";
|
|
@@ -17467,10 +17495,10 @@ function classifyReplyTarget(input) {
|
|
|
17467
17495
|
}
|
|
17468
17496
|
function recordReplyTargetClassification(agentDir, channel, classification) {
|
|
17469
17497
|
if (!agentDir) return;
|
|
17470
|
-
const path =
|
|
17498
|
+
const path = join13(agentDir, `${channel}${REPLY_TARGET_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
17471
17499
|
let counts = {};
|
|
17472
17500
|
try {
|
|
17473
|
-
const parsed = JSON.parse(
|
|
17501
|
+
const parsed = JSON.parse(readFileSync13(path, "utf-8"));
|
|
17474
17502
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
17475
17503
|
} catch {
|
|
17476
17504
|
}
|
|
@@ -17480,14 +17508,14 @@ function recordReplyTargetClassification(agentDir, channel, classification) {
|
|
|
17480
17508
|
);
|
|
17481
17509
|
counts[key2] = (counts[key2] ?? 0) + 1;
|
|
17482
17510
|
try {
|
|
17483
|
-
|
|
17511
|
+
writeFileSync11(path, JSON.stringify(counts), { mode: 384 });
|
|
17484
17512
|
} catch {
|
|
17485
17513
|
}
|
|
17486
17514
|
}
|
|
17487
17515
|
|
|
17488
17516
|
// src/scheduled-turn-marker.ts
|
|
17489
|
-
import { readFileSync as
|
|
17490
|
-
import { join as
|
|
17517
|
+
import { readFileSync as readFileSync14, unlinkSync as unlinkSync5 } from "fs";
|
|
17518
|
+
import { join as join14 } from "path";
|
|
17491
17519
|
var SCHEDULED_TURN_MARKER_FILENAME = ".current-scheduled-turn.json";
|
|
17492
17520
|
var SCHEDULED_TURN_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
17493
17521
|
function validateScheduledTurnMarker(raw, now, maxAgeMs = SCHEDULED_TURN_MAX_AGE_MS) {
|
|
@@ -17525,7 +17553,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
|
|
|
17525
17553
|
if (!agentDir) return null;
|
|
17526
17554
|
try {
|
|
17527
17555
|
const raw = JSON.parse(
|
|
17528
|
-
|
|
17556
|
+
readFileSync14(join14(agentDir, SCHEDULED_TURN_MARKER_FILENAME), "utf8")
|
|
17529
17557
|
);
|
|
17530
17558
|
return validateScheduledTurnMarker(raw, now);
|
|
17531
17559
|
} catch {
|
|
@@ -17535,7 +17563,7 @@ function readScheduledTurnMarker(agentDir, now = Date.now()) {
|
|
|
17535
17563
|
function clearScheduledTurnMarker(agentDir) {
|
|
17536
17564
|
if (!agentDir) return;
|
|
17537
17565
|
try {
|
|
17538
|
-
unlinkSync5(
|
|
17566
|
+
unlinkSync5(join14(agentDir, SCHEDULED_TURN_MARKER_FILENAME));
|
|
17539
17567
|
} catch {
|
|
17540
17568
|
}
|
|
17541
17569
|
}
|
|
@@ -18315,14 +18343,14 @@ async function actuateHostRestart(opts) {
|
|
|
18315
18343
|
|
|
18316
18344
|
// src/mcp-spawn-lock.ts
|
|
18317
18345
|
import {
|
|
18318
|
-
existsSync as
|
|
18319
|
-
mkdirSync as
|
|
18320
|
-
readFileSync as
|
|
18321
|
-
renameSync as
|
|
18346
|
+
existsSync as existsSync9,
|
|
18347
|
+
mkdirSync as mkdirSync8,
|
|
18348
|
+
readFileSync as readFileSync15,
|
|
18349
|
+
renameSync as renameSync4,
|
|
18322
18350
|
unlinkSync as unlinkSync6,
|
|
18323
|
-
writeFileSync as
|
|
18351
|
+
writeFileSync as writeFileSync12
|
|
18324
18352
|
} from "fs";
|
|
18325
|
-
import { join as
|
|
18353
|
+
import { join as join15 } from "path";
|
|
18326
18354
|
function defaultIsPidAlive(pid) {
|
|
18327
18355
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
18328
18356
|
try {
|
|
@@ -18340,7 +18368,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
18340
18368
|
const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
|
|
18341
18369
|
const selfPid = options.selfPid ?? process.pid;
|
|
18342
18370
|
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
18343
|
-
const path =
|
|
18371
|
+
const path = join15(agentDir, basename2);
|
|
18344
18372
|
const existing = readLockHolder(path);
|
|
18345
18373
|
if (existing) {
|
|
18346
18374
|
if (existing.pid === selfPid) {
|
|
@@ -18350,11 +18378,11 @@ function acquireMcpSpawnLock(args) {
|
|
|
18350
18378
|
return { kind: "blocked", path, holder: existing };
|
|
18351
18379
|
}
|
|
18352
18380
|
}
|
|
18353
|
-
|
|
18381
|
+
mkdirSync8(agentDir, { recursive: true, mode: 448 });
|
|
18354
18382
|
const tmpPath = `${path}.${selfPid}.tmp`;
|
|
18355
18383
|
const payload = { pid: selfPid, started_at: now() };
|
|
18356
|
-
|
|
18357
|
-
|
|
18384
|
+
writeFileSync12(tmpPath, JSON.stringify(payload), { mode: 384 });
|
|
18385
|
+
renameSync4(tmpPath, path);
|
|
18358
18386
|
return { kind: "acquired", path };
|
|
18359
18387
|
}
|
|
18360
18388
|
function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
@@ -18369,9 +18397,9 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
|
18369
18397
|
}
|
|
18370
18398
|
}
|
|
18371
18399
|
function readLockHolder(path) {
|
|
18372
|
-
if (!
|
|
18400
|
+
if (!existsSync9(path)) return null;
|
|
18373
18401
|
try {
|
|
18374
|
-
const raw =
|
|
18402
|
+
const raw = readFileSync15(path, "utf8");
|
|
18375
18403
|
const parsed = JSON.parse(raw);
|
|
18376
18404
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
18377
18405
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -18626,8 +18654,8 @@ var SLACK_TEAM_PEER_USER_IDS = parseTeamPeerUserIdsEnv(
|
|
|
18626
18654
|
process.env.SLACK_TEAM_PEER_USER_IDS
|
|
18627
18655
|
);
|
|
18628
18656
|
var PEER_HINT_SEEN = /* @__PURE__ */ new Set();
|
|
18629
|
-
var SLACK_AGENT_DIR = AGENT_CODE_NAME ?
|
|
18630
|
-
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ?
|
|
18657
|
+
var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join16(homedir4(), ".augmented", AGENT_CODE_NAME) : null;
|
|
18658
|
+
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
|
|
18631
18659
|
var liveAllowedUsersCache = null;
|
|
18632
18660
|
function readLiveAllowedUsers() {
|
|
18633
18661
|
if (!SLACK_MCP_CONFIG_PATH) return null;
|
|
@@ -18637,7 +18665,7 @@ function readLiveAllowedUsers() {
|
|
|
18637
18665
|
return liveAllowedUsersCache.value;
|
|
18638
18666
|
}
|
|
18639
18667
|
const value = extractAllowedUsersFromMcpJson(
|
|
18640
|
-
|
|
18668
|
+
readFileSync16(SLACK_MCP_CONFIG_PATH, "utf-8")
|
|
18641
18669
|
);
|
|
18642
18670
|
if (value === null) return null;
|
|
18643
18671
|
liveAllowedUsersCache = { mtimeMs, value };
|
|
@@ -18658,7 +18686,7 @@ function readLivePingAllowedUsers() {
|
|
|
18658
18686
|
return livePingAllowedUsersCache.value;
|
|
18659
18687
|
}
|
|
18660
18688
|
const value = extractPingAllowedUsersFromMcpJson(
|
|
18661
|
-
|
|
18689
|
+
readFileSync16(SLACK_MCP_CONFIG_PATH, "utf-8")
|
|
18662
18690
|
);
|
|
18663
18691
|
if (value === null) return null;
|
|
18664
18692
|
livePingAllowedUsersCache = { mtimeMs, value };
|
|
@@ -18670,15 +18698,16 @@ function readLivePingAllowedUsers() {
|
|
|
18670
18698
|
function getEffectivePingAllowedUsers() {
|
|
18671
18699
|
return readLivePingAllowedUsers() ?? PING_ALLOWED_USERS;
|
|
18672
18700
|
}
|
|
18673
|
-
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ?
|
|
18674
|
-
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
18675
|
-
var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ?
|
|
18701
|
+
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
|
|
18702
|
+
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
|
|
18703
|
+
var SLACK_RECOVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, ".agt-slack-recovery-ledger") : null;
|
|
18704
|
+
var SLACK_DELIVERY_LEDGER_DIR = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
|
|
18676
18705
|
var slackInboundRegistry = createInboundRegistry();
|
|
18677
|
-
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ?
|
|
18678
|
-
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ?
|
|
18679
|
-
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ?
|
|
18706
|
+
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
|
|
18707
|
+
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "slack-recent-dms.json") : null;
|
|
18708
|
+
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "slack-channel-add-restart.json") : null;
|
|
18680
18709
|
var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
|
|
18681
|
-
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ?
|
|
18710
|
+
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
|
|
18682
18711
|
function redactSlackId(id) {
|
|
18683
18712
|
if (!id) return "<none>";
|
|
18684
18713
|
return createHash2("sha256").update(id).digest("hex").slice(0, 8);
|
|
@@ -18689,7 +18718,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
|
|
|
18689
18718
|
}
|
|
18690
18719
|
function slackPendingInboundPath(channel, threadTs, messageTs) {
|
|
18691
18720
|
if (!SLACK_PENDING_INBOUND_DIR) return null;
|
|
18692
|
-
return
|
|
18721
|
+
return join16(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
|
|
18693
18722
|
}
|
|
18694
18723
|
function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false, discretionary = false, payload) {
|
|
18695
18724
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
@@ -18711,8 +18740,8 @@ function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undelivera
|
|
|
18711
18740
|
...payload ? { payload } : {}
|
|
18712
18741
|
};
|
|
18713
18742
|
try {
|
|
18714
|
-
|
|
18715
|
-
|
|
18743
|
+
mkdirSync9(SLACK_PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
|
|
18744
|
+
writeFileSync13(path, JSON.stringify(marker), { mode: 384 });
|
|
18716
18745
|
} catch (err) {
|
|
18717
18746
|
process.stderr.write(
|
|
18718
18747
|
`slack-channel(${AGENT_CODE_NAME}): pending-inbound marker write failed: ${err.message}
|
|
@@ -18740,7 +18769,7 @@ function rewriteSlackMarkerInPlace(path, marker) {
|
|
|
18740
18769
|
function markSlackMarkerSeenInPlace(fullPath) {
|
|
18741
18770
|
let marker;
|
|
18742
18771
|
try {
|
|
18743
|
-
marker = JSON.parse(
|
|
18772
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
18744
18773
|
} catch {
|
|
18745
18774
|
return;
|
|
18746
18775
|
}
|
|
@@ -18754,7 +18783,7 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
|
|
|
18754
18783
|
if (!path) return;
|
|
18755
18784
|
let marker;
|
|
18756
18785
|
try {
|
|
18757
|
-
marker = JSON.parse(
|
|
18786
|
+
marker = JSON.parse(readFileSync16(path, "utf-8"));
|
|
18758
18787
|
} catch {
|
|
18759
18788
|
return;
|
|
18760
18789
|
}
|
|
@@ -18763,9 +18792,9 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
|
|
|
18763
18792
|
}
|
|
18764
18793
|
function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
|
|
18765
18794
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
18766
|
-
if (!path || !
|
|
18795
|
+
if (!path || !existsSync10(path)) return null;
|
|
18767
18796
|
try {
|
|
18768
|
-
return JSON.parse(
|
|
18797
|
+
return JSON.parse(readFileSync16(path, "utf-8"));
|
|
18769
18798
|
} catch {
|
|
18770
18799
|
return null;
|
|
18771
18800
|
}
|
|
@@ -18881,7 +18910,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply, arrivedWhi
|
|
|
18881
18910
|
let paneLogFreshAgeMs = null;
|
|
18882
18911
|
if (SLACK_AGENT_DIR) {
|
|
18883
18912
|
try {
|
|
18884
|
-
const paneMtimeMs = statSync2(
|
|
18913
|
+
const paneMtimeMs = statSync2(join16(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
18885
18914
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
18886
18915
|
} catch {
|
|
18887
18916
|
}
|
|
@@ -18914,7 +18943,7 @@ function __resetSlackBusyAckNoticeThrottle() {
|
|
|
18914
18943
|
function clearSlackMarkerFileWithHeal(fullPath) {
|
|
18915
18944
|
let marker = null;
|
|
18916
18945
|
try {
|
|
18917
|
-
marker = JSON.parse(
|
|
18946
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
18918
18947
|
} catch {
|
|
18919
18948
|
}
|
|
18920
18949
|
if (marker && decideRecoveryHeal({
|
|
@@ -18925,14 +18954,14 @@ function clearSlackMarkerFileWithHeal(fullPath) {
|
|
|
18925
18954
|
deleteSlackUndeliverableNotice(undeliverableNoticeConversationKeyFromMarker(marker));
|
|
18926
18955
|
}
|
|
18927
18956
|
try {
|
|
18928
|
-
if (
|
|
18957
|
+
if (existsSync10(fullPath)) unlinkSync7(fullPath);
|
|
18929
18958
|
} catch {
|
|
18930
18959
|
}
|
|
18931
18960
|
}
|
|
18932
18961
|
function markSlackMarkerSeenWithHeal(fullPath) {
|
|
18933
18962
|
let marker = null;
|
|
18934
18963
|
try {
|
|
18935
|
-
marker = JSON.parse(
|
|
18964
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
18936
18965
|
} catch {
|
|
18937
18966
|
return;
|
|
18938
18967
|
}
|
|
@@ -19001,17 +19030,17 @@ function slackNextRetryName(filename) {
|
|
|
19001
19030
|
async function processSlackRecoveryOutboxFile(filename) {
|
|
19002
19031
|
if (!SLACK_RECOVERY_OUTBOX_DIR) return;
|
|
19003
19032
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
19004
|
-
const fullPath =
|
|
19033
|
+
const fullPath = join16(SLACK_RECOVERY_OUTBOX_DIR, filename);
|
|
19005
19034
|
let payload;
|
|
19006
19035
|
try {
|
|
19007
|
-
payload = JSON.parse(
|
|
19036
|
+
payload = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
19008
19037
|
} catch (err) {
|
|
19009
19038
|
process.stderr.write(
|
|
19010
19039
|
`slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
|
|
19011
19040
|
`
|
|
19012
19041
|
);
|
|
19013
19042
|
try {
|
|
19014
|
-
|
|
19043
|
+
renameSync5(fullPath, `${fullPath}.parse-error.poison`);
|
|
19015
19044
|
} catch {
|
|
19016
19045
|
}
|
|
19017
19046
|
return;
|
|
@@ -19023,7 +19052,7 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
19023
19052
|
);
|
|
19024
19053
|
removeRecoveryLedgerEntry(SLACK_RECOVERY_LEDGER_DIR, payload.marker_name);
|
|
19025
19054
|
try {
|
|
19026
|
-
|
|
19055
|
+
renameSync5(fullPath, `${fullPath}.malformed.poison`);
|
|
19027
19056
|
} catch {
|
|
19028
19057
|
}
|
|
19029
19058
|
return;
|
|
@@ -19108,7 +19137,7 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
19108
19137
|
const next = slackNextRetryName(filename);
|
|
19109
19138
|
if (next) {
|
|
19110
19139
|
try {
|
|
19111
|
-
|
|
19140
|
+
renameSync5(fullPath, join16(SLACK_RECOVERY_OUTBOX_DIR, next.next));
|
|
19112
19141
|
if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
|
|
19113
19142
|
process.stderr.write(
|
|
19114
19143
|
`slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -19139,7 +19168,7 @@ function scanSlackRecoveryRetries() {
|
|
|
19139
19168
|
if (!SLACK_RECOVERY_OUTBOX_DIR) return;
|
|
19140
19169
|
let entries;
|
|
19141
19170
|
try {
|
|
19142
|
-
entries =
|
|
19171
|
+
entries = readdirSync5(SLACK_RECOVERY_OUTBOX_DIR);
|
|
19143
19172
|
} catch {
|
|
19144
19173
|
return;
|
|
19145
19174
|
}
|
|
@@ -19148,7 +19177,7 @@ function scanSlackRecoveryRetries() {
|
|
|
19148
19177
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
19149
19178
|
let mtimeMs;
|
|
19150
19179
|
try {
|
|
19151
|
-
mtimeMs = statSync2(
|
|
19180
|
+
mtimeMs = statSync2(join16(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
19152
19181
|
} catch {
|
|
19153
19182
|
continue;
|
|
19154
19183
|
}
|
|
@@ -19160,7 +19189,7 @@ function scanSlackRecoveryRetries() {
|
|
|
19160
19189
|
function startSlackRecoveryOutboxWatcher() {
|
|
19161
19190
|
if (!SLACK_RECOVERY_OUTBOX_DIR) return;
|
|
19162
19191
|
try {
|
|
19163
|
-
|
|
19192
|
+
mkdirSync9(SLACK_RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
|
|
19164
19193
|
} catch (err) {
|
|
19165
19194
|
process.stderr.write(
|
|
19166
19195
|
`slack-channel(${AGENT_CODE_NAME}): recovery outbox mkdir failed: ${err.message}
|
|
@@ -19169,7 +19198,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
19169
19198
|
return;
|
|
19170
19199
|
}
|
|
19171
19200
|
try {
|
|
19172
|
-
for (const f of
|
|
19201
|
+
for (const f of readdirSync5(SLACK_RECOVERY_OUTBOX_DIR)) {
|
|
19173
19202
|
if (isFirstAttemptSlackOutboxFile(f)) void processSlackRecoveryOutboxFile(f);
|
|
19174
19203
|
}
|
|
19175
19204
|
} catch {
|
|
@@ -19178,7 +19207,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
19178
19207
|
const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
19179
19208
|
if (event !== "rename" || !filename) return;
|
|
19180
19209
|
if (!isFirstAttemptSlackOutboxFile(filename)) return;
|
|
19181
|
-
if (
|
|
19210
|
+
if (existsSync10(join16(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
|
|
19182
19211
|
void processSlackRecoveryOutboxFile(filename);
|
|
19183
19212
|
}
|
|
19184
19213
|
});
|
|
@@ -19193,7 +19222,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
19193
19222
|
retryTimer.unref?.();
|
|
19194
19223
|
}
|
|
19195
19224
|
startSlackRecoveryOutboxWatcher();
|
|
19196
|
-
var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
19225
|
+
var SLACK_NOTICE_OUTBOX_DIR = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "slack-notice-outbox") : null;
|
|
19197
19226
|
var SLACK_NOTICE_MAX_AGE_MS = 9e4;
|
|
19198
19227
|
var SLACK_NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
|
|
19199
19228
|
async function processSlackNoticeOutboxFile(filename) {
|
|
@@ -19201,7 +19230,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19201
19230
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
19202
19231
|
if (SLACK_NOTICE_INFLIGHT.has(filename)) return;
|
|
19203
19232
|
SLACK_NOTICE_INFLIGHT.add(filename);
|
|
19204
|
-
const fullPath =
|
|
19233
|
+
const fullPath = join16(SLACK_NOTICE_OUTBOX_DIR, filename);
|
|
19205
19234
|
try {
|
|
19206
19235
|
let mtimeMs;
|
|
19207
19236
|
try {
|
|
@@ -19218,7 +19247,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19218
19247
|
}
|
|
19219
19248
|
let payload;
|
|
19220
19249
|
try {
|
|
19221
|
-
const parsed = JSON.parse(
|
|
19250
|
+
const parsed = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
19222
19251
|
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
19223
19252
|
payload = parsed;
|
|
19224
19253
|
} catch {
|
|
@@ -19292,7 +19321,7 @@ async function processSlackNoticeOutboxFile(filename) {
|
|
|
19292
19321
|
function startSlackNoticeOutboxWatcher() {
|
|
19293
19322
|
if (!SLACK_NOTICE_OUTBOX_DIR) return;
|
|
19294
19323
|
try {
|
|
19295
|
-
|
|
19324
|
+
mkdirSync9(SLACK_NOTICE_OUTBOX_DIR, { recursive: true, mode: 448 });
|
|
19296
19325
|
} catch (err) {
|
|
19297
19326
|
process.stderr.write(
|
|
19298
19327
|
`slack-channel(${AGENT_CODE_NAME}): notice outbox mkdir failed: ${err.message}
|
|
@@ -19301,13 +19330,13 @@ function startSlackNoticeOutboxWatcher() {
|
|
|
19301
19330
|
return;
|
|
19302
19331
|
}
|
|
19303
19332
|
try {
|
|
19304
|
-
for (const f of
|
|
19333
|
+
for (const f of readdirSync5(SLACK_NOTICE_OUTBOX_DIR)) void processSlackNoticeOutboxFile(f);
|
|
19305
19334
|
} catch {
|
|
19306
19335
|
}
|
|
19307
19336
|
try {
|
|
19308
19337
|
const watcher = watch(SLACK_NOTICE_OUTBOX_DIR, (event, filename) => {
|
|
19309
19338
|
if (event !== "rename" || !filename) return;
|
|
19310
|
-
if (
|
|
19339
|
+
if (existsSync10(join16(SLACK_NOTICE_OUTBOX_DIR, filename))) {
|
|
19311
19340
|
void processSlackNoticeOutboxFile(filename);
|
|
19312
19341
|
}
|
|
19313
19342
|
});
|
|
@@ -19327,10 +19356,10 @@ function trackPendingMessage(channel, threadTs, messageTs, undeliverable = false
|
|
|
19327
19356
|
}
|
|
19328
19357
|
function sweepSlackStaleMarkers(thresholdMs) {
|
|
19329
19358
|
if (!SLACK_PENDING_INBOUND_DIR) return;
|
|
19330
|
-
if (!
|
|
19359
|
+
if (!existsSync10(SLACK_PENDING_INBOUND_DIR)) return;
|
|
19331
19360
|
let filenames;
|
|
19332
19361
|
try {
|
|
19333
|
-
filenames =
|
|
19362
|
+
filenames = readdirSync5(SLACK_PENDING_INBOUND_DIR);
|
|
19334
19363
|
} catch (err) {
|
|
19335
19364
|
process.stderr.write(
|
|
19336
19365
|
`slack-channel(${AGENT_CODE_NAME}): stale-marker readdir failed: ${err.message}
|
|
@@ -19343,10 +19372,10 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
19343
19372
|
for (const filename of filenames) {
|
|
19344
19373
|
if (!filename.endsWith(".json")) continue;
|
|
19345
19374
|
if (filename.endsWith(".tmp")) continue;
|
|
19346
|
-
const fullPath =
|
|
19375
|
+
const fullPath = join16(SLACK_PENDING_INBOUND_DIR, filename);
|
|
19347
19376
|
let marker;
|
|
19348
19377
|
try {
|
|
19349
|
-
marker = JSON.parse(
|
|
19378
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
19350
19379
|
} catch (err) {
|
|
19351
19380
|
process.stderr.write(
|
|
19352
19381
|
`slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
|
|
@@ -19396,13 +19425,13 @@ var slackOrphanSweepTimer = setInterval(() => {
|
|
|
19396
19425
|
checkSlackWatchdogGiveUpNotice();
|
|
19397
19426
|
}, orphanSweepIntervalMs());
|
|
19398
19427
|
slackOrphanSweepTimer.unref?.();
|
|
19399
|
-
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ?
|
|
19428
|
+
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join16(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
19400
19429
|
var slackTrackedProgress = null;
|
|
19401
19430
|
var slackProgressTickRunning = false;
|
|
19402
19431
|
function readSlackProgressHeartbeat() {
|
|
19403
|
-
if (!SLACK_PROGRESS_HEARTBEAT_PATH || !
|
|
19432
|
+
if (!SLACK_PROGRESS_HEARTBEAT_PATH || !existsSync10(SLACK_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
19404
19433
|
try {
|
|
19405
|
-
return parseProgressHeartbeat(
|
|
19434
|
+
return parseProgressHeartbeat(readFileSync16(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
19406
19435
|
} catch {
|
|
19407
19436
|
return null;
|
|
19408
19437
|
}
|
|
@@ -19411,8 +19440,8 @@ function seedSlackProgressHeartbeat() {
|
|
|
19411
19440
|
if (!SLACK_PROGRESS_HEARTBEAT_PATH) return;
|
|
19412
19441
|
const tmp = `${SLACK_PROGRESS_HEARTBEAT_PATH}.${process.pid}.tmp`;
|
|
19413
19442
|
try {
|
|
19414
|
-
|
|
19415
|
-
|
|
19443
|
+
writeFileSync13(tmp, serializeProgressHeartbeat(SEED_PROGRESS_STEP, Date.now()), { mode: 384 });
|
|
19444
|
+
renameSync5(tmp, SLACK_PROGRESS_HEARTBEAT_PATH);
|
|
19416
19445
|
} catch {
|
|
19417
19446
|
try {
|
|
19418
19447
|
unlinkSync7(tmp);
|
|
@@ -19421,15 +19450,15 @@ function seedSlackProgressHeartbeat() {
|
|
|
19421
19450
|
}
|
|
19422
19451
|
}
|
|
19423
19452
|
function findSlackProgressTarget() {
|
|
19424
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
19453
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync10(SLACK_PENDING_INBOUND_DIR)) return null;
|
|
19425
19454
|
let best = null;
|
|
19426
19455
|
let bestMs = Infinity;
|
|
19427
19456
|
try {
|
|
19428
|
-
for (const name of
|
|
19457
|
+
for (const name of readdirSync5(SLACK_PENDING_INBOUND_DIR)) {
|
|
19429
19458
|
if (!name.endsWith(".json")) continue;
|
|
19430
19459
|
let m;
|
|
19431
19460
|
try {
|
|
19432
|
-
m = JSON.parse(
|
|
19461
|
+
m = JSON.parse(readFileSync16(join16(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
|
|
19433
19462
|
} catch {
|
|
19434
19463
|
continue;
|
|
19435
19464
|
}
|
|
@@ -19573,14 +19602,14 @@ if (BOT_TOKEN && SLACK_PENDING_INBOUND_DIR) {
|
|
|
19573
19602
|
}
|
|
19574
19603
|
var lastSlackGiveUpHandledAtMs = null;
|
|
19575
19604
|
function listPendingSlackConversations() {
|
|
19576
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
19605
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync10(SLACK_PENDING_INBOUND_DIR)) return [];
|
|
19577
19606
|
const byKey = /* @__PURE__ */ new Map();
|
|
19578
19607
|
try {
|
|
19579
|
-
for (const name of
|
|
19608
|
+
for (const name of readdirSync5(SLACK_PENDING_INBOUND_DIR)) {
|
|
19580
19609
|
if (!name.endsWith(".json")) continue;
|
|
19581
19610
|
try {
|
|
19582
19611
|
const marker = JSON.parse(
|
|
19583
|
-
|
|
19612
|
+
readFileSync16(join16(SLACK_PENDING_INBOUND_DIR, name), "utf8")
|
|
19584
19613
|
);
|
|
19585
19614
|
if (typeof marker.channel !== "string" || !marker.channel) continue;
|
|
19586
19615
|
if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
|
|
@@ -19632,7 +19661,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply, reason)
|
|
|
19632
19661
|
}
|
|
19633
19662
|
function checkSlackWatchdogGiveUpNotice() {
|
|
19634
19663
|
if (!SLACK_AGENT_DIR) return;
|
|
19635
|
-
const signal = readGiveUpSignal(
|
|
19664
|
+
const signal = readGiveUpSignal(join16(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
19636
19665
|
const signalAtMs = signal?.atMs ?? null;
|
|
19637
19666
|
const act = decideGiveUpNotice({
|
|
19638
19667
|
signalAtMs,
|
|
@@ -19666,10 +19695,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
19666
19695
|
strandedInboundNoticeInFlight = true;
|
|
19667
19696
|
let hadFailure = false;
|
|
19668
19697
|
try {
|
|
19669
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
19698
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync10(SLACK_PENDING_INBOUND_DIR)) return;
|
|
19670
19699
|
let filenames;
|
|
19671
19700
|
try {
|
|
19672
|
-
filenames =
|
|
19701
|
+
filenames = readdirSync5(SLACK_PENDING_INBOUND_DIR);
|
|
19673
19702
|
} catch {
|
|
19674
19703
|
hadFailure = true;
|
|
19675
19704
|
return;
|
|
@@ -19679,10 +19708,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
19679
19708
|
let notified = 0;
|
|
19680
19709
|
for (const filename of filenames) {
|
|
19681
19710
|
if (!filename.endsWith(".json")) continue;
|
|
19682
|
-
const fullPath =
|
|
19711
|
+
const fullPath = join16(SLACK_PENDING_INBOUND_DIR, filename);
|
|
19683
19712
|
let marker;
|
|
19684
19713
|
try {
|
|
19685
|
-
marker = JSON.parse(
|
|
19714
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
19686
19715
|
} catch {
|
|
19687
19716
|
continue;
|
|
19688
19717
|
}
|
|
@@ -19853,7 +19882,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
|
|
|
19853
19882
|
markSeenAllSlackPendingMarkersForThread2(channel, messageTs);
|
|
19854
19883
|
markSeenSlackPendingMarkerByMessageTs2(channel, messageTs);
|
|
19855
19884
|
}
|
|
19856
|
-
var RESTART_FLAGS_DIR =
|
|
19885
|
+
var RESTART_FLAGS_DIR = join16(homedir4(), ".augmented", "restart-flags");
|
|
19857
19886
|
function actuateHostRestartSlack() {
|
|
19858
19887
|
return actuateHostRestart({
|
|
19859
19888
|
agtHost: AGT_HOST,
|
|
@@ -20455,10 +20484,10 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
20455
20484
|
writeSlackRestartConfirm(confirmReply, payload.user_name);
|
|
20456
20485
|
} else {
|
|
20457
20486
|
writeSlackRestartConfirm(confirmReply, payload.user_name);
|
|
20458
|
-
if (!
|
|
20459
|
-
|
|
20487
|
+
if (!existsSync10(RESTART_FLAGS_DIR)) {
|
|
20488
|
+
mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
|
|
20460
20489
|
}
|
|
20461
|
-
const flagPath =
|
|
20490
|
+
const flagPath = join16(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
20462
20491
|
const flag = {
|
|
20463
20492
|
codeName,
|
|
20464
20493
|
source: "slack",
|
|
@@ -20466,8 +20495,8 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
20466
20495
|
reply: confirmReply
|
|
20467
20496
|
};
|
|
20468
20497
|
const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
|
|
20469
|
-
|
|
20470
|
-
|
|
20498
|
+
writeFileSync13(tmpPath, JSON.stringify(flag) + "\n", "utf8");
|
|
20499
|
+
renameSync5(tmpPath, flagPath);
|
|
20471
20500
|
}
|
|
20472
20501
|
process.stderr.write(
|
|
20473
20502
|
`slack-channel(${codeName}): /restart slash-command queued from channel ${hashChannelId(payload.channel_id)}
|
|
@@ -20598,10 +20627,10 @@ async function handleRestartCommand(opts) {
|
|
|
20598
20627
|
writeSlackRestartConfirm(confirmReply, opts.requesterName);
|
|
20599
20628
|
} else {
|
|
20600
20629
|
writeSlackRestartConfirm(confirmReply, opts.requesterName);
|
|
20601
|
-
if (!
|
|
20602
|
-
|
|
20630
|
+
if (!existsSync10(RESTART_FLAGS_DIR)) {
|
|
20631
|
+
mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
|
|
20603
20632
|
}
|
|
20604
|
-
const flagPath =
|
|
20633
|
+
const flagPath = join16(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
20605
20634
|
const flag = {
|
|
20606
20635
|
codeName,
|
|
20607
20636
|
source: "slack",
|
|
@@ -20609,8 +20638,8 @@ async function handleRestartCommand(opts) {
|
|
|
20609
20638
|
reply: { ...confirmReply, message_ts: opts.ts }
|
|
20610
20639
|
};
|
|
20611
20640
|
const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
|
|
20612
|
-
|
|
20613
|
-
|
|
20641
|
+
writeFileSync13(tmpPath, JSON.stringify(flag) + "\n", "utf8");
|
|
20642
|
+
renameSync5(tmpPath, flagPath);
|
|
20614
20643
|
}
|
|
20615
20644
|
process.stderr.write(
|
|
20616
20645
|
`slack-channel(${codeName}): /restart queued from channel ${hashChannelId(opts.channel)}
|
|
@@ -20714,7 +20743,7 @@ var THREAD_STORE_TTL_DAYS = parseTtlDays(process.env.SLACK_THREAD_FOLLOW_TTL_DAY
|
|
|
20714
20743
|
var threadPersister = null;
|
|
20715
20744
|
function resolveThreadStorePath() {
|
|
20716
20745
|
if (!AGENT_CODE_NAME) return null;
|
|
20717
|
-
return
|
|
20746
|
+
return join16(homedir4(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
|
|
20718
20747
|
}
|
|
20719
20748
|
function parseTtlDays(raw) {
|
|
20720
20749
|
if (!raw) return void 0;
|
|
@@ -20753,9 +20782,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
|
|
|
20753
20782
|
var slackStderrLogStream = null;
|
|
20754
20783
|
if (AGENT_CODE_NAME) {
|
|
20755
20784
|
try {
|
|
20756
|
-
const logDir =
|
|
20757
|
-
|
|
20758
|
-
slackStderrLogStream = createWriteStream(
|
|
20785
|
+
const logDir = join16(homedir4(), ".augmented", AGENT_CODE_NAME);
|
|
20786
|
+
mkdirSync9(logDir, { recursive: true });
|
|
20787
|
+
slackStderrLogStream = createWriteStream(join16(logDir, "slack-channel-stderr.log"), {
|
|
20759
20788
|
flags: "a",
|
|
20760
20789
|
mode: 384
|
|
20761
20790
|
});
|
|
@@ -21333,6 +21362,14 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
21333
21362
|
};
|
|
21334
21363
|
}
|
|
21335
21364
|
settlePendingMarker();
|
|
21365
|
+
if (effectiveThreadTs) {
|
|
21366
|
+
writeInboundDeliveryLedgerEntry(SLACK_DELIVERY_LEDGER_DIR, {
|
|
21367
|
+
inbound_id: slackInboundId(effectiveChannel, effectiveThreadTs, effectiveMessageTs ?? ""),
|
|
21368
|
+
source: "slack",
|
|
21369
|
+
conv_key: effectiveThreadTs,
|
|
21370
|
+
delivered_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
21371
|
+
});
|
|
21372
|
+
}
|
|
21336
21373
|
recordReply(effectiveChannel, throttleKey, throttleNow, throttleCfg);
|
|
21337
21374
|
recordActivity("reply");
|
|
21338
21375
|
if (THREAD_AUTO_FOLLOW !== "off") {
|
|
@@ -21558,7 +21595,7 @@ ${result.formatted}` : "No messages in range, or the bot is not a member of this
|
|
|
21558
21595
|
};
|
|
21559
21596
|
}
|
|
21560
21597
|
size = stat2.size;
|
|
21561
|
-
bytes =
|
|
21598
|
+
bytes = readFileSync16(resolvedPath);
|
|
21562
21599
|
} catch (err) {
|
|
21563
21600
|
return {
|
|
21564
21601
|
content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
|
|
@@ -22271,8 +22308,8 @@ async function downloadSlackFile(fileId, codeName) {
|
|
|
22271
22308
|
if (!isPathInside(savedPath, dir)) {
|
|
22272
22309
|
throw new Error(`refusing to write ${savedPath} outside ${dir}`);
|
|
22273
22310
|
}
|
|
22274
|
-
|
|
22275
|
-
|
|
22311
|
+
mkdirSync9(dir, { recursive: true });
|
|
22312
|
+
writeFileSync13(savedPath, bytes, { mode: 384 });
|
|
22276
22313
|
try {
|
|
22277
22314
|
chmodSync(savedPath, 384);
|
|
22278
22315
|
} catch {
|
|
@@ -22327,13 +22364,13 @@ await mcp.connect(new StdioServerTransport());
|
|
|
22327
22364
|
var SLACK_REPLAY_SCAN_INTERVAL_MS = 6e4;
|
|
22328
22365
|
async function replayPendingSlackMarkers() {
|
|
22329
22366
|
if (!channelReplayEnabled()) return;
|
|
22330
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
22367
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync10(SLACK_PENDING_INBOUND_DIR)) return;
|
|
22331
22368
|
const probe = process.env.TMUX && AGENT_CODE_NAME ? probeAgentSessionCached(AGENT_CODE_NAME) : { tmux: "unknown", claude: "unknown" };
|
|
22332
22369
|
const sessionAlive = probe.tmux === "alive" && probe.claude === "alive";
|
|
22333
22370
|
if (!sessionAlive) return;
|
|
22334
22371
|
let filenames;
|
|
22335
22372
|
try {
|
|
22336
|
-
filenames =
|
|
22373
|
+
filenames = readdirSync5(SLACK_PENDING_INBOUND_DIR);
|
|
22337
22374
|
} catch {
|
|
22338
22375
|
return;
|
|
22339
22376
|
}
|
|
@@ -22341,7 +22378,7 @@ async function replayPendingSlackMarkers() {
|
|
|
22341
22378
|
let paneFreshAgeMs = null;
|
|
22342
22379
|
if (SLACK_AGENT_DIR) {
|
|
22343
22380
|
try {
|
|
22344
|
-
paneFreshAgeMs = Math.max(0, now - statSync2(
|
|
22381
|
+
paneFreshAgeMs = Math.max(0, now - statSync2(join16(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
|
|
22345
22382
|
} catch {
|
|
22346
22383
|
}
|
|
22347
22384
|
}
|
|
@@ -22349,10 +22386,10 @@ async function replayPendingSlackMarkers() {
|
|
|
22349
22386
|
const entries = [];
|
|
22350
22387
|
for (const name of filenames) {
|
|
22351
22388
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
22352
|
-
const fullPath =
|
|
22389
|
+
const fullPath = join16(SLACK_PENDING_INBOUND_DIR, name);
|
|
22353
22390
|
let marker;
|
|
22354
22391
|
try {
|
|
22355
|
-
marker = JSON.parse(
|
|
22392
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
22356
22393
|
} catch {
|
|
22357
22394
|
continue;
|
|
22358
22395
|
}
|
|
@@ -22910,7 +22947,7 @@ async function connectSocketMode() {
|
|
|
22910
22947
|
let paneLogFreshAgeMs = null;
|
|
22911
22948
|
if (SLACK_AGENT_DIR) {
|
|
22912
22949
|
try {
|
|
22913
|
-
const paneMtimeMs = statSync2(
|
|
22950
|
+
const paneMtimeMs = statSync2(join16(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
22914
22951
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
22915
22952
|
} catch {
|
|
22916
22953
|
}
|