@integrity-labs/agt-cli 0.28.431 → 0.28.433
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-EREBH2LV.js → chunk-NUKNLJNJ.js} +212 -274
- package/dist/chunk-NUKNLJNJ.js.map +1 -0
- package/dist/{chunk-SV67CNIX.js → chunk-RUVNJO63.js} +3 -3
- package/dist/{claude-pair-runtime-44RPFRIE.js → claude-pair-runtime-YAHBPFYL.js} +2 -2
- package/dist/lib/manager-worker.js +238 -197
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +101 -26
- package/dist/mcp/slack-channel.js +236 -128
- package/dist/mcp/telegram-channel.js +187 -91
- package/dist/{persistent-session-A4VUV3UI.js → persistent-session-ISBR3BBX.js} +2 -2
- package/dist/{responsiveness-probe-QRVMR22C.js → responsiveness-probe-OT6JVP43.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-EREBH2LV.js.map +0 -1
- /package/dist/{chunk-SV67CNIX.js.map → chunk-RUVNJO63.js.map} +0 -0
- /package/dist/{claude-pair-runtime-44RPFRIE.js.map → claude-pair-runtime-YAHBPFYL.js.map} +0 -0
- /package/dist/{persistent-session-A4VUV3UI.js.map → persistent-session-ISBR3BBX.js.map} +0 -0
- /package/dist/{responsiveness-probe-QRVMR22C.js.map → responsiveness-probe-OT6JVP43.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 join16(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 = join16;
|
|
18883
18883
|
function last(arr) {
|
|
18884
18884
|
return arr[arr.length - 1];
|
|
18885
18885
|
}
|
|
@@ -30093,7 +30093,7 @@ import {
|
|
|
30093
30093
|
ftruncateSync,
|
|
30094
30094
|
mkdirSync as mkdirSync9,
|
|
30095
30095
|
openSync,
|
|
30096
|
-
readFileSync as
|
|
30096
|
+
readFileSync as readFileSync15,
|
|
30097
30097
|
readdirSync as readdirSync4,
|
|
30098
30098
|
realpathSync,
|
|
30099
30099
|
renameSync as renameSync7,
|
|
@@ -30103,8 +30103,8 @@ import {
|
|
|
30103
30103
|
writeFileSync as writeFileSync11,
|
|
30104
30104
|
writeSync
|
|
30105
30105
|
} from "fs";
|
|
30106
|
-
import { homedir as
|
|
30107
|
-
import { basename, extname, join as
|
|
30106
|
+
import { homedir as homedir6 } from "os";
|
|
30107
|
+
import { basename, extname, join as join15, resolve as resolve2 } from "path";
|
|
30108
30108
|
|
|
30109
30109
|
// src/channel-attachments.ts
|
|
30110
30110
|
import { homedir } from "os";
|
|
@@ -34033,6 +34033,28 @@ function buildUsageLimitReplyText(limitedUntil) {
|
|
|
34033
34033
|
return `Your agent has hit its Claude Code usage limit until ${formatUtcClock(limitedUntil)}. It'll pick back up once the limit resets \u2014 please try again after then.`;
|
|
34034
34034
|
}
|
|
34035
34035
|
|
|
34036
|
+
// ../core/dist/account-enforcement/marker.js
|
|
34037
|
+
var ACCOUNT_ENFORCEMENT_MARKER_FILENAME = "account-enforcement.json";
|
|
34038
|
+
var ACCOUNT_ENFORCEMENT_MARKER_VERSION = 1;
|
|
34039
|
+
function parseAccountEnforcementMarker(raw) {
|
|
34040
|
+
let parsed;
|
|
34041
|
+
try {
|
|
34042
|
+
parsed = JSON.parse(raw);
|
|
34043
|
+
} catch {
|
|
34044
|
+
return null;
|
|
34045
|
+
}
|
|
34046
|
+
if (typeof parsed !== "object" || parsed === null || parsed.version !== ACCOUNT_ENFORCEMENT_MARKER_VERSION) {
|
|
34047
|
+
return null;
|
|
34048
|
+
}
|
|
34049
|
+
const level = parsed.level;
|
|
34050
|
+
if (level !== "warn" && level !== "mute")
|
|
34051
|
+
return null;
|
|
34052
|
+
return { version: ACCOUNT_ENFORCEMENT_MARKER_VERSION, level };
|
|
34053
|
+
}
|
|
34054
|
+
function buildAccountIssueReplyText() {
|
|
34055
|
+
return "There is an issue with your account, please contact support@augmented.team.";
|
|
34056
|
+
}
|
|
34057
|
+
|
|
34036
34058
|
// ../core/dist/kanban/state-machine.js
|
|
34037
34059
|
var KANBAN_STATUSES = [
|
|
34038
34060
|
"backlog",
|
|
@@ -35332,14 +35354,34 @@ function readUsageLimitUntil(opts) {
|
|
|
35332
35354
|
return resolveUsageLimitUntil(parseUsageLimitMarker(raw), opts.now ?? /* @__PURE__ */ new Date());
|
|
35333
35355
|
}
|
|
35334
35356
|
|
|
35357
|
+
// src/account-enforcement-notice.ts
|
|
35358
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
35359
|
+
import { homedir as homedir4 } from "os";
|
|
35360
|
+
import { join as join4 } from "path";
|
|
35361
|
+
function accountEnforcementMarkerPath(codeName) {
|
|
35362
|
+
if (!codeName) return null;
|
|
35363
|
+
return join4(homedir4(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
35364
|
+
}
|
|
35365
|
+
function readAccountEnforcementLevel(opts) {
|
|
35366
|
+
const path = opts.filePath ?? accountEnforcementMarkerPath(opts.codeName);
|
|
35367
|
+
if (!path) return null;
|
|
35368
|
+
let raw;
|
|
35369
|
+
try {
|
|
35370
|
+
raw = readFileSync5(path, "utf-8");
|
|
35371
|
+
} catch {
|
|
35372
|
+
return null;
|
|
35373
|
+
}
|
|
35374
|
+
return parseAccountEnforcementMarker(raw)?.level ?? null;
|
|
35375
|
+
}
|
|
35376
|
+
|
|
35335
35377
|
// src/turn-initiator-marker.ts
|
|
35336
|
-
import { writeFileSync as writeFileSync4, readFileSync as
|
|
35337
|
-
import { dirname as dirname3, join as
|
|
35378
|
+
import { writeFileSync as writeFileSync4, readFileSync as readFileSync6, mkdirSync as mkdirSync4, renameSync as renameSync3 } from "fs";
|
|
35379
|
+
import { dirname as dirname3, join as join5 } from "path";
|
|
35338
35380
|
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
35339
35381
|
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
35340
35382
|
var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
|
|
35341
35383
|
function turnInitiatorLedgerPath(singleSlotFile) {
|
|
35342
|
-
return
|
|
35384
|
+
return join5(dirname3(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
|
|
35343
35385
|
}
|
|
35344
35386
|
function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
|
|
35345
35387
|
const now = marker.ts;
|
|
@@ -35364,7 +35406,7 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
|
|
|
35364
35406
|
const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
|
|
35365
35407
|
let existing = null;
|
|
35366
35408
|
try {
|
|
35367
|
-
const parsed = JSON.parse(
|
|
35409
|
+
const parsed = JSON.parse(readFileSync6(ledgerFile, "utf8"));
|
|
35368
35410
|
if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
|
|
35369
35411
|
} catch {
|
|
35370
35412
|
}
|
|
@@ -35391,14 +35433,14 @@ function writeTurnInitiatorMarker(input) {
|
|
|
35391
35433
|
}
|
|
35392
35434
|
|
|
35393
35435
|
// src/scheduled-turn-marker.ts
|
|
35394
|
-
import { readFileSync as
|
|
35395
|
-
import { join as
|
|
35436
|
+
import { readFileSync as readFileSync7, unlinkSync as unlinkSync4 } from "fs";
|
|
35437
|
+
import { join as join6 } from "path";
|
|
35396
35438
|
var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
|
|
35397
35439
|
var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
35398
35440
|
function clearScheduledTurnMarker(agentDir) {
|
|
35399
35441
|
if (!agentDir) return;
|
|
35400
35442
|
try {
|
|
35401
|
-
unlinkSync4(
|
|
35443
|
+
unlinkSync4(join6(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
|
|
35402
35444
|
} catch {
|
|
35403
35445
|
}
|
|
35404
35446
|
}
|
|
@@ -36029,7 +36071,7 @@ function buildCommandRegistrations() {
|
|
|
36029
36071
|
import {
|
|
36030
36072
|
existsSync as existsSync3,
|
|
36031
36073
|
mkdirSync as mkdirSync5,
|
|
36032
|
-
readFileSync as
|
|
36074
|
+
readFileSync as readFileSync8,
|
|
36033
36075
|
renameSync as renameSync4,
|
|
36034
36076
|
unlinkSync as unlinkSync5,
|
|
36035
36077
|
writeFileSync as writeFileSync5
|
|
@@ -36039,7 +36081,7 @@ function loadPersistedOffset(filePath) {
|
|
|
36039
36081
|
if (!filePath) return 0;
|
|
36040
36082
|
try {
|
|
36041
36083
|
const parsed = JSON.parse(
|
|
36042
|
-
|
|
36084
|
+
readFileSync8(filePath, "utf-8")
|
|
36043
36085
|
);
|
|
36044
36086
|
const offset = parsed?.offset;
|
|
36045
36087
|
if (typeof offset === "number" && Number.isFinite(offset) && offset > 0) {
|
|
@@ -36083,8 +36125,8 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
36083
36125
|
}
|
|
36084
36126
|
|
|
36085
36127
|
// src/inbound-lane-telemetry.ts
|
|
36086
|
-
import { readFileSync as
|
|
36087
|
-
import { join as
|
|
36128
|
+
import { readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
|
|
36129
|
+
import { join as join7 } from "path";
|
|
36088
36130
|
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
36089
36131
|
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
36090
36132
|
var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
|
|
@@ -36101,10 +36143,10 @@ function isSuspectedMisclassification(lane, source) {
|
|
|
36101
36143
|
}
|
|
36102
36144
|
function recordLaneClassification(agentDir, channel, classification) {
|
|
36103
36145
|
if (!agentDir) return;
|
|
36104
|
-
const path =
|
|
36146
|
+
const path = join7(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
36105
36147
|
let counts = {};
|
|
36106
36148
|
try {
|
|
36107
|
-
const parsed = JSON.parse(
|
|
36149
|
+
const parsed = JSON.parse(readFileSync9(path, "utf-8"));
|
|
36108
36150
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
36109
36151
|
} catch {
|
|
36110
36152
|
}
|
|
@@ -36120,15 +36162,15 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
36120
36162
|
}
|
|
36121
36163
|
|
|
36122
36164
|
// src/agent-config-state.ts
|
|
36123
|
-
import { existsSync as existsSync4, readFileSync as
|
|
36124
|
-
import { join as
|
|
36165
|
+
import { existsSync as existsSync4, readFileSync as readFileSync10 } from "fs";
|
|
36166
|
+
import { join as join8 } from "path";
|
|
36125
36167
|
var SESSION_STATE_FILENAME = "session-state.json";
|
|
36126
36168
|
function readAgentSessionState(stateDir) {
|
|
36127
36169
|
if (!stateDir) return null;
|
|
36128
|
-
const path =
|
|
36170
|
+
const path = join8(stateDir, SESSION_STATE_FILENAME);
|
|
36129
36171
|
if (!existsSync4(path)) return null;
|
|
36130
36172
|
try {
|
|
36131
|
-
const parsed = JSON.parse(
|
|
36173
|
+
const parsed = JSON.parse(readFileSync10(path, "utf-8"));
|
|
36132
36174
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
36133
36175
|
return parsed;
|
|
36134
36176
|
} catch {
|
|
@@ -36933,8 +36975,8 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
|
|
|
36933
36975
|
// src/reply-intent-runtime.ts
|
|
36934
36976
|
import { execFile as execFile2 } from "child_process";
|
|
36935
36977
|
import { existsSync as existsSync5, mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
|
|
36936
|
-
import { homedir as
|
|
36937
|
-
import { join as
|
|
36978
|
+
import { homedir as homedir5 } from "os";
|
|
36979
|
+
import { join as join9 } from "path";
|
|
36938
36980
|
var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
|
|
36939
36981
|
var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
|
|
36940
36982
|
var ANTHROPIC_API_VERSION = "2023-06-01";
|
|
@@ -37033,12 +37075,12 @@ async function runAnthropicMessages(prompt, opts) {
|
|
|
37033
37075
|
var emptyMcpConfigPath = null;
|
|
37034
37076
|
function ensureEmptyMcpConfig() {
|
|
37035
37077
|
if (emptyMcpConfigPath && existsSync5(emptyMcpConfigPath)) return emptyMcpConfigPath;
|
|
37036
|
-
const dir =
|
|
37078
|
+
const dir = join9(homedir5(), ".augmented");
|
|
37037
37079
|
try {
|
|
37038
37080
|
mkdirSync6(dir, { recursive: true });
|
|
37039
37081
|
} catch {
|
|
37040
37082
|
}
|
|
37041
|
-
const p2 =
|
|
37083
|
+
const p2 = join9(dir, ".reply-intent-empty-mcp.json");
|
|
37042
37084
|
writeFileSync7(p2, JSON.stringify({ mcpServers: {} }));
|
|
37043
37085
|
emptyMcpConfigPath = p2;
|
|
37044
37086
|
return p2;
|
|
@@ -37063,7 +37105,7 @@ function runClaudeP(prompt, model) {
|
|
|
37063
37105
|
execFile2(
|
|
37064
37106
|
"claude",
|
|
37065
37107
|
args,
|
|
37066
|
-
{ cwd:
|
|
37108
|
+
{ cwd: homedir5(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
|
|
37067
37109
|
(err, stdout) => {
|
|
37068
37110
|
if (err) {
|
|
37069
37111
|
reject(err);
|
|
@@ -37185,11 +37227,11 @@ function emitTransientApiErrorTelemetry(channel, match, original) {
|
|
|
37185
37227
|
}
|
|
37186
37228
|
|
|
37187
37229
|
// src/telegram-pending-inbound-cleanup.ts
|
|
37188
|
-
import { readdirSync, readFileSync as
|
|
37189
|
-
import { join as
|
|
37230
|
+
import { readdirSync, readFileSync as readFileSync11, statSync } from "fs";
|
|
37231
|
+
import { join as join10 } from "path";
|
|
37190
37232
|
function markerArrivalMs(fullPath) {
|
|
37191
37233
|
try {
|
|
37192
|
-
const received = JSON.parse(
|
|
37234
|
+
const received = JSON.parse(readFileSync11(fullPath, "utf-8")).received_at;
|
|
37193
37235
|
const parsed = received ? Date.parse(received) : Number.NaN;
|
|
37194
37236
|
if (Number.isFinite(parsed)) return parsed;
|
|
37195
37237
|
} catch {
|
|
@@ -37219,7 +37261,7 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
|
|
|
37219
37261
|
for (const filename of filenames) {
|
|
37220
37262
|
if (!filename.startsWith(prefix)) continue;
|
|
37221
37263
|
if (!filename.endsWith(".json")) continue;
|
|
37222
|
-
const fullPath =
|
|
37264
|
+
const fullPath = join10(pendingDir, filename);
|
|
37223
37265
|
if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
|
|
37224
37266
|
op(fullPath);
|
|
37225
37267
|
applied++;
|
|
@@ -37229,12 +37271,12 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
|
|
|
37229
37271
|
|
|
37230
37272
|
// src/recovery-ledger.ts
|
|
37231
37273
|
import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
|
|
37232
|
-
import { join as
|
|
37274
|
+
import { join as join11 } from "path";
|
|
37233
37275
|
function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p2) => existsSync6(p2)) {
|
|
37234
37276
|
if (!ledgerDir || !markerName) return false;
|
|
37235
37277
|
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
|
|
37236
37278
|
try {
|
|
37237
|
-
return exists(
|
|
37279
|
+
return exists(join11(ledgerDir, markerName));
|
|
37238
37280
|
} catch {
|
|
37239
37281
|
return false;
|
|
37240
37282
|
}
|
|
@@ -37245,14 +37287,14 @@ function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p2) => {
|
|
|
37245
37287
|
if (!ledgerDir || !markerName) return;
|
|
37246
37288
|
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
|
|
37247
37289
|
try {
|
|
37248
|
-
unlink(
|
|
37290
|
+
unlink(join11(ledgerDir, markerName));
|
|
37249
37291
|
} catch {
|
|
37250
37292
|
}
|
|
37251
37293
|
}
|
|
37252
37294
|
|
|
37253
37295
|
// src/inbound-delivery-ledger.ts
|
|
37254
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync2, readFileSync as
|
|
37255
|
-
import { join as
|
|
37296
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync2, readFileSync as readFileSync12, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
|
|
37297
|
+
import { join as join12 } from "path";
|
|
37256
37298
|
function safeInboundId(inboundId) {
|
|
37257
37299
|
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
37258
37300
|
}
|
|
@@ -37261,7 +37303,7 @@ var defaultDeps = {
|
|
|
37261
37303
|
writeFile: (path, data) => writeFileSync8(path, data, "utf8"),
|
|
37262
37304
|
rename: (from, to) => renameSync5(from, to),
|
|
37263
37305
|
readdir: (dir) => readdirSync2(dir),
|
|
37264
|
-
readFile: (path) =>
|
|
37306
|
+
readFile: (path) => readFileSync12(path, "utf8"),
|
|
37265
37307
|
exists: (path) => existsSync7(path)
|
|
37266
37308
|
};
|
|
37267
37309
|
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
@@ -37270,7 +37312,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
|
37270
37312
|
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
|
|
37271
37313
|
try {
|
|
37272
37314
|
deps.mkdir(dir);
|
|
37273
|
-
const final =
|
|
37315
|
+
const final = join12(dir, `${safe}.json`);
|
|
37274
37316
|
const tmp = `${final}.tmp`;
|
|
37275
37317
|
deps.writeFile(tmp, JSON.stringify(record2));
|
|
37276
37318
|
deps.rename(tmp, final);
|
|
@@ -37475,14 +37517,14 @@ function createKanbanCardActiveClient(args) {
|
|
|
37475
37517
|
import {
|
|
37476
37518
|
existsSync as existsSync8,
|
|
37477
37519
|
mkdirSync as mkdirSync8,
|
|
37478
|
-
readFileSync as
|
|
37520
|
+
readFileSync as readFileSync13,
|
|
37479
37521
|
renameSync as renameSync6,
|
|
37480
37522
|
statSync as statSync2,
|
|
37481
37523
|
unlinkSync as unlinkSync7,
|
|
37482
37524
|
utimesSync,
|
|
37483
37525
|
writeFileSync as writeFileSync9
|
|
37484
37526
|
} from "fs";
|
|
37485
|
-
import { join as
|
|
37527
|
+
import { join as join13 } from "path";
|
|
37486
37528
|
var STALE_LOCK_MS = 9e4;
|
|
37487
37529
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
37488
37530
|
function defaultIsPidAlive(pid) {
|
|
@@ -37505,7 +37547,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
37505
37547
|
const nowMs = options.nowMs ?? (() => Date.now());
|
|
37506
37548
|
const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
|
|
37507
37549
|
const staleMs = options.staleMs ?? STALE_LOCK_MS;
|
|
37508
|
-
const path =
|
|
37550
|
+
const path = join13(agentDir, basename2);
|
|
37509
37551
|
const existing = readLockHolder(path);
|
|
37510
37552
|
if (existing) {
|
|
37511
37553
|
if (existing.pid === selfPid) {
|
|
@@ -37572,7 +37614,7 @@ function defaultLockMtimeMs(path) {
|
|
|
37572
37614
|
function readLockHolder(path) {
|
|
37573
37615
|
if (!existsSync8(path)) return null;
|
|
37574
37616
|
try {
|
|
37575
|
-
const raw =
|
|
37617
|
+
const raw = readFileSync13(path, "utf8");
|
|
37576
37618
|
const parsed = JSON.parse(raw);
|
|
37577
37619
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
37578
37620
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -37584,8 +37626,8 @@ function readLockHolder(path) {
|
|
|
37584
37626
|
}
|
|
37585
37627
|
|
|
37586
37628
|
// src/ack-reaction.ts
|
|
37587
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
37588
|
-
import { join as
|
|
37629
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync14, writeFileSync as writeFileSync10 } from "fs";
|
|
37630
|
+
import { join as join14 } from "path";
|
|
37589
37631
|
var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
|
|
37590
37632
|
var ACK_STARTUP_GRACE_MS = 6e4;
|
|
37591
37633
|
var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
|
|
@@ -37658,7 +37700,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
|
37658
37700
|
function readGiveUpSignal(path, now = Date.now()) {
|
|
37659
37701
|
if (!path) return null;
|
|
37660
37702
|
try {
|
|
37661
|
-
const raw = JSON.parse(
|
|
37703
|
+
const raw = JSON.parse(readFileSync14(path, "utf8"));
|
|
37662
37704
|
if (typeof raw.gave_up_at !== "string") return null;
|
|
37663
37705
|
const t = Date.parse(raw.gave_up_at);
|
|
37664
37706
|
if (!Number.isFinite(t) || t > now) return null;
|
|
@@ -37693,7 +37735,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
|
|
|
37693
37735
|
if (!name.endsWith(".json")) continue;
|
|
37694
37736
|
let receivedAt;
|
|
37695
37737
|
try {
|
|
37696
|
-
const raw = JSON.parse(
|
|
37738
|
+
const raw = JSON.parse(readFileSync14(join14(dir, name), "utf-8"));
|
|
37697
37739
|
if (raw.discretionary === true) continue;
|
|
37698
37740
|
if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
|
|
37699
37741
|
receivedAt = raw.received_at;
|
|
@@ -37761,14 +37803,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
|
|
|
37761
37803
|
}
|
|
37762
37804
|
var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
|
|
37763
37805
|
function deflectionCounterPath(agentDir, channel) {
|
|
37764
|
-
return
|
|
37806
|
+
return join14(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
|
|
37765
37807
|
}
|
|
37766
37808
|
function recordChannelDeflection(agentDir, channel, cause) {
|
|
37767
37809
|
if (!agentDir) return;
|
|
37768
37810
|
const path = deflectionCounterPath(agentDir, channel);
|
|
37769
37811
|
let counts = {};
|
|
37770
37812
|
try {
|
|
37771
|
-
const parsed = JSON.parse(
|
|
37813
|
+
const parsed = JSON.parse(readFileSync14(path, "utf-8"));
|
|
37772
37814
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
37773
37815
|
} catch {
|
|
37774
37816
|
}
|
|
@@ -37849,7 +37891,7 @@ function redactId(id) {
|
|
|
37849
37891
|
}
|
|
37850
37892
|
var BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
|
|
37851
37893
|
var AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME ?? "unknown";
|
|
37852
|
-
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
37894
|
+
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join15(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
|
|
37853
37895
|
var AGT_HOST = process.env.AGT_HOST ?? null;
|
|
37854
37896
|
var AGT_API_KEY = process.env.AGT_API_KEY ?? null;
|
|
37855
37897
|
var AGT_AGENT_ID = process.env.AGT_AGENT_ID ?? null;
|
|
@@ -37959,9 +38001,9 @@ if (!BOT_TOKEN) {
|
|
|
37959
38001
|
var stderrLogStream = null;
|
|
37960
38002
|
if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
|
|
37961
38003
|
try {
|
|
37962
|
-
const logDir =
|
|
38004
|
+
const logDir = join15(homedir6(), ".augmented", AGENT_CODE_NAME);
|
|
37963
38005
|
mkdirSync9(logDir, { recursive: true });
|
|
37964
|
-
stderrLogStream = createWriteStream(
|
|
38006
|
+
stderrLogStream = createWriteStream(join15(logDir, "telegram-channel-stderr.log"), {
|
|
37965
38007
|
flags: "a",
|
|
37966
38008
|
mode: 384
|
|
37967
38009
|
});
|
|
@@ -38146,6 +38188,48 @@ async function maybeSendTelegramUsageLimitNotice(args) {
|
|
|
38146
38188
|
);
|
|
38147
38189
|
}
|
|
38148
38190
|
}
|
|
38191
|
+
var TELEGRAM_ACCOUNT_MUTE_NOTICE_CACHE = /* @__PURE__ */ new Map();
|
|
38192
|
+
async function maybeSendTelegramAccountMuteNotice(args) {
|
|
38193
|
+
if (args.senderId === void 0) return;
|
|
38194
|
+
const key2 = `${args.chatId}|${args.senderId}|account_mute`;
|
|
38195
|
+
const decision = decideDeclineReply({
|
|
38196
|
+
cache: TELEGRAM_ACCOUNT_MUTE_NOTICE_CACHE,
|
|
38197
|
+
key: key2,
|
|
38198
|
+
cooldownMs: TELEGRAM_MAINTENANCE_COOLDOWN_MS,
|
|
38199
|
+
now: Date.now()
|
|
38200
|
+
});
|
|
38201
|
+
if (!decision.reply) {
|
|
38202
|
+
process.stderr.write(
|
|
38203
|
+
`telegram-channel(${AGENT_CODE_NAME}): account-mute notice suppressed by cooldown (chat=${redactId(String(args.chatId))}, remaining=${decision.remainingMs}ms)
|
|
38204
|
+
`
|
|
38205
|
+
);
|
|
38206
|
+
return;
|
|
38207
|
+
}
|
|
38208
|
+
try {
|
|
38209
|
+
const resp = await telegramApiCall(
|
|
38210
|
+
"sendMessage",
|
|
38211
|
+
{
|
|
38212
|
+
chat_id: args.chatId,
|
|
38213
|
+
text: buildAccountIssueReplyText(),
|
|
38214
|
+
...args.messageThreadId != null ? { message_thread_id: args.messageThreadId } : {}
|
|
38215
|
+
},
|
|
38216
|
+
1e4
|
|
38217
|
+
);
|
|
38218
|
+
if (!resp.ok) {
|
|
38219
|
+
TELEGRAM_ACCOUNT_MUTE_NOTICE_CACHE.delete(key2);
|
|
38220
|
+
process.stderr.write(
|
|
38221
|
+
`telegram-channel(${AGENT_CODE_NAME}): account-mute notice rejected (chat=${redactId(String(args.chatId))}): ${resp.description ?? "unknown"}
|
|
38222
|
+
`
|
|
38223
|
+
);
|
|
38224
|
+
}
|
|
38225
|
+
} catch (err) {
|
|
38226
|
+
TELEGRAM_ACCOUNT_MUTE_NOTICE_CACHE.delete(key2);
|
|
38227
|
+
process.stderr.write(
|
|
38228
|
+
`telegram-channel(${AGENT_CODE_NAME}): account-mute notice failed: ${err.message}
|
|
38229
|
+
`
|
|
38230
|
+
);
|
|
38231
|
+
}
|
|
38232
|
+
}
|
|
38149
38233
|
var ACK_EMOJI = (process.env.TELEGRAM_ACK_REACTION ?? "").trim() || "\u{1F440}";
|
|
38150
38234
|
var TELEGRAM_SKIP_REACTION = (process.env.TELEGRAM_SKIP_REACTION ?? "").trim();
|
|
38151
38235
|
async function setMessageReaction(chatId, messageId, emoji2) {
|
|
@@ -38282,7 +38366,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
38282
38366
|
let paneLogFreshAgeMs = null;
|
|
38283
38367
|
if (AGENT_DIR) {
|
|
38284
38368
|
try {
|
|
38285
|
-
const paneMtimeMs = statSync3(
|
|
38369
|
+
const paneMtimeMs = statSync3(join15(AGENT_DIR, "pane.log")).mtimeMs;
|
|
38286
38370
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
38287
38371
|
} catch {
|
|
38288
38372
|
}
|
|
@@ -38312,7 +38396,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
38312
38396
|
function __resetBusyAckNoticeThrottle() {
|
|
38313
38397
|
lastBusyAckNoticeAt.clear();
|
|
38314
38398
|
}
|
|
38315
|
-
var RESTART_FLAGS_DIR =
|
|
38399
|
+
var RESTART_FLAGS_DIR = join15(homedir6(), ".augmented", "restart-flags");
|
|
38316
38400
|
function actuateHostRestartTelegram() {
|
|
38317
38401
|
return actuateHostRestart({
|
|
38318
38402
|
agtHost: AGT_HOST,
|
|
@@ -38697,7 +38781,7 @@ async function handleRestartCommand(opts) {
|
|
|
38697
38781
|
if (!existsSync9(RESTART_FLAGS_DIR)) {
|
|
38698
38782
|
mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
|
|
38699
38783
|
}
|
|
38700
|
-
const flagPath =
|
|
38784
|
+
const flagPath = join15(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
|
|
38701
38785
|
const flag = {
|
|
38702
38786
|
codeName: AGENT_CODE_NAME,
|
|
38703
38787
|
source: "telegram",
|
|
@@ -39103,16 +39187,16 @@ async function classifyRestartCommand(text) {
|
|
|
39103
39187
|
if (!ours) return "verification_failed";
|
|
39104
39188
|
return target === ours ? "act" : "ignore";
|
|
39105
39189
|
}
|
|
39106
|
-
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
39107
|
-
var PENDING_INBOUND_DIR = AGENT_DIR ?
|
|
39108
|
-
var RECOVERY_OUTBOX_DIR = AGENT_DIR ?
|
|
39109
|
-
var RECOVERY_LEDGER_DIR = AGENT_DIR ?
|
|
39110
|
-
var DELIVERY_LEDGER_DIR = AGENT_DIR ?
|
|
39111
|
-
var RESTART_CONFIRM_FILE = AGENT_DIR ?
|
|
39190
|
+
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join15(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
|
|
39191
|
+
var PENDING_INBOUND_DIR = AGENT_DIR ? join15(AGENT_DIR, "telegram-pending-inbound") : null;
|
|
39192
|
+
var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join15(AGENT_DIR, "telegram-recovery-outbox") : null;
|
|
39193
|
+
var RECOVERY_LEDGER_DIR = AGENT_DIR ? join15(AGENT_DIR, ".agt-telegram-recovery-ledger") : null;
|
|
39194
|
+
var DELIVERY_LEDGER_DIR = AGENT_DIR ? join15(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
|
|
39195
|
+
var RESTART_CONFIRM_FILE = AGENT_DIR ? join15(AGENT_DIR, "telegram-restart-confirm.json") : null;
|
|
39112
39196
|
var TELEGRAM_PROCESS_BOOT_MS = Date.now();
|
|
39113
|
-
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ?
|
|
39114
|
-
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ?
|
|
39115
|
-
var TELEGRAM_OFFSET_FILE = AGENT_DIR ?
|
|
39197
|
+
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join15(AGENT_DIR, "telegram-recent-dms.json") : null;
|
|
39198
|
+
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join15(AGENT_DIR, "telegram-channel-add-restart.json") : null;
|
|
39199
|
+
var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join15(AGENT_DIR, "telegram-getupdates-offset.json") : null;
|
|
39116
39200
|
var recentDms = /* @__PURE__ */ new Map();
|
|
39117
39201
|
var recentDmPersister = TELEGRAM_RECENT_DMS_FILE ? createRecentDmPersister({
|
|
39118
39202
|
filePath: TELEGRAM_RECENT_DMS_FILE,
|
|
@@ -39167,7 +39251,7 @@ function safeMarkerName(chatId, messageId) {
|
|
|
39167
39251
|
}
|
|
39168
39252
|
function pendingInboundPath(chatId, messageId) {
|
|
39169
39253
|
if (!PENDING_INBOUND_DIR) return null;
|
|
39170
|
-
return
|
|
39254
|
+
return join15(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
|
|
39171
39255
|
}
|
|
39172
39256
|
function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false, payload) {
|
|
39173
39257
|
const path = pendingInboundPath(chatId, messageId);
|
|
@@ -39215,7 +39299,7 @@ function rewriteTelegramMarkerInPlace(path, marker) {
|
|
|
39215
39299
|
function clearTelegramMarkerFileWithHeal(fullPath) {
|
|
39216
39300
|
let marker = null;
|
|
39217
39301
|
try {
|
|
39218
|
-
marker = JSON.parse(
|
|
39302
|
+
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
39219
39303
|
} catch {
|
|
39220
39304
|
}
|
|
39221
39305
|
if (marker && decideRecoveryHeal({
|
|
@@ -39232,7 +39316,7 @@ function clearTelegramMarkerFileWithHeal(fullPath) {
|
|
|
39232
39316
|
function markTelegramMarkerSeenInPlace(fullPath) {
|
|
39233
39317
|
let marker;
|
|
39234
39318
|
try {
|
|
39235
|
-
marker = JSON.parse(
|
|
39319
|
+
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
39236
39320
|
} catch {
|
|
39237
39321
|
return;
|
|
39238
39322
|
}
|
|
@@ -39244,7 +39328,7 @@ function markTelegramMarkerSeenInPlace(fullPath) {
|
|
|
39244
39328
|
function markTelegramMarkerSeenWithHeal(fullPath) {
|
|
39245
39329
|
let marker = null;
|
|
39246
39330
|
try {
|
|
39247
|
-
marker = JSON.parse(
|
|
39331
|
+
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
39248
39332
|
} catch {
|
|
39249
39333
|
return;
|
|
39250
39334
|
}
|
|
@@ -39260,7 +39344,7 @@ function readPendingInboundMarker(chatId, messageId) {
|
|
|
39260
39344
|
const path = pendingInboundPath(chatId, messageId);
|
|
39261
39345
|
if (!path || !existsSync9(path)) return null;
|
|
39262
39346
|
try {
|
|
39263
|
-
return JSON.parse(
|
|
39347
|
+
return JSON.parse(readFileSync15(path, "utf-8"));
|
|
39264
39348
|
} catch {
|
|
39265
39349
|
return null;
|
|
39266
39350
|
}
|
|
@@ -39280,10 +39364,10 @@ function nextRetryName(filename) {
|
|
|
39280
39364
|
async function processRecoveryOutboxFile(filename) {
|
|
39281
39365
|
if (!RECOVERY_OUTBOX_DIR) return;
|
|
39282
39366
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
39283
|
-
const fullPath =
|
|
39367
|
+
const fullPath = join15(RECOVERY_OUTBOX_DIR, filename);
|
|
39284
39368
|
let payload;
|
|
39285
39369
|
try {
|
|
39286
|
-
const raw =
|
|
39370
|
+
const raw = readFileSync15(fullPath, "utf-8");
|
|
39287
39371
|
payload = JSON.parse(raw);
|
|
39288
39372
|
} catch (err) {
|
|
39289
39373
|
process.stderr.write(
|
|
@@ -39377,7 +39461,7 @@ async function processRecoveryOutboxFile(filename) {
|
|
|
39377
39461
|
const next = nextRetryName(filename);
|
|
39378
39462
|
if (next) {
|
|
39379
39463
|
try {
|
|
39380
|
-
renameSync7(fullPath,
|
|
39464
|
+
renameSync7(fullPath, join15(RECOVERY_OUTBOX_DIR, next.next));
|
|
39381
39465
|
if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
|
|
39382
39466
|
process.stderr.write(
|
|
39383
39467
|
`telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -39418,7 +39502,7 @@ function scanRecoveryRetries() {
|
|
|
39418
39502
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
39419
39503
|
let mtimeMs;
|
|
39420
39504
|
try {
|
|
39421
|
-
mtimeMs = statSync3(
|
|
39505
|
+
mtimeMs = statSync3(join15(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
39422
39506
|
} catch {
|
|
39423
39507
|
continue;
|
|
39424
39508
|
}
|
|
@@ -39448,7 +39532,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
39448
39532
|
const watcher = watch(RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
39449
39533
|
if (event !== "rename" || !filename) return;
|
|
39450
39534
|
if (!isFirstAttemptOutboxFile(filename)) return;
|
|
39451
|
-
if (existsSync9(
|
|
39535
|
+
if (existsSync9(join15(RECOVERY_OUTBOX_DIR, filename))) {
|
|
39452
39536
|
void processRecoveryOutboxFile(filename);
|
|
39453
39537
|
}
|
|
39454
39538
|
});
|
|
@@ -39463,7 +39547,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
39463
39547
|
retryTimer.unref?.();
|
|
39464
39548
|
}
|
|
39465
39549
|
startRecoveryOutboxWatcher();
|
|
39466
|
-
var NOTICE_OUTBOX_DIR = AGENT_DIR ?
|
|
39550
|
+
var NOTICE_OUTBOX_DIR = AGENT_DIR ? join15(AGENT_DIR, "telegram-notice-outbox") : null;
|
|
39467
39551
|
var NOTICE_MAX_AGE_MS = 9e4;
|
|
39468
39552
|
var NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
|
|
39469
39553
|
async function processNoticeOutboxFile(filename) {
|
|
@@ -39471,7 +39555,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
39471
39555
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
39472
39556
|
if (NOTICE_INFLIGHT.has(filename)) return;
|
|
39473
39557
|
NOTICE_INFLIGHT.add(filename);
|
|
39474
|
-
const fullPath =
|
|
39558
|
+
const fullPath = join15(NOTICE_OUTBOX_DIR, filename);
|
|
39475
39559
|
try {
|
|
39476
39560
|
let mtimeMs;
|
|
39477
39561
|
try {
|
|
@@ -39488,7 +39572,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
39488
39572
|
}
|
|
39489
39573
|
let payload;
|
|
39490
39574
|
try {
|
|
39491
|
-
const parsed = JSON.parse(
|
|
39575
|
+
const parsed = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
39492
39576
|
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
39493
39577
|
payload = parsed;
|
|
39494
39578
|
} catch {
|
|
@@ -39565,7 +39649,7 @@ function startNoticeOutboxWatcher() {
|
|
|
39565
39649
|
try {
|
|
39566
39650
|
const watcher = watch(NOTICE_OUTBOX_DIR, (event, filename) => {
|
|
39567
39651
|
if (event !== "rename" || !filename) return;
|
|
39568
|
-
if (existsSync9(
|
|
39652
|
+
if (existsSync9(join15(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
|
|
39569
39653
|
});
|
|
39570
39654
|
watcher.unref?.();
|
|
39571
39655
|
} catch (err) {
|
|
@@ -39598,10 +39682,10 @@ function sweepTelegramStaleMarkers(thresholdMs) {
|
|
|
39598
39682
|
for (const filename of filenames) {
|
|
39599
39683
|
if (!filename.endsWith(".json")) continue;
|
|
39600
39684
|
if (filename.endsWith(".tmp")) continue;
|
|
39601
|
-
const fullPath =
|
|
39685
|
+
const fullPath = join15(PENDING_INBOUND_DIR, filename);
|
|
39602
39686
|
let marker;
|
|
39603
39687
|
try {
|
|
39604
|
-
marker = JSON.parse(
|
|
39688
|
+
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
39605
39689
|
} catch (err) {
|
|
39606
39690
|
process.stderr.write(
|
|
39607
39691
|
`telegram-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactId(filename)}: ${err.message}
|
|
@@ -39647,13 +39731,13 @@ var orphanSweepTimer = setInterval(() => {
|
|
|
39647
39731
|
checkWatchdogGiveUpNotice();
|
|
39648
39732
|
}, orphanSweepIntervalMs());
|
|
39649
39733
|
orphanSweepTimer.unref?.();
|
|
39650
|
-
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ?
|
|
39734
|
+
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join15(AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
39651
39735
|
var telegramTrackedProgress = null;
|
|
39652
39736
|
var telegramProgressTickRunning = false;
|
|
39653
39737
|
function readTelegramProgressHeartbeat() {
|
|
39654
39738
|
if (!TELEGRAM_PROGRESS_HEARTBEAT_PATH || !existsSync9(TELEGRAM_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
39655
39739
|
try {
|
|
39656
|
-
return parseProgressHeartbeat(
|
|
39740
|
+
return parseProgressHeartbeat(readFileSync15(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
39657
39741
|
} catch {
|
|
39658
39742
|
return null;
|
|
39659
39743
|
}
|
|
@@ -39680,7 +39764,7 @@ function findTelegramProgressTarget() {
|
|
|
39680
39764
|
if (!name.endsWith(".json")) continue;
|
|
39681
39765
|
let m;
|
|
39682
39766
|
try {
|
|
39683
|
-
m = JSON.parse(
|
|
39767
|
+
m = JSON.parse(readFileSync15(join15(PENDING_INBOUND_DIR, name), "utf-8"));
|
|
39684
39768
|
} catch {
|
|
39685
39769
|
continue;
|
|
39686
39770
|
}
|
|
@@ -39811,7 +39895,7 @@ function listPendingInboundChatIds() {
|
|
|
39811
39895
|
if (!name.endsWith(".json")) continue;
|
|
39812
39896
|
try {
|
|
39813
39897
|
const marker = JSON.parse(
|
|
39814
|
-
|
|
39898
|
+
readFileSync15(join15(PENDING_INBOUND_DIR, name), "utf8")
|
|
39815
39899
|
);
|
|
39816
39900
|
if (typeof marker.seen_at === "string" && marker.seen_at) continue;
|
|
39817
39901
|
if (typeof marker.chat_id === "string" && marker.chat_id) chats.add(marker.chat_id);
|
|
@@ -39853,7 +39937,7 @@ async function notifyWatchdogGiveUp(chatId, reason) {
|
|
|
39853
39937
|
}
|
|
39854
39938
|
function checkWatchdogGiveUpNotice() {
|
|
39855
39939
|
if (!AGENT_DIR) return;
|
|
39856
|
-
const signal = readGiveUpSignal(
|
|
39940
|
+
const signal = readGiveUpSignal(join15(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
39857
39941
|
const signalAtMs = signal?.atMs ?? null;
|
|
39858
39942
|
const act = decideGiveUpNotice({
|
|
39859
39943
|
signalAtMs,
|
|
@@ -40132,7 +40216,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
40132
40216
|
isError: true
|
|
40133
40217
|
};
|
|
40134
40218
|
}
|
|
40135
|
-
const allowedRoot = resolve2(
|
|
40219
|
+
const allowedRoot = resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project") + "/";
|
|
40136
40220
|
const resolvedPath = resolve2(path);
|
|
40137
40221
|
if (!resolvedPath.startsWith(allowedRoot)) {
|
|
40138
40222
|
return {
|
|
@@ -40180,7 +40264,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
40180
40264
|
}
|
|
40181
40265
|
let realRoot = allowedRoot;
|
|
40182
40266
|
try {
|
|
40183
|
-
realRoot = realpathSync(resolve2(
|
|
40267
|
+
realRoot = realpathSync(resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project")) + "/";
|
|
40184
40268
|
} catch {
|
|
40185
40269
|
}
|
|
40186
40270
|
if (!realPath.startsWith(realRoot)) {
|
|
@@ -40209,7 +40293,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
40209
40293
|
isError: true
|
|
40210
40294
|
};
|
|
40211
40295
|
}
|
|
40212
|
-
bytes =
|
|
40296
|
+
bytes = readFileSync15(realPath);
|
|
40213
40297
|
} catch (err) {
|
|
40214
40298
|
return { content: [{ type: "text", text: `Failed to read file: ${err.message}` }], isError: true };
|
|
40215
40299
|
}
|
|
@@ -40770,7 +40854,7 @@ async function replayPendingTelegramMarkers() {
|
|
|
40770
40854
|
let paneFreshAgeMs = null;
|
|
40771
40855
|
if (AGENT_DIR) {
|
|
40772
40856
|
try {
|
|
40773
|
-
paneFreshAgeMs = Math.max(0, now - statSync3(
|
|
40857
|
+
paneFreshAgeMs = Math.max(0, now - statSync3(join15(AGENT_DIR, "pane.log")).mtimeMs);
|
|
40774
40858
|
} catch {
|
|
40775
40859
|
}
|
|
40776
40860
|
}
|
|
@@ -40778,10 +40862,10 @@ async function replayPendingTelegramMarkers() {
|
|
|
40778
40862
|
const entries = [];
|
|
40779
40863
|
for (const name of filenames) {
|
|
40780
40864
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
40781
|
-
const fullPath =
|
|
40865
|
+
const fullPath = join15(PENDING_INBOUND_DIR, name);
|
|
40782
40866
|
let marker;
|
|
40783
40867
|
try {
|
|
40784
|
-
marker = JSON.parse(
|
|
40868
|
+
marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
|
|
40785
40869
|
} catch {
|
|
40786
40870
|
continue;
|
|
40787
40871
|
}
|
|
@@ -41252,6 +41336,18 @@ async function pollLoop() {
|
|
|
41252
41336
|
});
|
|
41253
41337
|
continue;
|
|
41254
41338
|
}
|
|
41339
|
+
if (!isFromBot && readAccountEnforcementLevel({ codeName: AGENT_CODE_NAME }) === "mute") {
|
|
41340
|
+
process.stderr.write(
|
|
41341
|
+
`telegram-channel(${AGENT_CODE_NAME}): account muted \u2014 notice, no dispatch (chat=${redactId(chatId)})
|
|
41342
|
+
`
|
|
41343
|
+
);
|
|
41344
|
+
await maybeSendTelegramAccountMuteNotice({
|
|
41345
|
+
chatId,
|
|
41346
|
+
senderId: userId,
|
|
41347
|
+
messageThreadId: msg.message_thread_id
|
|
41348
|
+
});
|
|
41349
|
+
continue;
|
|
41350
|
+
}
|
|
41255
41351
|
const telegramUsageLimitUntil = !isFromBot ? readUsageLimitUntil({ codeName: AGENT_CODE_NAME }) : null;
|
|
41256
41352
|
if (telegramUsageLimitUntil) {
|
|
41257
41353
|
process.stderr.write(
|
|
@@ -41316,7 +41412,7 @@ async function pollLoop() {
|
|
|
41316
41412
|
let paneLogFreshAgeMs = null;
|
|
41317
41413
|
if (AGENT_DIR) {
|
|
41318
41414
|
try {
|
|
41319
|
-
const paneMtimeMs = statSync3(
|
|
41415
|
+
const paneMtimeMs = statSync3(join15(AGENT_DIR, "pane.log")).mtimeMs;
|
|
41320
41416
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
41321
41417
|
} catch {
|
|
41322
41418
|
}
|