@integrity-labs/agt-cli 0.28.423 → 0.28.425

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.
@@ -18870,7 +18870,7 @@ var require_filters = __commonJS({
18870
18870
  return r.copySafeness(str, res);
18871
18871
  }
18872
18872
  _exports.indent = indent;
18873
- function join14(arr, del, attr) {
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 = join14;
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 readFileSync13,
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 unlinkSync7,
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 join13, resolve as resolve2 } from "path";
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";
@@ -33771,6 +33771,86 @@ var INTEGRATION_REGISTRY = [
33771
33771
  ]
33772
33772
  }
33773
33773
  },
33774
+ {
33775
+ // Social Scraping: a PREMIUM, platform-managed integration on the Deck /
33776
+ // Firecrawl / X-Search model (ADR-0031, epic ENG-6920; ADR-0053). Backed by
33777
+ // Apify, but deliberately NOT surfaced as an "Apify" integration - the
33778
+ // integration is what a customer picks, and Apify is a vendor, not a job.
33779
+ // Splitting by job also means opt-in, rate card and monthly budget are keyed
33780
+ // per definition, so an org can take Local Business Data without taking the
33781
+ // pricier, more ToS-sensitive social scraping.
33782
+ //
33783
+ // Augmented holds ONE Apify account whose token (APIFY_API_TOKEN, read
33784
+ // from SSM - the API Lambda env is at the 4KB cap) every customer run bills
33785
+ // back to, so the key is a single platform-held secret, NOT a per-agent
33786
+ // credential. Auth type is `none` - customers never enter a key. Tools run on
33787
+ // a brokered-REST lane (apify-brokers.ts) so each run is metered at one
33788
+ // chokepoint and gated on a per-org monthly USD cap + the per-org premium
33789
+ // opt-in.
33790
+ //
33791
+ // "PPE-only" is guaranteed by a curated allowlist: the broker only ever runs
33792
+ // Actors on it, so a rental / pay-per-usage Actor can never surprise-bill the
33793
+ // shared account. (Apify's x402 rail enforces PPE-only at the payment layer;
33794
+ // we are on the account-key rail - Option A in the spike.) See
33795
+ // docs/design/apify-premium-option-a-ppe-allowlist.md.
33796
+ //
33797
+ // No `installable` here on purpose: this is a seed integration
33798
+ // (integration-definitions.json), so the seed catalog already makes it
33799
+ // picker-visible. This registry entry exists ONLY to carry the `premium`
33800
+ // descriptor that `isPremiumDefinition` reads - which arms the per-org opt-in
33801
+ // gate, the priced acknowledgement modal, and the admin pricing tab.
33802
+ id: "social-scraping",
33803
+ name: "Social Scraping",
33804
+ category: "social",
33805
+ description: "Pull public posts and videos from TikTok, Instagram and YouTube - captions, media, engagement counts and URLs - for brand, competitor and campaign research. Augmented Team manages the scraping account for you; there is no key to enter.",
33806
+ supported_auth_types: ["none"],
33807
+ capabilities: [
33808
+ { id: "social-scraping:scrape", name: "Scrape Social Posts", description: "Scrape public TikTok, Instagram and YouTube content (social_scrape_tiktok, social_scrape_instagram, social_scrape_youtube).", access: "write" },
33809
+ { id: "social-scraping:status", name: "Check Scrape Runs", description: "Poll a running scrape for status + results (social_scrape_status).", access: "read" }
33810
+ ],
33811
+ docs_url: "https://docs.apify.com/api/v2",
33812
+ beta: true,
33813
+ // Premium (billable). The upstream pay-per-event cost is per-Actor and
33814
+ // VARIABLE (each Actor's creator sets its own event prices), unlike X-Search's
33815
+ // fixed per-post price. So we meter the ACTUAL cost charged to us for each
33816
+ // run, as a pass-through: `units` = the run's `usageTotalUsd` in whole US
33817
+ // cents (the physical unit `usd_cent`), and the rate card prices each cent at
33818
+ // a managed markup (1.5x USD). This keeps margin safe across cheap and
33819
+ // expensive scrapes alike. `event_type` must match what the broker writes to
33820
+ // integration_usage_events. Until the rate row is seeded a run prices at 0
33821
+ // (budget gate inert) - the rate-card migration ships in the same PR.
33822
+ premium: {
33823
+ pricing: "usage",
33824
+ note: "Billed per result on the upstream pay-per-event cost of each scrape, at a managed markup.",
33825
+ meters: [{ event_type: "actor_run", unit: "usd_cent" }]
33826
+ }
33827
+ },
33828
+ {
33829
+ // Local Business Data: the second Apify-backed premium integration (ADR-0053).
33830
+ // Same platform-held account, same pass-through metering model, but a separate
33831
+ // definition so its opt-in, rate card and monthly budget are independent of
33832
+ // Social Scraping's - see the note on that entry for why the split exists.
33833
+ //
33834
+ // Distinct from Firecrawl on purpose: Firecrawl covers generic web
33835
+ // scrape/crawl/search, and we deliberately do NOT ship an Apify-backed
33836
+ // duplicate of that. This is the local-places job Firecrawl does not do.
33837
+ id: "local-business-data",
33838
+ name: "Local Business Data",
33839
+ category: "knowledge",
33840
+ description: "Find local businesses on Google Maps and pull their public listing details - name, address, phone, website, category, rating and review count - for local market research, competitor lists and lead research. Augmented Team manages the data account for you; there is no key to enter.",
33841
+ supported_auth_types: ["none"],
33842
+ capabilities: [
33843
+ { id: "local-business-data:search", name: "Search Local Businesses", description: "Search Google Maps for businesses and return their public listing details (local_business_search).", access: "write" },
33844
+ { id: "local-business-data:status", name: "Check Searches", description: "Poll a running search for status + results (local_business_search_status).", access: "read" }
33845
+ ],
33846
+ docs_url: "https://docs.apify.com/api/v2",
33847
+ beta: true,
33848
+ premium: {
33849
+ pricing: "usage",
33850
+ note: "Billed per place returned on the upstream pay-per-event cost of each search, at a managed markup.",
33851
+ meters: [{ event_type: "actor_run", unit: "usd_cent" }]
33852
+ }
33853
+ },
33774
33854
  {
33775
33855
  // Seed-catalog toolkit (composed by the ultimate-app-coder bundle). Registered
33776
33856
  // here only so the manager's ensureToolkitCli installs the binary via the
@@ -35303,6 +35383,19 @@ function writeTurnInitiatorMarker(input) {
35303
35383
  }
35304
35384
  }
35305
35385
 
35386
+ // src/scheduled-turn-marker.ts
35387
+ import { readFileSync as readFileSync6, unlinkSync as unlinkSync4 } from "fs";
35388
+ import { join as join5 } from "path";
35389
+ var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
35390
+ var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
35391
+ function clearScheduledTurnMarker(agentDir) {
35392
+ if (!agentDir) return;
35393
+ try {
35394
+ unlinkSync4(join5(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
35395
+ } catch {
35396
+ }
35397
+ }
35398
+
35306
35399
  // src/watch-command.ts
35307
35400
  var WATCH_DEFAULT_DURATION_MS = 2 * 60 * 60 * 1e3;
35308
35401
  var WATCH_MAX_DURATION_MS = 7 * 24 * 60 * 60 * 1e3;
@@ -35929,9 +36022,9 @@ function buildCommandRegistrations() {
35929
36022
  import {
35930
36023
  existsSync as existsSync3,
35931
36024
  mkdirSync as mkdirSync5,
35932
- readFileSync as readFileSync6,
36025
+ readFileSync as readFileSync7,
35933
36026
  renameSync as renameSync4,
35934
- unlinkSync as unlinkSync4,
36027
+ unlinkSync as unlinkSync5,
35935
36028
  writeFileSync as writeFileSync5
35936
36029
  } from "fs";
35937
36030
  import { randomUUID as randomUUID2 } from "crypto";
@@ -35939,7 +36032,7 @@ function loadPersistedOffset(filePath) {
35939
36032
  if (!filePath) return 0;
35940
36033
  try {
35941
36034
  const parsed = JSON.parse(
35942
- readFileSync6(filePath, "utf-8")
36035
+ readFileSync7(filePath, "utf-8")
35943
36036
  );
35944
36037
  const offset = parsed?.offset;
35945
36038
  if (typeof offset === "number" && Number.isFinite(offset) && offset > 0) {
@@ -35967,7 +36060,7 @@ function persistOffset(opts) {
35967
36060
  } catch (err) {
35968
36061
  onError?.(`getUpdates offset persist failed: ${err.message}`);
35969
36062
  try {
35970
- if (existsSync3(tmpPath)) unlinkSync4(tmpPath);
36063
+ if (existsSync3(tmpPath)) unlinkSync5(tmpPath);
35971
36064
  } catch {
35972
36065
  }
35973
36066
  }
@@ -35983,8 +36076,8 @@ function conversationalLaneMeta(expectsReply = true) {
35983
36076
  }
35984
36077
 
35985
36078
  // src/inbound-lane-telemetry.ts
35986
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
35987
- import { join as join5 } from "path";
36079
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
36080
+ import { join as join6 } from "path";
35988
36081
  var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
35989
36082
  var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
35990
36083
  var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
@@ -36001,10 +36094,10 @@ function isSuspectedMisclassification(lane, source) {
36001
36094
  }
36002
36095
  function recordLaneClassification(agentDir, channel, classification) {
36003
36096
  if (!agentDir) return;
36004
- const path = join5(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
36097
+ const path = join6(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
36005
36098
  let counts = {};
36006
36099
  try {
36007
- const parsed = JSON.parse(readFileSync7(path, "utf-8"));
36100
+ const parsed = JSON.parse(readFileSync8(path, "utf-8"));
36008
36101
  if (parsed && typeof parsed === "object") counts = parsed;
36009
36102
  } catch {
36010
36103
  }
@@ -36020,15 +36113,15 @@ function recordLaneClassification(agentDir, channel, classification) {
36020
36113
  }
36021
36114
 
36022
36115
  // src/agent-config-state.ts
36023
- import { existsSync as existsSync4, readFileSync as readFileSync8 } from "fs";
36024
- import { join as join6 } from "path";
36116
+ import { existsSync as existsSync4, readFileSync as readFileSync9 } from "fs";
36117
+ import { join as join7 } from "path";
36025
36118
  var SESSION_STATE_FILENAME = "session-state.json";
36026
36119
  function readAgentSessionState(stateDir) {
36027
36120
  if (!stateDir) return null;
36028
- const path = join6(stateDir, SESSION_STATE_FILENAME);
36121
+ const path = join7(stateDir, SESSION_STATE_FILENAME);
36029
36122
  if (!existsSync4(path)) return null;
36030
36123
  try {
36031
- const parsed = JSON.parse(readFileSync8(path, "utf-8"));
36124
+ const parsed = JSON.parse(readFileSync9(path, "utf-8"));
36032
36125
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
36033
36126
  return parsed;
36034
36127
  } catch {
@@ -36834,7 +36927,7 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
36834
36927
  import { execFile as execFile2 } from "child_process";
36835
36928
  import { existsSync as existsSync5, mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
36836
36929
  import { homedir as homedir4 } from "os";
36837
- import { join as join7 } from "path";
36930
+ import { join as join8 } from "path";
36838
36931
  var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
36839
36932
  var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
36840
36933
  var ANTHROPIC_API_VERSION = "2023-06-01";
@@ -36933,12 +37026,12 @@ async function runAnthropicMessages(prompt, opts) {
36933
37026
  var emptyMcpConfigPath = null;
36934
37027
  function ensureEmptyMcpConfig() {
36935
37028
  if (emptyMcpConfigPath && existsSync5(emptyMcpConfigPath)) return emptyMcpConfigPath;
36936
- const dir = join7(homedir4(), ".augmented");
37029
+ const dir = join8(homedir4(), ".augmented");
36937
37030
  try {
36938
37031
  mkdirSync6(dir, { recursive: true });
36939
37032
  } catch {
36940
37033
  }
36941
- const p2 = join7(dir, ".reply-intent-empty-mcp.json");
37034
+ const p2 = join8(dir, ".reply-intent-empty-mcp.json");
36942
37035
  writeFileSync7(p2, JSON.stringify({ mcpServers: {} }));
36943
37036
  emptyMcpConfigPath = p2;
36944
37037
  return p2;
@@ -37085,11 +37178,11 @@ function emitTransientApiErrorTelemetry(channel, match, original) {
37085
37178
  }
37086
37179
 
37087
37180
  // src/telegram-pending-inbound-cleanup.ts
37088
- import { readdirSync, readFileSync as readFileSync9, statSync } from "fs";
37089
- import { join as join8 } from "path";
37181
+ import { readdirSync, readFileSync as readFileSync10, statSync } from "fs";
37182
+ import { join as join9 } from "path";
37090
37183
  function markerArrivalMs(fullPath) {
37091
37184
  try {
37092
- const received = JSON.parse(readFileSync9(fullPath, "utf-8")).received_at;
37185
+ const received = JSON.parse(readFileSync10(fullPath, "utf-8")).received_at;
37093
37186
  const parsed = received ? Date.parse(received) : Number.NaN;
37094
37187
  if (Number.isFinite(parsed)) return parsed;
37095
37188
  } catch {
@@ -37119,7 +37212,7 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
37119
37212
  for (const filename of filenames) {
37120
37213
  if (!filename.startsWith(prefix)) continue;
37121
37214
  if (!filename.endsWith(".json")) continue;
37122
- const fullPath = join8(pendingDir, filename);
37215
+ const fullPath = join9(pendingDir, filename);
37123
37216
  if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
37124
37217
  op(fullPath);
37125
37218
  applied++;
@@ -37128,31 +37221,31 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
37128
37221
  }
37129
37222
 
37130
37223
  // src/recovery-ledger.ts
37131
- import { existsSync as existsSync6, unlinkSync as unlinkSync5 } from "fs";
37132
- import { join as join9 } from "path";
37224
+ import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
37225
+ import { join as join10 } from "path";
37133
37226
  function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p2) => existsSync6(p2)) {
37134
37227
  if (!ledgerDir || !markerName) return false;
37135
37228
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
37136
37229
  try {
37137
- return exists(join9(ledgerDir, markerName));
37230
+ return exists(join10(ledgerDir, markerName));
37138
37231
  } catch {
37139
37232
  return false;
37140
37233
  }
37141
37234
  }
37142
37235
  function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p2) => {
37143
- if (existsSync6(p2)) unlinkSync5(p2);
37236
+ if (existsSync6(p2)) unlinkSync6(p2);
37144
37237
  }) {
37145
37238
  if (!ledgerDir || !markerName) return;
37146
37239
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
37147
37240
  try {
37148
- unlink(join9(ledgerDir, markerName));
37241
+ unlink(join10(ledgerDir, markerName));
37149
37242
  } catch {
37150
37243
  }
37151
37244
  }
37152
37245
 
37153
37246
  // src/inbound-delivery-ledger.ts
37154
- import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync2, readFileSync as readFileSync10, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
37155
- import { join as join10 } from "path";
37247
+ import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync2, readFileSync as readFileSync11, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
37248
+ import { join as join11 } from "path";
37156
37249
  function safeInboundId(inboundId) {
37157
37250
  return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
37158
37251
  }
@@ -37161,7 +37254,7 @@ var defaultDeps = {
37161
37254
  writeFile: (path, data) => writeFileSync8(path, data, "utf8"),
37162
37255
  rename: (from, to) => renameSync5(from, to),
37163
37256
  readdir: (dir) => readdirSync2(dir),
37164
- readFile: (path) => readFileSync10(path, "utf8"),
37257
+ readFile: (path) => readFileSync11(path, "utf8"),
37165
37258
  exists: (path) => existsSync7(path)
37166
37259
  };
37167
37260
  function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
@@ -37170,7 +37263,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
37170
37263
  if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
37171
37264
  try {
37172
37265
  deps.mkdir(dir);
37173
- const final = join10(dir, `${safe}.json`);
37266
+ const final = join11(dir, `${safe}.json`);
37174
37267
  const tmp = `${final}.tmp`;
37175
37268
  deps.writeFile(tmp, JSON.stringify(record2));
37176
37269
  deps.rename(tmp, final);
@@ -37375,14 +37468,14 @@ function createKanbanCardActiveClient(args) {
37375
37468
  import {
37376
37469
  existsSync as existsSync8,
37377
37470
  mkdirSync as mkdirSync8,
37378
- readFileSync as readFileSync11,
37471
+ readFileSync as readFileSync12,
37379
37472
  renameSync as renameSync6,
37380
37473
  statSync as statSync2,
37381
- unlinkSync as unlinkSync6,
37474
+ unlinkSync as unlinkSync7,
37382
37475
  utimesSync,
37383
37476
  writeFileSync as writeFileSync9
37384
37477
  } from "fs";
37385
- import { join as join11 } from "path";
37478
+ import { join as join12 } from "path";
37386
37479
  var STALE_LOCK_MS = 9e4;
37387
37480
  var HEARTBEAT_INTERVAL_MS = 3e4;
37388
37481
  function defaultIsPidAlive(pid) {
@@ -37405,7 +37498,7 @@ function acquireMcpSpawnLock(args) {
37405
37498
  const nowMs = options.nowMs ?? (() => Date.now());
37406
37499
  const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
37407
37500
  const staleMs = options.staleMs ?? STALE_LOCK_MS;
37408
- const path = join11(agentDir, basename2);
37501
+ const path = join12(agentDir, basename2);
37409
37502
  const existing = readLockHolder(path);
37410
37503
  if (existing) {
37411
37504
  if (existing.pid === selfPid) {
@@ -37433,7 +37526,7 @@ function releaseMcpSpawnLock(lockPath, opts = {}) {
37433
37526
  if (!existing) return;
37434
37527
  if (existing.pid !== selfPid) return;
37435
37528
  try {
37436
- unlinkSync6(lockPath);
37529
+ unlinkSync7(lockPath);
37437
37530
  } catch {
37438
37531
  }
37439
37532
  }
@@ -37472,7 +37565,7 @@ function defaultLockMtimeMs(path) {
37472
37565
  function readLockHolder(path) {
37473
37566
  if (!existsSync8(path)) return null;
37474
37567
  try {
37475
- const raw = readFileSync11(path, "utf8");
37568
+ const raw = readFileSync12(path, "utf8");
37476
37569
  const parsed = JSON.parse(raw);
37477
37570
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
37478
37571
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -37484,8 +37577,8 @@ function readLockHolder(path) {
37484
37577
  }
37485
37578
 
37486
37579
  // src/ack-reaction.ts
37487
- import { readdirSync as readdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync10 } from "fs";
37488
- import { join as join12 } from "path";
37580
+ import { readdirSync as readdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
37581
+ import { join as join13 } from "path";
37489
37582
  var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
37490
37583
  var ACK_STARTUP_GRACE_MS = 6e4;
37491
37584
  var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
@@ -37558,7 +37651,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
37558
37651
  function readGiveUpSignal(path, now = Date.now()) {
37559
37652
  if (!path) return null;
37560
37653
  try {
37561
- const raw = JSON.parse(readFileSync12(path, "utf8"));
37654
+ const raw = JSON.parse(readFileSync13(path, "utf8"));
37562
37655
  if (typeof raw.gave_up_at !== "string") return null;
37563
37656
  const t = Date.parse(raw.gave_up_at);
37564
37657
  if (!Number.isFinite(t) || t > now) return null;
@@ -37593,7 +37686,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
37593
37686
  if (!name.endsWith(".json")) continue;
37594
37687
  let receivedAt;
37595
37688
  try {
37596
- const raw = JSON.parse(readFileSync12(join12(dir, name), "utf-8"));
37689
+ const raw = JSON.parse(readFileSync13(join13(dir, name), "utf-8"));
37597
37690
  if (raw.discretionary === true) continue;
37598
37691
  if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
37599
37692
  receivedAt = raw.received_at;
@@ -37661,14 +37754,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
37661
37754
  }
37662
37755
  var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
37663
37756
  function deflectionCounterPath(agentDir, channel) {
37664
- return join12(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
37757
+ return join13(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
37665
37758
  }
37666
37759
  function recordChannelDeflection(agentDir, channel, cause) {
37667
37760
  if (!agentDir) return;
37668
37761
  const path = deflectionCounterPath(agentDir, channel);
37669
37762
  let counts = {};
37670
37763
  try {
37671
- const parsed = JSON.parse(readFileSync12(path, "utf-8"));
37764
+ const parsed = JSON.parse(readFileSync13(path, "utf-8"));
37672
37765
  if (parsed && typeof parsed === "object") counts = parsed;
37673
37766
  } catch {
37674
37767
  }
@@ -37749,7 +37842,7 @@ function redactId(id) {
37749
37842
  }
37750
37843
  var BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
37751
37844
  var AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME ?? "unknown";
37752
- var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join13(homedir5(), ".augmented", AGENT_CODE_NAME) : null;
37845
+ var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join14(homedir5(), ".augmented", AGENT_CODE_NAME) : null;
37753
37846
  var AGT_HOST = process.env.AGT_HOST ?? null;
37754
37847
  var AGT_API_KEY = process.env.AGT_API_KEY ?? null;
37755
37848
  var AGT_AGENT_ID = process.env.AGT_AGENT_ID ?? null;
@@ -37859,9 +37952,9 @@ if (!BOT_TOKEN) {
37859
37952
  var stderrLogStream = null;
37860
37953
  if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
37861
37954
  try {
37862
- const logDir = join13(homedir5(), ".augmented", AGENT_CODE_NAME);
37955
+ const logDir = join14(homedir5(), ".augmented", AGENT_CODE_NAME);
37863
37956
  mkdirSync9(logDir, { recursive: true });
37864
- stderrLogStream = createWriteStream(join13(logDir, "telegram-channel-stderr.log"), {
37957
+ stderrLogStream = createWriteStream(join14(logDir, "telegram-channel-stderr.log"), {
37865
37958
  flags: "a",
37866
37959
  mode: 384
37867
37960
  });
@@ -38182,7 +38275,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
38182
38275
  let paneLogFreshAgeMs = null;
38183
38276
  if (AGENT_DIR) {
38184
38277
  try {
38185
- const paneMtimeMs = statSync3(join13(AGENT_DIR, "pane.log")).mtimeMs;
38278
+ const paneMtimeMs = statSync3(join14(AGENT_DIR, "pane.log")).mtimeMs;
38186
38279
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
38187
38280
  } catch {
38188
38281
  }
@@ -38212,7 +38305,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
38212
38305
  function __resetBusyAckNoticeThrottle() {
38213
38306
  lastBusyAckNoticeAt.clear();
38214
38307
  }
38215
- var RESTART_FLAGS_DIR = join13(homedir5(), ".augmented", "restart-flags");
38308
+ var RESTART_FLAGS_DIR = join14(homedir5(), ".augmented", "restart-flags");
38216
38309
  function actuateHostRestartTelegram() {
38217
38310
  return actuateHostRestart({
38218
38311
  agtHost: AGT_HOST,
@@ -38597,7 +38690,7 @@ async function handleRestartCommand(opts) {
38597
38690
  if (!existsSync9(RESTART_FLAGS_DIR)) {
38598
38691
  mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
38599
38692
  }
38600
- const flagPath = join13(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
38693
+ const flagPath = join14(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
38601
38694
  const flag = {
38602
38695
  codeName: AGENT_CODE_NAME,
38603
38696
  source: "telegram",
@@ -39003,16 +39096,16 @@ async function classifyRestartCommand(text) {
39003
39096
  if (!ours) return "verification_failed";
39004
39097
  return target === ours ? "act" : "ignore";
39005
39098
  }
39006
- var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join13(homedir5(), ".augmented", AGENT_CODE_NAME) : null;
39007
- var PENDING_INBOUND_DIR = AGENT_DIR ? join13(AGENT_DIR, "telegram-pending-inbound") : null;
39008
- var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join13(AGENT_DIR, "telegram-recovery-outbox") : null;
39009
- var RECOVERY_LEDGER_DIR = AGENT_DIR ? join13(AGENT_DIR, ".agt-telegram-recovery-ledger") : null;
39010
- var DELIVERY_LEDGER_DIR = AGENT_DIR ? join13(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
39011
- var RESTART_CONFIRM_FILE = AGENT_DIR ? join13(AGENT_DIR, "telegram-restart-confirm.json") : null;
39099
+ var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join14(homedir5(), ".augmented", AGENT_CODE_NAME) : null;
39100
+ var PENDING_INBOUND_DIR = AGENT_DIR ? join14(AGENT_DIR, "telegram-pending-inbound") : null;
39101
+ var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join14(AGENT_DIR, "telegram-recovery-outbox") : null;
39102
+ var RECOVERY_LEDGER_DIR = AGENT_DIR ? join14(AGENT_DIR, ".agt-telegram-recovery-ledger") : null;
39103
+ var DELIVERY_LEDGER_DIR = AGENT_DIR ? join14(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
39104
+ var RESTART_CONFIRM_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-restart-confirm.json") : null;
39012
39105
  var TELEGRAM_PROCESS_BOOT_MS = Date.now();
39013
- var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join13(AGENT_DIR, "telegram-recent-dms.json") : null;
39014
- var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join13(AGENT_DIR, "telegram-channel-add-restart.json") : null;
39015
- var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join13(AGENT_DIR, "telegram-getupdates-offset.json") : null;
39106
+ var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-recent-dms.json") : null;
39107
+ var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-channel-add-restart.json") : null;
39108
+ var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join14(AGENT_DIR, "telegram-getupdates-offset.json") : null;
39016
39109
  var recentDms = /* @__PURE__ */ new Map();
39017
39110
  var recentDmPersister = TELEGRAM_RECENT_DMS_FILE ? createRecentDmPersister({
39018
39111
  filePath: TELEGRAM_RECENT_DMS_FILE,
@@ -39067,7 +39160,7 @@ function safeMarkerName(chatId, messageId) {
39067
39160
  }
39068
39161
  function pendingInboundPath(chatId, messageId) {
39069
39162
  if (!PENDING_INBOUND_DIR) return null;
39070
- return join13(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
39163
+ return join14(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
39071
39164
  }
39072
39165
  function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false, payload) {
39073
39166
  const path = pendingInboundPath(chatId, messageId);
@@ -39115,7 +39208,7 @@ function rewriteTelegramMarkerInPlace(path, marker) {
39115
39208
  function clearTelegramMarkerFileWithHeal(fullPath) {
39116
39209
  let marker = null;
39117
39210
  try {
39118
- marker = JSON.parse(readFileSync13(fullPath, "utf-8"));
39211
+ marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
39119
39212
  } catch {
39120
39213
  }
39121
39214
  if (marker && decideRecoveryHeal({
@@ -39125,14 +39218,14 @@ function clearTelegramMarkerFileWithHeal(fullPath) {
39125
39218
  notifyBackOnline(marker.chat_id);
39126
39219
  }
39127
39220
  try {
39128
- if (existsSync9(fullPath)) unlinkSync7(fullPath);
39221
+ if (existsSync9(fullPath)) unlinkSync8(fullPath);
39129
39222
  } catch {
39130
39223
  }
39131
39224
  }
39132
39225
  function markTelegramMarkerSeenInPlace(fullPath) {
39133
39226
  let marker;
39134
39227
  try {
39135
- marker = JSON.parse(readFileSync13(fullPath, "utf-8"));
39228
+ marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
39136
39229
  } catch {
39137
39230
  return;
39138
39231
  }
@@ -39144,7 +39237,7 @@ function markTelegramMarkerSeenInPlace(fullPath) {
39144
39237
  function markTelegramMarkerSeenWithHeal(fullPath) {
39145
39238
  let marker = null;
39146
39239
  try {
39147
- marker = JSON.parse(readFileSync13(fullPath, "utf-8"));
39240
+ marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
39148
39241
  } catch {
39149
39242
  return;
39150
39243
  }
@@ -39160,7 +39253,7 @@ function readPendingInboundMarker(chatId, messageId) {
39160
39253
  const path = pendingInboundPath(chatId, messageId);
39161
39254
  if (!path || !existsSync9(path)) return null;
39162
39255
  try {
39163
- return JSON.parse(readFileSync13(path, "utf-8"));
39256
+ return JSON.parse(readFileSync14(path, "utf-8"));
39164
39257
  } catch {
39165
39258
  return null;
39166
39259
  }
@@ -39180,10 +39273,10 @@ function nextRetryName(filename) {
39180
39273
  async function processRecoveryOutboxFile(filename) {
39181
39274
  if (!RECOVERY_OUTBOX_DIR) return;
39182
39275
  if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
39183
- const fullPath = join13(RECOVERY_OUTBOX_DIR, filename);
39276
+ const fullPath = join14(RECOVERY_OUTBOX_DIR, filename);
39184
39277
  let payload;
39185
39278
  try {
39186
- const raw = readFileSync13(fullPath, "utf-8");
39279
+ const raw = readFileSync14(fullPath, "utf-8");
39187
39280
  payload = JSON.parse(raw);
39188
39281
  } catch (err) {
39189
39282
  process.stderr.write(
@@ -39232,7 +39325,7 @@ async function processRecoveryOutboxFile(filename) {
39232
39325
  clearPendingMessage(payload.chat_id, recoveryDrainCutoffMs);
39233
39326
  removeRecoveryLedgerEntry(RECOVERY_LEDGER_DIR, payload.marker_name);
39234
39327
  try {
39235
- unlinkSync7(fullPath);
39328
+ unlinkSync8(fullPath);
39236
39329
  } catch {
39237
39330
  }
39238
39331
  return;
@@ -39269,7 +39362,7 @@ async function processRecoveryOutboxFile(filename) {
39269
39362
  if (sendSucceeded) {
39270
39363
  removeRecoveryLedgerEntry(RECOVERY_LEDGER_DIR, payload.marker_name);
39271
39364
  try {
39272
- unlinkSync7(fullPath);
39365
+ unlinkSync8(fullPath);
39273
39366
  } catch {
39274
39367
  }
39275
39368
  return;
@@ -39277,7 +39370,7 @@ async function processRecoveryOutboxFile(filename) {
39277
39370
  const next = nextRetryName(filename);
39278
39371
  if (next) {
39279
39372
  try {
39280
- renameSync7(fullPath, join13(RECOVERY_OUTBOX_DIR, next.next));
39373
+ renameSync7(fullPath, join14(RECOVERY_OUTBOX_DIR, next.next));
39281
39374
  if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
39282
39375
  process.stderr.write(
39283
39376
  `telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -39318,7 +39411,7 @@ function scanRecoveryRetries() {
39318
39411
  if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
39319
39412
  let mtimeMs;
39320
39413
  try {
39321
- mtimeMs = statSync3(join13(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
39414
+ mtimeMs = statSync3(join14(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
39322
39415
  } catch {
39323
39416
  continue;
39324
39417
  }
@@ -39348,7 +39441,7 @@ function startRecoveryOutboxWatcher() {
39348
39441
  const watcher = watch(RECOVERY_OUTBOX_DIR, (event, filename) => {
39349
39442
  if (event !== "rename" || !filename) return;
39350
39443
  if (!isFirstAttemptOutboxFile(filename)) return;
39351
- if (existsSync9(join13(RECOVERY_OUTBOX_DIR, filename))) {
39444
+ if (existsSync9(join14(RECOVERY_OUTBOX_DIR, filename))) {
39352
39445
  void processRecoveryOutboxFile(filename);
39353
39446
  }
39354
39447
  });
@@ -39363,7 +39456,7 @@ function startRecoveryOutboxWatcher() {
39363
39456
  retryTimer.unref?.();
39364
39457
  }
39365
39458
  startRecoveryOutboxWatcher();
39366
- var NOTICE_OUTBOX_DIR = AGENT_DIR ? join13(AGENT_DIR, "telegram-notice-outbox") : null;
39459
+ var NOTICE_OUTBOX_DIR = AGENT_DIR ? join14(AGENT_DIR, "telegram-notice-outbox") : null;
39367
39460
  var NOTICE_MAX_AGE_MS = 9e4;
39368
39461
  var NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
39369
39462
  async function processNoticeOutboxFile(filename) {
@@ -39371,7 +39464,7 @@ async function processNoticeOutboxFile(filename) {
39371
39464
  if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
39372
39465
  if (NOTICE_INFLIGHT.has(filename)) return;
39373
39466
  NOTICE_INFLIGHT.add(filename);
39374
- const fullPath = join13(NOTICE_OUTBOX_DIR, filename);
39467
+ const fullPath = join14(NOTICE_OUTBOX_DIR, filename);
39375
39468
  try {
39376
39469
  let mtimeMs;
39377
39470
  try {
@@ -39381,26 +39474,26 @@ async function processNoticeOutboxFile(filename) {
39381
39474
  }
39382
39475
  if (Date.now() - mtimeMs > NOTICE_MAX_AGE_MS) {
39383
39476
  try {
39384
- unlinkSync7(fullPath);
39477
+ unlinkSync8(fullPath);
39385
39478
  } catch {
39386
39479
  }
39387
39480
  return;
39388
39481
  }
39389
39482
  let payload;
39390
39483
  try {
39391
- const parsed = JSON.parse(readFileSync13(fullPath, "utf-8"));
39484
+ const parsed = JSON.parse(readFileSync14(fullPath, "utf-8"));
39392
39485
  if (!parsed || typeof parsed !== "object") throw new Error("not an object");
39393
39486
  payload = parsed;
39394
39487
  } catch {
39395
39488
  try {
39396
- unlinkSync7(fullPath);
39489
+ unlinkSync8(fullPath);
39397
39490
  } catch {
39398
39491
  }
39399
39492
  return;
39400
39493
  }
39401
39494
  if (!payload.chat_id || !payload.text) {
39402
39495
  try {
39403
- unlinkSync7(fullPath);
39496
+ unlinkSync8(fullPath);
39404
39497
  } catch {
39405
39498
  }
39406
39499
  return;
@@ -39411,7 +39504,7 @@ async function processNoticeOutboxFile(filename) {
39411
39504
  defaultValue: false
39412
39505
  })) {
39413
39506
  try {
39414
- unlinkSync7(fullPath);
39507
+ unlinkSync8(fullPath);
39415
39508
  } catch {
39416
39509
  }
39417
39510
  return;
@@ -39440,7 +39533,7 @@ async function processNoticeOutboxFile(filename) {
39440
39533
  );
39441
39534
  }
39442
39535
  try {
39443
- unlinkSync7(fullPath);
39536
+ unlinkSync8(fullPath);
39444
39537
  } catch {
39445
39538
  }
39446
39539
  } finally {
@@ -39465,7 +39558,7 @@ function startNoticeOutboxWatcher() {
39465
39558
  try {
39466
39559
  const watcher = watch(NOTICE_OUTBOX_DIR, (event, filename) => {
39467
39560
  if (event !== "rename" || !filename) return;
39468
- if (existsSync9(join13(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
39561
+ if (existsSync9(join14(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
39469
39562
  });
39470
39563
  watcher.unref?.();
39471
39564
  } catch (err) {
@@ -39498,17 +39591,17 @@ function sweepTelegramStaleMarkers(thresholdMs) {
39498
39591
  for (const filename of filenames) {
39499
39592
  if (!filename.endsWith(".json")) continue;
39500
39593
  if (filename.endsWith(".tmp")) continue;
39501
- const fullPath = join13(PENDING_INBOUND_DIR, filename);
39594
+ const fullPath = join14(PENDING_INBOUND_DIR, filename);
39502
39595
  let marker;
39503
39596
  try {
39504
- marker = JSON.parse(readFileSync13(fullPath, "utf-8"));
39597
+ marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
39505
39598
  } catch (err) {
39506
39599
  process.stderr.write(
39507
39600
  `telegram-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactId(filename)}: ${err.message}
39508
39601
  `
39509
39602
  );
39510
39603
  try {
39511
- unlinkSync7(fullPath);
39604
+ unlinkSync8(fullPath);
39512
39605
  } catch {
39513
39606
  }
39514
39607
  cleared++;
@@ -39526,7 +39619,7 @@ function sweepTelegramStaleMarkers(thresholdMs) {
39526
39619
  );
39527
39620
  }
39528
39621
  try {
39529
- unlinkSync7(fullPath);
39622
+ unlinkSync8(fullPath);
39530
39623
  } catch {
39531
39624
  }
39532
39625
  cleared++;
@@ -39547,13 +39640,13 @@ var orphanSweepTimer = setInterval(() => {
39547
39640
  checkWatchdogGiveUpNotice();
39548
39641
  }, orphanSweepIntervalMs());
39549
39642
  orphanSweepTimer.unref?.();
39550
- var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join13(AGENT_DIR, "channel-progress-heartbeat.json") : null;
39643
+ var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join14(AGENT_DIR, "channel-progress-heartbeat.json") : null;
39551
39644
  var telegramTrackedProgress = null;
39552
39645
  var telegramProgressTickRunning = false;
39553
39646
  function readTelegramProgressHeartbeat() {
39554
39647
  if (!TELEGRAM_PROGRESS_HEARTBEAT_PATH || !existsSync9(TELEGRAM_PROGRESS_HEARTBEAT_PATH)) return null;
39555
39648
  try {
39556
- return parseProgressHeartbeat(readFileSync13(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
39649
+ return parseProgressHeartbeat(readFileSync14(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
39557
39650
  } catch {
39558
39651
  return null;
39559
39652
  }
@@ -39566,7 +39659,7 @@ function seedTelegramProgressHeartbeat() {
39566
39659
  renameSync7(tmp, TELEGRAM_PROGRESS_HEARTBEAT_PATH);
39567
39660
  } catch {
39568
39661
  try {
39569
- unlinkSync7(tmp);
39662
+ unlinkSync8(tmp);
39570
39663
  } catch {
39571
39664
  }
39572
39665
  }
@@ -39580,7 +39673,7 @@ function findTelegramProgressTarget() {
39580
39673
  if (!name.endsWith(".json")) continue;
39581
39674
  let m;
39582
39675
  try {
39583
- m = JSON.parse(readFileSync13(join13(PENDING_INBOUND_DIR, name), "utf-8"));
39676
+ m = JSON.parse(readFileSync14(join14(PENDING_INBOUND_DIR, name), "utf-8"));
39584
39677
  } catch {
39585
39678
  continue;
39586
39679
  }
@@ -39711,7 +39804,7 @@ function listPendingInboundChatIds() {
39711
39804
  if (!name.endsWith(".json")) continue;
39712
39805
  try {
39713
39806
  const marker = JSON.parse(
39714
- readFileSync13(join13(PENDING_INBOUND_DIR, name), "utf8")
39807
+ readFileSync14(join14(PENDING_INBOUND_DIR, name), "utf8")
39715
39808
  );
39716
39809
  if (typeof marker.seen_at === "string" && marker.seen_at) continue;
39717
39810
  if (typeof marker.chat_id === "string" && marker.chat_id) chats.add(marker.chat_id);
@@ -39753,7 +39846,7 @@ async function notifyWatchdogGiveUp(chatId, reason) {
39753
39846
  }
39754
39847
  function checkWatchdogGiveUpNotice() {
39755
39848
  if (!AGENT_DIR) return;
39756
- const signal = readGiveUpSignal(join13(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
39849
+ const signal = readGiveUpSignal(join14(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
39757
39850
  const signalAtMs = signal?.atMs ?? null;
39758
39851
  const act = decideGiveUpNotice({
39759
39852
  signalAtMs,
@@ -40109,7 +40202,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
40109
40202
  isError: true
40110
40203
  };
40111
40204
  }
40112
- bytes = readFileSync13(realPath);
40205
+ bytes = readFileSync14(realPath);
40113
40206
  } catch (err) {
40114
40207
  return { content: [{ type: "text", text: `Failed to read file: ${err.message}` }], isError: true };
40115
40208
  }
@@ -40670,7 +40763,7 @@ async function replayPendingTelegramMarkers() {
40670
40763
  let paneFreshAgeMs = null;
40671
40764
  if (AGENT_DIR) {
40672
40765
  try {
40673
- paneFreshAgeMs = Math.max(0, now - statSync3(join13(AGENT_DIR, "pane.log")).mtimeMs);
40766
+ paneFreshAgeMs = Math.max(0, now - statSync3(join14(AGENT_DIR, "pane.log")).mtimeMs);
40674
40767
  } catch {
40675
40768
  }
40676
40769
  }
@@ -40678,10 +40771,10 @@ async function replayPendingTelegramMarkers() {
40678
40771
  const entries = [];
40679
40772
  for (const name of filenames) {
40680
40773
  if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
40681
- const fullPath = join13(PENDING_INBOUND_DIR, name);
40774
+ const fullPath = join14(PENDING_INBOUND_DIR, name);
40682
40775
  let marker;
40683
40776
  try {
40684
- marker = JSON.parse(readFileSync13(fullPath, "utf-8"));
40777
+ marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
40685
40778
  } catch {
40686
40779
  continue;
40687
40780
  }
@@ -41216,7 +41309,7 @@ async function pollLoop() {
41216
41309
  let paneLogFreshAgeMs = null;
41217
41310
  if (AGENT_DIR) {
41218
41311
  try {
41219
- const paneMtimeMs = statSync3(join13(AGENT_DIR, "pane.log")).mtimeMs;
41312
+ const paneMtimeMs = statSync3(join14(AGENT_DIR, "pane.log")).mtimeMs;
41220
41313
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
41221
41314
  } catch {
41222
41315
  }
@@ -41312,6 +41405,9 @@ async function pollLoop() {
41312
41405
  if (ackDecision === "ack") {
41313
41406
  scheduleBusyAck(chatId, messageId, arrivedWhileBusy);
41314
41407
  }
41408
+ if (!isFromBot && !peerAgentMeta && userId && userId !== "unknown" && chatId) {
41409
+ clearScheduledTurnMarker(TELEGRAM_AGENT_DIR);
41410
+ }
41315
41411
  await mcp.notification({
41316
41412
  method: "notifications/claude/channel",
41317
41413
  params: channelPayload