@integrity-labs/agt-cli 0.27.29 → 0.27.31
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 +19 -4
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-HX74HMG4.js → chunk-E6MGOZTL.js} +1 -1
- package/dist/lib/manager-worker.js +341 -115
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/slack-channel.js +76 -0
- package/package.json +1 -1
- /package/dist/{chunk-HX74HMG4.js.map → chunk-E6MGOZTL.js.map} +0 -0
|
@@ -16115,6 +16115,81 @@ function sweepSlackStaleMarkersOnBoot() {
|
|
|
16115
16115
|
}
|
|
16116
16116
|
}
|
|
16117
16117
|
sweepSlackStaleMarkersOnBoot();
|
|
16118
|
+
var SLACK_PROCESS_BOOT_MS = Date.now();
|
|
16119
|
+
var STRANDED_INBOUND_MIN_AGE_FROM_BOOT_MS = 6e4;
|
|
16120
|
+
var STRANDED_INBOUND_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
16121
|
+
var strandedInboundNoticeFired = false;
|
|
16122
|
+
var strandedInboundNoticeInFlight = false;
|
|
16123
|
+
async function notifyStrandedInboundsOnFirstConnect() {
|
|
16124
|
+
if (strandedInboundNoticeFired || strandedInboundNoticeInFlight) return;
|
|
16125
|
+
strandedInboundNoticeInFlight = true;
|
|
16126
|
+
let hadFailure = false;
|
|
16127
|
+
try {
|
|
16128
|
+
if (!SLACK_PENDING_INBOUND_DIR || !existsSync3(SLACK_PENDING_INBOUND_DIR)) return;
|
|
16129
|
+
let filenames;
|
|
16130
|
+
try {
|
|
16131
|
+
filenames = readdirSync3(SLACK_PENDING_INBOUND_DIR);
|
|
16132
|
+
} catch {
|
|
16133
|
+
hadFailure = true;
|
|
16134
|
+
return;
|
|
16135
|
+
}
|
|
16136
|
+
const now = Date.now();
|
|
16137
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16138
|
+
let notified = 0;
|
|
16139
|
+
for (const filename of filenames) {
|
|
16140
|
+
if (!filename.endsWith(".json")) continue;
|
|
16141
|
+
const fullPath = join5(SLACK_PENDING_INBOUND_DIR, filename);
|
|
16142
|
+
let marker;
|
|
16143
|
+
try {
|
|
16144
|
+
marker = JSON.parse(readFileSync4(fullPath, "utf-8"));
|
|
16145
|
+
} catch {
|
|
16146
|
+
continue;
|
|
16147
|
+
}
|
|
16148
|
+
const { channel, thread_ts, received_at } = marker;
|
|
16149
|
+
if (!channel || !thread_ts || !received_at) continue;
|
|
16150
|
+
const receivedAtMs = Date.parse(received_at);
|
|
16151
|
+
if (!Number.isFinite(receivedAtMs)) continue;
|
|
16152
|
+
if (receivedAtMs >= SLACK_PROCESS_BOOT_MS - STRANDED_INBOUND_MIN_AGE_FROM_BOOT_MS) continue;
|
|
16153
|
+
if (now - receivedAtMs > STRANDED_INBOUND_MAX_AGE_MS) continue;
|
|
16154
|
+
const key2 = `${channel}__${thread_ts}`;
|
|
16155
|
+
if (seen.has(key2)) {
|
|
16156
|
+
try {
|
|
16157
|
+
unlinkSync3(fullPath);
|
|
16158
|
+
} catch {
|
|
16159
|
+
}
|
|
16160
|
+
continue;
|
|
16161
|
+
}
|
|
16162
|
+
seen.add(key2);
|
|
16163
|
+
const res = await postSlackMessage({
|
|
16164
|
+
channel,
|
|
16165
|
+
thread_ts,
|
|
16166
|
+
text: "I was restarted mid-conversation and may have missed your last message. Please re-send if I didn't reply."
|
|
16167
|
+
});
|
|
16168
|
+
if (res.ok) {
|
|
16169
|
+
notified += 1;
|
|
16170
|
+
try {
|
|
16171
|
+
unlinkSync3(fullPath);
|
|
16172
|
+
} catch {
|
|
16173
|
+
}
|
|
16174
|
+
} else {
|
|
16175
|
+
hadFailure = true;
|
|
16176
|
+
process.stderr.write(
|
|
16177
|
+
`slack-channel(${AGENT_CODE_NAME}): stranded-inbound notify failed channel=${redactSlackId(channel)} thread=${redactSlackId(thread_ts)} error=${res.error}
|
|
16178
|
+
`
|
|
16179
|
+
);
|
|
16180
|
+
}
|
|
16181
|
+
}
|
|
16182
|
+
if (notified > 0) {
|
|
16183
|
+
process.stderr.write(
|
|
16184
|
+
`slack-channel(${AGENT_CODE_NAME}): notified ${notified} stranded inbound thread(s) after restart
|
|
16185
|
+
`
|
|
16186
|
+
);
|
|
16187
|
+
}
|
|
16188
|
+
} finally {
|
|
16189
|
+
if (!hadFailure) strandedInboundNoticeFired = true;
|
|
16190
|
+
strandedInboundNoticeInFlight = false;
|
|
16191
|
+
}
|
|
16192
|
+
}
|
|
16118
16193
|
function clearPendingMessage(channel, threadTs) {
|
|
16119
16194
|
clearAllSlackPendingMarkersForThread2(channel, threadTs);
|
|
16120
16195
|
}
|
|
@@ -17945,6 +18020,7 @@ async function connectSocketMode() {
|
|
|
17945
18020
|
process.stderr.write("slack-channel: Socket Mode connected\n");
|
|
17946
18021
|
recordActivity("connect");
|
|
17947
18022
|
void setBotStatus(":large_green_circle:", "Active");
|
|
18023
|
+
void notifyStrandedInboundsOnFirstConnect();
|
|
17948
18024
|
};
|
|
17949
18025
|
ws.onmessage = async (event) => {
|
|
17950
18026
|
try {
|
package/package.json
CHANGED
|
File without changes
|