@integrity-labs/agt-cli 0.28.109 → 0.28.111
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-D22IMWAZ.js → chunk-63VABDNF.js} +1 -1
- package/dist/{chunk-ZJLRHPPL.js → chunk-JMNRCUHL.js} +28 -3
- package/dist/chunk-JMNRCUHL.js.map +1 -0
- package/dist/{chunk-O4OYAFTZ.js → chunk-QP4RFWWF.js} +2 -2
- package/dist/{claude-pair-runtime-6DZEDQAG.js → claude-pair-runtime-Z3RAR35Q.js} +2 -2
- package/dist/lib/manager-worker.js +8 -8
- package/dist/mcp/slack-channel.js +95 -54
- package/dist/mcp/teams-channel.js +76 -35
- package/dist/mcp/telegram-channel.js +101 -60
- package/dist/{persistent-session-RMRG5HXI.js → persistent-session-BQ3NLYEC.js} +3 -3
- package/dist/{responsiveness-probe-2KVIALGI.js → responsiveness-probe-QNTUW6SW.js} +58 -4
- package/dist/responsiveness-probe-QNTUW6SW.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-ZJLRHPPL.js.map +0 -1
- package/dist/responsiveness-probe-2KVIALGI.js.map +0 -1
- /package/dist/{chunk-D22IMWAZ.js.map → chunk-63VABDNF.js.map} +0 -0
- /package/dist/{chunk-O4OYAFTZ.js.map → chunk-QP4RFWWF.js.map} +0 -0
- /package/dist/{claude-pair-runtime-6DZEDQAG.js.map → claude-pair-runtime-Z3RAR35Q.js.map} +0 -0
- /package/dist/{persistent-session-RMRG5HXI.js.map → persistent-session-BQ3NLYEC.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
formatMissingVar,
|
|
4
4
|
isClaudeFastMode,
|
|
5
5
|
probeMcpEnvSubstitution
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-63VABDNF.js";
|
|
7
7
|
import {
|
|
8
8
|
reapOrphanChannelMcps
|
|
9
9
|
} from "./chunk-XWVM4KPK.js";
|
|
@@ -1565,4 +1565,4 @@ export {
|
|
|
1565
1565
|
stopAllSessionsAndWait,
|
|
1566
1566
|
getProjectDir
|
|
1567
1567
|
};
|
|
1568
|
-
//# sourceMappingURL=chunk-
|
|
1568
|
+
//# sourceMappingURL=chunk-QP4RFWWF.js.map
|
|
@@ -100,7 +100,7 @@ async function spawnPairSession(session) {
|
|
|
100
100
|
return { ok: true };
|
|
101
101
|
} catch {
|
|
102
102
|
}
|
|
103
|
-
const { resolveClaudeBinary } = await import("./persistent-session-
|
|
103
|
+
const { resolveClaudeBinary } = await import("./persistent-session-BQ3NLYEC.js");
|
|
104
104
|
const claudeBin = resolveClaudeBinary();
|
|
105
105
|
const pairEnv = {
|
|
106
106
|
...process.env,
|
|
@@ -373,4 +373,4 @@ export {
|
|
|
373
373
|
startClaudePair,
|
|
374
374
|
submitClaudePairCode
|
|
375
375
|
};
|
|
376
|
-
//# sourceMappingURL=claude-pair-runtime-
|
|
376
|
+
//# sourceMappingURL=claude-pair-runtime-Z3RAR35Q.js.map
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
requireHost,
|
|
29
29
|
safeWriteJsonAtomic,
|
|
30
30
|
setConfigHash
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-JMNRCUHL.js";
|
|
32
32
|
import {
|
|
33
33
|
getProjectDir as getProjectDir2,
|
|
34
34
|
getReadyTasks,
|
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
takeZombieDetection,
|
|
73
73
|
transcriptActivityAgeSeconds,
|
|
74
74
|
writeEgressAllowlist
|
|
75
|
-
} from "../chunk-
|
|
75
|
+
} from "../chunk-QP4RFWWF.js";
|
|
76
76
|
import {
|
|
77
77
|
FLAGS_SCHEMA_VERSION,
|
|
78
78
|
FLAG_REGISTRY,
|
|
@@ -108,7 +108,7 @@ import {
|
|
|
108
108
|
resolveDmTarget,
|
|
109
109
|
sumTranscriptUsageInWindow,
|
|
110
110
|
wrapScheduledTaskPrompt
|
|
111
|
-
} from "../chunk-
|
|
111
|
+
} from "../chunk-63VABDNF.js";
|
|
112
112
|
import {
|
|
113
113
|
parsePsRows,
|
|
114
114
|
reapOrphanChannelMcps
|
|
@@ -7000,7 +7000,7 @@ var cachedMaintenanceWindow = null;
|
|
|
7000
7000
|
var lastVersionCheckAt = 0;
|
|
7001
7001
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
7002
7002
|
var lastResponsivenessProbeAt = 0;
|
|
7003
|
-
var agtCliVersion = true ? "0.28.
|
|
7003
|
+
var agtCliVersion = true ? "0.28.111" : "dev";
|
|
7004
7004
|
function resolveBrewPath(execFileSync4) {
|
|
7005
7005
|
try {
|
|
7006
7006
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -8111,7 +8111,7 @@ async function pollCycle() {
|
|
|
8111
8111
|
}
|
|
8112
8112
|
try {
|
|
8113
8113
|
const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
|
|
8114
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
8114
|
+
const { collectDiagnostics } = await import("../persistent-session-BQ3NLYEC.js");
|
|
8115
8115
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
8116
8116
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
|
|
8117
8117
|
let tailscaleHostname;
|
|
@@ -8212,7 +8212,7 @@ async function pollCycle() {
|
|
|
8212
8212
|
const {
|
|
8213
8213
|
collectResponsivenessProbes,
|
|
8214
8214
|
getResponsivenessIntervalMs
|
|
8215
|
-
} = await import("../responsiveness-probe-
|
|
8215
|
+
} = await import("../responsiveness-probe-QNTUW6SW.js");
|
|
8216
8216
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
8217
8217
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
8218
8218
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -8244,7 +8244,7 @@ async function pollCycle() {
|
|
|
8244
8244
|
collectResponsivenessProbes,
|
|
8245
8245
|
livePendingInboundOldestAgeSeconds,
|
|
8246
8246
|
parkPendingInbound
|
|
8247
|
-
} = await import("../responsiveness-probe-
|
|
8247
|
+
} = await import("../responsiveness-probe-QNTUW6SW.js");
|
|
8248
8248
|
const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
|
|
8249
8249
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
8250
8250
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -11776,7 +11776,7 @@ async function processClaudePairSessions(agents) {
|
|
|
11776
11776
|
killPairSession,
|
|
11777
11777
|
pairTmuxSession,
|
|
11778
11778
|
finalizeClaudePairOnboarding
|
|
11779
|
-
} = await import("../claude-pair-runtime-
|
|
11779
|
+
} = await import("../claude-pair-runtime-Z3RAR35Q.js");
|
|
11780
11780
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
11781
11781
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
11782
11782
|
const killed = await killPairSession(pairTmuxSession(pairId));
|
|
@@ -15624,16 +15624,16 @@ import {
|
|
|
15624
15624
|
ftruncateSync,
|
|
15625
15625
|
mkdirSync as mkdirSync7,
|
|
15626
15626
|
openSync,
|
|
15627
|
-
readFileSync as
|
|
15627
|
+
readFileSync as readFileSync10,
|
|
15628
15628
|
readdirSync as readdirSync3,
|
|
15629
15629
|
renameSync as renameSync4,
|
|
15630
15630
|
statSync as statSync2,
|
|
15631
15631
|
unlinkSync as unlinkSync5,
|
|
15632
15632
|
watch,
|
|
15633
|
-
writeFileSync as
|
|
15633
|
+
writeFileSync as writeFileSync9,
|
|
15634
15634
|
writeSync
|
|
15635
15635
|
} from "fs";
|
|
15636
|
-
import { basename, join as
|
|
15636
|
+
import { basename, join as join8, resolve as resolve2 } from "path";
|
|
15637
15637
|
import { homedir as homedir3 } from "os";
|
|
15638
15638
|
import { createHash, randomUUID as randomUUID2 } from "crypto";
|
|
15639
15639
|
|
|
@@ -16211,6 +16211,43 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
16211
16211
|
};
|
|
16212
16212
|
}
|
|
16213
16213
|
|
|
16214
|
+
// src/inbound-lane-telemetry.ts
|
|
16215
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
16216
|
+
import { join as join6 } from "path";
|
|
16217
|
+
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
16218
|
+
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
16219
|
+
var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
|
|
16220
|
+
"slack",
|
|
16221
|
+
"telegram",
|
|
16222
|
+
"msteams",
|
|
16223
|
+
"direct-chat"
|
|
16224
|
+
]);
|
|
16225
|
+
function laneClassificationKey(lane, expectsReply, source) {
|
|
16226
|
+
return `${lane}|${expectsReply ? "true" : "false"}|${source}`;
|
|
16227
|
+
}
|
|
16228
|
+
function isSuspectedMisclassification(lane, source) {
|
|
16229
|
+
return lane === "directive" && HUMAN_CHANNEL_SOURCES.has(source);
|
|
16230
|
+
}
|
|
16231
|
+
function recordLaneClassification(agentDir, channel, classification) {
|
|
16232
|
+
if (!agentDir) return;
|
|
16233
|
+
const path = join6(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
16234
|
+
let counts = {};
|
|
16235
|
+
try {
|
|
16236
|
+
const parsed = JSON.parse(readFileSync8(path, "utf-8"));
|
|
16237
|
+
if (parsed && typeof parsed === "object") counts = parsed;
|
|
16238
|
+
} catch {
|
|
16239
|
+
}
|
|
16240
|
+
const key2 = laneClassificationKey(classification.lane, classification.expectsReply, channel);
|
|
16241
|
+
counts[key2] = (counts[key2] ?? 0) + 1;
|
|
16242
|
+
if (isSuspectedMisclassification(classification.lane, channel)) {
|
|
16243
|
+
counts[SUSPECTED_MISCLASSIFICATION_KEY] = (counts[SUSPECTED_MISCLASSIFICATION_KEY] ?? 0) + 1;
|
|
16244
|
+
}
|
|
16245
|
+
try {
|
|
16246
|
+
writeFileSync7(path, JSON.stringify(counts), { mode: 384 });
|
|
16247
|
+
} catch {
|
|
16248
|
+
}
|
|
16249
|
+
}
|
|
16250
|
+
|
|
16214
16251
|
// src/slack-allowlist-source.ts
|
|
16215
16252
|
function parseAllowedUsersCsv(raw) {
|
|
16216
16253
|
return new Set(
|
|
@@ -16778,12 +16815,12 @@ function createSlackBotUserIdClient(args) {
|
|
|
16778
16815
|
import {
|
|
16779
16816
|
existsSync as existsSync6,
|
|
16780
16817
|
mkdirSync as mkdirSync6,
|
|
16781
|
-
readFileSync as
|
|
16818
|
+
readFileSync as readFileSync9,
|
|
16782
16819
|
renameSync as renameSync3,
|
|
16783
16820
|
unlinkSync as unlinkSync4,
|
|
16784
|
-
writeFileSync as
|
|
16821
|
+
writeFileSync as writeFileSync8
|
|
16785
16822
|
} from "fs";
|
|
16786
|
-
import { join as
|
|
16823
|
+
import { join as join7 } from "path";
|
|
16787
16824
|
function defaultIsPidAlive(pid) {
|
|
16788
16825
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
16789
16826
|
try {
|
|
@@ -16801,7 +16838,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
16801
16838
|
const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
|
|
16802
16839
|
const selfPid = options.selfPid ?? process.pid;
|
|
16803
16840
|
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
16804
|
-
const path =
|
|
16841
|
+
const path = join7(agentDir, basename2);
|
|
16805
16842
|
const existing = readLockHolder(path);
|
|
16806
16843
|
if (existing) {
|
|
16807
16844
|
if (existing.pid === selfPid) {
|
|
@@ -16814,7 +16851,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
16814
16851
|
mkdirSync6(agentDir, { recursive: true, mode: 448 });
|
|
16815
16852
|
const tmpPath = `${path}.${selfPid}.tmp`;
|
|
16816
16853
|
const payload = { pid: selfPid, started_at: now() };
|
|
16817
|
-
|
|
16854
|
+
writeFileSync8(tmpPath, JSON.stringify(payload), { mode: 384 });
|
|
16818
16855
|
renameSync3(tmpPath, path);
|
|
16819
16856
|
return { kind: "acquired", path };
|
|
16820
16857
|
}
|
|
@@ -16832,7 +16869,7 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
|
16832
16869
|
function readLockHolder(path) {
|
|
16833
16870
|
if (!existsSync6(path)) return null;
|
|
16834
16871
|
try {
|
|
16835
|
-
const raw =
|
|
16872
|
+
const raw = readFileSync9(path, "utf8");
|
|
16836
16873
|
const parsed = JSON.parse(raw);
|
|
16837
16874
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
16838
16875
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -17061,8 +17098,8 @@ var SLACK_PEER_CLASSIFIER_CONFIG = {
|
|
|
17061
17098
|
peers: parsePeersEnv(process.env.SLACK_PEERS, process.env.SLACK_PEERS_GATE),
|
|
17062
17099
|
peer_disabled_mode: SLACK_PEER_DISABLED_MODE
|
|
17063
17100
|
};
|
|
17064
|
-
var SLACK_AGENT_DIR = AGENT_CODE_NAME ?
|
|
17065
|
-
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ?
|
|
17101
|
+
var SLACK_AGENT_DIR = AGENT_CODE_NAME ? join8(homedir3(), ".augmented", AGENT_CODE_NAME) : null;
|
|
17102
|
+
var SLACK_MCP_CONFIG_PATH = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "project", ".mcp.json") : null;
|
|
17066
17103
|
var liveAllowedUsersCache = null;
|
|
17067
17104
|
function readLiveAllowedUsers() {
|
|
17068
17105
|
if (!SLACK_MCP_CONFIG_PATH) return null;
|
|
@@ -17072,7 +17109,7 @@ function readLiveAllowedUsers() {
|
|
|
17072
17109
|
return liveAllowedUsersCache.value;
|
|
17073
17110
|
}
|
|
17074
17111
|
const value = extractAllowedUsersFromMcpJson(
|
|
17075
|
-
|
|
17112
|
+
readFileSync10(SLACK_MCP_CONFIG_PATH, "utf-8")
|
|
17076
17113
|
);
|
|
17077
17114
|
if (value === null) return null;
|
|
17078
17115
|
liveAllowedUsersCache = { mtimeMs, value };
|
|
@@ -17084,13 +17121,13 @@ function readLiveAllowedUsers() {
|
|
|
17084
17121
|
function getEffectiveAllowedUsers() {
|
|
17085
17122
|
return readLiveAllowedUsers() ?? ALLOWED_USERS;
|
|
17086
17123
|
}
|
|
17087
|
-
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ?
|
|
17088
|
-
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ?
|
|
17089
|
-
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ?
|
|
17090
|
-
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ?
|
|
17091
|
-
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ?
|
|
17124
|
+
var SLACK_PENDING_INBOUND_DIR = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "slack-pending-inbound") : null;
|
|
17125
|
+
var SLACK_RECOVERY_OUTBOX_DIR = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "slack-recovery-outbox") : null;
|
|
17126
|
+
var SLACK_RESTART_CONFIRM_FILE = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "slack-restart-confirm.json") : null;
|
|
17127
|
+
var SLACK_RECENT_DMS_FILE = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "slack-recent-dms.json") : null;
|
|
17128
|
+
var SLACK_CHANNEL_ADD_RESTART_FILE = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "slack-channel-add-restart.json") : null;
|
|
17092
17129
|
var SLACK_MAX_RECOVERY_ATTEMPTS = 3;
|
|
17093
|
-
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ?
|
|
17130
|
+
var SLACK_AVATAR_MARKER_PATH = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "slack-avatar-applied") : null;
|
|
17094
17131
|
function redactSlackId(id) {
|
|
17095
17132
|
if (!id) return "<none>";
|
|
17096
17133
|
return createHash("sha256").update(id).digest("hex").slice(0, 8);
|
|
@@ -17101,7 +17138,7 @@ function safeSlackMarkerName(channel, threadTs, messageTs) {
|
|
|
17101
17138
|
}
|
|
17102
17139
|
function slackPendingInboundPath(channel, threadTs, messageTs) {
|
|
17103
17140
|
if (!SLACK_PENDING_INBOUND_DIR) return null;
|
|
17104
|
-
return
|
|
17141
|
+
return join8(SLACK_PENDING_INBOUND_DIR, safeSlackMarkerName(channel, threadTs, messageTs));
|
|
17105
17142
|
}
|
|
17106
17143
|
function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undeliverable = false, discretionary = false, payload) {
|
|
17107
17144
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
@@ -17120,7 +17157,7 @@ function writeSlackPendingInboundMarker(channel, threadTs, messageTs, undelivera
|
|
|
17120
17157
|
};
|
|
17121
17158
|
try {
|
|
17122
17159
|
mkdirSync7(SLACK_PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
|
|
17123
|
-
|
|
17160
|
+
writeFileSync9(path, JSON.stringify(marker), { mode: 384 });
|
|
17124
17161
|
} catch (err) {
|
|
17125
17162
|
process.stderr.write(
|
|
17126
17163
|
`slack-channel(${AGENT_CODE_NAME}): pending-inbound marker write failed: ${err.message}
|
|
@@ -17148,7 +17185,7 @@ function rewriteSlackMarkerInPlace(path, marker) {
|
|
|
17148
17185
|
function markSlackMarkerSeenInPlace(fullPath) {
|
|
17149
17186
|
let marker;
|
|
17150
17187
|
try {
|
|
17151
|
-
marker = JSON.parse(
|
|
17188
|
+
marker = JSON.parse(readFileSync10(fullPath, "utf-8"));
|
|
17152
17189
|
} catch {
|
|
17153
17190
|
return;
|
|
17154
17191
|
}
|
|
@@ -17162,7 +17199,7 @@ function attachSlackReplayPayload(channel, threadTs, messageTs, payload) {
|
|
|
17162
17199
|
if (!path) return;
|
|
17163
17200
|
let marker;
|
|
17164
17201
|
try {
|
|
17165
|
-
marker = JSON.parse(
|
|
17202
|
+
marker = JSON.parse(readFileSync10(path, "utf-8"));
|
|
17166
17203
|
} catch {
|
|
17167
17204
|
return;
|
|
17168
17205
|
}
|
|
@@ -17173,7 +17210,7 @@ function readSlackPendingInboundMarker(channel, threadTs, messageTs) {
|
|
|
17173
17210
|
const path = slackPendingInboundPath(channel, threadTs, messageTs);
|
|
17174
17211
|
if (!path || !existsSync7(path)) return null;
|
|
17175
17212
|
try {
|
|
17176
|
-
return JSON.parse(
|
|
17213
|
+
return JSON.parse(readFileSync10(path, "utf-8"));
|
|
17177
17214
|
} catch {
|
|
17178
17215
|
return null;
|
|
17179
17216
|
}
|
|
@@ -17268,7 +17305,7 @@ function scheduleBusyAck(channel, threadTs, messageTs, isThreadReply, arrivedWhi
|
|
|
17268
17305
|
let paneLogFreshAgeMs = null;
|
|
17269
17306
|
if (SLACK_AGENT_DIR) {
|
|
17270
17307
|
try {
|
|
17271
|
-
const paneMtimeMs = statSync2(
|
|
17308
|
+
const paneMtimeMs = statSync2(join8(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
17272
17309
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
17273
17310
|
} catch {
|
|
17274
17311
|
}
|
|
@@ -17301,7 +17338,7 @@ function __resetSlackBusyAckNoticeThrottle() {
|
|
|
17301
17338
|
function clearSlackMarkerFileWithHeal(fullPath) {
|
|
17302
17339
|
let marker = null;
|
|
17303
17340
|
try {
|
|
17304
|
-
marker = JSON.parse(
|
|
17341
|
+
marker = JSON.parse(readFileSync10(fullPath, "utf-8"));
|
|
17305
17342
|
} catch {
|
|
17306
17343
|
}
|
|
17307
17344
|
if (marker && decideRecoveryHeal({
|
|
@@ -17318,7 +17355,7 @@ function clearSlackMarkerFileWithHeal(fullPath) {
|
|
|
17318
17355
|
function markSlackMarkerSeenWithHeal(fullPath) {
|
|
17319
17356
|
let marker = null;
|
|
17320
17357
|
try {
|
|
17321
|
-
marker = JSON.parse(
|
|
17358
|
+
marker = JSON.parse(readFileSync10(fullPath, "utf-8"));
|
|
17322
17359
|
} catch {
|
|
17323
17360
|
return;
|
|
17324
17361
|
}
|
|
@@ -17383,10 +17420,10 @@ function slackNextRetryName(filename) {
|
|
|
17383
17420
|
async function processSlackRecoveryOutboxFile(filename) {
|
|
17384
17421
|
if (!SLACK_RECOVERY_OUTBOX_DIR) return;
|
|
17385
17422
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
17386
|
-
const fullPath =
|
|
17423
|
+
const fullPath = join8(SLACK_RECOVERY_OUTBOX_DIR, filename);
|
|
17387
17424
|
let payload;
|
|
17388
17425
|
try {
|
|
17389
|
-
payload = JSON.parse(
|
|
17426
|
+
payload = JSON.parse(readFileSync10(fullPath, "utf-8"));
|
|
17390
17427
|
} catch (err) {
|
|
17391
17428
|
process.stderr.write(
|
|
17392
17429
|
`slack-channel(${AGENT_CODE_NAME}): recovery outbox parse failed (${filename}): ${err.message}
|
|
@@ -17462,7 +17499,7 @@ ${payload.text}`;
|
|
|
17462
17499
|
const next = slackNextRetryName(filename);
|
|
17463
17500
|
if (next) {
|
|
17464
17501
|
try {
|
|
17465
|
-
renameSync4(fullPath,
|
|
17502
|
+
renameSync4(fullPath, join8(SLACK_RECOVERY_OUTBOX_DIR, next.next));
|
|
17466
17503
|
if (next.attempt >= SLACK_MAX_RECOVERY_ATTEMPTS) {
|
|
17467
17504
|
process.stderr.write(
|
|
17468
17505
|
`slack-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -17501,7 +17538,7 @@ function scanSlackRecoveryRetries() {
|
|
|
17501
17538
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
17502
17539
|
let mtimeMs;
|
|
17503
17540
|
try {
|
|
17504
|
-
mtimeMs = statSync2(
|
|
17541
|
+
mtimeMs = statSync2(join8(SLACK_RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
17505
17542
|
} catch {
|
|
17506
17543
|
continue;
|
|
17507
17544
|
}
|
|
@@ -17531,7 +17568,7 @@ function startSlackRecoveryOutboxWatcher() {
|
|
|
17531
17568
|
const watcher = watch(SLACK_RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
17532
17569
|
if (event !== "rename" || !filename) return;
|
|
17533
17570
|
if (!isFirstAttemptSlackOutboxFile(filename)) return;
|
|
17534
|
-
if (existsSync7(
|
|
17571
|
+
if (existsSync7(join8(SLACK_RECOVERY_OUTBOX_DIR, filename))) {
|
|
17535
17572
|
void processSlackRecoveryOutboxFile(filename);
|
|
17536
17573
|
}
|
|
17537
17574
|
});
|
|
@@ -17569,10 +17606,10 @@ function sweepSlackStaleMarkers(thresholdMs) {
|
|
|
17569
17606
|
for (const filename of filenames) {
|
|
17570
17607
|
if (!filename.endsWith(".json")) continue;
|
|
17571
17608
|
if (filename.endsWith(".tmp")) continue;
|
|
17572
|
-
const fullPath =
|
|
17609
|
+
const fullPath = join8(SLACK_PENDING_INBOUND_DIR, filename);
|
|
17573
17610
|
let marker;
|
|
17574
17611
|
try {
|
|
17575
|
-
marker = JSON.parse(
|
|
17612
|
+
marker = JSON.parse(readFileSync10(fullPath, "utf-8"));
|
|
17576
17613
|
} catch (err) {
|
|
17577
17614
|
process.stderr.write(
|
|
17578
17615
|
`slack-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactSlackId(filename)}: ${err.message}
|
|
@@ -17615,13 +17652,13 @@ var slackOrphanSweepTimer = setInterval(() => {
|
|
|
17615
17652
|
checkSlackWatchdogGiveUpNotice();
|
|
17616
17653
|
}, orphanSweepIntervalMs());
|
|
17617
17654
|
slackOrphanSweepTimer.unref?.();
|
|
17618
|
-
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ?
|
|
17655
|
+
var SLACK_PROGRESS_HEARTBEAT_PATH = SLACK_AGENT_DIR ? join8(SLACK_AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
17619
17656
|
var slackTrackedProgress = null;
|
|
17620
17657
|
var slackProgressTickRunning = false;
|
|
17621
17658
|
function readSlackProgressHeartbeat() {
|
|
17622
17659
|
if (!SLACK_PROGRESS_HEARTBEAT_PATH || !existsSync7(SLACK_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
17623
17660
|
try {
|
|
17624
|
-
return parseProgressHeartbeat(
|
|
17661
|
+
return parseProgressHeartbeat(readFileSync10(SLACK_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
17625
17662
|
} catch {
|
|
17626
17663
|
return null;
|
|
17627
17664
|
}
|
|
@@ -17635,7 +17672,7 @@ function findSlackProgressTarget() {
|
|
|
17635
17672
|
if (!name.endsWith(".json")) continue;
|
|
17636
17673
|
let m;
|
|
17637
17674
|
try {
|
|
17638
|
-
m = JSON.parse(
|
|
17675
|
+
m = JSON.parse(readFileSync10(join8(SLACK_PENDING_INBOUND_DIR, name), "utf-8"));
|
|
17639
17676
|
} catch {
|
|
17640
17677
|
continue;
|
|
17641
17678
|
}
|
|
@@ -17786,7 +17823,7 @@ function listPendingSlackConversations() {
|
|
|
17786
17823
|
if (!name.endsWith(".json")) continue;
|
|
17787
17824
|
try {
|
|
17788
17825
|
const marker = JSON.parse(
|
|
17789
|
-
|
|
17826
|
+
readFileSync10(join8(SLACK_PENDING_INBOUND_DIR, name), "utf8")
|
|
17790
17827
|
);
|
|
17791
17828
|
if (typeof marker.channel !== "string" || !marker.channel) continue;
|
|
17792
17829
|
if (typeof marker.thread_ts !== "string" || !marker.thread_ts) continue;
|
|
@@ -17838,7 +17875,7 @@ function postSlackWatchdogGiveUpNotice(channel, threadTs, isThreadReply) {
|
|
|
17838
17875
|
}
|
|
17839
17876
|
function checkSlackWatchdogGiveUpNotice() {
|
|
17840
17877
|
if (!SLACK_AGENT_DIR) return;
|
|
17841
|
-
const signalAtMs = readGiveUpSignalAtMs(
|
|
17878
|
+
const signalAtMs = readGiveUpSignalAtMs(join8(SLACK_AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
17842
17879
|
const act = decideGiveUpNotice({
|
|
17843
17880
|
signalAtMs,
|
|
17844
17881
|
lastHandledAtMs: lastSlackGiveUpHandledAtMs,
|
|
@@ -17878,10 +17915,10 @@ async function notifyStrandedInboundsOnFirstConnect() {
|
|
|
17878
17915
|
let notified = 0;
|
|
17879
17916
|
for (const filename of filenames) {
|
|
17880
17917
|
if (!filename.endsWith(".json")) continue;
|
|
17881
|
-
const fullPath =
|
|
17918
|
+
const fullPath = join8(SLACK_PENDING_INBOUND_DIR, filename);
|
|
17882
17919
|
let marker;
|
|
17883
17920
|
try {
|
|
17884
|
-
marker = JSON.parse(
|
|
17921
|
+
marker = JSON.parse(readFileSync10(fullPath, "utf-8"));
|
|
17885
17922
|
} catch {
|
|
17886
17923
|
continue;
|
|
17887
17924
|
}
|
|
@@ -18052,7 +18089,7 @@ function noteThreadActivityByMessageTs(channel, messageTs) {
|
|
|
18052
18089
|
markSeenAllSlackPendingMarkersForThread2(channel, messageTs);
|
|
18053
18090
|
markSeenSlackPendingMarkerByMessageTs2(channel, messageTs);
|
|
18054
18091
|
}
|
|
18055
|
-
var RESTART_FLAGS_DIR =
|
|
18092
|
+
var RESTART_FLAGS_DIR = join8(homedir3(), ".augmented", "restart-flags");
|
|
18056
18093
|
function buildAugmentedSlackMetadata() {
|
|
18057
18094
|
if (!AGT_TEAM_ID) return void 0;
|
|
18058
18095
|
return {
|
|
@@ -18488,7 +18525,7 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
18488
18525
|
if (!existsSync7(RESTART_FLAGS_DIR)) {
|
|
18489
18526
|
mkdirSync7(RESTART_FLAGS_DIR, { recursive: true });
|
|
18490
18527
|
}
|
|
18491
|
-
const flagPath =
|
|
18528
|
+
const flagPath = join8(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
18492
18529
|
writeSlackRestartConfirm(
|
|
18493
18530
|
{
|
|
18494
18531
|
channel: payload.channel_id,
|
|
@@ -18506,7 +18543,7 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
18506
18543
|
}
|
|
18507
18544
|
};
|
|
18508
18545
|
const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
|
|
18509
|
-
|
|
18546
|
+
writeFileSync9(tmpPath, JSON.stringify(flag) + "\n", "utf8");
|
|
18510
18547
|
renameSync4(tmpPath, flagPath);
|
|
18511
18548
|
process.stderr.write(
|
|
18512
18549
|
`slack-channel(${codeName}): /restart slash-command queued from channel ${hashChannelId(payload.channel_id)}
|
|
@@ -18628,7 +18665,7 @@ async function handleRestartCommand(opts) {
|
|
|
18628
18665
|
if (!existsSync7(RESTART_FLAGS_DIR)) {
|
|
18629
18666
|
mkdirSync7(RESTART_FLAGS_DIR, { recursive: true });
|
|
18630
18667
|
}
|
|
18631
|
-
const flagPath =
|
|
18668
|
+
const flagPath = join8(RESTART_FLAGS_DIR, `${codeName}.flag`);
|
|
18632
18669
|
writeSlackRestartConfirm(
|
|
18633
18670
|
{
|
|
18634
18671
|
channel: opts.channel,
|
|
@@ -18647,7 +18684,7 @@ async function handleRestartCommand(opts) {
|
|
|
18647
18684
|
}
|
|
18648
18685
|
};
|
|
18649
18686
|
const tmpPath = `${flagPath}.${process.pid}.${randomUUID2()}.tmp`;
|
|
18650
|
-
|
|
18687
|
+
writeFileSync9(tmpPath, JSON.stringify(flag) + "\n", "utf8");
|
|
18651
18688
|
renameSync4(tmpPath, flagPath);
|
|
18652
18689
|
process.stderr.write(
|
|
18653
18690
|
`slack-channel(${codeName}): /restart queued from channel ${hashChannelId(opts.channel)}
|
|
@@ -18751,7 +18788,7 @@ var THREAD_STORE_TTL_DAYS = parseTtlDays(process.env.SLACK_THREAD_FOLLOW_TTL_DAY
|
|
|
18751
18788
|
var threadPersister = null;
|
|
18752
18789
|
function resolveThreadStorePath() {
|
|
18753
18790
|
if (!AGENT_CODE_NAME) return null;
|
|
18754
|
-
return
|
|
18791
|
+
return join8(homedir3(), ".augmented", AGENT_CODE_NAME, "slack-tracked-threads.json");
|
|
18755
18792
|
}
|
|
18756
18793
|
function parseTtlDays(raw) {
|
|
18757
18794
|
if (!raw) return void 0;
|
|
@@ -18790,9 +18827,9 @@ if (!BOT_TOKEN || !APP_TOKEN) {
|
|
|
18790
18827
|
var slackStderrLogStream = null;
|
|
18791
18828
|
if (AGENT_CODE_NAME) {
|
|
18792
18829
|
try {
|
|
18793
|
-
const logDir =
|
|
18830
|
+
const logDir = join8(homedir3(), ".augmented", AGENT_CODE_NAME);
|
|
18794
18831
|
mkdirSync7(logDir, { recursive: true });
|
|
18795
|
-
slackStderrLogStream = createWriteStream(
|
|
18832
|
+
slackStderrLogStream = createWriteStream(join8(logDir, "slack-channel-stderr.log"), {
|
|
18796
18833
|
flags: "a",
|
|
18797
18834
|
mode: 384
|
|
18798
18835
|
});
|
|
@@ -19397,7 +19434,7 @@ ${result.formatted}` : "Thread is empty or not found."
|
|
|
19397
19434
|
};
|
|
19398
19435
|
}
|
|
19399
19436
|
size = stat2.size;
|
|
19400
|
-
bytes =
|
|
19437
|
+
bytes = readFileSync10(resolvedPath);
|
|
19401
19438
|
} catch (err) {
|
|
19402
19439
|
return {
|
|
19403
19440
|
content: [{ type: "text", text: `Failed to read file: ${err.message}` }],
|
|
@@ -20036,7 +20073,7 @@ async function downloadSlackFile(fileId, codeName) {
|
|
|
20036
20073
|
throw new Error(`refusing to write ${savedPath} outside ${dir}`);
|
|
20037
20074
|
}
|
|
20038
20075
|
mkdirSync7(dir, { recursive: true });
|
|
20039
|
-
|
|
20076
|
+
writeFileSync9(savedPath, bytes, { mode: 384 });
|
|
20040
20077
|
try {
|
|
20041
20078
|
chmodSync(savedPath, 384);
|
|
20042
20079
|
} catch {
|
|
@@ -20105,17 +20142,17 @@ async function replayPendingSlackMarkers() {
|
|
|
20105
20142
|
let paneFreshAgeMs = null;
|
|
20106
20143
|
if (SLACK_AGENT_DIR) {
|
|
20107
20144
|
try {
|
|
20108
|
-
paneFreshAgeMs = Math.max(0, now - statSync2(
|
|
20145
|
+
paneFreshAgeMs = Math.max(0, now - statSync2(join8(SLACK_AGENT_DIR, "pane.log")).mtimeMs);
|
|
20109
20146
|
} catch {
|
|
20110
20147
|
}
|
|
20111
20148
|
}
|
|
20112
20149
|
const entries = [];
|
|
20113
20150
|
for (const name of filenames) {
|
|
20114
20151
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
20115
|
-
const fullPath =
|
|
20152
|
+
const fullPath = join8(SLACK_PENDING_INBOUND_DIR, name);
|
|
20116
20153
|
let marker;
|
|
20117
20154
|
try {
|
|
20118
|
-
marker = JSON.parse(
|
|
20155
|
+
marker = JSON.parse(readFileSync10(fullPath, "utf-8"));
|
|
20119
20156
|
} catch {
|
|
20120
20157
|
continue;
|
|
20121
20158
|
}
|
|
@@ -20539,7 +20576,7 @@ async function connectSocketMode() {
|
|
|
20539
20576
|
let paneLogFreshAgeMs = null;
|
|
20540
20577
|
if (SLACK_AGENT_DIR) {
|
|
20541
20578
|
try {
|
|
20542
|
-
const paneMtimeMs = statSync2(
|
|
20579
|
+
const paneMtimeMs = statSync2(join8(SLACK_AGENT_DIR, "pane.log")).mtimeMs;
|
|
20543
20580
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
20544
20581
|
} catch {
|
|
20545
20582
|
}
|
|
@@ -20656,6 +20693,10 @@ async function connectSocketMode() {
|
|
|
20656
20693
|
...threadContext ? { thread_context: threadContext } : {}
|
|
20657
20694
|
}
|
|
20658
20695
|
};
|
|
20696
|
+
recordLaneClassification(SLACK_AGENT_DIR, "slack", {
|
|
20697
|
+
lane: "conversational",
|
|
20698
|
+
expectsReply: shouldEngage
|
|
20699
|
+
});
|
|
20659
20700
|
if (channel && ts && armMarker) {
|
|
20660
20701
|
attachSlackReplayPayload(channel, threadTs, ts, replayPayload);
|
|
20661
20702
|
}
|