@integrity-labs/agt-cli 0.27.137 → 0.27.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/agt.js +4 -4
- package/dist/{chunk-TDMOEMDM.js → chunk-PDDU4Z5V.js} +26 -9
- package/dist/chunk-PDDU4Z5V.js.map +1 -0
- package/dist/{chunk-YJOFVGD2.js → chunk-RT37WJXI.js} +2 -2
- package/dist/{chunk-UIRCFCED.js → chunk-SCZVYC5P.js} +2 -2
- package/dist/{claude-pair-runtime-ZOHU673W.js → claude-pair-runtime-CNTCM57R.js} +2 -2
- package/dist/lib/manager-worker.js +9 -9
- package/dist/mcp/slack-channel.js +146 -69
- package/dist/mcp/telegram-channel.js +178 -49
- package/dist/{persistent-session-NSN62HZN.js → persistent-session-WWEAEEL4.js} +3 -3
- package/dist/{responsiveness-probe-RF5ZCTE7.js → responsiveness-probe-MCKI22FY.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-TDMOEMDM.js.map +0 -1
- /package/dist/{chunk-YJOFVGD2.js.map → chunk-RT37WJXI.js.map} +0 -0
- /package/dist/{chunk-UIRCFCED.js.map → chunk-SCZVYC5P.js.map} +0 -0
- /package/dist/{claude-pair-runtime-ZOHU673W.js.map → claude-pair-runtime-CNTCM57R.js.map} +0 -0
- /package/dist/{persistent-session-NSN62HZN.js.map → persistent-session-WWEAEEL4.js.map} +0 -0
- /package/dist/{responsiveness-probe-RF5ZCTE7.js.map → responsiveness-probe-MCKI22FY.js.map} +0 -0
|
@@ -14477,6 +14477,81 @@ function probeAgentSessionCached(codeName, ttlMs = SESSION_PROBE_TTL_MS, now = D
|
|
|
14477
14477
|
return value;
|
|
14478
14478
|
}
|
|
14479
14479
|
|
|
14480
|
+
// src/agent-config-state.ts
|
|
14481
|
+
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
14482
|
+
import { join as join2 } from "path";
|
|
14483
|
+
var SESSION_STATE_FILENAME = "session-state.json";
|
|
14484
|
+
function readAgentSessionState(stateDir) {
|
|
14485
|
+
if (!stateDir) return null;
|
|
14486
|
+
const path = join2(stateDir, SESSION_STATE_FILENAME);
|
|
14487
|
+
if (!existsSync(path)) return null;
|
|
14488
|
+
try {
|
|
14489
|
+
const parsed = JSON.parse(readFileSync2(path, "utf-8"));
|
|
14490
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
14491
|
+
return parsed;
|
|
14492
|
+
} catch {
|
|
14493
|
+
return null;
|
|
14494
|
+
}
|
|
14495
|
+
}
|
|
14496
|
+
function describeSessionOrigin(source) {
|
|
14497
|
+
switch (source) {
|
|
14498
|
+
case "startup":
|
|
14499
|
+
return "fresh start";
|
|
14500
|
+
case "resume":
|
|
14501
|
+
return "resumed";
|
|
14502
|
+
case "clear":
|
|
14503
|
+
return "cleared (/clear)";
|
|
14504
|
+
case "compact":
|
|
14505
|
+
return "compacted";
|
|
14506
|
+
default:
|
|
14507
|
+
return "unknown";
|
|
14508
|
+
}
|
|
14509
|
+
}
|
|
14510
|
+
function formatModelLabel(model) {
|
|
14511
|
+
const trimmed = model?.trim();
|
|
14512
|
+
return trimmed && trimmed.length > 0 ? trimmed : "unknown";
|
|
14513
|
+
}
|
|
14514
|
+
function shortSessionId(id) {
|
|
14515
|
+
const trimmed = id?.trim();
|
|
14516
|
+
if (!trimmed) return "unknown";
|
|
14517
|
+
return trimmed.length > 8 ? trimmed.slice(0, 8) : trimmed;
|
|
14518
|
+
}
|
|
14519
|
+
function formatRelativeAge(ts, now = Date.now()) {
|
|
14520
|
+
if (typeof ts !== "number" || !Number.isFinite(ts) || ts <= 0) return "unknown";
|
|
14521
|
+
const seconds = Math.floor((now - ts) / 1e3);
|
|
14522
|
+
if (seconds < 0) return "unknown";
|
|
14523
|
+
if (seconds < 5) return "just now";
|
|
14524
|
+
if (seconds < 60) return `${seconds}s ago`;
|
|
14525
|
+
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
|
|
14526
|
+
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
|
|
14527
|
+
return `${Math.floor(seconds / 86400)}d ago`;
|
|
14528
|
+
}
|
|
14529
|
+
function formatChannels(channels) {
|
|
14530
|
+
if (!Array.isArray(channels) || channels.length === 0) return "unknown";
|
|
14531
|
+
const cleaned = channels.map((c) => String(c).trim()).filter((c) => c.length > 0);
|
|
14532
|
+
return cleaned.length > 0 ? cleaned.join(", ") : "unknown";
|
|
14533
|
+
}
|
|
14534
|
+
function buildAgentConfigReport(opts) {
|
|
14535
|
+
const { codeName, connectivityLine, state, now = Date.now() } = opts;
|
|
14536
|
+
const lines = [`\u{1F916} *Config for \`${codeName}\`*`, connectivityLine];
|
|
14537
|
+
if (!state) {
|
|
14538
|
+
lines.push("\u2022 *Model:* unknown \u2014 session state not recorded yet");
|
|
14539
|
+
lines.push("\u2022 *Session:* unknown");
|
|
14540
|
+
return lines.join("\n");
|
|
14541
|
+
}
|
|
14542
|
+
lines.push(`\u2022 *Model:* \`${formatModelLabel(state.model)}\``);
|
|
14543
|
+
const origin = describeSessionOrigin(state.source);
|
|
14544
|
+
const age = formatRelativeAge(state.recorded_at, now);
|
|
14545
|
+
const sessionLine = age === "unknown" ? `\u2022 *Session:* ${origin}` : `\u2022 *Session:* ${origin} \xB7 started ${age}`;
|
|
14546
|
+
lines.push(sessionLine);
|
|
14547
|
+
lines.push(`\u2022 *Session ID:* \`${shortSessionId(state.session_id)}\``);
|
|
14548
|
+
if (state.environment && state.environment.trim().length > 0) {
|
|
14549
|
+
lines.push(`\u2022 *Environment:* ${state.environment.trim()}`);
|
|
14550
|
+
}
|
|
14551
|
+
lines.push(`\u2022 *Channels:* ${formatChannels(state.channels)}`);
|
|
14552
|
+
return lines.join("\n");
|
|
14553
|
+
}
|
|
14554
|
+
|
|
14480
14555
|
// src/pane-tail.ts
|
|
14481
14556
|
import { execFile } from "child_process";
|
|
14482
14557
|
import { promisify } from "util";
|
|
@@ -14484,9 +14559,9 @@ import { open, stat } from "fs/promises";
|
|
|
14484
14559
|
|
|
14485
14560
|
// src/channel-attachments.ts
|
|
14486
14561
|
import { homedir } from "os";
|
|
14487
|
-
import { join as
|
|
14562
|
+
import { join as join3, resolve, sep } from "path";
|
|
14488
14563
|
function resolveChannelInboundDir(codeName, channelSlug) {
|
|
14489
|
-
const base =
|
|
14564
|
+
const base = join3(homedir(), ".augmented");
|
|
14490
14565
|
const allowedSegment = /^[A-Za-z0-9_-]+$/;
|
|
14491
14566
|
if (!allowedSegment.test(codeName) || !allowedSegment.test(channelSlug)) {
|
|
14492
14567
|
throw new Error(
|
|
@@ -14912,14 +14987,14 @@ var SLACK_EGRESS_TOOLS = /* @__PURE__ */ new Set([
|
|
|
14912
14987
|
]);
|
|
14913
14988
|
|
|
14914
14989
|
// src/slack-pending-inbound-cleanup.ts
|
|
14915
|
-
import { existsSync, readdirSync as readdirSync2, statSync, unlinkSync } from "fs";
|
|
14916
|
-
import { join as
|
|
14990
|
+
import { existsSync as existsSync2, readdirSync as readdirSync2, statSync, unlinkSync } from "fs";
|
|
14991
|
+
import { join as join4 } from "path";
|
|
14917
14992
|
function sanitizeMarkerSegment(value) {
|
|
14918
14993
|
return value.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
14919
14994
|
}
|
|
14920
14995
|
var defaultClearMarkerFile = (fullPath) => {
|
|
14921
14996
|
try {
|
|
14922
|
-
if (
|
|
14997
|
+
if (existsSync2(fullPath)) unlinkSync(fullPath);
|
|
14923
14998
|
} catch {
|
|
14924
14999
|
}
|
|
14925
15000
|
};
|
|
@@ -14930,7 +15005,7 @@ function clearAllSlackPendingMarkersForThread(dir, channel, threadTs, clear = de
|
|
|
14930
15005
|
try {
|
|
14931
15006
|
for (const f of readdirSync2(dir)) {
|
|
14932
15007
|
if (!f.startsWith(prefix) || !f.endsWith(".json")) continue;
|
|
14933
|
-
clear(
|
|
15008
|
+
clear(join4(dir, f));
|
|
14934
15009
|
cleared += 1;
|
|
14935
15010
|
}
|
|
14936
15011
|
} catch {
|
|
@@ -14945,7 +15020,7 @@ function clearSlackPendingMarkerByMessageTs(dir, channel, messageTs, clear = def
|
|
|
14945
15020
|
try {
|
|
14946
15021
|
for (const f of readdirSync2(dir)) {
|
|
14947
15022
|
if (!f.startsWith(channelPrefix) || !f.endsWith(messageSuffix)) continue;
|
|
14948
|
-
clear(
|
|
15023
|
+
clear(join4(dir, f));
|
|
14949
15024
|
cleared += 1;
|
|
14950
15025
|
}
|
|
14951
15026
|
} catch {
|
|
@@ -14957,7 +15032,7 @@ function clearOldestSlackPendingMarkerInChannel(dir, channel, clear = defaultCle
|
|
|
14957
15032
|
const channelPrefix = `${sanitizeMarkerSegment(channel)}__`;
|
|
14958
15033
|
try {
|
|
14959
15034
|
const entries = readdirSync2(dir).filter((f) => f.startsWith(channelPrefix) && f.endsWith(".json")).map((f) => {
|
|
14960
|
-
const full =
|
|
15035
|
+
const full = join4(dir, f);
|
|
14961
15036
|
let mtime = 0;
|
|
14962
15037
|
try {
|
|
14963
15038
|
mtime = statSync(full).mtimeMs;
|
|
@@ -14975,7 +15050,7 @@ function clearOldestSlackPendingMarkerInChannel(dir, channel, clear = defaultCle
|
|
|
14975
15050
|
}
|
|
14976
15051
|
|
|
14977
15052
|
// src/restart-confirm.ts
|
|
14978
|
-
import { existsSync as
|
|
15053
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, renameSync, unlinkSync as unlinkSync2, writeFileSync } from "fs";
|
|
14979
15054
|
import { dirname } from "path";
|
|
14980
15055
|
import { randomUUID } from "crypto";
|
|
14981
15056
|
var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
@@ -14993,15 +15068,15 @@ function buildBackOnlineText(name) {
|
|
|
14993
15068
|
}
|
|
14994
15069
|
function writeRestartConfirmMarker(filePath, marker) {
|
|
14995
15070
|
const dir = dirname(filePath);
|
|
14996
|
-
if (!
|
|
15071
|
+
if (!existsSync3(dir)) mkdirSync(dir, { recursive: true, mode: 448 });
|
|
14997
15072
|
const tmpPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
14998
15073
|
writeFileSync(tmpPath, JSON.stringify(marker) + "\n", { encoding: "utf8", mode: 384 });
|
|
14999
15074
|
renameSync(tmpPath, filePath);
|
|
15000
15075
|
}
|
|
15001
15076
|
function readRestartConfirmMarker(filePath) {
|
|
15002
15077
|
try {
|
|
15003
|
-
if (!
|
|
15004
|
-
const parsed = JSON.parse(
|
|
15078
|
+
if (!existsSync3(filePath)) return null;
|
|
15079
|
+
const parsed = JSON.parse(readFileSync3(filePath, "utf8"));
|
|
15005
15080
|
if (!parsed || typeof parsed !== "object") return null;
|
|
15006
15081
|
return parsed;
|
|
15007
15082
|
} catch {
|
|
@@ -15010,7 +15085,7 @@ function readRestartConfirmMarker(filePath) {
|
|
|
15010
15085
|
}
|
|
15011
15086
|
function clearRestartConfirmMarker(filePath) {
|
|
15012
15087
|
try {
|
|
15013
|
-
if (
|
|
15088
|
+
if (existsSync3(filePath)) unlinkSync2(filePath);
|
|
15014
15089
|
} catch {
|
|
15015
15090
|
}
|
|
15016
15091
|
}
|
|
@@ -15111,9 +15186,9 @@ var StdioServerTransport = class {
|
|
|
15111
15186
|
import {
|
|
15112
15187
|
chmodSync,
|
|
15113
15188
|
createWriteStream,
|
|
15114
|
-
existsSync as
|
|
15189
|
+
existsSync as existsSync6,
|
|
15115
15190
|
mkdirSync as mkdirSync5,
|
|
15116
|
-
readFileSync as
|
|
15191
|
+
readFileSync as readFileSync7,
|
|
15117
15192
|
readdirSync as readdirSync3,
|
|
15118
15193
|
renameSync as renameSync3,
|
|
15119
15194
|
statSync as statSync2,
|
|
@@ -15121,12 +15196,12 @@ import {
|
|
|
15121
15196
|
watch,
|
|
15122
15197
|
writeFileSync as writeFileSync5
|
|
15123
15198
|
} from "fs";
|
|
15124
|
-
import { basename, join as
|
|
15199
|
+
import { basename, join as join6, resolve as resolve2 } from "path";
|
|
15125
15200
|
import { homedir as homedir2 } from "os";
|
|
15126
15201
|
import { createHash, randomUUID as randomUUID2 } from "crypto";
|
|
15127
15202
|
|
|
15128
15203
|
// src/slack-thread-store.ts
|
|
15129
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
15204
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
15130
15205
|
import { dirname as dirname2 } from "path";
|
|
15131
15206
|
var FILE_VERSION = 1;
|
|
15132
15207
|
var DEFAULT_TTL_DAYS = 30;
|
|
@@ -15137,7 +15212,7 @@ function loadThreadStore(filePath, opts = {}) {
|
|
|
15137
15212
|
const ttlMs = ttlDays * 24 * 60 * 60 * 1e3;
|
|
15138
15213
|
let raw;
|
|
15139
15214
|
try {
|
|
15140
|
-
raw =
|
|
15215
|
+
raw = readFileSync4(filePath, "utf-8");
|
|
15141
15216
|
} catch {
|
|
15142
15217
|
return { threads: /* @__PURE__ */ new Map(), pruned: 0 };
|
|
15143
15218
|
}
|
|
@@ -15251,7 +15326,7 @@ async function runOrRetry(fn, opts) {
|
|
|
15251
15326
|
}
|
|
15252
15327
|
|
|
15253
15328
|
// src/slack-bot-photo.ts
|
|
15254
|
-
import { existsSync as
|
|
15329
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
15255
15330
|
import { dirname as dirname3 } from "path";
|
|
15256
15331
|
async function applyBotPhoto(opts) {
|
|
15257
15332
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
@@ -15259,9 +15334,9 @@ async function applyBotPhoto(opts) {
|
|
|
15259
15334
|
process.stderr.write(m);
|
|
15260
15335
|
});
|
|
15261
15336
|
const { token, avatarUrl, markerPath } = opts;
|
|
15262
|
-
if (markerPath &&
|
|
15337
|
+
if (markerPath && existsSync4(markerPath)) {
|
|
15263
15338
|
try {
|
|
15264
|
-
if (
|
|
15339
|
+
if (readFileSync5(markerPath, "utf-8").trim() === avatarUrl) {
|
|
15265
15340
|
return { status: "skipped-unchanged" };
|
|
15266
15341
|
}
|
|
15267
15342
|
} catch {
|
|
@@ -16041,14 +16116,14 @@ function createSlackBotUserIdClient(args) {
|
|
|
16041
16116
|
|
|
16042
16117
|
// src/mcp-spawn-lock.ts
|
|
16043
16118
|
import {
|
|
16044
|
-
existsSync as
|
|
16119
|
+
existsSync as existsSync5,
|
|
16045
16120
|
mkdirSync as mkdirSync4,
|
|
16046
|
-
readFileSync as
|
|
16121
|
+
readFileSync as readFileSync6,
|
|
16047
16122
|
renameSync as renameSync2,
|
|
16048
16123
|
unlinkSync as unlinkSync3,
|
|
16049
16124
|
writeFileSync as writeFileSync4
|
|
16050
16125
|
} from "fs";
|
|
16051
|
-
import { join as
|
|
16126
|
+
import { join as join5 } from "path";
|
|
16052
16127
|
function defaultIsPidAlive(pid) {
|
|
16053
16128
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
16054
16129
|
try {
|
|
@@ -16066,7 +16141,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
16066
16141
|
const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
|
|
16067
16142
|
const selfPid = options.selfPid ?? process.pid;
|
|
16068
16143
|
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
16069
|
-
const path =
|
|
16144
|
+
const path = join5(agentDir, basename2);
|
|
16070
16145
|
const existing = readLockHolder(path);
|
|
16071
16146
|
if (existing) {
|
|
16072
16147
|
if (existing.pid === selfPid) {
|
|
@@ -16095,9 +16170,9 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
|
16095
16170
|
}
|
|
16096
16171
|
}
|
|
16097
16172
|
function readLockHolder(path) {
|
|
16098
|
-
if (!
|
|
16173
|
+
if (!existsSync5(path)) return null;
|
|
16099
16174
|
try {
|
|
16100
|
-
const raw =
|
|
16175
|
+
const raw = readFileSync6(path, "utf8");
|
|
16101
16176
|
const parsed = JSON.parse(raw);
|
|
16102
16177
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
16103
16178
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -16275,12 +16350,12 @@ var SLACK_PEER_CLASSIFIER_CONFIG = {
|
|
|
16275
16350
|
peers: parsePeersEnv(process.env.SLACK_PEERS, process.env.SLACK_PEERS_GATE),
|
|
16276
16351
|
peer_disabled_mode: SLACK_PEER_DISABLED_MODE
|
|
16277
16352
|
};
|
|
16278
|
-
var SLACK_AGENT_DIR = AGENT_CODE_NAME ?
|
|
16279
|
-
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ?
|
|
16280
|
-
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
16281
|
-
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ?
|
|
16353
|
+
var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join6(homedir2(), ".augmented", AGENT_CODE_NAME) : null;
|
|
16354
|
+
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
|
|
16355
|
+
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
|
|
16356
|
+
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
|
|
16282
16357
|
var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
|
|
16283
|
-
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ?
|
|
16358
|
+
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join6(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
|
|
16284
16359
|
function redactSlackId(id) {
|
|
16285
16360
|
if (!id) return "<none>";
|
|
16286
16361
|
return createHash("sha256").update(id).digest("hex").slice(0, 8);
|
|
@@ -16291,7 +16366,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
|
|
|
16291
16366
|
}
|
|
16292
16367
|
function slackPendingInboundPath(channel, threadTs, messageTs) {
|
|
16293
16368
|
if (!SLACK_PENDING_INBOUND_DIR) return null;
|
|
16294
|
-
return
|
|
16369
|
+
return join6(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
|
|
16295
16370
|
}
|
|
16296
16371
|
function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false) {
|
|
16297
16372
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
@@ -16316,9 +16391,9 @@ function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undelivera
|
|
|
16316
16391
|
}
|
|
16317
16392
|
function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
|
|
16318
16393
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
16319
|
-
if (!path || !
|
|
16394
|
+
if (!path || !existsSync6(path)) return null;
|
|
16320
16395
|
try {
|
|
16321
|
-
return JSON.parse(
|
|
16396
|
+
return JSON.parse(readFileSync7(path, "utf-8"));
|
|
16322
16397
|
} catch {
|
|
16323
16398
|
return null;
|
|
16324
16399
|
}
|
|
@@ -16412,7 +16487,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply) {
|
|
|
16412
16487
|
let paneLogFreshAgeMs = null;
|
|
16413
16488
|
if (SLACK_AGENT_DIR) {
|
|
16414
16489
|
try {
|
|
16415
|
-
const paneMtimeMs = statSync2(
|
|
16490
|
+
const paneMtimeMs = statSync2(join6(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
16416
16491
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
16417
16492
|
} catch {
|
|
16418
16493
|
}
|
|
@@ -16437,7 +16512,7 @@ function __resetSlackBusyAckNoticeThrottle() {
|
|
|
16437
16512
|
function clearSlackMarkerFileWithHeal(fullPath) {
|
|
16438
16513
|
let marker = null;
|
|
16439
16514
|
try {
|
|
16440
|
-
marker = JSON.parse(
|
|
16515
|
+
marker = JSON.parse(readFileSync7(fullPath, "utf-8"));
|
|
16441
16516
|
} catch {
|
|
16442
16517
|
}
|
|
16443
16518
|
if (marker && decideRecoveryHeal({
|
|
@@ -16447,7 +16522,7 @@ function clearSlackMarkerFileWithHeal(fullPath) {
|
|
|
16447
16522
|
healSlackUndeliverable(marker.channel, marker.message_ts);
|
|
16448
16523
|
}
|
|
16449
16524
|
try {
|
|
16450
|
-
if (
|
|
16525
|
+
if (existsSync6(fullPath)) unlinkSync4(fullPath);
|
|
16451
16526
|
} catch {
|
|
16452
16527
|
}
|
|
16453
16528
|
}
|
|
@@ -16488,10 +16563,10 @@ function slackNextRetryName(filename) {
|
|
|
16488
16563
|
async function processSlackRecoveryOutboxFile(filename) {
|
|
16489
16564
|
if (!SLACK_RECOVERY_OUTBOX_DIR) return;
|
|
16490
16565
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
16491
|
-
const fullPath =
|
|
16566
|
+
const fullPath = join6(SLACK_RECOVERY_OUTBOX_DIR, filename);
|
|
16492
16567
|
let payload;
|
|
16493
16568
|
try {
|
|
16494
|
-
payload = JSON.parse(
|
|
16569
|
+
payload = JSON.parse(readFileSync7(fullPath, "utf-8"));
|
|
16495
16570
|
} catch (err) {
|
|
16496
16571
|
process.stderr.write(
|
|
16497
16572
|
`slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
|
|
@@ -16565,7 +16640,7 @@ async function processSlackRecoveryOutboxFile(filename) {
|
|
|
16565
16640
|
const next = slackNextRetryName(filename);
|
|
16566
16641
|
if (next) {
|
|
16567
16642
|
try {
|
|
16568
|
-
renameSync3(fullPath,
|
|
16643
|
+
renameSync3(fullPath, join6(SLACK_RECOVERY_OUTBOX_DIR, next.next));
|
|
16569
16644
|
if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
|
|
16570
16645
|
process.stderr.write(
|
|
16571
16646
|
`slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -16604,7 +16679,7 @@ function scanSlackRecoveryRetries() {
|
|
|
16604
16679
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
16605
16680
|
let mtimeMs;
|
|
16606
16681
|
try {
|
|
16607
|
-
mtimeMs = statSync2(
|
|
16682
|
+
mtimeMs = statSync2(join6(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
16608
16683
|
} catch {
|
|
16609
16684
|
continue;
|
|
16610
16685
|
}
|
|
@@ -16634,7 +16709,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
16634
16709
|
const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
16635
16710
|
if (event !== "rename" || !filename) return;
|
|
16636
16711
|
if (!isFirstAttemptSlackOutboxFile(filename)) return;
|
|
16637
|
-
if (
|
|
16712
|
+
if (existsSync6(join6(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
|
|
16638
16713
|
void processSlackRecoveryOutboxFile(filename);
|
|
16639
16714
|
}
|
|
16640
16715
|
});
|
|
@@ -16655,7 +16730,7 @@ function trackPendingMessage(channel, threadTs, messageTs, undeliverable = false
|
|
|
16655
16730
|
}
|
|
16656
16731
|
function sweepSlackStaleMarkers(thresholdMs) {
|
|
16657
16732
|
if (!SLACK_PENDING_INBOUND_DIR) return;
|
|
16658
|
-
if (!
|
|
16733
|
+
if (!existsSync6(SLACK_PENDING_INBOUND_DIR)) return;
|
|
16659
16734
|
let filenames;
|
|
16660
16735
|
try {
|
|
16661
16736
|
filenames = readdirSync3(SLACK_PENDING_INBOUND_DIR);
|
|
@@ -16671,10 +16746,10 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
16671
16746
|
for (const filename of filenames) {
|
|
16672
16747
|
if (!filename.endsWith(".json")) continue;
|
|
16673
16748
|
if (filename.endsWith(".tmp")) continue;
|
|
16674
|
-
const fullPath =
|
|
16749
|
+
const fullPath = join6(SLACK_PENDING_INBOUND_DIR, filename);
|
|
16675
16750
|
let marker;
|
|
16676
16751
|
try {
|
|
16677
|
-
marker = JSON.parse(
|
|
16752
|
+
marker = JSON.parse(readFileSync7(fullPath, "utf-8"));
|
|
16678
16753
|
} catch (err) {
|
|
16679
16754
|
process.stderr.write(
|
|
16680
16755
|
`slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
|
|
@@ -16713,14 +16788,14 @@ var slackOrphanSweepTimer = setInterval(() => {
|
|
|
16713
16788
|
slackOrphanSweepTimer.unref?.();
|
|
16714
16789
|
var lastSlackGiveUpHandledAtMs = null;
|
|
16715
16790
|
function listPendingSlackConversations() {
|
|
16716
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
16791
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync6(SLACK_PENDING_INBOUND_DIR)) return [];
|
|
16717
16792
|
const byKey = /* @__PURE__ */ new Map();
|
|
16718
16793
|
try {
|
|
16719
16794
|
for (const name of readdirSync3(SLACK_PENDING_INBOUND_DIR)) {
|
|
16720
16795
|
if (!name.endsWith(".json")) continue;
|
|
16721
16796
|
try {
|
|
16722
16797
|
const marker = JSON.parse(
|
|
16723
|
-
|
|
16798
|
+
readFileSync7(join6(SLACK_PENDING_INBOUND_DIR, name), "utf8")
|
|
16724
16799
|
);
|
|
16725
16800
|
if (typeof marker.channel !== "string" || !marker.channel) continue;
|
|
16726
16801
|
if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
|
|
@@ -16770,7 +16845,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply) {
|
|
|
16770
16845
|
}
|
|
16771
16846
|
function checkSlackWatchdogGiveUpNotice() {
|
|
16772
16847
|
if (!SLACK_AGENT_DIR) return;
|
|
16773
|
-
const signalAtMs = readGiveUpSignalAtMs(
|
|
16848
|
+
const signalAtMs = readGiveUpSignalAtMs(join6(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
16774
16849
|
const act = decideGiveUpNotice({
|
|
16775
16850
|
signalAtMs,
|
|
16776
16851
|
lastHandledAtMs: lastSlackGiveUpHandledAtMs,
|
|
@@ -16797,7 +16872,7 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
16797
16872
|
strandedInboundNoticeInFlight = true;
|
|
16798
16873
|
let hadFailure = false;
|
|
16799
16874
|
try {
|
|
16800
|
-
if (!SLACK_PENDING_INBOUND_DIR || !
|
|
16875
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync6(SLACK_PENDING_INBOUND_DIR)) return;
|
|
16801
16876
|
let filenames;
|
|
16802
16877
|
try {
|
|
16803
16878
|
filenames = readdirSync3(SLACK_PENDING_INBOUND_DIR);
|
|
@@ -16810,10 +16885,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
16810
16885
|
let notified = 0;
|
|
16811
16886
|
for (const filename of filenames) {
|
|
16812
16887
|
if (!filename.endsWith(".json")) continue;
|
|
16813
|
-
const fullPath =
|
|
16888
|
+
const fullPath = join6(SLACK_PENDING_INBOUND_DIR, filename);
|
|
16814
16889
|
let marker;
|
|
16815
16890
|
try {
|
|
16816
|
-
marker = JSON.parse(
|
|
16891
|
+
marker = JSON.parse(readFileSync7(fullPath, "utf-8"));
|
|
16817
16892
|
} catch {
|
|
16818
16893
|
continue;
|
|
16819
16894
|
}
|
|
@@ -16940,7 +17015,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
|
|
|
16940
17015
|
if (!channel || !messageTs) return;
|
|
16941
17016
|
clearPendingMessage(channel, messageTs);
|
|
16942
17017
|
if (!SLACK_PENDING_INBOUND_DIR) return;
|
|
16943
|
-
if (!
|
|
17018
|
+
if (!existsSync6(SLACK_PENDING_INBOUND_DIR)) return;
|
|
16944
17019
|
let filenames;
|
|
16945
17020
|
try {
|
|
16946
17021
|
filenames = readdirSync3(SLACK_PENDING_INBOUND_DIR);
|
|
@@ -16954,10 +17029,10 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
|
|
|
16954
17029
|
for (const filename of filenames) {
|
|
16955
17030
|
if (!filename.startsWith(channelPrefix)) continue;
|
|
16956
17031
|
if (!filename.endsWith(messageSuffix)) continue;
|
|
16957
|
-
clearSlackMarkerFileWithHeal(
|
|
17032
|
+
clearSlackMarkerFileWithHeal(join6(SLACK_PENDING_INBOUND_DIR, filename));
|
|
16958
17033
|
}
|
|
16959
17034
|
}
|
|
16960
|
-
var RESTART_FLAGS_DIR =
|
|
17035
|
+
var RESTART_FLAGS_DIR = join6(homedir2(), ".augmented", "restart-flags");
|
|
16961
17036
|
function buildAugmentedSlackMetadata() {
|
|
16962
17037
|
if (!AGT_TEAM_ID) return void 0;
|
|
16963
17038
|
return {
|
|
@@ -17008,9 +17083,9 @@ function buildSlackHelpMessage(codeName) {
|
|
|
17008
17083
|
`\u{1F916} *Available commands for \`${codeName}\`*`,
|
|
17009
17084
|
"",
|
|
17010
17085
|
"All commands are real Slack slash commands (autocomplete via `/`). For backward compatibility, `/help` and the restart command can also be typed as plain messages in any channel where the bot is present:",
|
|
17011
|
-
|
|
17086
|
+
`\u2022 \`${agentSlashCommand("/help")}\` (or type \`/help\`) \u2014 show this help`,
|
|
17012
17087
|
`\u2022 \`${agentSlashCommand("/restart")}\` \u2014 restart this agent`,
|
|
17013
|
-
`\u2022 \`${agentSlashCommand("/
|
|
17088
|
+
`\u2022 \`${agentSlashCommand("/status")}\` \u2014 this agent's model, session origin, uptime + connectivity`,
|
|
17014
17089
|
"\u2022 `/kill` \u2014 silence all agents in this thread for 6h (use as a thread reply)",
|
|
17015
17090
|
"\u2022 `/unkill` \u2014 clear a kill (use as a thread reply)",
|
|
17016
17091
|
`\u2022 \`${agentSlashCommand("/investigate")}\` \u2014 live tail of this agent's terminal pane (DM only, allowlisted users; works while the channel process is alive \u2014 a wedged host still needs SSM diagnostics)`
|
|
@@ -17095,7 +17170,9 @@ function buildAgentStatusReply(codeName) {
|
|
|
17095
17170
|
const connected = currentWs != null && !isShuttingDown;
|
|
17096
17171
|
const dot = connected ? "\u{1F7E2}" : "\u{1F534}";
|
|
17097
17172
|
const state = connected ? "online" : "offline";
|
|
17098
|
-
|
|
17173
|
+
const connectivityLine = `${dot} *${state}* \u2014 Socket Mode ${connected ? "connected" : "disconnected"}. Last activity: ${formatLastActivity()}.`;
|
|
17174
|
+
const sessionState = readAgentSessionState(SLACK_AGENT_DIR);
|
|
17175
|
+
return buildAgentConfigReport({ codeName, connectivityLine, state: sessionState });
|
|
17099
17176
|
}
|
|
17100
17177
|
async function postEphemeralViaResponseUrl(responseUrl, text, logTag) {
|
|
17101
17178
|
try {
|
|
@@ -17310,11 +17387,11 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
17310
17387
|
const responseUrl = payload.response_url;
|
|
17311
17388
|
const codeName = AGENT_CODE_NAME ?? "unknown";
|
|
17312
17389
|
if (!command || !responseUrl) return;
|
|
17313
|
-
if (matchesAgentCommand(command, "/agent-status")) {
|
|
17390
|
+
if (matchesAgentCommand(command, "/status") || matchesAgentCommand(command, "/agent-status")) {
|
|
17314
17391
|
await postEphemeralViaResponseUrl(responseUrl, buildAgentStatusReply(codeName), codeName);
|
|
17315
17392
|
return;
|
|
17316
17393
|
}
|
|
17317
|
-
if (command
|
|
17394
|
+
if (matchesAgentCommand(command, "/help")) {
|
|
17318
17395
|
await postEphemeralViaResponseUrl(responseUrl, buildSlackHelpMessage(codeName), codeName);
|
|
17319
17396
|
return;
|
|
17320
17397
|
}
|
|
@@ -17340,10 +17417,10 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
17340
17417
|
return;
|
|
17341
17418
|
}
|
|
17342
17419
|
try {
|
|
17343
|
-
if (!
|
|
17420
|
+
if (!existsSync6(RESTART_FLAGS_DIR)) {
|
|
17344
17421
|
mkdirSync5(RESTART_FLAGS_DIR, { recursive: true });
|
|
17345
17422
|
}
|
|
17346
|
-
const flagPath =
|
|
17423
|
+
const flagPath = join6(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
17347
17424
|
writeSlackRestartConfirm(
|
|
17348
17425
|
{
|
|
17349
17426
|
channel: payload.channel_id,
|
|
@@ -17458,10 +17535,10 @@ async function handleHelpCommand(opts) {
|
|
|
17458
17535
|
async function handleRestartCommand(opts) {
|
|
17459
17536
|
const codeName = AGENT_CODE_NAME ?? "unknown";
|
|
17460
17537
|
try {
|
|
17461
|
-
if (!
|
|
17538
|
+
if (!existsSync6(RESTART_FLAGS_DIR)) {
|
|
17462
17539
|
mkdirSync5(RESTART_FLAGS_DIR, { recursive: true });
|
|
17463
17540
|
}
|
|
17464
|
-
const flagPath =
|
|
17541
|
+
const flagPath = join6(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
17465
17542
|
writeSlackRestartConfirm(
|
|
17466
17543
|
{
|
|
17467
17544
|
channel: opts.channel,
|
|
@@ -17527,7 +17604,7 @@ var THREAD_STORE_TTL_DAYS = parseTtlDays(process.env.SLACK_THREAD_FOLLOW_TTL_DAY
|
|
|
17527
17604
|
var threadPersister = null;
|
|
17528
17605
|
function resolveThreadStorePath() {
|
|
17529
17606
|
if (!AGENT_CODE_NAME) return null;
|
|
17530
|
-
return
|
|
17607
|
+
return join6(homedir2(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
|
|
17531
17608
|
}
|
|
17532
17609
|
function parseTtlDays(raw) {
|
|
17533
17610
|
if (!raw) return void 0;
|
|
@@ -17562,9 +17639,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
|
|
|
17562
17639
|
var slackStderrLogStream = null;
|
|
17563
17640
|
if (AGENT_CODE_NAME) {
|
|
17564
17641
|
try {
|
|
17565
|
-
const logDir =
|
|
17642
|
+
const logDir = join6(homedir2(), ".augmented", AGENT_CODE_NAME);
|
|
17566
17643
|
mkdirSync5(logDir, { recursive: true });
|
|
17567
|
-
slackStderrLogStream = createWriteStream(
|
|
17644
|
+
slackStderrLogStream = createWriteStream(join6(logDir, "slack-channel-stderr.log"), {
|
|
17568
17645
|
flags: "a",
|
|
17569
17646
|
mode: 384
|
|
17570
17647
|
});
|
|
@@ -18138,7 +18215,7 @@ ${result.formatted}` : "Thread is empty or not found."
|
|
|
18138
18215
|
};
|
|
18139
18216
|
}
|
|
18140
18217
|
size = stat2.size;
|
|
18141
|
-
bytes =
|
|
18218
|
+
bytes = readFileSync7(resolvedPath);
|
|
18142
18219
|
} catch (err) {
|
|
18143
18220
|
return {
|
|
18144
18221
|
content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
|
|
@@ -19116,7 +19193,7 @@ async function connectSocketMode() {
|
|
|
19116
19193
|
let paneLogFreshAgeMs = null;
|
|
19117
19194
|
if (SLACK_AGENT_DIR) {
|
|
19118
19195
|
try {
|
|
19119
|
-
const paneMtimeMs = statSync2(
|
|
19196
|
+
const paneMtimeMs = statSync2(join6(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
19120
19197
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
19121
19198
|
} catch {
|
|
19122
19199
|
}
|