@integrity-labs/agt-cli 0.28.474 → 0.28.476
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-C47UJ5QI.js → chunk-IGXBEU55.js} +3 -3
- package/dist/chunk-IGXBEU55.js.map +1 -0
- package/dist/{chunk-YR6ESOCM.js → chunk-Q6RVMDAC.js} +31 -87
- package/dist/chunk-Q6RVMDAC.js.map +1 -0
- package/dist/{claude-pair-runtime-62G3PXXX.js → claude-pair-runtime-DYLJU6EV.js} +2 -2
- package/dist/lib/manager-worker.js +368 -426
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +74 -185
- package/dist/mcp/origami.js +32 -36
- package/dist/mcp/slack-channel.js +188 -309
- package/dist/mcp/telegram-channel.js +151 -264
- package/dist/{persistent-session-Y77TKSL6.js → persistent-session-QITF76DO.js} +2 -2
- package/dist/{responsiveness-probe-KIPMD2UJ.js → responsiveness-probe-BEA4J6IL.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-C47UJ5QI.js.map +0 -1
- package/dist/chunk-YR6ESOCM.js.map +0 -1
- /package/dist/{claude-pair-runtime-62G3PXXX.js.map → claude-pair-runtime-DYLJU6EV.js.map} +0 -0
- /package/dist/{persistent-session-Y77TKSL6.js.map → persistent-session-QITF76DO.js.map} +0 -0
- /package/dist/{responsiveness-probe-KIPMD2UJ.js.map → responsiveness-probe-BEA4J6IL.js.map} +0 -0
|
@@ -18906,7 +18906,7 @@ var require_filters = __commonJS({
|
|
|
18906
18906
|
return r.copySafeness(str, res);
|
|
18907
18907
|
}
|
|
18908
18908
|
_exports.indent = indent;
|
|
18909
|
-
function
|
|
18909
|
+
function join17(arr, del, attr) {
|
|
18910
18910
|
del = del || "";
|
|
18911
18911
|
if (attr) {
|
|
18912
18912
|
arr = lib.map(arr, function(v) {
|
|
@@ -18915,7 +18915,7 @@ var require_filters = __commonJS({
|
|
|
18915
18915
|
}
|
|
18916
18916
|
return arr.join(del);
|
|
18917
18917
|
}
|
|
18918
|
-
_exports.join =
|
|
18918
|
+
_exports.join = join17;
|
|
18919
18919
|
function last(arr) {
|
|
18920
18920
|
return arr[arr.length - 1];
|
|
18921
18921
|
}
|
|
@@ -30132,7 +30132,7 @@ import {
|
|
|
30132
30132
|
ftruncateSync,
|
|
30133
30133
|
mkdirSync as mkdirSync9,
|
|
30134
30134
|
openSync,
|
|
30135
|
-
readFileSync as
|
|
30135
|
+
readFileSync as readFileSync16,
|
|
30136
30136
|
readdirSync as readdirSync6,
|
|
30137
30137
|
realpathSync,
|
|
30138
30138
|
renameSync as renameSync7,
|
|
@@ -30142,8 +30142,8 @@ import {
|
|
|
30142
30142
|
writeFileSync as writeFileSync11,
|
|
30143
30143
|
writeSync
|
|
30144
30144
|
} from "fs";
|
|
30145
|
-
import { homedir as
|
|
30146
|
-
import { basename, extname, join as
|
|
30145
|
+
import { homedir as homedir6 } from "os";
|
|
30146
|
+
import { basename, extname, join as join16, resolve as resolve2 } from "path";
|
|
30147
30147
|
|
|
30148
30148
|
// ../core/dist/channels/interim-promise.js
|
|
30149
30149
|
function decideMarkerEngagement(marker, kind, nowIso) {
|
|
@@ -30758,40 +30758,6 @@ function resolveGhostReplyMode(opts) {
|
|
|
30758
30758
|
if (cached2 !== void 0) return cached2;
|
|
30759
30759
|
return "off";
|
|
30760
30760
|
}
|
|
30761
|
-
var USAGE_LIMIT_REACTIVE_FLAG_KEY = "usage-limit-reactive-notice";
|
|
30762
|
-
function parseUsageLimitReactiveMode(raw) {
|
|
30763
|
-
if (raw === void 0) return void 0;
|
|
30764
|
-
const v = raw.trim().toLowerCase();
|
|
30765
|
-
if (v === "") return void 0;
|
|
30766
|
-
if (v === "off" || v === "shadow" || v === "enforce") return v;
|
|
30767
|
-
const b = envBoolean(raw);
|
|
30768
|
-
if (b === true) return "enforce";
|
|
30769
|
-
if (b === false) return "off";
|
|
30770
|
-
return void 0;
|
|
30771
|
-
}
|
|
30772
|
-
function cachedUsageLimitReactiveMode(path) {
|
|
30773
|
-
try {
|
|
30774
|
-
if (!existsSync2(path)) return void 0;
|
|
30775
|
-
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
30776
|
-
if (!parsed || typeof parsed !== "object") return void 0;
|
|
30777
|
-
const flags = parsed.flags;
|
|
30778
|
-
if (!flags || typeof flags !== "object") return void 0;
|
|
30779
|
-
const value = flags[USAGE_LIMIT_REACTIVE_FLAG_KEY];
|
|
30780
|
-
if (typeof value === "string") return parseUsageLimitReactiveMode(value);
|
|
30781
|
-
if (typeof value === "boolean") return value ? "enforce" : "off";
|
|
30782
|
-
return void 0;
|
|
30783
|
-
} catch {
|
|
30784
|
-
return void 0;
|
|
30785
|
-
}
|
|
30786
|
-
}
|
|
30787
|
-
function resolveUsageLimitReactiveMode(opts) {
|
|
30788
|
-
const env2 = opts?.env ?? process.env;
|
|
30789
|
-
const modeOverride = parseUsageLimitReactiveMode(env2["AGT_USAGE_LIMIT_REACTIVE_MODE"]);
|
|
30790
|
-
if (modeOverride !== void 0) return modeOverride;
|
|
30791
|
-
const cached2 = cachedUsageLimitReactiveMode(opts?.cachePath ?? defaultFlagsCachePath());
|
|
30792
|
-
if (cached2 !== void 0) return cached2;
|
|
30793
|
-
return "off";
|
|
30794
|
-
}
|
|
30795
30761
|
|
|
30796
30762
|
// src/maintenance-mode.ts
|
|
30797
30763
|
var FLAG_KEY = "platform-maintenance-mode";
|
|
@@ -30806,11 +30772,6 @@ function isMaintenanceModeActive(opts) {
|
|
|
30806
30772
|
});
|
|
30807
30773
|
}
|
|
30808
30774
|
|
|
30809
|
-
// src/usage-limit-notice.ts
|
|
30810
|
-
import { readFileSync as readFileSync4 } from "fs";
|
|
30811
|
-
import { homedir as homedir3 } from "os";
|
|
30812
|
-
import { join as join3 } from "path";
|
|
30813
|
-
|
|
30814
30775
|
// ../core/dist/types/integration.js
|
|
30815
30776
|
var HITL_TIER_ORDER = [
|
|
30816
30777
|
"read",
|
|
@@ -33521,6 +33482,34 @@ var INTEGRATION_REGISTRY = [
|
|
|
33521
33482
|
docs_url: "https://higgsfield.ai/mcp",
|
|
33522
33483
|
beta: true
|
|
33523
33484
|
},
|
|
33485
|
+
{
|
|
33486
|
+
id: "vercel",
|
|
33487
|
+
name: "Vercel",
|
|
33488
|
+
category: "infrastructure",
|
|
33489
|
+
description: "Check on Vercel app deployments \u2014 status, build/runtime logs \u2014 and search Vercel documentation. Remote streamable-HTTP MCP at https://mcp.vercel.com.",
|
|
33490
|
+
// Same OAuth pattern as Granola/Higgsfield: Claude Code brokers the
|
|
33491
|
+
// browser sign-in at runtime; nothing for the manager API to provision.
|
|
33492
|
+
supported_auth_types: ["none"],
|
|
33493
|
+
capabilities: [
|
|
33494
|
+
{ id: "vercel:read-deployments", name: "Read Deployments", description: "List teams/projects, check deployment status, and read build/runtime logs.", access: "read" },
|
|
33495
|
+
{ id: "vercel:search-docs", name: "Search Documentation", description: "Search Vercel platform documentation.", access: "read" }
|
|
33496
|
+
],
|
|
33497
|
+
docs_url: "https://vercel.com/docs/agent-resources/vercel-mcp",
|
|
33498
|
+
// Beta until the headless OAuth flow (and Vercel's OAuth-client allowlist,
|
|
33499
|
+
// which is vendor-side and outside our control) is verified end-to-end.
|
|
33500
|
+
beta: true,
|
|
33501
|
+
// No `auth`/`headers` — host-brokered OAuth (Claude Code authenticates
|
|
33502
|
+
// directly with Vercel; nothing for us to inject). Declaring this here
|
|
33503
|
+
// (rather than a hardcoded buildMcpJson/writeIntegrations branch, the
|
|
33504
|
+
// pre-ENG-8035 Higgsfield-era pattern) lets the generic remote-MCP loop
|
|
33505
|
+
// render the `.mcp.json` entry AND enrolls 'vercel' in the
|
|
33506
|
+
// `registryRemoteMcpKeys` prune universe automatically, so an uninstall
|
|
33507
|
+
// actually removes the entry instead of leaving it stale.
|
|
33508
|
+
remoteMcp: {
|
|
33509
|
+
type: "http",
|
|
33510
|
+
url: "https://mcp.vercel.com"
|
|
33511
|
+
}
|
|
33512
|
+
},
|
|
33524
33513
|
{
|
|
33525
33514
|
id: "qmd",
|
|
33526
33515
|
name: "QMD Memory Search",
|
|
@@ -34244,30 +34233,11 @@ function parseResetDateTime(humanDate, now) {
|
|
|
34244
34233
|
return resolved;
|
|
34245
34234
|
}
|
|
34246
34235
|
|
|
34247
|
-
// ../core/dist/claude-code-usage/
|
|
34248
|
-
var
|
|
34249
|
-
var
|
|
34250
|
-
|
|
34251
|
-
|
|
34252
|
-
try {
|
|
34253
|
-
parsed = JSON.parse(raw);
|
|
34254
|
-
} catch {
|
|
34255
|
-
return null;
|
|
34256
|
-
}
|
|
34257
|
-
if (typeof parsed !== "object" || parsed === null || parsed.version !== USAGE_LIMIT_MARKER_VERSION) {
|
|
34258
|
-
return null;
|
|
34259
|
-
}
|
|
34260
|
-
const until = parsed.limited_until;
|
|
34261
|
-
if (typeof until !== "string" || !Number.isFinite(Date.parse(until)))
|
|
34262
|
-
return null;
|
|
34263
|
-
return { version: USAGE_LIMIT_MARKER_VERSION, limited_until: until };
|
|
34264
|
-
}
|
|
34265
|
-
function resolveUsageLimitUntil(marker, now) {
|
|
34266
|
-
if (!marker)
|
|
34267
|
-
return null;
|
|
34268
|
-
const until = new Date(marker.limited_until);
|
|
34269
|
-
return until.getTime() > now.getTime() ? until : null;
|
|
34270
|
-
}
|
|
34236
|
+
// ../core/dist/claude-code-usage/run-marker.js
|
|
34237
|
+
var RUN_MARKER_RE = /<!--\s*agt-run:([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\s*-->/;
|
|
34238
|
+
var RUN_MARKER_RE_GLOBAL = new RegExp(RUN_MARKER_RE.source, "g");
|
|
34239
|
+
|
|
34240
|
+
// ../core/dist/claude-code-usage/usage-limit-notice-text.js
|
|
34271
34241
|
function formatUtcClock(date3) {
|
|
34272
34242
|
const hours = date3.getUTCHours();
|
|
34273
34243
|
const minutes = date3.getUTCMinutes();
|
|
@@ -35202,42 +35172,6 @@ var FLAG_REGISTRY = [
|
|
|
35202
35172
|
// projectDefinition, so setting it does not roll FLAGS_SCHEMA_VERSION.
|
|
35203
35173
|
since: "0.28.421"
|
|
35204
35174
|
},
|
|
35205
|
-
{
|
|
35206
|
-
key: "usage-limit-reactive-notice",
|
|
35207
|
-
description: "Report a Claude Code usage cap REACTIVELY instead of predicting it (ENG-8201). Today the manager guesses from the agent transcript that the next turn will be refused, writes a marker, and every channel MCP refuses to dispatch on the strength of that guess - so a wrong guess is a swallowed message, and because the notice is throttled per (channel, sender) while the DROP is not, the usual symptom is total silence rather than a wrong reply. A refused turn actually costs nothing (rejected in under a second, zero tokens) and Claude Code records it with the reset time in it, so there is no need to guess: dispatch, and report the refusal if one comes back. off = today behaviour (pre-dispatch marker gate, no watcher). shadow = still gate on the marker, but ALSO watch dispatched messages and log the refusal that would have been reported - measures the true-positive rate with no user-visible change. enforce = stop reading the marker before dispatch; every admitted human message reaches the agent and a refusal is answered in-thread with the reset time from the error itself. Read live from the heartbeat flags-cache (or the env override).",
|
|
35208
|
-
flagType: "enum",
|
|
35209
|
-
allowedValues: ["off", "shadow", "enforce"],
|
|
35210
|
-
// Ships dark: off preserves today's gate byte-for-byte. shadow is a free
|
|
35211
|
-
// local log line (the watch is a transcript read, no model spend), so it is a
|
|
35212
|
-
// cheap soak; enforce changes what reaches the agent, so it is the audited
|
|
35213
|
-
// per-org flip.
|
|
35214
|
-
defaultValue: "off",
|
|
35215
|
-
// Enum override AGT_USAGE_LIMIT_REACTIVE_MODE (off|shadow|enforce), resolved
|
|
35216
|
-
// by resolveUsageLimitReactiveMode in the channel-server bundle.
|
|
35217
|
-
envVar: "AGT_USAGE_LIMIT_REACTIVE_MODE",
|
|
35218
|
-
// enforce sends a message to an agent the host currently believes is capped -
|
|
35219
|
-
// a deliberate availability trade (the refusal is free, but it is still a
|
|
35220
|
-
// dispatch the operator previously suppressed), so flipping toward it is an
|
|
35221
|
-
// audited change (ADR-0022 sensitive-flag confirm).
|
|
35222
|
-
sensitive: true,
|
|
35223
|
-
// ENG-8149 / ENG-8229: the agt-cli that first carries
|
|
35224
|
-
// resolveUsageLimitReactiveMode in ALL THREE channel servers - published from
|
|
35225
|
-
// the ENG-8207 merge 0294fa1a8. Without this the flip-reach modal reports FULL
|
|
35226
|
-
// reach, because an undefined `since` means "every host can honour it" - true
|
|
35227
|
-
// for flags that predate the reach work, wrong for a NEW host-read flag whose
|
|
35228
|
-
// reader older hosts simply do not have. Excluded from projectDefinition, so
|
|
35229
|
-
// setting it does not roll FLAGS_SCHEMA_VERSION.
|
|
35230
|
-
//
|
|
35231
|
-
// Deliberately the LATER of the two versions this flag's reader shipped in.
|
|
35232
|
-
// Unlike its siblings, this reader landed in two stages: direct-chat at the
|
|
35233
|
-
// ENG-8201 Slice 2 publish, slack + telegram only at 0.28.450 (ENG-8207) - and
|
|
35234
|
-
// `since` is one version per flag, so it cannot express "partially honoured".
|
|
35235
|
-
// A host in between genuinely honours the flag for direct-chat and is still
|
|
35236
|
-
// classified `stale`. That understates reach rather than overstating it, which
|
|
35237
|
-
// is the safe direction, and it is the useful one while the flag sits at
|
|
35238
|
-
// enforce and slack/telegram adoption is what an operator needs to track.
|
|
35239
|
-
since: "0.28.450"
|
|
35240
|
-
},
|
|
35241
35175
|
{
|
|
35242
35176
|
key: "slack-hot-thread-guard",
|
|
35243
35177
|
description: "Server-side hot-thread guard on the slack.reply surface (ENG-7462). Prevents an agent posting a NEW top-level Slack message when it meant to reply inside the thread it is already working in - a prompt/memory rule proved insufficient (the agent had the rule and still slipped). When a reply would otherwise post to channel ROOT (no thread_ts / message_ts / inbound_id, no active kanban card) and the agent has a recent active thread in that channel (its last bot-posted thread, from the persisted trackedThreads cache, within a freshness window), the reply is redirected into that thread. proactive:true no longer implies channel root; posting at root becomes a deliberate action (the to_channel_root flag, or the thread_ts:null sentinel). off = guard never runs, replies with no coords root exactly as today (ships dark). shadow = compute + log the would-redirect but STILL post to root (measure the fire rate before acting). enforce = apply the redirect (a soft-block: redirect + inform, never a hard rejection). Read live from the heartbeat flags-cache (or the env override); enforce is a deliberate per-org flip after a shadow soak.",
|
|
@@ -35944,37 +35878,20 @@ function deriveBindFailureQuarantineThreshold(provisioningMax) {
|
|
|
35944
35878
|
}
|
|
35945
35879
|
var MIN_PROVISIONING_MAX_FOR_QUARANTINE_ORDERING = BIND_FAILURE_QUARANTINE_THRESHOLD + 1;
|
|
35946
35880
|
|
|
35947
|
-
// src/usage-limit-notice.ts
|
|
35948
|
-
function usageLimitMarkerPath(codeName) {
|
|
35949
|
-
if (!codeName) return null;
|
|
35950
|
-
return join3(homedir3(), ".augmented", codeName, USAGE_LIMIT_MARKER_FILENAME);
|
|
35951
|
-
}
|
|
35952
|
-
function readUsageLimitUntil(opts) {
|
|
35953
|
-
const path = opts.filePath ?? usageLimitMarkerPath(opts.codeName);
|
|
35954
|
-
if (!path) return null;
|
|
35955
|
-
let raw;
|
|
35956
|
-
try {
|
|
35957
|
-
raw = readFileSync4(path, "utf-8");
|
|
35958
|
-
} catch {
|
|
35959
|
-
return null;
|
|
35960
|
-
}
|
|
35961
|
-
return resolveUsageLimitUntil(parseUsageLimitMarker(raw), opts.now ?? /* @__PURE__ */ new Date());
|
|
35962
|
-
}
|
|
35963
|
-
|
|
35964
35881
|
// src/account-enforcement-notice.ts
|
|
35965
|
-
import { readFileSync as
|
|
35966
|
-
import { homedir as
|
|
35967
|
-
import { join as
|
|
35882
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
35883
|
+
import { homedir as homedir3 } from "os";
|
|
35884
|
+
import { join as join3 } from "path";
|
|
35968
35885
|
function accountEnforcementMarkerPath(codeName) {
|
|
35969
35886
|
if (!codeName) return null;
|
|
35970
|
-
return
|
|
35887
|
+
return join3(homedir3(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
35971
35888
|
}
|
|
35972
35889
|
function readAccountEnforcementLevel(opts) {
|
|
35973
35890
|
const path = opts.filePath ?? accountEnforcementMarkerPath(opts.codeName);
|
|
35974
35891
|
if (!path) return null;
|
|
35975
35892
|
let raw;
|
|
35976
35893
|
try {
|
|
35977
|
-
raw =
|
|
35894
|
+
raw = readFileSync4(path, "utf-8");
|
|
35978
35895
|
} catch {
|
|
35979
35896
|
return null;
|
|
35980
35897
|
}
|
|
@@ -35993,13 +35910,13 @@ function shouldSendAccountWarn(opts) {
|
|
|
35993
35910
|
}
|
|
35994
35911
|
|
|
35995
35912
|
// src/turn-initiator-marker.ts
|
|
35996
|
-
import { writeFileSync as writeFileSync4, readFileSync as
|
|
35997
|
-
import { dirname as dirname3, join as
|
|
35913
|
+
import { writeFileSync as writeFileSync4, readFileSync as readFileSync5, mkdirSync as mkdirSync4, renameSync as renameSync3 } from "fs";
|
|
35914
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
35998
35915
|
var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
35999
35916
|
var TURN_INITIATOR_LEDGER_MAX_ENTRIES = 20;
|
|
36000
35917
|
var TURN_INITIATOR_LEDGER_FILENAME = ".turn-initiator-ledger.json";
|
|
36001
35918
|
function turnInitiatorLedgerPath(singleSlotFile) {
|
|
36002
|
-
return
|
|
35919
|
+
return join4(dirname3(singleSlotFile), TURN_INITIATOR_LEDGER_FILENAME);
|
|
36003
35920
|
}
|
|
36004
35921
|
function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX_AGE_MS, maxEntries = TURN_INITIATOR_LEDGER_MAX_ENTRIES) {
|
|
36005
35922
|
const now = marker.ts;
|
|
@@ -36024,7 +35941,7 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
|
|
|
36024
35941
|
const ledgerFile = turnInitiatorLedgerPath(singleSlotFile);
|
|
36025
35942
|
let existing = null;
|
|
36026
35943
|
try {
|
|
36027
|
-
const parsed = JSON.parse(
|
|
35944
|
+
const parsed = JSON.parse(readFileSync5(ledgerFile, "utf8"));
|
|
36028
35945
|
if (parsed && parsed.v === 1 && Array.isArray(parsed.entries)) existing = parsed;
|
|
36029
35946
|
} catch {
|
|
36030
35947
|
}
|
|
@@ -36051,14 +35968,14 @@ function writeTurnInitiatorMarker(input) {
|
|
|
36051
35968
|
}
|
|
36052
35969
|
|
|
36053
35970
|
// src/scheduled-turn-marker.ts
|
|
36054
|
-
import { readFileSync as
|
|
36055
|
-
import { join as
|
|
35971
|
+
import { readFileSync as readFileSync6, unlinkSync as unlinkSync4 } from "fs";
|
|
35972
|
+
import { join as join5 } from "path";
|
|
36056
35973
|
var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
|
|
36057
35974
|
var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
36058
35975
|
function clearScheduledTurnMarker(agentDir) {
|
|
36059
35976
|
if (!agentDir) return;
|
|
36060
35977
|
try {
|
|
36061
|
-
unlinkSync4(
|
|
35978
|
+
unlinkSync4(join5(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
|
|
36062
35979
|
} catch {
|
|
36063
35980
|
}
|
|
36064
35981
|
}
|
|
@@ -36710,7 +36627,7 @@ function buildCommandRegistrations() {
|
|
|
36710
36627
|
import {
|
|
36711
36628
|
existsSync as existsSync3,
|
|
36712
36629
|
mkdirSync as mkdirSync5,
|
|
36713
|
-
readFileSync as
|
|
36630
|
+
readFileSync as readFileSync7,
|
|
36714
36631
|
renameSync as renameSync4,
|
|
36715
36632
|
unlinkSync as unlinkSync5,
|
|
36716
36633
|
writeFileSync as writeFileSync5
|
|
@@ -36720,7 +36637,7 @@ function loadPersistedOffset(filePath) {
|
|
|
36720
36637
|
if (!filePath) return 0;
|
|
36721
36638
|
try {
|
|
36722
36639
|
const parsed = JSON.parse(
|
|
36723
|
-
|
|
36640
|
+
readFileSync7(filePath, "utf-8")
|
|
36724
36641
|
);
|
|
36725
36642
|
const offset = parsed?.offset;
|
|
36726
36643
|
if (typeof offset === "number" && Number.isFinite(offset) && offset > 0) {
|
|
@@ -36764,8 +36681,8 @@ function conversationalLaneMeta(expectsReply = true) {
|
|
|
36764
36681
|
}
|
|
36765
36682
|
|
|
36766
36683
|
// src/inbound-lane-telemetry.ts
|
|
36767
|
-
import { readFileSync as
|
|
36768
|
-
import { join as
|
|
36684
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
36685
|
+
import { join as join6 } from "path";
|
|
36769
36686
|
var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
|
|
36770
36687
|
var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
|
|
36771
36688
|
var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
|
|
@@ -36782,10 +36699,10 @@ function isSuspectedMisclassification(lane, source) {
|
|
|
36782
36699
|
}
|
|
36783
36700
|
function recordLaneClassification(agentDir, channel, classification) {
|
|
36784
36701
|
if (!agentDir) return;
|
|
36785
|
-
const path =
|
|
36702
|
+
const path = join6(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
|
|
36786
36703
|
let counts = {};
|
|
36787
36704
|
try {
|
|
36788
|
-
const parsed = JSON.parse(
|
|
36705
|
+
const parsed = JSON.parse(readFileSync8(path, "utf-8"));
|
|
36789
36706
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
36790
36707
|
} catch {
|
|
36791
36708
|
}
|
|
@@ -36801,15 +36718,15 @@ function recordLaneClassification(agentDir, channel, classification) {
|
|
|
36801
36718
|
}
|
|
36802
36719
|
|
|
36803
36720
|
// src/agent-config-state.ts
|
|
36804
|
-
import { existsSync as existsSync4, readFileSync as
|
|
36805
|
-
import { join as
|
|
36721
|
+
import { existsSync as existsSync4, readFileSync as readFileSync9 } from "fs";
|
|
36722
|
+
import { join as join7 } from "path";
|
|
36806
36723
|
var SESSION_STATE_FILENAME = "session-state.json";
|
|
36807
36724
|
function readAgentSessionState(stateDir) {
|
|
36808
36725
|
if (!stateDir) return null;
|
|
36809
|
-
const path =
|
|
36726
|
+
const path = join7(stateDir, SESSION_STATE_FILENAME);
|
|
36810
36727
|
if (!existsSync4(path)) return null;
|
|
36811
36728
|
try {
|
|
36812
|
-
const parsed = JSON.parse(
|
|
36729
|
+
const parsed = JSON.parse(readFileSync9(path, "utf-8"));
|
|
36813
36730
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
36814
36731
|
return parsed;
|
|
36815
36732
|
} catch {
|
|
@@ -37612,15 +37529,15 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
|
|
|
37612
37529
|
}
|
|
37613
37530
|
|
|
37614
37531
|
// src/rate-limit-watch.ts
|
|
37615
|
-
import { readFileSync as
|
|
37616
|
-
import { homedir as
|
|
37617
|
-
import { join as
|
|
37532
|
+
import { readFileSync as readFileSync10, readdirSync, statSync } from "fs";
|
|
37533
|
+
import { homedir as homedir4 } from "os";
|
|
37534
|
+
import { join as join8 } from "path";
|
|
37618
37535
|
var DEFAULT_WATCH_MS = 5e3;
|
|
37619
37536
|
var DEFAULT_POLL_MS = 400;
|
|
37620
37537
|
function agentTranscriptDir(opts) {
|
|
37621
37538
|
const cwd = opts?.cwd ?? process.cwd();
|
|
37622
|
-
const home = opts?.home ??
|
|
37623
|
-
return
|
|
37539
|
+
const home = opts?.home ?? homedir4();
|
|
37540
|
+
return join8(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
|
|
37624
37541
|
}
|
|
37625
37542
|
function classifyTranscriptSince(opts) {
|
|
37626
37543
|
const dir = opts.transcriptDir ?? agentTranscriptDir({ cwd: opts.cwd, home: opts.home });
|
|
@@ -37633,7 +37550,7 @@ function classifyTranscriptSince(opts) {
|
|
|
37633
37550
|
let newest = UNKNOWN_RATE_LIMIT;
|
|
37634
37551
|
for (const name of entries) {
|
|
37635
37552
|
if (!name.endsWith(".jsonl")) continue;
|
|
37636
|
-
const path =
|
|
37553
|
+
const path = join8(dir, name);
|
|
37637
37554
|
try {
|
|
37638
37555
|
const st = statSync(path);
|
|
37639
37556
|
if (!st.isFile() || st.mtimeMs < opts.sinceMs) continue;
|
|
@@ -37642,7 +37559,7 @@ function classifyTranscriptSince(opts) {
|
|
|
37642
37559
|
}
|
|
37643
37560
|
let content;
|
|
37644
37561
|
try {
|
|
37645
|
-
content =
|
|
37562
|
+
content = readFileSync10(path, "utf-8");
|
|
37646
37563
|
} catch {
|
|
37647
37564
|
continue;
|
|
37648
37565
|
}
|
|
@@ -37681,8 +37598,8 @@ async function watchForRateLimitRefusal(opts) {
|
|
|
37681
37598
|
}
|
|
37682
37599
|
|
|
37683
37600
|
// src/turn-failure-watch.ts
|
|
37684
|
-
import { readFileSync as
|
|
37685
|
-
import { join as
|
|
37601
|
+
import { readFileSync as readFileSync11, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
37602
|
+
import { join as join9 } from "path";
|
|
37686
37603
|
function turnFailureNoticeEnabled(env2) {
|
|
37687
37604
|
return resolveHostBooleanFlag({
|
|
37688
37605
|
key: "wedge-transient-notice",
|
|
@@ -37711,7 +37628,7 @@ function classifyTurnFailureSince(opts) {
|
|
|
37711
37628
|
const unrecognised = /* @__PURE__ */ new Set();
|
|
37712
37629
|
for (const name of entries) {
|
|
37713
37630
|
if (!name.endsWith(".jsonl")) continue;
|
|
37714
|
-
const path =
|
|
37631
|
+
const path = join9(dir, name);
|
|
37715
37632
|
let fingerprint;
|
|
37716
37633
|
try {
|
|
37717
37634
|
const st = statSync2(path);
|
|
@@ -37727,7 +37644,7 @@ function classifyTurnFailureSince(opts) {
|
|
|
37727
37644
|
} else {
|
|
37728
37645
|
let content;
|
|
37729
37646
|
try {
|
|
37730
|
-
content =
|
|
37647
|
+
content = readFileSync11(path, "utf-8");
|
|
37731
37648
|
} catch {
|
|
37732
37649
|
continue;
|
|
37733
37650
|
}
|
|
@@ -37825,19 +37742,14 @@ async function watchForTurnFailure(opts) {
|
|
|
37825
37742
|
|
|
37826
37743
|
// src/usage-limit-reactive-decision.ts
|
|
37827
37744
|
import { createHash } from "crypto";
|
|
37828
|
-
function
|
|
37829
|
-
return
|
|
37830
|
-
}
|
|
37831
|
-
function armedWatchMode(opts) {
|
|
37832
|
-
if (opts.mode === "off") return null;
|
|
37833
|
-
if (opts.isBot || !opts.replyOwed) return null;
|
|
37834
|
-
return opts.mode;
|
|
37745
|
+
function shouldArmWatch(opts) {
|
|
37746
|
+
return !opts.isBot && opts.replyOwed;
|
|
37835
37747
|
}
|
|
37836
37748
|
function decideRefusalAction(opts) {
|
|
37837
37749
|
const { refusal } = opts;
|
|
37838
37750
|
if (!refusal || refusal.verdict !== "capped") return "none";
|
|
37839
37751
|
if (!refusal.resetsAt) return "missing-reset";
|
|
37840
|
-
return
|
|
37752
|
+
return "notify";
|
|
37841
37753
|
}
|
|
37842
37754
|
function describeUnparsedRefusal(text) {
|
|
37843
37755
|
if (!text) return "refusal=absent";
|
|
@@ -37848,8 +37760,8 @@ function describeUnparsedRefusal(text) {
|
|
|
37848
37760
|
// src/reply-intent-runtime.ts
|
|
37849
37761
|
import { execFile as execFile2 } from "child_process";
|
|
37850
37762
|
import { existsSync as existsSync5, mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
|
|
37851
|
-
import { homedir as
|
|
37852
|
-
import { join as
|
|
37763
|
+
import { homedir as homedir5 } from "os";
|
|
37764
|
+
import { join as join10 } from "path";
|
|
37853
37765
|
var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
|
|
37854
37766
|
var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
|
|
37855
37767
|
var ANTHROPIC_API_VERSION = "2023-06-01";
|
|
@@ -37948,12 +37860,12 @@ async function runAnthropicMessages(prompt, opts) {
|
|
|
37948
37860
|
var emptyMcpConfigPath = null;
|
|
37949
37861
|
function ensureEmptyMcpConfig() {
|
|
37950
37862
|
if (emptyMcpConfigPath && existsSync5(emptyMcpConfigPath)) return emptyMcpConfigPath;
|
|
37951
|
-
const dir =
|
|
37863
|
+
const dir = join10(homedir5(), ".augmented");
|
|
37952
37864
|
try {
|
|
37953
37865
|
mkdirSync6(dir, { recursive: true });
|
|
37954
37866
|
} catch {
|
|
37955
37867
|
}
|
|
37956
|
-
const p2 =
|
|
37868
|
+
const p2 = join10(dir, ".reply-intent-empty-mcp.json");
|
|
37957
37869
|
writeFileSync7(p2, JSON.stringify({ mcpServers: {} }));
|
|
37958
37870
|
emptyMcpConfigPath = p2;
|
|
37959
37871
|
return p2;
|
|
@@ -37978,7 +37890,7 @@ function runClaudeP(prompt, model) {
|
|
|
37978
37890
|
execFile2(
|
|
37979
37891
|
"claude",
|
|
37980
37892
|
args,
|
|
37981
|
-
{ cwd:
|
|
37893
|
+
{ cwd: homedir5(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
|
|
37982
37894
|
(err, stdout) => {
|
|
37983
37895
|
if (err) {
|
|
37984
37896
|
reject(err);
|
|
@@ -38100,11 +38012,11 @@ function emitTransientApiErrorTelemetry(channel, match, original) {
|
|
|
38100
38012
|
}
|
|
38101
38013
|
|
|
38102
38014
|
// src/telegram-pending-inbound-cleanup.ts
|
|
38103
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
38104
|
-
import { join as
|
|
38015
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync12, statSync as statSync3 } from "fs";
|
|
38016
|
+
import { join as join11 } from "path";
|
|
38105
38017
|
function markerArrivalMs(fullPath) {
|
|
38106
38018
|
try {
|
|
38107
|
-
const received = JSON.parse(
|
|
38019
|
+
const received = JSON.parse(readFileSync12(fullPath, "utf-8")).received_at;
|
|
38108
38020
|
const parsed = received ? Date.parse(received) : Number.NaN;
|
|
38109
38021
|
if (Number.isFinite(parsed)) return parsed;
|
|
38110
38022
|
} catch {
|
|
@@ -38134,7 +38046,7 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
|
|
|
38134
38046
|
for (const filename of filenames) {
|
|
38135
38047
|
if (!filename.startsWith(prefix)) continue;
|
|
38136
38048
|
if (!filename.endsWith(".json")) continue;
|
|
38137
|
-
const fullPath =
|
|
38049
|
+
const fullPath = join11(pendingDir, filename);
|
|
38138
38050
|
if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
|
|
38139
38051
|
op(fullPath);
|
|
38140
38052
|
applied++;
|
|
@@ -38144,12 +38056,12 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
|
|
|
38144
38056
|
|
|
38145
38057
|
// src/recovery-ledger.ts
|
|
38146
38058
|
import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
|
|
38147
|
-
import { join as
|
|
38059
|
+
import { join as join12 } from "path";
|
|
38148
38060
|
function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p2) => existsSync6(p2)) {
|
|
38149
38061
|
if (!ledgerDir || !markerName) return false;
|
|
38150
38062
|
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
|
|
38151
38063
|
try {
|
|
38152
|
-
return exists(
|
|
38064
|
+
return exists(join12(ledgerDir, markerName));
|
|
38153
38065
|
} catch {
|
|
38154
38066
|
return false;
|
|
38155
38067
|
}
|
|
@@ -38160,14 +38072,14 @@ function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p2) => {
|
|
|
38160
38072
|
if (!ledgerDir || !markerName) return;
|
|
38161
38073
|
if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
|
|
38162
38074
|
try {
|
|
38163
|
-
unlink(
|
|
38075
|
+
unlink(join12(ledgerDir, markerName));
|
|
38164
38076
|
} catch {
|
|
38165
38077
|
}
|
|
38166
38078
|
}
|
|
38167
38079
|
|
|
38168
38080
|
// src/inbound-delivery-ledger.ts
|
|
38169
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as
|
|
38170
|
-
import { join as
|
|
38081
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as readFileSync13, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
|
|
38082
|
+
import { join as join13 } from "path";
|
|
38171
38083
|
function safeInboundId(inboundId) {
|
|
38172
38084
|
return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
38173
38085
|
}
|
|
@@ -38176,7 +38088,7 @@ var defaultDeps = {
|
|
|
38176
38088
|
writeFile: (path, data) => writeFileSync8(path, data, "utf8"),
|
|
38177
38089
|
rename: (from, to) => renameSync5(from, to),
|
|
38178
38090
|
readdir: (dir) => readdirSync4(dir),
|
|
38179
|
-
readFile: (path) =>
|
|
38091
|
+
readFile: (path) => readFileSync13(path, "utf8"),
|
|
38180
38092
|
exists: (path) => existsSync7(path)
|
|
38181
38093
|
};
|
|
38182
38094
|
function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
@@ -38185,7 +38097,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
|
|
|
38185
38097
|
if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
|
|
38186
38098
|
try {
|
|
38187
38099
|
deps.mkdir(dir);
|
|
38188
|
-
const final =
|
|
38100
|
+
const final = join13(dir, `${safe}.json`);
|
|
38189
38101
|
const tmp = `${final}.tmp`;
|
|
38190
38102
|
deps.writeFile(tmp, JSON.stringify(record2));
|
|
38191
38103
|
deps.rename(tmp, final);
|
|
@@ -38390,14 +38302,14 @@ function createKanbanCardActiveClient(args) {
|
|
|
38390
38302
|
import {
|
|
38391
38303
|
existsSync as existsSync8,
|
|
38392
38304
|
mkdirSync as mkdirSync8,
|
|
38393
|
-
readFileSync as
|
|
38305
|
+
readFileSync as readFileSync14,
|
|
38394
38306
|
renameSync as renameSync6,
|
|
38395
38307
|
statSync as statSync4,
|
|
38396
38308
|
unlinkSync as unlinkSync7,
|
|
38397
38309
|
utimesSync,
|
|
38398
38310
|
writeFileSync as writeFileSync9
|
|
38399
38311
|
} from "fs";
|
|
38400
|
-
import { join as
|
|
38312
|
+
import { join as join14 } from "path";
|
|
38401
38313
|
var STALE_LOCK_MS = 9e4;
|
|
38402
38314
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
38403
38315
|
function defaultIsPidAlive(pid) {
|
|
@@ -38420,7 +38332,7 @@ function acquireMcpSpawnLock(args) {
|
|
|
38420
38332
|
const nowMs = options.nowMs ?? (() => Date.now());
|
|
38421
38333
|
const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
|
|
38422
38334
|
const staleMs = options.staleMs ?? STALE_LOCK_MS;
|
|
38423
|
-
const path =
|
|
38335
|
+
const path = join14(agentDir, basename2);
|
|
38424
38336
|
const existing = readLockHolder(path);
|
|
38425
38337
|
if (existing) {
|
|
38426
38338
|
if (existing.pid === selfPid) {
|
|
@@ -38487,7 +38399,7 @@ function defaultLockMtimeMs(path) {
|
|
|
38487
38399
|
function readLockHolder(path) {
|
|
38488
38400
|
if (!existsSync8(path)) return null;
|
|
38489
38401
|
try {
|
|
38490
|
-
const raw =
|
|
38402
|
+
const raw = readFileSync14(path, "utf8");
|
|
38491
38403
|
const parsed = JSON.parse(raw);
|
|
38492
38404
|
const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
|
|
38493
38405
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
@@ -38499,8 +38411,8 @@ function readLockHolder(path) {
|
|
|
38499
38411
|
}
|
|
38500
38412
|
|
|
38501
38413
|
// src/ack-reaction.ts
|
|
38502
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
38503
|
-
import { join as
|
|
38414
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync15, writeFileSync as writeFileSync10 } from "fs";
|
|
38415
|
+
import { join as join15 } from "path";
|
|
38504
38416
|
var REPLY_WEDGED_THRESHOLD_MS = 5 * 60 * 1e3;
|
|
38505
38417
|
var ACK_STARTUP_GRACE_MS = 6e4;
|
|
38506
38418
|
var ACK_PANE_FRESH_THRESHOLD_MS = 6e4;
|
|
@@ -38573,7 +38485,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
|
|
|
38573
38485
|
function readGiveUpSignal(path, now = Date.now()) {
|
|
38574
38486
|
if (!path) return null;
|
|
38575
38487
|
try {
|
|
38576
|
-
const raw = JSON.parse(
|
|
38488
|
+
const raw = JSON.parse(readFileSync15(path, "utf8"));
|
|
38577
38489
|
if (typeof raw.gave_up_at !== "string") return null;
|
|
38578
38490
|
const t = Date.parse(raw.gave_up_at);
|
|
38579
38491
|
if (!Number.isFinite(t) || t > now) return null;
|
|
@@ -38614,7 +38526,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
|
|
|
38614
38526
|
if (!name.endsWith(".json")) continue;
|
|
38615
38527
|
let receivedAt;
|
|
38616
38528
|
try {
|
|
38617
|
-
const raw = JSON.parse(
|
|
38529
|
+
const raw = JSON.parse(readFileSync15(join15(dir, name), "utf-8"));
|
|
38618
38530
|
if (raw.discretionary === true) continue;
|
|
38619
38531
|
if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
|
|
38620
38532
|
receivedAt = raw.received_at;
|
|
@@ -38691,14 +38603,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
|
|
|
38691
38603
|
}
|
|
38692
38604
|
var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
|
|
38693
38605
|
function deflectionCounterPath(agentDir, channel) {
|
|
38694
|
-
return
|
|
38606
|
+
return join15(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
|
|
38695
38607
|
}
|
|
38696
38608
|
function recordChannelDeflection(agentDir, channel, cause) {
|
|
38697
38609
|
if (!agentDir) return;
|
|
38698
38610
|
const path = deflectionCounterPath(agentDir, channel);
|
|
38699
38611
|
let counts = {};
|
|
38700
38612
|
try {
|
|
38701
|
-
const parsed = JSON.parse(
|
|
38613
|
+
const parsed = JSON.parse(readFileSync15(path, "utf-8"));
|
|
38702
38614
|
if (parsed && typeof parsed === "object") counts = parsed;
|
|
38703
38615
|
} catch {
|
|
38704
38616
|
}
|
|
@@ -38779,7 +38691,7 @@ function redactId(id) {
|
|
|
38779
38691
|
}
|
|
38780
38692
|
var BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
|
|
38781
38693
|
var AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME ?? "unknown";
|
|
38782
|
-
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
38694
|
+
var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join16(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
|
|
38783
38695
|
var AGT_HOST = process.env.AGT_HOST ?? null;
|
|
38784
38696
|
var AGT_API_KEY = process.env.AGT_API_KEY ?? null;
|
|
38785
38697
|
var AGT_AGENT_ID = process.env.AGT_AGENT_ID ?? null;
|
|
@@ -38882,11 +38794,11 @@ var peerRateLimiter = peerRateApiClient && parsePeerAgentModeEnv(process.env.TEL
|
|
|
38882
38794
|
log: (line) => process.stderr.write(`telegram-channel(${AGENT_CODE_NAME}): ${line}
|
|
38883
38795
|
`)
|
|
38884
38796
|
}) : createPeerRateLimiter();
|
|
38885
|
-
var PEER_PRESENCE_STATE_FILE = TELEGRAM_AGENT_DIR ?
|
|
38797
|
+
var PEER_PRESENCE_STATE_FILE = TELEGRAM_AGENT_DIR ? join16(TELEGRAM_AGENT_DIR, "telegram-peer-presence.json") : null;
|
|
38886
38798
|
function readPeerPresenceState() {
|
|
38887
38799
|
if (!PEER_PRESENCE_STATE_FILE) return null;
|
|
38888
38800
|
try {
|
|
38889
|
-
const parsed = JSON.parse(
|
|
38801
|
+
const parsed = JSON.parse(readFileSync16(PEER_PRESENCE_STATE_FILE, "utf-8"));
|
|
38890
38802
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
38891
38803
|
return parsed;
|
|
38892
38804
|
} catch {
|
|
@@ -38921,9 +38833,9 @@ if (!BOT_TOKEN) {
|
|
|
38921
38833
|
var stderrLogStream = null;
|
|
38922
38834
|
if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
|
|
38923
38835
|
try {
|
|
38924
|
-
const logDir =
|
|
38836
|
+
const logDir = join16(homedir6(), ".augmented", AGENT_CODE_NAME);
|
|
38925
38837
|
mkdirSync9(logDir, { recursive: true });
|
|
38926
|
-
stderrLogStream = createWriteStream(
|
|
38838
|
+
stderrLogStream = createWriteStream(join16(logDir, "telegram-channel-stderr.log"), {
|
|
38927
38839
|
flags: "a",
|
|
38928
38840
|
mode: 384
|
|
38929
38841
|
});
|
|
@@ -39112,24 +39024,17 @@ function armTelegramUsageLimitWatch(args) {
|
|
|
39112
39024
|
void (async () => {
|
|
39113
39025
|
try {
|
|
39114
39026
|
const refusal = await watchForRateLimitRefusal({ sinceMs: args.sinceMs });
|
|
39115
|
-
const action = decideRefusalAction({
|
|
39027
|
+
const action = decideRefusalAction({ refusal });
|
|
39116
39028
|
if (action === "none") return;
|
|
39117
39029
|
if (action === "missing-reset") {
|
|
39118
39030
|
process.stderr.write(
|
|
39119
|
-
`telegram-channel(${AGENT_CODE_NAME}): [usage-limit-reactive]
|
|
39031
|
+
`telegram-channel(${AGENT_CODE_NAME}): [usage-limit-reactive] refusal detected for chat=${redactId(args.chatId)} but no reset time in it (${describeUnparsedRefusal(refusal?.text)}) - no notice
|
|
39120
39032
|
`
|
|
39121
39033
|
);
|
|
39122
39034
|
return;
|
|
39123
39035
|
}
|
|
39124
39036
|
const resetsAt = refusal?.resetsAt;
|
|
39125
39037
|
if (!resetsAt) return;
|
|
39126
|
-
if (action === "shadow-log") {
|
|
39127
|
-
process.stderr.write(
|
|
39128
|
-
`telegram-channel(${AGENT_CODE_NAME}): [usage-limit-reactive] mode=shadow WOULD notify chat=${redactId(args.chatId)} resets=${resetsAt.toISOString()}
|
|
39129
|
-
`
|
|
39130
|
-
);
|
|
39131
|
-
return;
|
|
39132
|
-
}
|
|
39133
39038
|
await maybeSendTelegramUsageLimitNotice({
|
|
39134
39039
|
chatId: args.chatId,
|
|
39135
39040
|
senderId: args.senderId,
|
|
@@ -39360,7 +39265,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
39360
39265
|
let paneLogFreshAgeMs = null;
|
|
39361
39266
|
if (AGENT_DIR) {
|
|
39362
39267
|
try {
|
|
39363
|
-
const paneMtimeMs = statSync5(
|
|
39268
|
+
const paneMtimeMs = statSync5(join16(AGENT_DIR, "pane.log")).mtimeMs;
|
|
39364
39269
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
39365
39270
|
} catch {
|
|
39366
39271
|
}
|
|
@@ -39390,7 +39295,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
|
|
|
39390
39295
|
function __resetBusyAckNoticeThrottle() {
|
|
39391
39296
|
lastBusyAckNoticeAt.clear();
|
|
39392
39297
|
}
|
|
39393
|
-
var RESTART_FLAGS_DIR =
|
|
39298
|
+
var RESTART_FLAGS_DIR = join16(homedir6(), ".augmented", "restart-flags");
|
|
39394
39299
|
function actuateHostRestartTelegram() {
|
|
39395
39300
|
return actuateHostRestart({
|
|
39396
39301
|
agtHost: AGT_HOST,
|
|
@@ -39775,7 +39680,7 @@ async function handleRestartCommand(opts) {
|
|
|
39775
39680
|
if (!existsSync9(RESTART_FLAGS_DIR)) {
|
|
39776
39681
|
mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
|
|
39777
39682
|
}
|
|
39778
|
-
const flagPath =
|
|
39683
|
+
const flagPath = join16(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
|
|
39779
39684
|
const flag = {
|
|
39780
39685
|
codeName: AGENT_CODE_NAME,
|
|
39781
39686
|
source: "telegram",
|
|
@@ -40181,16 +40086,16 @@ async function classifyRestartCommand(text) {
|
|
|
40181
40086
|
if (!ours) return "verification_failed";
|
|
40182
40087
|
return target === ours ? "act" : "ignore";
|
|
40183
40088
|
}
|
|
40184
|
-
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ?
|
|
40185
|
-
var PENDING_INBOUND_DIR = AGENT_DIR ?
|
|
40186
|
-
var RECOVERY_OUTBOX_DIR = AGENT_DIR ?
|
|
40187
|
-
var RECOVERY_LEDGER_DIR = AGENT_DIR ?
|
|
40188
|
-
var DELIVERY_LEDGER_DIR = AGENT_DIR ?
|
|
40189
|
-
var RESTART_CONFIRM_FILE = AGENT_DIR ?
|
|
40089
|
+
var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join16(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
|
|
40090
|
+
var PENDING_INBOUND_DIR = AGENT_DIR ? join16(AGENT_DIR, "telegram-pending-inbound") : null;
|
|
40091
|
+
var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join16(AGENT_DIR, "telegram-recovery-outbox") : null;
|
|
40092
|
+
var RECOVERY_LEDGER_DIR = AGENT_DIR ? join16(AGENT_DIR, ".agt-telegram-recovery-ledger") : null;
|
|
40093
|
+
var DELIVERY_LEDGER_DIR = AGENT_DIR ? join16(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
|
|
40094
|
+
var RESTART_CONFIRM_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-restart-confirm.json") : null;
|
|
40190
40095
|
var TELEGRAM_PROCESS_BOOT_MS = Date.now();
|
|
40191
|
-
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ?
|
|
40192
|
-
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ?
|
|
40193
|
-
var TELEGRAM_OFFSET_FILE = AGENT_DIR ?
|
|
40096
|
+
var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-recent-dms.json") : null;
|
|
40097
|
+
var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-channel-add-restart.json") : null;
|
|
40098
|
+
var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-getupdates-offset.json") : null;
|
|
40194
40099
|
var recentDms = /* @__PURE__ */ new Map();
|
|
40195
40100
|
var recentDmPersister = TELEGRAM_RECENT_DMS_FILE ? createRecentDmPersister({
|
|
40196
40101
|
filePath: TELEGRAM_RECENT_DMS_FILE,
|
|
@@ -40245,7 +40150,7 @@ function safeMarkerName(chatId, messageId) {
|
|
|
40245
40150
|
}
|
|
40246
40151
|
function pendingInboundPath(chatId, messageId) {
|
|
40247
40152
|
if (!PENDING_INBOUND_DIR) return null;
|
|
40248
|
-
return
|
|
40153
|
+
return join16(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
|
|
40249
40154
|
}
|
|
40250
40155
|
function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false, payload) {
|
|
40251
40156
|
const path = pendingInboundPath(chatId, messageId);
|
|
@@ -40293,7 +40198,7 @@ function rewriteTelegramMarkerInPlace(path, marker) {
|
|
|
40293
40198
|
function clearTelegramMarkerFileWithHeal(fullPath) {
|
|
40294
40199
|
let marker = null;
|
|
40295
40200
|
try {
|
|
40296
|
-
marker = JSON.parse(
|
|
40201
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
40297
40202
|
} catch {
|
|
40298
40203
|
}
|
|
40299
40204
|
if (marker && decideRecoveryHeal({
|
|
@@ -40316,7 +40221,7 @@ function markTelegramMarkerPromisedInPlace(fullPath) {
|
|
|
40316
40221
|
function markTelegramMarkerEngagedInPlace(fullPath, opts) {
|
|
40317
40222
|
let marker;
|
|
40318
40223
|
try {
|
|
40319
|
-
marker = JSON.parse(
|
|
40224
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
40320
40225
|
} catch {
|
|
40321
40226
|
return false;
|
|
40322
40227
|
}
|
|
@@ -40331,7 +40236,7 @@ function markTelegramMarkerEngagedInPlace(fullPath, opts) {
|
|
|
40331
40236
|
rewriteTelegramMarkerInPlace(fullPath, marker);
|
|
40332
40237
|
if (!opts.promise) return false;
|
|
40333
40238
|
try {
|
|
40334
|
-
const readBack = JSON.parse(
|
|
40239
|
+
const readBack = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
40335
40240
|
return typeof readBack.promised_at === "string" && readBack.promised_at.length > 0;
|
|
40336
40241
|
} catch {
|
|
40337
40242
|
return false;
|
|
@@ -40340,7 +40245,7 @@ function markTelegramMarkerEngagedInPlace(fullPath, opts) {
|
|
|
40340
40245
|
function markTelegramMarkerSeenWithHeal(fullPath) {
|
|
40341
40246
|
let marker = null;
|
|
40342
40247
|
try {
|
|
40343
|
-
marker = JSON.parse(
|
|
40248
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
40344
40249
|
} catch {
|
|
40345
40250
|
return;
|
|
40346
40251
|
}
|
|
@@ -40355,7 +40260,7 @@ function markTelegramMarkerSeenWithHeal(fullPath) {
|
|
|
40355
40260
|
function markTelegramMarkerPromisedWithHeal(fullPath) {
|
|
40356
40261
|
let marker = null;
|
|
40357
40262
|
try {
|
|
40358
|
-
marker = JSON.parse(
|
|
40263
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
40359
40264
|
} catch {
|
|
40360
40265
|
return;
|
|
40361
40266
|
}
|
|
@@ -40373,7 +40278,7 @@ function readPendingInboundMarker(chatId, messageId) {
|
|
|
40373
40278
|
const path = pendingInboundPath(chatId, messageId);
|
|
40374
40279
|
if (!path || !existsSync9(path)) return null;
|
|
40375
40280
|
try {
|
|
40376
|
-
return JSON.parse(
|
|
40281
|
+
return JSON.parse(readFileSync16(path, "utf-8"));
|
|
40377
40282
|
} catch {
|
|
40378
40283
|
return null;
|
|
40379
40284
|
}
|
|
@@ -40393,10 +40298,10 @@ function nextRetryName(filename) {
|
|
|
40393
40298
|
async function processRecoveryOutboxFile(filename) {
|
|
40394
40299
|
if (!RECOVERY_OUTBOX_DIR) return;
|
|
40395
40300
|
if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
|
|
40396
|
-
const fullPath =
|
|
40301
|
+
const fullPath = join16(RECOVERY_OUTBOX_DIR, filename);
|
|
40397
40302
|
let payload;
|
|
40398
40303
|
try {
|
|
40399
|
-
const raw =
|
|
40304
|
+
const raw = readFileSync16(fullPath, "utf-8");
|
|
40400
40305
|
payload = JSON.parse(raw);
|
|
40401
40306
|
} catch (err) {
|
|
40402
40307
|
process.stderr.write(
|
|
@@ -40490,7 +40395,7 @@ async function processRecoveryOutboxFile(filename) {
|
|
|
40490
40395
|
const next = nextRetryName(filename);
|
|
40491
40396
|
if (next) {
|
|
40492
40397
|
try {
|
|
40493
|
-
renameSync7(fullPath,
|
|
40398
|
+
renameSync7(fullPath, join16(RECOVERY_OUTBOX_DIR, next.next));
|
|
40494
40399
|
if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
|
|
40495
40400
|
process.stderr.write(
|
|
40496
40401
|
`telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
|
|
@@ -40531,7 +40436,7 @@ function scanRecoveryRetries() {
|
|
|
40531
40436
|
if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
|
|
40532
40437
|
let mtimeMs;
|
|
40533
40438
|
try {
|
|
40534
|
-
mtimeMs = statSync5(
|
|
40439
|
+
mtimeMs = statSync5(join16(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
|
|
40535
40440
|
} catch {
|
|
40536
40441
|
continue;
|
|
40537
40442
|
}
|
|
@@ -40561,7 +40466,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
40561
40466
|
const watcher = watch(RECOVERY_OUTBOX_DIR, (event, filename) => {
|
|
40562
40467
|
if (event !== "rename" || !filename) return;
|
|
40563
40468
|
if (!isFirstAttemptOutboxFile(filename)) return;
|
|
40564
|
-
if (existsSync9(
|
|
40469
|
+
if (existsSync9(join16(RECOVERY_OUTBOX_DIR, filename))) {
|
|
40565
40470
|
void processRecoveryOutboxFile(filename);
|
|
40566
40471
|
}
|
|
40567
40472
|
});
|
|
@@ -40576,7 +40481,7 @@ function startRecoveryOutboxWatcher() {
|
|
|
40576
40481
|
retryTimer.unref?.();
|
|
40577
40482
|
}
|
|
40578
40483
|
startRecoveryOutboxWatcher();
|
|
40579
|
-
var NOTICE_OUTBOX_DIR = AGENT_DIR ?
|
|
40484
|
+
var NOTICE_OUTBOX_DIR = AGENT_DIR ? join16(AGENT_DIR, "telegram-notice-outbox") : null;
|
|
40580
40485
|
var NOTICE_MAX_AGE_MS = 9e4;
|
|
40581
40486
|
var NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
|
|
40582
40487
|
async function processNoticeOutboxFile(filename) {
|
|
@@ -40584,7 +40489,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
40584
40489
|
if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
|
|
40585
40490
|
if (NOTICE_INFLIGHT.has(filename)) return;
|
|
40586
40491
|
NOTICE_INFLIGHT.add(filename);
|
|
40587
|
-
const fullPath =
|
|
40492
|
+
const fullPath = join16(NOTICE_OUTBOX_DIR, filename);
|
|
40588
40493
|
try {
|
|
40589
40494
|
let mtimeMs;
|
|
40590
40495
|
try {
|
|
@@ -40601,7 +40506,7 @@ async function processNoticeOutboxFile(filename) {
|
|
|
40601
40506
|
}
|
|
40602
40507
|
let payload;
|
|
40603
40508
|
try {
|
|
40604
|
-
const parsed = JSON.parse(
|
|
40509
|
+
const parsed = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
40605
40510
|
if (!parsed || typeof parsed !== "object") throw new Error("not an object");
|
|
40606
40511
|
payload = parsed;
|
|
40607
40512
|
} catch {
|
|
@@ -40678,7 +40583,7 @@ function startNoticeOutboxWatcher() {
|
|
|
40678
40583
|
try {
|
|
40679
40584
|
const watcher = watch(NOTICE_OUTBOX_DIR, (event, filename) => {
|
|
40680
40585
|
if (event !== "rename" || !filename) return;
|
|
40681
|
-
if (existsSync9(
|
|
40586
|
+
if (existsSync9(join16(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
|
|
40682
40587
|
});
|
|
40683
40588
|
watcher.unref?.();
|
|
40684
40589
|
} catch (err) {
|
|
@@ -40712,10 +40617,10 @@ function sweepTelegramStaleMarkers(thresholdMs) {
|
|
|
40712
40617
|
for (const filename of filenames) {
|
|
40713
40618
|
if (!filename.endsWith(".json")) continue;
|
|
40714
40619
|
if (filename.endsWith(".tmp")) continue;
|
|
40715
|
-
const fullPath =
|
|
40620
|
+
const fullPath = join16(PENDING_INBOUND_DIR, filename);
|
|
40716
40621
|
let marker;
|
|
40717
40622
|
try {
|
|
40718
|
-
marker = JSON.parse(
|
|
40623
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
40719
40624
|
} catch (err) {
|
|
40720
40625
|
process.stderr.write(
|
|
40721
40626
|
`telegram-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactId(filename)}: ${err.message}
|
|
@@ -40768,13 +40673,13 @@ var orphanSweepTimer = setInterval(() => {
|
|
|
40768
40673
|
checkWatchdogGiveUpNotice();
|
|
40769
40674
|
}, orphanSweepIntervalMs());
|
|
40770
40675
|
orphanSweepTimer.unref?.();
|
|
40771
|
-
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ?
|
|
40676
|
+
var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join16(AGENT_DIR, "channel-progress-heartbeat.json") : null;
|
|
40772
40677
|
var telegramTrackedProgress = null;
|
|
40773
40678
|
var telegramProgressTickRunning = false;
|
|
40774
40679
|
function readTelegramProgressHeartbeat() {
|
|
40775
40680
|
if (!TELEGRAM_PROGRESS_HEARTBEAT_PATH || !existsSync9(TELEGRAM_PROGRESS_HEARTBEAT_PATH)) return null;
|
|
40776
40681
|
try {
|
|
40777
|
-
return parseProgressHeartbeat(
|
|
40682
|
+
return parseProgressHeartbeat(readFileSync16(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
|
|
40778
40683
|
} catch {
|
|
40779
40684
|
return null;
|
|
40780
40685
|
}
|
|
@@ -40801,7 +40706,7 @@ function findTelegramProgressTarget() {
|
|
|
40801
40706
|
if (!name.endsWith(".json")) continue;
|
|
40802
40707
|
let m;
|
|
40803
40708
|
try {
|
|
40804
|
-
m = JSON.parse(
|
|
40709
|
+
m = JSON.parse(readFileSync16(join16(PENDING_INBOUND_DIR, name), "utf-8"));
|
|
40805
40710
|
} catch {
|
|
40806
40711
|
continue;
|
|
40807
40712
|
}
|
|
@@ -40932,7 +40837,7 @@ function listPendingInboundChatIds() {
|
|
|
40932
40837
|
if (!name.endsWith(".json")) continue;
|
|
40933
40838
|
try {
|
|
40934
40839
|
const marker = JSON.parse(
|
|
40935
|
-
|
|
40840
|
+
readFileSync16(join16(PENDING_INBOUND_DIR, name), "utf8")
|
|
40936
40841
|
);
|
|
40937
40842
|
if (typeof marker.seen_at === "string" && marker.seen_at) continue;
|
|
40938
40843
|
if (typeof marker.chat_id === "string" && marker.chat_id) chats.add(marker.chat_id);
|
|
@@ -41052,7 +40957,7 @@ async function notifyWatchdogGiveUp(chatId, reason) {
|
|
|
41052
40957
|
}
|
|
41053
40958
|
function checkWatchdogGiveUpNotice() {
|
|
41054
40959
|
if (!AGENT_DIR) return;
|
|
41055
|
-
const signal = readGiveUpSignal(
|
|
40960
|
+
const signal = readGiveUpSignal(join16(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
|
|
41056
40961
|
const signalAtMs = signal?.atMs ?? null;
|
|
41057
40962
|
const act = decideGiveUpNotice({
|
|
41058
40963
|
signalAtMs,
|
|
@@ -41348,7 +41253,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
41348
41253
|
isError: true
|
|
41349
41254
|
};
|
|
41350
41255
|
}
|
|
41351
|
-
const allowedRoot = resolve2(
|
|
41256
|
+
const allowedRoot = resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project") + "/";
|
|
41352
41257
|
const resolvedPath = resolve2(path);
|
|
41353
41258
|
if (!resolvedPath.startsWith(allowedRoot)) {
|
|
41354
41259
|
return {
|
|
@@ -41396,7 +41301,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
41396
41301
|
}
|
|
41397
41302
|
let realRoot = allowedRoot;
|
|
41398
41303
|
try {
|
|
41399
|
-
realRoot = realpathSync(resolve2(
|
|
41304
|
+
realRoot = realpathSync(resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project")) + "/";
|
|
41400
41305
|
} catch {
|
|
41401
41306
|
}
|
|
41402
41307
|
if (!realPath.startsWith(realRoot)) {
|
|
@@ -41425,7 +41330,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
41425
41330
|
isError: true
|
|
41426
41331
|
};
|
|
41427
41332
|
}
|
|
41428
|
-
bytes =
|
|
41333
|
+
bytes = readFileSync16(realPath);
|
|
41429
41334
|
} catch (err) {
|
|
41430
41335
|
return { content: [{ type: "text", text: `Failed to read file: ${err.message}` }], isError: true };
|
|
41431
41336
|
}
|
|
@@ -41994,7 +41899,7 @@ async function replayPendingTelegramMarkers() {
|
|
|
41994
41899
|
let paneFreshAgeMs = null;
|
|
41995
41900
|
if (AGENT_DIR) {
|
|
41996
41901
|
try {
|
|
41997
|
-
paneFreshAgeMs = Math.max(0, now - statSync5(
|
|
41902
|
+
paneFreshAgeMs = Math.max(0, now - statSync5(join16(AGENT_DIR, "pane.log")).mtimeMs);
|
|
41998
41903
|
} catch {
|
|
41999
41904
|
}
|
|
42000
41905
|
}
|
|
@@ -42002,10 +41907,10 @@ async function replayPendingTelegramMarkers() {
|
|
|
42002
41907
|
const entries = [];
|
|
42003
41908
|
for (const name of filenames) {
|
|
42004
41909
|
if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
|
|
42005
|
-
const fullPath =
|
|
41910
|
+
const fullPath = join16(PENDING_INBOUND_DIR, name);
|
|
42006
41911
|
let marker;
|
|
42007
41912
|
try {
|
|
42008
|
-
marker = JSON.parse(
|
|
41913
|
+
marker = JSON.parse(readFileSync16(fullPath, "utf-8"));
|
|
42009
41914
|
} catch {
|
|
42010
41915
|
continue;
|
|
42011
41916
|
}
|
|
@@ -42491,21 +42396,6 @@ async function pollLoop() {
|
|
|
42491
42396
|
});
|
|
42492
42397
|
continue;
|
|
42493
42398
|
}
|
|
42494
|
-
const reactiveMode = resolveUsageLimitReactiveMode();
|
|
42495
|
-
const telegramUsageLimitUntil = !isFromBot && shouldReadPredictiveMarker(reactiveMode) ? readUsageLimitUntil({ codeName: AGENT_CODE_NAME }) : null;
|
|
42496
|
-
if (telegramUsageLimitUntil) {
|
|
42497
|
-
process.stderr.write(
|
|
42498
|
-
`telegram-channel(${AGENT_CODE_NAME}): usage-limit active until ${telegramUsageLimitUntil.toISOString()} \u2014 notice, no dispatch (chat=${redactId(chatId)})
|
|
42499
|
-
`
|
|
42500
|
-
);
|
|
42501
|
-
await maybeSendTelegramUsageLimitNotice({
|
|
42502
|
-
chatId,
|
|
42503
|
-
senderId: userId,
|
|
42504
|
-
messageThreadId: msg.message_thread_id,
|
|
42505
|
-
limitedUntil: telegramUsageLimitUntil
|
|
42506
|
-
});
|
|
42507
|
-
continue;
|
|
42508
|
-
}
|
|
42509
42399
|
if (isFromBot && classification?.kind === "peer-ingress") {
|
|
42510
42400
|
const limit = await peerRateLimiter.recordInboundPeer(
|
|
42511
42401
|
chatId,
|
|
@@ -42556,7 +42446,7 @@ async function pollLoop() {
|
|
|
42556
42446
|
let paneLogFreshAgeMs = null;
|
|
42557
42447
|
if (AGENT_DIR) {
|
|
42558
42448
|
try {
|
|
42559
|
-
const paneMtimeMs = statSync5(
|
|
42449
|
+
const paneMtimeMs = statSync5(join16(AGENT_DIR, "pane.log")).mtimeMs;
|
|
42560
42450
|
paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
|
|
42561
42451
|
} catch {
|
|
42562
42452
|
}
|
|
@@ -42660,16 +42550,13 @@ async function pollLoop() {
|
|
|
42660
42550
|
method: "notifications/claude/channel",
|
|
42661
42551
|
params: channelPayload
|
|
42662
42552
|
});
|
|
42663
|
-
|
|
42664
|
-
mode: reactiveMode,
|
|
42553
|
+
if (shouldArmWatch({
|
|
42665
42554
|
isBot: isFromBot || !!peerAgentMeta,
|
|
42666
42555
|
// Every Telegram inbound that reaches here owes a reply — there is no
|
|
42667
42556
|
// discretionary auto-follow variant as there is on Slack.
|
|
42668
42557
|
replyOwed: true
|
|
42669
|
-
})
|
|
42670
|
-
if (watchMode) {
|
|
42558
|
+
})) {
|
|
42671
42559
|
armTelegramUsageLimitWatch({
|
|
42672
|
-
mode: watchMode,
|
|
42673
42560
|
chatId,
|
|
42674
42561
|
senderId: userId,
|
|
42675
42562
|
...msg.message_thread_id != null ? { messageThreadId: msg.message_thread_id } : {},
|