@integrity-labs/agt-cli 0.19.21 → 0.19.23
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 +3 -3
- package/dist/{chunk-5WDQ5G5M.js → chunk-EPYGSR3M.js} +305 -39
- package/dist/chunk-EPYGSR3M.js.map +1 -0
- package/dist/lib/manager-worker.js +101 -11
- package/dist/lib/manager-worker.js.map +1 -1
- package/mcp/slack-channel.js +248 -141
- package/package.json +1 -1
- package/dist/chunk-5WDQ5G5M.js.map +0 -1
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveChannels,
|
|
23
23
|
resolveDmTarget,
|
|
24
24
|
wrapScheduledTaskPrompt
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-EPYGSR3M.js";
|
|
26
26
|
import {
|
|
27
27
|
findTaskByTemplate,
|
|
28
28
|
getProjectDir,
|
|
@@ -1795,6 +1795,29 @@ function stopRealtimeChat() {
|
|
|
1795
1795
|
}
|
|
1796
1796
|
|
|
1797
1797
|
// src/lib/manager-worker.ts
|
|
1798
|
+
function applyRestartAcks(args) {
|
|
1799
|
+
const { agentStates, priorAgents, restartAcks } = args;
|
|
1800
|
+
if (agentStates.length === 0) return false;
|
|
1801
|
+
const priorAcks = /* @__PURE__ */ new Map();
|
|
1802
|
+
for (const prev of priorAgents) {
|
|
1803
|
+
if (prev.lastRestartProcessedAt) {
|
|
1804
|
+
priorAcks.set(prev.agentId, prev.lastRestartProcessedAt);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
let changed = false;
|
|
1808
|
+
for (const ack of agentStates) {
|
|
1809
|
+
const freshAck = restartAcks.get(ack.agentId);
|
|
1810
|
+
const carryForward = priorAcks.get(ack.agentId);
|
|
1811
|
+
if (freshAck) {
|
|
1812
|
+
if (ack.lastRestartProcessedAt !== freshAck) changed = true;
|
|
1813
|
+
ack.lastRestartProcessedAt = freshAck;
|
|
1814
|
+
} else if (carryForward) {
|
|
1815
|
+
if (ack.lastRestartProcessedAt !== carryForward) changed = true;
|
|
1816
|
+
ack.lastRestartProcessedAt = carryForward;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
return changed;
|
|
1820
|
+
}
|
|
1798
1821
|
var GATEWAY_PORT_BASE = 18800;
|
|
1799
1822
|
var GATEWAY_PORT_STEP = 10;
|
|
1800
1823
|
var GATEWAY_PORT_MAX = 18899;
|
|
@@ -1852,6 +1875,52 @@ function extractCharterTelegramPeers(rawContent, gateContext) {
|
|
|
1852
1875
|
return [];
|
|
1853
1876
|
}
|
|
1854
1877
|
}
|
|
1878
|
+
function extractCharterSlackPeers(rawContent, gateContext) {
|
|
1879
|
+
if (!rawContent || rawContent.length === 0) return [];
|
|
1880
|
+
try {
|
|
1881
|
+
const parsed = extractFrontmatter(rawContent);
|
|
1882
|
+
const frontmatter = parsed.frontmatter;
|
|
1883
|
+
const peers = frontmatter?.multi_agent?.slack_peers;
|
|
1884
|
+
if (!peers || !Array.isArray(peers)) return [];
|
|
1885
|
+
const teamUserIds = new Set(gateContext?.teamPeerSlackUserIds ?? []);
|
|
1886
|
+
const grants = gateContext?.crossTeamGrants ?? [];
|
|
1887
|
+
const intraOrg = gateContext?.crossTeamPeerIntraOrg ?? "unrestricted";
|
|
1888
|
+
const now = (gateContext?.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
1889
|
+
const out = [];
|
|
1890
|
+
for (const p of peers) {
|
|
1891
|
+
if (!p || typeof p !== "object" || typeof p.code_name !== "string" || typeof p.bot_user_id !== "string" || p.bot_user_id.length === 0) {
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
const grantId = typeof p.cross_team_grant_id === "string" && p.cross_team_grant_id.length > 0 ? p.cross_team_grant_id : null;
|
|
1895
|
+
let gate = null;
|
|
1896
|
+
if (gateContext === void 0) {
|
|
1897
|
+
gate = "same_team";
|
|
1898
|
+
} else if (teamUserIds.has(p.bot_user_id)) {
|
|
1899
|
+
gate = "same_team";
|
|
1900
|
+
} else if (grantId) {
|
|
1901
|
+
const grant = grants.find((g) => g.grant_id === grantId);
|
|
1902
|
+
if (grant && !grant.revoked_at && (!grant.expires_at || new Date(grant.expires_at) > now) && (grant.granted_agent_slack_user_id ?? null) === p.bot_user_id) {
|
|
1903
|
+
gate = `grant:${grantId}`;
|
|
1904
|
+
} else {
|
|
1905
|
+
gate = null;
|
|
1906
|
+
}
|
|
1907
|
+
} else if (intraOrg === "unrestricted") {
|
|
1908
|
+
gate = "intra_org_unrestricted";
|
|
1909
|
+
} else {
|
|
1910
|
+
gate = null;
|
|
1911
|
+
}
|
|
1912
|
+
out.push({
|
|
1913
|
+
code_name: p.code_name,
|
|
1914
|
+
bot_user_id: p.bot_user_id,
|
|
1915
|
+
agent_id: "",
|
|
1916
|
+
gate_path: gate
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
return out;
|
|
1920
|
+
} catch {
|
|
1921
|
+
return [];
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1855
1924
|
function truncateForLog(s) {
|
|
1856
1925
|
const lines = s.split("\n").filter((l) => l.length > 0);
|
|
1857
1926
|
return lines.slice(-PANE_TAIL_PREVIEW_LINES).map((l) => ` | ${l}`).join("\n");
|
|
@@ -1991,7 +2060,7 @@ function clearAgentCaches(agentId, codeName) {
|
|
|
1991
2060
|
var cachedFrameworkVersion = null;
|
|
1992
2061
|
var lastVersionCheckAt = 0;
|
|
1993
2062
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
1994
|
-
var agtCliVersion = true ? "0.19.
|
|
2063
|
+
var agtCliVersion = true ? "0.19.23" : "dev";
|
|
1995
2064
|
function resolveBrewPath(execFileSync3) {
|
|
1996
2065
|
try {
|
|
1997
2066
|
const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -2993,11 +3062,12 @@ async function pollCycle() {
|
|
|
2993
3062
|
}
|
|
2994
3063
|
}
|
|
2995
3064
|
}
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3065
|
+
const restartAckStateChanged = applyRestartAcks({
|
|
3066
|
+
agentStates,
|
|
3067
|
+
priorAgents: state.agents,
|
|
3068
|
+
restartAcks
|
|
3069
|
+
});
|
|
3070
|
+
if (restartAckStateChanged) {
|
|
3001
3071
|
try {
|
|
3002
3072
|
const ackedState = { ...state, agents: agentStates };
|
|
3003
3073
|
writeFileSync3(getStateFile(), JSON.stringify(ackedState, null, 2));
|
|
@@ -3506,14 +3576,15 @@ async function processAgent(agent, agentStates) {
|
|
|
3506
3576
|
})();
|
|
3507
3577
|
const teamSettingsForHash = channelId === "telegram" || channelId === "slack" ? { peer_disabled: peerDisabledMode } : null;
|
|
3508
3578
|
const crossTeamData = refreshData;
|
|
3509
|
-
const refreshHasCrossTeamFields = Array.isArray(crossTeamData.team_peer_bot_ids);
|
|
3579
|
+
const refreshHasCrossTeamFields = channelId === "telegram" ? Array.isArray(crossTeamData.team_peer_bot_ids) : channelId === "slack" ? Array.isArray(crossTeamData.team_peer_slack_user_ids) : false;
|
|
3510
3580
|
const gateContext = refreshHasCrossTeamFields ? {
|
|
3511
3581
|
teamPeerBotIds: crossTeamData.team_peer_bot_ids ?? [],
|
|
3582
|
+
teamPeerSlackUserIds: crossTeamData.team_peer_slack_user_ids ?? [],
|
|
3512
3583
|
crossTeamGrants: crossTeamData.cross_team_grants?.inbound ?? [],
|
|
3513
3584
|
crossTeamPeerIntraOrg: crossTeamData.organization?.cross_team_peer_intra_org ?? "unrestricted"
|
|
3514
3585
|
} : void 0;
|
|
3515
|
-
const peersForHash = channelId === "telegram" ? extractCharterTelegramPeers(refreshData.charter?.raw_content ?? "", gateContext) : null;
|
|
3516
|
-
const CHANNEL_WRITE_VERSION =
|
|
3586
|
+
const peersForHash = channelId === "telegram" ? extractCharterTelegramPeers(refreshData.charter?.raw_content ?? "", gateContext) : channelId === "slack" ? extractCharterSlackPeers(refreshData.charter?.raw_content ?? "", gateContext) : null;
|
|
3587
|
+
const CHANNEL_WRITE_VERSION = 3;
|
|
3517
3588
|
const configHash = createHash2("sha256").update(
|
|
3518
3589
|
canonicalJson({
|
|
3519
3590
|
writeVersion: CHANNEL_WRITE_VERSION,
|
|
@@ -3544,11 +3615,19 @@ async function processAgent(agent, agentStates) {
|
|
|
3544
3615
|
const peerDisabled = channelId === "telegram" || channelId === "slack" ? peerDisabledMode : void 0;
|
|
3545
3616
|
const telegramPeerDisabled = channelId === "telegram" ? peerDisabledMode === "all" : void 0;
|
|
3546
3617
|
const telegramPeers = channelId === "telegram" ? extractCharterTelegramPeers(refreshData.charter?.raw_content ?? "", gateContext) : void 0;
|
|
3618
|
+
const slackPeers = channelId === "slack" ? extractCharterSlackPeers(refreshData.charter?.raw_content ?? "", gateContext) : void 0;
|
|
3547
3619
|
frameworkAdapter.writeChannelCredentials(
|
|
3548
3620
|
agent.code_name,
|
|
3549
3621
|
channelId,
|
|
3550
3622
|
entry.config,
|
|
3551
|
-
{
|
|
3623
|
+
{
|
|
3624
|
+
sessionMode: sessionMode2,
|
|
3625
|
+
agentId: agent.agent_id,
|
|
3626
|
+
telegramPeerDisabled,
|
|
3627
|
+
peerDisabled,
|
|
3628
|
+
telegramPeers,
|
|
3629
|
+
slackPeers
|
|
3630
|
+
}
|
|
3552
3631
|
);
|
|
3553
3632
|
knownChannelConfigHashes.set(cacheKey, configHash);
|
|
3554
3633
|
saveChannelHashCache2();
|
|
@@ -6451,6 +6530,15 @@ function generateArtifacts(agent, refreshData, adapter) {
|
|
|
6451
6530
|
deploymentTarget: "local_docker",
|
|
6452
6531
|
gatewayPort: 9e3,
|
|
6453
6532
|
team: refreshData.team ?? void 0,
|
|
6533
|
+
// ENG-5009: org name for the identity-preamble. Only present when
|
|
6534
|
+
// /host/refresh ships the field — falls through cleanly for older
|
|
6535
|
+
// API payloads that don't carry it.
|
|
6536
|
+
organization: (() => {
|
|
6537
|
+
const org = refreshData.organization;
|
|
6538
|
+
if (typeof org?.name !== "string") return void 0;
|
|
6539
|
+
const name = org.name.trim();
|
|
6540
|
+
return name.length > 0 ? { name } : void 0;
|
|
6541
|
+
})(),
|
|
6454
6542
|
timezone: agentTimezone,
|
|
6455
6543
|
reportsTo,
|
|
6456
6544
|
personalitySeed,
|
|
@@ -6959,6 +7047,8 @@ process.on("disconnect", () => {
|
|
|
6959
7047
|
});
|
|
6960
7048
|
export {
|
|
6961
7049
|
ChildProcessError,
|
|
7050
|
+
applyRestartAcks,
|
|
7051
|
+
extractCharterSlackPeers,
|
|
6962
7052
|
extractCharterTelegramPeers,
|
|
6963
7053
|
markAgentForFreshMemorySync,
|
|
6964
7054
|
startManager,
|