@integrity-labs/agt-cli 0.27.60 → 0.27.62
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 +95 -3
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-2YSXMB7P.js → chunk-33OAS3V2.js} +1 -1
- package/dist/lib/manager-worker.js +212 -21
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/telegram-channel.js +116 -27
- package/package.json +1 -1
- /package/dist/{chunk-2YSXMB7P.js.map → chunk-33OAS3V2.js.map} +0 -0
|
@@ -15568,6 +15568,18 @@ var ORPHAN_SWEEP_INTERVAL_MS = 30 * 60 * 1e3;
|
|
|
15568
15568
|
function orphanSweepIntervalMs() {
|
|
15569
15569
|
return Math.max(6e4, Math.min(ORPHAN_SWEEP_INTERVAL_MS, channelOrphanMarkerMs()));
|
|
15570
15570
|
}
|
|
15571
|
+
var MAX_MARKER_REPLAYS = 3;
|
|
15572
|
+
function channelReplayEnabled() {
|
|
15573
|
+
const v = process.env.AGT_CHANNEL_REPLAY_ENABLED;
|
|
15574
|
+
return v === "1" || v === "true";
|
|
15575
|
+
}
|
|
15576
|
+
function shouldReplayMarker(i) {
|
|
15577
|
+
if (!i.enabled) return false;
|
|
15578
|
+
if (!i.hasPayload) return false;
|
|
15579
|
+
if (!i.sessionAlive) return false;
|
|
15580
|
+
if (i.markerAgeMs < (i.minAgeMs ?? REPLY_WEDGED_THRESHOLD_MS)) return false;
|
|
15581
|
+
return i.replayCount < (i.maxReplays ?? MAX_MARKER_REPLAYS);
|
|
15582
|
+
}
|
|
15571
15583
|
|
|
15572
15584
|
// src/session-probe-runtime.ts
|
|
15573
15585
|
import { execFileSync } from "child_process";
|
|
@@ -16030,7 +16042,7 @@ function pendingInboundPath(chatId, messageId) {
|
|
|
16030
16042
|
if (!PENDING_INBOUND_DIR) return null;
|
|
16031
16043
|
return join4(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
|
|
16032
16044
|
}
|
|
16033
|
-
function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false) {
|
|
16045
|
+
function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false, payload) {
|
|
16034
16046
|
const path = pendingInboundPath(chatId, messageId);
|
|
16035
16047
|
if (!path || !PENDING_INBOUND_DIR) return;
|
|
16036
16048
|
const marker = {
|
|
@@ -16039,7 +16051,10 @@ function writePendingInboundMarker(chatId, messageId, chatType, undeliverable =
|
|
|
16039
16051
|
chat_type: chatType,
|
|
16040
16052
|
received_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16041
16053
|
// Only persist the flag when set — keeps healthy-path markers byte-identical.
|
|
16042
|
-
...undeliverable ? { undeliverable: true } : {}
|
|
16054
|
+
...undeliverable ? { undeliverable: true } : {},
|
|
16055
|
+
// ENG-5969: carry the replay payload only when provided (the durable-replay
|
|
16056
|
+
// path). Absent ⇒ the marker can't be replayed (older / ack-only callers).
|
|
16057
|
+
...payload ? { payload } : {}
|
|
16043
16058
|
};
|
|
16044
16059
|
try {
|
|
16045
16060
|
mkdirSync3(PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
|
|
@@ -16240,8 +16255,8 @@ function startRecoveryOutboxWatcher() {
|
|
|
16240
16255
|
}
|
|
16241
16256
|
startRecoveryOutboxWatcher();
|
|
16242
16257
|
var STALE_MARKER_MS = 24 * 60 * 60 * 1e3;
|
|
16243
|
-
function trackPendingMessage(chatId, messageId, chatType, undeliverable = false) {
|
|
16244
|
-
writePendingInboundMarker(chatId, messageId, chatType, undeliverable);
|
|
16258
|
+
function trackPendingMessage(chatId, messageId, chatType, undeliverable = false, payload) {
|
|
16259
|
+
writePendingInboundMarker(chatId, messageId, chatType, undeliverable, payload);
|
|
16245
16260
|
}
|
|
16246
16261
|
function sweepTelegramStaleMarkers(thresholdMs) {
|
|
16247
16262
|
if (!PENDING_INBOUND_DIR) return;
|
|
@@ -16885,6 +16900,73 @@ async function ackCallbackQuery(callbackQueryId, text) {
|
|
|
16885
16900
|
}
|
|
16886
16901
|
}
|
|
16887
16902
|
await mcp.connect(new StdioServerTransport());
|
|
16903
|
+
var REPLAY_SCAN_INTERVAL_MS = 6e4;
|
|
16904
|
+
async function replayPendingTelegramMarkers() {
|
|
16905
|
+
if (!channelReplayEnabled()) return;
|
|
16906
|
+
if (!PENDING_INBOUND_DIR || !existsSync2(PENDING_INBOUND_DIR)) return;
|
|
16907
|
+
const probe = process.env.TMUX && AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? probeAgentSessionCached(AGENT_CODE_NAME) : { tmux: "unknown", claude: "unknown" };
|
|
16908
|
+
const sessionAlive = probe.tmux === "alive" && probe.claude === "alive";
|
|
16909
|
+
if (!sessionAlive) return;
|
|
16910
|
+
let filenames;
|
|
16911
|
+
try {
|
|
16912
|
+
filenames = readdirSync2(PENDING_INBOUND_DIR);
|
|
16913
|
+
} catch {
|
|
16914
|
+
return;
|
|
16915
|
+
}
|
|
16916
|
+
const now = Date.now();
|
|
16917
|
+
const entries = [];
|
|
16918
|
+
for (const name of filenames) {
|
|
16919
|
+
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
16920
|
+
const fullPath = join4(PENDING_INBOUND_DIR, name);
|
|
16921
|
+
let marker;
|
|
16922
|
+
try {
|
|
16923
|
+
marker = JSON.parse(readFileSync3(fullPath, "utf-8"));
|
|
16924
|
+
} catch {
|
|
16925
|
+
continue;
|
|
16926
|
+
}
|
|
16927
|
+
const t = Date.parse(marker.received_at ?? "");
|
|
16928
|
+
const ageMs = Number.isFinite(t) ? now - t : 0;
|
|
16929
|
+
entries.push({ path: fullPath, marker, ageMs });
|
|
16930
|
+
}
|
|
16931
|
+
entries.sort((a, b) => b.ageMs - a.ageMs);
|
|
16932
|
+
for (const { path, marker, ageMs } of entries) {
|
|
16933
|
+
if (!shouldReplayMarker({
|
|
16934
|
+
enabled: true,
|
|
16935
|
+
hasPayload: Boolean(marker.payload),
|
|
16936
|
+
sessionAlive,
|
|
16937
|
+
markerAgeMs: ageMs,
|
|
16938
|
+
replayCount: marker.replay_count ?? 0
|
|
16939
|
+
})) {
|
|
16940
|
+
continue;
|
|
16941
|
+
}
|
|
16942
|
+
try {
|
|
16943
|
+
await mcp.notification({
|
|
16944
|
+
method: "notifications/claude/channel",
|
|
16945
|
+
params: marker.payload
|
|
16946
|
+
});
|
|
16947
|
+
} catch (err) {
|
|
16948
|
+
process.stderr.write(
|
|
16949
|
+
`telegram-channel(${AGENT_CODE_NAME}): replay push failed: ${err.message}
|
|
16950
|
+
`
|
|
16951
|
+
);
|
|
16952
|
+
continue;
|
|
16953
|
+
}
|
|
16954
|
+
try {
|
|
16955
|
+
if (existsSync2(path)) {
|
|
16956
|
+
const updated = {
|
|
16957
|
+
...marker,
|
|
16958
|
+
replay_count: (marker.replay_count ?? 0) + 1
|
|
16959
|
+
};
|
|
16960
|
+
writeFileSync3(path, JSON.stringify(updated), { mode: 384 });
|
|
16961
|
+
}
|
|
16962
|
+
} catch {
|
|
16963
|
+
}
|
|
16964
|
+
}
|
|
16965
|
+
}
|
|
16966
|
+
var replayTimer = setInterval(() => {
|
|
16967
|
+
void replayPendingTelegramMarkers();
|
|
16968
|
+
}, REPLAY_SCAN_INTERVAL_MS);
|
|
16969
|
+
replayTimer.unref?.();
|
|
16888
16970
|
var LONG_POLL_SECONDS = 50;
|
|
16889
16971
|
var POLL_HTTP_TIMEOUT_MS = (LONG_POLL_SECONDS + 10) * 1e3;
|
|
16890
16972
|
var TELEGRAM_DOWNLOAD_TIMEOUT_MS = 15e3;
|
|
@@ -17181,7 +17263,6 @@ async function pollLoop() {
|
|
|
17181
17263
|
} else if (ackDecision === "undeliverable") {
|
|
17182
17264
|
void notifyUndeliverable(chatId, messageId);
|
|
17183
17265
|
}
|
|
17184
|
-
trackPendingMessage(chatId, messageId, msg.chat.type, ackDecision === "undeliverable");
|
|
17185
17266
|
const fileMeta = [];
|
|
17186
17267
|
for (const attachment of classifiedAttachments) {
|
|
17187
17268
|
if (attachment.kind === "image") {
|
|
@@ -17209,30 +17290,38 @@ async function pollLoop() {
|
|
|
17209
17290
|
}
|
|
17210
17291
|
const downloadedImages = fileMeta.filter((f) => f.kind === "image" && typeof f.path === "string");
|
|
17211
17292
|
const imagePath = downloadedImages.length === 1 ? downloadedImages[0].path : void 0;
|
|
17293
|
+
const channelPayload = {
|
|
17294
|
+
content,
|
|
17295
|
+
meta: {
|
|
17296
|
+
source: "telegram",
|
|
17297
|
+
chat_id: chatId,
|
|
17298
|
+
chat_type: msg.chat.type,
|
|
17299
|
+
message_id: messageId,
|
|
17300
|
+
user: userId,
|
|
17301
|
+
user_name: userName,
|
|
17302
|
+
ts: String(msg.date),
|
|
17303
|
+
...fileMeta.length > 0 ? { files: JSON.stringify(fileMeta) } : {},
|
|
17304
|
+
...imagePath ? { image_path: imagePath } : {},
|
|
17305
|
+
// ENG-4902: peer-agent ingress carries distinct framing so the
|
|
17306
|
+
// runtime (MVP #5) can apply the peer-agent system preamble
|
|
17307
|
+
// and store the turn under a peer_agent memory role.
|
|
17308
|
+
...peerAgentMeta ? {
|
|
17309
|
+
source_role: "agent",
|
|
17310
|
+
peer_code_name: peerAgentMeta.code_name,
|
|
17311
|
+
peer_agent_id: peerAgentMeta.agent_id
|
|
17312
|
+
} : {}
|
|
17313
|
+
}
|
|
17314
|
+
};
|
|
17315
|
+
trackPendingMessage(
|
|
17316
|
+
chatId,
|
|
17317
|
+
messageId,
|
|
17318
|
+
msg.chat.type,
|
|
17319
|
+
ackDecision === "undeliverable",
|
|
17320
|
+
channelPayload
|
|
17321
|
+
);
|
|
17212
17322
|
await mcp.notification({
|
|
17213
17323
|
method: "notifications/claude/channel",
|
|
17214
|
-
params:
|
|
17215
|
-
content,
|
|
17216
|
-
meta: {
|
|
17217
|
-
source: "telegram",
|
|
17218
|
-
chat_id: chatId,
|
|
17219
|
-
chat_type: msg.chat.type,
|
|
17220
|
-
message_id: messageId,
|
|
17221
|
-
user: userId,
|
|
17222
|
-
user_name: userName,
|
|
17223
|
-
ts: String(msg.date),
|
|
17224
|
-
...fileMeta.length > 0 ? { files: JSON.stringify(fileMeta) } : {},
|
|
17225
|
-
...imagePath ? { image_path: imagePath } : {},
|
|
17226
|
-
// ENG-4902: peer-agent ingress carries distinct framing so the
|
|
17227
|
-
// runtime (MVP #5) can apply the peer-agent system preamble
|
|
17228
|
-
// and store the turn under a peer_agent memory role.
|
|
17229
|
-
...peerAgentMeta ? {
|
|
17230
|
-
source_role: "agent",
|
|
17231
|
-
peer_code_name: peerAgentMeta.code_name,
|
|
17232
|
-
peer_agent_id: peerAgentMeta.agent_id
|
|
17233
|
-
} : {}
|
|
17234
|
-
}
|
|
17235
|
-
}
|
|
17324
|
+
params: channelPayload
|
|
17236
17325
|
});
|
|
17237
17326
|
conversationIngestClient?.ingest({
|
|
17238
17327
|
channel: "telegram",
|
package/package.json
CHANGED
|
File without changes
|