@integrity-labs/agt-cli 0.26.2 → 0.27.0
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 +58 -16
- package/dist/bin/agt.js.map +1 -1
- package/dist/{chunk-U3HCB23E.js → chunk-BKLEFKUZ.js} +10 -8
- package/dist/chunk-BKLEFKUZ.js.map +1 -0
- package/dist/{chunk-QSDDP7JN.js → chunk-LJZK5RL3.js} +2 -2
- package/dist/{chunk-4CESBZPM.js → chunk-YWXPSVI5.js} +2 -2
- package/dist/{claude-pair-runtime-2NNAUBP3.js → claude-pair-runtime-3UQKYKMO.js} +2 -2
- package/dist/lib/manager-worker.js +7 -7
- package/dist/mcp/direct-chat-channel.js +76 -0
- package/dist/mcp/slack-channel.js +86 -4
- package/dist/mcp/telegram-channel.js +82 -0
- package/dist/{persistent-session-K4X76LLB.js → persistent-session-SE3E72ET.js} +3 -3
- package/dist/{responsiveness-probe-QBV43SJ7.js → responsiveness-probe-MTMEIXEL.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-U3HCB23E.js.map +0 -1
- /package/dist/{chunk-QSDDP7JN.js.map → chunk-LJZK5RL3.js.map} +0 -0
- /package/dist/{chunk-4CESBZPM.js.map → chunk-YWXPSVI5.js.map} +0 -0
- /package/dist/{claude-pair-runtime-2NNAUBP3.js.map → claude-pair-runtime-3UQKYKMO.js.map} +0 -0
- /package/dist/{persistent-session-K4X76LLB.js.map → persistent-session-SE3E72ET.js.map} +0 -0
- /package/dist/{responsiveness-probe-QBV43SJ7.js.map → responsiveness-probe-MTMEIXEL.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
claudeModelAlias
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BKLEFKUZ.js";
|
|
4
4
|
import {
|
|
5
5
|
reapOrphanChannelMcps
|
|
6
6
|
} from "./chunk-XWVM4KPK.js";
|
|
@@ -1024,4 +1024,4 @@ export {
|
|
|
1024
1024
|
stopAllSessionsAndWait,
|
|
1025
1025
|
getProjectDir
|
|
1026
1026
|
};
|
|
1027
|
-
//# sourceMappingURL=chunk-
|
|
1027
|
+
//# sourceMappingURL=chunk-LJZK5RL3.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
parseDeliveryTarget,
|
|
10
10
|
registerFramework,
|
|
11
11
|
wrapScheduledTaskPrompt
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BKLEFKUZ.js";
|
|
13
13
|
|
|
14
14
|
// ../../packages/core/dist/integrations/registry.js
|
|
15
15
|
var INTEGRATION_REGISTRY = [
|
|
@@ -6694,4 +6694,4 @@ export {
|
|
|
6694
6694
|
managerInstallSystemUnitCommand,
|
|
6695
6695
|
managerUninstallSystemUnitCommand
|
|
6696
6696
|
};
|
|
6697
|
-
//# sourceMappingURL=chunk-
|
|
6697
|
+
//# sourceMappingURL=chunk-YWXPSVI5.js.map
|
|
@@ -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-SE3E72ET.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-3UQKYKMO.js.map
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
provisionOrientHook,
|
|
14
14
|
provisionStopHook,
|
|
15
15
|
requireHost
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-YWXPSVI5.js";
|
|
17
17
|
import {
|
|
18
18
|
getProjectDir as getProjectDir2,
|
|
19
19
|
getReadyTasks,
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
stopAllSessionsAndWait,
|
|
45
45
|
stopPersistentSession,
|
|
46
46
|
takeZombieDetection
|
|
47
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-LJZK5RL3.js";
|
|
48
48
|
import {
|
|
49
49
|
KANBAN_CHECK_COMMAND,
|
|
50
50
|
appendDmFooter,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
resolveConnectivityProbe,
|
|
68
68
|
resolveDmTarget,
|
|
69
69
|
wrapScheduledTaskPrompt
|
|
70
|
-
} from "../chunk-
|
|
70
|
+
} from "../chunk-BKLEFKUZ.js";
|
|
71
71
|
import {
|
|
72
72
|
parsePsRows,
|
|
73
73
|
reapOrphanChannelMcps
|
|
@@ -3161,7 +3161,7 @@ var cachedFrameworkVersion = null;
|
|
|
3161
3161
|
var lastVersionCheckAt = 0;
|
|
3162
3162
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
3163
3163
|
var lastResponsivenessProbeAt = 0;
|
|
3164
|
-
var agtCliVersion = true ? "0.
|
|
3164
|
+
var agtCliVersion = true ? "0.27.0" : "dev";
|
|
3165
3165
|
function resolveBrewPath(execFileSync4) {
|
|
3166
3166
|
try {
|
|
3167
3167
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -4120,7 +4120,7 @@ async function pollCycle() {
|
|
|
4120
4120
|
}
|
|
4121
4121
|
try {
|
|
4122
4122
|
const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
|
|
4123
|
-
const { collectDiagnostics } = await import("../persistent-session-
|
|
4123
|
+
const { collectDiagnostics } = await import("../persistent-session-SE3E72ET.js");
|
|
4124
4124
|
const diagCodeNames = [...agentState.persistentSessionAgents];
|
|
4125
4125
|
const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
|
|
4126
4126
|
let tailscaleHostname;
|
|
@@ -4188,7 +4188,7 @@ async function pollCycle() {
|
|
|
4188
4188
|
const {
|
|
4189
4189
|
collectResponsivenessProbes,
|
|
4190
4190
|
getResponsivenessIntervalMs
|
|
4191
|
-
} = await import("../responsiveness-probe-
|
|
4191
|
+
} = await import("../responsiveness-probe-MTMEIXEL.js");
|
|
4192
4192
|
const probeIntervalMs = getResponsivenessIntervalMs();
|
|
4193
4193
|
if (now - lastResponsivenessProbeAt > probeIntervalMs) {
|
|
4194
4194
|
const probeCodeNames = [...agentState.persistentSessionAgents];
|
|
@@ -8111,7 +8111,7 @@ async function processClaudePairSessions(agents) {
|
|
|
8111
8111
|
killPairSession,
|
|
8112
8112
|
pairTmuxSession,
|
|
8113
8113
|
finalizeClaudePairOnboarding
|
|
8114
|
-
} = await import("../claude-pair-runtime-
|
|
8114
|
+
} = await import("../claude-pair-runtime-3UQKYKMO.js");
|
|
8115
8115
|
for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
|
|
8116
8116
|
log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
|
|
8117
8117
|
const killed = await killPairSession(pairTmuxSession(pairId));
|
|
@@ -13982,6 +13982,75 @@ function createDirectChatProgressFlush(opts) {
|
|
|
13982
13982
|
};
|
|
13983
13983
|
}
|
|
13984
13984
|
|
|
13985
|
+
// src/inbound-context-client.ts
|
|
13986
|
+
var REQUEST_TIMEOUT_MS = 1e4;
|
|
13987
|
+
function createInboundContextClient(args) {
|
|
13988
|
+
if (!args.agtHost || !args.agtApiKey || !args.agentId) return null;
|
|
13989
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
13990
|
+
const log = args.log ?? (() => {
|
|
13991
|
+
});
|
|
13992
|
+
const base = args.agtHost.replace(/\/+$/, "");
|
|
13993
|
+
const agentId = args.agentId;
|
|
13994
|
+
const apiKey = args.agtApiKey;
|
|
13995
|
+
let cachedToken = null;
|
|
13996
|
+
let cachedTokenExpiresAt = 0;
|
|
13997
|
+
async function getToken() {
|
|
13998
|
+
if (cachedToken && Date.now() < cachedTokenExpiresAt) return cachedToken;
|
|
13999
|
+
const resp = await fetchImpl(`${base}/host/exchange`, {
|
|
14000
|
+
method: "POST",
|
|
14001
|
+
headers: { "Content-Type": "application/json" },
|
|
14002
|
+
body: JSON.stringify({ host_key: apiKey }),
|
|
14003
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
14004
|
+
});
|
|
14005
|
+
if (!resp.ok) {
|
|
14006
|
+
const body = await resp.text().catch(() => "");
|
|
14007
|
+
throw new Error(`/host/exchange failed (${resp.status}): ${body.slice(0, 200)}`);
|
|
14008
|
+
}
|
|
14009
|
+
const data = await resp.json();
|
|
14010
|
+
cachedToken = data.token;
|
|
14011
|
+
cachedTokenExpiresAt = data.expires_at ? new Date(data.expires_at).getTime() - 12e4 : Date.now() + 55 * 6e4;
|
|
14012
|
+
return cachedToken;
|
|
14013
|
+
}
|
|
14014
|
+
async function postOnce(body) {
|
|
14015
|
+
const token = await getToken();
|
|
14016
|
+
return fetchImpl(`${base}/host/inbound-context`, {
|
|
14017
|
+
method: "POST",
|
|
14018
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
14019
|
+
body: JSON.stringify(body),
|
|
14020
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
14021
|
+
});
|
|
14022
|
+
}
|
|
14023
|
+
async function emit(args2) {
|
|
14024
|
+
const body = {
|
|
14025
|
+
agent_id: agentId,
|
|
14026
|
+
source_integration: args2.sourceIntegration,
|
|
14027
|
+
source_external_id: args2.sourceExternalId,
|
|
14028
|
+
...args2.sourceUrl ? { source_url: args2.sourceUrl } : {}
|
|
14029
|
+
};
|
|
14030
|
+
try {
|
|
14031
|
+
let resp = await postOnce(body);
|
|
14032
|
+
if (resp.status === 401) {
|
|
14033
|
+
cachedToken = null;
|
|
14034
|
+
cachedTokenExpiresAt = 0;
|
|
14035
|
+
resp = await postOnce(body);
|
|
14036
|
+
}
|
|
14037
|
+
if (!resp.ok) {
|
|
14038
|
+
const text = await resp.text().catch(() => "");
|
|
14039
|
+
log(
|
|
14040
|
+
`inbound-context: POST failed (${resp.status}) integration=${args2.sourceIntegration}: ${text.slice(0, 200)}`
|
|
14041
|
+
);
|
|
14042
|
+
}
|
|
14043
|
+
} catch (err) {
|
|
14044
|
+
log(`inbound-context: emit threw integration=${args2.sourceIntegration}: ${err.message}`);
|
|
14045
|
+
}
|
|
14046
|
+
}
|
|
14047
|
+
return {
|
|
14048
|
+
recordInbound(args2) {
|
|
14049
|
+
void emit(args2);
|
|
14050
|
+
}
|
|
14051
|
+
};
|
|
14052
|
+
}
|
|
14053
|
+
|
|
13985
14054
|
// src/progress-tools.ts
|
|
13986
14055
|
import { randomUUID } from "crypto";
|
|
13987
14056
|
|
|
@@ -14375,6 +14444,13 @@ var AGT_HOST = process.env.AGT_HOST;
|
|
|
14375
14444
|
var AGT_API_KEY = process.env.AGT_API_KEY;
|
|
14376
14445
|
var AGT_AGENT_ID = process.env.AGT_AGENT_ID;
|
|
14377
14446
|
var DIRECT_CHAT_AGENT_DIR = AGT_AGENT_ID ? join2(homedir(), ".augmented", AGT_AGENT_ID) : null;
|
|
14447
|
+
var inboundContextClient = createInboundContextClient({
|
|
14448
|
+
agtHost: AGT_HOST ?? null,
|
|
14449
|
+
agtApiKey: AGT_API_KEY ?? null,
|
|
14450
|
+
agentId: AGT_AGENT_ID ?? null,
|
|
14451
|
+
log: (line) => process.stderr.write(`direct-chat-channel: ${line}
|
|
14452
|
+
`)
|
|
14453
|
+
});
|
|
14378
14454
|
if (!AGT_HOST || !AGT_API_KEY || !AGT_AGENT_ID) {
|
|
14379
14455
|
process.stderr.write(
|
|
14380
14456
|
"direct-chat-channel: Missing AGT_HOST, AGT_API_KEY, or AGT_AGENT_ID. Cannot start.\n"
|
|
@@ -15495,8 +15495,77 @@ function createConversationIngestClient(args) {
|
|
|
15495
15495
|
};
|
|
15496
15496
|
}
|
|
15497
15497
|
|
|
15498
|
-
// src/
|
|
15498
|
+
// src/inbound-context-client.ts
|
|
15499
15499
|
var REQUEST_TIMEOUT_MS3 = 1e4;
|
|
15500
|
+
function createInboundContextClient(args) {
|
|
15501
|
+
if (!args.agtHost || !args.agtApiKey || !args.agentId) return null;
|
|
15502
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
15503
|
+
const log = args.log ?? (() => {
|
|
15504
|
+
});
|
|
15505
|
+
const base = args.agtHost.replace(/\/+$/, "");
|
|
15506
|
+
const agentId = args.agentId;
|
|
15507
|
+
const apiKey = args.agtApiKey;
|
|
15508
|
+
let cachedToken = null;
|
|
15509
|
+
let cachedTokenExpiresAt = 0;
|
|
15510
|
+
async function getToken() {
|
|
15511
|
+
if (cachedToken && Date.now() < cachedTokenExpiresAt) return cachedToken;
|
|
15512
|
+
const resp = await fetchImpl(`${base}/host/exchange`, {
|
|
15513
|
+
method: "POST",
|
|
15514
|
+
headers: { "Content-Type": "application/json" },
|
|
15515
|
+
body: JSON.stringify({ host_key: apiKey }),
|
|
15516
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS3)
|
|
15517
|
+
});
|
|
15518
|
+
if (!resp.ok) {
|
|
15519
|
+
const body = await resp.text().catch(() => "");
|
|
15520
|
+
throw new Error(`/host/exchange failed (${resp.status}): ${body.slice(0, 200)}`);
|
|
15521
|
+
}
|
|
15522
|
+
const data = await resp.json();
|
|
15523
|
+
cachedToken = data.token;
|
|
15524
|
+
cachedTokenExpiresAt = data.expires_at ? new Date(data.expires_at).getTime() - 12e4 : Date.now() + 55 * 6e4;
|
|
15525
|
+
return cachedToken;
|
|
15526
|
+
}
|
|
15527
|
+
async function postOnce(body) {
|
|
15528
|
+
const token = await getToken();
|
|
15529
|
+
return fetchImpl(`${base}/host/inbound-context`, {
|
|
15530
|
+
method: "POST",
|
|
15531
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
15532
|
+
body: JSON.stringify(body),
|
|
15533
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS3)
|
|
15534
|
+
});
|
|
15535
|
+
}
|
|
15536
|
+
async function emit(args2) {
|
|
15537
|
+
const body = {
|
|
15538
|
+
agent_id: agentId,
|
|
15539
|
+
source_integration: args2.sourceIntegration,
|
|
15540
|
+
source_external_id: args2.sourceExternalId,
|
|
15541
|
+
...args2.sourceUrl ? { source_url: args2.sourceUrl } : {}
|
|
15542
|
+
};
|
|
15543
|
+
try {
|
|
15544
|
+
let resp = await postOnce(body);
|
|
15545
|
+
if (resp.status === 401) {
|
|
15546
|
+
cachedToken = null;
|
|
15547
|
+
cachedTokenExpiresAt = 0;
|
|
15548
|
+
resp = await postOnce(body);
|
|
15549
|
+
}
|
|
15550
|
+
if (!resp.ok) {
|
|
15551
|
+
const text = await resp.text().catch(() => "");
|
|
15552
|
+
log(
|
|
15553
|
+
`inbound-context: POST failed (${resp.status}) integration=${args2.sourceIntegration}: ${text.slice(0, 200)}`
|
|
15554
|
+
);
|
|
15555
|
+
}
|
|
15556
|
+
} catch (err) {
|
|
15557
|
+
log(`inbound-context: emit threw integration=${args2.sourceIntegration}: ${err.message}`);
|
|
15558
|
+
}
|
|
15559
|
+
}
|
|
15560
|
+
return {
|
|
15561
|
+
recordInbound(args2) {
|
|
15562
|
+
void emit(args2);
|
|
15563
|
+
}
|
|
15564
|
+
};
|
|
15565
|
+
}
|
|
15566
|
+
|
|
15567
|
+
// src/slack-bot-user-id-client.ts
|
|
15568
|
+
var REQUEST_TIMEOUT_MS4 = 1e4;
|
|
15500
15569
|
function createSlackBotUserIdClient(args) {
|
|
15501
15570
|
if (!args.agtHost || !args.agtApiKey || !args.agentId) return null;
|
|
15502
15571
|
const fetchImpl = args.fetchImpl ?? fetch;
|
|
@@ -15514,7 +15583,7 @@ function createSlackBotUserIdClient(args) {
|
|
|
15514
15583
|
method: "POST",
|
|
15515
15584
|
headers: { "Content-Type": "application/json" },
|
|
15516
15585
|
body: JSON.stringify({ host_key: apiKey }),
|
|
15517
|
-
signal: AbortSignal.timeout(
|
|
15586
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS4)
|
|
15518
15587
|
});
|
|
15519
15588
|
if (!resp.ok) {
|
|
15520
15589
|
const body = await resp.text().catch(() => "");
|
|
@@ -15531,7 +15600,7 @@ function createSlackBotUserIdClient(args) {
|
|
|
15531
15600
|
method: "POST",
|
|
15532
15601
|
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
15533
15602
|
body: JSON.stringify({ agent_id: agentId, bot_user_id: botUserId2 }),
|
|
15534
|
-
signal: AbortSignal.timeout(
|
|
15603
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS4)
|
|
15535
15604
|
});
|
|
15536
15605
|
}
|
|
15537
15606
|
async function emitAsync(botUserId2) {
|
|
@@ -15563,7 +15632,7 @@ function createSlackBotUserIdClient(args) {
|
|
|
15563
15632
|
method: "POST",
|
|
15564
15633
|
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
15565
15634
|
body: JSON.stringify({ agent_id: agentId, channel_id: "slack", healthy }),
|
|
15566
|
-
signal: AbortSignal.timeout(
|
|
15635
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS4)
|
|
15567
15636
|
});
|
|
15568
15637
|
};
|
|
15569
15638
|
try {
|
|
@@ -15721,6 +15790,13 @@ var conversationIngestClient = createConversationIngestClient({
|
|
|
15721
15790
|
log: (line) => process.stderr.write(`slack-channel: ${line}
|
|
15722
15791
|
`)
|
|
15723
15792
|
});
|
|
15793
|
+
var inboundContextClient = createInboundContextClient({
|
|
15794
|
+
agtHost: AGT_HOST,
|
|
15795
|
+
agtApiKey: AGT_API_KEY,
|
|
15796
|
+
agentId: AGT_AGENT_ID,
|
|
15797
|
+
log: (line) => process.stderr.write(`slack-channel: ${line}
|
|
15798
|
+
`)
|
|
15799
|
+
});
|
|
15724
15800
|
var SLACK_PEER_CLASSIFIER_CONFIG = {
|
|
15725
15801
|
peer_agent_mode: parsePeerAgentModeEnv(process.env.SLACK_PEER_AGENT_MODE),
|
|
15726
15802
|
peer_group_ids: parsePeerGroupIdsEnv(process.env.SLACK_PEER_GROUP_IDS),
|
|
@@ -18094,6 +18170,12 @@ async function connectSocketMode() {
|
|
|
18094
18170
|
is_bot: isFromBot,
|
|
18095
18171
|
bot_id: evt.bot_id ?? null
|
|
18096
18172
|
});
|
|
18173
|
+
if (!isFromBot && threadTs) {
|
|
18174
|
+
inboundContextClient?.recordInbound({
|
|
18175
|
+
sourceIntegration: "slack",
|
|
18176
|
+
sourceExternalId: `${channel}:${threadTs}`
|
|
18177
|
+
});
|
|
18178
|
+
}
|
|
18097
18179
|
}
|
|
18098
18180
|
} catch (err) {
|
|
18099
18181
|
process.stderr.write(`slack-channel: Event error: ${err.message}
|
|
@@ -15317,6 +15317,75 @@ function createConversationIngestClient(args) {
|
|
|
15317
15317
|
};
|
|
15318
15318
|
}
|
|
15319
15319
|
|
|
15320
|
+
// src/inbound-context-client.ts
|
|
15321
|
+
var REQUEST_TIMEOUT_MS4 = 1e4;
|
|
15322
|
+
function createInboundContextClient(args) {
|
|
15323
|
+
if (!args.agtHost || !args.agtApiKey || !args.agentId) return null;
|
|
15324
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
15325
|
+
const log = args.log ?? (() => {
|
|
15326
|
+
});
|
|
15327
|
+
const base = args.agtHost.replace(/\/+$/, "");
|
|
15328
|
+
const agentId = args.agentId;
|
|
15329
|
+
const apiKey = args.agtApiKey;
|
|
15330
|
+
let cachedToken = null;
|
|
15331
|
+
let cachedTokenExpiresAt = 0;
|
|
15332
|
+
async function getToken() {
|
|
15333
|
+
if (cachedToken && Date.now() < cachedTokenExpiresAt) return cachedToken;
|
|
15334
|
+
const resp = await fetchImpl(`${base}/host/exchange`, {
|
|
15335
|
+
method: "POST",
|
|
15336
|
+
headers: { "Content-Type": "application/json" },
|
|
15337
|
+
body: JSON.stringify({ host_key: apiKey }),
|
|
15338
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS4)
|
|
15339
|
+
});
|
|
15340
|
+
if (!resp.ok) {
|
|
15341
|
+
const body = await resp.text().catch(() => "");
|
|
15342
|
+
throw new Error(`/host/exchange failed (${resp.status}): ${body.slice(0, 200)}`);
|
|
15343
|
+
}
|
|
15344
|
+
const data = await resp.json();
|
|
15345
|
+
cachedToken = data.token;
|
|
15346
|
+
cachedTokenExpiresAt = data.expires_at ? new Date(data.expires_at).getTime() - 12e4 : Date.now() + 55 * 6e4;
|
|
15347
|
+
return cachedToken;
|
|
15348
|
+
}
|
|
15349
|
+
async function postOnce(body) {
|
|
15350
|
+
const token = await getToken();
|
|
15351
|
+
return fetchImpl(`${base}/host/inbound-context`, {
|
|
15352
|
+
method: "POST",
|
|
15353
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
15354
|
+
body: JSON.stringify(body),
|
|
15355
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS4)
|
|
15356
|
+
});
|
|
15357
|
+
}
|
|
15358
|
+
async function emit(args2) {
|
|
15359
|
+
const body = {
|
|
15360
|
+
agent_id: agentId,
|
|
15361
|
+
source_integration: args2.sourceIntegration,
|
|
15362
|
+
source_external_id: args2.sourceExternalId,
|
|
15363
|
+
...args2.sourceUrl ? { source_url: args2.sourceUrl } : {}
|
|
15364
|
+
};
|
|
15365
|
+
try {
|
|
15366
|
+
let resp = await postOnce(body);
|
|
15367
|
+
if (resp.status === 401) {
|
|
15368
|
+
cachedToken = null;
|
|
15369
|
+
cachedTokenExpiresAt = 0;
|
|
15370
|
+
resp = await postOnce(body);
|
|
15371
|
+
}
|
|
15372
|
+
if (!resp.ok) {
|
|
15373
|
+
const text = await resp.text().catch(() => "");
|
|
15374
|
+
log(
|
|
15375
|
+
`inbound-context: POST failed (${resp.status}) integration=${args2.sourceIntegration}: ${text.slice(0, 200)}`
|
|
15376
|
+
);
|
|
15377
|
+
}
|
|
15378
|
+
} catch (err) {
|
|
15379
|
+
log(`inbound-context: emit threw integration=${args2.sourceIntegration}: ${err.message}`);
|
|
15380
|
+
}
|
|
15381
|
+
}
|
|
15382
|
+
return {
|
|
15383
|
+
recordInbound(args2) {
|
|
15384
|
+
void emit(args2);
|
|
15385
|
+
}
|
|
15386
|
+
};
|
|
15387
|
+
}
|
|
15388
|
+
|
|
15320
15389
|
// src/progress-tools.ts
|
|
15321
15390
|
import { randomUUID } from "crypto";
|
|
15322
15391
|
|
|
@@ -15872,6 +15941,13 @@ var conversationIngestClient = createConversationIngestClient({
|
|
|
15872
15941
|
log: (line) => process.stderr.write(`telegram-channel(${AGENT_CODE_NAME}): ${line}
|
|
15873
15942
|
`)
|
|
15874
15943
|
});
|
|
15944
|
+
var inboundContextClient = createInboundContextClient({
|
|
15945
|
+
agtHost: AGT_HOST,
|
|
15946
|
+
agtApiKey: AGT_API_KEY,
|
|
15947
|
+
agentId: process.env.AGT_AGENT_ID ?? null,
|
|
15948
|
+
log: (line) => process.stderr.write(`telegram-channel(${AGENT_CODE_NAME}): ${line}
|
|
15949
|
+
`)
|
|
15950
|
+
});
|
|
15875
15951
|
var peerRateApiClient = createDefaultPeerRateApiClient({
|
|
15876
15952
|
agtHost: AGT_HOST,
|
|
15877
15953
|
agtApiKey: AGT_API_KEY,
|
|
@@ -17357,6 +17433,12 @@ async function pollLoop() {
|
|
|
17357
17433
|
is_bot: isFromBot,
|
|
17358
17434
|
is_peer_agent: !!peerAgentMeta
|
|
17359
17435
|
});
|
|
17436
|
+
if (!isFromBot && !peerAgentMeta) {
|
|
17437
|
+
inboundContextClient?.recordInbound({
|
|
17438
|
+
sourceIntegration: "telegram",
|
|
17439
|
+
sourceExternalId: String(chatId)
|
|
17440
|
+
});
|
|
17441
|
+
}
|
|
17360
17442
|
}
|
|
17361
17443
|
} catch (err) {
|
|
17362
17444
|
if (isShuttingDown) return;
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
stopPersistentSession,
|
|
21
21
|
takeZombieDetection,
|
|
22
22
|
writePersistentClaudeWrapper
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-LJZK5RL3.js";
|
|
24
|
+
import "./chunk-BKLEFKUZ.js";
|
|
25
25
|
import "./chunk-XWVM4KPK.js";
|
|
26
26
|
export {
|
|
27
27
|
_internals,
|
|
@@ -46,4 +46,4 @@ export {
|
|
|
46
46
|
takeZombieDetection,
|
|
47
47
|
writePersistentClaudeWrapper
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=persistent-session-
|
|
49
|
+
//# sourceMappingURL=persistent-session-SE3E72ET.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
paneLogPath
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-LJZK5RL3.js";
|
|
4
|
+
import "./chunk-BKLEFKUZ.js";
|
|
5
5
|
import "./chunk-XWVM4KPK.js";
|
|
6
6
|
|
|
7
7
|
// src/lib/responsiveness-probe.ts
|
|
@@ -30,4 +30,4 @@ export {
|
|
|
30
30
|
collectResponsivenessProbes,
|
|
31
31
|
getResponsivenessIntervalMs
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=responsiveness-probe-
|
|
33
|
+
//# sourceMappingURL=responsiveness-probe-MTMEIXEL.js.map
|