@openclaw/tlon 2026.10.33 → 2026.10.34
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/.setup/{api-BywJShk3.mjs → api-DmQrmK1_.mjs} +1 -1
- package/dist/.setup/{channel-C2dWMDrp.mjs → channel-DUrG5iQ1.mjs} +28 -7
- package/dist/.setup/{channel.runtime-DeZaAXos.mjs → channel.runtime-DjdFSVIL.mjs} +223 -77
- package/dist/.setup/{setup-core-kO8u8noA.mjs → setup-core-DQLcZhhT.mjs} +16 -2
- package/dist/.setup/{setup-surface-Byac6RoF.mjs → setup-surface-BNYZOF4n.mjs} +1 -1
- package/dist/api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/setup-api.js +2 -2
- package/dist/setup-entry.js +1 -1
- package/openclaw.plugin.json +60 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "../runtime-api.js";
|
|
2
|
-
import { t as tlonPlugin } from "./channel-
|
|
2
|
+
import { t as tlonPlugin } from "./channel-DUrG5iQ1.mjs";
|
|
3
3
|
import { n as setTlonRuntime } from "./runtime-Ck3lNvST.mjs";
|
|
4
4
|
import "../api.js";
|
|
5
5
|
export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, setTlonRuntime, ssrfPolicyFromDangerouslyAllowPrivateNetwork, tlonPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-bInPRAQZ.mjs";
|
|
2
|
-
import { c as resolveTlonAccount,
|
|
2
|
+
import { c as resolveTlonAccount, d as normalizeShip, i as tlonSetupContract, l as TLON_CLUB_ID_RE, m as resolveTlonOutboundTarget, n as createTlonSetupWizardBase, p as parseTlonTarget, s as listTlonAccountIds, u as formatTargetHint } from "./setup-core-DQLcZhhT.mjs";
|
|
3
3
|
import { buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/core";
|
|
4
4
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
5
5
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
@@ -12,6 +12,12 @@ import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plu
|
|
|
12
12
|
import { ChannelImplicitMentionsSchema, buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
//#region extensions/tlon/src/config-schema.ts
|
|
15
|
+
const TlonClubPolicySchema = z.enum([
|
|
16
|
+
"approve-once",
|
|
17
|
+
"approve-each",
|
|
18
|
+
"disabled"
|
|
19
|
+
]);
|
|
20
|
+
const TlonClubRulesSchema = z.record(z.string().regex(TLON_CLUB_ID_RE), z.enum(["allow", "deny"]));
|
|
15
21
|
const ShipSchema = z.string().min(1);
|
|
16
22
|
const ChannelNestSchema = z.string().min(1);
|
|
17
23
|
const TlonChannelRuleSchema = z.object({
|
|
@@ -32,6 +38,8 @@ const tlonCommonConfigFields = {
|
|
|
32
38
|
network: TlonNetworkSchema,
|
|
33
39
|
groupChannels: z.array(ChannelNestSchema).optional(),
|
|
34
40
|
dmAllowlist: z.array(ShipSchema).optional(),
|
|
41
|
+
clubPolicy: TlonClubPolicySchema.optional(),
|
|
42
|
+
clubRules: TlonClubRulesSchema.optional(),
|
|
35
43
|
groupInviteAllowlist: z.array(ShipSchema).optional(),
|
|
36
44
|
autoDiscoverChannels: z.boolean().optional(),
|
|
37
45
|
showModelSignature: z.boolean().optional(),
|
|
@@ -54,6 +62,14 @@ const botThreadMentionHint = {
|
|
|
54
62
|
label: "Require Mention in Bot Threads",
|
|
55
63
|
help: "Override mention gating when this account's ship authored the thread root. False allows unmentioned replies; true requires a mention even after the bot participates. Omit to preserve existing behavior. Sender authorization still applies."
|
|
56
64
|
};
|
|
65
|
+
const clubPolicyHint = {
|
|
66
|
+
label: "Tlon Group DM Policy",
|
|
67
|
+
help: "Default: approve-once. Enable each club once for automatic replies, require approval for every message with approve-each, or disable group DMs. Club authors and participants are unverified."
|
|
68
|
+
};
|
|
69
|
+
const clubRulesHint = {
|
|
70
|
+
label: "Tlon Group DM Rules",
|
|
71
|
+
help: "Club IDs mapped to allow or deny. Allow accepts unverified input delivered under that club ID with the agent's normal permitted tools; it does not authenticate participants or grant owner authority. Deny blocks the club, not a claimed ship. Approve-each still requires each message; disabled overrides all rules."
|
|
72
|
+
};
|
|
57
73
|
const tlonChannelConfigSchema = buildChannelConfigSchema(TlonConfigSchema, { uiHints: {
|
|
58
74
|
...createChannelConfigUiHints({
|
|
59
75
|
channelLabel: "Tlon",
|
|
@@ -61,7 +77,11 @@ const tlonChannelConfigSchema = buildChannelConfigSchema(TlonConfigSchema, { uiH
|
|
|
61
77
|
}),
|
|
62
78
|
requireMentionInBotThreads: botThreadMentionHint,
|
|
63
79
|
"accounts.*.requireMentionInBotThreads": botThreadMentionHint,
|
|
64
|
-
"authorization.channelRules.*.requireMentionInBotThreads": botThreadMentionHint
|
|
80
|
+
"authorization.channelRules.*.requireMentionInBotThreads": botThreadMentionHint,
|
|
81
|
+
clubPolicy: clubPolicyHint,
|
|
82
|
+
"accounts.*.clubPolicy": clubPolicyHint,
|
|
83
|
+
clubRules: clubRulesHint,
|
|
84
|
+
"accounts.*.clubRules": clubRulesHint
|
|
65
85
|
} });
|
|
66
86
|
//#endregion
|
|
67
87
|
//#region extensions/tlon/src/doctor.ts
|
|
@@ -74,8 +94,8 @@ const tlonDoctor = {
|
|
|
74
94
|
function resolveTlonOutboundSessionRoute(params) {
|
|
75
95
|
const parsed = parseTlonTarget(params.target);
|
|
76
96
|
if (!parsed) return null;
|
|
77
|
-
const isGroup = parsed.kind
|
|
78
|
-
const peerId =
|
|
97
|
+
const isGroup = parsed.kind !== "dm";
|
|
98
|
+
const peerId = parsed.kind === "dm" ? parsed.ship : parsed.kind === "club" ? `club:${parsed.clubId}` : parsed.nest;
|
|
79
99
|
return buildChannelOutboundSessionRoute({
|
|
80
100
|
cfg: params.cfg,
|
|
81
101
|
agentId: params.agentId,
|
|
@@ -87,14 +107,14 @@ function resolveTlonOutboundSessionRoute(params) {
|
|
|
87
107
|
id: peerId
|
|
88
108
|
},
|
|
89
109
|
chatType: isGroup ? "group" : "direct",
|
|
90
|
-
from:
|
|
110
|
+
from: parsed.kind === "group" ? `tlon:group:${peerId}` : `tlon:${peerId}`,
|
|
91
111
|
to: `tlon:${peerId}`
|
|
92
112
|
});
|
|
93
113
|
}
|
|
94
114
|
//#endregion
|
|
95
115
|
//#region extensions/tlon/src/channel.ts
|
|
96
116
|
const TLON_CHANNEL_ID = "tlon";
|
|
97
|
-
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
117
|
+
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-DjdFSVIL.mjs"));
|
|
98
118
|
const tlonSetupWizardProxy = createTlonSetupWizardBase(async (params) => await (await loadTlonChannelRuntime()).tlonSetupWizard.finalize(params));
|
|
99
119
|
const tlonConfigAdapter = createHybridChannelConfigAdapter({
|
|
100
120
|
sectionKey: TLON_CHANNEL_ID,
|
|
@@ -181,6 +201,7 @@ const tlonPlugin = createChatChannelPlugin({
|
|
|
181
201
|
const parsed = parseTlonTarget(target);
|
|
182
202
|
if (!parsed) return target.trim();
|
|
183
203
|
if (parsed.kind === "dm") return parsed.ship;
|
|
204
|
+
if (parsed.kind === "club") return `club:${parsed.clubId}`;
|
|
184
205
|
return parsed.nest;
|
|
185
206
|
},
|
|
186
207
|
inferTargetChatType: ({ to }) => {
|
|
@@ -241,4 +262,4 @@ const tlonPlugin = createChatChannelPlugin({
|
|
|
241
262
|
outbound: tlonChannelOutbound
|
|
242
263
|
});
|
|
243
264
|
//#endregion
|
|
244
|
-
export { tlonPlugin as t };
|
|
265
|
+
export { TlonClubPolicySchema as n, TlonClubRulesSchema as r, tlonPlugin as t };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { i as __reExport, r as __exportAll } from "./doctor-contract-bInPRAQZ.mjs";
|
|
2
2
|
import { createDedupeCache, createLoggerBackedRuntime } from "../runtime-api.js";
|
|
3
|
-
import { c as resolveTlonAccount, d as
|
|
3
|
+
import { c as resolveTlonAccount, d as normalizeShip, f as parseChannelNest, l as TLON_CLUB_ID_RE, o as validateUrbitBaseUrl, p as parseTlonTarget, u as formatTargetHint } from "./setup-core-DQLcZhhT.mjs";
|
|
4
|
+
import { n as TlonClubPolicySchema, r as TlonClubRulesSchema } from "./channel-DUrG5iQ1.mjs";
|
|
4
5
|
import { t as getTlonRuntime } from "./runtime-Ck3lNvST.mjs";
|
|
5
|
-
import { t as tlonSetupWizard } from "./setup-surface-
|
|
6
|
+
import { t as tlonSetupWizard } from "./setup-surface-BNYZOF4n.mjs";
|
|
6
7
|
import { fetchWithSsrFGuard, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
7
8
|
import { bindIngressLifecycleToReplyOptions, createArmableStallWatchdog, createChannelIngressError, createChannelIngressMonitor, createMessageReceiptFromOutboundResults, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
|
|
8
9
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
@@ -52,6 +53,8 @@ function parseSettingsResponse(raw) {
|
|
|
52
53
|
return {
|
|
53
54
|
groupChannels: Array.isArray(settings.groupChannels) ? filterStringEntries(settings.groupChannels) : void 0,
|
|
54
55
|
dmAllowlist: Array.isArray(settings.dmAllowlist) ? filterStringEntries(settings.dmAllowlist) : void 0,
|
|
56
|
+
clubPolicy: TlonClubPolicySchema.safeParse(settings.clubPolicy).data,
|
|
57
|
+
clubRules: TlonClubRulesSchema.safeParse(parseJsonSetting(settings.clubRules)).data,
|
|
55
58
|
autoDiscoverChannels: asBoolean(settings.autoDiscoverChannels),
|
|
56
59
|
showModelSig: asBoolean(settings.showModelSig),
|
|
57
60
|
autoAcceptDmInvites: asBoolean(settings.autoAcceptDmInvites),
|
|
@@ -73,14 +76,15 @@ function parsePendingApprovals(value) {
|
|
|
73
76
|
return parsed.filter((item) => {
|
|
74
77
|
if (!item || typeof item !== "object") return false;
|
|
75
78
|
const obj = item;
|
|
76
|
-
return typeof obj.id === "string" && (obj.type === "dm" || obj.type === "channel" || obj.type === "group") && typeof obj.requestingShip === "string" && typeof obj.timestamp === "number" && (obj.clubId === void 0 || typeof obj.clubId === "string") && (obj.verifiedDirect === void 0 || typeof obj.verifiedDirect === "boolean");
|
|
79
|
+
return typeof obj.id === "string" && (obj.type === "dm" || obj.type === "channel" || obj.type === "group" || obj.type === "club" && typeof obj.clubId === "string" && TLON_CLUB_ID_RE.test(obj.clubId) && (obj.clubMode === "once" || obj.clubMode === "message")) && typeof obj.requestingShip === "string" && typeof obj.timestamp === "number" && (obj.clubId === void 0 || typeof obj.clubId === "string") && (obj.verifiedDirect === void 0 || typeof obj.verifiedDirect === "boolean");
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
82
|
function parseSettingsEvent(event) {
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
const record = asNullableRecord(event);
|
|
84
|
+
if (!record) return null;
|
|
85
|
+
const evt = asNullableRecord(record["settings-event"]) ?? record;
|
|
82
86
|
const operation = evt["put-entry"] ? "put-entry" : "del-entry";
|
|
83
|
-
const entry = evt[operation];
|
|
87
|
+
const entry = asNullableRecord(evt[operation]);
|
|
84
88
|
if (!entry || entry.desk !== SETTINGS_DESK || entry["bucket-key"] !== SETTINGS_BUCKET) return null;
|
|
85
89
|
return {
|
|
86
90
|
key: typeof entry["entry-key"] === "string" ? entry["entry-key"] : "",
|
|
@@ -672,35 +676,67 @@ async function sendDm({ text, ...params }) {
|
|
|
672
676
|
kind: "text"
|
|
673
677
|
});
|
|
674
678
|
}
|
|
675
|
-
async function sendDmWithStory({
|
|
679
|
+
async function sendDmWithStory({ toShip, ...params }) {
|
|
680
|
+
return sendChatWithStory({
|
|
681
|
+
...params,
|
|
682
|
+
target: {
|
|
683
|
+
kind: "dm",
|
|
684
|
+
ship: toShip
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
async function sendClubMessage({ text, ...params }) {
|
|
689
|
+
return sendClubMessageWithStory({
|
|
690
|
+
...params,
|
|
691
|
+
story: markdownToStory(text),
|
|
692
|
+
kind: "text"
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
async function sendClubMessageWithStory({ clubId, ...params }) {
|
|
696
|
+
return sendChatWithStory({
|
|
697
|
+
...params,
|
|
698
|
+
target: {
|
|
699
|
+
kind: "club",
|
|
700
|
+
clubId
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
async function sendChatWithStory({ api, fromShip, target, story, kind = "unknown" }) {
|
|
676
705
|
const sentAt = Date.now();
|
|
677
706
|
const id = `${fromShip}/${scot("ud", da.fromUnix(sentAt))}`;
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
time: null
|
|
690
|
-
} }
|
|
691
|
-
}
|
|
707
|
+
const diff = {
|
|
708
|
+
id,
|
|
709
|
+
delta: { add: {
|
|
710
|
+
memo: {
|
|
711
|
+
content: story,
|
|
712
|
+
author: fromShip,
|
|
713
|
+
sent: sentAt
|
|
714
|
+
},
|
|
715
|
+
kind: null,
|
|
716
|
+
time: null
|
|
717
|
+
} }
|
|
692
718
|
};
|
|
719
|
+
const conversationId = target.kind === "dm" ? target.ship : `club:${target.clubId}`;
|
|
693
720
|
await api.poke({
|
|
694
721
|
app: "chat",
|
|
695
|
-
mark: "chat-dm-action",
|
|
696
|
-
json:
|
|
722
|
+
mark: target.kind === "dm" ? "chat-dm-action" : "chat-club-action",
|
|
723
|
+
json: target.kind === "dm" ? {
|
|
724
|
+
ship: target.ship,
|
|
725
|
+
diff
|
|
726
|
+
} : {
|
|
727
|
+
id: target.clubId,
|
|
728
|
+
diff: {
|
|
729
|
+
uid: "0v0",
|
|
730
|
+
delta: { writ: diff }
|
|
731
|
+
}
|
|
732
|
+
}
|
|
697
733
|
});
|
|
698
734
|
return {
|
|
699
735
|
channel: "tlon",
|
|
700
736
|
messageId: id,
|
|
701
737
|
receipt: createTlonSendReceipt({
|
|
702
738
|
messageId: id,
|
|
703
|
-
conversationId
|
|
739
|
+
conversationId,
|
|
704
740
|
kind
|
|
705
741
|
})
|
|
706
742
|
};
|
|
@@ -1296,6 +1332,7 @@ function createPendingApproval(params) {
|
|
|
1296
1332
|
type: params.type,
|
|
1297
1333
|
requestingShip: params.requestingShip,
|
|
1298
1334
|
...params.clubId !== void 0 ? { clubId: params.clubId } : {},
|
|
1335
|
+
...params.clubMode !== void 0 ? { clubMode: params.clubMode } : {},
|
|
1299
1336
|
...params.verifiedDirect === true ? { verifiedDirect: true } : {},
|
|
1300
1337
|
channelNest: params.channelNest,
|
|
1301
1338
|
groupFlag: params.groupFlag,
|
|
@@ -1314,10 +1351,12 @@ function formatApprovalInstructions(id) {
|
|
|
1314
1351
|
function formatApprovalRequest(approval) {
|
|
1315
1352
|
const preview = approval.messagePreview ? `\n"${truncate(approval.messagePreview, 100)}"` : "";
|
|
1316
1353
|
switch (approval.type) {
|
|
1354
|
+
case "club":
|
|
1317
1355
|
case "dm":
|
|
1318
1356
|
if (approval.clubId !== void 0) {
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1357
|
+
const permission = approval.type === "club" && approval.clubMode === "once" ? "Approving enables this club for automatic replies, including future messages." : "Approving permits this saved message only; it does not enable future messages.";
|
|
1358
|
+
const replayLine = approval.originalMessage ? "The reply goes to the club, using its own conversation." : "No message was saved; approval only dismisses this request.";
|
|
1359
|
+
return `Group DM ${approval.clubId}: claimed author ${approval.requestingShip} (unverified).${preview}\n\n${permission} Tlon does not authenticate club authors or participants. Input delivered under this club ID can use the agent's normal permitted tools.\n${replayLine} No direct-DM access or owner authority is granted. ` + (approval.type === "club" ? "Deny or block disables this club; no ship is blocked.\n" : "Blocking only dismisses this legacy request; no ship is blocked.\n") + formatApprovalInstructions(approval.id);
|
|
1321
1360
|
}
|
|
1322
1361
|
return `New DM request from ${approval.requestingShip}:${preview}\n\n` + formatApprovalInstructions(approval.id);
|
|
1323
1362
|
case "channel": return `${approval.requestingShip} mentioned you in ${approval.channelNest}:${preview}\n\n` + formatApprovalInstructions(approval.id);
|
|
@@ -1347,9 +1386,15 @@ function requiresResendAfterApproval(approval) {
|
|
|
1347
1386
|
return approval.type === "dm" && approval.originalMessage !== void 0 && approval.clubId === void 0 && approval.verifiedDirect !== true;
|
|
1348
1387
|
}
|
|
1349
1388
|
function formatApprovalConfirmation(approval, action) {
|
|
1389
|
+
if (approval.clubId !== void 0) {
|
|
1390
|
+
if (approval.type !== "club") return `Resolved legacy group DM request ${approval.id}. No standing club or direct-DM access was granted; no ship was blocked.`;
|
|
1391
|
+
if (action !== "approve") return `Disabled group DM ${approval.clubId}. No ship was blocked. Set its clubRules entry to "allow" to enable it again.`;
|
|
1392
|
+
return approval.clubMode === "once" ? `Enabled group DM ${approval.clubId} for automatic replies from unverified input. No direct-DM access or owner authority was granted.` : `Approved this group DM message only. No standing club or direct-DM access was granted.`;
|
|
1393
|
+
}
|
|
1350
1394
|
if (action === "block") return `Blocked ${approval.requestingShip}. They will no longer be able to contact the bot.`;
|
|
1351
1395
|
const actionText = action === "approve" ? "Approved" : "Denied";
|
|
1352
1396
|
switch (approval.type) {
|
|
1397
|
+
case "club":
|
|
1353
1398
|
case "dm":
|
|
1354
1399
|
if (action === "approve") {
|
|
1355
1400
|
if (requiresResendAfterApproval(approval)) return `${actionText} DM access for ${approval.requestingShip}. They can now message the bot.\nTheir earlier message was saved before this version and its sender cannot be verified, so it was not processed. Ask ${approval.requestingShip} to send it again.`;
|
|
@@ -1382,7 +1427,7 @@ function formatBlockedList(ships) {
|
|
|
1382
1427
|
}
|
|
1383
1428
|
function formatPendingList(approvals) {
|
|
1384
1429
|
if (approvals.length === 0) return "No pending approval requests.";
|
|
1385
|
-
return `Pending approvals (${approvals.length}):\n${approvals.map((a) => `• ${a.id}: ${a.type} from ${a.requestingShip}`).join("\n")}`;
|
|
1430
|
+
return `Pending approvals (${approvals.length}):\n${approvals.map((a) => a.clubId !== void 0 ? `• ${a.id}: group DM ${a.clubId} (unverified)` : `• ${a.id}: ${a.type} from ${a.requestingShip}`).join("\n")}`;
|
|
1386
1431
|
}
|
|
1387
1432
|
//#endregion
|
|
1388
1433
|
//#region extensions/tlon/src/monitor/approval-runtime.ts
|
|
@@ -1437,6 +1482,18 @@ function createTlonApprovalRuntime(params) {
|
|
|
1437
1482
|
runtime.error?.(`[tlon] Failed to update channelRules: ${String(err)}`);
|
|
1438
1483
|
}
|
|
1439
1484
|
};
|
|
1485
|
+
const setClubRule = async (clubId, rule) => {
|
|
1486
|
+
const clubRules = {
|
|
1487
|
+
...state.effectiveClubRules,
|
|
1488
|
+
[clubId]: rule
|
|
1489
|
+
};
|
|
1490
|
+
await putTlonSetting(api, "clubRules", JSON.stringify(clubRules));
|
|
1491
|
+
state.effectiveClubRules = clubRules;
|
|
1492
|
+
state.currentSettings = {
|
|
1493
|
+
...state.currentSettings,
|
|
1494
|
+
clubRules
|
|
1495
|
+
};
|
|
1496
|
+
};
|
|
1440
1497
|
const setShipBlocked = async (ship, blocked) => {
|
|
1441
1498
|
const normalizedShip = normalizeShip(ship);
|
|
1442
1499
|
const action = blocked ? "block" : "unblock";
|
|
@@ -1492,14 +1549,18 @@ function createTlonApprovalRuntime(params) {
|
|
|
1492
1549
|
return false;
|
|
1493
1550
|
}
|
|
1494
1551
|
};
|
|
1495
|
-
const
|
|
1496
|
-
if (await isShipBlocked(approval.requestingShip)) {
|
|
1552
|
+
const queueApprovalRequestUnqueued = async (approval) => {
|
|
1553
|
+
if (approval.clubId === void 0 && await isShipBlocked(approval.requestingShip)) {
|
|
1497
1554
|
runtime.log?.(`[tlon] Ignoring request from blocked ship ${approval.requestingShip}`);
|
|
1498
1555
|
return false;
|
|
1499
1556
|
}
|
|
1500
1557
|
const approvals = state.pendingApprovals;
|
|
1501
|
-
const existing = approvals.find((item) =>
|
|
1558
|
+
const existing = approvals.find((item) => {
|
|
1559
|
+
if (approval.type === "club") return item.type === "club" && item.clubId === approval.clubId && item.clubMode === approval.clubMode && (approval.clubMode === "once" || item.originalMessage?.messageId === approval.originalMessage?.messageId);
|
|
1560
|
+
return item.type === approval.type && item.requestingShip === approval.requestingShip && item.clubId === approval.clubId && (approval.type !== "channel" || item.channelNest === approval.channelNest) && (approval.type !== "group" || item.groupFlag === approval.groupFlag);
|
|
1561
|
+
});
|
|
1502
1562
|
if (existing) {
|
|
1563
|
+
if (approval.type === "club") return true;
|
|
1503
1564
|
if (approval.originalMessage) {
|
|
1504
1565
|
existing.originalMessage = approval.originalMessage;
|
|
1505
1566
|
existing.messagePreview = approval.messagePreview;
|
|
@@ -1521,12 +1582,19 @@ function createTlonApprovalRuntime(params) {
|
|
|
1521
1582
|
}
|
|
1522
1583
|
approvalOverflowNoticeSent = false;
|
|
1523
1584
|
approvalOverflowNoticeAttempts = 0;
|
|
1524
|
-
|
|
1525
|
-
await
|
|
1585
|
+
const nextApprovals = [...approvals, approval];
|
|
1586
|
+
await putTlonSetting(api, "pendingApprovals", JSON.stringify(nextApprovals));
|
|
1587
|
+
state.pendingApprovals = nextApprovals;
|
|
1526
1588
|
await sendOwnerNotification(formatApprovalRequest(approval));
|
|
1527
1589
|
runtime.log?.(`[tlon] Queued approval request: ${approval.id} (${approval.type} from ${approval.requestingShip})`);
|
|
1528
1590
|
return true;
|
|
1529
1591
|
};
|
|
1592
|
+
let pendingRequestWrite = Promise.resolve();
|
|
1593
|
+
const queueApprovalRequest = (approval) => {
|
|
1594
|
+
const result = pendingRequestWrite.then(() => queueApprovalRequestUnqueued(approval));
|
|
1595
|
+
pendingRequestWrite = result.then(() => {}, () => {});
|
|
1596
|
+
return result;
|
|
1597
|
+
};
|
|
1530
1598
|
const handleApprovalResponse = async (text) => {
|
|
1531
1599
|
const parsed = parseApprovalResponse(text);
|
|
1532
1600
|
if (!parsed) return false;
|
|
@@ -1535,9 +1603,25 @@ function createTlonApprovalRuntime(params) {
|
|
|
1535
1603
|
await sendOwnerNotification(parsed.id ? `No pending approval found for ID: ${parsed.id}` : state.pendingApprovals.length > 1 ? `Multiple approvals are pending. Include an approval ID with your decision.\n\n${formatPendingList(state.pendingApprovals)}` : "No pending approval found.");
|
|
1536
1604
|
return true;
|
|
1537
1605
|
}
|
|
1606
|
+
if (approval.clubId !== void 0 && (state.effectiveClubPolicy === "disabled" || state.effectiveClubRules[approval.clubId] === "deny")) {
|
|
1607
|
+
await sendOwnerNotification(`Group DM ${approval.clubId} is disabled. No message was processed.`);
|
|
1608
|
+
state.pendingApprovals = removePendingApproval(state.pendingApprovals, approval.id);
|
|
1609
|
+
await savePendingApprovals();
|
|
1610
|
+
return true;
|
|
1611
|
+
}
|
|
1538
1612
|
if (parsed.action === "approve") switch (approval.type) {
|
|
1613
|
+
case "club":
|
|
1614
|
+
if (approval.clubId && approval.clubMode === "once" && state.effectiveClubPolicy === "approve-once") await setClubRule(approval.clubId, "allow");
|
|
1615
|
+
else if (approval.clubMode === "once") {
|
|
1616
|
+
await sendOwnerNotification("The club policy changed. Send a new club message to request approval under the current policy.");
|
|
1617
|
+
state.pendingApprovals = removePendingApproval(state.pendingApprovals, approval.id);
|
|
1618
|
+
await savePendingApprovals();
|
|
1619
|
+
return true;
|
|
1620
|
+
}
|
|
1621
|
+
if (approval.originalMessage) await processApprovedMessage(approval);
|
|
1622
|
+
break;
|
|
1539
1623
|
case "dm":
|
|
1540
|
-
await addToDmAllowlist(approval.requestingShip);
|
|
1624
|
+
if (approval.clubId === void 0) await addToDmAllowlist(approval.requestingShip);
|
|
1541
1625
|
if (requiresResendAfterApproval(approval)) runtime.log?.(`[tlon] Not replaying pre-upgrade DM request from ${approval.requestingShip}: sender provenance unknown; owner told to request a resend`);
|
|
1542
1626
|
else if (approval.originalMessage) {
|
|
1543
1627
|
runtime.log?.(`[tlon] Processing original message from ${approval.requestingShip} after approval`);
|
|
@@ -1577,7 +1661,8 @@ function createTlonApprovalRuntime(params) {
|
|
|
1577
1661
|
runtime.error?.(`[tlon] Failed to join group ${approval.groupFlag}: ${String(err)}`);
|
|
1578
1662
|
}
|
|
1579
1663
|
}
|
|
1580
|
-
else if (
|
|
1664
|
+
else if (approval.type === "club" && approval.clubId) await setClubRule(approval.clubId, "deny");
|
|
1665
|
+
else if (parsed.action === "block" && approval.clubId === void 0) await setShipBlocked(approval.requestingShip, true);
|
|
1581
1666
|
await sendOwnerNotification(formatApprovalConfirmation(approval, parsed.action));
|
|
1582
1667
|
state.pendingApprovals = removePendingApproval(state.pendingApprovals, approval.id);
|
|
1583
1668
|
await savePendingApprovals();
|
|
@@ -2399,8 +2484,11 @@ async function prepareTlonGroupAdmission(params) {
|
|
|
2399
2484
|
//#endregion
|
|
2400
2485
|
//#region extensions/tlon/src/monitor/settings-helpers.ts
|
|
2401
2486
|
function buildTlonSettingsMigrations(account, currentSettings) {
|
|
2487
|
+
const configuredClubRules = Object.keys(account.clubRules).length > 0 ? JSON.stringify(account.clubRules) : void 0;
|
|
2402
2488
|
return [...[
|
|
2403
2489
|
"dmAllowlist",
|
|
2490
|
+
"clubPolicy",
|
|
2491
|
+
"clubRules",
|
|
2404
2492
|
"groupInviteAllowlist",
|
|
2405
2493
|
"groupChannels",
|
|
2406
2494
|
"defaultAuthorizedShips",
|
|
@@ -2409,7 +2497,7 @@ function buildTlonSettingsMigrations(account, currentSettings) {
|
|
|
2409
2497
|
"autoAcceptGroupInvites"
|
|
2410
2498
|
].map((key) => ({
|
|
2411
2499
|
key,
|
|
2412
|
-
fileValue: account[key],
|
|
2500
|
+
fileValue: key === "clubRules" ? configuredClubRules : account[key],
|
|
2413
2501
|
settingsValue: currentSettings[key]
|
|
2414
2502
|
})), {
|
|
2415
2503
|
key: "showModelSig",
|
|
@@ -2438,6 +2526,8 @@ function applyTlonSettingsOverrides(params) {
|
|
|
2438
2526
|
if (settings.pendingApprovals?.length) log?.(`[tlon] Loaded ${settings.pendingApprovals.length} pending approval(s) from settings`);
|
|
2439
2527
|
return {
|
|
2440
2528
|
effectiveDmAllowlist: settings.dmAllowlist ?? account.dmAllowlist,
|
|
2529
|
+
effectiveClubPolicy: settings.clubPolicy ?? account.clubPolicy ?? "approve-once",
|
|
2530
|
+
effectiveClubRules: settings.clubRules ?? account.clubRules,
|
|
2441
2531
|
effectiveShowModelSig: settings.showModelSig ?? account.showModelSignature ?? false,
|
|
2442
2532
|
effectiveAutoAcceptDmInvites: settings.autoAcceptDmInvites ?? account.autoAcceptDmInvites ?? false,
|
|
2443
2533
|
effectiveAutoAcceptGroupInvites: settings.autoAcceptGroupInvites ?? account.autoAcceptGroupInvites ?? false,
|
|
@@ -2456,6 +2546,7 @@ function createTlonSettingsInstaller(state, account, log) {
|
|
|
2456
2546
|
return (currentSettings, preserveApprovalState = false) => {
|
|
2457
2547
|
const pendingApprovals = state.pendingApprovals;
|
|
2458
2548
|
const effectiveDmAllowlist = state.effectiveDmAllowlist;
|
|
2549
|
+
const effectiveClubRules = state.effectiveClubRules;
|
|
2459
2550
|
Object.assign(state, applyTlonSettingsOverrides({
|
|
2460
2551
|
account,
|
|
2461
2552
|
currentSettings,
|
|
@@ -2464,6 +2555,7 @@ function createTlonSettingsInstaller(state, account, log) {
|
|
|
2464
2555
|
if (preserveApprovalState) {
|
|
2465
2556
|
state.pendingApprovals = pendingApprovals;
|
|
2466
2557
|
state.effectiveDmAllowlist = effectiveDmAllowlist;
|
|
2558
|
+
state.effectiveClubRules = effectiveClubRules;
|
|
2467
2559
|
}
|
|
2468
2560
|
};
|
|
2469
2561
|
}
|
|
@@ -2596,6 +2688,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2596
2688
|
} catch (err) {
|
|
2597
2689
|
runtime.log?.(`[tlon] Settings store not available, using file config: ${String(err)}`);
|
|
2598
2690
|
}
|
|
2691
|
+
runtime.log?.("[tlon] Group DMs require club enablement; dmAllowlist applies only to verified 1:1 DMs. Approve an enablement request or configure clubRules.");
|
|
2599
2692
|
if (settingsState.effectiveAutoDiscoverChannels) try {
|
|
2600
2693
|
const initData = await fetchInitData(api, runtime);
|
|
2601
2694
|
if (initData.channels.length > 0) groupChannels = initData.channels;
|
|
@@ -2614,17 +2707,13 @@ async function monitorTlonProvider(opts) {
|
|
|
2614
2707
|
if (!settingsState.effectiveOwnerShip) return false;
|
|
2615
2708
|
return normalizeShip(ship) === settingsState.effectiveOwnerShip;
|
|
2616
2709
|
}
|
|
2617
|
-
/** DM ingress allowlist for one chat event; club claims only match as their club-scoped id. */
|
|
2618
|
-
function resolveChatAllowFrom(params) {
|
|
2619
|
-
if (params.ownerDm) return [params.senderShip];
|
|
2620
|
-
if (!params.isClubMessage) return settingsState.effectiveDmAllowlist;
|
|
2621
|
-
return settingsState.effectiveDmAllowlist.some((ship) => normalizeShip(ship) === params.senderShip) ? [params.senderId] : [];
|
|
2622
|
-
}
|
|
2623
2710
|
const processMessage = async (params) => {
|
|
2624
2711
|
const { messageId, senderShip, isGroup, channelNest, timestamp, parentId, isThreadReply, isAdmissionAllowed, messageContent, turnAdoptionLifecycle, resolveChannelIngress } = params;
|
|
2625
2712
|
let messageText = params.messageText;
|
|
2626
2713
|
const clubId = params.clubId;
|
|
2627
2714
|
const senderId = clubId === void 0 ? senderShip : clubSenderId(clubId, senderShip);
|
|
2715
|
+
const groupConversation = isGroup || clubId !== void 0;
|
|
2716
|
+
const conversationId = isGroup ? channelNest ?? senderShip : clubId !== void 0 ? `club:${clubId}` : senderShip;
|
|
2628
2717
|
let attachments = [];
|
|
2629
2718
|
let unavailableMediaCount = 0;
|
|
2630
2719
|
if (messageContent) try {
|
|
@@ -2678,8 +2767,8 @@ async function monitorTlonProvider(opts) {
|
|
|
2678
2767
|
channel: "tlon",
|
|
2679
2768
|
accountId: opts.accountId ?? void 0,
|
|
2680
2769
|
peer: {
|
|
2681
|
-
kind:
|
|
2682
|
-
id:
|
|
2770
|
+
kind: groupConversation ? "group" : "direct",
|
|
2771
|
+
id: conversationId
|
|
2683
2772
|
}
|
|
2684
2773
|
});
|
|
2685
2774
|
const channelIngress = await resolveChannelIngress({
|
|
@@ -2692,7 +2781,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2692
2781
|
runtime.log?.(`[tlon] Authorization changed before dispatch for ${senderShip}`);
|
|
2693
2782
|
return;
|
|
2694
2783
|
}
|
|
2695
|
-
if (!
|
|
2784
|
+
if (!groupConversation) {
|
|
2696
2785
|
const sessionKey = route.sessionKey;
|
|
2697
2786
|
if (!dmSendersBySession.has(sessionKey)) dmSendersBySession.set(sessionKey, /* @__PURE__ */ new Set());
|
|
2698
2787
|
const senders = dmSendersBySession.get(sessionKey);
|
|
@@ -2714,7 +2803,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2714
2803
|
const fromLabel = isGroup ? `${senderShip} [${senderRole}] in ${channelNest}` : clubId !== void 0 ? `${senderShip} (unverified) [${senderRole}] in group DM ${clubId}` : `${senderShip} [${senderRole}]`;
|
|
2715
2804
|
const shouldComputeAuth = core.channel.commands.shouldComputeCommandAuthorized(messageText, cfg);
|
|
2716
2805
|
let commandAuthorized = false;
|
|
2717
|
-
if (shouldComputeAuth) {
|
|
2806
|
+
if (shouldComputeAuth && clubId === void 0) {
|
|
2718
2807
|
commandAuthorized = (await resolveTlonCommandAuthorizationWithIngress({
|
|
2719
2808
|
senderShip: senderId,
|
|
2720
2809
|
ownerShip: settingsState.effectiveOwnerShip
|
|
@@ -2736,21 +2825,20 @@ async function monitorTlonProvider(opts) {
|
|
|
2736
2825
|
body: commandBody,
|
|
2737
2826
|
notice: `[tlon ${unavailableMediaCount > 1 ? `${unavailableMediaCount} attachments` : "attachment"} unavailable]`
|
|
2738
2827
|
}) : commandBody;
|
|
2739
|
-
const tlonConversationId = isGroup ? channelNest ?? senderShip : senderShip;
|
|
2740
2828
|
const ctxPayload = core.channel.inbound.buildContext({
|
|
2741
2829
|
channel: "tlon",
|
|
2742
2830
|
accountId: route.accountId,
|
|
2743
2831
|
messageId,
|
|
2744
2832
|
timestamp,
|
|
2745
|
-
from: isGroup ? `tlon:group:${channelNest}` : `tlon:${senderId}`,
|
|
2833
|
+
from: isGroup ? `tlon:group:${channelNest}` : clubId !== void 0 ? `tlon:club:${clubId}` : `tlon:${senderId}`,
|
|
2746
2834
|
sender: {
|
|
2747
2835
|
id: senderId,
|
|
2748
2836
|
name: clubId === void 0 ? senderShip : senderId,
|
|
2749
2837
|
roles: [senderRole]
|
|
2750
2838
|
},
|
|
2751
2839
|
conversation: {
|
|
2752
|
-
kind:
|
|
2753
|
-
id:
|
|
2840
|
+
kind: groupConversation ? "group" : "direct",
|
|
2841
|
+
id: conversationId,
|
|
2754
2842
|
label: fromLabel
|
|
2755
2843
|
},
|
|
2756
2844
|
route: {
|
|
@@ -2761,7 +2849,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2761
2849
|
},
|
|
2762
2850
|
reply: {
|
|
2763
2851
|
to: `tlon:${botShipName}`,
|
|
2764
|
-
originatingTo: `tlon:${
|
|
2852
|
+
originatingTo: `tlon:${groupConversation ? conversationId : botShipName}`,
|
|
2765
2853
|
replyToId: parentId ?? void 0
|
|
2766
2854
|
},
|
|
2767
2855
|
message: {
|
|
@@ -2777,12 +2865,13 @@ async function monitorTlonProvider(opts) {
|
|
|
2777
2865
|
CommandAuthorized: commandAuthorized,
|
|
2778
2866
|
CommandSource: "text",
|
|
2779
2867
|
...attachments.length > 0 && { Attachments: attachments },
|
|
2868
|
+
...groupConversation && { ReplyThreading: { implicitCurrentMessage: "deny" } },
|
|
2780
2869
|
...parentId && { ThreadId: parentId }
|
|
2781
2870
|
}
|
|
2782
2871
|
});
|
|
2783
2872
|
const dispatchStartTime = Date.now();
|
|
2784
2873
|
const humanDelay = resolveHumanDelayConfig(cfg, route.agentId);
|
|
2785
|
-
const deliveryTarget =
|
|
2874
|
+
const deliveryTarget = conversationId;
|
|
2786
2875
|
const prepareReplyPayload = (payload) => {
|
|
2787
2876
|
const replyText = payload.text;
|
|
2788
2877
|
if (!replyText || !settingsState.effectiveShowModelSig) return payload;
|
|
@@ -2832,7 +2921,13 @@ async function monitorTlonProvider(opts) {
|
|
|
2832
2921
|
replyToId: parentId ?? void 0
|
|
2833
2922
|
};
|
|
2834
2923
|
}
|
|
2835
|
-
await
|
|
2924
|
+
if (clubId !== void 0) await sendClubMessage({
|
|
2925
|
+
api,
|
|
2926
|
+
fromShip: botShipName,
|
|
2927
|
+
clubId,
|
|
2928
|
+
text: replyText
|
|
2929
|
+
});
|
|
2930
|
+
else await sendDm({
|
|
2836
2931
|
api,
|
|
2837
2932
|
fromShip: botShipName,
|
|
2838
2933
|
toShip: senderShip,
|
|
@@ -2876,7 +2971,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2876
2971
|
processApprovedMessage: async (approval) => {
|
|
2877
2972
|
if (!approval.originalMessage || approval.type === "group") return;
|
|
2878
2973
|
const isGroup = approval.type === "channel";
|
|
2879
|
-
const conversationId = isGroup ? approval.channelNest ?? "" : approval.requestingShip;
|
|
2974
|
+
const conversationId = isGroup ? approval.channelNest ?? "" : approval.clubId !== void 0 ? `club:${approval.clubId}` : approval.requestingShip;
|
|
2880
2975
|
if (isGroup && !conversationId) return;
|
|
2881
2976
|
const clubId = !isGroup ? approval.clubId : void 0;
|
|
2882
2977
|
if (!isGroup && clubId === void 0 && approval.verifiedDirect !== true) {
|
|
@@ -2901,11 +2996,11 @@ async function monitorTlonProvider(opts) {
|
|
|
2901
2996
|
senderShip: replaySenderId,
|
|
2902
2997
|
accountId: account.accountId,
|
|
2903
2998
|
conversation: {
|
|
2904
|
-
kind: isGroup ? "group" : "direct",
|
|
2999
|
+
kind: isGroup || clubId !== void 0 ? "group" : "direct",
|
|
2905
3000
|
id: conversationId
|
|
2906
3001
|
},
|
|
2907
3002
|
allowFrom: [replaySenderId],
|
|
2908
|
-
...isGroup ? { groupPolicy: "allowlist" } : {},
|
|
3003
|
+
...isGroup || clubId !== void 0 ? { groupPolicy: "allowlist" } : {},
|
|
2909
3004
|
contextBinding
|
|
2910
3005
|
})
|
|
2911
3006
|
});
|
|
@@ -3067,22 +3162,71 @@ async function monitorTlonProvider(opts) {
|
|
|
3067
3162
|
const authorShip = normalizeShip(readStringField(essay, "author") ?? "");
|
|
3068
3163
|
const partnerShip = extractDmPartnerShip(whom);
|
|
3069
3164
|
const senderShip = partnerShip || authorShip;
|
|
3070
|
-
const clubId = partnerShip ? void 0 : typeof whom === "string" && whom ? whom :
|
|
3071
|
-
|
|
3072
|
-
|
|
3165
|
+
const clubId = partnerShip ? void 0 : typeof whom === "string" && TLON_CLUB_ID_RE.test(whom) ? whom : void 0;
|
|
3166
|
+
if (!partnerShip && clubId === void 0) {
|
|
3167
|
+
runtime.log?.("[tlon] Dropped chat event without a valid DM peer or club ID");
|
|
3168
|
+
return;
|
|
3169
|
+
}
|
|
3170
|
+
const senderId = clubId !== void 0 ? clubSenderId(clubId, senderShip) : senderShip;
|
|
3073
3171
|
if (authorShip === botShipName) return;
|
|
3074
3172
|
if (!senderShip || senderShip === botShipName) return;
|
|
3075
3173
|
if (authorShip && partnerShip && authorShip !== partnerShip) runtime.log?.(`[tlon] DM ship mismatch (author=${authorShip}, partner=${partnerShip}) - routing to partner`);
|
|
3076
3174
|
const rawText = extractMessageTextSafely(essay.content, runtime);
|
|
3077
3175
|
if (!rawText.trim()) return;
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3176
|
+
if (clubId !== void 0) {
|
|
3177
|
+
const policy = settingsState.effectiveClubPolicy;
|
|
3178
|
+
const rule = settingsState.effectiveClubRules[clubId];
|
|
3179
|
+
if (policy === "disabled" || rule === "deny") {
|
|
3180
|
+
runtime.log?.(`[tlon] Dropped disabled group DM ${clubId}`);
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
if (policy === "approve-each" || rule !== "allow") {
|
|
3184
|
+
if (settingsState.effectiveOwnerShip) await queueApprovalRequest(createPendingApproval({
|
|
3185
|
+
type: "club",
|
|
3186
|
+
clubId,
|
|
3187
|
+
clubMode: policy === "approve-each" ? "message" : "once",
|
|
3188
|
+
requestingShip: senderShip,
|
|
3189
|
+
messagePreview: rawText,
|
|
3190
|
+
originalMessage: {
|
|
3191
|
+
messageId,
|
|
3192
|
+
messageText: rawText,
|
|
3193
|
+
messageContent: essay.content,
|
|
3194
|
+
timestamp: asFiniteNumber(essay.sent) ?? Date.now()
|
|
3195
|
+
}
|
|
3196
|
+
}));
|
|
3197
|
+
else runtime.log?.(`[tlon] Group DM ${clubId} needs enablement: set channels.tlon.clubRules["${clubId}"] to "allow", or configure ownerShip for approval`);
|
|
3198
|
+
return;
|
|
3199
|
+
}
|
|
3200
|
+
await processMessage({
|
|
3201
|
+
messageId,
|
|
3202
|
+
senderShip,
|
|
3203
|
+
clubId,
|
|
3204
|
+
messageText: await resolveTlonCitations(essay.content, canExpandCitedNest, api, runtime) + rawText,
|
|
3205
|
+
messageContent: essay.content,
|
|
3206
|
+
timestamp: asFiniteNumber(essay.sent) ?? Date.now(),
|
|
3207
|
+
isGroup: false,
|
|
3208
|
+
turnAdoptionLifecycle,
|
|
3209
|
+
resolveChannelIngress: async (contextBinding) => resolveTlonMessageIngress({
|
|
3210
|
+
senderShip: senderId,
|
|
3211
|
+
accountId: account.accountId,
|
|
3212
|
+
conversation: {
|
|
3213
|
+
kind: "group",
|
|
3214
|
+
id: `club:${clubId}`
|
|
3215
|
+
},
|
|
3216
|
+
allowFrom: [],
|
|
3217
|
+
groupPolicy: "open",
|
|
3218
|
+
contextBinding
|
|
3219
|
+
})
|
|
3220
|
+
});
|
|
3221
|
+
return;
|
|
3222
|
+
}
|
|
3223
|
+
const ownerDm = isOwner(senderShip);
|
|
3224
|
+
if (ownerDm && await handleApprovalResponse(rawText)) {
|
|
3225
|
+
runtime.log?.("[tlon] Processed approval response from owner");
|
|
3082
3226
|
return;
|
|
3083
3227
|
}
|
|
3084
|
-
if (ownerDm && await handleAdminCommand(
|
|
3085
|
-
runtime.log?.(
|
|
3228
|
+
if (ownerDm && await handleAdminCommand(rawText)) {
|
|
3229
|
+
runtime.log?.("[tlon] Processed admin command from owner");
|
|
3086
3230
|
return;
|
|
3087
3231
|
}
|
|
3088
3232
|
const resolveChannelIngress = async (contextBinding) => await resolveTlonMessageIngress({
|
|
@@ -3092,12 +3236,7 @@ async function monitorTlonProvider(opts) {
|
|
|
3092
3236
|
kind: "direct",
|
|
3093
3237
|
id: senderShip
|
|
3094
3238
|
},
|
|
3095
|
-
allowFrom:
|
|
3096
|
-
ownerDm,
|
|
3097
|
-
isClubMessage,
|
|
3098
|
-
senderShip,
|
|
3099
|
-
senderId
|
|
3100
|
-
}),
|
|
3239
|
+
allowFrom: ownerDm ? [senderShip] : settingsState.effectiveDmAllowlist,
|
|
3101
3240
|
contextBinding
|
|
3102
3241
|
});
|
|
3103
3242
|
if (!ownerDm && !(await resolveChannelIngress()).senderAccess.allowed) {
|
|
@@ -3105,20 +3244,20 @@ async function monitorTlonProvider(opts) {
|
|
|
3105
3244
|
const approval = createPendingApproval({
|
|
3106
3245
|
type: "dm",
|
|
3107
3246
|
requestingShip: senderShip,
|
|
3108
|
-
messagePreview:
|
|
3109
|
-
|
|
3110
|
-
|
|
3247
|
+
messagePreview: rawText,
|
|
3248
|
+
verifiedDirect: true,
|
|
3249
|
+
originalMessage: {
|
|
3111
3250
|
messageId,
|
|
3112
|
-
messageText,
|
|
3251
|
+
messageText: rawText,
|
|
3113
3252
|
messageContent: essay.content,
|
|
3114
|
-
timestamp: asFiniteNumber(essay
|
|
3115
|
-
}
|
|
3253
|
+
timestamp: asFiniteNumber(essay.sent) ?? Date.now()
|
|
3254
|
+
}
|
|
3116
3255
|
});
|
|
3117
3256
|
await queueApprovalRequest(approval);
|
|
3118
3257
|
} else runtime.log?.(`[tlon] Blocked DM from ${senderShip}: not in allowlist`);
|
|
3119
3258
|
return;
|
|
3120
3259
|
}
|
|
3121
|
-
const canExpandDmCitedNest = (nest) =>
|
|
3260
|
+
const canExpandDmCitedNest = (nest) => isOwner(senderShip) || canExpandCitedNest(nest);
|
|
3122
3261
|
const resolvedMessageText = await resolveTlonCitations(essay.content, canExpandDmCitedNest, api, runtime) + rawText;
|
|
3123
3262
|
if (ownerDm) runtime.log?.(`[tlon] Processing DM from owner ${senderShip}`);
|
|
3124
3263
|
await processMessage({
|
|
@@ -3728,6 +3867,13 @@ async function sendTlonOutbound(params, kind) {
|
|
|
3728
3867
|
story,
|
|
3729
3868
|
kind
|
|
3730
3869
|
});
|
|
3870
|
+
if (parsed.kind === "club") return await sendClubMessageWithStory({
|
|
3871
|
+
api,
|
|
3872
|
+
fromShip,
|
|
3873
|
+
clubId: parsed.clubId,
|
|
3874
|
+
story,
|
|
3875
|
+
kind
|
|
3876
|
+
});
|
|
3731
3877
|
return await sendGroupMessageWithStory({
|
|
3732
3878
|
api,
|
|
3733
3879
|
fromShip,
|
|
@@ -8,6 +8,7 @@ import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as norma
|
|
|
8
8
|
//#region extensions/tlon/src/targets.ts
|
|
9
9
|
const SHIP_RE = /^~?[a-z-]+$/i;
|
|
10
10
|
const NEST_RE = /^chat\/([^/]+)\/([^/]+)$/i;
|
|
11
|
+
const TLON_CLUB_ID_RE = /^0v(?:0|[1-9a-v][0-9a-v]{0,4}(?:\.[0-9a-v]{5})*)$/;
|
|
11
12
|
function normalizeShip(raw) {
|
|
12
13
|
const trimmed = raw.trim();
|
|
13
14
|
if (!trimmed) return trimmed;
|
|
@@ -33,6 +34,13 @@ function parseTlonTarget(raw) {
|
|
|
33
34
|
const trimmed = raw?.trim();
|
|
34
35
|
if (!trimmed) return null;
|
|
35
36
|
const withoutPrefix = trimmed.replace(/^tlon:/i, "");
|
|
37
|
+
if (withoutPrefix.startsWith("club:")) {
|
|
38
|
+
const clubId = withoutPrefix.slice(5);
|
|
39
|
+
return TLON_CLUB_ID_RE.test(clubId) ? {
|
|
40
|
+
kind: "club",
|
|
41
|
+
clubId
|
|
42
|
+
} : null;
|
|
43
|
+
}
|
|
36
44
|
const dmPrefix = withoutPrefix.match(/^dm[/:](.+)$/i);
|
|
37
45
|
if (dmPrefix) return {
|
|
38
46
|
kind: "dm",
|
|
@@ -74,13 +82,17 @@ function resolveTlonOutboundTarget(to) {
|
|
|
74
82
|
ok: true,
|
|
75
83
|
to: parsed.ship
|
|
76
84
|
};
|
|
85
|
+
if (parsed.kind === "club") return {
|
|
86
|
+
ok: true,
|
|
87
|
+
to: `club:${parsed.clubId}`
|
|
88
|
+
};
|
|
77
89
|
return {
|
|
78
90
|
ok: true,
|
|
79
91
|
to: parsed.nest
|
|
80
92
|
};
|
|
81
93
|
}
|
|
82
94
|
function formatTargetHint() {
|
|
83
|
-
return "dm/~sampel-palnet | ~sampel-palnet | chat/~host-ship/channel | group:~host-ship/channel";
|
|
95
|
+
return "dm/~sampel-palnet | ~sampel-palnet | club:0v1.abcde | chat/~host-ship/channel | group:~host-ship/channel";
|
|
84
96
|
}
|
|
85
97
|
//#endregion
|
|
86
98
|
//#region extensions/tlon/src/account-fields.ts
|
|
@@ -137,6 +149,8 @@ function resolveTlonAccount(cfg, accountId) {
|
|
|
137
149
|
dangerouslyAllowPrivateNetwork: merged.network?.dangerouslyAllowPrivateNetwork ?? null,
|
|
138
150
|
groupChannels: merged.groupChannels ?? [],
|
|
139
151
|
dmAllowlist: merged.dmAllowlist ?? [],
|
|
152
|
+
clubPolicy: merged.clubPolicy ?? null,
|
|
153
|
+
clubRules: merged.clubRules ?? {},
|
|
140
154
|
groupInviteAllowlist: merged.groupInviteAllowlist ?? [],
|
|
141
155
|
autoDiscoverChannels: merged.autoDiscoverChannels ?? null,
|
|
142
156
|
showModelSignature: merged.showModelSignature ?? null,
|
|
@@ -401,4 +415,4 @@ const tlonSetupContract = defineChannelSetupContract({
|
|
|
401
415
|
legacyAdapter: tlonSetupAdapter
|
|
402
416
|
});
|
|
403
417
|
//#endregion
|
|
404
|
-
export { isBlockedUrbitHostname as a, resolveTlonAccount as c,
|
|
418
|
+
export { isBlockedUrbitHostname as a, resolveTlonAccount as c, normalizeShip as d, parseChannelNest as f, tlonSetupContract as i, TLON_CLUB_ID_RE as l, resolveTlonOutboundTarget as m, createTlonSetupWizardBase as n, validateUrbitBaseUrl as o, parseTlonTarget as p, tlonSetupAdapter as r, listTlonAccountIds as s, applyTlonSetupConfig as t, formatTargetHint as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isBlockedUrbitHostname, c as resolveTlonAccount, n as createTlonSetupWizardBase, o as validateUrbitBaseUrl, t as applyTlonSetupConfig
|
|
1
|
+
import { a as isBlockedUrbitHostname, c as resolveTlonAccount, d as normalizeShip, n as createTlonSetupWizardBase, o as validateUrbitBaseUrl, t as applyTlonSetupConfig } from "./setup-core-DQLcZhhT.mjs";
|
|
2
2
|
import { createSetupTranslator, splitSetupEntries } from "openclaw/plugin-sdk/setup-runtime";
|
|
3
3
|
//#region extensions/tlon/src/setup-surface.ts
|
|
4
4
|
const t = createSetupTranslator();
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "./runtime-api.js";
|
|
2
|
-
import { t as tlonPlugin } from "./.setup/channel-
|
|
2
|
+
import { t as tlonPlugin } from "./.setup/channel-DUrG5iQ1.mjs";
|
|
3
3
|
import { n as setTlonRuntime } from "./.setup/runtime-Ck3lNvST.mjs";
|
|
4
4
|
export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, setTlonRuntime, ssrfPolicyFromDangerouslyAllowPrivateNetwork, tlonPlugin };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as tlonPlugin } from "./.setup/channel-
|
|
1
|
+
import { t as tlonPlugin } from "./.setup/channel-DUrG5iQ1.mjs";
|
|
2
2
|
export { tlonPlugin };
|
package/dist/setup-api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as tlonSetupAdapter } from "./.setup/setup-core-
|
|
2
|
-
import { t as tlonSetupWizard } from "./.setup/setup-surface-
|
|
1
|
+
import { r as tlonSetupAdapter } from "./.setup/setup-core-DQLcZhhT.mjs";
|
|
2
|
+
import { t as tlonSetupWizard } from "./.setup/setup-surface-BNYZOF4n.mjs";
|
|
3
3
|
export { tlonSetupAdapter, tlonSetupWizard };
|
package/dist/setup-entry.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
var setup_entry_default = defineBundledChannelSetupEntry({
|
|
5
5
|
importMetaUrl: import.meta.url,
|
|
6
6
|
plugin: {
|
|
7
|
-
specifier: fileURLToPath(new URL(".setup/api-
|
|
7
|
+
specifier: fileURLToPath(new URL(".setup/api-DmQrmK1_.mjs", import.meta.url).href),
|
|
8
8
|
exportName: "tlonPlugin"
|
|
9
9
|
}
|
|
10
10
|
});
|
package/openclaw.plugin.json
CHANGED
|
@@ -74,6 +74,28 @@
|
|
|
74
74
|
"minLength": 1
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
|
+
"clubPolicy": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"enum": [
|
|
80
|
+
"approve-once",
|
|
81
|
+
"approve-each",
|
|
82
|
+
"disabled"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"clubRules": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"propertyNames": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"pattern": "^0v(?:0|[1-9a-v][0-9a-v]{0,4}(?:\\.[0-9a-v]{5})*)$"
|
|
90
|
+
},
|
|
91
|
+
"additionalProperties": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"enum": [
|
|
94
|
+
"allow",
|
|
95
|
+
"deny"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
77
99
|
"groupInviteAllowlist": {
|
|
78
100
|
"type": "array",
|
|
79
101
|
"items": {
|
|
@@ -219,6 +241,28 @@
|
|
|
219
241
|
"minLength": 1
|
|
220
242
|
}
|
|
221
243
|
},
|
|
244
|
+
"clubPolicy": {
|
|
245
|
+
"type": "string",
|
|
246
|
+
"enum": [
|
|
247
|
+
"approve-once",
|
|
248
|
+
"approve-each",
|
|
249
|
+
"disabled"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
"clubRules": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"propertyNames": {
|
|
255
|
+
"type": "string",
|
|
256
|
+
"pattern": "^0v(?:0|[1-9a-v][0-9a-v]{0,4}(?:\\.[0-9a-v]{5})*)$"
|
|
257
|
+
},
|
|
258
|
+
"additionalProperties": {
|
|
259
|
+
"type": "string",
|
|
260
|
+
"enum": [
|
|
261
|
+
"allow",
|
|
262
|
+
"deny"
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
},
|
|
222
266
|
"groupInviteAllowlist": {
|
|
223
267
|
"type": "array",
|
|
224
268
|
"items": {
|
|
@@ -300,6 +344,22 @@
|
|
|
300
344
|
"authorization.channelRules.*.requireMentionInBotThreads": {
|
|
301
345
|
"label": "Require Mention in Bot Threads",
|
|
302
346
|
"help": "Override mention gating when this account's ship authored the thread root. False allows unmentioned replies; true requires a mention even after the bot participates. Omit to preserve existing behavior. Sender authorization still applies."
|
|
347
|
+
},
|
|
348
|
+
"clubPolicy": {
|
|
349
|
+
"label": "Tlon Group DM Policy",
|
|
350
|
+
"help": "Default: approve-once. Enable each club once for automatic replies, require approval for every message with approve-each, or disable group DMs. Club authors and participants are unverified."
|
|
351
|
+
},
|
|
352
|
+
"accounts.*.clubPolicy": {
|
|
353
|
+
"label": "Tlon Group DM Policy",
|
|
354
|
+
"help": "Default: approve-once. Enable each club once for automatic replies, require approval for every message with approve-each, or disable group DMs. Club authors and participants are unverified."
|
|
355
|
+
},
|
|
356
|
+
"clubRules": {
|
|
357
|
+
"label": "Tlon Group DM Rules",
|
|
358
|
+
"help": "Club IDs mapped to allow or deny. Allow accepts unverified input delivered under that club ID with the agent's normal permitted tools; it does not authenticate participants or grant owner authority. Deny blocks the club, not a claimed ship. Approve-each still requires each message; disabled overrides all rules."
|
|
359
|
+
},
|
|
360
|
+
"accounts.*.clubRules": {
|
|
361
|
+
"label": "Tlon Group DM Rules",
|
|
362
|
+
"help": "Club IDs mapped to allow or deny. Allow accepts unverified input delivered under that club ID with the agent's normal permitted tools; it does not authenticate participants or grant owner authority. Deny blocks the club, not a claimed ship. Approve-each still requires each message; disabled overrides all rules."
|
|
303
363
|
}
|
|
304
364
|
}
|
|
305
365
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/tlon",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.34",
|
|
4
4
|
"description": "OpenClaw Tlon/Urbit channel plugin for chat workflows.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"pluginApi": ">=2026.11.4"
|
|
125
125
|
},
|
|
126
126
|
"build": {
|
|
127
|
-
"openclawVersion": "2026.10.
|
|
127
|
+
"openclawVersion": "2026.10.34"
|
|
128
128
|
},
|
|
129
129
|
"release": {
|
|
130
130
|
"bundleRuntimeDependencies": false,
|