@integrity-labs/agt-cli 0.28.237 → 0.28.239
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-PYVEJMY2.js → chunk-GO4VMK2P.js} +37 -4
- package/dist/chunk-GO4VMK2P.js.map +1 -0
- package/dist/{chunk-DN4HSL6M.js → chunk-O3MVFYYC.js} +298 -9
- package/dist/chunk-O3MVFYYC.js.map +1 -0
- package/dist/{claude-pair-runtime-2ZFH6K4I.js → claude-pair-runtime-422CI7SM.js} +2 -2
- package/dist/lib/manager-worker.js +22 -11
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +63 -21
- package/dist/mcp/origami.js +40510 -0
- package/dist/mcp/slack-channel.js +551 -100
- package/dist/mcp/telegram-channel.js +111 -69
- package/dist/{persistent-session-LVDRHYX7.js → persistent-session-RRCU7CQJ.js} +2 -2
- package/dist/{responsiveness-probe-UW5TXKMS.js → responsiveness-probe-K5HFFW5F.js} +118 -3
- package/dist/responsiveness-probe-K5HFFW5F.js.map +1 -0
- package/package.json +3 -2
- package/dist/chunk-DN4HSL6M.js.map +0 -1
- package/dist/chunk-PYVEJMY2.js.map +0 -1
- package/dist/responsiveness-probe-UW5TXKMS.js.map +0 -1
- /package/dist/{claude-pair-runtime-2ZFH6K4I.js.map → claude-pair-runtime-422CI7SM.js.map} +0 -0
- /package/dist/{persistent-session-LVDRHYX7.js.map → persistent-session-RRCU7CQJ.js.map} +0 -0
|
@@ -14492,7 +14492,7 @@ import {
|
|
|
14492
14492
|
ftruncateSync,
|
|
14493
14493
|
mkdirSync as mkdirSync8,
|
|
14494
14494
|
openSync,
|
|
14495
|
-
readFileSync as
|
|
14495
|
+
readFileSync as readFileSync11,
|
|
14496
14496
|
readdirSync as readdirSync3,
|
|
14497
14497
|
renameSync as renameSync6,
|
|
14498
14498
|
statSync as statSync2,
|
|
@@ -14502,7 +14502,7 @@ import {
|
|
|
14502
14502
|
writeSync
|
|
14503
14503
|
} from "fs";
|
|
14504
14504
|
import { homedir as homedir4 } from "os";
|
|
14505
|
-
import { join as
|
|
14505
|
+
import { join as join10 } from "path";
|
|
14506
14506
|
|
|
14507
14507
|
// src/channel-attachments.ts
|
|
14508
14508
|
import { homedir } from "os";
|
|
@@ -15064,8 +15064,46 @@ function isMaintenanceModeActive(opts) {
|
|
|
15064
15064
|
}
|
|
15065
15065
|
|
|
15066
15066
|
// src/turn-initiator-marker.ts
|
|
15067
|
-
import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, renameSync as renameSync3 } from "fs";
|
|
15068
|
-
import { dirname as dirname3 } from "path";
|
|
15067
|
+
import { writeFileSync as writeFileSync4, readFileSync as readFileSync4, mkdirSync as mkdirSync4, renameSync as renameSync3 } from "fs";
|
|
15068
|
+
import { dirname as dirname3, join as join3 } from "path";
|
|
15069
|
+
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
15070
|
+
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
15071
|
+
var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
|
|
15072
|
+
function turnInitiatorLedgerPath(singleSlotFile) {
|
|
15073
|
+
return join3(dirname3(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
|
|
15074
|
+
}
|
|
15075
|
+
function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
|
|
15076
|
+
const now = marker.ts;
|
|
15077
|
+
const key2 = (e) => `${e.channel}\0${e.channel_ref ?? ""}`;
|
|
15078
|
+
const markerKey = key2(marker);
|
|
15079
|
+
const prior = existing && Array.isArray(existing.entries) ? existing.entries : [];
|
|
15080
|
+
const kept = prior.filter(
|
|
15081
|
+
(e) => e && typeof e.ts === "number" && Number.isFinite(e.ts) && now - e.ts <= maxAgeMs && now - e.ts >= 0 && key2(e) !== markerKey
|
|
15082
|
+
// the same thread is replaced by the new entry below
|
|
15083
|
+
);
|
|
15084
|
+
kept.push({
|
|
15085
|
+
channel: marker.channel,
|
|
15086
|
+
sender_id: marker.sender_id,
|
|
15087
|
+
...marker.sender_name ? { sender_name: marker.sender_name } : {},
|
|
15088
|
+
...marker.channel_ref ? { channel_ref: marker.channel_ref } : {},
|
|
15089
|
+
ts: marker.ts
|
|
15090
|
+
});
|
|
15091
|
+
kept.sort((a, b) => b.ts - a.ts);
|
|
15092
|
+
return { v: 1, entries: kept.slice(0, maxEntries) };
|
|
15093
|
+
}
|
|
15094
|
+
function updateTurnInitiatorLedger(singleSlotFile, marker) {
|
|
15095
|
+
const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
|
|
15096
|
+
let existing = null;
|
|
15097
|
+
try {
|
|
15098
|
+
const parsed = JSON.parse(readFileSync4(ledgerFile, "utf8"));
|
|
15099
|
+
if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
|
|
15100
|
+
} catch {
|
|
15101
|
+
}
|
|
15102
|
+
const next = foldTurnInitiatorLedger(existing, marker);
|
|
15103
|
+
const tmp = `${ledgerFile}.tmp`;
|
|
15104
|
+
writeFileSync4(tmp, JSON.stringify(next), "utf8");
|
|
15105
|
+
renameSync3(tmp, ledgerFile);
|
|
15106
|
+
}
|
|
15069
15107
|
function writeTurnInitiatorMarker(input) {
|
|
15070
15108
|
const file = process.env["AGT_TURN_INITIATOR_FILE"];
|
|
15071
15109
|
if (!file || !input.sender_id) return;
|
|
@@ -15075,6 +15113,10 @@ function writeTurnInitiatorMarker(input) {
|
|
|
15075
15113
|
const tmp = `${file}.tmp`;
|
|
15076
15114
|
writeFileSync4(tmp, JSON.stringify(marker), "utf8");
|
|
15077
15115
|
renameSync3(tmp, file);
|
|
15116
|
+
try {
|
|
15117
|
+
updateTurnInitiatorLedger(file, marker);
|
|
15118
|
+
} catch {
|
|
15119
|
+
}
|
|
15078
15120
|
} catch {
|
|
15079
15121
|
}
|
|
15080
15122
|
}
|
|
@@ -15697,7 +15739,7 @@ function buildCommandRegistrations() {
|
|
|
15697
15739
|
import {
|
|
15698
15740
|
existsSync as existsSync3,
|
|
15699
15741
|
mkdirSync as mkdirSync5,
|
|
15700
|
-
readFileSync as
|
|
15742
|
+
readFileSync as readFileSync5,
|
|
15701
15743
|
renameSync as renameSync4,
|
|
15702
15744
|
unlinkSync as unlinkSync4,
|
|
15703
15745
|
writeFileSync as writeFileSync5
|
|
@@ -15707,7 +15749,7 @@ function loadPersistedOffset(filePath) {
|
|
|
15707
15749
|
if (!filePath) return 0;
|
|
15708
15750
|
try {
|
|
15709
15751
|
const parsed = JSON.parse(
|
|
15710
|
-
|
|
15752
|
+
readFileSync5(filePath, "utf-8")
|
|
15711
15753
|
);
|
|
15712
15754
|
const offset = parsed?.offset;
|
|
15713
15755
|
if (typeof offset === "number" && Number.isFinite(offset) && offset > 0) {
|
|
@@ -15751,8 +15793,8 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
15751
15793
|
}
|
|
15752
15794
|
|
|
15753
15795
|
// src/inbound-lane-telemetry.ts
|
|
15754
|
-
import { readFileSync as
|
|
15755
|
-
import { join as
|
|
15796
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
15797
|
+
import { join as join4 } from "path";
|
|
15756
15798
|
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
15757
15799
|
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
15758
15800
|
var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
|
|
@@ -15769,10 +15811,10 @@ function isSuspectedMisclassification(lane, source) {
|
|
|
15769
15811
|
}
|
|
15770
15812
|
function recordLaneClassification(agentDir, channel, classification) {
|
|
15771
15813
|
if (!agentDir) return;
|
|
15772
|
-
const path =
|
|
15814
|
+
const path = join4(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
15773
15815
|
let counts = {};
|
|
15774
15816
|
try {
|
|
15775
|
-
const parsed = JSON.parse(
|
|
15817
|
+
const parsed = JSON.parse(readFileSync6(path, "utf-8"));
|
|
15776
15818
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
15777
15819
|
} catch {
|
|
15778
15820
|
}
|
|
@@ -15788,15 +15830,15 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
15788
15830
|
}
|
|
15789
15831
|
|
|
15790
15832
|
// src/agent-config-state.ts
|
|
15791
|
-
import { existsSync as existsSync4, readFileSync as
|
|
15792
|
-
import { join as
|
|
15833
|
+
import { existsSync as existsSync4, readFileSync as readFileSync7 } from "fs";
|
|
15834
|
+
import { join as join5 } from "path";
|
|
15793
15835
|
var SESSION_STATE_FILENAME = "session-state.json";
|
|
15794
15836
|
function readAgentSessionState(stateDir) {
|
|
15795
15837
|
if (!stateDir) return null;
|
|
15796
|
-
const path =
|
|
15838
|
+
const path = join5(stateDir, SESSION_STATE_FILENAME);
|
|
15797
15839
|
if (!existsSync4(path)) return null;
|
|
15798
15840
|
try {
|
|
15799
|
-
const parsed = JSON.parse(
|
|
15841
|
+
const parsed = JSON.parse(readFileSync7(path, "utf-8"));
|
|
15800
15842
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
15801
15843
|
return parsed;
|
|
15802
15844
|
} catch {
|
|
@@ -16546,7 +16588,7 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
|
|
|
16546
16588
|
import { execFile as execFile2 } from "child_process";
|
|
16547
16589
|
import { existsSync as existsSync5, mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
|
|
16548
16590
|
import { homedir as homedir3 } from "os";
|
|
16549
|
-
import { join as
|
|
16591
|
+
import { join as join6 } from "path";
|
|
16550
16592
|
var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
|
|
16551
16593
|
var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
|
|
16552
16594
|
var ANTHROPIC_API_VERSION = "2023-06-01";
|
|
@@ -16637,12 +16679,12 @@ async function runAnthropicMessages(prompt, opts) {
|
|
|
16637
16679
|
var emptyMcpConfigPath = null;
|
|
16638
16680
|
function ensureEmptyMcpConfig() {
|
|
16639
16681
|
if (emptyMcpConfigPath && existsSync5(emptyMcpConfigPath)) return emptyMcpConfigPath;
|
|
16640
|
-
const dir =
|
|
16682
|
+
const dir = join6(homedir3(), ".augmented");
|
|
16641
16683
|
try {
|
|
16642
16684
|
mkdirSync6(dir, { recursive: true });
|
|
16643
16685
|
} catch {
|
|
16644
16686
|
}
|
|
16645
|
-
const p =
|
|
16687
|
+
const p = join6(dir, ".reply-intent-empty-mcp.json");
|
|
16646
16688
|
writeFileSync7(p, JSON.stringify({ mcpServers: {} }));
|
|
16647
16689
|
emptyMcpConfigPath = p;
|
|
16648
16690
|
return p;
|
|
@@ -16766,11 +16808,11 @@ function emitTransientApiErrorTelemetry(channel, match, original) {
|
|
|
16766
16808
|
}
|
|
16767
16809
|
|
|
16768
16810
|
// src/telegram-pending-inbound-cleanup.ts
|
|
16769
|
-
import { readdirSync, readFileSync as
|
|
16770
|
-
import { join as
|
|
16811
|
+
import { readdirSync, readFileSync as readFileSync8, statSync } from "fs";
|
|
16812
|
+
import { join as join7 } from "path";
|
|
16771
16813
|
function markerArrivalMs(fullPath) {
|
|
16772
16814
|
try {
|
|
16773
|
-
const received = JSON.parse(
|
|
16815
|
+
const received = JSON.parse(readFileSync8(fullPath, "utf-8")).received_at;
|
|
16774
16816
|
const parsed = received ? Date.parse(received) : Number.NaN;
|
|
16775
16817
|
if (Number.isFinite(parsed)) return parsed;
|
|
16776
16818
|
} catch {
|
|
@@ -16800,7 +16842,7 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
|
|
|
16800
16842
|
for (const filename of filenames) {
|
|
16801
16843
|
if (!filename.startsWith(prefix)) continue;
|
|
16802
16844
|
if (!filename.endsWith(".json")) continue;
|
|
16803
|
-
const fullPath =
|
|
16845
|
+
const fullPath = join7(pendingDir, filename);
|
|
16804
16846
|
if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
|
|
16805
16847
|
op(fullPath);
|
|
16806
16848
|
applied++;
|
|
@@ -16958,12 +17000,12 @@ function createKanbanCardActiveClient(args) {
|
|
|
16958
17000
|
import {
|
|
16959
17001
|
existsSync as existsSync6,
|
|
16960
17002
|
mkdirSync as mkdirSync7,
|
|
16961
|
-
readFileSync as
|
|
17003
|
+
readFileSync as readFileSync9,
|
|
16962
17004
|
renameSync as renameSync5,
|
|
16963
17005
|
unlinkSync as unlinkSync5,
|
|
16964
17006
|
writeFileSync as writeFileSync8
|
|
16965
17007
|
} from "fs";
|
|
16966
|
-
import { join as
|
|
17008
|
+
import { join as join8 } from "path";
|
|
16967
17009
|
function defaultIsPidAlive(pid) {
|
|
16968
17010
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
16969
17011
|
try {
|
|
@@ -16981,7 +17023,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
16981
17023
|
const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
|
|
16982
17024
|
const selfPid = options.selfPid ?? process.pid;
|
|
16983
17025
|
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
16984
|
-
const path =
|
|
17026
|
+
const path = join8(agentDir, basename);
|
|
16985
17027
|
const existing = readLockHolder(path);
|
|
16986
17028
|
if (existing) {
|
|
16987
17029
|
if (existing.pid === selfPid) {
|
|
@@ -17012,7 +17054,7 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
|
|
|
17012
17054
|
function readLockHolder(path) {
|
|
17013
17055
|
if (!existsSync6(path)) return null;
|
|
17014
17056
|
try {
|
|
17015
|
-
const raw =
|
|
17057
|
+
const raw = readFileSync9(path, "utf8");
|
|
17016
17058
|
const parsed = JSON.parse(raw);
|
|
17017
17059
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
17018
17060
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -17024,8 +17066,8 @@ function readLockHolder(path) {
|
|
|
17024
17066
|
}
|
|
17025
17067
|
|
|
17026
17068
|
// src/ack-reaction.ts
|
|
17027
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
17028
|
-
import { join as
|
|
17069
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
|
|
17070
|
+
import { join as join9 } from "path";
|
|
17029
17071
|
var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
|
|
17030
17072
|
var ACK_STARTUP_GRACE_MS = 6e4;
|
|
17031
17073
|
var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
|
|
@@ -17098,7 +17140,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
|
17098
17140
|
function readGiveUpSignal(path, now = Date.now()) {
|
|
17099
17141
|
if (!path) return null;
|
|
17100
17142
|
try {
|
|
17101
|
-
const raw = JSON.parse(
|
|
17143
|
+
const raw = JSON.parse(readFileSync10(path, "utf8"));
|
|
17102
17144
|
if (typeof raw.gave_up_at !== "string") return null;
|
|
17103
17145
|
const t = Date.parse(raw.gave_up_at);
|
|
17104
17146
|
if (!Number.isFinite(t) || t > now) return null;
|
|
@@ -17133,7 +17175,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
|
|
|
17133
17175
|
if (!name.endsWith(".json")) continue;
|
|
17134
17176
|
let receivedAt;
|
|
17135
17177
|
try {
|
|
17136
|
-
const raw = JSON.parse(
|
|
17178
|
+
const raw = JSON.parse(readFileSync10(join9(dir, name), "utf-8"));
|
|
17137
17179
|
if (raw.discretionary === true) continue;
|
|
17138
17180
|
if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
|
|
17139
17181
|
receivedAt = raw.received_at;
|
|
@@ -17191,14 +17233,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
|
|
|
17191
17233
|
}
|
|
17192
17234
|
var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
|
|
17193
17235
|
function deflectionCounterPath(agentDir, channel) {
|
|
17194
|
-
return
|
|
17236
|
+
return join9(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
|
|
17195
17237
|
}
|
|
17196
17238
|
function recordChannelDeflection(agentDir, channel, cause) {
|
|
17197
17239
|
if (!agentDir) return;
|
|
17198
17240
|
const path = deflectionCounterPath(agentDir, channel);
|
|
17199
17241
|
let counts = {};
|
|
17200
17242
|
try {
|
|
17201
|
-
const parsed = JSON.parse(
|
|
17243
|
+
const parsed = JSON.parse(readFileSync10(path, "utf-8"));
|
|
17202
17244
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
17203
17245
|
} catch {
|
|
17204
17246
|
}
|
|
@@ -17279,7 +17321,7 @@ function redactId(id) {
|
|
|
17279
17321
|
}
|
|
17280
17322
|
var BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
|
|
17281
17323
|
var AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME ?? "unknown";
|
|
17282
|
-
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
17324
|
+
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join10(homedir4(), ".augmented", AGENT_CODE_NAME) : null;
|
|
17283
17325
|
var AGT_HOST = process.env.AGT_HOST ?? null;
|
|
17284
17326
|
var AGT_API_KEY = process.env.AGT_API_KEY ?? null;
|
|
17285
17327
|
var AGT_AGENT_ID = process.env.AGT_AGENT_ID ?? null;
|
|
@@ -17383,9 +17425,9 @@ if (!BOT_TOKEN) {
|
|
|
17383
17425
|
var stderrLogStream = null;
|
|
17384
17426
|
if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
|
|
17385
17427
|
try {
|
|
17386
|
-
const logDir =
|
|
17428
|
+
const logDir = join10(homedir4(), ".augmented", AGENT_CODE_NAME);
|
|
17387
17429
|
mkdirSync8(logDir, { recursive: true });
|
|
17388
|
-
stderrLogStream = createWriteStream(
|
|
17430
|
+
stderrLogStream = createWriteStream(join10(logDir, "telegram-channel-stderr.log"), {
|
|
17389
17431
|
flags: "a",
|
|
17390
17432
|
mode: 384
|
|
17391
17433
|
});
|
|
@@ -17624,7 +17666,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
17624
17666
|
let paneLogFreshAgeMs = null;
|
|
17625
17667
|
if (AGENT_DIR) {
|
|
17626
17668
|
try {
|
|
17627
|
-
const paneMtimeMs = statSync2(
|
|
17669
|
+
const paneMtimeMs = statSync2(join10(AGENT_DIR, "pane.log")).mtimeMs;
|
|
17628
17670
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
17629
17671
|
} catch {
|
|
17630
17672
|
}
|
|
@@ -17654,7 +17696,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
17654
17696
|
function __resetBusyAckNoticeThrottle() {
|
|
17655
17697
|
lastBusyAckNoticeAt.clear();
|
|
17656
17698
|
}
|
|
17657
|
-
var RESTART_FLAGS_DIR =
|
|
17699
|
+
var RESTART_FLAGS_DIR = join10(homedir4(), ".augmented", "restart-flags");
|
|
17658
17700
|
function actuateHostRestartTelegram() {
|
|
17659
17701
|
return actuateHostRestart({
|
|
17660
17702
|
agtHost: AGT_HOST,
|
|
@@ -18039,7 +18081,7 @@ async function handleRestartCommand(opts) {
|
|
|
18039
18081
|
if (!existsSync7(RESTART_FLAGS_DIR)) {
|
|
18040
18082
|
mkdirSync8(RESTART_FLAGS_DIR, { recursive: true });
|
|
18041
18083
|
}
|
|
18042
|
-
const flagPath =
|
|
18084
|
+
const flagPath = join10(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
|
|
18043
18085
|
const flag = {
|
|
18044
18086
|
codeName: AGENT_CODE_NAME,
|
|
18045
18087
|
source: "telegram",
|
|
@@ -18445,14 +18487,14 @@ async function classifyRestartCommand(text) {
|
|
|
18445
18487
|
if (!ours) return "verification_failed";
|
|
18446
18488
|
return target === ours ? "act" : "ignore";
|
|
18447
18489
|
}
|
|
18448
|
-
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
18449
|
-
var PENDING_INBOUND_DIR = AGENT_DIR ?
|
|
18450
|
-
var RECOVERY_OUTBOX_DIR = AGENT_DIR ?
|
|
18451
|
-
var RESTART_CONFIRM_FILE = AGENT_DIR ?
|
|
18490
|
+
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join10(homedir4(), ".augmented", AGENT_CODE_NAME) : null;
|
|
18491
|
+
var PENDING_INBOUND_DIR = AGENT_DIR ? join10(AGENT_DIR, "telegram-pending-inbound") : null;
|
|
18492
|
+
var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join10(AGENT_DIR, "telegram-recovery-outbox") : null;
|
|
18493
|
+
var RESTART_CONFIRM_FILE = AGENT_DIR ? join10(AGENT_DIR, "telegram-restart-confirm.json") : null;
|
|
18452
18494
|
var TELEGRAM_PROCESS_BOOT_MS = Date.now();
|
|
18453
|
-
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ?
|
|
18454
|
-
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ?
|
|
18455
|
-
var TELEGRAM_OFFSET_FILE = AGENT_DIR ?
|
|
18495
|
+
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join10(AGENT_DIR, "telegram-recent-dms.json") : null;
|
|
18496
|
+
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join10(AGENT_DIR, "telegram-channel-add-restart.json") : null;
|
|
18497
|
+
var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join10(AGENT_DIR, "telegram-getupdates-offset.json") : null;
|
|
18456
18498
|
var recentDms = /* @__PURE__ */ new Map();
|
|
18457
18499
|
var recentDmPersister = TELEGRAM_RECENT_DMS_FILE ? createRecentDmPersister({
|
|
18458
18500
|
filePath: TELEGRAM_RECENT_DMS_FILE,
|
|
@@ -18507,7 +18549,7 @@ function safeMarkerName(chatId, messageId) {
|
|
|
18507
18549
|
}
|
|
18508
18550
|
function pendingInboundPath(chatId, messageId) {
|
|
18509
18551
|
if (!PENDING_INBOUND_DIR) return null;
|
|
18510
|
-
return
|
|
18552
|
+
return join10(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
|
|
18511
18553
|
}
|
|
18512
18554
|
function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false, payload) {
|
|
18513
18555
|
const path = pendingInboundPath(chatId, messageId);
|
|
@@ -18553,7 +18595,7 @@ function rewriteTelegramMarkerInPlace(path, marker) {
|
|
|
18553
18595
|
function clearTelegramMarkerFileWithHeal(fullPath) {
|
|
18554
18596
|
let marker = null;
|
|
18555
18597
|
try {
|
|
18556
|
-
marker = JSON.parse(
|
|
18598
|
+
marker = JSON.parse(readFileSync11(fullPath, "utf-8"));
|
|
18557
18599
|
} catch {
|
|
18558
18600
|
}
|
|
18559
18601
|
if (marker && decideRecoveryHeal({
|
|
@@ -18570,7 +18612,7 @@ function clearTelegramMarkerFileWithHeal(fullPath) {
|
|
|
18570
18612
|
function markTelegramMarkerSeenInPlace(fullPath) {
|
|
18571
18613
|
let marker;
|
|
18572
18614
|
try {
|
|
18573
|
-
marker = JSON.parse(
|
|
18615
|
+
marker = JSON.parse(readFileSync11(fullPath, "utf-8"));
|
|
18574
18616
|
} catch {
|
|
18575
18617
|
return;
|
|
18576
18618
|
}
|
|
@@ -18582,7 +18624,7 @@ function markTelegramMarkerSeenInPlace(fullPath) {
|
|
|
18582
18624
|
function markTelegramMarkerSeenWithHeal(fullPath) {
|
|
18583
18625
|
let marker = null;
|
|
18584
18626
|
try {
|
|
18585
|
-
marker = JSON.parse(
|
|
18627
|
+
marker = JSON.parse(readFileSync11(fullPath, "utf-8"));
|
|
18586
18628
|
} catch {
|
|
18587
18629
|
return;
|
|
18588
18630
|
}
|
|
@@ -18598,7 +18640,7 @@ function readPendingInboundMarker(chatId, messageId) {
|
|
|
18598
18640
|
const path = pendingInboundPath(chatId, messageId);
|
|
18599
18641
|
if (!path || !existsSync7(path)) return null;
|
|
18600
18642
|
try {
|
|
18601
|
-
return JSON.parse(
|
|
18643
|
+
return JSON.parse(readFileSync11(path, "utf-8"));
|
|
18602
18644
|
} catch {
|
|
18603
18645
|
return null;
|
|
18604
18646
|
}
|
|
@@ -18618,10 +18660,10 @@ function nextRetryName(filename) {
|
|
|
18618
18660
|
async function processRecoveryOutboxFile(filename) {
|
|
18619
18661
|
if (!RECOVERY_OUTBOX_DIR) return;
|
|
18620
18662
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
18621
|
-
const fullPath =
|
|
18663
|
+
const fullPath = join10(RECOVERY_OUTBOX_DIR, filename);
|
|
18622
18664
|
let payload;
|
|
18623
18665
|
try {
|
|
18624
|
-
const raw =
|
|
18666
|
+
const raw = readFileSync11(fullPath, "utf-8");
|
|
18625
18667
|
payload = JSON.parse(raw);
|
|
18626
18668
|
} catch (err) {
|
|
18627
18669
|
process.stderr.write(
|
|
@@ -18711,7 +18753,7 @@ async function processRecoveryOutboxFile(filename) {
|
|
|
18711
18753
|
const next = nextRetryName(filename);
|
|
18712
18754
|
if (next) {
|
|
18713
18755
|
try {
|
|
18714
|
-
renameSync6(fullPath,
|
|
18756
|
+
renameSync6(fullPath, join10(RECOVERY_OUTBOX_DIR, next.next));
|
|
18715
18757
|
if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
|
|
18716
18758
|
process.stderr.write(
|
|
18717
18759
|
`telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -18751,7 +18793,7 @@ function scanRecoveryRetries() {
|
|
|
18751
18793
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
18752
18794
|
let mtimeMs;
|
|
18753
18795
|
try {
|
|
18754
|
-
mtimeMs = statSync2(
|
|
18796
|
+
mtimeMs = statSync2(join10(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
18755
18797
|
} catch {
|
|
18756
18798
|
continue;
|
|
18757
18799
|
}
|
|
@@ -18781,7 +18823,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
18781
18823
|
const watcher = watch(RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
18782
18824
|
if (event !== "rename" || !filename) return;
|
|
18783
18825
|
if (!isFirstAttemptOutboxFile(filename)) return;
|
|
18784
|
-
if (existsSync7(
|
|
18826
|
+
if (existsSync7(join10(RECOVERY_OUTBOX_DIR, filename))) {
|
|
18785
18827
|
void processRecoveryOutboxFile(filename);
|
|
18786
18828
|
}
|
|
18787
18829
|
});
|
|
@@ -18796,7 +18838,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
18796
18838
|
retryTimer.unref?.();
|
|
18797
18839
|
}
|
|
18798
18840
|
startRecoveryOutboxWatcher();
|
|
18799
|
-
var NOTICE_OUTBOX_DIR = AGENT_DIR ?
|
|
18841
|
+
var NOTICE_OUTBOX_DIR = AGENT_DIR ? join10(AGENT_DIR, "telegram-notice-outbox") : null;
|
|
18800
18842
|
var NOTICE_MAX_AGE_MS = 9e4;
|
|
18801
18843
|
var NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
|
|
18802
18844
|
async function processNoticeOutboxFile(filename) {
|
|
@@ -18804,7 +18846,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
18804
18846
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
18805
18847
|
if (NOTICE_INFLIGHT.has(filename)) return;
|
|
18806
18848
|
NOTICE_INFLIGHT.add(filename);
|
|
18807
|
-
const fullPath =
|
|
18849
|
+
const fullPath = join10(NOTICE_OUTBOX_DIR, filename);
|
|
18808
18850
|
try {
|
|
18809
18851
|
let mtimeMs;
|
|
18810
18852
|
try {
|
|
@@ -18821,7 +18863,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
18821
18863
|
}
|
|
18822
18864
|
let payload;
|
|
18823
18865
|
try {
|
|
18824
|
-
const parsed = JSON.parse(
|
|
18866
|
+
const parsed = JSON.parse(readFileSync11(fullPath, "utf-8"));
|
|
18825
18867
|
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
18826
18868
|
payload = parsed;
|
|
18827
18869
|
} catch {
|
|
@@ -18898,7 +18940,7 @@ function startNoticeOutboxWatcher() {
|
|
|
18898
18940
|
try {
|
|
18899
18941
|
const watcher = watch(NOTICE_OUTBOX_DIR, (event, filename) => {
|
|
18900
18942
|
if (event !== "rename" || !filename) return;
|
|
18901
|
-
if (existsSync7(
|
|
18943
|
+
if (existsSync7(join10(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
|
|
18902
18944
|
});
|
|
18903
18945
|
watcher.unref?.();
|
|
18904
18946
|
} catch (err) {
|
|
@@ -18931,10 +18973,10 @@ function sweepTelegramStaleMarkers(thresholdMs) {
|
|
|
18931
18973
|
for (const filename of filenames) {
|
|
18932
18974
|
if (!filename.endsWith(".json")) continue;
|
|
18933
18975
|
if (filename.endsWith(".tmp")) continue;
|
|
18934
|
-
const fullPath =
|
|
18976
|
+
const fullPath = join10(PENDING_INBOUND_DIR, filename);
|
|
18935
18977
|
let marker;
|
|
18936
18978
|
try {
|
|
18937
|
-
marker = JSON.parse(
|
|
18979
|
+
marker = JSON.parse(readFileSync11(fullPath, "utf-8"));
|
|
18938
18980
|
} catch (err) {
|
|
18939
18981
|
process.stderr.write(
|
|
18940
18982
|
`telegram-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactId(filename)}: ${err.message}
|
|
@@ -18976,13 +19018,13 @@ var orphanSweepTimer = setInterval(() => {
|
|
|
18976
19018
|
checkWatchdogGiveUpNotice();
|
|
18977
19019
|
}, orphanSweepIntervalMs());
|
|
18978
19020
|
orphanSweepTimer.unref?.();
|
|
18979
|
-
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ?
|
|
19021
|
+
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join10(AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
18980
19022
|
var telegramTrackedProgress = null;
|
|
18981
19023
|
var telegramProgressTickRunning = false;
|
|
18982
19024
|
function readTelegramProgressHeartbeat() {
|
|
18983
19025
|
if (!TELEGRAM_PROGRESS_HEARTBEAT_PATH || !existsSync7(TELEGRAM_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
18984
19026
|
try {
|
|
18985
|
-
return parseProgressHeartbeat(
|
|
19027
|
+
return parseProgressHeartbeat(readFileSync11(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
18986
19028
|
} catch {
|
|
18987
19029
|
return null;
|
|
18988
19030
|
}
|
|
@@ -19009,7 +19051,7 @@ function findTelegramProgressTarget() {
|
|
|
19009
19051
|
if (!name.endsWith(".json")) continue;
|
|
19010
19052
|
let m;
|
|
19011
19053
|
try {
|
|
19012
|
-
m = JSON.parse(
|
|
19054
|
+
m = JSON.parse(readFileSync11(join10(PENDING_INBOUND_DIR, name), "utf-8"));
|
|
19013
19055
|
} catch {
|
|
19014
19056
|
continue;
|
|
19015
19057
|
}
|
|
@@ -19140,7 +19182,7 @@ function listPendingInboundChatIds() {
|
|
|
19140
19182
|
if (!name.endsWith(".json")) continue;
|
|
19141
19183
|
try {
|
|
19142
19184
|
const marker = JSON.parse(
|
|
19143
|
-
|
|
19185
|
+
readFileSync11(join10(PENDING_INBOUND_DIR, name), "utf8")
|
|
19144
19186
|
);
|
|
19145
19187
|
if (typeof marker.seen_at === "string" && marker.seen_at) continue;
|
|
19146
19188
|
if (typeof marker.chat_id === "string" && marker.chat_id) chats.add(marker.chat_id);
|
|
@@ -19182,7 +19224,7 @@ async function notifyWatchdogGiveUp(chatId, reason) {
|
|
|
19182
19224
|
}
|
|
19183
19225
|
function checkWatchdogGiveUpNotice() {
|
|
19184
19226
|
if (!AGENT_DIR) return;
|
|
19185
|
-
const signal = readGiveUpSignal(
|
|
19227
|
+
const signal = readGiveUpSignal(join10(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
19186
19228
|
const signalAtMs = signal?.atMs ?? null;
|
|
19187
19229
|
const act = decideGiveUpNotice({
|
|
19188
19230
|
signalAtMs,
|
|
@@ -19946,17 +19988,17 @@ async function replayPendingTelegramMarkers() {
|
|
|
19946
19988
|
let paneFreshAgeMs = null;
|
|
19947
19989
|
if (AGENT_DIR) {
|
|
19948
19990
|
try {
|
|
19949
|
-
paneFreshAgeMs = Math.max(0, now - statSync2(
|
|
19991
|
+
paneFreshAgeMs = Math.max(0, now - statSync2(join10(AGENT_DIR, "pane.log")).mtimeMs);
|
|
19950
19992
|
} catch {
|
|
19951
19993
|
}
|
|
19952
19994
|
}
|
|
19953
19995
|
const entries = [];
|
|
19954
19996
|
for (const name of filenames) {
|
|
19955
19997
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
19956
|
-
const fullPath =
|
|
19998
|
+
const fullPath = join10(PENDING_INBOUND_DIR, name);
|
|
19957
19999
|
let marker;
|
|
19958
20000
|
try {
|
|
19959
|
-
marker = JSON.parse(
|
|
20001
|
+
marker = JSON.parse(readFileSync11(fullPath, "utf-8"));
|
|
19960
20002
|
} catch {
|
|
19961
20003
|
continue;
|
|
19962
20004
|
}
|
|
@@ -20472,7 +20514,7 @@ async function pollLoop() {
|
|
|
20472
20514
|
let paneLogFreshAgeMs = null;
|
|
20473
20515
|
if (AGENT_DIR) {
|
|
20474
20516
|
try {
|
|
20475
|
-
const paneMtimeMs = statSync2(
|
|
20517
|
+
const paneMtimeMs = statSync2(join10(AGENT_DIR, "pane.log")).mtimeMs;
|
|
20476
20518
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
20477
20519
|
} catch {
|
|
20478
20520
|
}
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
writeDirectChatSessionState,
|
|
37
37
|
writeEgressAllowlist,
|
|
38
38
|
writePersistentClaudeWrapper
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-GO4VMK2P.js";
|
|
40
40
|
import "./chunk-XWVM4KPK.js";
|
|
41
41
|
export {
|
|
42
42
|
EGRESS_BASELINE_DOMAINS,
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
writeEgressAllowlist,
|
|
78
78
|
writePersistentClaudeWrapper
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=persistent-session-
|
|
80
|
+
//# sourceMappingURL=persistent-session-RRCU7CQJ.js.map
|