@integrity-labs/agt-cli 0.28.233 → 0.28.235
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-EXBFINF4.js → chunk-2KTGXFX5.js} +3 -3
- package/dist/{chunk-LTBALKME.js → chunk-PYVEJMY2.js} +7 -22
- package/dist/chunk-PYVEJMY2.js.map +1 -0
- package/dist/{claude-pair-runtime-MTIOLC2O.js → claude-pair-runtime-2ZFH6K4I.js} +2 -2
- package/dist/lib/manager-worker.js +9 -9
- package/dist/mcp/slack-channel.js +29 -128
- package/dist/mcp/telegram-channel.js +9 -90
- package/dist/{persistent-session-BWE63K2J.js → persistent-session-LVDRHYX7.js} +2 -2
- package/dist/{responsiveness-probe-NV2I7OCG.js → responsiveness-probe-UW5TXKMS.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-LTBALKME.js.map +0 -1
- /package/dist/{chunk-EXBFINF4.js.map → chunk-2KTGXFX5.js.map} +0 -0
- /package/dist/{claude-pair-runtime-MTIOLC2O.js.map → claude-pair-runtime-2ZFH6K4I.js.map} +0 -0
- /package/dist/{persistent-session-BWE63K2J.js.map → persistent-session-LVDRHYX7.js.map} +0 -0
- /package/dist/{responsiveness-probe-NV2I7OCG.js.map → responsiveness-probe-UW5TXKMS.js.map} +0 -0
|
@@ -100,7 +100,7 @@ async function spawnPairSession(session) {
|
|
|
100
100
|
return { ok: true };
|
|
101
101
|
} catch {
|
|
102
102
|
}
|
|
103
|
-
const { resolveClaudeBinary } = await import("./persistent-session-
|
|
103
|
+
const { resolveClaudeBinary } = await import("./persistent-session-LVDRHYX7.js");
|
|
104
104
|
const claudeBin = resolveClaudeBinary();
|
|
105
105
|
const pairEnv = {
|
|
106
106
|
...process.env,
|
|
@@ -373,4 +373,4 @@ export {
|
|
|
373
373
|
startClaudePair,
|
|
374
374
|
submitClaudePairCode
|
|
375
375
|
};
|
|
376
|
-
//# sourceMappingURL=claude-pair-runtime-
|
|
376
|
+
//# sourceMappingURL=claude-pair-runtime-2ZFH6K4I.js.map
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
requireHost,
|
|
38
38
|
safeWriteJsonAtomic,
|
|
39
39
|
setConfigHash
|
|
40
|
-
} from "../chunk-
|
|
40
|
+
} from "../chunk-2KTGXFX5.js";
|
|
41
41
|
import {
|
|
42
42
|
getProjectDir as getProjectDir2,
|
|
43
43
|
getReadyTasks,
|
|
@@ -122,7 +122,7 @@ import {
|
|
|
122
122
|
takeZombieDetection,
|
|
123
123
|
transcriptActivityAgeSeconds,
|
|
124
124
|
writeEgressAllowlist
|
|
125
|
-
} from "../chunk-
|
|
125
|
+
} from "../chunk-PYVEJMY2.js";
|
|
126
126
|
import {
|
|
127
127
|
reapOrphanChannelMcps
|
|
128
128
|
} from "../chunk-XWVM4KPK.js";
|
|
@@ -6426,7 +6426,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
6426
6426
|
var lastVersionCheckAt = 0;
|
|
6427
6427
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6428
6428
|
var lastResponsivenessProbeAt = 0;
|
|
6429
|
-
var agtCliVersion = true ? "0.28.
|
|
6429
|
+
var agtCliVersion = true ? "0.28.235" : "dev";
|
|
6430
6430
|
function resolveBrewPath(execFileSync2) {
|
|
6431
6431
|
try {
|
|
6432
6432
|
const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -7351,7 +7351,7 @@ async function pollCycle() {
|
|
|
7351
7351
|
}
|
|
7352
7352
|
try {
|
|
7353
7353
|
const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
|
|
7354
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
7354
|
+
const { collectDiagnostics } = await import("../persistent-session-LVDRHYX7.js");
|
|
7355
7355
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
7356
7356
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
|
|
7357
7357
|
let tailscaleHostname;
|
|
@@ -7499,7 +7499,7 @@ async function pollCycle() {
|
|
|
7499
7499
|
const {
|
|
7500
7500
|
collectResponsivenessProbes,
|
|
7501
7501
|
getResponsivenessIntervalMs
|
|
7502
|
-
} = await import("../responsiveness-probe-
|
|
7502
|
+
} = await import("../responsiveness-probe-UW5TXKMS.js");
|
|
7503
7503
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
7504
7504
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
7505
7505
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -7531,7 +7531,7 @@ async function pollCycle() {
|
|
|
7531
7531
|
collectResponsivenessProbes,
|
|
7532
7532
|
livePendingInboundOldestAgeSeconds,
|
|
7533
7533
|
parkPendingInbound
|
|
7534
|
-
} = await import("../responsiveness-probe-
|
|
7534
|
+
} = await import("../responsiveness-probe-UW5TXKMS.js");
|
|
7535
7535
|
const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
|
|
7536
7536
|
const wedgeNow = /* @__PURE__ */ new Date();
|
|
7537
7537
|
const liveAgents = agentState.persistentSessionAgents;
|
|
@@ -7827,7 +7827,7 @@ async function pollCycle() {
|
|
|
7827
7827
|
if (restartedCodeNames.length > 0) {
|
|
7828
7828
|
void (async () => {
|
|
7829
7829
|
try {
|
|
7830
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
7830
|
+
const { collectDiagnostics } = await import("../persistent-session-LVDRHYX7.js");
|
|
7831
7831
|
const freshDiagnostics = collectDiagnostics(restartedCodeNames);
|
|
7832
7832
|
await api.post("/host/heartbeat", {
|
|
7833
7833
|
host_id: hostId,
|
|
@@ -10335,7 +10335,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
|
|
|
10335
10335
|
void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
|
|
10336
10336
|
void (async () => {
|
|
10337
10337
|
try {
|
|
10338
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
10338
|
+
const { collectDiagnostics } = await import("../persistent-session-LVDRHYX7.js");
|
|
10339
10339
|
await api.post("/host/heartbeat", {
|
|
10340
10340
|
host_id: hostId,
|
|
10341
10341
|
agent_diagnostics: collectDiagnostics([codeName])
|
|
@@ -10729,7 +10729,7 @@ async function processClaudePairSessions(agents) {
|
|
|
10729
10729
|
killPairSession,
|
|
10730
10730
|
pairTmuxSession,
|
|
10731
10731
|
finalizeClaudePairOnboarding
|
|
10732
|
-
} = await import("../claude-pair-runtime-
|
|
10732
|
+
} = await import("../claude-pair-runtime-2ZFH6K4I.js");
|
|
10733
10733
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
10734
10734
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
10735
10735
|
const killed = await killPairSession(pairTmuxSession(pairId));
|
|
@@ -4152,8 +4152,8 @@ var require_core = __commonJS({
|
|
|
4152
4152
|
return this;
|
|
4153
4153
|
}
|
|
4154
4154
|
case "object": {
|
|
4155
|
-
const
|
|
4156
|
-
this._cache.delete(
|
|
4155
|
+
const cacheKey = schemaKeyRef;
|
|
4156
|
+
this._cache.delete(cacheKey);
|
|
4157
4157
|
let id = schemaKeyRef[this.opts.schemaId];
|
|
4158
4158
|
if (id) {
|
|
4159
4159
|
id = (0, resolve_1.normalizeId)(id);
|
|
@@ -15474,51 +15474,6 @@ function configFromEnv(env = process.env) {
|
|
|
15474
15474
|
};
|
|
15475
15475
|
}
|
|
15476
15476
|
|
|
15477
|
-
// src/channel-kill-check.ts
|
|
15478
|
-
var CACHE_TTL_MS = 6e4;
|
|
15479
|
-
var cache = /* @__PURE__ */ new Map();
|
|
15480
|
-
function cacheKey(channelType, channelId, threadTs) {
|
|
15481
|
-
return `${channelType}|${channelId}|${threadTs}`;
|
|
15482
|
-
}
|
|
15483
|
-
async function isThreadKilled(opts) {
|
|
15484
|
-
const threadTs = opts.threadTs ?? "";
|
|
15485
|
-
const key2 = cacheKey(opts.channelType, opts.channelId, threadTs);
|
|
15486
|
-
const now = opts.now ? opts.now() : Date.now();
|
|
15487
|
-
const cached2 = cache.get(key2);
|
|
15488
|
-
if (cached2 && cached2.expiresAt > now) {
|
|
15489
|
-
return cached2.killed;
|
|
15490
|
-
}
|
|
15491
|
-
if (!opts.agtHost || !opts.agtApiKey) {
|
|
15492
|
-
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
15493
|
-
return false;
|
|
15494
|
-
}
|
|
15495
|
-
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
15496
|
-
try {
|
|
15497
|
-
const url = new URL("/host/channels/kill-check", opts.agtHost);
|
|
15498
|
-
url.searchParams.set("channel_type", opts.channelType);
|
|
15499
|
-
url.searchParams.set("channel_id", opts.channelId);
|
|
15500
|
-
if (threadTs) url.searchParams.set("thread_ts", threadTs);
|
|
15501
|
-
const res = await fetchImpl(url.toString(), {
|
|
15502
|
-
method: "GET",
|
|
15503
|
-
headers: { Authorization: `Bearer ${opts.agtApiKey}` },
|
|
15504
|
-
// 5s ceiling — kill check is hot-path. If the API is slow,
|
|
15505
|
-
// fail-open and try again next cache window.
|
|
15506
|
-
signal: AbortSignal.timeout(5e3)
|
|
15507
|
-
});
|
|
15508
|
-
if (!res.ok) {
|
|
15509
|
-
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
15510
|
-
return false;
|
|
15511
|
-
}
|
|
15512
|
-
const body = await res.json();
|
|
15513
|
-
const killed = !!body.killed;
|
|
15514
|
-
cache.set(key2, { killed, expiresAt: now + CACHE_TTL_MS });
|
|
15515
|
-
return killed;
|
|
15516
|
-
} catch {
|
|
15517
|
-
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
15518
|
-
return false;
|
|
15519
|
-
}
|
|
15520
|
-
}
|
|
15521
|
-
|
|
15522
15477
|
// src/slack-thread-context.ts
|
|
15523
15478
|
var SLACK_AUTOLOAD_THREAD_LIMIT = 30;
|
|
15524
15479
|
var SLACK_AUTOLOAD_THREAD_MAX_CHARS = 4e3;
|
|
@@ -16091,7 +16046,7 @@ function createKanbanCardActiveClient(args) {
|
|
|
16091
16046
|
const base = args.agtHost.replace(/\/+$/, "");
|
|
16092
16047
|
const agentId = args.agentId;
|
|
16093
16048
|
const apiKey = args.agtApiKey;
|
|
16094
|
-
const
|
|
16049
|
+
const cache = /* @__PURE__ */ new Map();
|
|
16095
16050
|
let cachedToken = null;
|
|
16096
16051
|
let cachedTokenExpiresAt = 0;
|
|
16097
16052
|
async function getToken() {
|
|
@@ -16139,11 +16094,11 @@ function createKanbanCardActiveClient(args) {
|
|
|
16139
16094
|
async isCardActive(sourceIntegration, sourceExternalId) {
|
|
16140
16095
|
const key2 = `${sourceIntegration}:${sourceExternalId}`;
|
|
16141
16096
|
const t = now();
|
|
16142
|
-
const hit =
|
|
16097
|
+
const hit = cache.get(key2);
|
|
16143
16098
|
if (hit && t < hit.expiresAt) return hit.active;
|
|
16144
16099
|
try {
|
|
16145
16100
|
const active = await query(sourceIntegration, sourceExternalId);
|
|
16146
|
-
|
|
16101
|
+
cache.set(key2, { active, expiresAt: t + (active ? positiveTtlMs : negativeTtlMs) });
|
|
16147
16102
|
return active;
|
|
16148
16103
|
} catch (err) {
|
|
16149
16104
|
log(`kanban-card-active: query threw key=${key2}: ${err.message}`);
|
|
@@ -16685,6 +16640,21 @@ function classifySlackFile(file) {
|
|
|
16685
16640
|
function resolveSlackInboundDir(codeName) {
|
|
16686
16641
|
return resolveChannelInboundDir(codeName, "slack-inbound");
|
|
16687
16642
|
}
|
|
16643
|
+
function explainSlackFileAccessError(stage, detail) {
|
|
16644
|
+
if (stage === "files.info") {
|
|
16645
|
+
if (detail === "missing_scope") {
|
|
16646
|
+
return "the bot token lacks the files:read OAuth scope; add it to the Slack app (Augmented Team installs include it by default) and reinstall the app";
|
|
16647
|
+
}
|
|
16648
|
+
if (detail === "file_not_found" || detail === "not_visible" || detail === "access_denied") {
|
|
16649
|
+
return "Slack reports this for files the bot token cannot access, not only for deleted files. If the file was uploaded by another (peer) agent, verify this bot has the files:read scope and is a member of the conversation where the file was shared";
|
|
16650
|
+
}
|
|
16651
|
+
return null;
|
|
16652
|
+
}
|
|
16653
|
+
if (detail === 401 || detail === 403) {
|
|
16654
|
+
return "the bot token was rejected for this file. If the file was uploaded by another (peer) agent, this bot needs the files:read scope and membership in the conversation where the file was shared";
|
|
16655
|
+
}
|
|
16656
|
+
return null;
|
|
16657
|
+
}
|
|
16688
16658
|
function buildSafeInboundPath2(codeName, fileId, mimetype) {
|
|
16689
16659
|
return buildSafeInboundPath(resolveSlackInboundDir(codeName), fileId, mimetype);
|
|
16690
16660
|
}
|
|
@@ -18970,8 +18940,6 @@ function buildSlackHelpMessage(codeName) {
|
|
|
18970
18940
|
`\u2022 \`${agentSlashCommand("/status")}\` - full health report: model, session, uptime + per-channel and per-integration status (cached snapshot, then this channel's own live check)`,
|
|
18971
18941
|
`\u2022 \`${agentSlashCommand("/ping")}\` - confirm this agent's channel is connected: posts a visible pong (team + manager only)`,
|
|
18972
18942
|
"\u2022 `/watch <google-doc-url> [duration]` (type it in chat) \u2014 watch a Google Doc for comments that mention me (default 2h, max 7d; auto-pauses when the window ends). In a shared channel, address me as `/watch-<my-name>`.",
|
|
18973
|
-
"\u2022 `/kill` \u2014 silence all agents in this thread for 6h (use as a thread reply)",
|
|
18974
|
-
"\u2022 `/unkill` \u2014 clear a kill (use as a thread reply)",
|
|
18975
18943
|
`\u2022 \`${agentSlashCommand("/investigate")}\` \u2014 live tail of this agent's terminal pane (DM only, allowlisted users; works while the channel process is alive \u2014 a wedged host still needs SSM diagnostics)`
|
|
18976
18944
|
].join("\n");
|
|
18977
18945
|
}
|
|
@@ -19510,56 +19478,6 @@ async function handleSlashCommandEnvelope(payload) {
|
|
|
19510
19478
|
await handleDebugSlashCommand(payload, responseUrl);
|
|
19511
19479
|
return;
|
|
19512
19480
|
}
|
|
19513
|
-
if (command === "/kill" || command === "/unkill") {
|
|
19514
|
-
if (!AGT_HOST || !AGT_API_KEY || !AGT_AGENT_ID) {
|
|
19515
|
-
await postEphemeralViaResponseUrl(
|
|
19516
|
-
responseUrl,
|
|
19517
|
-
":warning: This agent has no host API wiring \u2014 `/kill` / `/unkill` need the host runtime to be reachable.",
|
|
19518
|
-
codeName
|
|
19519
|
-
);
|
|
19520
|
-
return;
|
|
19521
|
-
}
|
|
19522
|
-
if (!payload.thread_ts || !payload.channel_id || !payload.user_id) {
|
|
19523
|
-
await postEphemeralViaResponseUrl(
|
|
19524
|
-
responseUrl,
|
|
19525
|
-
`:warning: \`${command}\` only works inside a thread. Invoke it as a thread reply.`,
|
|
19526
|
-
codeName
|
|
19527
|
-
);
|
|
19528
|
-
return;
|
|
19529
|
-
}
|
|
19530
|
-
try {
|
|
19531
|
-
const res = await fetch(`${AGT_HOST}/host/slack/thread-kill`, {
|
|
19532
|
-
method: "POST",
|
|
19533
|
-
headers: {
|
|
19534
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
19535
|
-
Authorization: `Bearer ${AGT_API_KEY}`
|
|
19536
|
-
},
|
|
19537
|
-
body: JSON.stringify({
|
|
19538
|
-
agent_id: AGT_AGENT_ID,
|
|
19539
|
-
op: command === "/kill" ? "kill" : "unkill",
|
|
19540
|
-
channel_id: payload.channel_id,
|
|
19541
|
-
thread_ts: payload.thread_ts,
|
|
19542
|
-
user_id: payload.user_id,
|
|
19543
|
-
user_name: payload.user_name
|
|
19544
|
-
}),
|
|
19545
|
-
signal: AbortSignal.timeout(SLACK_DOWNLOAD_TIMEOUT_MS)
|
|
19546
|
-
});
|
|
19547
|
-
const data = await res.json();
|
|
19548
|
-
const text = data.message ?? (data.ok ? command === "/kill" ? ":lock: Kill engaged for this thread." : ":unlock: Kill cleared for this thread." : `:x: ${command} failed.`);
|
|
19549
|
-
await postEphemeralViaResponseUrl(responseUrl, text, codeName);
|
|
19550
|
-
} catch (err) {
|
|
19551
|
-
process.stderr.write(
|
|
19552
|
-
`slack-channel(${codeName}): ${command} forward failed: ${err.message}
|
|
19553
|
-
`
|
|
19554
|
-
);
|
|
19555
|
-
await postEphemeralViaResponseUrl(
|
|
19556
|
-
responseUrl,
|
|
19557
|
-
`:x: \`${command}\` forwarding failed \u2014 host runtime unreachable. Try again in a moment.`,
|
|
19558
|
-
codeName
|
|
19559
|
-
);
|
|
19560
|
-
}
|
|
19561
|
-
return;
|
|
19562
|
-
}
|
|
19563
19481
|
if (matchesAgentCommand(command, "/ping")) {
|
|
19564
19482
|
if (!payload.channel_id) {
|
|
19565
19483
|
await postEphemeralViaResponseUrl(
|
|
@@ -20163,30 +20081,6 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
20163
20081
|
threadTs: thread_ts,
|
|
20164
20082
|
messageTs: message_ts
|
|
20165
20083
|
});
|
|
20166
|
-
if (channel && effectiveThreadTs) {
|
|
20167
|
-
const killed = await isThreadKilled({
|
|
20168
|
-
channelType: "slack",
|
|
20169
|
-
channelId: channel,
|
|
20170
|
-
threadTs: effectiveThreadTs,
|
|
20171
|
-
agtHost: AGT_HOST,
|
|
20172
|
-
agtApiKey: AGT_API_KEY
|
|
20173
|
-
});
|
|
20174
|
-
if (killed) {
|
|
20175
|
-
process.stderr.write(
|
|
20176
|
-
`slack-channel(${AGENT_CODE_NAME}): reply_killed channel=${redactSlackId(channel)} thread=${redactSlackId(effectiveThreadTs)}
|
|
20177
|
-
`
|
|
20178
|
-
);
|
|
20179
|
-
return {
|
|
20180
|
-
content: [
|
|
20181
|
-
{
|
|
20182
|
-
type: "text",
|
|
20183
|
-
text: "This thread has been silenced by /kill. Stop attempting to reply \u2014 the human will /unkill when they want agents back."
|
|
20184
|
-
}
|
|
20185
|
-
],
|
|
20186
|
-
isError: true
|
|
20187
|
-
};
|
|
20188
|
-
}
|
|
20189
|
-
}
|
|
20190
20084
|
const throttleCfg = configFromEnv();
|
|
20191
20085
|
const throttleKey = effectiveThreadTs ?? channel;
|
|
20192
20086
|
const throttleNow = Date.now();
|
|
@@ -21071,7 +20965,11 @@ async function downloadSlackFile(fileId, codeName) {
|
|
|
21071
20965
|
);
|
|
21072
20966
|
const infoData = await infoRes.json();
|
|
21073
20967
|
if (!infoData.ok || !infoData.file) {
|
|
21074
|
-
|
|
20968
|
+
const rawError = infoData.error ?? "unknown";
|
|
20969
|
+
const accessHint = explainSlackFileAccessError("files.info", rawError);
|
|
20970
|
+
throw new Error(
|
|
20971
|
+
`files.info failed: ${rawError}${accessHint ? ` (${accessHint})` : ""}`
|
|
20972
|
+
);
|
|
21075
20973
|
}
|
|
21076
20974
|
const file = infoData.file;
|
|
21077
20975
|
if (typeof file.size === "number" && file.size > MAX_INBOUND_FILE_BYTES) {
|
|
@@ -21086,7 +20984,10 @@ async function downloadSlackFile(fileId, codeName) {
|
|
|
21086
20984
|
signal: AbortSignal.timeout(SLACK_DOWNLOAD_TIMEOUT_MS)
|
|
21087
20985
|
});
|
|
21088
20986
|
if (!res.ok) {
|
|
21089
|
-
|
|
20987
|
+
const accessHint = explainSlackFileAccessError("url_private", res.status);
|
|
20988
|
+
throw new Error(
|
|
20989
|
+
`download failed: HTTP ${res.status}${accessHint ? ` (${accessHint})` : ""}`
|
|
20990
|
+
);
|
|
21090
20991
|
}
|
|
21091
20992
|
const contentLengthHeader = res.headers.get("content-length");
|
|
21092
20993
|
if (contentLengthHeader) {
|
|
@@ -4152,8 +4152,8 @@ var require_core = __commonJS({
|
|
|
4152
4152
|
return this;
|
|
4153
4153
|
}
|
|
4154
4154
|
case "object": {
|
|
4155
|
-
const
|
|
4156
|
-
this._cache.delete(
|
|
4155
|
+
const cacheKey = schemaKeyRef;
|
|
4156
|
+
this._cache.delete(cacheKey);
|
|
4157
4157
|
let id = schemaKeyRef[this.opts.schemaId];
|
|
4158
4158
|
if (id) {
|
|
4159
4159
|
id = (0, resolve_1.normalizeId)(id);
|
|
@@ -14801,51 +14801,6 @@ function configFromEnv(env = process.env) {
|
|
|
14801
14801
|
};
|
|
14802
14802
|
}
|
|
14803
14803
|
|
|
14804
|
-
// src/channel-kill-check.ts
|
|
14805
|
-
var CACHE_TTL_MS = 6e4;
|
|
14806
|
-
var cache = /* @__PURE__ */ new Map();
|
|
14807
|
-
function cacheKey(channelType, channelId, threadTs) {
|
|
14808
|
-
return `${channelType}|${channelId}|${threadTs}`;
|
|
14809
|
-
}
|
|
14810
|
-
async function isThreadKilled(opts) {
|
|
14811
|
-
const threadTs = opts.threadTs ?? "";
|
|
14812
|
-
const key2 = cacheKey(opts.channelType, opts.channelId, threadTs);
|
|
14813
|
-
const now = opts.now ? opts.now() : Date.now();
|
|
14814
|
-
const cached2 = cache.get(key2);
|
|
14815
|
-
if (cached2 && cached2.expiresAt > now) {
|
|
14816
|
-
return cached2.killed;
|
|
14817
|
-
}
|
|
14818
|
-
if (!opts.agtHost || !opts.agtApiKey) {
|
|
14819
|
-
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14820
|
-
return false;
|
|
14821
|
-
}
|
|
14822
|
-
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
14823
|
-
try {
|
|
14824
|
-
const url = new URL("/host/channels/kill-check", opts.agtHost);
|
|
14825
|
-
url.searchParams.set("channel_type", opts.channelType);
|
|
14826
|
-
url.searchParams.set("channel_id", opts.channelId);
|
|
14827
|
-
if (threadTs) url.searchParams.set("thread_ts", threadTs);
|
|
14828
|
-
const res = await fetchImpl(url.toString(), {
|
|
14829
|
-
method: "GET",
|
|
14830
|
-
headers: { Authorization: `Bearer ${opts.agtApiKey}` },
|
|
14831
|
-
// 5s ceiling — kill check is hot-path. If the API is slow,
|
|
14832
|
-
// fail-open and try again next cache window.
|
|
14833
|
-
signal: AbortSignal.timeout(5e3)
|
|
14834
|
-
});
|
|
14835
|
-
if (!res.ok) {
|
|
14836
|
-
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14837
|
-
return false;
|
|
14838
|
-
}
|
|
14839
|
-
const body = await res.json();
|
|
14840
|
-
const killed = !!body.killed;
|
|
14841
|
-
cache.set(key2, { killed, expiresAt: now + CACHE_TTL_MS });
|
|
14842
|
-
return killed;
|
|
14843
|
-
} catch {
|
|
14844
|
-
cache.set(key2, { killed: false, expiresAt: now + CACHE_TTL_MS });
|
|
14845
|
-
return false;
|
|
14846
|
-
}
|
|
14847
|
-
}
|
|
14848
|
-
|
|
14849
14804
|
// src/telegram-peer-classifier.ts
|
|
14850
14805
|
function classifyPeerMessage(msg, cfg, self) {
|
|
14851
14806
|
if (!msg.from?.is_bot) return { kind: "human" };
|
|
@@ -15347,12 +15302,12 @@ function createDbBackedPeerRateLimiter(deps) {
|
|
|
15347
15302
|
pendingWrites.add(write);
|
|
15348
15303
|
void write.finally(() => pendingWrites.delete(write));
|
|
15349
15304
|
}
|
|
15350
|
-
function
|
|
15305
|
+
function cacheKey(layer, chatId, peerBotId) {
|
|
15351
15306
|
return `${layer}|${chatId}|${peerBotId ?? ""}`;
|
|
15352
15307
|
}
|
|
15353
15308
|
const localBumpTimes = /* @__PURE__ */ new Map();
|
|
15354
15309
|
function bumpLocal(layer, chatId, peerBotId, now) {
|
|
15355
|
-
const key2 =
|
|
15310
|
+
const key2 = cacheKey(layer, chatId, peerBotId);
|
|
15356
15311
|
const list = localBumpTimes.get(key2);
|
|
15357
15312
|
if (list) list.push(now);
|
|
15358
15313
|
else localBumpTimes.set(key2, [now]);
|
|
@@ -15377,7 +15332,7 @@ function createDbBackedPeerRateLimiter(deps) {
|
|
|
15377
15332
|
}
|
|
15378
15333
|
}
|
|
15379
15334
|
async function readCount(layer, chatId, peerBotId, windowMs, now) {
|
|
15380
|
-
const key2 =
|
|
15335
|
+
const key2 = cacheKey(layer, chatId, peerBotId);
|
|
15381
15336
|
const cached2 = caches.get(key2);
|
|
15382
15337
|
if (cached2 && now - cached2.fetchedAt < readCacheMs) {
|
|
15383
15338
|
return cached2.count + localBumpsSince(key2, cached2.fetchedAt);
|
|
@@ -15425,7 +15380,7 @@ function createDbBackedPeerRateLimiter(deps) {
|
|
|
15425
15380
|
trackPending(deps.api.recordEvent({ chat_id: chatId, peer_bot_id: null, traffic_class: "chat" }).catch((err) => log(`peer_rate_event write failed: ${err.message}`)));
|
|
15426
15381
|
trackPending(deps.api.recordEvent({ chat_id: chatId, peer_bot_id: null, traffic_class: "agent_daily" }).catch((err) => log(`peer_rate_event write failed: ${err.message}`)));
|
|
15427
15382
|
trackPending(deps.api.recordEvent({ chat_id: chatId, peer_bot_id: null, traffic_class: "daily_budget" }).catch((err) => log(`peer_rate_event write failed: ${err.message}`)));
|
|
15428
|
-
const dbKey =
|
|
15383
|
+
const dbKey = cacheKey("daily_budget", "", null);
|
|
15429
15384
|
const dbCached = caches.get(dbKey);
|
|
15430
15385
|
const dbBudget = (dbCached?.count ?? 0) + localBumpsSince(dbKey, dbCached?.fetchedAt ?? 0);
|
|
15431
15386
|
const warn80 = dbBudget >= Math.ceil(config2.dailyBudgetLimit * 0.8) && dbBudget < config2.dailyBudgetLimit;
|
|
@@ -16937,7 +16892,7 @@ function createKanbanCardActiveClient(args) {
|
|
|
16937
16892
|
const base = args.agtHost.replace(/\/+$/, "");
|
|
16938
16893
|
const agentId = args.agentId;
|
|
16939
16894
|
const apiKey = args.agtApiKey;
|
|
16940
|
-
const
|
|
16895
|
+
const cache = /* @__PURE__ */ new Map();
|
|
16941
16896
|
let cachedToken = null;
|
|
16942
16897
|
let cachedTokenExpiresAt = 0;
|
|
16943
16898
|
async function getToken() {
|
|
@@ -16985,11 +16940,11 @@ function createKanbanCardActiveClient(args) {
|
|
|
16985
16940
|
async isCardActive(sourceIntegration, sourceExternalId) {
|
|
16986
16941
|
const key2 = `${sourceIntegration}:${sourceExternalId}`;
|
|
16987
16942
|
const t = now();
|
|
16988
|
-
const hit =
|
|
16943
|
+
const hit = cache.get(key2);
|
|
16989
16944
|
if (hit && t < hit.expiresAt) return hit.active;
|
|
16990
16945
|
try {
|
|
16991
16946
|
const active = await query(sourceIntegration, sourceExternalId);
|
|
16992
|
-
|
|
16947
|
+
cache.set(key2, { active, expiresAt: t + (active ? positiveTtlMs : negativeTtlMs) });
|
|
16993
16948
|
return active;
|
|
16994
16949
|
} catch (err) {
|
|
16995
16950
|
log(`kanban-card-active: query threw key=${key2}: ${err.message}`);
|
|
@@ -19262,20 +19217,6 @@ async function deliverQueuedReply(p) {
|
|
|
19262
19217
|
if (remaining <= 0) queuedReplyCounts.delete(p.chatId);
|
|
19263
19218
|
else queuedReplyCounts.set(p.chatId, remaining);
|
|
19264
19219
|
try {
|
|
19265
|
-
const killed = await isThreadKilled({
|
|
19266
|
-
channelType: "telegram",
|
|
19267
|
-
channelId: p.chatId,
|
|
19268
|
-
threadTs: "",
|
|
19269
|
-
agtHost: AGT_HOST,
|
|
19270
|
-
agtApiKey: AGT_API_KEY
|
|
19271
|
-
});
|
|
19272
|
-
if (killed) {
|
|
19273
|
-
process.stderr.write(
|
|
19274
|
-
`telegram-channel(${AGENT_CODE_NAME}): reply_queue_dropped reason=killed chat=${redactId(p.chatId)}
|
|
19275
|
-
`
|
|
19276
|
-
);
|
|
19277
|
-
return;
|
|
19278
|
-
}
|
|
19279
19220
|
const body = { chat_id: p.chatId, text: p.text };
|
|
19280
19221
|
if (p.replyToMessageId) body.reply_to_message_id = Number(p.replyToMessageId);
|
|
19281
19222
|
const drainCutoffMs = Date.now();
|
|
@@ -19517,28 +19458,6 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
19517
19458
|
};
|
|
19518
19459
|
}
|
|
19519
19460
|
}
|
|
19520
|
-
const killed = await isThreadKilled({
|
|
19521
|
-
channelType: "telegram",
|
|
19522
|
-
channelId: chat_id,
|
|
19523
|
-
threadTs: "",
|
|
19524
|
-
agtHost: AGT_HOST,
|
|
19525
|
-
agtApiKey: AGT_API_KEY
|
|
19526
|
-
});
|
|
19527
|
-
if (killed) {
|
|
19528
|
-
process.stderr.write(
|
|
19529
|
-
`telegram-channel(${AGENT_CODE_NAME}): reply_killed chat=${redactId(chat_id)}
|
|
19530
|
-
`
|
|
19531
|
-
);
|
|
19532
|
-
return {
|
|
19533
|
-
content: [
|
|
19534
|
-
{
|
|
19535
|
-
type: "text",
|
|
19536
|
-
text: "This chat has been silenced by /kill. Stop attempting to reply \u2014 the human will /unkill when they want agents back."
|
|
19537
|
-
}
|
|
19538
|
-
],
|
|
19539
|
-
isError: true
|
|
19540
|
-
};
|
|
19541
|
-
}
|
|
19542
19461
|
const tgSanitized = stripRepostPreambleWithMeta(text);
|
|
19543
19462
|
if (tgSanitized.stripped) emitPreambleStripTelemetry("telegram", tgSanitized.shape);
|
|
19544
19463
|
const tgSanitizedGuarded = redactToolCallMarkup(tgSanitized.text);
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
writeDirectChatSessionState,
|
|
37
37
|
writeEgressAllowlist,
|
|
38
38
|
writePersistentClaudeWrapper
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-PYVEJMY2.js";
|
|
40
40
|
import "./chunk-XWVM4KPK.js";
|
|
41
41
|
export {
|
|
42
42
|
EGRESS_BASELINE_DOMAINS,
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
writeEgressAllowlist,
|
|
78
78
|
writePersistentClaudeWrapper
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=persistent-session-
|
|
80
|
+
//# sourceMappingURL=persistent-session-LVDRHYX7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
paneLogPath
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PYVEJMY2.js";
|
|
4
4
|
import "./chunk-XWVM4KPK.js";
|
|
5
5
|
|
|
6
6
|
// src/lib/responsiveness-probe.ts
|
|
@@ -303,4 +303,4 @@ export {
|
|
|
303
303
|
readAndResetChannelDeflections,
|
|
304
304
|
readAndResetChannelLaneClassifications
|
|
305
305
|
};
|
|
306
|
-
//# sourceMappingURL=responsiveness-probe-
|
|
306
|
+
//# sourceMappingURL=responsiveness-probe-UW5TXKMS.js.map
|