@openclaw/tlon 2026.5.7 → 2026.5.10-beta.1
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/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as ssrfPolicyFromAllowPrivateNetwork, i as isBlockedHostnameOrIp, n as createDedupeCache, o as ssrfPolicyFromDangerouslyAllowPrivateNetwork, r as fetchWithSsrFGuard, s as createLoggerBackedRuntime, t as SsrFBlockedError } from "./runtime-api-C0hr1Rtn.js";
|
|
2
|
-
import { t as tlonPlugin } from "./channel-
|
|
2
|
+
import { t as tlonPlugin } from "./channel-ByuwHe2i.js";
|
|
3
3
|
import { n as setTlonRuntime } from "./runtime-5FiW9E50.js";
|
|
4
4
|
export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, setTlonRuntime, ssrfPolicyFromAllowPrivateNetwork, ssrfPolicyFromDangerouslyAllowPrivateNetwork, tlonPlugin };
|
|
@@ -5,6 +5,7 @@ import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
|
5
5
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
6
6
|
import { createHybridChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
7
7
|
import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
8
|
+
import { createChannelMessageAdapterFromOutbound } from "openclaw/plugin-sdk/channel-message";
|
|
8
9
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
9
10
|
import { createRuntimeOutboundDelegates } from "openclaw/plugin-sdk/outbound-runtime";
|
|
10
11
|
import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
@@ -84,7 +85,7 @@ function resolveTlonOutboundSessionRoute(params) {
|
|
|
84
85
|
//#endregion
|
|
85
86
|
//#region extensions/tlon/src/channel.ts
|
|
86
87
|
const TLON_CHANNEL_ID = "tlon";
|
|
87
|
-
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
88
|
+
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-u89kWom3.js"));
|
|
88
89
|
const tlonSetupWizardProxy = createTlonSetupWizardBase({
|
|
89
90
|
resolveConfigured: async ({ cfg, accountId }) => await (await loadTlonChannelRuntime()).tlonSetupWizard.status.resolveConfigured({
|
|
90
91
|
cfg,
|
|
@@ -112,6 +113,27 @@ const tlonConfigAdapter = createHybridChannelConfigAdapter({
|
|
|
112
113
|
resolveAllowFrom: (account) => account.dmAllowlist,
|
|
113
114
|
formatAllowFrom: (allowFrom) => allowFrom.map((entry) => normalizeShip(String(entry))).filter(Boolean)
|
|
114
115
|
});
|
|
116
|
+
const tlonChannelOutbound = {
|
|
117
|
+
deliveryMode: "direct",
|
|
118
|
+
textChunkLimit: 1e4,
|
|
119
|
+
resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
|
|
120
|
+
deliveryCapabilities: { durableFinal: {
|
|
121
|
+
text: true,
|
|
122
|
+
media: true,
|
|
123
|
+
replyTo: true,
|
|
124
|
+
thread: true,
|
|
125
|
+
messageSendingHooks: true
|
|
126
|
+
} },
|
|
127
|
+
...createRuntimeOutboundDelegates({
|
|
128
|
+
getRuntime: loadTlonChannelRuntime,
|
|
129
|
+
sendText: { resolve: (runtime) => runtime.tlonRuntimeOutbound.sendText },
|
|
130
|
+
sendMedia: { resolve: (runtime) => runtime.tlonRuntimeOutbound.sendMedia }
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
const tlonMessageAdapter = createChannelMessageAdapterFromOutbound({
|
|
134
|
+
id: TLON_CHANNEL_ID,
|
|
135
|
+
outbound: tlonChannelOutbound
|
|
136
|
+
});
|
|
115
137
|
const tlonPlugin = createChatChannelPlugin({
|
|
116
138
|
base: {
|
|
117
139
|
id: TLON_CHANNEL_ID,
|
|
@@ -166,6 +188,7 @@ const tlonPlugin = createChatChannelPlugin({
|
|
|
166
188
|
},
|
|
167
189
|
resolveOutboundSessionRoute: (params) => resolveTlonOutboundSessionRoute(params)
|
|
168
190
|
},
|
|
191
|
+
message: tlonMessageAdapter,
|
|
169
192
|
status: createComputedAccountStatusAdapter({
|
|
170
193
|
defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID),
|
|
171
194
|
collectStatusIssues: (accounts) => {
|
|
@@ -207,16 +230,7 @@ const tlonPlugin = createChatChannelPlugin({
|
|
|
207
230
|
}),
|
|
208
231
|
gateway: { startAccount: async (ctx) => await (await loadTlonChannelRuntime()).startTlonGatewayAccount(ctx) }
|
|
209
232
|
},
|
|
210
|
-
outbound:
|
|
211
|
-
deliveryMode: "direct",
|
|
212
|
-
textChunkLimit: 1e4,
|
|
213
|
-
resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
|
|
214
|
-
...createRuntimeOutboundDelegates({
|
|
215
|
-
getRuntime: loadTlonChannelRuntime,
|
|
216
|
-
sendText: { resolve: (runtime) => runtime.tlonRuntimeOutbound.sendText },
|
|
217
|
-
sendMedia: { resolve: (runtime) => runtime.tlonRuntimeOutbound.sendMedia }
|
|
218
|
-
})
|
|
219
|
-
}
|
|
233
|
+
outbound: tlonChannelOutbound
|
|
220
234
|
});
|
|
221
235
|
//#endregion
|
|
222
236
|
export { tlonPlugin as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as tlonPlugin } from "./channel-
|
|
1
|
+
import { t as tlonPlugin } from "./channel-ByuwHe2i.js";
|
|
2
2
|
export { tlonPlugin };
|
|
@@ -3,13 +3,16 @@ import { c as validateUrbitBaseUrl, d as formatTargetHint, f as normalizeShip, h
|
|
|
3
3
|
import { t as getTlonRuntime } from "./runtime-5FiW9E50.js";
|
|
4
4
|
import { t as tlonSetupWizard } from "./setup-surface-FxNMaluC.js";
|
|
5
5
|
import { fetchWithSsrFGuard, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
6
|
+
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-message";
|
|
6
7
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
|
7
8
|
import crypto, { randomBytes, randomUUID } from "node:crypto";
|
|
8
9
|
import { da, scot } from "@urbit/aura";
|
|
9
10
|
import { Readable } from "node:stream";
|
|
11
|
+
import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
10
12
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
11
13
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
12
14
|
import * as path from "node:path";
|
|
15
|
+
import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
|
|
13
16
|
import { MAX_IMAGE_BYTES, fetchRemoteMedia, saveMediaBuffer } from "openclaw/plugin-sdk/media-runtime";
|
|
14
17
|
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
15
18
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
@@ -326,11 +329,6 @@ function getUrbitContext(url, ship) {
|
|
|
326
329
|
ship: normalizeUrbitShip(ship, validated.hostname)
|
|
327
330
|
};
|
|
328
331
|
}
|
|
329
|
-
/**
|
|
330
|
-
* Get the default SSRF policy for image uploads.
|
|
331
|
-
* Uses a restrictive policy that blocks private networks by default.
|
|
332
|
-
*/
|
|
333
|
-
function getDefaultSsrFPolicy() {}
|
|
334
332
|
//#endregion
|
|
335
333
|
//#region extensions/tlon/src/urbit/story.ts
|
|
336
334
|
/**
|
|
@@ -528,15 +526,27 @@ function markdownToStory(markdown) {
|
|
|
528
526
|
}
|
|
529
527
|
//#endregion
|
|
530
528
|
//#region extensions/tlon/src/urbit/send.ts
|
|
529
|
+
function createTlonSendReceipt(params) {
|
|
530
|
+
return createMessageReceiptFromOutboundResults({
|
|
531
|
+
results: [{
|
|
532
|
+
channel: "tlon",
|
|
533
|
+
messageId: params.messageId,
|
|
534
|
+
conversationId: params.conversationId
|
|
535
|
+
}],
|
|
536
|
+
threadId: params.conversationId,
|
|
537
|
+
kind: params.kind
|
|
538
|
+
});
|
|
539
|
+
}
|
|
531
540
|
async function sendDm({ api, fromShip, toShip, text }) {
|
|
532
541
|
return sendDmWithStory({
|
|
533
542
|
api,
|
|
534
543
|
fromShip,
|
|
535
544
|
toShip,
|
|
536
|
-
story: markdownToStory(text)
|
|
545
|
+
story: markdownToStory(text),
|
|
546
|
+
kind: "text"
|
|
537
547
|
});
|
|
538
548
|
}
|
|
539
|
-
async function sendDmWithStory({ api, fromShip, toShip, story }) {
|
|
549
|
+
async function sendDmWithStory({ api, fromShip, toShip, story, kind = "unknown" }) {
|
|
540
550
|
const sentAt = Date.now();
|
|
541
551
|
const id = `${fromShip}/${scot("ud", da.fromUnix(sentAt))}`;
|
|
542
552
|
const action = {
|
|
@@ -561,7 +571,12 @@ async function sendDmWithStory({ api, fromShip, toShip, story }) {
|
|
|
561
571
|
});
|
|
562
572
|
return {
|
|
563
573
|
channel: "tlon",
|
|
564
|
-
messageId: id
|
|
574
|
+
messageId: id,
|
|
575
|
+
receipt: createTlonSendReceipt({
|
|
576
|
+
messageId: id,
|
|
577
|
+
conversationId: toShip,
|
|
578
|
+
kind
|
|
579
|
+
})
|
|
565
580
|
};
|
|
566
581
|
}
|
|
567
582
|
async function sendGroupMessage({ api, fromShip, hostShip, channelName, text, replyToId }) {
|
|
@@ -571,10 +586,11 @@ async function sendGroupMessage({ api, fromShip, hostShip, channelName, text, re
|
|
|
571
586
|
hostShip,
|
|
572
587
|
channelName,
|
|
573
588
|
story: markdownToStory(text),
|
|
574
|
-
replyToId
|
|
589
|
+
replyToId,
|
|
590
|
+
kind: "text"
|
|
575
591
|
});
|
|
576
592
|
}
|
|
577
|
-
async function sendGroupMessageWithStory({ api, fromShip, hostShip, channelName, story, replyToId }) {
|
|
593
|
+
async function sendGroupMessageWithStory({ api, fromShip, hostShip, channelName, story, replyToId, kind = "unknown" }) {
|
|
578
594
|
const sentAt = Date.now();
|
|
579
595
|
let formattedReplyId = replyToId;
|
|
580
596
|
if (replyToId && /^\d+$/.test(replyToId)) try {
|
|
@@ -603,9 +619,15 @@ async function sendGroupMessageWithStory({ api, fromShip, hostShip, channelName,
|
|
|
603
619
|
mark: "channel-action-1",
|
|
604
620
|
json: action
|
|
605
621
|
});
|
|
622
|
+
const messageId = `${fromShip}/${sentAt}`;
|
|
606
623
|
return {
|
|
607
624
|
channel: "tlon",
|
|
608
|
-
messageId
|
|
625
|
+
messageId,
|
|
626
|
+
receipt: createTlonSendReceipt({
|
|
627
|
+
messageId,
|
|
628
|
+
conversationId: `${hostShip}/${channelName}`,
|
|
629
|
+
kind
|
|
630
|
+
})
|
|
609
631
|
};
|
|
610
632
|
}
|
|
611
633
|
/**
|
|
@@ -1063,9 +1085,6 @@ var UrbitSSEClient = class {
|
|
|
1063
1085
|
* When an unknown ship tries to interact with the bot, the owner receives
|
|
1064
1086
|
* a notification and can approve or deny the request.
|
|
1065
1087
|
*/
|
|
1066
|
-
function normalizeLowercaseStringOrEmpty$1(value) {
|
|
1067
|
-
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
1068
|
-
}
|
|
1069
1088
|
/**
|
|
1070
1089
|
* Generate a unique approval ID in the format: {type}-{timestamp}-{shortHash}
|
|
1071
1090
|
*/
|
|
@@ -1114,7 +1133,7 @@ function formatApprovalRequest(approval) {
|
|
|
1114
1133
|
* - "block" permanently blocks the ship via Tlon's native blocking
|
|
1115
1134
|
*/
|
|
1116
1135
|
function parseApprovalResponse(text) {
|
|
1117
|
-
const match = normalizeLowercaseStringOrEmpty
|
|
1136
|
+
const match = normalizeLowercaseStringOrEmpty(text).match(/^(approve|deny|block)(?:\s+(.+))?$/);
|
|
1118
1137
|
if (!match) return null;
|
|
1119
1138
|
return {
|
|
1120
1139
|
action: match[1],
|
|
@@ -1126,7 +1145,7 @@ function parseApprovalResponse(text) {
|
|
|
1126
1145
|
* Used to determine if we should intercept the message before normal processing.
|
|
1127
1146
|
*/
|
|
1128
1147
|
function isApprovalResponse(text) {
|
|
1129
|
-
const trimmed = normalizeLowercaseStringOrEmpty
|
|
1148
|
+
const trimmed = normalizeLowercaseStringOrEmpty(text);
|
|
1130
1149
|
return trimmed.startsWith("approve") || trimmed.startsWith("deny") || trimmed.startsWith("block");
|
|
1131
1150
|
}
|
|
1132
1151
|
/**
|
|
@@ -1169,7 +1188,7 @@ function formatApprovalConfirmation(approval, action) {
|
|
|
1169
1188
|
* - "pending" - list all pending approvals
|
|
1170
1189
|
*/
|
|
1171
1190
|
function parseAdminCommand(text) {
|
|
1172
|
-
const trimmed = normalizeLowercaseStringOrEmpty
|
|
1191
|
+
const trimmed = normalizeLowercaseStringOrEmpty(text);
|
|
1173
1192
|
if (trimmed === "blocked") return { type: "blocked" };
|
|
1174
1193
|
if (trimmed === "pending") return { type: "pending" };
|
|
1175
1194
|
const unblockMatch = trimmed.match(/^unblock\s+(~[\w-]+)$/);
|
|
@@ -1531,35 +1550,58 @@ function isBotMentioned(messageText, botShipName, nickname) {
|
|
|
1531
1550
|
}
|
|
1532
1551
|
return false;
|
|
1533
1552
|
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Strip bot ship mention from message text for command detection.
|
|
1536
|
-
* "~bot-ship /status" → "/status"
|
|
1537
|
-
*/
|
|
1538
1553
|
function stripBotMention(messageText, botShipName) {
|
|
1539
1554
|
if (!messageText || !botShipName) return messageText;
|
|
1540
1555
|
return messageText.replace(normalizeShip(botShipName), "").trim();
|
|
1541
1556
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1557
|
+
const tlonIngressIdentity = {
|
|
1558
|
+
key: "sender-ship",
|
|
1559
|
+
normalize: normalizeShip,
|
|
1560
|
+
sensitivity: "pii",
|
|
1561
|
+
isWildcardEntry: () => false,
|
|
1562
|
+
entryIdPrefix: "tlon-entry"
|
|
1563
|
+
};
|
|
1564
|
+
async function isDmAllowedWithIngress(senderShip, allowlist) {
|
|
1565
|
+
return (await resolveStableChannelMessageIngress({
|
|
1566
|
+
channelId: "tlon",
|
|
1567
|
+
accountId: "default",
|
|
1568
|
+
identity: tlonIngressIdentity,
|
|
1569
|
+
subject: { stableId: senderShip },
|
|
1570
|
+
conversation: {
|
|
1571
|
+
kind: "direct",
|
|
1572
|
+
id: "direct"
|
|
1573
|
+
},
|
|
1574
|
+
dmPolicy: "allowlist",
|
|
1575
|
+
allowFrom: allowlist ?? []
|
|
1576
|
+
})).senderAccess.allowed;
|
|
1577
|
+
}
|
|
1578
|
+
async function resolveTlonCommandAuthorizationWithIngress(params) {
|
|
1579
|
+
const normalizedOwner = params.ownerShip ? normalizeShip(params.ownerShip) : null;
|
|
1580
|
+
return await resolveStableChannelMessageIngress({
|
|
1581
|
+
channelId: "tlon",
|
|
1582
|
+
accountId: "default",
|
|
1583
|
+
identity: tlonIngressIdentity,
|
|
1584
|
+
useAccessGroups: params.useAccessGroups,
|
|
1585
|
+
subject: { stableId: params.senderShip },
|
|
1586
|
+
conversation: {
|
|
1587
|
+
kind: "direct",
|
|
1588
|
+
id: "command"
|
|
1589
|
+
},
|
|
1590
|
+
event: {
|
|
1591
|
+
authMode: "none",
|
|
1592
|
+
mayPair: false
|
|
1593
|
+
},
|
|
1594
|
+
dmPolicy: "allowlist",
|
|
1595
|
+
groupPolicy: "open",
|
|
1596
|
+
allowFrom: normalizedOwner ? [normalizedOwner] : [],
|
|
1597
|
+
command: {}
|
|
1598
|
+
});
|
|
1546
1599
|
}
|
|
1547
|
-
/**
|
|
1548
|
-
* Check if a group invite from a ship should be auto-accepted.
|
|
1549
|
-
*
|
|
1550
|
-
* SECURITY: Fail-safe to deny. If allowlist is empty or undefined,
|
|
1551
|
-
* ALL invites are rejected - even if autoAcceptGroupInvites is enabled.
|
|
1552
|
-
* This prevents misconfigured bots from accepting malicious invites.
|
|
1553
|
-
*/
|
|
1554
1600
|
function isGroupInviteAllowed(inviterShip, allowlist) {
|
|
1555
1601
|
if (!allowlist || allowlist.length === 0) return false;
|
|
1556
1602
|
const normalizedInviter = normalizeShip(inviterShip);
|
|
1557
1603
|
return allowlist.map((ship) => normalizeShip(ship)).some((ship) => ship === normalizedInviter);
|
|
1558
1604
|
}
|
|
1559
|
-
/**
|
|
1560
|
-
* Resolve quoted/cited content only after the caller has passed authorization.
|
|
1561
|
-
* Unauthorized paths must keep raw text and must not trigger cross-channel cite fetches.
|
|
1562
|
-
*/
|
|
1563
1605
|
async function resolveAuthorizedMessageText(params) {
|
|
1564
1606
|
const { rawText, content, authorizedForCites, resolveAllCites } = params;
|
|
1565
1607
|
if (!authorizedForCites) return rawText;
|
|
@@ -1911,7 +1953,7 @@ async function downloadMedia(url, mediaDir) {
|
|
|
1911
1953
|
url,
|
|
1912
1954
|
maxBytes: MAX_IMAGE_BYTES,
|
|
1913
1955
|
readIdleTimeoutMs: TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS,
|
|
1914
|
-
ssrfPolicy:
|
|
1956
|
+
ssrfPolicy: void 0,
|
|
1915
1957
|
requestInit: { method: "GET" }
|
|
1916
1958
|
});
|
|
1917
1959
|
if (!mediaDir) {
|
|
@@ -1941,18 +1983,7 @@ function getExtensionFromFileName(fileName) {
|
|
|
1941
1983
|
return path.extname(fileName).replace(/^\./, "") || null;
|
|
1942
1984
|
}
|
|
1943
1985
|
function getExtensionFromContentType(contentType) {
|
|
1944
|
-
return
|
|
1945
|
-
"image/jpeg": "jpg",
|
|
1946
|
-
"image/jpg": "jpg",
|
|
1947
|
-
"image/png": "png",
|
|
1948
|
-
"image/gif": "gif",
|
|
1949
|
-
"image/webp": "webp",
|
|
1950
|
-
"image/svg+xml": "svg",
|
|
1951
|
-
"video/mp4": "mp4",
|
|
1952
|
-
"video/webm": "webm",
|
|
1953
|
-
"audio/mpeg": "mp3",
|
|
1954
|
-
"audio/ogg": "ogg"
|
|
1955
|
-
}[contentType.split(";")[0].trim()] ?? null;
|
|
1986
|
+
return extensionForMime(contentType)?.replace(/^\./u, "") ?? null;
|
|
1956
1987
|
}
|
|
1957
1988
|
function getExtensionFromUrl(url) {
|
|
1958
1989
|
try {
|
|
@@ -2390,14 +2421,11 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2390
2421
|
let commandAuthorized = false;
|
|
2391
2422
|
if (shouldComputeAuth) {
|
|
2392
2423
|
const useAccessGroups = cfg.commands?.useAccessGroups !== false;
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
allowed: senderIsOwner
|
|
2399
|
-
}]
|
|
2400
|
-
});
|
|
2424
|
+
commandAuthorized = (await resolveTlonCommandAuthorizationWithIngress({
|
|
2425
|
+
senderShip,
|
|
2426
|
+
ownerShip: effectiveOwnerShip,
|
|
2427
|
+
useAccessGroups
|
|
2428
|
+
})).commandAccess.authorized;
|
|
2401
2429
|
if (!commandAuthorized) console.log(`[tlon] Command attempt denied: ${senderShip} is not owner (owner=${effectiveOwnerShip ?? "not configured"})`);
|
|
2402
2430
|
}
|
|
2403
2431
|
let bodyWithAttachments = messageText;
|
|
@@ -2410,11 +2438,6 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2410
2438
|
});
|
|
2411
2439
|
const commandBody = isGroup ? stripBotMention(messageText, botShipName) : messageText;
|
|
2412
2440
|
const tlonConversationId = isGroup ? groupChannel ?? channelNest ?? senderShip : senderShip;
|
|
2413
|
-
const rawTurnMessage = {
|
|
2414
|
-
messageId,
|
|
2415
|
-
messageText,
|
|
2416
|
-
timestamp
|
|
2417
|
-
};
|
|
2418
2441
|
const ctxPayload = core.channel.turn.buildContext({
|
|
2419
2442
|
channel: "tlon",
|
|
2420
2443
|
accountId: route.accountId,
|
|
@@ -2465,75 +2488,83 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2465
2488
|
const responsePrefix = core.channel.reply.resolveEffectiveMessagesConfig(cfg, route.agentId).responsePrefix;
|
|
2466
2489
|
const humanDelay = core.channel.reply.resolveHumanDelayConfig(cfg, route.agentId);
|
|
2467
2490
|
const storePath = core.channel.session.resolveStorePath(cfg.session?.store, { agentId: route.agentId });
|
|
2468
|
-
|
|
2491
|
+
const deliveryTarget = isGroup ? groupChannel : senderShip;
|
|
2492
|
+
const prepareReplyPayload = (payload) => {
|
|
2493
|
+
const replyText = payload.text;
|
|
2494
|
+
if (!replyText) return payload;
|
|
2495
|
+
if (!effectiveShowModelSig) return payload;
|
|
2496
|
+
const extPayload = payload;
|
|
2497
|
+
const defaultModel = cfg.agents?.defaults?.model;
|
|
2498
|
+
const modelInfo = extPayload.metadata?.model || extPayload.model || (typeof defaultModel === "string" ? defaultModel : defaultModel?.primary);
|
|
2499
|
+
return {
|
|
2500
|
+
...payload,
|
|
2501
|
+
text: `${replyText}\n\n_[Generated by ${formatModelName(modelInfo)}]_`
|
|
2502
|
+
};
|
|
2503
|
+
};
|
|
2504
|
+
const rememberThreadParticipation = (result) => {
|
|
2505
|
+
if (!isGroup || !groupChannel || !parentId || result?.visibleReplySent === false) return;
|
|
2506
|
+
participatedThreads.add(parentId);
|
|
2507
|
+
runtime.log?.(`[tlon] Now tracking thread for future replies: ${parentId}`);
|
|
2508
|
+
};
|
|
2509
|
+
await core.channel.turn.runAssembled({
|
|
2469
2510
|
channel: "tlon",
|
|
2470
2511
|
accountId: route.accountId,
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
},
|
|
2528
|
-
dispatcherOptions: {
|
|
2529
|
-
responsePrefix,
|
|
2530
|
-
humanDelay
|
|
2531
|
-
},
|
|
2532
|
-
record: { onRecordError: (err) => {
|
|
2533
|
-
runtime.error?.(`[tlon] failed updating session meta: ${String(err)}`);
|
|
2534
|
-
} }
|
|
2535
|
-
})
|
|
2536
|
-
}
|
|
2512
|
+
cfg,
|
|
2513
|
+
agentId: route.agentId,
|
|
2514
|
+
routeSessionKey: route.sessionKey,
|
|
2515
|
+
storePath,
|
|
2516
|
+
ctxPayload,
|
|
2517
|
+
recordInboundSession: core.channel.session.recordInboundSession,
|
|
2518
|
+
dispatchReplyWithBufferedBlockDispatcher: core.channel.reply.dispatchReplyWithBufferedBlockDispatcher,
|
|
2519
|
+
delivery: {
|
|
2520
|
+
preparePayload: prepareReplyPayload,
|
|
2521
|
+
durable: deliveryTarget ? () => ({
|
|
2522
|
+
to: deliveryTarget,
|
|
2523
|
+
replyToId: parentId ?? void 0,
|
|
2524
|
+
threadId: parentId ?? void 0
|
|
2525
|
+
}) : false,
|
|
2526
|
+
deliver: async (payload) => {
|
|
2527
|
+
const replyText = payload.text;
|
|
2528
|
+
if (!replyText) return { visibleReplySent: false };
|
|
2529
|
+
if (isGroup && groupChannel) {
|
|
2530
|
+
const parsed = parseChannelNest(groupChannel);
|
|
2531
|
+
if (!parsed) return { visibleReplySent: false };
|
|
2532
|
+
await sendGroupMessage({
|
|
2533
|
+
api,
|
|
2534
|
+
fromShip: botShipName,
|
|
2535
|
+
hostShip: parsed.hostShip,
|
|
2536
|
+
channelName: parsed.channelName,
|
|
2537
|
+
text: replyText,
|
|
2538
|
+
replyToId: parentId ?? void 0
|
|
2539
|
+
});
|
|
2540
|
+
return {
|
|
2541
|
+
visibleReplySent: true,
|
|
2542
|
+
replyToId: parentId ?? void 0
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
await sendDm({
|
|
2546
|
+
api,
|
|
2547
|
+
fromShip: botShipName,
|
|
2548
|
+
toShip: senderShip,
|
|
2549
|
+
text: replyText
|
|
2550
|
+
});
|
|
2551
|
+
return { visibleReplySent: true };
|
|
2552
|
+
},
|
|
2553
|
+
onDelivered: (_payload, _info, result) => {
|
|
2554
|
+
rememberThreadParticipation(result);
|
|
2555
|
+
},
|
|
2556
|
+
onError: (err, info) => {
|
|
2557
|
+
const dispatchDuration = Date.now() - dispatchStartTime;
|
|
2558
|
+
runtime.error?.(`[tlon] ${info.kind} reply failed after ${dispatchDuration}ms: ${String(err)}`);
|
|
2559
|
+
}
|
|
2560
|
+
},
|
|
2561
|
+
dispatcherOptions: {
|
|
2562
|
+
responsePrefix,
|
|
2563
|
+
humanDelay
|
|
2564
|
+
},
|
|
2565
|
+
record: { onRecordError: (err) => {
|
|
2566
|
+
runtime.error?.(`[tlon] failed updating session meta: ${String(err)}`);
|
|
2567
|
+
} }
|
|
2537
2568
|
});
|
|
2538
2569
|
};
|
|
2539
2570
|
const watchedChannels = new Set(groupChannels);
|
|
@@ -2719,7 +2750,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2719
2750
|
}
|
|
2720
2751
|
continue;
|
|
2721
2752
|
}
|
|
2722
|
-
if (effectiveAutoAcceptDmInvites &&
|
|
2753
|
+
if (effectiveAutoAcceptDmInvites && await isDmAllowedWithIngress(ship, effectiveDmAllowlist)) {
|
|
2723
2754
|
try {
|
|
2724
2755
|
await api.poke({
|
|
2725
2756
|
app: "chat",
|
|
@@ -2736,7 +2767,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2736
2767
|
}
|
|
2737
2768
|
continue;
|
|
2738
2769
|
}
|
|
2739
|
-
if (effectiveOwnerShip && !
|
|
2770
|
+
if (effectiveOwnerShip && !await isDmAllowedWithIngress(ship, effectiveDmAllowlist)) {
|
|
2740
2771
|
await queueApprovalRequest(createPendingApproval({
|
|
2741
2772
|
type: "dm",
|
|
2742
2773
|
requestingShip: ship,
|
|
@@ -2798,7 +2829,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2798
2829
|
});
|
|
2799
2830
|
return;
|
|
2800
2831
|
}
|
|
2801
|
-
if (!
|
|
2832
|
+
if (!await isDmAllowedWithIngress(senderShip, effectiveDmAllowlist)) {
|
|
2802
2833
|
if (effectiveOwnerShip) await queueApprovalRequest(createPendingApproval({
|
|
2803
2834
|
type: "dm",
|
|
2804
2835
|
requestingShip: senderShip,
|
|
@@ -3124,15 +3155,6 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3124
3155
|
//#endregion
|
|
3125
3156
|
//#region extensions/tlon/src/tlon-api.ts
|
|
3126
3157
|
const MEMEX_BASE_URL = "https://memex.tlon.network";
|
|
3127
|
-
const mimeToExt = {
|
|
3128
|
-
"image/gif": ".gif",
|
|
3129
|
-
"image/heic": ".heic",
|
|
3130
|
-
"image/heif": ".heif",
|
|
3131
|
-
"image/jpeg": ".jpg",
|
|
3132
|
-
"image/jpg": ".jpg",
|
|
3133
|
-
"image/png": ".png",
|
|
3134
|
-
"image/webp": ".webp"
|
|
3135
|
-
};
|
|
3136
3158
|
let currentClientConfig = null;
|
|
3137
3159
|
function configureClient(params) {
|
|
3138
3160
|
currentClientConfig = {
|
|
@@ -3145,8 +3167,7 @@ function requireClientConfig() {
|
|
|
3145
3167
|
return currentClientConfig;
|
|
3146
3168
|
}
|
|
3147
3169
|
function getExtensionFromMimeType(mimeType) {
|
|
3148
|
-
|
|
3149
|
-
return mimeToExt[normalizeLowercaseStringOrEmpty(mimeType)] || ".jpg";
|
|
3170
|
+
return extensionForMime(mimeType) || ".jpg";
|
|
3150
3171
|
}
|
|
3151
3172
|
function hasCustomS3Creds(credentials) {
|
|
3152
3173
|
return Boolean(credentials?.accessKeyId && credentials?.endpoint && credentials?.secretAccessKey);
|
|
@@ -3378,7 +3399,7 @@ async function uploadImageFromUrl(imageUrl) {
|
|
|
3378
3399
|
const { response, release } = await fetchWithSsrFGuard({
|
|
3379
3400
|
url: imageUrl,
|
|
3380
3401
|
init: { method: "GET" },
|
|
3381
|
-
policy:
|
|
3402
|
+
policy: void 0,
|
|
3382
3403
|
auditContext: "tlon-upload-image"
|
|
3383
3404
|
});
|
|
3384
3405
|
try {
|
|
@@ -3477,6 +3498,13 @@ const tlonRuntimeOutbound = {
|
|
|
3477
3498
|
deliveryMode: "direct",
|
|
3478
3499
|
textChunkLimit: 1e4,
|
|
3479
3500
|
resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
|
|
3501
|
+
deliveryCapabilities: { durableFinal: {
|
|
3502
|
+
text: true,
|
|
3503
|
+
media: true,
|
|
3504
|
+
replyTo: true,
|
|
3505
|
+
thread: true,
|
|
3506
|
+
messageSendingHooks: true
|
|
3507
|
+
} },
|
|
3480
3508
|
sendText: async ({ cfg, to, text, accountId, replyToId, threadId }) => {
|
|
3481
3509
|
const { account, parsed } = resolveOutboundContext({
|
|
3482
3510
|
cfg,
|
|
@@ -3522,7 +3550,8 @@ const tlonRuntimeOutbound = {
|
|
|
3522
3550
|
api,
|
|
3523
3551
|
fromShip,
|
|
3524
3552
|
toShip: parsed.ship,
|
|
3525
|
-
story
|
|
3553
|
+
story,
|
|
3554
|
+
kind: "media"
|
|
3526
3555
|
});
|
|
3527
3556
|
return await sendGroupMessageWithStory({
|
|
3528
3557
|
api,
|
|
@@ -3530,7 +3559,8 @@ const tlonRuntimeOutbound = {
|
|
|
3530
3559
|
hostShip: parsed.hostShip,
|
|
3531
3560
|
channelName: parsed.channelName,
|
|
3532
3561
|
story,
|
|
3533
|
-
replyToId: resolveReplyId(replyToId, threadId)
|
|
3562
|
+
replyToId: resolveReplyId(replyToId, threadId),
|
|
3563
|
+
kind: "media"
|
|
3534
3564
|
});
|
|
3535
3565
|
});
|
|
3536
3566
|
}
|
package/dist/test-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as tlonPlugin } from "./channel-
|
|
1
|
+
import { t as tlonPlugin } from "./channel-ByuwHe2i.js";
|
|
2
2
|
export { tlonPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/tlon",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.10-beta.1",
|
|
4
4
|
"description": "OpenClaw Tlon/Urbit channel plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@aws-sdk/client-s3": "3.
|
|
12
|
-
"@aws-sdk/s3-request-presigner": "3.
|
|
13
|
-
"@tloncorp/tlon-skill": "0.3.
|
|
11
|
+
"@aws-sdk/client-s3": "3.1045.0",
|
|
12
|
+
"@aws-sdk/s3-request-presigner": "3.1045.0",
|
|
13
|
+
"@tloncorp/tlon-skill": "0.3.6",
|
|
14
14
|
"@urbit/aura": "^3.0.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"openclaw": "workspace:*"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"openclaw": ">=2026.5.
|
|
21
|
+
"openclaw": ">=2026.5.10-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependenciesMeta": {
|
|
24
24
|
"openclaw": {
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"minHostVersion": ">=2026.4.10"
|
|
73
73
|
},
|
|
74
74
|
"compat": {
|
|
75
|
-
"pluginApi": ">=2026.5.
|
|
75
|
+
"pluginApi": ">=2026.5.10-beta.1"
|
|
76
76
|
},
|
|
77
77
|
"build": {
|
|
78
|
-
"openclawVersion": "2026.5.
|
|
78
|
+
"openclawVersion": "2026.5.10-beta.1"
|
|
79
79
|
},
|
|
80
80
|
"release": {
|
|
81
81
|
"publishToClawHub": true,
|