@integrity-labs/agt-cli 0.28.423 → 0.28.424
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-4SEBGBAO.js → chunk-2QBY2QVX.js} +3 -3
- package/dist/{chunk-XFC7YVGS.js → chunk-CWIWI2ZX.js} +1 -1
- package/dist/{chunk-XFC7YVGS.js.map → chunk-CWIWI2ZX.js.map} +1 -1
- package/dist/{claude-pair-runtime-3JHCWZZD.js → claude-pair-runtime-PAP4BS3I.js} +2 -2
- package/dist/lib/manager-worker.js +63 -42
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +80 -64
- package/dist/mcp/slack-channel.js +1 -1
- package/dist/mcp/telegram-channel.js +113 -97
- package/dist/{persistent-session-HWCKGPYF.js → persistent-session-O7OCNB6B.js} +2 -2
- package/dist/{responsiveness-probe-4CGMUXOH.js → responsiveness-probe-R5FWKHPI.js} +2 -2
- package/package.json +1 -1
- /package/dist/{chunk-4SEBGBAO.js.map → chunk-2QBY2QVX.js.map} +0 -0
- /package/dist/{claude-pair-runtime-3JHCWZZD.js.map → claude-pair-runtime-PAP4BS3I.js.map} +0 -0
- /package/dist/{persistent-session-HWCKGPYF.js.map → persistent-session-O7OCNB6B.js.map} +0 -0
- /package/dist/{responsiveness-probe-4CGMUXOH.js.map → responsiveness-probe-R5FWKHPI.js.map} +0 -0
|
@@ -18870,7 +18870,7 @@ var require_filters = __commonJS({
|
|
|
18870
18870
|
return r.copySafeness(str, res);
|
|
18871
18871
|
}
|
|
18872
18872
|
_exports.indent = indent;
|
|
18873
|
-
function
|
|
18873
|
+
function join15(arr, del, attr) {
|
|
18874
18874
|
del = del || "";
|
|
18875
18875
|
if (attr) {
|
|
18876
18876
|
arr = lib.map(arr, function(v) {
|
|
@@ -18879,7 +18879,7 @@ var require_filters = __commonJS({
|
|
|
18879
18879
|
}
|
|
18880
18880
|
return arr.join(del);
|
|
18881
18881
|
}
|
|
18882
|
-
_exports.join =
|
|
18882
|
+
_exports.join = join15;
|
|
18883
18883
|
function last(arr) {
|
|
18884
18884
|
return arr[arr.length - 1];
|
|
18885
18885
|
}
|
|
@@ -30093,18 +30093,18 @@ import {
|
|
|
30093
30093
|
ftruncateSync,
|
|
30094
30094
|
mkdirSync as mkdirSync9,
|
|
30095
30095
|
openSync,
|
|
30096
|
-
readFileSync as
|
|
30096
|
+
readFileSync as readFileSync14,
|
|
30097
30097
|
readdirSync as readdirSync4,
|
|
30098
30098
|
realpathSync,
|
|
30099
30099
|
renameSync as renameSync7,
|
|
30100
30100
|
statSync as statSync3,
|
|
30101
|
-
unlinkSync as
|
|
30101
|
+
unlinkSync as unlinkSync8,
|
|
30102
30102
|
watch,
|
|
30103
30103
|
writeFileSync as writeFileSync11,
|
|
30104
30104
|
writeSync
|
|
30105
30105
|
} from "fs";
|
|
30106
30106
|
import { homedir as homedir5 } from "os";
|
|
30107
|
-
import { basename, extname, join as
|
|
30107
|
+
import { basename, extname, join as join14, resolve as resolve2 } from "path";
|
|
30108
30108
|
|
|
30109
30109
|
// src/channel-attachments.ts
|
|
30110
30110
|
import { homedir } from "os";
|
|
@@ -35303,6 +35303,19 @@ function writeTurnInitiatorMarker(input) {
|
|
|
35303
35303
|
}
|
|
35304
35304
|
}
|
|
35305
35305
|
|
|
35306
|
+
// src/scheduled-turn-marker.ts
|
|
35307
|
+
import { readFileSync as readFileSync6, unlinkSync as unlinkSync4 } from "fs";
|
|
35308
|
+
import { join as join5 } from "path";
|
|
35309
|
+
var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
|
|
35310
|
+
var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
35311
|
+
function clearScheduledTurnMarker(agentDir) {
|
|
35312
|
+
if (!agentDir) return;
|
|
35313
|
+
try {
|
|
35314
|
+
unlinkSync4(join5(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
|
|
35315
|
+
} catch {
|
|
35316
|
+
}
|
|
35317
|
+
}
|
|
35318
|
+
|
|
35306
35319
|
// src/watch-command.ts
|
|
35307
35320
|
var WATCH_DEFAULT_DURATION_MS = 2 * 60 * 60 * 1e3;
|
|
35308
35321
|
var WATCH_MAX_DURATION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
@@ -35929,9 +35942,9 @@ function buildCommandRegistrations() {
|
|
|
35929
35942
|
import {
|
|
35930
35943
|
existsSync as existsSync3,
|
|
35931
35944
|
mkdirSync as mkdirSync5,
|
|
35932
|
-
readFileSync as
|
|
35945
|
+
readFileSync as readFileSync7,
|
|
35933
35946
|
renameSync as renameSync4,
|
|
35934
|
-
unlinkSync as
|
|
35947
|
+
unlinkSync as unlinkSync5,
|
|
35935
35948
|
writeFileSync as writeFileSync5
|
|
35936
35949
|
} from "fs";
|
|
35937
35950
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -35939,7 +35952,7 @@ function loadPersistedOffset(filePath) {
|
|
|
35939
35952
|
if (!filePath) return 0;
|
|
35940
35953
|
try {
|
|
35941
35954
|
const parsed = JSON.parse(
|
|
35942
|
-
|
|
35955
|
+
readFileSync7(filePath, "utf-8")
|
|
35943
35956
|
);
|
|
35944
35957
|
const offset = parsed?.offset;
|
|
35945
35958
|
if (typeof offset === "number" && Number.isFinite(offset) && offset > 0) {
|
|
@@ -35967,7 +35980,7 @@ function persistOffset(opts) {
|
|
|
35967
35980
|
} catch (err) {
|
|
35968
35981
|
onError?.(`getUpdates offset persist failed: ${err.message}`);
|
|
35969
35982
|
try {
|
|
35970
|
-
if (existsSync3(tmpPath))
|
|
35983
|
+
if (existsSync3(tmpPath)) unlinkSync5(tmpPath);
|
|
35971
35984
|
} catch {
|
|
35972
35985
|
}
|
|
35973
35986
|
}
|
|
@@ -35983,8 +35996,8 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
35983
35996
|
}
|
|
35984
35997
|
|
|
35985
35998
|
// src/inbound-lane-telemetry.ts
|
|
35986
|
-
import { readFileSync as
|
|
35987
|
-
import { join as
|
|
35999
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
36000
|
+
import { join as join6 } from "path";
|
|
35988
36001
|
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
35989
36002
|
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
35990
36003
|
var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
|
|
@@ -36001,10 +36014,10 @@ function isSuspectedMisclassification(lane, source) {
|
|
|
36001
36014
|
}
|
|
36002
36015
|
function recordLaneClassification(agentDir, channel, classification) {
|
|
36003
36016
|
if (!agentDir) return;
|
|
36004
|
-
const path =
|
|
36017
|
+
const path = join6(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
36005
36018
|
let counts = {};
|
|
36006
36019
|
try {
|
|
36007
|
-
const parsed = JSON.parse(
|
|
36020
|
+
const parsed = JSON.parse(readFileSync8(path, "utf-8"));
|
|
36008
36021
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
36009
36022
|
} catch {
|
|
36010
36023
|
}
|
|
@@ -36020,15 +36033,15 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
36020
36033
|
}
|
|
36021
36034
|
|
|
36022
36035
|
// src/agent-config-state.ts
|
|
36023
|
-
import { existsSync as existsSync4, readFileSync as
|
|
36024
|
-
import { join as
|
|
36036
|
+
import { existsSync as existsSync4, readFileSync as readFileSync9 } from "fs";
|
|
36037
|
+
import { join as join7 } from "path";
|
|
36025
36038
|
var SESSION_STATE_FILENAME = "session-state.json";
|
|
36026
36039
|
function readAgentSessionState(stateDir) {
|
|
36027
36040
|
if (!stateDir) return null;
|
|
36028
|
-
const path =
|
|
36041
|
+
const path = join7(stateDir, SESSION_STATE_FILENAME);
|
|
36029
36042
|
if (!existsSync4(path)) return null;
|
|
36030
36043
|
try {
|
|
36031
|
-
const parsed = JSON.parse(
|
|
36044
|
+
const parsed = JSON.parse(readFileSync9(path, "utf-8"));
|
|
36032
36045
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
36033
36046
|
return parsed;
|
|
36034
36047
|
} catch {
|
|
@@ -36834,7 +36847,7 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
|
|
|
36834
36847
|
import { execFile as execFile2 } from "child_process";
|
|
36835
36848
|
import { existsSync as existsSync5, mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
|
|
36836
36849
|
import { homedir as homedir4 } from "os";
|
|
36837
|
-
import { join as
|
|
36850
|
+
import { join as join8 } from "path";
|
|
36838
36851
|
var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
|
|
36839
36852
|
var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
|
|
36840
36853
|
var ANTHROPIC_API_VERSION = "2023-06-01";
|
|
@@ -36933,12 +36946,12 @@ async function runAnthropicMessages(prompt, opts) {
|
|
|
36933
36946
|
var emptyMcpConfigPath = null;
|
|
36934
36947
|
function ensureEmptyMcpConfig() {
|
|
36935
36948
|
if (emptyMcpConfigPath && existsSync5(emptyMcpConfigPath)) return emptyMcpConfigPath;
|
|
36936
|
-
const dir =
|
|
36949
|
+
const dir = join8(homedir4(), ".augmented");
|
|
36937
36950
|
try {
|
|
36938
36951
|
mkdirSync6(dir, { recursive: true });
|
|
36939
36952
|
} catch {
|
|
36940
36953
|
}
|
|
36941
|
-
const p2 =
|
|
36954
|
+
const p2 = join8(dir, ".reply-intent-empty-mcp.json");
|
|
36942
36955
|
writeFileSync7(p2, JSON.stringify({ mcpServers: {} }));
|
|
36943
36956
|
emptyMcpConfigPath = p2;
|
|
36944
36957
|
return p2;
|
|
@@ -37085,11 +37098,11 @@ function emitTransientApiErrorTelemetry(channel, match, original) {
|
|
|
37085
37098
|
}
|
|
37086
37099
|
|
|
37087
37100
|
// src/telegram-pending-inbound-cleanup.ts
|
|
37088
|
-
import { readdirSync, readFileSync as
|
|
37089
|
-
import { join as
|
|
37101
|
+
import { readdirSync, readFileSync as readFileSync10, statSync } from "fs";
|
|
37102
|
+
import { join as join9 } from "path";
|
|
37090
37103
|
function markerArrivalMs(fullPath) {
|
|
37091
37104
|
try {
|
|
37092
|
-
const received = JSON.parse(
|
|
37105
|
+
const received = JSON.parse(readFileSync10(fullPath, "utf-8")).received_at;
|
|
37093
37106
|
const parsed = received ? Date.parse(received) : Number.NaN;
|
|
37094
37107
|
if (Number.isFinite(parsed)) return parsed;
|
|
37095
37108
|
} catch {
|
|
@@ -37119,7 +37132,7 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
|
|
|
37119
37132
|
for (const filename of filenames) {
|
|
37120
37133
|
if (!filename.startsWith(prefix)) continue;
|
|
37121
37134
|
if (!filename.endsWith(".json")) continue;
|
|
37122
|
-
const fullPath =
|
|
37135
|
+
const fullPath = join9(pendingDir, filename);
|
|
37123
37136
|
if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
|
|
37124
37137
|
op(fullPath);
|
|
37125
37138
|
applied++;
|
|
@@ -37128,31 +37141,31 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
|
|
|
37128
37141
|
}
|
|
37129
37142
|
|
|
37130
37143
|
// src/recovery-ledger.ts
|
|
37131
|
-
import { existsSync as existsSync6, unlinkSync as
|
|
37132
|
-
import { join as
|
|
37144
|
+
import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
|
|
37145
|
+
import { join as join10 } from "path";
|
|
37133
37146
|
function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p2) => existsSync6(p2)) {
|
|
37134
37147
|
if (!ledgerDir || !markerName) return false;
|
|
37135
37148
|
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
|
|
37136
37149
|
try {
|
|
37137
|
-
return exists(
|
|
37150
|
+
return exists(join10(ledgerDir, markerName));
|
|
37138
37151
|
} catch {
|
|
37139
37152
|
return false;
|
|
37140
37153
|
}
|
|
37141
37154
|
}
|
|
37142
37155
|
function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p2) => {
|
|
37143
|
-
if (existsSync6(p2))
|
|
37156
|
+
if (existsSync6(p2)) unlinkSync6(p2);
|
|
37144
37157
|
}) {
|
|
37145
37158
|
if (!ledgerDir || !markerName) return;
|
|
37146
37159
|
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
|
|
37147
37160
|
try {
|
|
37148
|
-
unlink(
|
|
37161
|
+
unlink(join10(ledgerDir, markerName));
|
|
37149
37162
|
} catch {
|
|
37150
37163
|
}
|
|
37151
37164
|
}
|
|
37152
37165
|
|
|
37153
37166
|
// src/inbound-delivery-ledger.ts
|
|
37154
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync2, readFileSync as
|
|
37155
|
-
import { join as
|
|
37167
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync2, readFileSync as readFileSync11, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
|
|
37168
|
+
import { join as join11 } from "path";
|
|
37156
37169
|
function safeInboundId(inboundId) {
|
|
37157
37170
|
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
37158
37171
|
}
|
|
@@ -37161,7 +37174,7 @@ var defaultDeps = {
|
|
|
37161
37174
|
writeFile: (path, data) => writeFileSync8(path, data, "utf8"),
|
|
37162
37175
|
rename: (from, to) => renameSync5(from, to),
|
|
37163
37176
|
readdir: (dir) => readdirSync2(dir),
|
|
37164
|
-
readFile: (path) =>
|
|
37177
|
+
readFile: (path) => readFileSync11(path, "utf8"),
|
|
37165
37178
|
exists: (path) => existsSync7(path)
|
|
37166
37179
|
};
|
|
37167
37180
|
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
@@ -37170,7 +37183,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
|
37170
37183
|
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
|
|
37171
37184
|
try {
|
|
37172
37185
|
deps.mkdir(dir);
|
|
37173
|
-
const final =
|
|
37186
|
+
const final = join11(dir, `${safe}.json`);
|
|
37174
37187
|
const tmp = `${final}.tmp`;
|
|
37175
37188
|
deps.writeFile(tmp, JSON.stringify(record2));
|
|
37176
37189
|
deps.rename(tmp, final);
|
|
@@ -37375,14 +37388,14 @@ function createKanbanCardActiveClient(args) {
|
|
|
37375
37388
|
import {
|
|
37376
37389
|
existsSync as existsSync8,
|
|
37377
37390
|
mkdirSync as mkdirSync8,
|
|
37378
|
-
readFileSync as
|
|
37391
|
+
readFileSync as readFileSync12,
|
|
37379
37392
|
renameSync as renameSync6,
|
|
37380
37393
|
statSync as statSync2,
|
|
37381
|
-
unlinkSync as
|
|
37394
|
+
unlinkSync as unlinkSync7,
|
|
37382
37395
|
utimesSync,
|
|
37383
37396
|
writeFileSync as writeFileSync9
|
|
37384
37397
|
} from "fs";
|
|
37385
|
-
import { join as
|
|
37398
|
+
import { join as join12 } from "path";
|
|
37386
37399
|
var STALE_LOCK_MS = 9e4;
|
|
37387
37400
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
37388
37401
|
function defaultIsPidAlive(pid) {
|
|
@@ -37405,7 +37418,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
37405
37418
|
const nowMs = options.nowMs ?? (() => Date.now());
|
|
37406
37419
|
const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
|
|
37407
37420
|
const staleMs = options.staleMs ?? STALE_LOCK_MS;
|
|
37408
|
-
const path =
|
|
37421
|
+
const path = join12(agentDir, basename2);
|
|
37409
37422
|
const existing = readLockHolder(path);
|
|
37410
37423
|
if (existing) {
|
|
37411
37424
|
if (existing.pid === selfPid) {
|
|
@@ -37433,7 +37446,7 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
|
37433
37446
|
if (!existing) return;
|
|
37434
37447
|
if (existing.pid !== selfPid) return;
|
|
37435
37448
|
try {
|
|
37436
|
-
|
|
37449
|
+
unlinkSync7(lockPath);
|
|
37437
37450
|
} catch {
|
|
37438
37451
|
}
|
|
37439
37452
|
}
|
|
@@ -37472,7 +37485,7 @@ function defaultLockMtimeMs(path) {
|
|
|
37472
37485
|
function readLockHolder(path) {
|
|
37473
37486
|
if (!existsSync8(path)) return null;
|
|
37474
37487
|
try {
|
|
37475
|
-
const raw =
|
|
37488
|
+
const raw = readFileSync12(path, "utf8");
|
|
37476
37489
|
const parsed = JSON.parse(raw);
|
|
37477
37490
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
37478
37491
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -37484,8 +37497,8 @@ function readLockHolder(path) {
|
|
|
37484
37497
|
}
|
|
37485
37498
|
|
|
37486
37499
|
// src/ack-reaction.ts
|
|
37487
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
37488
|
-
import { join as
|
|
37500
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
|
|
37501
|
+
import { join as join13 } from "path";
|
|
37489
37502
|
var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
|
|
37490
37503
|
var ACK_STARTUP_GRACE_MS = 6e4;
|
|
37491
37504
|
var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
|
|
@@ -37558,7 +37571,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
|
37558
37571
|
function readGiveUpSignal(path, now = Date.now()) {
|
|
37559
37572
|
if (!path) return null;
|
|
37560
37573
|
try {
|
|
37561
|
-
const raw = JSON.parse(
|
|
37574
|
+
const raw = JSON.parse(readFileSync13(path, "utf8"));
|
|
37562
37575
|
if (typeof raw.gave_up_at !== "string") return null;
|
|
37563
37576
|
const t = Date.parse(raw.gave_up_at);
|
|
37564
37577
|
if (!Number.isFinite(t) || t > now) return null;
|
|
@@ -37593,7 +37606,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
|
|
|
37593
37606
|
if (!name.endsWith(".json")) continue;
|
|
37594
37607
|
let receivedAt;
|
|
37595
37608
|
try {
|
|
37596
|
-
const raw = JSON.parse(
|
|
37609
|
+
const raw = JSON.parse(readFileSync13(join13(dir, name), "utf-8"));
|
|
37597
37610
|
if (raw.discretionary === true) continue;
|
|
37598
37611
|
if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
|
|
37599
37612
|
receivedAt = raw.received_at;
|
|
@@ -37661,14 +37674,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
|
|
|
37661
37674
|
}
|
|
37662
37675
|
var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
|
|
37663
37676
|
function deflectionCounterPath(agentDir, channel) {
|
|
37664
|
-
return
|
|
37677
|
+
return join13(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
|
|
37665
37678
|
}
|
|
37666
37679
|
function recordChannelDeflection(agentDir, channel, cause) {
|
|
37667
37680
|
if (!agentDir) return;
|
|
37668
37681
|
const path = deflectionCounterPath(agentDir, channel);
|
|
37669
37682
|
let counts = {};
|
|
37670
37683
|
try {
|
|
37671
|
-
const parsed = JSON.parse(
|
|
37684
|
+
const parsed = JSON.parse(readFileSync13(path, "utf-8"));
|
|
37672
37685
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
37673
37686
|
} catch {
|
|
37674
37687
|
}
|
|
@@ -37749,7 +37762,7 @@ function redactId(id) {
|
|
|
37749
37762
|
}
|
|
37750
37763
|
var BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
|
|
37751
37764
|
var AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME ?? "unknown";
|
|
37752
|
-
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
37765
|
+
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join14(homedir5(), ".augmented", AGENT_CODE_NAME) : null;
|
|
37753
37766
|
var AGT_HOST = process.env.AGT_HOST ?? null;
|
|
37754
37767
|
var AGT_API_KEY = process.env.AGT_API_KEY ?? null;
|
|
37755
37768
|
var AGT_AGENT_ID = process.env.AGT_AGENT_ID ?? null;
|
|
@@ -37859,9 +37872,9 @@ if (!BOT_TOKEN) {
|
|
|
37859
37872
|
var stderrLogStream = null;
|
|
37860
37873
|
if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
|
|
37861
37874
|
try {
|
|
37862
|
-
const logDir =
|
|
37875
|
+
const logDir = join14(homedir5(), ".augmented", AGENT_CODE_NAME);
|
|
37863
37876
|
mkdirSync9(logDir, { recursive: true });
|
|
37864
|
-
stderrLogStream = createWriteStream(
|
|
37877
|
+
stderrLogStream = createWriteStream(join14(logDir, "telegram-channel-stderr.log"), {
|
|
37865
37878
|
flags: "a",
|
|
37866
37879
|
mode: 384
|
|
37867
37880
|
});
|
|
@@ -38182,7 +38195,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
38182
38195
|
let paneLogFreshAgeMs = null;
|
|
38183
38196
|
if (AGENT_DIR) {
|
|
38184
38197
|
try {
|
|
38185
|
-
const paneMtimeMs = statSync3(
|
|
38198
|
+
const paneMtimeMs = statSync3(join14(AGENT_DIR, "pane.log")).mtimeMs;
|
|
38186
38199
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
38187
38200
|
} catch {
|
|
38188
38201
|
}
|
|
@@ -38212,7 +38225,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
38212
38225
|
function __resetBusyAckNoticeThrottle() {
|
|
38213
38226
|
lastBusyAckNoticeAt.clear();
|
|
38214
38227
|
}
|
|
38215
|
-
var RESTART_FLAGS_DIR =
|
|
38228
|
+
var RESTART_FLAGS_DIR = join14(homedir5(), ".augmented", "restart-flags");
|
|
38216
38229
|
function actuateHostRestartTelegram() {
|
|
38217
38230
|
return actuateHostRestart({
|
|
38218
38231
|
agtHost: AGT_HOST,
|
|
@@ -38597,7 +38610,7 @@ async function handleRestartCommand(opts) {
|
|
|
38597
38610
|
if (!existsSync9(RESTART_FLAGS_DIR)) {
|
|
38598
38611
|
mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
|
|
38599
38612
|
}
|
|
38600
|
-
const flagPath =
|
|
38613
|
+
const flagPath = join14(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
|
|
38601
38614
|
const flag = {
|
|
38602
38615
|
codeName: AGENT_CODE_NAME,
|
|
38603
38616
|
source: "telegram",
|
|
@@ -39003,16 +39016,16 @@ async function classifyRestartCommand(text) {
|
|
|
39003
39016
|
if (!ours) return "verification_failed";
|
|
39004
39017
|
return target === ours ? "act" : "ignore";
|
|
39005
39018
|
}
|
|
39006
|
-
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
39007
|
-
var PENDING_INBOUND_DIR = AGENT_DIR ?
|
|
39008
|
-
var RECOVERY_OUTBOX_DIR = AGENT_DIR ?
|
|
39009
|
-
var RECOVERY_LEDGER_DIR = AGENT_DIR ?
|
|
39010
|
-
var DELIVERY_LEDGER_DIR = AGENT_DIR ?
|
|
39011
|
-
var RESTART_CONFIRM_FILE = AGENT_DIR ?
|
|
39019
|
+
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join14(homedir5(), ".augmented", AGENT_CODE_NAME) : null;
|
|
39020
|
+
var PENDING_INBOUND_DIR = AGENT_DIR ? join14(AGENT_DIR, "telegram-pending-inbound") : null;
|
|
39021
|
+
var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join14(AGENT_DIR, "telegram-recovery-outbox") : null;
|
|
39022
|
+
var RECOVERY_LEDGER_DIR = AGENT_DIR ? join14(AGENT_DIR, ".agt-telegram-recovery-ledger") : null;
|
|
39023
|
+
var DELIVERY_LEDGER_DIR = AGENT_DIR ? join14(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
|
|
39024
|
+
var RESTART_CONFIRM_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-restart-confirm.json") : null;
|
|
39012
39025
|
var TELEGRAM_PROCESS_BOOT_MS = Date.now();
|
|
39013
|
-
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ?
|
|
39014
|
-
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ?
|
|
39015
|
-
var TELEGRAM_OFFSET_FILE = AGENT_DIR ?
|
|
39026
|
+
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-recent-dms.json") : null;
|
|
39027
|
+
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-channel-add-restart.json") : null;
|
|
39028
|
+
var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-getupdates-offset.json") : null;
|
|
39016
39029
|
var recentDms = /* @__PURE__ */ new Map();
|
|
39017
39030
|
var recentDmPersister = TELEGRAM_RECENT_DMS_FILE ? createRecentDmPersister({
|
|
39018
39031
|
filePath: TELEGRAM_RECENT_DMS_FILE,
|
|
@@ -39067,7 +39080,7 @@ function safeMarkerName(chatId, messageId) {
|
|
|
39067
39080
|
}
|
|
39068
39081
|
function pendingInboundPath(chatId, messageId) {
|
|
39069
39082
|
if (!PENDING_INBOUND_DIR) return null;
|
|
39070
|
-
return
|
|
39083
|
+
return join14(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
|
|
39071
39084
|
}
|
|
39072
39085
|
function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false, payload) {
|
|
39073
39086
|
const path = pendingInboundPath(chatId, messageId);
|
|
@@ -39115,7 +39128,7 @@ function rewriteTelegramMarkerInPlace(path, marker) {
|
|
|
39115
39128
|
function clearTelegramMarkerFileWithHeal(fullPath) {
|
|
39116
39129
|
let marker = null;
|
|
39117
39130
|
try {
|
|
39118
|
-
marker = JSON.parse(
|
|
39131
|
+
marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
|
|
39119
39132
|
} catch {
|
|
39120
39133
|
}
|
|
39121
39134
|
if (marker && decideRecoveryHeal({
|
|
@@ -39125,14 +39138,14 @@ function clearTelegramMarkerFileWithHeal(fullPath) {
|
|
|
39125
39138
|
notifyBackOnline(marker.chat_id);
|
|
39126
39139
|
}
|
|
39127
39140
|
try {
|
|
39128
|
-
if (existsSync9(fullPath))
|
|
39141
|
+
if (existsSync9(fullPath)) unlinkSync8(fullPath);
|
|
39129
39142
|
} catch {
|
|
39130
39143
|
}
|
|
39131
39144
|
}
|
|
39132
39145
|
function markTelegramMarkerSeenInPlace(fullPath) {
|
|
39133
39146
|
let marker;
|
|
39134
39147
|
try {
|
|
39135
|
-
marker = JSON.parse(
|
|
39148
|
+
marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
|
|
39136
39149
|
} catch {
|
|
39137
39150
|
return;
|
|
39138
39151
|
}
|
|
@@ -39144,7 +39157,7 @@ function markTelegramMarkerSeenInPlace(fullPath) {
|
|
|
39144
39157
|
function markTelegramMarkerSeenWithHeal(fullPath) {
|
|
39145
39158
|
let marker = null;
|
|
39146
39159
|
try {
|
|
39147
|
-
marker = JSON.parse(
|
|
39160
|
+
marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
|
|
39148
39161
|
} catch {
|
|
39149
39162
|
return;
|
|
39150
39163
|
}
|
|
@@ -39160,7 +39173,7 @@ function readPendingInboundMarker(chatId, messageId) {
|
|
|
39160
39173
|
const path = pendingInboundPath(chatId, messageId);
|
|
39161
39174
|
if (!path || !existsSync9(path)) return null;
|
|
39162
39175
|
try {
|
|
39163
|
-
return JSON.parse(
|
|
39176
|
+
return JSON.parse(readFileSync14(path, "utf-8"));
|
|
39164
39177
|
} catch {
|
|
39165
39178
|
return null;
|
|
39166
39179
|
}
|
|
@@ -39180,10 +39193,10 @@ function nextRetryName(filename) {
|
|
|
39180
39193
|
async function processRecoveryOutboxFile(filename) {
|
|
39181
39194
|
if (!RECOVERY_OUTBOX_DIR) return;
|
|
39182
39195
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
39183
|
-
const fullPath =
|
|
39196
|
+
const fullPath = join14(RECOVERY_OUTBOX_DIR, filename);
|
|
39184
39197
|
let payload;
|
|
39185
39198
|
try {
|
|
39186
|
-
const raw =
|
|
39199
|
+
const raw = readFileSync14(fullPath, "utf-8");
|
|
39187
39200
|
payload = JSON.parse(raw);
|
|
39188
39201
|
} catch (err) {
|
|
39189
39202
|
process.stderr.write(
|
|
@@ -39232,7 +39245,7 @@ async function processRecoveryOutboxFile(filename) {
|
|
|
39232
39245
|
clearPendingMessage(payload.chat_id, recoveryDrainCutoffMs);
|
|
39233
39246
|
removeRecoveryLedgerEntry(RECOVERY_LEDGER_DIR, payload.marker_name);
|
|
39234
39247
|
try {
|
|
39235
|
-
|
|
39248
|
+
unlinkSync8(fullPath);
|
|
39236
39249
|
} catch {
|
|
39237
39250
|
}
|
|
39238
39251
|
return;
|
|
@@ -39269,7 +39282,7 @@ async function processRecoveryOutboxFile(filename) {
|
|
|
39269
39282
|
if (sendSucceeded) {
|
|
39270
39283
|
removeRecoveryLedgerEntry(RECOVERY_LEDGER_DIR, payload.marker_name);
|
|
39271
39284
|
try {
|
|
39272
|
-
|
|
39285
|
+
unlinkSync8(fullPath);
|
|
39273
39286
|
} catch {
|
|
39274
39287
|
}
|
|
39275
39288
|
return;
|
|
@@ -39277,7 +39290,7 @@ async function processRecoveryOutboxFile(filename) {
|
|
|
39277
39290
|
const next = nextRetryName(filename);
|
|
39278
39291
|
if (next) {
|
|
39279
39292
|
try {
|
|
39280
|
-
renameSync7(fullPath,
|
|
39293
|
+
renameSync7(fullPath, join14(RECOVERY_OUTBOX_DIR, next.next));
|
|
39281
39294
|
if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
|
|
39282
39295
|
process.stderr.write(
|
|
39283
39296
|
`telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -39318,7 +39331,7 @@ function scanRecoveryRetries() {
|
|
|
39318
39331
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
39319
39332
|
let mtimeMs;
|
|
39320
39333
|
try {
|
|
39321
|
-
mtimeMs = statSync3(
|
|
39334
|
+
mtimeMs = statSync3(join14(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
39322
39335
|
} catch {
|
|
39323
39336
|
continue;
|
|
39324
39337
|
}
|
|
@@ -39348,7 +39361,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
39348
39361
|
const watcher = watch(RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
39349
39362
|
if (event !== "rename" || !filename) return;
|
|
39350
39363
|
if (!isFirstAttemptOutboxFile(filename)) return;
|
|
39351
|
-
if (existsSync9(
|
|
39364
|
+
if (existsSync9(join14(RECOVERY_OUTBOX_DIR, filename))) {
|
|
39352
39365
|
void processRecoveryOutboxFile(filename);
|
|
39353
39366
|
}
|
|
39354
39367
|
});
|
|
@@ -39363,7 +39376,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
39363
39376
|
retryTimer.unref?.();
|
|
39364
39377
|
}
|
|
39365
39378
|
startRecoveryOutboxWatcher();
|
|
39366
|
-
var NOTICE_OUTBOX_DIR = AGENT_DIR ?
|
|
39379
|
+
var NOTICE_OUTBOX_DIR = AGENT_DIR ? join14(AGENT_DIR, "telegram-notice-outbox") : null;
|
|
39367
39380
|
var NOTICE_MAX_AGE_MS = 9e4;
|
|
39368
39381
|
var NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
|
|
39369
39382
|
async function processNoticeOutboxFile(filename) {
|
|
@@ -39371,7 +39384,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
39371
39384
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
39372
39385
|
if (NOTICE_INFLIGHT.has(filename)) return;
|
|
39373
39386
|
NOTICE_INFLIGHT.add(filename);
|
|
39374
|
-
const fullPath =
|
|
39387
|
+
const fullPath = join14(NOTICE_OUTBOX_DIR, filename);
|
|
39375
39388
|
try {
|
|
39376
39389
|
let mtimeMs;
|
|
39377
39390
|
try {
|
|
@@ -39381,26 +39394,26 @@ async function processNoticeOutboxFile(filename) {
|
|
|
39381
39394
|
}
|
|
39382
39395
|
if (Date.now() - mtimeMs > NOTICE_MAX_AGE_MS) {
|
|
39383
39396
|
try {
|
|
39384
|
-
|
|
39397
|
+
unlinkSync8(fullPath);
|
|
39385
39398
|
} catch {
|
|
39386
39399
|
}
|
|
39387
39400
|
return;
|
|
39388
39401
|
}
|
|
39389
39402
|
let payload;
|
|
39390
39403
|
try {
|
|
39391
|
-
const parsed = JSON.parse(
|
|
39404
|
+
const parsed = JSON.parse(readFileSync14(fullPath, "utf-8"));
|
|
39392
39405
|
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
39393
39406
|
payload = parsed;
|
|
39394
39407
|
} catch {
|
|
39395
39408
|
try {
|
|
39396
|
-
|
|
39409
|
+
unlinkSync8(fullPath);
|
|
39397
39410
|
} catch {
|
|
39398
39411
|
}
|
|
39399
39412
|
return;
|
|
39400
39413
|
}
|
|
39401
39414
|
if (!payload.chat_id || !payload.text) {
|
|
39402
39415
|
try {
|
|
39403
|
-
|
|
39416
|
+
unlinkSync8(fullPath);
|
|
39404
39417
|
} catch {
|
|
39405
39418
|
}
|
|
39406
39419
|
return;
|
|
@@ -39411,7 +39424,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
39411
39424
|
defaultValue: false
|
|
39412
39425
|
})) {
|
|
39413
39426
|
try {
|
|
39414
|
-
|
|
39427
|
+
unlinkSync8(fullPath);
|
|
39415
39428
|
} catch {
|
|
39416
39429
|
}
|
|
39417
39430
|
return;
|
|
@@ -39440,7 +39453,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
39440
39453
|
);
|
|
39441
39454
|
}
|
|
39442
39455
|
try {
|
|
39443
|
-
|
|
39456
|
+
unlinkSync8(fullPath);
|
|
39444
39457
|
} catch {
|
|
39445
39458
|
}
|
|
39446
39459
|
} finally {
|
|
@@ -39465,7 +39478,7 @@ function startNoticeOutboxWatcher() {
|
|
|
39465
39478
|
try {
|
|
39466
39479
|
const watcher = watch(NOTICE_OUTBOX_DIR, (event, filename) => {
|
|
39467
39480
|
if (event !== "rename" || !filename) return;
|
|
39468
|
-
if (existsSync9(
|
|
39481
|
+
if (existsSync9(join14(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
|
|
39469
39482
|
});
|
|
39470
39483
|
watcher.unref?.();
|
|
39471
39484
|
} catch (err) {
|
|
@@ -39498,17 +39511,17 @@ function sweepTelegramStaleMarkers(thresholdMs) {
|
|
|
39498
39511
|
for (const filename of filenames) {
|
|
39499
39512
|
if (!filename.endsWith(".json")) continue;
|
|
39500
39513
|
if (filename.endsWith(".tmp")) continue;
|
|
39501
|
-
const fullPath =
|
|
39514
|
+
const fullPath = join14(PENDING_INBOUND_DIR, filename);
|
|
39502
39515
|
let marker;
|
|
39503
39516
|
try {
|
|
39504
|
-
marker = JSON.parse(
|
|
39517
|
+
marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
|
|
39505
39518
|
} catch (err) {
|
|
39506
39519
|
process.stderr.write(
|
|
39507
39520
|
`telegram-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactId(filename)}: ${err.message}
|
|
39508
39521
|
`
|
|
39509
39522
|
);
|
|
39510
39523
|
try {
|
|
39511
|
-
|
|
39524
|
+
unlinkSync8(fullPath);
|
|
39512
39525
|
} catch {
|
|
39513
39526
|
}
|
|
39514
39527
|
cleared++;
|
|
@@ -39526,7 +39539,7 @@ function sweepTelegramStaleMarkers(thresholdMs) {
|
|
|
39526
39539
|
);
|
|
39527
39540
|
}
|
|
39528
39541
|
try {
|
|
39529
|
-
|
|
39542
|
+
unlinkSync8(fullPath);
|
|
39530
39543
|
} catch {
|
|
39531
39544
|
}
|
|
39532
39545
|
cleared++;
|
|
@@ -39547,13 +39560,13 @@ var orphanSweepTimer = setInterval(() => {
|
|
|
39547
39560
|
checkWatchdogGiveUpNotice();
|
|
39548
39561
|
}, orphanSweepIntervalMs());
|
|
39549
39562
|
orphanSweepTimer.unref?.();
|
|
39550
|
-
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ?
|
|
39563
|
+
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join14(AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
39551
39564
|
var telegramTrackedProgress = null;
|
|
39552
39565
|
var telegramProgressTickRunning = false;
|
|
39553
39566
|
function readTelegramProgressHeartbeat() {
|
|
39554
39567
|
if (!TELEGRAM_PROGRESS_HEARTBEAT_PATH || !existsSync9(TELEGRAM_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
39555
39568
|
try {
|
|
39556
|
-
return parseProgressHeartbeat(
|
|
39569
|
+
return parseProgressHeartbeat(readFileSync14(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
39557
39570
|
} catch {
|
|
39558
39571
|
return null;
|
|
39559
39572
|
}
|
|
@@ -39566,7 +39579,7 @@ function seedTelegramProgressHeartbeat() {
|
|
|
39566
39579
|
renameSync7(tmp, TELEGRAM_PROGRESS_HEARTBEAT_PATH);
|
|
39567
39580
|
} catch {
|
|
39568
39581
|
try {
|
|
39569
|
-
|
|
39582
|
+
unlinkSync8(tmp);
|
|
39570
39583
|
} catch {
|
|
39571
39584
|
}
|
|
39572
39585
|
}
|
|
@@ -39580,7 +39593,7 @@ function findTelegramProgressTarget() {
|
|
|
39580
39593
|
if (!name.endsWith(".json")) continue;
|
|
39581
39594
|
let m;
|
|
39582
39595
|
try {
|
|
39583
|
-
m = JSON.parse(
|
|
39596
|
+
m = JSON.parse(readFileSync14(join14(PENDING_INBOUND_DIR, name), "utf-8"));
|
|
39584
39597
|
} catch {
|
|
39585
39598
|
continue;
|
|
39586
39599
|
}
|
|
@@ -39711,7 +39724,7 @@ function listPendingInboundChatIds() {
|
|
|
39711
39724
|
if (!name.endsWith(".json")) continue;
|
|
39712
39725
|
try {
|
|
39713
39726
|
const marker = JSON.parse(
|
|
39714
|
-
|
|
39727
|
+
readFileSync14(join14(PENDING_INBOUND_DIR, name), "utf8")
|
|
39715
39728
|
);
|
|
39716
39729
|
if (typeof marker.seen_at === "string" && marker.seen_at) continue;
|
|
39717
39730
|
if (typeof marker.chat_id === "string" && marker.chat_id) chats.add(marker.chat_id);
|
|
@@ -39753,7 +39766,7 @@ async function notifyWatchdogGiveUp(chatId, reason) {
|
|
|
39753
39766
|
}
|
|
39754
39767
|
function checkWatchdogGiveUpNotice() {
|
|
39755
39768
|
if (!AGENT_DIR) return;
|
|
39756
|
-
const signal = readGiveUpSignal(
|
|
39769
|
+
const signal = readGiveUpSignal(join14(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
39757
39770
|
const signalAtMs = signal?.atMs ?? null;
|
|
39758
39771
|
const act = decideGiveUpNotice({
|
|
39759
39772
|
signalAtMs,
|
|
@@ -40109,7 +40122,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
40109
40122
|
isError: true
|
|
40110
40123
|
};
|
|
40111
40124
|
}
|
|
40112
|
-
bytes =
|
|
40125
|
+
bytes = readFileSync14(realPath);
|
|
40113
40126
|
} catch (err) {
|
|
40114
40127
|
return { content: [{ type: "text", text: `Failed to read file: ${err.message}` }], isError: true };
|
|
40115
40128
|
}
|
|
@@ -40670,7 +40683,7 @@ async function replayPendingTelegramMarkers() {
|
|
|
40670
40683
|
let paneFreshAgeMs = null;
|
|
40671
40684
|
if (AGENT_DIR) {
|
|
40672
40685
|
try {
|
|
40673
|
-
paneFreshAgeMs = Math.max(0, now - statSync3(
|
|
40686
|
+
paneFreshAgeMs = Math.max(0, now - statSync3(join14(AGENT_DIR, "pane.log")).mtimeMs);
|
|
40674
40687
|
} catch {
|
|
40675
40688
|
}
|
|
40676
40689
|
}
|
|
@@ -40678,10 +40691,10 @@ async function replayPendingTelegramMarkers() {
|
|
|
40678
40691
|
const entries = [];
|
|
40679
40692
|
for (const name of filenames) {
|
|
40680
40693
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
40681
|
-
const fullPath =
|
|
40694
|
+
const fullPath = join14(PENDING_INBOUND_DIR, name);
|
|
40682
40695
|
let marker;
|
|
40683
40696
|
try {
|
|
40684
|
-
marker = JSON.parse(
|
|
40697
|
+
marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
|
|
40685
40698
|
} catch {
|
|
40686
40699
|
continue;
|
|
40687
40700
|
}
|
|
@@ -41216,7 +41229,7 @@ async function pollLoop() {
|
|
|
41216
41229
|
let paneLogFreshAgeMs = null;
|
|
41217
41230
|
if (AGENT_DIR) {
|
|
41218
41231
|
try {
|
|
41219
|
-
const paneMtimeMs = statSync3(
|
|
41232
|
+
const paneMtimeMs = statSync3(join14(AGENT_DIR, "pane.log")).mtimeMs;
|
|
41220
41233
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
41221
41234
|
} catch {
|
|
41222
41235
|
}
|
|
@@ -41312,6 +41325,9 @@ async function pollLoop() {
|
|
|
41312
41325
|
if (ackDecision === "ack") {
|
|
41313
41326
|
scheduleBusyAck(chatId, messageId, arrivedWhileBusy);
|
|
41314
41327
|
}
|
|
41328
|
+
if (!isFromBot && !peerAgentMeta && userId && userId !== "unknown" && chatId) {
|
|
41329
|
+
clearScheduledTurnMarker(TELEGRAM_AGENT_DIR);
|
|
41330
|
+
}
|
|
41315
41331
|
await mcp.notification({
|
|
41316
41332
|
method: "notifications/claude/channel",
|
|
41317
41333
|
params: channelPayload
|