Skip to content

Commit c0561ed

Browse files
committed
Tlon: fail closed on explicit empty allowlists
1 parent db20141 commit c0561ed

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

‎extensions/tlon/src/monitor/index.ts‎

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
301301
`[tlon] Using autoDiscoverChannels from settings store: ${effectiveAutoDiscoverChannels}`,
302302
);
303303
}
304-
if (currentSettings.dmAllowlist?.length) {
304+
if (currentSettings.dmAllowlist !== undefined) {
305305
effectiveDmAllowlist = currentSettings.dmAllowlist;
306306
runtime.log?.(
307307
`[tlon] Using dmAllowlist from settings store: ${effectiveDmAllowlist.join(", ")}`,
@@ -322,7 +322,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
322322
`[tlon] Using autoAcceptGroupInvites from settings store: ${effectiveAutoAcceptGroupInvites}`,
323323
);
324324
}
325-
if (currentSettings.groupInviteAllowlist?.length) {
325+
if (currentSettings.groupInviteAllowlist !== undefined) {
326326
effectiveGroupInviteAllowlist = currentSettings.groupInviteAllowlist;
327327
runtime.log?.(
328328
`[tlon] Using groupInviteAllowlist from settings store: ${effectiveGroupInviteAllowlist.join(", ")}`,
@@ -1176,17 +1176,14 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
11761176
return;
11771177
}
11781178

1179-
// Resolve any cited/quoted messages first
1180-
const citedContent = await resolveAllCites(content.content);
11811179
const rawText = extractMessageText(content.content);
1182-
const messageText = citedContent + rawText;
1183-
if (!messageText.trim()) {
1180+
if (!rawText.trim()) {
11841181
return;
11851182
}
11861183

11871184
cacheMessage(nest, {
11881185
author: senderShip,
1189-
content: messageText,
1186+
content: rawText,
11901187
timestamp: content.sent || Date.now(),
11911188
id: messageId,
11921189
});
@@ -1200,7 +1197,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
12001197
// Check if we should respond:
12011198
// 1. Direct mention always triggers response
12021199
// 2. Thread replies where we've participated - respond if relevant (let agent decide)
1203-
const mentioned = isBotMentioned(messageText, botShipName, botNickname ?? undefined);
1200+
const mentioned = isBotMentioned(rawText, botShipName, botNickname ?? undefined);
12041201
const inParticipatedThread =
12051202
isThreadReply && parentId && participatedThreads.has(String(parentId));
12061203

@@ -1222,6 +1219,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
12221219
const normalizedAllowed = allowedShips.map(normalizeShip);
12231220
if (!normalizedAllowed.includes(senderShip)) {
12241221
// If owner is configured, queue approval request
1222+
const messageText = rawText;
12251223
if (effectiveOwnerShip) {
12261224
const approval = createPendingApproval({
12271225
type: "channel",
@@ -1248,6 +1246,10 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
12481246
}
12491247
}
12501248

1249+
// Resolve quoted content only after the sender passed channel authorization.
1250+
const citedContent = await resolveAllCites(content.content);
1251+
const messageText = citedContent + rawText;
1252+
12511253
const parsed = parseChannelNest(nest);
12521254
await processMessage({
12531255
messageId: messageId ?? "",
@@ -1365,15 +1367,13 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
13651367
);
13661368
}
13671369

1368-
// Resolve any cited/quoted messages first
1369-
const citedContent = await resolveAllCites(essay.content);
13701370
const rawText = extractMessageText(essay.content);
1371-
const messageText = citedContent + rawText;
1372-
if (!messageText.trim()) {
1371+
if (!rawText.trim()) {
13731372
return;
13741373
}
13751374

13761375
// Check if this is the owner sending an approval response
1376+
const messageText = rawText;
13771377
if (isOwner(senderShip) && isApprovalResponse(messageText)) {
13781378
const handled = await handleApprovalResponse(messageText);
13791379
if (handled) {
@@ -1427,10 +1427,13 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
14271427
return;
14281428
}
14291429

1430+
const citedContent = await resolveAllCites(essay.content);
1431+
const resolvedMessageText = citedContent + rawText;
1432+
14301433
await processMessage({
14311434
messageId: messageId ?? "",
14321435
senderShip,
1433-
messageText,
1436+
messageText: resolvedMessageText,
14341437
messageContent: essay.content, // Pass raw content for media extraction
14351438
isGroup: false,
14361439
timestamp: essay.sent || Date.now(),
@@ -1524,8 +1527,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
15241527

15251528
// Update DM allowlist
15261529
if (newSettings.dmAllowlist !== undefined) {
1527-
effectiveDmAllowlist =
1528-
newSettings.dmAllowlist.length > 0 ? newSettings.dmAllowlist : account.dmAllowlist;
1530+
effectiveDmAllowlist = newSettings.dmAllowlist;
15291531
runtime.log?.(`[tlon] Settings: dmAllowlist updated to ${effectiveDmAllowlist.join(", ")}`);
15301532
}
15311533

@@ -1551,10 +1553,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
15511553

15521554
// Update group invite allowlist
15531555
if (newSettings.groupInviteAllowlist !== undefined) {
1554-
effectiveGroupInviteAllowlist =
1555-
newSettings.groupInviteAllowlist.length > 0
1556-
? newSettings.groupInviteAllowlist
1557-
: account.groupInviteAllowlist;
1556+
effectiveGroupInviteAllowlist = newSettings.groupInviteAllowlist;
15581557
runtime.log?.(
15591558
`[tlon] Settings: groupInviteAllowlist updated to ${effectiveGroupInviteAllowlist.join(", ")}`,
15601559
);

0 commit comments

Comments
 (0)